mirror of https://github.com/PrimeDecomp/prime.git
Match and link CCollisionInfo
This commit is contained in:
parent
799ce41ad0
commit
dbaf1f40ca
|
@ -458,8 +458,8 @@ lbl_802D5ADC:
|
||||||
/* 802D5B6C 002D2ACC 38 21 01 A0 */ addi r1, r1, 0x1a0
|
/* 802D5B6C 002D2ACC 38 21 01 A0 */ addi r1, r1, 0x1a0
|
||||||
/* 802D5B70 002D2AD0 4E 80 00 20 */ blr
|
/* 802D5B70 002D2AD0 4E 80 00 20 */ blr
|
||||||
|
|
||||||
.global AABoxIntersectsBox__6COBBoxFRC6CAABox
|
.global AABoxIntersectsBox__6COBBoxCFRC6CAABox
|
||||||
AABoxIntersectsBox__6COBBoxFRC6CAABox:
|
AABoxIntersectsBox__6COBBoxCFRC6CAABox:
|
||||||
/* 802D5B74 002D2AD4 94 21 FF B0 */ stwu r1, -0x50(r1)
|
/* 802D5B74 002D2AD4 94 21 FF B0 */ stwu r1, -0x50(r1)
|
||||||
/* 802D5B78 002D2AD8 7C 08 02 A6 */ mflr r0
|
/* 802D5B78 002D2AD8 7C 08 02 A6 */ mflr r0
|
||||||
/* 802D5B7C 002D2ADC 3C A0 80 5A */ lis r5, sIdentity__12CTransform4f@ha
|
/* 802D5B7C 002D2ADC 3C A0 80 5A */ lis r5, sIdentity__12CTransform4f@ha
|
||||||
|
@ -785,4 +785,3 @@ lbl_805AE268:
|
||||||
# ROM: 0x3FAB08
|
# ROM: 0x3FAB08
|
||||||
.float -1.0
|
.float -1.0
|
||||||
.4byte 0
|
.4byte 0
|
||||||
|
|
||||||
|
|
|
@ -408,7 +408,7 @@ lbl_801979D8:
|
||||||
lbl_80197A00:
|
lbl_80197A00:
|
||||||
/* 80197A00 00194960 38 61 01 F8 */ addi r3, r1, 0x1f8
|
/* 80197A00 00194960 38 61 01 F8 */ addi r3, r1, 0x1f8
|
||||||
/* 80197A04 00194964 38 81 00 88 */ addi r4, r1, 0x88
|
/* 80197A04 00194964 38 81 00 88 */ addi r4, r1, 0x88
|
||||||
/* 80197A08 00194968 48 13 E1 6D */ bl AABoxIntersectsBox__6COBBoxFRC6CAABox
|
/* 80197A08 00194968 48 13 E1 6D */ bl AABoxIntersectsBox__6COBBoxCFRC6CAABox
|
||||||
/* 80197A0C 0019496C 54 60 06 3F */ clrlwi. r0, r3, 0x18
|
/* 80197A0C 0019496C 54 60 06 3F */ clrlwi. r0, r3, 0x18
|
||||||
/* 80197A10 00194970 41 82 02 A8 */ beq lbl_80197CB8
|
/* 80197A10 00194970 41 82 02 A8 */ beq lbl_80197CB8
|
||||||
/* 80197A14 00194974 38 61 01 08 */ addi r3, r1, 0x108
|
/* 80197A14 00194974 38 61 01 08 */ addi r3, r1, 0x108
|
||||||
|
|
|
@ -30,6 +30,7 @@ COMPLETE_OBJECTS = [
|
||||||
"Weapons/IWeaponRenderer",
|
"Weapons/IWeaponRenderer",
|
||||||
"Collision/CMaterialList",
|
"Collision/CMaterialList",
|
||||||
"Collision/CMaterialFilter",
|
"Collision/CMaterialFilter",
|
||||||
|
"Collision/CCollisionInfo",
|
||||||
"Collision/CMRay",
|
"Collision/CMRay",
|
||||||
"Kyoto/Basics/CStopwatch",
|
"Kyoto/Basics/CStopwatch",
|
||||||
"Kyoto/Basics/COsContextDolphin",
|
"Kyoto/Basics/COsContextDolphin",
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "Collision/CMaterialList.hpp"
|
#include "Collision/CMaterialList.hpp"
|
||||||
|
|
||||||
#include "Kyoto/Math/CUnitVector3f.hpp"
|
|
||||||
#include "Kyoto/Math/CVector3f.hpp"
|
#include "Kyoto/Math/CVector3f.hpp"
|
||||||
|
|
||||||
class CAABox;
|
class CAABox;
|
||||||
|
@ -17,16 +16,36 @@ public:
|
||||||
kI_Valid,
|
kI_Valid,
|
||||||
};
|
};
|
||||||
enum ESwapMaterials {
|
enum ESwapMaterials {
|
||||||
// TODO
|
kSM_Swap
|
||||||
};
|
};
|
||||||
|
|
||||||
CCollisionInfo(EInvalid valid = kI_Invalid);
|
CCollisionInfo(EInvalid valid = kI_Invalid);
|
||||||
CCollisionInfo(const CVector3f&, const CMaterialList&, const CMaterialList&, const CVector3f&);
|
CCollisionInfo(const CVector3f& point, const CMaterialList& leftMat, const CMaterialList& rightMat, const CVector3f& normal);
|
||||||
CCollisionInfo(const CVector3f&, const CMaterialList&, const CMaterialList&, const CVector3f&,
|
CCollisionInfo(const CVector3f& point, const CMaterialList& leftMat, const CMaterialList& rightMat, const CVector3f& leftNormal,
|
||||||
const CVector3f&);
|
const CVector3f& rightNormal);
|
||||||
CCollisionInfo(const CAABox&, const CMaterialList&, const CMaterialList&, const CVector3f&,
|
CCollisionInfo(const CAABox& aabox, const CMaterialList& leftMat, const CMaterialList& rightMat, const CVector3f& leftNormal,
|
||||||
const CVector3f&);
|
const CVector3f& rightNormal);
|
||||||
CCollisionInfo(const CCollisionInfo&, ESwapMaterials);
|
CCollisionInfo(const CCollisionInfo& other, ESwapMaterials swap)
|
||||||
|
: x0_point(other.x0_point)
|
||||||
|
, xc_extentX(other.xc_extentX)
|
||||||
|
, x18_extentY(other.x18_extentY)
|
||||||
|
, x24_extentZ(other.x24_extentZ)
|
||||||
|
, x30_valid(other.x30_valid)
|
||||||
|
, x31_hasExtents(other.x31_hasExtents)
|
||||||
|
, x38_materialLeft(other.x40_materialRight)
|
||||||
|
, x40_materialRight(other.x38_materialLeft)
|
||||||
|
, x48_normalLeft(other.x54_normalRight)
|
||||||
|
, x54_normalRight(other.x48_normalLeft) {}
|
||||||
|
|
||||||
|
CCollisionInfo GetSwapped() const;
|
||||||
|
bool IsValid() const { return x30_valid; }
|
||||||
|
const CMaterialList& GetMaterialLeft() const { return x38_materialLeft; }
|
||||||
|
const CMaterialList& GetMaterialRight() const { return x40_materialRight; }
|
||||||
|
CVector3f GetExtreme() const;
|
||||||
|
void Swap();
|
||||||
|
const CVector3f& GetNormalLeft() const { return x48_normalLeft; }
|
||||||
|
const CVector3f& GetNormalRight() const { return x54_normalRight; }
|
||||||
|
const CVector3f& GetPoint() const { return x0_point; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CVector3f x0_point;
|
CVector3f x0_point;
|
||||||
|
@ -37,8 +56,8 @@ private:
|
||||||
bool x31_hasExtents;
|
bool x31_hasExtents;
|
||||||
CMaterialList x38_materialLeft;
|
CMaterialList x38_materialLeft;
|
||||||
CMaterialList x40_materialRight;
|
CMaterialList x40_materialRight;
|
||||||
CUnitVector3f x48_normalLeft;
|
CVector3f x48_normalLeft;
|
||||||
CUnitVector3f x54_normalRight;
|
CVector3f x54_normalRight;
|
||||||
};
|
};
|
||||||
CHECK_SIZEOF(CCollisionInfo, 0x60)
|
CHECK_SIZEOF(CCollisionInfo, 0x60)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef __COBBOX_HPP__
|
||||||
|
#define __COBBOX_HPP__
|
||||||
|
|
||||||
|
#include "Kyoto/Math/CAABox.hpp"
|
||||||
|
#include "Kyoto/Math/CTransform4f.hpp"
|
||||||
|
#include "Kyoto/Math/CVector3f.hpp"
|
||||||
|
|
||||||
|
class CInputStream;
|
||||||
|
class CMRay;
|
||||||
|
class COBBox {
|
||||||
|
public:
|
||||||
|
COBBox(const CTransform4f& xf, const CVector3f& extents);
|
||||||
|
COBBox(CInputStream& in);
|
||||||
|
|
||||||
|
CAABox CalculateAABox(const CTransform4f& xf) const;
|
||||||
|
|
||||||
|
static COBBox FromAABox(const CAABox& box, const CTransform4f& xf);
|
||||||
|
|
||||||
|
bool LineIntersectsBox(const CMRay& ray, float& penetration) const;
|
||||||
|
bool AABoxIntersectsBox(const CAABox& box) const;
|
||||||
|
bool OBBIntersectsBox(const COBBox& box) const;
|
||||||
|
private:
|
||||||
|
CTransform4f mTransform;
|
||||||
|
CVector3f mExtents;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __COBBOX_HPP__
|
|
@ -19,7 +19,7 @@ public:
|
||||||
CTransform4f(const CVector3f& m0, const CVector3f& m1, const CVector3f& m2, const CVector3f& pos)
|
CTransform4f(const CVector3f& m0, const CVector3f& m1, const CVector3f& m2, const CVector3f& pos)
|
||||||
: m0(m0), posX(pos.GetX()), m1(m1), posY(pos.GetY()), m2(m2), posZ(pos.GetZ()) {}
|
: m0(m0), posX(pos.GetX()), m1(m1), posY(pos.GetY()), m2(m2), posZ(pos.GetZ()) {}
|
||||||
CTransform4f(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32);
|
CTransform4f(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32);
|
||||||
CTransform4f(const CInputStream& in);
|
CTransform4f(CInputStream& in);
|
||||||
CTransform4f(const CMatrix3f& rotation, const CVector3f& translation);
|
CTransform4f(const CMatrix3f& rotation, const CVector3f& translation);
|
||||||
CTransform4f(const CTransform4f& other);
|
CTransform4f(const CTransform4f& other);
|
||||||
CTransform4f& operator=(const CTransform4f& other);
|
CTransform4f& operator=(const CTransform4f& other);
|
||||||
|
|
|
@ -164,10 +164,7 @@ inline CVector3f operator/(const CVector3f& vec, f32 f) {
|
||||||
return CVector3f(x, y, z);
|
return CVector3f(x, y, z);
|
||||||
}
|
}
|
||||||
inline CVector3f operator-(const CVector3f& vec) {
|
inline CVector3f operator-(const CVector3f& vec) {
|
||||||
f32 x = -vec.GetX();
|
return CVector3f(-vec.GetX(), -vec.GetY(), -vec.GetZ());
|
||||||
f32 y = -vec.GetY();
|
|
||||||
f32 z = -vec.GetZ();
|
|
||||||
return CVector3f(x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __CVECTOR3F_HPP__
|
#endif // __CVECTOR3F_HPP__
|
||||||
|
|
|
@ -407,7 +407,7 @@ GUISYS :=\
|
||||||
COLLISION :=\
|
COLLISION :=\
|
||||||
$(BUILD_DIR)/asm/Collision/CCollidableAABox.o\
|
$(BUILD_DIR)/asm/Collision/CCollidableAABox.o\
|
||||||
$(BUILD_DIR)/asm/Collision/CCollidableCollisionSurface.o\
|
$(BUILD_DIR)/asm/Collision/CCollidableCollisionSurface.o\
|
||||||
$(BUILD_DIR)/asm/Collision/CCollisionInfo.o\
|
$(BUILD_DIR)/src/Collision/CCollisionInfo.o\
|
||||||
$(BUILD_DIR)/asm/Collision/InternalColliders.o\
|
$(BUILD_DIR)/asm/Collision/InternalColliders.o\
|
||||||
$(BUILD_DIR)/asm/Collision/CCollisionPrimitive.o\
|
$(BUILD_DIR)/asm/Collision/CCollisionPrimitive.o\
|
||||||
$(BUILD_DIR)/src/Collision/CMaterialList.o\
|
$(BUILD_DIR)/src/Collision/CMaterialList.o\
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include "Collision/CCollisionInfo.hpp"
|
||||||
|
|
||||||
|
#include "Kyoto/Math/CAABox.hpp"
|
||||||
|
|
||||||
|
#include "rstl/algorithm.hpp"
|
||||||
|
|
||||||
|
CCollisionInfo::CCollisionInfo(const CVector3f& point, const CMaterialList& rightMat,
|
||||||
|
const CMaterialList& leftMat, const CVector3f& normal)
|
||||||
|
: x0_point(point)
|
||||||
|
, xc_extentX(CVector3f::Zero())
|
||||||
|
, x18_extentY(CVector3f::Zero())
|
||||||
|
, x24_extentZ(CVector3f::Zero())
|
||||||
|
, x30_valid(true)
|
||||||
|
, x31_hasExtents(false)
|
||||||
|
, x38_materialLeft(leftMat)
|
||||||
|
, x40_materialRight(rightMat)
|
||||||
|
, x48_normalLeft(normal)
|
||||||
|
, x54_normalRight(-normal) {}
|
||||||
|
|
||||||
|
CCollisionInfo::CCollisionInfo(const CVector3f& point, const CMaterialList& rightMat,
|
||||||
|
const CMaterialList& leftMat, const CVector3f& leftNormal,
|
||||||
|
const CVector3f& rightNormal)
|
||||||
|
: x0_point(point)
|
||||||
|
, xc_extentX(CVector3f::Zero())
|
||||||
|
, x18_extentY(CVector3f::Zero())
|
||||||
|
, x24_extentZ(CVector3f::Zero())
|
||||||
|
, x30_valid(true)
|
||||||
|
, x31_hasExtents(false)
|
||||||
|
, x38_materialLeft(leftMat)
|
||||||
|
, x40_materialRight(rightMat)
|
||||||
|
, x48_normalLeft(leftNormal)
|
||||||
|
, x54_normalRight(rightNormal) {}
|
||||||
|
|
||||||
|
CCollisionInfo::CCollisionInfo(const CAABox& aabox, const CMaterialList& rightMat,
|
||||||
|
const CMaterialList& leftMat, const CVector3f& leftNormal,
|
||||||
|
const CVector3f& rightNormal)
|
||||||
|
: x0_point(aabox.GetMinPoint())
|
||||||
|
, xc_extentX(aabox.GetMaxPoint().GetX() - aabox.GetMinPoint().GetX(), 0.f, 0.f)
|
||||||
|
, x18_extentY(0.f, aabox.GetMaxPoint().GetY() - aabox.GetMinPoint().GetY(), 0.f)
|
||||||
|
, x24_extentZ(0.f, 0.f, aabox.GetMaxPoint().GetZ() - aabox.GetMinPoint().GetZ())
|
||||||
|
, x30_valid(true)
|
||||||
|
, x31_hasExtents(true)
|
||||||
|
, x38_materialLeft(leftMat)
|
||||||
|
, x40_materialRight(rightMat)
|
||||||
|
, x48_normalLeft(leftNormal)
|
||||||
|
, x54_normalRight(rightNormal) {}
|
||||||
|
|
||||||
|
CCollisionInfo CCollisionInfo::GetSwapped() const { return CCollisionInfo(*this, kSM_Swap); }
|
||||||
|
|
||||||
|
CCollisionInfo::CCollisionInfo(EInvalid invalid)
|
||||||
|
: x0_point(0.f, 0.f, 0.f)
|
||||||
|
, xc_extentX(0.f, 0.f, 0.f)
|
||||||
|
, x18_extentY(0.f, 0.f, 0.f)
|
||||||
|
, x24_extentZ(0.f, 0.f, 0.f)
|
||||||
|
, x30_valid(false)
|
||||||
|
, x31_hasExtents(false)
|
||||||
|
, x38_materialLeft(CMaterialList())
|
||||||
|
, x40_materialRight(CMaterialList())
|
||||||
|
, x48_normalLeft(0.f, 0.f, 0.f)
|
||||||
|
, x54_normalRight(0.f, 0.f, 0.f) {}
|
||||||
|
|
||||||
|
CVector3f CCollisionInfo::GetExtreme() const {
|
||||||
|
return x0_point + xc_extentX + x18_extentY + x24_extentZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCollisionInfo::Swap() {
|
||||||
|
x48_normalLeft = -x48_normalLeft;
|
||||||
|
x54_normalRight = -x54_normalRight;
|
||||||
|
rstl::swap(x38_materialLeft, x40_materialRight);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include "Collision/COBBox.hpp"
|
||||||
|
|
||||||
|
#include "Kyoto/Streams/CInputStream.hpp"
|
||||||
|
|
||||||
|
COBBox::COBBox(const CTransform4f& xf, const CVector3f& extents)
|
||||||
|
: mTransform(xf), mExtents(extents) {}
|
||||||
|
|
||||||
|
COBBox::COBBox(CInputStream& in) : mTransform(in), mExtents(in) {}
|
||||||
|
|
||||||
|
CAABox COBBox::CalculateAABox(const CTransform4f& xf) const {
|
||||||
|
}
|
||||||
|
|
||||||
|
COBBox COBBox::FromAABox(const CAABox& box, const CTransform4f& xf) {
|
||||||
|
CVector3f center = box.GetCenterPoint();
|
||||||
|
CVector3f extents = box.GetMaxPoint() - center;
|
||||||
|
CTransform4f final = xf * CTransform4f::Translate(center);
|
||||||
|
return COBBox(final, extents);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool COBBox::LineIntersectsBox(const CMRay& ray, float& penetration) const {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool COBBox::AABoxIntersectsBox(const CAABox& box) const {
|
||||||
|
return OBBIntersectsBox(FromAABox(box, CTransform4f::Identity()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool COBBox::OBBIntersectsBox(const COBBox& box) const {
|
||||||
|
return false;
|
||||||
|
}
|
Loading…
Reference in New Issue