mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-10 01:47:40 +00:00
Halfway match CAABox; continue CBallCamera
Former-commit-id: 602109d8f0
This commit is contained in:
27
include/Collision/CCollidableSphere.hpp
Normal file
27
include/Collision/CCollidableSphere.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef _CCOLLIDABLESPHERE_HPP
|
||||
#define _CCOLLIDABLESPHERE_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Collision/CCollisionPrimitive.hpp"
|
||||
|
||||
#include "Kyoto/Math/CSphere.hpp"
|
||||
|
||||
class CCollidableSphere : public CCollisionPrimitive {
|
||||
public:
|
||||
CCollidableSphere(const CSphere& sphere, const CMaterialList& material)
|
||||
: CCollisionPrimitive(material), x10_sphere(sphere) {}
|
||||
|
||||
u32 GetTableIndex() const override;
|
||||
CAABox CalculateAABox(const CTransform4f&) const override;
|
||||
CAABox CalculateLocalAABox() const override;
|
||||
FourCC GetPrimType() const override;
|
||||
~CCollidableSphere() override {}
|
||||
CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
|
||||
|
||||
private:
|
||||
CSphere x10_sphere;
|
||||
};
|
||||
CHECK_SIZEOF(CCollidableSphere, 0x20)
|
||||
|
||||
#endif
|
||||
45
include/Collision/CCollisionInfo.hpp
Normal file
45
include/Collision/CCollisionInfo.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef _CCOLLISIONINFO_HPP
|
||||
#define _CCOLLISIONINFO_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Collision/CMaterialList.hpp"
|
||||
|
||||
#include "Kyoto/Math/CUnitVector3f.hpp"
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CAABox;
|
||||
|
||||
class CCollisionInfo {
|
||||
public:
|
||||
enum EInvalid {
|
||||
kI_Invalid,
|
||||
kI_Valid,
|
||||
};
|
||||
enum ESwapMaterials {
|
||||
// TODO
|
||||
};
|
||||
|
||||
CCollisionInfo(EInvalid valid = kI_Invalid);
|
||||
CCollisionInfo(const CVector3f&, const CMaterialList&, const CMaterialList&, const CVector3f&);
|
||||
CCollisionInfo(const CVector3f&, const CMaterialList&, const CMaterialList&, const CVector3f&,
|
||||
const CVector3f&);
|
||||
CCollisionInfo(const CAABox&, const CMaterialList&, const CMaterialList&, const CVector3f&,
|
||||
const CVector3f&);
|
||||
CCollisionInfo(const CCollisionInfo&, ESwapMaterials);
|
||||
|
||||
private:
|
||||
CVector3f x0_point;
|
||||
CVector3f xc_extentX;
|
||||
CVector3f x18_extentY;
|
||||
CVector3f x24_extentZ;
|
||||
bool x30_valid;
|
||||
bool x31_hasExtents;
|
||||
CMaterialList x38_materialLeft;
|
||||
CMaterialList x40_materialRight;
|
||||
CUnitVector3f x48_normalLeft;
|
||||
CUnitVector3f x54_normalRight;
|
||||
};
|
||||
CHECK_SIZEOF(CCollisionInfo, 0x60)
|
||||
|
||||
#endif
|
||||
@@ -72,44 +72,58 @@ static EMaterialTypes SolidMaterial = kMT_Solid;
|
||||
class CMaterialList {
|
||||
public:
|
||||
CMaterialList() : value(0) {}
|
||||
CMaterialList(const EMaterialTypes& material) : value(0) { value |= u64(1) << material; }
|
||||
CMaterialList(const EMaterialTypes& m1) : value(0) { Add(m1); }
|
||||
CMaterialList(const EMaterialTypes& m1, const EMaterialTypes& m2) : value(0) {
|
||||
value |= u64(1) << m1;
|
||||
value |= u64(1) << m2;
|
||||
Add(m1);
|
||||
Add(m2);
|
||||
}
|
||||
CMaterialList(const EMaterialTypes& m1, const EMaterialTypes& m2, const EMaterialTypes& m3)
|
||||
: value(0) {
|
||||
value |= u64(1) << m1;
|
||||
value |= u64(1) << m2;
|
||||
value |= u64(1) << m3;
|
||||
Add(m1);
|
||||
Add(m2);
|
||||
Add(m3);
|
||||
}
|
||||
CMaterialList(const EMaterialTypes& m1, const EMaterialTypes& m2, const EMaterialTypes& m3,
|
||||
const EMaterialTypes& m4)
|
||||
: value(0) {
|
||||
value |= u64(1) << m1;
|
||||
value |= u64(1) << m2;
|
||||
value |= u64(1) << m3;
|
||||
value |= u64(1) << m4;
|
||||
Add(m1);
|
||||
Add(m2);
|
||||
Add(m3);
|
||||
Add(m4);
|
||||
}
|
||||
CMaterialList(const EMaterialTypes& m1, const EMaterialTypes& m2, const EMaterialTypes& m3,
|
||||
const EMaterialTypes& m4, const EMaterialTypes& m5)
|
||||
: value(0) {
|
||||
value |= u64(1) << m1;
|
||||
value |= u64(1) << m2;
|
||||
value |= u64(1) << m3;
|
||||
value |= u64(1) << m4;
|
||||
value |= u64(1) << m5;
|
||||
Add(m1);
|
||||
Add(m2);
|
||||
Add(m3);
|
||||
Add(m4);
|
||||
Add(m5);
|
||||
}
|
||||
CMaterialList(u64 value) : value(value) {}
|
||||
|
||||
void Add(EMaterialTypes material) { value |= u64(1) << material; }
|
||||
// Add__13CMaterialListFRC13CMaterialList weak
|
||||
// Remove__13CMaterialListF14EMaterialTypes weak
|
||||
// Remove__13CMaterialListFRC13CMaterialList weak
|
||||
const CMaterialList& Union(const CMaterialList& other) {
|
||||
value |= other.value;
|
||||
return *this;
|
||||
}
|
||||
bool HasMaterial(EMaterialTypes material) const {
|
||||
return (value & (u64(1) << material)) ? true : false;
|
||||
}
|
||||
// HasMaterials__13CMaterialListCFv weak
|
||||
// GetField__13CMaterialListCFUxUx weak
|
||||
// Intersection__13CMaterialListCFRC13CMaterialList weak
|
||||
// BitPosition__13CMaterialListFUx global
|
||||
// GetMaterialString__13CMaterialListCFv weak
|
||||
// SharesMaterials__13CMaterialListCFRC13CMaterialList weak
|
||||
|
||||
private:
|
||||
u64 value;
|
||||
|
||||
// static CMaterialList kEverything;
|
||||
};
|
||||
CHECK_SIZEOF(CMaterialList, 0x8)
|
||||
|
||||
|
||||
@@ -3,41 +3,73 @@
|
||||
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CInputStream;
|
||||
class CLineSeg;
|
||||
class CPlane;
|
||||
class CTransform4f;
|
||||
class CTri;
|
||||
|
||||
class CAABox {
|
||||
public:
|
||||
// CAABox() {
|
||||
// // TODO
|
||||
// }
|
||||
CAABox(const CVector3f& min, const CVector3f& max); // : min(min), max(max) {}
|
||||
enum EBoxEdgeId {
|
||||
kE_Z0,
|
||||
kE_X0,
|
||||
kE_Z1,
|
||||
kE_X1,
|
||||
kE_Z2,
|
||||
kE_X2,
|
||||
kE_Z3,
|
||||
kE_X3,
|
||||
kE_Y0,
|
||||
kE_Y1,
|
||||
kE_Y2,
|
||||
kE_Y3,
|
||||
};
|
||||
enum EBoxFaceId {
|
||||
kF_YMin,
|
||||
kF_YMax,
|
||||
kF_XMin,
|
||||
kF_XMax,
|
||||
kF_ZMax,
|
||||
kF_ZMin,
|
||||
};
|
||||
|
||||
CAABox(const CVector3f& min, const CVector3f& max);
|
||||
CAABox(f32 minX, f32 minY, f32 minZ, f32 maxX, f32 maxY, f32 maxZ)
|
||||
: min(minX, minY, minZ), max(maxX, maxY, maxZ) {}
|
||||
CAABox(CInputStream& in);
|
||||
// CAABox(const CAABox& other)
|
||||
// : minX(other.minX)
|
||||
// , minY(other.minY)
|
||||
// , minZ(other.minZ)
|
||||
// , maxX(other.maxX)
|
||||
// , maxY(other.maxY)
|
||||
// , maxZ(other.maxZ) {}
|
||||
// : min(other.min)
|
||||
// , max(other.max) {}
|
||||
|
||||
CAABox& operator=(const CAABox&);
|
||||
// CAABox& operator=(const CAABox& other) {
|
||||
// min = other.min;
|
||||
// max = other.max;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
CLineSeg GetEdge(EBoxEdgeId edge) const;
|
||||
CTri GetTri(EBoxFaceId face, int windOffset) const;
|
||||
CVector3f ClosestPointAlongVector(const CVector3f& vec) const;
|
||||
// FurthestPointAlongVector__6CAABoxCFRC9CVector3f global
|
||||
CVector3f FurthestPointAlongVector(const CVector3f& vec) const;
|
||||
const CVector3f& GetMinPoint() const { return min; }
|
||||
const CVector3f& GetMaxPoint() const { return max; }
|
||||
// GetCenterPoint__6CAABoxCFv global
|
||||
// GetPoint__6CAABoxCFi global
|
||||
// Include__6CAABoxFRC9CVector3f weak
|
||||
// Include__6CAABoxFRC6CAABox weak
|
||||
// AccumulateBounds__6CAABoxFRC9CVector3f global
|
||||
void AccumulateBounds(const CVector3f&);
|
||||
// bool Invalid__6CAABoxCFv global
|
||||
// PointInside__6CAABoxCFRC9CVector3f global
|
||||
// InsidePlane__6CAABoxCFRC6CPlane global
|
||||
// DoBoundsOverlap__6CAABoxCFRC6CAABox global
|
||||
bool DoBoundsOverlap(const CAABox&) const;
|
||||
// GetVolume__6CAABoxCFv global
|
||||
// GetBooleanIntersection__6CAABoxCFRC6CAABox global
|
||||
// Inside__6CAABoxCFRC6CAABox global
|
||||
// ClampToBox__6CAABoxCFRC9CVector3f global
|
||||
bool Inside(const CAABox& other) const;
|
||||
bool InsidePlane(const CPlane& plane) const;
|
||||
CVector3f ClampToBox(const CVector3f& vec) const;
|
||||
// GetTri__6CAABoxCFQ26CAABox10EBoxFaceIdi global
|
||||
// DistanceBetween__6CAABoxFRC6CAABoxRC6CAABox global
|
||||
CAABox GetTransformedAABox(const CTransform4f& xf) const;
|
||||
|
||||
// GetPointA__6CAABoxCFv weak
|
||||
// GetPointB__6CAABoxCFv weak
|
||||
@@ -54,8 +86,6 @@ public:
|
||||
// GetTri__6CAABoxCFii weak
|
||||
// GetEdge__6CAABoxCFi weak
|
||||
|
||||
// GetTransformedAABox__6CAABoxCFRC12CTransform4f
|
||||
|
||||
static const CAABox& Identity() { return mskNullBox; }
|
||||
static const CAABox& MakeMaxInvertedBox() { return mskInvertedBox; }
|
||||
// MakeNullBox__6CAABoxFv ??
|
||||
|
||||
21
include/Kyoto/Math/CLine.hpp
Normal file
21
include/Kyoto/Math/CLine.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _CLINE_HPP
|
||||
#define _CLINE_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CUnitVector3f.hpp"
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CLine {
|
||||
public:
|
||||
CLine(const CVector3f& origin, const CUnitVector3f& dir) : x0_origin(origin), xc_dir(dir) {}
|
||||
|
||||
const CVector3f& GetRefPoint() const { return x0_origin; }
|
||||
const CUnitVector3f& GetNormal() const { return xc_dir; }
|
||||
|
||||
private:
|
||||
CVector3f x0_origin;
|
||||
CUnitVector3f xc_dir;
|
||||
};
|
||||
|
||||
#endif
|
||||
23
include/Kyoto/Math/CLineSeg.hpp
Normal file
23
include/Kyoto/Math/CLineSeg.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _CLINESEG_HPP
|
||||
#define _CLINESEG_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CUnitVector3f.hpp"
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
#include "Kyoto/Math/CLine.hpp"
|
||||
|
||||
class CLineSeg : public CLine {
|
||||
public:
|
||||
CLineSeg(const CVector3f& start, const CVector3f& end)
|
||||
: CLine(start, (end - start).AsNormalized())
|
||||
, x18_end(end) {}
|
||||
|
||||
const CVector3f& GetEndPoint() const { return x18_end; }
|
||||
|
||||
private:
|
||||
CVector3f x18_end;
|
||||
};
|
||||
CHECK_SIZEOF(CLineSeg, 0x24)
|
||||
|
||||
#endif
|
||||
@@ -3,15 +3,24 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CPlane {
|
||||
public:
|
||||
CPlane(const CVector3f&, const CUnitVector3f&); // TODO weak
|
||||
CPlane(float, const CUnitVector3f&); // TODO weak
|
||||
CPlane(const CVector3f&, const CVector3f&, const CVector3f&);
|
||||
// TODO
|
||||
|
||||
const CUnitVector3f& GetNormal() const { return x0_normal; }
|
||||
f32 GetConstant() const { return xc_constant; }
|
||||
// GetHeight__6CPlaneCFRC9CVector3f
|
||||
// IsFacing__6CPlaneCFRC9CVector3f
|
||||
// ClipLineSegment__6CPlaneCFRC9CVector3fRC9CVector3f
|
||||
|
||||
private:
|
||||
f32 x;
|
||||
f32 y;
|
||||
f32 z;
|
||||
f32 w;
|
||||
CUnitVector3f x0_normal;
|
||||
f32 xc_constant;
|
||||
};
|
||||
CHECK_SIZEOF(CPlane, 0x10)
|
||||
|
||||
|
||||
20
include/Kyoto/Math/CSphere.hpp
Normal file
20
include/Kyoto/Math/CSphere.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _CSPHERE_HPP
|
||||
#define _CSPHERE_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CSphere {
|
||||
public:
|
||||
CSphere(const CVector3f& pos, f32 radius) : x0_pos(pos), xc_radius(radius) {}
|
||||
|
||||
// TODO
|
||||
|
||||
private:
|
||||
CVector3f x0_pos;
|
||||
f32 xc_radius;
|
||||
};
|
||||
CHECK_SIZEOF(CSphere, 0x10)
|
||||
|
||||
#endif
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
inline const CVector3f& GetRow(EDimX dim) const { return m0; }
|
||||
inline const CVector3f& GetRow(EDimY dim) const { return m1; }
|
||||
inline const CVector3f& GetRow(EDimZ dim) const { return m2; }
|
||||
// GetRow__12CTransform4fCFi
|
||||
inline const CVector3f& GetRow(int i) const { return *(&m0 + i); }
|
||||
// GetUp__12CTransform4fCFv
|
||||
static CTransform4f LookAt(const CVector3f& pos, const CVector3f& lookPos,
|
||||
const CVector3f& up = CVector3f::Up());
|
||||
@@ -73,8 +73,6 @@ public:
|
||||
// ScaleBy__12CTransform4fFf
|
||||
// SetRotation__12CTransform4fFRC12CTransform4f
|
||||
// SetRotation__12CTransform4fFRC9CMatrix3f
|
||||
// Translate__12CTransform4fFfff
|
||||
// Translate__12CTransform4fFRC9CVector3f
|
||||
// TransposeMultiply__12CTransform4fCFRC9CVector3f
|
||||
CVector3f TransposeRotate(const CVector3f& in) const;
|
||||
|
||||
@@ -96,6 +94,9 @@ public:
|
||||
|
||||
static CTransform4f FromColumns(const CVector3f&, const CVector3f&, const CVector3f&,
|
||||
const CVector3f&);
|
||||
static CTransform4f Translate(f32 x, f32 y, f32 z);
|
||||
static CTransform4f Translate(const CVector3f& vec);
|
||||
|
||||
static const CTransform4f& Identity() { return sIdentity; }
|
||||
|
||||
private:
|
||||
|
||||
27
include/Kyoto/Math/CTri.hpp
Normal file
27
include/Kyoto/Math/CTri.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef _CTRI_HPP
|
||||
#define _CTRI_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CPlane.hpp"
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CTri {
|
||||
public:
|
||||
CTri(const CVector3f& a, const CVector3f& b, const CVector3f& c)
|
||||
: x0_plane(a, b, c), x10_a(a), x1c_b(b), x28_c(c) {}
|
||||
|
||||
const CPlane& GetPlane() const { return x0_plane; }
|
||||
const CVector3f& GetPointA() const { return x10_a; }
|
||||
const CVector3f& GetPointB() const { return x1c_b; }
|
||||
const CVector3f& GetPointC() const { return x28_c; }
|
||||
|
||||
private:
|
||||
CPlane x0_plane;
|
||||
CVector3f x10_a;
|
||||
CVector3f x1c_b;
|
||||
CVector3f x28_c;
|
||||
};
|
||||
CHECK_SIZEOF(CTri, 0x34)
|
||||
|
||||
#endif
|
||||
19
include/Kyoto/Math/CUnitVector3f.hpp
Normal file
19
include/Kyoto/Math/CUnitVector3f.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _CUNITVECTOR3F_HPP
|
||||
#define _CUNITVECTOR3F_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CUnitVector3f : public CVector3f {
|
||||
public:
|
||||
enum ENormalize {
|
||||
// TODO
|
||||
};
|
||||
CUnitVector3f(f32 x, f32 y, f32 z);
|
||||
CUnitVector3f(const CVector3f& vec);
|
||||
// TODO
|
||||
};
|
||||
CHECK_SIZEOF(CUnitVector3f, 0xc)
|
||||
|
||||
#endif
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
// Slerp__9CVector3fFRC9CVector3fRC9CVector3fRC9CRelAngle
|
||||
void Normalize();
|
||||
f32 Magnitude() const;
|
||||
// AsNormalized__9CVector3fCFv
|
||||
CVector3f AsNormalized() const;
|
||||
bool CanBeNormalized() const;
|
||||
// GetAngleDiff__9CVector3fFRC9CVector3fRC9CVector3f
|
||||
// IsEqu__9CVector3fCFRC9CVector3ff
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
f32 operator[](EDimY) const { return mY; }
|
||||
f32 operator[](EDimZ) const { return mZ; }
|
||||
|
||||
f32& operator[](int i) { return *(&mX + i); }
|
||||
// f32 operator[](int i) const { return *(&mX + i); }
|
||||
f32& operator[](int i) { return (&mX)[i]; }
|
||||
f32 operator[](int i) const { return (&mX)[i]; }
|
||||
bool IsNonZero() const { return mX != 0.f || mY != 0.f || mZ != 0.f; }
|
||||
|
||||
CVector3f DropZ() const { return CVector3f(mX, mY, 0.f); }
|
||||
@@ -78,6 +78,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
static f32 Dot(const CVector3f& a, const CVector3f& b) {
|
||||
return (a.GetX() * b.GetX()) + (a.GetY() * b.GetY()) + (a.GetZ() * b.GetZ());
|
||||
}
|
||||
|
||||
static const CVector3f& Zero() { return sZeroVector; }
|
||||
static const CVector3f& Up() { return sUpVector; }
|
||||
static const CVector3f& Down() { return sDownVector; }
|
||||
@@ -99,6 +103,7 @@ private:
|
||||
static CVector3f sForwardVector;
|
||||
static CVector3f sBackVector;
|
||||
};
|
||||
CHECK_SIZEOF(CVector3f, 0xc)
|
||||
|
||||
// ClassifyVector__FRC9CVector3f
|
||||
// TGetType<9CVector3f>__FRC9CVector3f
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class CStateManager;
|
||||
class CAreaCollisionCache;
|
||||
class CCollisionPrimitive;
|
||||
class CTransform4f;
|
||||
class CMaterialFilter;
|
||||
class CStateManager;
|
||||
class CTransform4f;
|
||||
|
||||
class CGameCollision {
|
||||
public:
|
||||
@@ -14,6 +15,15 @@ public:
|
||||
const CTransform4f&, const CMaterialFilter&);
|
||||
static bool DetectDynamicCollisionBoolean(const CCollisionPrimitive&, const CTransform4f&,
|
||||
const TEntityList&, const CStateManager&);
|
||||
static void BuildAreaCollisionCache(const CStateManager& mgr, CAreaCollisionCache& cache);
|
||||
static bool DetectCollisionBoolean_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
|
||||
const CCollisionPrimitive& prim, const CTransform4f& xf,
|
||||
const CMaterialFilter& filter,
|
||||
const TEntityList& nearList);
|
||||
static bool DetectCollision_Cached_Moving(const CStateManager&, CAreaCollisionCache&,
|
||||
const CCollisionPrimitive&, const CTransform4f&,
|
||||
const CMaterialFilter&, const TEntityList&, CVector3f,
|
||||
TUniqueId&, CCollisionInfo&, f64&);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
CRayCastResult RayWorldIntersection(TUniqueId& idOut, const CVector3f& pos, const CVector3f& dir,
|
||||
f32 length, const CMaterialFilter& filter,
|
||||
const TEntityList& list) const;
|
||||
void BuildColliderList(TEntityList& out, const CActor& actor, const CAABox& aabb) const;
|
||||
|
||||
CEntity* ObjectById(TUniqueId uid);
|
||||
const CEntity* GetObjectById(TUniqueId uid) const;
|
||||
|
||||
@@ -44,7 +44,8 @@ public:
|
||||
const CVector3f& GetLookAtPosition() const { return x20_scaledWorldPos; }
|
||||
const CVector3f& GetLineOfSight() const;
|
||||
const CVector3f& GetPosition() const { return x8_lastLocalPos; }
|
||||
uint GetOcclusionCount() const { return x4c_occlusionCount; }
|
||||
int GetOcclusionCount() const { return x4c_occlusionCount; }
|
||||
f32 GetScale() const { return x50_scale; }
|
||||
|
||||
void SetRadius(f32 radius) { this->x4_radius = radius; }
|
||||
// TODO
|
||||
@@ -53,7 +54,8 @@ public:
|
||||
void SetDesiredPosition(CVector3f vec) { x14_localPos = vec; }
|
||||
void SetLookAtPosition(CVector3f vec) { x20_scaledWorldPos = vec; }
|
||||
void SetLineOfSight();
|
||||
void SetOcclusionCount(uint val) { x4c_occlusionCount = val; }
|
||||
void SetOcclusionCount(int val) { x4c_occlusionCount = val; }
|
||||
void SetScale(f32 val) { x50_scale = val; }
|
||||
|
||||
private:
|
||||
f32 x4_radius;
|
||||
@@ -62,9 +64,7 @@ private:
|
||||
CVector3f x20_scaledWorldPos; // look at position
|
||||
CVector3f x2c_lastWorldPos; // real position
|
||||
CCameraSpring x38_spring;
|
||||
|
||||
public: // TODO
|
||||
uint x4c_occlusionCount;
|
||||
int x4c_occlusionCount;
|
||||
f32 x50_scale;
|
||||
};
|
||||
|
||||
@@ -126,6 +126,18 @@ public:
|
||||
void UpdateColliders(const CTransform4f& xf, rstl::vector< CCameraCollider >& colliderList,
|
||||
int& idx, int count, float tolerance, const TEntityList& nearList, f32 dt,
|
||||
CStateManager& mgr);
|
||||
CVector3f CalculateCollidersCentroid(const rstl::vector< CCameraCollider >& colliderList,
|
||||
int numObscured) const;
|
||||
CVector3f ApplyColliders();
|
||||
int CountObscuredColliders(const rstl::vector< CCameraCollider >& colliderList) const;
|
||||
CAABox CalculateCollidersBoundingBox(const rstl::vector< CCameraCollider >& colliderList,
|
||||
const CStateManager&) const;
|
||||
CVector3f AvoidGeometryFull(const CTransform4f& xf, const TEntityList& nearList, f32 dt,
|
||||
CStateManager& mgr);
|
||||
CVector3f AvoidGeometry(const CTransform4f& xf, const TEntityList& nearList, f32 dt,
|
||||
CStateManager& mgr);
|
||||
bool DetectCollision(const CVector3f& from, const CVector3f& to, f32 radius, f32& d,
|
||||
CStateManager& mgr);
|
||||
|
||||
const CVector3f& GetLookAtPosition() const { return x1d8_lookPos; }
|
||||
f32 GetDistance() const { return x190_curMinDistance; }
|
||||
@@ -226,7 +238,7 @@ private:
|
||||
f32 x30c_speedingTime;
|
||||
CVector3f x310_idealLookVec;
|
||||
CVector3f x31c_predictedLookPos;
|
||||
uint x328_avoidGeomCycle;
|
||||
int x328_avoidGeomCycle;
|
||||
f32 x32c_colliderMag;
|
||||
f32 x330_clearColliderThreshold;
|
||||
CAABox x334_collidersAABB;
|
||||
|
||||
93
include/WorldFormat/CAreaOctTree.hpp
Normal file
93
include/WorldFormat/CAreaOctTree.hpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _CAREAOCTTREE_HPP
|
||||
#define _CAREAOCTTREE_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "WorldFormat/CCollisionSurface.hpp"
|
||||
|
||||
#include "Kyoto/Math/CAABox.hpp"
|
||||
#include "Kyoto/Math/CPlane.hpp"
|
||||
|
||||
#include "rstl/optional_object.hpp"
|
||||
|
||||
class CCollisionEdge;
|
||||
class CLine;
|
||||
class CMaterialFilter;
|
||||
|
||||
class CAreaOctTree {
|
||||
public:
|
||||
struct SRayResult {
|
||||
CPlane x0_plane;
|
||||
rstl::optional_object< CCollisionSurface > x10_surface;
|
||||
f32 x3c_t;
|
||||
};
|
||||
|
||||
class TriListReference {
|
||||
public:
|
||||
explicit TriListReference(const u16* ptr) : m_ptr(ptr) {}
|
||||
u16 GetAt(int idx) const { return m_ptr[idx + 1]; }
|
||||
u16 GetSize() const { return m_ptr[0]; }
|
||||
|
||||
private:
|
||||
const u16* m_ptr;
|
||||
};
|
||||
|
||||
class Node {
|
||||
public:
|
||||
enum ETreeType { kTT_Invalid, kTT_Branch, kTT_Leaf };
|
||||
|
||||
Node(const void* ptr, const CAABox& aabb, const CAreaOctTree& owner, ETreeType type)
|
||||
: x0_aabb(aabb)
|
||||
, x18_ptr(reinterpret_cast< const u8* >(ptr))
|
||||
, x1c_owner(owner)
|
||||
, x20_nodeType(type) {}
|
||||
|
||||
bool LineTest(const CLine& line, const CMaterialFilter& filter, f32 length) const;
|
||||
void LineTestEx(const CLine& line, const CMaterialFilter& filter, SRayResult& res,
|
||||
f32 length) const;
|
||||
|
||||
const CAreaOctTree& GetOwner() const { return x1c_owner; }
|
||||
const CAABox& GetBoundingBox() const { return x0_aabb; }
|
||||
u16 GetChildFlags() const { return *reinterpret_cast< const u16* >(x18_ptr); }
|
||||
Node GetChild(int idx) const;
|
||||
TriListReference GetTriangleArray() const;
|
||||
ETreeType GetChildType(int idx) const {
|
||||
u16 flags = *reinterpret_cast< const u16* >(x18_ptr);
|
||||
return ETreeType((flags >> (2 * idx)) & 0x3);
|
||||
}
|
||||
ETreeType GetTreeType() const { return x20_nodeType; }
|
||||
|
||||
private:
|
||||
CAABox x0_aabb;
|
||||
const u8* x18_ptr;
|
||||
const CAreaOctTree& x1c_owner;
|
||||
ETreeType x20_nodeType;
|
||||
|
||||
bool LineTestInternal(const CLine& line, const CMaterialFilter& filter, f32 lT, f32 hT,
|
||||
f32 maxT, const CVector3f& vec) const;
|
||||
void LineTestExInternal(const CLine& line, const CMaterialFilter& filter, SRayResult& res,
|
||||
f32 lT, f32 hT, f32 maxT, const CVector3f& dirRecip) const;
|
||||
};
|
||||
|
||||
// TODO
|
||||
|
||||
private:
|
||||
CAABox x0_aabb;
|
||||
Node::ETreeType x18_treeType;
|
||||
const u8* x1c_buf;
|
||||
const u8* x20_treeBuf;
|
||||
uint x24_matCount;
|
||||
const uint* x28_materials;
|
||||
const u8* x2c_vertMats;
|
||||
const u8* x30_edgeMats;
|
||||
const u8* x34_polyMats;
|
||||
uint x38_edgeCount;
|
||||
const CCollisionEdge* x3c_edges;
|
||||
uint x40_polyCount;
|
||||
const u16* x44_polyEdges;
|
||||
uint x48_vertCount;
|
||||
const float* x4c_verts;
|
||||
};
|
||||
CHECK_SIZEOF(CAreaOctTree, 0x50)
|
||||
|
||||
#endif
|
||||
20
include/WorldFormat/CCollisionSurface.hpp
Normal file
20
include/WorldFormat/CCollisionSurface.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _CCOLLISIONSURFACE_HPP
|
||||
#define _CCOLLISIONSURFACE_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CCollisionSurface {
|
||||
public:
|
||||
typedef CVector3f TVerts[3];
|
||||
|
||||
// TODO
|
||||
|
||||
private:
|
||||
TVerts x0_data;
|
||||
uint x24_flags;
|
||||
};
|
||||
CHECK_SIZEOF(CCollisionSurface, 0x28)
|
||||
|
||||
#endif
|
||||
68
include/WorldFormat/CMetroidAreaCollider.hpp
Normal file
68
include/WorldFormat/CMetroidAreaCollider.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _CMETROIDAREACOLLIDER_HPP
|
||||
#define _CMETROIDAREACOLLIDER_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "WorldFormat/CAreaOctTree.hpp"
|
||||
|
||||
#include "Kyoto/Math/CAABox.hpp"
|
||||
|
||||
#include "rstl/reserved_vector.hpp"
|
||||
|
||||
class CMetroidAreaCollider {
|
||||
public:
|
||||
class COctreeLeafCache {
|
||||
public:
|
||||
COctreeLeafCache(const CAreaOctTree& octTree);
|
||||
void AddLeaf(const CAreaOctTree::Node& node);
|
||||
u32 GetNumLeaves() const { return x4_nodeCache.size(); }
|
||||
bool HasCacheOverflowed() const { return x908_24_overflow; }
|
||||
const CAreaOctTree& GetOctTree() const { return x0_octTree; }
|
||||
rstl::reserved_vector< CAreaOctTree::Node, 64 >::const_iterator begin() const {
|
||||
return x4_nodeCache.begin();
|
||||
}
|
||||
rstl::reserved_vector< CAreaOctTree::Node, 64 >::const_iterator end() const {
|
||||
return x4_nodeCache.end();
|
||||
}
|
||||
|
||||
private:
|
||||
const CAreaOctTree& x0_octTree;
|
||||
rstl::reserved_vector< CAreaOctTree::Node, 64 > x4_nodeCache;
|
||||
bool x908_24_overflow : 1;
|
||||
};
|
||||
|
||||
// TODO
|
||||
|
||||
private:
|
||||
// TODO
|
||||
};
|
||||
|
||||
class CAreaCollisionCache {
|
||||
public:
|
||||
CAreaCollisionCache(const CAABox& aabb);
|
||||
|
||||
void ClearCache();
|
||||
const CAABox& GetCacheBounds() const { return x0_aabb; }
|
||||
void SetCacheBounds(const CAABox& aabb) { x0_aabb = aabb; }
|
||||
void AddOctreeLeafCache(const CMetroidAreaCollider::COctreeLeafCache& leafCache);
|
||||
u32 GetNumCaches() const { return x18_leafCaches.size(); }
|
||||
const CMetroidAreaCollider::COctreeLeafCache& GetOctreeLeafCache(int idx) {
|
||||
return x18_leafCaches[idx];
|
||||
}
|
||||
bool HasCacheOverflowed() const { return x1b40_24_leafOverflow; }
|
||||
rstl::reserved_vector< CMetroidAreaCollider::COctreeLeafCache, 3 >::const_iterator begin() const {
|
||||
return x18_leafCaches.begin();
|
||||
}
|
||||
rstl::reserved_vector< CMetroidAreaCollider::COctreeLeafCache, 3 >::const_iterator end() const {
|
||||
return x18_leafCaches.end();
|
||||
}
|
||||
|
||||
private:
|
||||
CAABox x0_aabb;
|
||||
rstl::reserved_vector< CMetroidAreaCollider::COctreeLeafCache, 3 > x18_leafCaches;
|
||||
bool x1b40_24_leafOverflow : 1;
|
||||
bool x1b40_25_cacheOverflow : 1;
|
||||
};
|
||||
CHECK_SIZEOF(CAreaCollisionCache, 0x1b44)
|
||||
|
||||
#endif
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
}
|
||||
void clear() {
|
||||
for (int i = 0; i < x0_count; ++i) {
|
||||
rstl::destroy(&data()[i]);
|
||||
rstl::destroy(&reinterpret_cast< T* >(x4_data)[i]);
|
||||
}
|
||||
x0_count = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user