From 192dcb7a41f325f2d18fad6d0d0ac4a26853ddfc Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 24 Oct 2023 09:24:51 -0700 Subject: [PATCH] PVS related imps Former-commit-id: 147cd11849f4f5531a8763c238f00e5a84ab0e18 --- config/GM8E01_00/symbols.txt | 18 ++++----- config/GM8E01_01/symbols.txt | 18 ++++----- include/Kyoto/PVS/CPVSVisOctree.hpp | 2 + include/Kyoto/PVS/CPVSVisSet.hpp | 2 +- include/WorldFormat/CCollidableOBBTree.hpp | 19 ++++++++++ .../WorldFormat/CCollidableOBBTreeGroup.hpp | 11 ++++-- include/WorldFormat/COBBTree.hpp | 6 +++ include/WorldFormat/CPVSAreaSet.hpp | 4 +- src/WorldFormat/CCollidableOBBTreeGroup.cpp | 38 +++++++++++++++++++ src/WorldFormat/CPVSAreaSet.cpp | 15 ++++++-- 10 files changed, 104 insertions(+), 29 deletions(-) create mode 100644 include/WorldFormat/CCollidableOBBTree.hpp create mode 100644 src/WorldFormat/CCollidableOBBTreeGroup.cpp diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 0d524dba..aed739cf 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -8462,7 +8462,7 @@ SphereSubdivideCollision__26CJointCollisionDescriptionF6CSegId6CSegIdffQ226CJoin SphereCollision__26CJointCollisionDescriptionF6CSegIdfRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>f = .text:0x801A880C; // type:function size:0xC0 scope:global __dt__15CCollisionActorFv = .text:0x801A88CC; // type:function size:0xE8 scope:global fn_801A89B4 = .text:0x801A89B4; // type:function size:0x58 -fn_801A8A0C = .text:0x801A8A0C; // type:function size:0x10C +__dt__32CCollidableOBBTreeGroupContainerFv = .text:0x801A8A0C; // type:function size:0x10C GetCollisionResponseType__15CCollisionActorCFRC9CVector3fRC9CVector3fRC11CWeaponModei = .text:0x801A8B18; // type:function size:0x8 scope:global fn_801A8B20 = .text:0x801A8B20; // type:function size:0x5C GetSphereRadius__15CCollisionActorCFv = .text:0x801A8B7C; // type:function size:0x8 scope:global @@ -11737,14 +11737,14 @@ __ct__23CCollidableOBBTreeGroupFP32CCollidableOBBTreeGroupContainerRC13CMaterial GetType__23CCollidableOBBTreeGroupFv = .text:0x802AD9B4; // type:function size:0x1C scope:global SetStaticTableIndex__23CCollidableOBBTreeGroupFUi = .text:0x802AD9D0; // type:function size:0x8 scope:global __ct__23CCollidableOBBTreeGroupFRC9CVector3fRC9CVector3f = .text:0x802AD9D8; // type:function size:0x27C scope:global -__ct__23CCollidableOBBTreeGroupFR12CInputStream = .text:0x802ADC54; // type:function size:0x29C scope:global +__ct__32CCollidableOBBTreeGroupContainerFR12CInputStream = .text:0x802ADC54; // type:function size:0x29C scope:global FCollidableOBBTreeGroupFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x802ADEF0; // type:function size:0x68 scope:global -__ct<23CCollidableOBBTreeGroup>__16CFactoryFnReturnFP23CCollidableOBBTreeGroup = .text:0x802ADF58; // type:function size:0xA4 scope:global -__dt__51TObjOwnerDerivedFromIObj<23CCollidableOBBTreeGroup>Fv = .text:0x802ADFFC; // type:function size:0x90 scope:global -GetIObjObjectFor__33TToken<23CCollidableOBBTreeGroup>FRCQ24rstl35auto_ptr<23CCollidableOBBTreeGroup> = .text:0x802AE08C; // type:function size:0x2C scope:global -GetNewDerivedObject__51TObjOwnerDerivedFromIObj<23CCollidableOBBTreeGroup>FRCQ24rstl35auto_ptr<23CCollidableOBBTreeGroup> = .text:0x802AE0B8; // type:function size:0x9C scope:global -fn_802AE154 = .text:0x802AE154; // type:function size:0x64 -reserve__Q24rstl44vector<8COBBTree,Q24rstl17rmemory_allocator>Fi = .text:0x802AE1B8; // type:function size:0x110 scope:global +__ct<32CCollidableOBBTreeGroupContainer>__16CFactoryFnReturnFP32CCollidableOBBTreeGroupContainer = .text:0x802ADF58; // type:function size:0xA4 scope:global +__dt__60TObjOwnerDerivedFromIObj<32CCollidableOBBTreeGroupContainer>Fv = .text:0x802ADFFC; // type:function size:0x90 scope:global +GetIObjObjectFor__42TToken<32CCollidableOBBTreeGroupContainer>FRCQ24rstl44auto_ptr<32CCollidableOBBTreeGroupContainer> = .text:0x802AE08C; // type:function size:0x2C scope:global +GetNewDerivedObject__60TObjOwnerDerivedFromIObj<32CCollidableOBBTreeGroupContainer>FRCQ24rstl44auto_ptr<32CCollidableOBBTreeGroupContainer> = .text:0x802AE0B8; // type:function size:0x9C scope:global +__dt__Q24rstl44auto_ptr<32CCollidableOBBTreeGroupContainer>Fv = .text:0x802AE154; // type:function size:0x64 +reserve__Q24rstl63vector,Q24rstl17rmemory_allocator>Fi = .text:0x802AE1B8; // type:function size:0x110 scope:global reserve__Q24rstl42vector<6CAABox,Q24rstl17rmemory_allocator>Fi = .text:0x802AE2C8; // type:function size:0x11C scope:global GetEntityIdByIndex__11CPVSAreaSetCFUi = .text:0x802AE3E4; // type:function size:0x10 scope:global GetLightSet__11CPVSAreaSetCFi = .text:0x802AE3F4; // type:function size:0x90 scope:global @@ -18621,7 +18621,7 @@ lbl_803EC428 = .data:0x803EC428; // type:object size:0x10 lbl_803EC438 = .data:0x803EC438; // type:object size:0x10 lbl_803EC448 = .data:0x803EC448; // type:object size:0x28 __vt__23CCollidableOBBTreeGroup = .data:0x803EC470; // type:object size:0x28 scope:global -lbl_803EC498 = .data:0x803EC498; // type:object size:0x10 +__vt__60TObjOwnerDerivedFromIObj<32CCollidableOBBTreeGroupContainer> = .data:0x803EC498; // type:object size:0x10 jumptable_803EC4A8 = .data:0x803EC4A8; // type:object size:0x20 scope:local lbl_803EC4C8 = .data:0x803EC4C8; // type:object size:0x20 lbl_803EC4E8 = .data:0x803EC4E8; // type:object size:0x20 diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index a716ac4a..955ca340 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -8467,7 +8467,7 @@ SphereSubdivideCollision__26CJointCollisionDescriptionF6CSegId6CSegIdffQ226CJoin SphereCollision__26CJointCollisionDescriptionF6CSegIdfRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>f = .text:0x801A8888; // type:function size:0xC0 scope:global __dt__15CCollisionActorFv = .text:0x801A8948; // type:function size:0xE8 scope:global fn_801A89B4 = .text:0x801A8A30; // type:function size:0x58 scope:global -fn_801A8A0C = .text:0x801A8A88; // type:function size:0x10C scope:global +__dt__32CCollidableOBBTreeGroupContainerFv = .text:0x801A8A88; // type:function size:0x10C scope:global GetCollisionResponseType__15CCollisionActorCFRC9CVector3fRC9CVector3fRC11CWeaponModei = .text:0x801A8B94; // type:function size:0x8 scope:global fn_801A8B20 = .text:0x801A8B9C; // type:function size:0x5C scope:global GetSphereRadius__15CCollisionActorCFv = .text:0x801A8BF8; // type:function size:0x8 scope:global @@ -11750,14 +11750,14 @@ __ct__23CCollidableOBBTreeGroupFP32CCollidableOBBTreeGroupContainerRC13CMaterial GetType__23CCollidableOBBTreeGroupFv = .text:0x802ADA60; // type:function size:0x1C scope:global SetStaticTableIndex__23CCollidableOBBTreeGroupFUi = .text:0x802ADA7C; // type:function size:0x8 scope:global __ct__23CCollidableOBBTreeGroupFRC9CVector3fRC9CVector3f = .text:0x802ADA84; // type:function size:0x27C scope:global -__ct__23CCollidableOBBTreeGroupFR12CInputStream = .text:0x802ADD00; // type:function size:0x29C scope:global +__ct__32CCollidableOBBTreeGroupContainerFR12CInputStream = .text:0x802ADD00; // type:function size:0x29C scope:global FCollidableOBBTreeGroupFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x802ADF9C; // type:function size:0x68 scope:global -__ct<23CCollidableOBBTreeGroup>__16CFactoryFnReturnFP23CCollidableOBBTreeGroup = .text:0x802AE004; // type:function size:0xA4 scope:global -__dt__51TObjOwnerDerivedFromIObj<23CCollidableOBBTreeGroup>Fv = .text:0x802AE0A8; // type:function size:0x90 scope:global -GetIObjObjectFor__33TToken<23CCollidableOBBTreeGroup>FRCQ24rstl35auto_ptr<23CCollidableOBBTreeGroup> = .text:0x802AE138; // type:function size:0x2C scope:global -GetNewDerivedObject__51TObjOwnerDerivedFromIObj<23CCollidableOBBTreeGroup>FRCQ24rstl35auto_ptr<23CCollidableOBBTreeGroup> = .text:0x802AE164; // type:function size:0x9C scope:global -fn_802AE154 = .text:0x802AE200; // type:function size:0x64 scope:global -reserve__Q24rstl44vector<8COBBTree,Q24rstl17rmemory_allocator>Fi = .text:0x802AE264; // type:function size:0x110 scope:global +__ct<32CCollidableOBBTreeGroupContainer>__16CFactoryFnReturnFP32CCollidableOBBTreeGroupContainer = .text:0x802AE004; // type:function size:0xA4 scope:global +__dt__60TObjOwnerDerivedFromIObj<32CCollidableOBBTreeGroupContainer>Fv = .text:0x802AE0A8; // type:function size:0x90 scope:global +GetIObjObjectFor__42TToken<32CCollidableOBBTreeGroupContainer>FRCQ24rstl44auto_ptr<32CCollidableOBBTreeGroupContainer> = .text:0x802AE138; // type:function size:0x2C scope:global +GetNewDerivedObject__60TObjOwnerDerivedFromIObj<32CCollidableOBBTreeGroupContainer>FRCQ24rstl44auto_ptr<32CCollidableOBBTreeGroupContainer> = .text:0x802AE164; // type:function size:0x9C scope:global +__dt__Q24rstl44auto_ptr<32CCollidableOBBTreeGroupContainer>Fv = .text:0x802AE200; // type:function size:0x64 scope:global +reserve__Q24rstl63vector,Q24rstl17rmemory_allocator>Fi = .text:0x802AE264; // type:function size:0x110 scope:global reserve__Q24rstl42vector<6CAABox,Q24rstl17rmemory_allocator>Fi = .text:0x802AE374; // type:function size:0x11C scope:global GetEntityIdByIndex__11CPVSAreaSetCFUi = .text:0x802AE490; // type:function size:0x10 scope:global GetLightSet__11CPVSAreaSetCFi = .text:0x802AE4A0; // type:function size:0x90 scope:global @@ -18672,7 +18672,7 @@ lbl_803EC428 = .data:0x803EC608; // type:object size:0x10 scope:global lbl_803EC438 = .data:0x803EC618; // type:object size:0x10 scope:global lbl_803EC448 = .data:0x803EC628; // type:object size:0x28 scope:global __vt__23CCollidableOBBTreeGroup = .data:0x803EC650; // type:object size:0x28 scope:global -lbl_803EC498 = .data:0x803EC678; // type:object size:0x10 scope:global +__vt__60TObjOwnerDerivedFromIObj<32CCollidableOBBTreeGroupContainer> = .data:0x803EC678; // type:object size:0x10 scope:global lbl_803EC4A8 = .data:0x803EC688; // type:object size:0x20 scope:global lbl_803EC4C8 = .data:0x803EC6A8; // type:object size:0x20 scope:global lbl_803EC4E8 = .data:0x803EC6C8; // type:object size:0x20 scope:global diff --git a/include/Kyoto/PVS/CPVSVisOctree.hpp b/include/Kyoto/PVS/CPVSVisOctree.hpp index a813e4fa..f5c405a6 100644 --- a/include/Kyoto/PVS/CPVSVisOctree.hpp +++ b/include/Kyoto/PVS/CPVSVisOctree.hpp @@ -9,6 +9,8 @@ class CPVSVisOctree { public: int IterateSearch(uchar a, const CVector3f& pos) const; uint GetNumChildren(uchar a) const; + uint GetNumObjects() const { return mNumObjects; } + uint GetNumLights() const { return mNumLights; } static CPVSVisOctree MakePVSVisOctree(const char* data, int len); diff --git a/include/Kyoto/PVS/CPVSVisSet.hpp b/include/Kyoto/PVS/CPVSVisSet.hpp index 26695a1d..132b2ab0 100644 --- a/include/Kyoto/PVS/CPVSVisSet.hpp +++ b/include/Kyoto/PVS/CPVSVisSet.hpp @@ -6,7 +6,7 @@ class CPVSVisSet { public: static CPVSVisSet Reset(int); - + void SetFromMemory(int numBits, int numLights, const char* leafPtr); private: int x0_state; uint x4_numBits; diff --git a/include/WorldFormat/CCollidableOBBTree.hpp b/include/WorldFormat/CCollidableOBBTree.hpp new file mode 100644 index 00000000..0592a158 --- /dev/null +++ b/include/WorldFormat/CCollidableOBBTree.hpp @@ -0,0 +1,19 @@ +#ifndef _CCOLLIDABLEOBBTREE +#define _CCOLLIDABLEOBBTREE + +#include + +class COBBTree; +class CCollidableOBBTree : public CCollisionPrimitive { + +public: + CCollidableOBBTree(const COBBTree& tree, const CMaterialList& list); + + uint GetTableIndex() const override; + CAABox CalculateAABox(const CTransform4f& xf) const override; + const CAABox CalculateLocalAABox() const override; + FourCC GetPrimType() const override; + CRayCastResult CastRayInternal(const CInternalRayCastStructure& intRayCast) const override; +}; + +#endif // _CCOLLIDABLEOBBTREE diff --git a/include/WorldFormat/CCollidableOBBTreeGroup.hpp b/include/WorldFormat/CCollidableOBBTreeGroup.hpp index e55931b5..9897a26f 100644 --- a/include/WorldFormat/CCollidableOBBTreeGroup.hpp +++ b/include/WorldFormat/CCollidableOBBTreeGroup.hpp @@ -11,14 +11,15 @@ class COBBTree; class CCollidableOBBTreeGroupContainer { +public: + CCollidableOBBTreeGroupContainer(CInputStream& in); + CCollidableOBBTreeGroupContainer(const CVector3f&, const CVector3f&); + +private: friend class CCollidableOBBTreeGroup; rstl::vector< rstl::auto_ptr< COBBTree > > x0_trees; rstl::vector< CAABox > x10_aabbs; CAABox x20_aabox; - -public: - CCollidableOBBTreeGroupContainer(CInputStream& in); - CCollidableOBBTreeGroupContainer(const CVector3f&, const CVector3f&); }; class CCollidableOBBTreeGroup : public CCollisionPrimitive { @@ -33,6 +34,8 @@ public: ~CCollidableOBBTreeGroup() override {} CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const override; + static Type GetType(); + static void SetStaticTableIndex(uint); private: CCollidableOBBTreeGroupContainer* x10_container; }; diff --git a/include/WorldFormat/COBBTree.hpp b/include/WorldFormat/COBBTree.hpp index 391348d8..2b8ac142 100644 --- a/include/WorldFormat/COBBTree.hpp +++ b/include/WorldFormat/COBBTree.hpp @@ -20,6 +20,12 @@ class COBBTree { rstl::vector x60_vertices; SIndexData(CInputStream& in); }; + +public: + COBBTree(CInputStream& in); + ~COBBTree(); +private: + char data[0x8c]; }; #endif // _COBBTREE diff --git a/include/WorldFormat/CPVSAreaSet.hpp b/include/WorldFormat/CPVSAreaSet.hpp index 33ef2d6e..f1b43bea 100644 --- a/include/WorldFormat/CPVSAreaSet.hpp +++ b/include/WorldFormat/CPVSAreaSet.hpp @@ -22,10 +22,10 @@ private: int x4_; int x8_; int xc_; - int x10_; + int x10_leafSize; int x14_; const char* x18_; - const char* x1c_; + const char* x1c_lightLeaves; CPVSVisOctree x20_octree; }; diff --git a/src/WorldFormat/CCollidableOBBTreeGroup.cpp b/src/WorldFormat/CCollidableOBBTreeGroup.cpp new file mode 100644 index 00000000..522eb073 --- /dev/null +++ b/src/WorldFormat/CCollidableOBBTreeGroup.cpp @@ -0,0 +1,38 @@ + +#include "Collision/CCollisionPrimitive.hpp" +#include + +#include +#include + +#include + +#pragma inline_max_size(250) +CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag& tag, CInputStream& in, + const CVParamTransfer& xfer) { + return rs_new CCollidableOBBTreeGroupContainer(in); +} + +CCollidableOBBTreeGroupContainer::CCollidableOBBTreeGroupContainer(CInputStream& in) +: x20_aabox(CAABox::MakeMaxInvertedBox()) { + int obbCount = in.ReadInt32(); + x0_trees.reserve(obbCount); + for (uint i = 0; i < obbCount; ++i) { + x0_trees.push_back(rs_new COBBTree(in)); + } + + x10_aabbs.reserve(x0_trees.size()); + rstl::vector< rstl::auto_ptr< COBBTree > >::iterator it = x0_trees.begin(); + for (; it != x0_trees.end(); ++it) { + CCollidableOBBTree tree(*it->get(), CMaterialList()); + CAABox box = tree.CalculateLocalAABox(); + x10_aabbs.push_back(box); + x20_aabox.AccumulateBounds(box.GetMinPoint()); + x20_aabox.AccumulateBounds(box.GetMaxPoint()); + } +} + + +CCollisionPrimitive::Type CCollidableOBBTreeGroup::GetType() { + return Type(SetStaticTableIndex, "CCollidableOBBTreeGroup"); +} diff --git a/src/WorldFormat/CPVSAreaSet.cpp b/src/WorldFormat/CPVSAreaSet.cpp index 1e5a930d..3b357982 100644 --- a/src/WorldFormat/CPVSAreaSet.cpp +++ b/src/WorldFormat/CPVSAreaSet.cpp @@ -1,8 +1,8 @@ #include "Kyoto/PVS/CPVSVisOctree.hpp" #include "rstl/auto_ptr.hpp" -#include - +#include #include +#include #pragma inline_max_size(250) CPVSAreaSet::CPVSAreaSet(int numFeatures, int numLights, int num2ndLights, int numActors, @@ -12,10 +12,10 @@ CPVSAreaSet::CPVSAreaSet(int numFeatures, int numLights, int num2ndLights, int n , x4_(numLights) , x8_(num2ndLights) , xc_(numActors) -, x10_(leafSize) +, x10_leafSize(leafSize) , x14_(lightIndexCount) , x18_(w7) -, x1c_(w8) +, x1c_lightLeaves(w8) , x20_octree(CPVSVisOctree::MakePVSVisOctree(w9, 68)) {} rstl::auto_ptr< CPVSAreaSet > CPVSAreaSet::MakeAreaSet(const char* data, int len) { @@ -35,3 +35,10 @@ rstl::auto_ptr< CPVSAreaSet > CPVSAreaSet::MakeAreaSet(const char* data, int len } const CPVSVisOctree& CPVSAreaSet::GetVisOctree(const uint) const { return x20_octree; } + +CPVSVisSet CPVSAreaSet::GetLightSet(int lightIdx) const { + CPVSVisSet ret; + ret.SetFromMemory(x20_octree.GetNumObjects(), x20_octree.GetNumLights(), + x1c_lightLeaves + x10_leafSize * lightIdx); + return ret; +}