Match and link InternalColliders

Former-commit-id: 9a6b212fb1bc4b57ae1701c6333d2d903dce8935
This commit is contained in:
Phillip Stephens 2023-10-19 21:15:38 -07:00
parent 12e5a2c300
commit 3cb651ad95
14 changed files with 149 additions and 22 deletions

View File

@ -11749,9 +11749,9 @@ reserve__Q24rstl42vector<6CAABox,Q24rstl17rmemory_allocator>Fi = .text:0x802AE2C
GetEntityIdByIndex__11CPVSAreaSetCFUi = .text:0x802AE3E4; // type:function size:0x10 scope:global GetEntityIdByIndex__11CPVSAreaSetCFUi = .text:0x802AE3E4; // type:function size:0x10 scope:global
GetLightSet__11CPVSAreaSetCFi = .text:0x802AE3F4; // type:function size:0x90 scope:global GetLightSet__11CPVSAreaSetCFi = .text:0x802AE3F4; // type:function size:0x90 scope:global
GetVisOctree__11CPVSAreaSetCFUi = .text:0x802AE484; // type:function size:0x8 scope:global GetVisOctree__11CPVSAreaSetCFUi = .text:0x802AE484; // type:function size:0x8 scope:global
__ct__11CPVSAreaSetFPCci = .text:0x802AE48C; // type:function size:0x11C scope:global MakeAreaSet__11CPVSAreaSetFPCci = .text:0x802AE48C; // type:function size:0x11C scope:global
__ct__Q211CPVSAreaSet14CPVSAreaHolderFiiiiiiii = .text:0x802AE5A8; // type:function size:0x88 scope:global __ct__11CPVSAreaSetFiiiiiiPCcPCcPCc = .text:0x802AE5A8; // type:function size:0x88 scope:global
__ct__13CPVSVisOctreeFR13CPVSVisOctree = .text:0x802AE630; // type:function size:0x94 scope:global __ct__13CPVSVisOctreeFRC13CPVSVisOctree = .text:0x802AE630; // type:function size:0x94 scope:global
TestBit__13CCubeRendererFPCUii = .text:0x802AE6C4; // type:function size:0x2C scope:global TestBit__13CCubeRendererFPCUii = .text:0x802AE6C4; // type:function size:0x2C scope:global
RecursiveBuildOverlaps__18CAreaRenderOctTreeFPUiRC18CAreaRenderOctTreeRC6CAABoxRC6CAABox = .text:0x802AE6F0; // type:function size:0x128 scope:global RecursiveBuildOverlaps__18CAreaRenderOctTreeFPUiRC18CAreaRenderOctTreeRC6CAABoxRC6CAABox = .text:0x802AE6F0; // type:function size:0x128 scope:global
FindOverlappingModels__18CAreaRenderOctTreeFPUiRC6CAABox = .text:0x802AE818; // type:function size:0x3C scope:global FindOverlappingModels__18CAreaRenderOctTreeFPUiRC6CAABox = .text:0x802AE818; // type:function size:0x3C scope:global
@ -14708,10 +14708,10 @@ SetIconAddr__8CARDStatFi = .text:0x8034E538; // type:function size:0x8 scope:glo
SetIconSpeed__8CARDStatFii = .text:0x8034E540; // type:function size:0x24 scope:global SetIconSpeed__8CARDStatFii = .text:0x8034E540; // type:function size:0x24 scope:global
SetIconFormat__8CARDStatFii = .text:0x8034E564; // type:function size:0x24 scope:global SetIconFormat__8CARDStatFii = .text:0x8034E564; // type:function size:0x24 scope:global
SetBannerFormat__8CARDStatFi = .text:0x8034E588; // type:function size:0x14 scope:global SetBannerFormat__8CARDStatFi = .text:0x8034E588; // type:function size:0x14 scope:global
GetCommentAddr__8CardStatCFv = .text:0x8034E59C; // type:function size:0x8 scope:global GetCommentAddr__8CARDStatCFv = .text:0x8034E59C; // type:function size:0x8 scope:global
GetIconFormat__8CARDStatFi = .text:0x8034E5A4; // type:function size:0x14 scope:global GetIconFormat__8CARDStatFi = .text:0x8034E5A4; // type:function size:0x14 scope:global
GetBannerFormat__8CARDStatFv = .text:0x8034E5B8; // type:function size:0xC scope:global GetBannerFormat__8CARDStatFv = .text:0x8034E5B8; // type:function size:0xC scope:global
GetTime__8CardStatCFv = .text:0x8034E5C4; // type:function size:0x8 scope:global GetTime__8CARDStatCFv = .text:0x8034E5C4; // type:function size:0x8 scope:global
GetFileLength__8CARDStatFv = .text:0x8034E5CC; // type:function size:0x8 scope:global GetFileLength__8CARDStatFv = .text:0x8034E5CC; // type:function size:0x8 scope:global
CalculateBannerDataSize__13CCardFileInfoFv = .text:0x8034E5D4; // type:function size:0x84 scope:global CalculateBannerDataSize__13CCardFileInfoFv = .text:0x8034E5D4; // type:function size:0x84 scope:global
CalculateTotalDataSize__13CCardFileInfoFv = .text:0x8034E658; // type:function size:0x38 scope:global CalculateTotalDataSize__13CCardFileInfoFv = .text:0x8034E658; // type:function size:0x38 scope:global

