diff --git a/configure.py b/configure.py index f28babc2..77147bfd 100755 --- a/configure.py +++ b/configure.py @@ -451,7 +451,7 @@ LIBS = [ ["Collision/CCollidableCollisionSurface", True], ["Collision/CCollisionInfo", True], "Collision/InternalColliders", - "Collision/CCollisionPrimitive", + ["Collision/CCollisionPrimitive", False], ["Collision/CMaterialList", True], "Collision/CollisionUtil", "Collision/CCollidableSphere", diff --git a/include/Collision/CCollisionPrimitive.hpp b/include/Collision/CCollisionPrimitive.hpp index c156cd74..083bc26c 100644 --- a/include/Collision/CCollisionPrimitive.hpp +++ b/include/Collision/CCollisionPrimitive.hpp @@ -8,11 +8,21 @@ #include "Kyoto/IObjectStore.hpp" #include "Kyoto/Math/CAABox.hpp" #include "Kyoto/Math/CTransform4f.hpp" +#include "rstl/single_ptr.hpp" +#include "rstl/vector.hpp" class CRayCastResult; +class CCollisionInfoList; +class CInternalCollisionStructure; class CInternalRayCastStructure; +class CCollisionInfo; -typedef void(*PrimitiveSetter)(uint); +typedef void (*PrimitiveSetter)(uint); + +typedef bool (*ComparisonFunc)(const CInternalCollisionStructure&, CCollisionInfoList&); +typedef bool (*BooleanComparisonFunc)(const CInternalCollisionStructure&); +typedef bool (*MovingComparisonFunc)(const CInternalCollisionStructure&, const CVector3f&, double&, + CCollisionInfo&); class CCollisionPrimitive { public: @@ -22,6 +32,7 @@ public: PrimitiveSetter GetSetter() const { return mSetter; } const char* GetInfo() const { return mInfo; } + private: PrimitiveSetter mSetter; const char* mInfo; @@ -38,9 +49,26 @@ public: virtual ~CCollisionPrimitive(); virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const = 0; + static void InitBeginTypes(); + static void InitAddType(const Type& type); + static void InitEndTypes(); static void Uninitialize(); private: + static int sNumTypes; + static bool sInitComplete; + static bool sTypesAdded; + static bool sTypesAdding; + static bool sCollidersAdded; + static bool sCollidersAdding; + static rstl::single_ptr< rstl::vector< Type > > sCollisionTypeList; + static rstl::single_ptr< ComparisonFunc > sTableOfCollidables; + static rstl::single_ptr< BooleanComparisonFunc > sTableOfBooleanCollidables; + static rstl::single_ptr< MovingComparisonFunc > sTableOfMovingCollidables; + static ComparisonFunc sNullCollider; + static BooleanComparisonFunc sNullBooleanCollider; + static MovingComparisonFunc sNullMovingCollider; + uint x4_; CMaterialList x8_material; }; diff --git a/include/Collision/InternalColliders.hpp b/include/Collision/InternalColliders.hpp new file mode 100644 index 00000000..cc8359f4 --- /dev/null +++ b/include/Collision/InternalColliders.hpp @@ -0,0 +1,5 @@ + + +namespace InternalColliders { + void AddTypes(); +} diff --git a/src/Collision/CCollisionPrimitive.cpp b/src/Collision/CCollisionPrimitive.cpp new file mode 100644 index 00000000..aa5601a7 --- /dev/null +++ b/src/Collision/CCollisionPrimitive.cpp @@ -0,0 +1,34 @@ +#include "Collision/CCollisionPrimitive.hpp" +#include "Collision/InternalColliders.hpp" + +int CCollisionPrimitive::sNumTypes = 0; +bool CCollisionPrimitive::sInitComplete = false; +bool CCollisionPrimitive::sTypesAdded = false; +bool CCollisionPrimitive::sTypesAdding = false; +bool CCollisionPrimitive::sCollidersAdded = false; +bool CCollisionPrimitive::sCollidersAdding = false; + +rstl::single_ptr< rstl::vector< CCollisionPrimitive::Type > > + CCollisionPrimitive::sCollisionTypeList; +rstl::single_ptr< ComparisonFunc > CCollisionPrimitive::sTableOfCollidables; +rstl::single_ptr< BooleanComparisonFunc > CCollisionPrimitive::sTableOfBooleanCollidables; +rstl::single_ptr< MovingComparisonFunc > CCollisionPrimitive::sTableOfMovingCollidables; + +CCollisionPrimitive::CCollisionPrimitive(const CMaterialList& list) : x8_material(list) {} + +void CCollisionPrimitive::InitBeginTypes() { + sCollisionTypeList = new rstl::vector< Type >(); + sCollisionTypeList->reserve(3); + sTypesAdding = true; + InternalColliders::AddTypes(); +} + +void CCollisionPrimitive::InitAddType(const Type& type) { + type.GetSetter()(sCollisionTypeList->size()); + sCollisionTypeList->reserve(sCollisionTypeList->size() + 1); + sCollisionTypeList->push_back(type); +} + +void CCollisionPrimitive::InitEndTypes() { + +}