diff --git a/.gitignore b/.gitignore index c138894b3..9bde34c4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ version.h *.user .DS_Store +*.autosave diff --git a/DataSpec/DNACommon/CRSC.cpp b/DataSpec/DNACommon/CRSC.cpp index 2a1976723..b0e077448 100644 --- a/DataSpec/DNACommon/CRSC.cpp +++ b/DataSpec/DNACommon/CRSC.cpp @@ -65,7 +65,7 @@ static const std::vector DecalTypes = SBIG('NCDL'),SBIG('DDCL'),SBIG('CODL'),SBIG('MEDL'), SBIG('GRDL'),SBIG('ICDL'),SBIG('GODL'),SBIG('WODL'), SBIG('WTDL'),SBIG('3MUD'),SBIG('3LAV'),SBIG('3SAN'), - SBIG('CHDL') + SBIG('CHDL'),SBIG('ENDL') }; diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 689d68657..8a8dd1f44 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -14,7 +14,7 @@ class CGameState { int m_stateFlag = -1; CPlayerState m_playerState; - CWorldTransManager m_transManager; + CWorldTransManager x9c_transManager; float m_gameTime = 0.0; CGameOptions m_gameOpts; double xa0_playTime; @@ -22,7 +22,7 @@ public: CGameState() {} CGameState(CBitStreamReader& stream); void SetCurrentWorldId(unsigned int id, const std::string& name); - CWorldTransManager& WorldTransitionManager() {return m_transManager;} + CWorldTransManager& WorldTransitionManager() {return x9c_transManager;} void SetTotalPlayTime(float time); }; diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 12af24f1c..b7673221f 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -47,6 +47,7 @@ add_library(RuntimeCommon ${WORLD_SOURCES} #CMemory.hpp CMemory.cpp CMemoryCardSys.hpp + CSaveWorld.hpp CSaveWorld.cpp IAllocator.hpp IAllocator.cpp CGameAllocator.hpp CGameAllocator.cpp CDependencyGroup.hpp CDependencyGroup.cpp diff --git a/Runtime/CSaveWorld.cpp b/Runtime/CSaveWorld.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/Runtime/CSaveWorld.hpp b/Runtime/CSaveWorld.hpp new file mode 100644 index 000000000..ae154e5e2 --- /dev/null +++ b/Runtime/CSaveWorld.hpp @@ -0,0 +1,12 @@ +#ifndef __URDE_CSAVEWORLD_HPP__ +#define __URDE_CSAVEWORLD_HPP__ + +namespace urde +{ +class CSaveWorld +{ + CSaveWorld(CInputStream& in); +}; +} + +#endif // __URDE_CSAVEWORLD_HPP__ diff --git a/Runtime/Collision/CCollidableAABox.cpp b/Runtime/Collision/CCollidableAABox.cpp index ee048d470..6b75d91ae 100644 --- a/Runtime/Collision/CCollidableAABox.cpp +++ b/Runtime/Collision/CCollidableAABox.cpp @@ -1,6 +1,51 @@ #include "CCollidableAABox.hpp" +namespace urde +{ +const CCollisionPrimitive::Type CCollidableAABox::sType(CCollidableAABox::SetStaticTableIndex, "CCollidableAABox"); +u32 CCollidableAABox::sTableIndex = -1; + CCollidableAABox::CCollidableAABox() { - +} + +zeus::CAABox CCollidableAABox::Transform(const zeus::CTransform& xf) const +{ + return {xf.origin + x10_aabox.min, xf.origin + x10_aabox.max}; +} + +u32 CCollidableAABox::GetTableIndex() const +{ + return sTableIndex; +} + +zeus::CAABox CCollidableAABox::CalculateAABox(const zeus::CTransform& xf) const +{ + return Transform(xf); +} + +zeus::CAABox CCollidableAABox::CalculateLocalAABox() const +{ + return x10_aabox; +} + +FourCC CCollidableAABox::GetPrimType() const +{ + return SBIG('AABX'); +} + +CRayCastResult CCollidableAABox::CastRayInternal(const CInternalRayCastStructure &) const +{ + return {}; +} + +const CCollisionPrimitive::Type& CCollidableAABox::GetType() +{ + return sType; +} + +void CCollidableAABox::SetStaticTableIndex(u32 index) +{ + sTableIndex = index; +} } diff --git a/Runtime/Collision/CCollidableAABox.hpp b/Runtime/Collision/CCollidableAABox.hpp index b94c3d0c9..9e5d9a099 100644 --- a/Runtime/Collision/CCollidableAABox.hpp +++ b/Runtime/Collision/CCollidableAABox.hpp @@ -1,11 +1,35 @@ -#ifndef CCOLLIDABLEAABOX_HPP -#define CCOLLIDABLEAABOX_HPP +#ifndef __URDE_CCOLLIDABLEAABOX_HPP__ +#define __URDE_CCOLLIDABLEAABOX_HPP__ +#include "CCollisionPrimitive.hpp" -class CCollidableAABox +namespace urde { +namespace Collide +{ +bool AABox_AABox(const CInternalCollisionStructure&, CCollisionInfoList&); +bool AABox_AABox_Bool(const CInternalCollisionStructure&, CCollisionInfoList&); +} + +class CCollidableAABox : public CCollisionPrimitive +{ + static const Type sType; + static u32 sTableIndex; + + zeus::CAABox x10_aabox; public: CCollidableAABox(); -}; -#endif // CCOLLIDABLEAABOX_HPP \ No newline at end of file + zeus::CAABox Transform(const zeus::CTransform&) const; + virtual u32 GetTableIndex() const; + virtual zeus::CAABox CalculateAABox(const zeus::CTransform&) const; + virtual zeus::CAABox CalculateLocalAABox() const; + virtual FourCC GetPrimType() const; + virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const; + + static const CCollisionPrimitive::Type& GetType(); + static void SetStaticTableIndex(u32 index); +}; +} + +#endif // __URDE_CCOLLIDABLEAABOX_HPP__ diff --git a/Runtime/Collision/CCollidableCollisionSurface.cpp b/Runtime/Collision/CCollidableCollisionSurface.cpp new file mode 100644 index 000000000..5711850be --- /dev/null +++ b/Runtime/Collision/CCollidableCollisionSurface.cpp @@ -0,0 +1,17 @@ +#include "CCollidableCollisionSurface.hpp" + +namespace urde +{ +const CCollisionPrimitive::Type CCollidableCollisionSurface::sType(CCollidableCollisionSurface::SetStaticTableIndex, "CCollidableCollisionSurface"); +u32 CCollidableCollisionSurface::sTableIndex = -1; + +const CCollisionPrimitive::Type& CCollidableCollisionSurface::GetType() +{ + return sType; +} + +void CCollidableCollisionSurface::SetStaticTableIndex(u32 index) +{ + sTableIndex = index; +} +} diff --git a/Runtime/Collision/CCollidableCollisionSurface.hpp b/Runtime/Collision/CCollidableCollisionSurface.hpp new file mode 100644 index 000000000..cf9a429d6 --- /dev/null +++ b/Runtime/Collision/CCollidableCollisionSurface.hpp @@ -0,0 +1,17 @@ +#ifndef __URDE_COLLIDABLECOLLISIONSURFACE_HPP__ +#define __URDE_COLLIDABLECOLLISIONSURFACE_HPP__ + +#include "CCollisionPrimitive.hpp" + +namespace urde +{ +class CCollidableCollisionSurface +{ + static const CCollisionPrimitive::Type sType; + static u32 sTableIndex; +public: + static const CCollisionPrimitive::Type& GetType(); + static void SetStaticTableIndex(u32 index); +}; +} +#endif // __URDE_COLLIDABLECOLLISIONSURFACE_HPP__ diff --git a/Runtime/Collision/CCollidableOBBTreeGroup.hpp b/Runtime/Collision/CCollidableOBBTreeGroup.hpp index 4f81b840d..d2c2956e4 100644 --- a/Runtime/Collision/CCollidableOBBTreeGroup.hpp +++ b/Runtime/Collision/CCollidableOBBTreeGroup.hpp @@ -11,7 +11,7 @@ namespace urde { class CCollidableOBBTreeGroup : public CCollisionPrimitive { - static const CCollisionPrimitive::Type sType; + static const Type sType; static u32 sTableIndex; std::vector> x0_trees; std::vector x10_aabbs; @@ -26,7 +26,7 @@ public: virtual FourCC GetPrimType() const; virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const; - static const CCollisionPrimitive::Type& GetType(); + static const Type& GetType(); static void SetStaticTableIndex(u32 index); }; diff --git a/Runtime/Collision/CCollidableSphere.cpp b/Runtime/Collision/CCollidableSphere.cpp new file mode 100644 index 000000000..e04fc2791 --- /dev/null +++ b/Runtime/Collision/CCollidableSphere.cpp @@ -0,0 +1,43 @@ +#include "CCollidableSphere.hpp" + +namespace urde +{ +const CCollisionPrimitive::Type CCollidableSphere::sType(CCollidableSphere::SetStaticTableIndex, "CCollidableSphere"); +u32 CCollidableSphere::sTableIndex = -1; + +u32 CCollidableSphere::GetTableIndex() const +{ + return sTableIndex; +} + +zeus::CAABox CCollidableSphere::CalculateAABox(const zeus::CTransform &) const +{ + return {}; +} + +zeus::CAABox CCollidableSphere::CalculateLocalAABox() const +{ + return {}; +} + +FourCC CCollidableSphere::GetPrimType() const +{ + return SBIG('SPHR'); +} + +CRayCastResult CCollidableSphere::CastRayInternal(const CInternalRayCastStructure &) const +{ + return {}; +} + +const CCollisionPrimitive::Type& CCollidableSphere::GetType() +{ + return sType; +} + +void CCollidableSphere::SetStaticTableIndex(u32 index) +{ + sTableIndex = index; +} + +} diff --git a/Runtime/Collision/CCollidableSphere.hpp b/Runtime/Collision/CCollidableSphere.hpp new file mode 100644 index 000000000..cfc96319e --- /dev/null +++ b/Runtime/Collision/CCollidableSphere.hpp @@ -0,0 +1,25 @@ +#ifndef __URDE_CCOLLIDALBESPHERE_HPP +#define __URDE_CCOLLIDALBESPHERE_HPP + +#include "CCollisionPrimitive.hpp" + +namespace urde +{ +class CCollidableSphere : public CCollisionPrimitive +{ + static const Type sType; + static u32 sTableIndex; +public: + + virtual u32 GetTableIndex() const; + virtual zeus::CAABox CalculateAABox(const zeus::CTransform&) const; + virtual zeus::CAABox CalculateLocalAABox() const; + virtual FourCC GetPrimType() const; + virtual CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const; + + static const Type& GetType(); + static void SetStaticTableIndex(u32 index); +}; +} + +#endif // __URDE_CCOLLIDALBESPHERE_HPP diff --git a/Runtime/Collision/CCollisionInfo.cpp b/Runtime/Collision/CCollisionInfo.cpp index e69de29bb..daa488f40 100644 --- a/Runtime/Collision/CCollisionInfo.cpp +++ b/Runtime/Collision/CCollisionInfo.cpp @@ -0,0 +1,6 @@ +#include "CCollisionInfo.hpp" + +namespace urde +{ + +} diff --git a/Runtime/Collision/CCollisionInfo.hpp b/Runtime/Collision/CCollisionInfo.hpp index b22b20b18..98bfd87e6 100644 --- a/Runtime/Collision/CCollisionInfo.hpp +++ b/Runtime/Collision/CCollisionInfo.hpp @@ -1,11 +1,14 @@ #ifndef __URDE_CCOLLISIONINFO_HPP__ #define __URDE_CCOLLISIONINFO_HPP__ +#include "zeus/CAABox.hpp" + namespace urde { - +class CMaterialList; class CCollisionInfo { +public: }; } diff --git a/Runtime/Collision/CCollisionInfoList.cpp b/Runtime/Collision/CCollisionInfoList.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/Runtime/Collision/CCollisionInfoList.hpp b/Runtime/Collision/CCollisionInfoList.hpp new file mode 100644 index 000000000..e97c24220 --- /dev/null +++ b/Runtime/Collision/CCollisionInfoList.hpp @@ -0,0 +1,30 @@ +#ifndef __URDE_CCOLLISIONINFOLIST_HPP__ +#define __URDE_CCOLLISIONINFOLIST_HPP__ + +#include "RetroTypes.hpp" + +namespace urde +{ +class CCollisionInfo; +class CCollisionInfoList +{ + rstl::reserved_vector x0_list; +public: + CCollisionInfoList() = default; + + void GetAverageLeftNormal() const; + void GetAveragePoint() const; + void GetUnionOfAllLeftMaterials() const; + s32 GetCount() const; + void Swap(s32); + + void Add(const CCollisionInfo&, bool); + void Clear(); + void End(); + void End() const; + void Begin(); + void Begin() const; +}; +} + +#endif // __URDE_CCOLLISIONINFOLIST_HPP__ diff --git a/Runtime/Collision/CCollisionPrimitive.cpp b/Runtime/Collision/CCollisionPrimitive.cpp index 67aa27441..203a8b503 100644 --- a/Runtime/Collision/CCollisionPrimitive.cpp +++ b/Runtime/Collision/CCollisionPrimitive.cpp @@ -1,9 +1,12 @@ #include "CCollisionPrimitive.hpp" #include "CInternalRayCastStructure.hpp" #include "CMaterialFilter.hpp" +#include "InternalColliders.hpp" namespace urde { +std::unique_ptr> CCollisionPrimitive::sCollisionTypeList; +bool CCollisionPrimitive::sTypesAdding = false; CCollisionPrimitive::CCollisionPrimitive(const CMaterialList& list) : x8_material(list) { @@ -14,7 +17,7 @@ void CCollisionPrimitive::SetMaterial(const CMaterialList& material) x8_material = material; } -const CMaterialList&CCollisionPrimitive::GetMaterial() const +const CMaterialList& CCollisionPrimitive::GetMaterial() const { return x8_material; @@ -26,4 +29,41 @@ CRayCastResult CCollisionPrimitive::CastRay(const zeus::CVector3f& start, const return CastRayInternal(CInternalRayCastStructure(start, end, d, xf, filter)); } +void CCollisionPrimitive::InitBeginTypes() +{ + sCollisionTypeList.reset(new std::vector()); + sCollisionTypeList->reserve(3); + sTypesAdding = true; + InternalColliders::AddTypes(); +} + +void CCollisionPrimitive::InitAddType(const CCollisionPrimitive::Type& tp) +{ + tp.GetSetter()(sCollisionTypeList->size()); + + sCollisionTypeList->reserve(sCollisionTypeList->size() + 1); + sCollisionTypeList->push_back(tp); +} + +void CCollisionPrimitive::InitEndTypes() +{ + sTypesAdding = false; +} + +CCollisionPrimitive::Type::Type(const std::function& setter, const char *info) + : x0_setter(setter), + x4_info(info) +{ +} + +const char *CCollisionPrimitive::Type::GetInfo() const +{ + return x4_info; +} + +std::function CCollisionPrimitive::Type::GetSetter() const +{ + return x0_setter; +} + } diff --git a/Runtime/Collision/CCollisionPrimitive.hpp b/Runtime/Collision/CCollisionPrimitive.hpp index e67c09bca..cda8f94fb 100644 --- a/Runtime/Collision/CCollisionPrimitive.hpp +++ b/Runtime/Collision/CCollisionPrimitive.hpp @@ -11,11 +11,20 @@ namespace urde { class COBBTree; +class CInternalCollisionStructure; +class CCollisionInfo; +class CCollisionInfoList; class CInternalRayCastStructure; class CMaterialFilter; class CCollisionPrimitive { +public: + class Type; +private: + CMaterialList x8_material; + static std::unique_ptr> sCollisionTypeList; + static bool sTypesAdding; public: class Type { @@ -23,21 +32,71 @@ public: const char* x4_info; public: Type() = default; - Type(std::function setter, const char * info) - : x0_setter(setter), - x4_info(info) + Type(const std::function& setter, const char * info); + + const char* GetInfo() const; + + std::function GetSetter() const; + }; + + class Comparison + { + std::function x0_collider; + const char* x4_type1; + const char* x8_type2; + public: + Comparison(const std::function& collider, + const char* type1, const char* type2) + : x0_collider(collider), + x4_type1(type1), + x8_type2(type2) { } - const char* GetInfo() const + std::function GetCollider() const { return x0_collider; } + const char* GetType1() const { return x4_type1; } + const char* GetType2() const { return x8_type2; } + }; + + class MovingComparison + { + std::function x0_collider; + const char* x4_type1; + const char* x8_type2; + public: + MovingComparison(const std::function& collider, const char* type1, const char* type2) + : x0_collider(collider), + x4_type1(type1), + x8_type2(type2) { - return x4_info; } - std::function GetSetter() const + std::function GetCollider() const { return x0_collider; } + const char* GetType1() const { return x4_type1; } + const char* GetType2() const { return x8_type2; } + }; + + class BooleanComparison + { + std::function x0_collider; + const char* x4_type1; + const char* x8_type2; + + public: + BooleanComparison(const std::function& collider, const char* type1, + const char* type2) + : x0_collider(collider), + x4_type1(type1), + x8_type2(type2) { - return x0_setter; } + + std::function GetCollider() const { return x0_collider; } + const char* GetType1() const { return x4_type1; } + const char* GetType2() const { return x8_type2; } }; CCollisionPrimitive()=default; @@ -59,7 +118,10 @@ public: static void InitEndTypes(); static void InitBeginColliders(); - static void InitAddCollider(const Type& tp); + static void InitAddBooleanCollider(const BooleanComparison& cmp); + static void InitAddMovingCollider(const MovingComparison& cmp); + static void InitAddCollider(const Comparison& cmp); + static void InitEndColliders(); }; } diff --git a/Runtime/Collision/CCollisionSurface.cpp b/Runtime/Collision/CCollisionSurface.cpp new file mode 100644 index 000000000..b9c38f8dc --- /dev/null +++ b/Runtime/Collision/CCollisionSurface.cpp @@ -0,0 +1,12 @@ +#include "CCollisionSurface.hpp" + +namespace urde +{ +CCollisionSurface::CCollisionSurface(const zeus::CVector3f& a, const zeus::CVector3f& b, const zeus::CVector3f& c, u32 flags) + : x0_a(a), + xc_b(b), + x18_c(c), + x24_flags(flags) +{ +} +} diff --git a/Runtime/Collision/CCollisionSurface.hpp b/Runtime/Collision/CCollisionSurface.hpp new file mode 100644 index 000000000..0f38b5b6b --- /dev/null +++ b/Runtime/Collision/CCollisionSurface.hpp @@ -0,0 +1,22 @@ +#ifndef __URDE_CCOLLISIONSURFACE_HPP__ +#define __URDE_CCOLLISIONSURFACE_HPP__ + +#include "zeus/zeus.hpp" +#include "RetroTypes.hpp" + +namespace urde +{ +class CCollisionSurface +{ + zeus::CVector3f x0_a; + zeus::CVector3f xc_b; + zeus::CVector3f x18_c; + u32 x24_flags; +public: + CCollisionSurface(const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CVector3f&, u32); + + zeus::CVector3f GetPoint(u32) const; +}; +} + +#endif // __URDE_CCOLLISIONSURFACE_HPP__ diff --git a/Runtime/Collision/CGameCollision.cpp b/Runtime/Collision/CGameCollision.cpp index 4abd80232..7b5ff301a 100644 --- a/Runtime/Collision/CGameCollision.cpp +++ b/Runtime/Collision/CGameCollision.cpp @@ -1 +1,13 @@ #include "CMaterialFilter.hpp" +#include "CGameCollision.hpp" +#include "CCollidableOBBTreeGroup.hpp" + +namespace urde +{ + +void CGameCollision::InitCollision() +{ + CCollisionPrimitive::InitBeginTypes(); +} + +} diff --git a/Runtime/Collision/CInternalRayCastStructure.hpp b/Runtime/Collision/CInternalRayCastStructure.hpp index ce8f50ce8..69ab7575d 100644 --- a/Runtime/Collision/CInternalRayCastStructure.hpp +++ b/Runtime/Collision/CInternalRayCastStructure.hpp @@ -24,7 +24,7 @@ public: const zeus::CMRay& GetRay() const { return x0_ray; } const zeus::CVector3f& GetStart() const { return x0_ray.start; } const zeus::CVector3f& GetNormal() const { return x0_ray.normal; } - float GetMaxTime() const { return 0.f; } + float GetMaxTime() const { return x38_maxTime; } const zeus::CTransform& GetTransform() const { return x3c_xf; } const CMaterialFilter& GetFilter() const { return x6c_filter; } }; diff --git a/Runtime/Collision/CMakeLists.txt b/Runtime/Collision/CMakeLists.txt index f6e667126..ad4202743 100644 --- a/Runtime/Collision/CMakeLists.txt +++ b/Runtime/Collision/CMakeLists.txt @@ -1,8 +1,15 @@ set(COLLISION_SOURCES + CollisionUtil.hpp CollisionUtil.cpp CGameCollision.hpp CGameCollision.cpp CCollisionInfo.hpp CCollisionInfo.cpp + CCollisionInfoList.hpp CCollisionInfoList.cpp CCollisionEdge.hpp CCollisionEdge.cpp + CCollisionSurface.hpp CCollisionSurface.cpp + InternalColliders.hpp InternalColliders.cpp COBBTree.hpp COBBTree.cpp + CCollidableAABox.hpp CCollidableAABox.cpp + CCollidableCollisionSurface.hpp CCollidableCollisionSurface.cpp + CCollidableSphere.hpp CCollidableSphere.cpp CCollidableOBBTree.hpp CCollidableOBBTree.cpp CCollidableOBBTreeGroup.hpp CCollidableOBBTreeGroup.cpp CCollisionPrimitive.hpp CCollisionPrimitive.cpp diff --git a/Runtime/Collision/COBBTree.cpp b/Runtime/Collision/COBBTree.cpp index d80a137f8..f990ee8e7 100644 --- a/Runtime/Collision/COBBTree.cpp +++ b/Runtime/Collision/COBBTree.cpp @@ -15,7 +15,9 @@ u32 verify_version(CInputStream& in) return in.readUint32Big(); } -COBBTree::COBBTree(const COBBTree::SIndexData&, const COBBTree::CNode*) +COBBTree::COBBTree(const SIndexData& indexData, const CNode* root) + : x18_indexData(indexData), + x88_root((CNode*)root) { } @@ -114,6 +116,25 @@ const zeus::COBBox& COBBTree::CNode::GetOBB() const return x0_obb; } +size_t COBBTree::CNode::GetMemoryUsage() const +{ + size_t ret = 0; + if (x3c_isLeaf) + ret = x48_leaf->GetMemoryUsage() + 80; + else + { + if (x40_left) + ret = x40_left->GetMemoryUsage() + 80; + if (x44_right) + ret += x44_right->GetMemoryUsage(); + } + + if (!(ret & 3)) + return ret; + + return ret + ((ret & 3) - 4); +} + COBBTree::CLeafData::CLeafData(const std::vector& surface) : x0_surface(surface) { @@ -124,6 +145,14 @@ const std::vector& COBBTree::CLeafData::GetSurfaceVector() const return x0_surface; } +size_t COBBTree::CLeafData::GetMemoryUsage() const +{ + size_t ret = (x0_surface.size() * 2) + 16; + if (!(ret & 3)) + return ret; + return ret + ((ret & 3) - 4); +} + COBBTree::CLeafData::CLeafData(CInputStream& in) { u32 edgeCount = in.readUint32Big(); diff --git a/Runtime/Collision/COBBTree.hpp b/Runtime/Collision/COBBTree.hpp index 38e89d42b..2a8fbe2d1 100644 --- a/Runtime/Collision/COBBTree.hpp +++ b/Runtime/Collision/COBBTree.hpp @@ -32,6 +32,7 @@ public: CLeafData(CInputStream&); const std::vector& GetSurfaceVector() const; + size_t GetMemoryUsage() const; }; class CNode @@ -48,11 +49,12 @@ public: CNode(CInputStream&); bool WasHit() const; - void SetWasHit(bool) const; + void SetHit(bool) const; CNode* GetLeft() const; CNode* GetRight() const; CLeafData* GetLeafData() const; const zeus::COBBox& GetOBB() const; + size_t GetMemoryUsage() const; }; private: diff --git a/Runtime/Collision/CollisionUtil.cpp b/Runtime/Collision/CollisionUtil.cpp new file mode 100644 index 000000000..c04319456 --- /dev/null +++ b/Runtime/Collision/CollisionUtil.cpp @@ -0,0 +1,25 @@ +#include "CollisionUtil.hpp" +namespace urde +{ +namespace CollisionUtil +{ +bool LineIntersectsOBBox(const zeus::COBBox& obb, const zeus::CMRay& ray, float& d) +{ + const zeus::CVector3f transXf = obb.transform.toMatrix4f().vec[0].toVec3f(); + return RayAABoxIntersection(ray.getInvUnscaledTransformRay(obb.transform), {-obb.extents, obb.extents}, + transXf, d); +} + +u32 RayAABoxIntersection(const zeus::CMRay& ray, const zeus::CAABox& box, const zeus::CVector3f&, float& d) +{ + + return 0; +} + +u32 RaySphereIntersection_Double(const zeus::CSphere&, const zeus::CVector3f &, const zeus::CVector3f &, double &) +{ + return 0; +} + +} +} diff --git a/Runtime/Collision/CollisionUtil.hpp b/Runtime/Collision/CollisionUtil.hpp new file mode 100644 index 000000000..6e2e68f4c --- /dev/null +++ b/Runtime/Collision/CollisionUtil.hpp @@ -0,0 +1,16 @@ +#ifndef __URDE_COLLISIONUTIL_HPP__ +#define __URDE_COLLISIONUTIL_HPP__ + +#include "GCNTypes.hpp" +#include "zeus/zeus.hpp" + +namespace urde +{ +namespace CollisionUtil +{ +bool LineIntersectsOBBox(const zeus::COBBox&, const zeus::CMRay&, float&); +u32 RayAABoxIntersection(const zeus::CMRay&, const zeus::CAABox&, const zeus::CVector3f&, float&); +u32 RaySphereIntersection_Double(const zeus::CSphere&, const zeus::CVector3f&, const zeus::CVector3f&, double&); +} +} +#endif // __URDE_COLLISIONUTIL_HPP__ diff --git a/Runtime/Collision/InternalColliders.cpp b/Runtime/Collision/InternalColliders.cpp new file mode 100644 index 000000000..55719a145 --- /dev/null +++ b/Runtime/Collision/InternalColliders.cpp @@ -0,0 +1,17 @@ +#include "InternalColliders.hpp" +#include "CCollidableAABox.hpp" +#include "CCollidableCollisionSurface.hpp" +#include "CCollidableSphere.hpp" + +namespace urde +{ +namespace InternalColliders +{ +void AddTypes() +{ + CCollisionPrimitive::InitAddType(CCollidableAABox::GetType()); + CCollisionPrimitive::InitAddType(CCollidableCollisionSurface::GetType()); + CCollisionPrimitive::InitAddType(CCollidableSphere::GetType()); +} +} +} diff --git a/Runtime/Collision/InternalColliders.hpp b/Runtime/Collision/InternalColliders.hpp new file mode 100644 index 000000000..664ab17f0 --- /dev/null +++ b/Runtime/Collision/InternalColliders.hpp @@ -0,0 +1,11 @@ +#ifndef __URDE_INTERNALCOLLIDERS_HPP__ +#define __URDE_INTERNALCOLLIDERS_HPP__ + +namespace urde +{ +namespace InternalColliders +{ + void AddTypes(); +} +} +#endif // __URDE_INTERNALCOLLIDERS_HPP__ diff --git a/Runtime/GuiSys/CGuiCamera.cpp b/Runtime/GuiSys/CGuiCamera.cpp index f3d1bf865..878aa019a 100644 --- a/Runtime/GuiSys/CGuiCamera.cpp +++ b/Runtime/GuiSys/CGuiCamera.cpp @@ -38,7 +38,7 @@ zeus::CVector3f CGuiCamera::ConvertToScreenSpace(const zeus::CVector3f& vec) con void CGuiCamera::Draw(const CGuiWidgetDrawParms& parms) const { - if (xf8_proj == Projection::Perspective) + if (xf8_proj == EProjection::Perspective) CGraphics::SetPerspective(xfc_fov, x100_aspect, x104_znear, x108_zfar); else CGraphics::SetOrtho(xfc_left, x100_right, x104_top, x108_bottom, x10c_znear, x110_zfar); @@ -49,11 +49,11 @@ void CGuiCamera::Draw(const CGuiWidgetDrawParms& parms) const CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag) { CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag); - Projection proj = Projection(in.readUint32Big()); + EProjection proj = EProjection(in.readUint32Big()); CGuiCamera* ret = nullptr; switch (proj) { - case Projection::Perspective: + case EProjection::Perspective: { float fov = in.readFloatBig(); float aspect = in.readFloatBig(); @@ -62,7 +62,7 @@ CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag) ret = new CGuiCamera(parms, fov, aspect, znear, zfar); break; } - case Projection::Orthographic: + case EProjection::Orthographic: { float left = in.readFloatBig(); float right = in.readFloatBig(); diff --git a/Runtime/GuiSys/CGuiCamera.hpp b/Runtime/GuiSys/CGuiCamera.hpp index 8b64d41d3..deefab497 100644 --- a/Runtime/GuiSys/CGuiCamera.hpp +++ b/Runtime/GuiSys/CGuiCamera.hpp @@ -9,13 +9,13 @@ namespace urde class CGuiCamera : public CGuiWidget { public: - enum class Projection + enum class EProjection { Perspective, Orthographic }; private: - Projection xf8_proj; + EProjection xf8_proj; union { struct diff --git a/Runtime/Particle/CCollisionResponseData.cpp b/Runtime/Particle/CCollisionResponseData.cpp index fd0aceb5e..33c7fc03a 100644 --- a/Runtime/Particle/CCollisionResponseData.cpp +++ b/Runtime/Particle/CCollisionResponseData.cpp @@ -69,7 +69,7 @@ static const std::vector DecalTypes = SBIG('NCDL'),SBIG('DDCL'),SBIG('CODL'),SBIG('MEDL'), SBIG('GRDL'),SBIG('ICDL'),SBIG('GODL'),SBIG('WODL'), SBIG('WTDL'),SBIG('3MUD'),SBIG('3LAV'),SBIG('3SAN'), - SBIG('CHDL') + SBIG('CHDL'),SBIG('ENDL') }; using CPF = CParticleDataFactory; diff --git a/specter b/specter index 4dff27e3c..47a6e28db 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 4dff27e3c69b11d7fa8232c4b32d28089e524b57 +Subproject commit 47a6e28db624f100e8cbc6ef11f3feba2a575ec7