View File

@ -11762,9 +11762,9 @@ reserve__Q24rstl42vector<6CAABox,Q24rstl17rmemory_allocator>Fi = .text:0x802AE37
GetEntityIdByIndex__11CPVSAreaSetCFUi = .text:0x802AE490; // type:function size:0x10 scope:global GetEntityIdByIndex__11CPVSAreaSetCFUi = .text:0x802AE490; // type:function size:0x10 scope:global
GetLightSet__11CPVSAreaSetCFi = .text:0x802AE4A0; // type:function size:0x90 scope:global GetLightSet__11CPVSAreaSetCFi = .text:0x802AE4A0; // type:function size:0x90 scope:global
GetVisOctree__11CPVSAreaSetCFUi = .text:0x802AE530; // type:function size:0x8 scope:global GetVisOctree__11CPVSAreaSetCFUi = .text:0x802AE530; // type:function size:0x8 scope:global
__ct__11CPVSAreaSetFPCci = .text:0x802AE538; // type:function size:0x11C scope:global MakeAreaSet__11CPVSAreaSetFPCci = .text:0x802AE538; // type:function size:0x11C scope:global
__ct__Q211CPVSAreaSet14CPVSAreaHolderFiiiiiiii = .text:0x802AE654; // type:function size:0x88 scope:global __ct__Q211CPVSAreaSet14CPVSAreaHolderFiiiiiiii = .text:0x802AE654; // type:function size:0x88 scope:global
__ct__13CPVSVisOctreeFR13CPVSVisOctree = .text:0x802AE6DC; // type:function size:0x94 scope:global __ct__11CPVSAreaSetFiiiiiiPCcPCcPCc = .text:0x802AE6DC; // type:function size:0x94 scope:global
TestBit__13CCubeRendererFPCUii = .text:0x802AE770; // type:function size:0x2C scope:global TestBit__13CCubeRendererFPCUii = .text:0x802AE770; // type:function size:0x2C scope:global
RecursiveBuildOverlaps__18CAreaRenderOctTreeFPUiRC18CAreaRenderOctTreeRC6CAABoxRC6CAABox = .text:0x802AE79C; // type:function size:0x128 scope:global RecursiveBuildOverlaps__18CAreaRenderOctTreeFPUiRC18CAreaRenderOctTreeRC6CAABoxRC6CAABox = .text:0x802AE79C; // type:function size:0x128 scope:global
FindOverlappingModels__18CAreaRenderOctTreeFPUiRC6CAABox = .text:0x802AE8C4; // type:function size:0x3C scope:global FindOverlappingModels__18CAreaRenderOctTreeFPUiRC6CAABox = .text:0x802AE8C4; // type:function size:0x3C scope:global

View File

