Match and link CMRay

Former-commit-id: 166a545542
This commit is contained in:
Phillip Stephens 2022-10-06 08:36:33 -07:00
parent 64037a01e3
commit 61eee21924
4 changed files with 49 additions and 1 deletions

View File

@ -28,6 +28,7 @@ COMPLETE_OBJECTS = [
"MetroidPrime/HUD/CHUDMemoParms", "MetroidPrime/HUD/CHUDMemoParms",
"MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint", "MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint",
"Weapons/IWeaponRenderer", "Weapons/IWeaponRenderer",
"Collision/CMRay",
"Kyoto/Basics/CStopwatch", "Kyoto/Basics/CStopwatch",
"Kyoto/Basics/COsContextDolphin", "Kyoto/Basics/COsContextDolphin",
"Kyoto/Basics/CSWDataDolphin", "Kyoto/Basics/CSWDataDolphin",

View File

@ -0,0 +1,22 @@
#ifndef __CMRAY_HPP__
#define __CMRAY_HPP__
#include "Kyoto/Math/CVector3f.hpp"
class CTransform4f;
class CMRay {
public:
CMRay(const CVector3f& start, const CVector3f& end, float, float);
CMRay(const CVector3f& start, const CVector3f& end, float);
CMRay GetInvUnscaledTransformRay(const CTransform4f&) const;
private:
CVector3f mStart;
CVector3f mEnd;
CVector3f mDelta;
float mLength;
float mInvLength;
CVector3f mDir;
};
#endif // __CMRAY_HPP__

View File

@ -415,7 +415,7 @@ COLLISION :=\
$(BUILD_DIR)/asm/Collision/CCollidableSphere.o\ $(BUILD_DIR)/asm/Collision/CCollidableSphere.o\
$(BUILD_DIR)/asm/Collision/CMaterialFilter.o\ $(BUILD_DIR)/asm/Collision/CMaterialFilter.o\
$(BUILD_DIR)/asm/Collision/COBBox.o\ $(BUILD_DIR)/asm/Collision/COBBox.o\
$(BUILD_DIR)/asm/Collision/CMRay.o\ $(BUILD_DIR)/src/Collision/CMRay.o\
KYOTO_1 :=\ KYOTO_1 :=\
$(BUILD_DIR)/asm/Kyoto/Basics/CBasics.o\ $(BUILD_DIR)/asm/Kyoto/Basics/CBasics.o\

25
src/Collision/CMRay.cpp Normal file
View File

@ -0,0 +1,25 @@
#include "Collision/CMRay.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
CMRay::CMRay(const CVector3f& start, const CVector3f& end, float length, float invLength)
: mStart(start)
, mEnd(end)
, mDelta(mEnd - mStart)
, mLength(length)
, mInvLength(invLength)
, mDir(mInvLength * mDelta) {
}
CMRay::CMRay(const CVector3f& start, const CVector3f& dir, float length)
: mStart(start)
, mEnd(start + length * dir)
, mDelta(mEnd - mStart)
, mLength(length)
, mInvLength(1.f / length)
, mDir(dir) {}
CMRay CMRay::GetInvUnscaledTransformRay(const CTransform4f& xf) const {
CTransform4f invXf = xf.GetQuickInverse();
return CMRay(invXf * mStart, invXf * mEnd, mLength, mInvLength);
}