CalculateBoundingSphereRadiusCB

This commit is contained in:
Sergeanur 2019-10-10 19:07:16 +03:00
parent 69963cea68
commit c83cf31910

View File

@ -129,7 +129,20 @@ CVector &CCutsceneMgr::ms_cutsceneOffset = *(CVector*)0x8F2C0C;
float &CCutsceneMgr::ms_cutsceneTimer = *(float*)0x941548; float &CCutsceneMgr::ms_cutsceneTimer = *(float*)0x941548;
uint32 &CCutsceneMgr::ms_cutsceneLoadStatus = *(uint32*)0x95CB40; uint32 &CCutsceneMgr::ms_cutsceneLoadStatus = *(uint32*)0x95CB40;
WRAPPER RpAtomic* CalculateBoundingSphereRadiusCB(RpAtomic * atomic, void *data) { EAXJMP(0x404B40); } RpAtomic *
CalculateBoundingSphereRadiusCB(RpAtomic *atomic, void *data)
{
float radius = RpAtomicGetBoundingSphereMacro(atomic)->radius;
RwV3d center = RpAtomicGetBoundingSphereMacro(atomic)->center;
for (RwFrame *frame = RpAtomicGetFrame(atomic); RwFrameGetParent(frame); frame = RwFrameGetParent(frame))
RwV3dTransformPoints(&center, &center, 1, RwFrameGetMatrix(frame));
float size = RwV3dLength(&center) + radius;
if (size > *(float *)data)
*(float *)data = size;
return atomic;
}
void void
CCutsceneMgr::Initialise(void) CCutsceneMgr::Initialise(void)
@ -312,7 +325,7 @@ CCutsceneMgr::CreateCutsceneObject(int modelId)
pModelInfo->SetColModel(pColModel); pModelInfo->SetColModel(pColModel);
clump = (RpClump*)pModelInfo->GetRwObject(); clump = (RpClump*)pModelInfo->GetRwObject();
assert(RwObjectGetType(clump) == rpCLUMP); assert(RwObjectGetType(clump) == rpCLUMP);
RpClumpForAllAtomics(clump, (RpAtomicCallBack)CalculateBoundingSphereRadiusCB, &radius); RpClumpForAllAtomics(clump, CalculateBoundingSphereRadiusCB, &radius);
pColModel->boundingSphere.radius = radius; pColModel->boundingSphere.radius = radius;
pColModel->boundingBox.min = CVector(-radius, -radius, -radius); pColModel->boundingBox.min = CVector(-radius, -radius, -radius);
@ -422,4 +435,5 @@ InjectHook(0x4048E0, &CCutsceneMgr::DeleteCutsceneData, PATCH_JUMP);
InjectHook(0x404EE0, &CCutsceneMgr::Update, PATCH_JUMP); InjectHook(0x404EE0, &CCutsceneMgr::Update, PATCH_JUMP);
InjectHook(0x4051B0, &CCutsceneMgr::GetCutsceneTimeInMilleseconds, PATCH_JUMP); InjectHook(0x4051B0, &CCutsceneMgr::GetCutsceneTimeInMilleseconds, PATCH_JUMP);
InjectHook(0x4051F0, &CCutsceneMgr::HasCutsceneFinished, PATCH_JUMP); InjectHook(0x4051F0, &CCutsceneMgr::HasCutsceneFinished, PATCH_JUMP);
InjectHook(0x404B40, &CalculateBoundingSphereRadiusCB, PATCH_JUMP);
ENDPATCHES ENDPATCHES