@ -727,7 +727,7 @@ config.libs = [
Object(NonMatching, "Collision/CCollidableAABox.cpp"), Object(NonMatching, "Collision/CCollidableAABox.cpp"),
Object(Matching, "Collision/CCollidableCollisionSurface.cpp"), Object(Matching, "Collision/CCollidableCollisionSurface.cpp"),
Object(Matching, "Collision/CCollisionInfo.cpp"), Object(Matching, "Collision/CCollisionInfo.cpp"),
Object(NonMatching, "Collision/InternalColliders.cpp"), Object(Matching, "Collision/InternalColliders.cpp"),
Object(NonMatching, "Collision/CCollisionPrimitive.cpp"), Object(NonMatching, "Collision/CCollisionPrimitive.cpp"),
Object(Matching, "Collision/CMaterialList.cpp"), Object(Matching, "Collision/CMaterialList.cpp"),
Object(NonMatching, "Collision/CollisionUtil.cpp"), Object(NonMatching, "Collision/CollisionUtil.cpp"),

View File

@ -11,10 +11,10 @@ public:
CCollidableAABox(const CAABox& box, const CMaterialList& matList) CCollidableAABox(const CAABox& box, const CMaterialList& matList)
: CCollisionPrimitive(matList), x10_aabb(box) {} : CCollisionPrimitive(matList), x10_aabb(box) {}
bool CollideMovingAABox(const CInternalCollisionStructure& collision, const CVector3f& dir, static bool CollideMovingAABox(const CInternalCollisionStructure& collision, const CVector3f& dir,
double& dOut, CCollisionInfo& infoOut); double& dOut, CCollisionInfo& infoOut);
bool CollideMovingSphere(const CInternalCollisionStructure& collision, const CVector3f& dir, static bool CollideMovingSphere(const CInternalCollisionStructure& collision,
double& dOut, CCollisionInfo& infoOut); const CVector3f& dir, double& dOut, CCollisionInfo& infoOut);
uint GetTableIndex() const; uint GetTableIndex() const;
CAABox CalculateAABox(const CTransform4f&) const; CAABox CalculateAABox(const CTransform4f&) const;
@ -36,5 +36,6 @@ CHECK_SIZEOF(CCollidableAABox, 0x28)
namespace Collide { namespace Collide {
bool AABox_AABox_Bool(const CInternalCollisionStructure&); bool AABox_AABox_Bool(const CInternalCollisionStructure&);
bool AABox_AABox(const CInternalCollisionStructure& collision, CCollisionInfoList& list); bool AABox_AABox(const CInternalCollisionStructure& collision, CCollisionInfoList& list);
bool Sphere_AABox(const CInternalCollisionStructure& collision, CCollisionInfoList& list);
} // namespace Collide } // namespace Collide
#endif // _CCOLLIDABLEAABOX #endif // _CCOLLIDABLEAABOX

View File

@ -12,6 +12,11 @@ public:
CCollidableSphere(const CSphere& sphere, const CMaterialList& material) CCollidableSphere(const CSphere& sphere, const CMaterialList& material)
: CCollisionPrimitive(material), x10_sphere(sphere) {} : CCollisionPrimitive(material), x10_sphere(sphere) {}
static bool CollideMovingAABox(const CInternalCollisionStructure& collision, const CVector3f& dir,
double& dOut, CCollisionInfo& infoOut);
static bool CollideMovingSphere(const CInternalCollisionStructure& collision,
const CVector3f& dir, double& dOut, CCollisionInfo& infoOut);
uint GetTableIndex() const override; uint GetTableIndex() const override;
CAABox CalculateAABox(const CTransform4f&) const override; CAABox CalculateAABox(const CTransform4f&) const override;
CAABox CalculateLocalAABox() const override; CAABox CalculateLocalAABox() const override;
@ -19,9 +24,17 @@ public:
~CCollidableSphere() override {} ~CCollidableSphere() override {}
CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const; CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const;
static Type GetType();
private: private:
CSphere x10_sphere; CSphere x10_sphere;
}; };
CHECK_SIZEOF(CCollidableSphere, 0x20) CHECK_SIZEOF(CCollidableSphere, 0x20)
namespace Collide {
bool Sphere_Sphere(const CInternalCollisionStructure& collision, CCollisionInfoList& list);
bool Sphere_AABox_Bool(const CInternalCollisionStructure& collision);
bool Sphere_Sphere_Bool(const CInternalCollisionStructure& collision);
} // namespace Collide
#endif // _CCOLLIDABLESPHERE #endif // _CCOLLIDABLESPHERE

View File

@ -38,6 +38,10 @@ public:
const char* mInfo; const char* mInfo;
}; };
class Comparison {
};
CCollisionPrimitive(const CMaterialList& list); CCollisionPrimitive(const CMaterialList& list);
virtual uint GetTableIndex() const = 0; virtual uint GetTableIndex() const = 0;
@ -52,6 +56,12 @@ public:
static void InitBeginTypes(); static void InitBeginTypes();
static void InitAddType(const Type& type); static void InitAddType(const Type& type);
static void InitEndTypes(); static void InitEndTypes();
static void InitBeginColliders();
static void InitAddCollider(const Comparison& comp);
static void InitAddCollider(ComparisonFunc comp, const char*, const char*);
static void InitAddBooleanCollider(BooleanComparisonFunc comp, const char*, const char*);
static void InitAddMovingCollider(MovingComparisonFunc comp, const char*, const char*);
static void InitEndColliders();
static void Uninitialize(); static void Uninitialize();
private: private:

View File

@ -2,4 +2,5 @@
namespace InternalColliders { namespace InternalColliders {
void AddTypes(); void AddTypes();
void AddColliders();
} }

View File

@ -10,6 +10,8 @@ public:
int IterateSearch(uchar a, const CVector3f& pos) const; int IterateSearch(uchar a, const CVector3f& pos) const;
uint GetNumChildren(uchar a) const; uint GetNumChildren(uchar a) const;
static CPVSVisOctree MakePVSVisOctree(const char* data, int len);
private: private:
CAABox mBounds; CAABox mBounds;
uint mNumObjects; uint mNumObjects;

View File

@ -45,6 +45,7 @@ public:
short ReadInt16() { return Get< short >(); } short ReadInt16() { return Get< short >(); }
uint GetBlockOffset() const { return x4_blockOffset; } uint GetBlockOffset() const { return x4_blockOffset; }
const uint GetReadPosition() const { return x18_readPosition; }
private: private:
bool GrabAnotherBlock(); bool GrabAnotherBlock();

View File

@ -1,11 +1,32 @@
#ifndef _CPVSAREASET #ifndef _CPVSAREASET
#define _CPVSAREASET #define _CPVSAREASET
#include "Kyoto/PVS/CPVSVisOctree.hpp"
class CPVSVisSet; class CPVSVisSet;
class CInputStream;
class CPVSAreaSet { class CPVSAreaSet {
public: public:
CPVSAreaSet(const int, const int, const int, const int, const int, const int, const char*,
const char*, const char*);
const CPVSVisOctree& GetOctree() const { return x20_octree; }
static rstl::auto_ptr< CPVSAreaSet > MakeAreaSet(const char* data, int len);
CPVSVisSet GetLightSet(int) const; CPVSVisSet GetLightSet(int) const;
const CPVSVisOctree& GetVisOctree(const uint) const;
private:
int x0_;
int x4_;
int x8_;
int xc_;
int x10_;
int x14_;
const char* x18_;
const char* x1c_;
CPVSVisOctree x20_octree;
}; };
#endif // _CPVSAREASET #endif // _CPVSAREASET

View File

@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSBOOTINFO #ifndef _DOLPHIN_OSBOOTINFO
#define _DOLPHIN_OSBOOTINFO #define _DOLPHIN_OSBOOTINFO
#include "dolphin/DVDPriv.h"
#include "dolphin/types.h"
typedef struct OSBootInfo { typedef struct OSBootInfo {
DVDDiskID DVDDiskID; DVDDiskID DVDDiskID;
u32 magic; u32 magic;
@ -36,4 +39,12 @@ typedef struct BI2Debug {
u32 padSpec; // 0x24 u32 padSpec; // 0x24
} BI2Debug; } BI2Debug;
// Magic number defines.
#define OS_BOOTINFO_MAGIC 0x0D15EA5E
#define OS_BOOTINFO_MAGIC_JTAG 0xE5207C22
#define OS_DVD_MAGIC_NINTENDO 0xC2339F3D
#define OS_THREAD_STACK_MAGIC 0xDEADBABE
#define OS_BOOTROM_ADDR 0x81300000
#endif // _DOLPHIN_OSBOOTINFO #endif // _DOLPHIN_OSBOOTINFO

View File

@ -0,0 +1,24 @@
#include "Collision/CCollisionPrimitive.hpp"
#include <Collision/InternalColliders.hpp>
#include <Collision/CCollidableAABox.hpp>
#include <Collision/CCollidableSphere.hpp>
#include <Collision/CCollidableCollisionSurface.hpp>
void InternalColliders::AddTypes() {
CCollisionPrimitive::InitAddType(CCollidableAABox::GetType());
CCollisionPrimitive::InitAddType(CCollidableCollisionSurface::GetType());
CCollisionPrimitive::InitAddType(CCollidableSphere::GetType());
}
void InternalColliders::AddColliders() {
CCollisionPrimitive::InitAddCollider(Collide::AABox_AABox, "CCollidableAABox", "CCollidableAABox");
CCollisionPrimitive::InitAddCollider(Collide::Sphere_AABox, "CCollidableSphere", "CCollidableAABox");
CCollisionPrimitive::InitAddCollider(Collide::Sphere_Sphere, "CCollidableSphere", "CCollidableSphere");
CCollisionPrimitive::InitAddBooleanCollider(Collide::AABox_AABox_Bool, "CCollidableAABox", "CCollidableAABox");
CCollisionPrimitive::InitAddBooleanCollider(Collide::Sphere_AABox_Bool, "CCollidableSphere", "CCollidableAABox");
CCollisionPrimitive::InitAddBooleanCollider(Collide::Sphere_Sphere_Bool, "CCollidableSphere", "CCollidableSphere");
CCollisionPrimitive::InitAddMovingCollider(CCollidableAABox::CollideMovingAABox, "CCollidableAABox", "CCollidableAABox");
CCollisionPrimitive::InitAddMovingCollider(CCollidableAABox::CollideMovingSphere, "CCollidableAABox", "CCollidableSphere");
CCollisionPrimitive::InitAddMovingCollider(CCollidableSphere::CollideMovingAABox, "CCollidableSphere", "CCollidableAABox");
CCollisionPrimitive::InitAddMovingCollider(CCollidableSphere::CollideMovingSphere, "CCollidableSphere", "CCollidableSphere");
}

View File

@ -1,12 +1,14 @@
#include "dolphin/os.h" #include "dolphin/os.h"
#include "dolphin/os/OSBootInfo.h"
#include "dolphin/dvd.h"
typedef struct ApploaderHeader { typedef struct ApploaderHeader {
// total size: 0x20 // total size: 0x20
char date[16]; // offset 0x0, size 0x10 char date[16]; // offset 0x0, size 0x10
u32 entry; // offset 0x10, size 0x4 u32 entry; // offset 0x10, size 0x4
u32 size; // offset 0x14, size 0x4 u32 size; // offset 0x14, size 0x4
u32 rebootSize; // offset 0x18, size 0x4 u32 rebootSize; // offset 0x18, size 0x4
u32 reserved2; // offset 0x1C, size 0x4 u32 reserved2; // offset 0x1C, size 0x4
} ApploaderHeader; } ApploaderHeader;
static ApploaderHeader Header; static ApploaderHeader Header;
@ -17,6 +19,10 @@ extern void* __OSSavedRegionEnd;
static void* SaveStart = NULL; static void* SaveStart = NULL;
static void* SaveEnd = NULL; static void* SaveEnd = NULL;
extern u32 BOOT_REGION_START AT_ADDRESS(0x812FDFF0); //(*(u32 *)0x812fdff0)
extern u32 BOOT_REGION_END AT_ADDRESS(0x812FDFEC); //(*(u32 *)0x812fdfec)
extern u32 __OSIsGcam;
static BOOL Prepared = FALSE; static BOOL Prepared = FALSE;
asm void Run() { asm void Run() {
@ -29,12 +35,12 @@ asm void Run() {
// clang-format on // clang-format on
} }
static void Callback() { static void Callback() { Prepared = TRUE; }
Prepared = TRUE;
void ReadApploader(OSTime time1, OSTime time2) {
} }
void __OSReboot(u32 resetCode, u32 bootDol) { void __OSReboot(u32 resetCode, u32 bootDol) {
OSDisableInterrupts();
} }
void OSSetSaveRegion(void* start, void* end) { void OSSetSaveRegion(void* start, void* end) {

View File

@ -0,0 +1,37 @@
#include "Kyoto/PVS/CPVSVisOctree.hpp"
#include "rstl/auto_ptr.hpp"
#include <WorldFormat/CPVSAreaSet.hpp>
#include <Kyoto/Streams/CMemoryInStream.hpp>
#pragma inline_max_size(250)
CPVSAreaSet::CPVSAreaSet(int numFeatures, int numLights, int num2ndLights, int numActors,
int leafSize, int lightIndexCount, const char* w7, const char* w8,
const char* w9)
: x0_(numFeatures)
, x4_(numLights)
, x8_(num2ndLights)
, xc_(numActors)
, x10_(leafSize)
, x14_(lightIndexCount)
, x18_(w7)
, x1c_(w8)
, x20_octree(CPVSVisOctree::MakePVSVisOctree(w9, 68)) {}
rstl::auto_ptr< CPVSAreaSet > CPVSAreaSet::MakeAreaSet(const char* data, int len) {
CMemoryInStream in(data, len);
int numFeatures = in.ReadLong();
int numLights = in.ReadLong();
int num2ndLights = in.ReadLong();
int numActors = in.ReadLong();
int leafSize = in.ReadLong();
int lightIndexCount = in.ReadLong();
char* data1 = (char*)(data + in.GetReadPosition());
char* entityIndexEnd = (char*)(data + in.GetReadPosition() + (numActors * 4));
char* data3 = entityIndexEnd + lightIndexCount * leafSize;
return rs_new CPVSAreaSet(numFeatures, numLights, num2ndLights, numActors, leafSize,
lightIndexCount, data1, entityIndexEnd, data3);
}
const CPVSVisOctree& CPVSAreaSet::GetVisOctree(const uint) const { return x20_octree; }