Skip to content

Commit 1701874

Browse files
author
ReimousTH
committed
BulletCollisionFix
1 parent a51b6c2 commit 1701874

5 files changed

Lines changed: 68 additions & 111 deletions

File tree

MarathonRecomp/api/Marathon.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
#include "Sonicteam/MyPhantom.h"
6161
#include "Sonicteam/MyTexture.h"
6262
#include "Sonicteam/MyTransforms.h"
63+
#include "Sonicteam/NamedActor.h"
64+
#include "Sonicteam/NamedTask.h"
6365
#include "Sonicteam/NoSyncThread.h"
6466
#include "Sonicteam/ObjectVehicle.h"
6567
#include "Sonicteam/ObjectVehicleBike.h"
@@ -115,14 +117,10 @@
115117
#include "Sonicteam/SoX/Graphics/Xenon/DeviceXenon.h"
116118
#include "Sonicteam/SoX/Graphics/Xenon/TextureXenon.h"
117119
#include "Sonicteam/SoX/IResource.h"
118-
<<<<<<< HEAD
119120
#include "Sonicteam/SoX/IResource2.h"
120121
#include "Sonicteam/SoX/IResourceMgr.h"
121-
=======
122-
#include "Sonicteam/NamedTask.h"
123-
#include "Sonicteam/NamedActor.h"
124-
>>>>>>> b9d30a6 (Api #2)
125122
#include "Sonicteam/SoX/Input/Manager.h"
123+
#include "Sonicteam/SoX/LinkNode.h"
126124
#include "Sonicteam/SoX/Math/Matrix.h"
127125
#include "Sonicteam/SoX/Math/Quaternion.h"
128126
#include "Sonicteam/SoX/Math/Vector.h"
@@ -167,11 +165,17 @@
167165
#include "hk330/hkpBroadPhaseHandle.h"
168166
#include "hk330/hkpCdBody.h"
169167
#include "hk330/hkpCollidable.h"
168+
#include "hk330/hkpCollidableCollidableFilter.h"
169+
#include "hk330/hkpCollisionFilter.h"
170170
#include "hk330/hkpEntity.h"
171171
#include "hk330/hkpLinkedCollidable.h"
172+
#include "hk330/hkpPhantom.h"
172173
#include "hk330/hkpProperty.h"
174+
#include "hk330/hkpRayCollidableFilter.h"
175+
#include "hk330/hkpRayShapeCollectionFilter.h"
173176
#include "hk330/hkpRigidBody.h"
174177
#include "hk330/hkpShape.h"
178+
#include "hk330/hkpShapeCollectionFilter.h"
175179
#include "hk330/hkpTypedBroadPhaseHandle.h"
176180
#include "hk330/hkpWorld.h"
177181
#include "hk330/hkpWorldObject.h"

MarathonRecomp/api/Sonicteam/SoX/Physics/Havok/WorldHavok.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
#include <Marathon.inl>
44
#include <Sonicteam/SoX/Physics/World.h>
5+
#include <hk330/hkpWorld.h>
56

67
namespace Sonicteam::SoX::Physics::Havok
78
{
89
class WorldHavok : public World
910
{
1011
public:
11-
MARATHON_INSERT_PADDING(0x18);
12+
xpointer<hk330::hkpWorld> m_pWorld;
13+
MARATHON_INSERT_PADDING(0x14);
1214
bool m_IsDynamicUpdateRate;
1315
};
1416
}

MarathonRecomp/api/hk330/hkMultiThreadCheck.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

MarathonRecomp/api/hk330/hkpWorld.h

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,72 +4,59 @@
44
#include <hk330/hkReferencedObject.h>
55
#include <Sonicteam/SoX/Math/Vector.h>
66
#include <hk330/hkArray.h>
7-
#include <hk330/hkMultiThreadCheck.h>
87

98
namespace hk330
109
{
1110
class hkpRigidBody;
1211
class hkpPhantom;
1312
class hkpRigidBody;
1413
class hkpCollisionFilter;
14+
class hkpsimulation;
15+
class hkpSimulationIsland;
16+
class hkpBroadPhase;
17+
class hkpTypedBroadPhaseDispatcher;
18+
class hkpProcessCollisionInput;
19+
class hkpCollisionDispatcher;
20+
class hkpWorldMaintenanceMgr;
21+
class hkWorldMemoryAvailableWatchDog;
22+
class hkpPhantomBroadPhaseListener;
23+
class hkpEntityEntityBroadPhaseListener;
24+
class hkpBroadPhaseBorderListener;
25+
class hkpWorldOperationQueue;
1526
class hkpWorld : public hkReferencedObject
1627
{
1728
public:
18-
xpointer<void> m_simulation;
29+
30+
xpointer<hkpsimulation> m_simulation;
31+
MARATHON_INSERT_PADDING(20);
1932
Sonicteam::SoX::Math::Vector m_gravity;
20-
xpointer<void> m_fixedIsland;
33+
xpointer<hkpSimulationIsland> m_fixedIsland;
2134
xpointer<hkpRigidBody> m_fixedRigidBody;
22-
hkArray<void> m_activeSimulationIslands;
23-
hkArray<void> m_inactiveSimulationIslands;
24-
hkArray<void> m_dirtySimulationIslands;
25-
xpointer<void> m_maintenanceMgr;
26-
xpointer<void> m_memoryWatchDog;
27-
MARATHON_INSERT_PADDING(8);
28-
xpointer<void> m_broadPhase; //should be at this right position
29-
xpointer<void> m_broadPhaseDispatcher;
30-
xpointer<void> m_phantomBroadPhaseListener;
31-
xpointer<void> m_entityEntityBroadPhaseListener;
32-
xpointer<void> m_broadPhaseBorderListener;
33-
//xpointer<void> m_multithreadedSimulationJobData;
34-
//Some of them are are not need (duno why) 4 bytes
35-
xpointer<void> m_collisionInput;
35+
hkArray<hkpSimulationIsland*> m_activeSimulationIslands;
36+
hkArray<hkpSimulationIsland*> m_inactiveSimulationIslands;
37+
hkArray<hkpSimulationIsland*> m_dirtySimulationIslands;
38+
xpointer<hkpWorldMaintenanceMgr> m_maintenanceMgr;
39+
xpointer<hkWorldMemoryAvailableWatchDog> m_memoryWatchDog;
40+
xpointer<hkpBroadPhase> m_broadPhase;
41+
xpointer<hkpTypedBroadPhaseDispatcher> m_broadPhaseDispatcher;
42+
xpointer<hkpPhantomBroadPhaseListener> m_phantomBroadPhaseListener;
43+
xpointer<hkpEntityEntityBroadPhaseListener> m_entityEntityBroadPhaseListener;
44+
xpointer<hkpBroadPhaseBorderListener> m_broadPhaseBorderListener;
45+
xpointer<hkpProcessCollisionInput> m_collisionInput;
3646
xpointer<hkpCollisionFilter> m_collisionFilter;
37-
// xpointer<void> m_collisionDispatcher; probably (not need)
38-
xpointer<void> m_convexListFilter;
39-
MARATHON_INSERT_PADDING(8);
40-
xpointer<void> m_pendingOperations; // Correct Place
41-
be<int32_t> m_pendingOperationsCount; //Correct Place
47+
xpointer<hkpCollisionDispatcher> m_collisionDispatcher;
48+
xpointer<hkpWorldOperationQueue> m_pendingOperations;
49+
be<int32_t> m_pendingOperationsCount;
4250
be<int32_t> m_criticalOperationsLockCount;
4351
be<int32_t> m_criticalOperationsLockCountForPhantoms;
44-
be<bool> m_blockExecutingPendingOperations; //Correct Place
45-
be<bool> m_criticalOperationsAllowed;
46-
xpointer<void> hkpDebugInfoOnPendingOperationQueues;
47-
be<int32_t> m_pendingOperationQueueCount;
48-
hkMultiThreadCheck m_multiThreadCheck;
49-
be<bool> m_processActionsInSingleThread;
50-
be<uint32_t> m_minDesiredIslandSize;
51-
xpointer<void> m_modifyConstraintCriticalSection;
52-
xpointer<void> m_worldLock;
53-
xpointer<void> m_islandDirtyListCriticalSection;
54-
xpointer<void> m_propertyMasterLock;
55-
be<bool> m_wantSimulationIslands;
56-
be<float> m_snapCollisionToConvexEdgeThreshold;
57-
be<float> m_snapCollisionToConcaveEdgeThreshold;
58-
be<float> m_enableToiWeldRejection;
59-
be<float> m_wantDeactivation;
60-
be<float> m_shouldActivateOnRigidBodyTransformChange;
61-
be<float> m_highFrequencyDeactivationPeriod;
62-
be<float> m_lowFrequencyDeactivationPeriod;
63-
be<float> m_deactivationReferenceDistance;
64-
be<float> m_toiCollisionResponseRotateNormal;
65-
be<int32_t> m_simulationType;
66-
be<uint32_t> m_lastEntityUid;
67-
hkArray<xpointer<hkpPhantom>> hkpPhantom;
68-
52+
bool m_blockExecutingPendingOperations;
53+
bool m_criticalOperationsAllowed;
54+
MARATHON_INSERT_PADDING(0x2C);
55+
hkArray<hkpPhantom*> m_phantoms; //0xCC
6956

70-
//sub_828306E0
71-
//hkWorld_updateFilterOnSinglePhantom 8282D528
72-
//hkpworld::internal_executePendingOperations 8282DB94
73-
void updateCollisionFilterOnPhantom(hk330::hkpPhantom* phantom, uint32_t updateShapeCollectionFilter);
57+
void updateCollisionFilterOnWorld(uint32_t updateMode,uint32_t updateShapeCollectionFilter)
58+
{
59+
GuestToHostFunction<void>(sub_82832910, this, updateMode, updateShapeCollectionFilter);
60+
}
7461
};
7562
}

MarathonRecomp/patches/fps_patches.cpp

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ void ObjEspSwing_DecayRateFix(PPCRegister& f0, PPCRegister& f13, PPCRegister& de
115115
f0.f64 = float(f13.f64 * pow(pow(f0.f64, 60.0), deltaTime.f64));
116116
}
117117

118-
<<<<<<< HEAD
119118
struct MsgSuckPlayerEx : public Sonicteam::Message::MsgSuckPlayer
120119
{
121120
be<float> DeltaTime;
@@ -225,52 +224,29 @@ PPC_FUNC(sub_8250D698)
225224

226225
void ObjVehicleBike_BulletDisableCollisionLayer(PPCRegister& r3)
227226
{
228-
if (Config::FPS <= 60.0)
229-
return;
227+
if (Config::FPS <= 60.0) return;
228+
229+
auto pVehicleBike = reinterpret_cast<Sonicteam::ObjectVehicleBike*>(g_memory.Translate(r3.u32));
230+
auto pNamedActorEntity = static_cast<Sonicteam::NamedActor*>(pVehicleBike->m_pDependency.get());
231+
232+
auto pEnemyShotNormal = static_cast<Sonicteam::Enemy::EnemyShotNormal*>(pNamedActorEntity->GetFirstDependent());
233+
sub_822C1FA8(*GetPPCContext(), g_memory.base);
230234

231-
auto ctx = GetPPCContext();
232-
auto base = g_memory.base;
233-
auto pVehicleBike = (Sonicteam::ObjectVehicleBike*)(g_memory.Translate(r3.u32));
234-
auto pNamedActorEntity = (Sonicteam::NamedActor*)(pVehicleBike->m_pDependency.get());
235-
auto pEnemyShotNormal = (Sonicteam::Enemy::EnemyShotNormal*)pNamedActorEntity->GetFirstDependent();
236-
sub_822C1FA8(*ctx, g_memory.base);
237-
auto pEnemyShotNormalAfter = (Sonicteam::Enemy::EnemyShotNormal*)pNamedActorEntity->GetFirstDependent();
238-
while (pEnemyShotNormal != pEnemyShotNormalAfter)
235+
// Process rigids created after the function call
236+
auto pCurrentShot = static_cast<Sonicteam::Enemy::EnemyShotNormal*>(pNamedActorEntity->GetFirstDependent());
237+
auto IsUpdatePhysicsWorld = false;
238+
while (pEnemyShotNormal != pCurrentShot)
239239
{
240-
pEnemyShotNormal = ((Sonicteam::Enemy::EnemyShotNormal*)pEnemyShotNormal->m_pSiblingPrev.get());
240+
pEnemyShotNormal = static_cast<Sonicteam::Enemy::EnemyShotNormal*>(pEnemyShotNormal->m_pSiblingPrev.get());
241241
auto pObject = reinterpret_cast<Sonicteam::SoX::Object*>(pEnemyShotNormal);
242242

243-
if (pObject->m_pVftable.ptr.get() == 0x820200C8)
243+
if (pObject->m_pVftable.ptr.get() == 0x820200C8 && pEnemyShotNormal->m_spPhantom)
244244
{
245-
auto hkpCollideable = &pEnemyShotNormal->m_spPhantom->m_pRigidBody->m_collidable;
246-
auto owner = hkpCollideable->m_parent.get();
247-
// pEnemyShotNormal->m_spPhantom->m_spWorldHavok->
248-
249-
printf("hkpCollideable %x\n", hkpCollideable);
250-
printf("owner %x\n", owner);
251-
printf("m_collisionFilterInfo : %x\n", pEnemyShotNormal->m_spPhantom->m_pRigidBody->m_collidable.m_broadPhaseHandle.m_collisionFilterInfo.get());
252-
printf("hkPhantom : %x\n", pEnemyShotNormal->m_spPhantom->m_pRigidBody->m_collidable);
253-
pEnemyShotNormal->m_spPhantom->m_pRigidBody->m_collidable.m_broadPhaseHandle.m_collisionFilterInfo = 0xFFFF0000;
254-
printf("pObject : %x\n", pObject);
245+
auto& collideable = pEnemyShotNormal->m_spPhantom->m_pRigidBody->m_collidable;
246+
collideable.m_broadPhaseHandle.m_collisionFilterInfo = 0xFFFF5E00;
247+
IsUpdatePhysicsWorld = true;
255248
}
256-
257-
}
258-
259-
/*
260-
if (pVehicleBike->m_pVehicleMissileCtrlAutomatic->m_IsShot)
261-
{
262-
pEnemyShotNormal->m_spPhantom->m_pRigidBody->m_collidable.m_broadPhaseHandle.m_collisionFilterInfo = 0x5E00;
263-
printf("SHOT\n");
264249
}
265-
*/
266-
printf("pEntityB : %x\n", pNamedActorEntity);
267-
printf("pEntityF : %x\n", pEnemyShotNormalAfter);
268-
269-
printf("NamedActor : %s\n", pNamedActorEntity->m_Name.c_str());
270-
printf("NamedActor : %s\n", pNamedActorEntity->m_Name.c_str());
271-
printf("pEntity : %x\n", pEnemyShotNormal);
272-
printf("m_pVehicleMissileCtrlAutomatic : %x\n", pVehicleBike->m_pVehicleMissileCtrlAutomatic->m_pMyPhantom.get());
273-
printf("m_pShotInfo : %x\n", pVehicleBike->m_pVehicleMissileCtrlAutomatic->m_pShotInfo.get());
274-
printf("m_pShotParameter : %x\n", pVehicleBike->m_pVehicleMissileCtrlAutomatic->m_pShotParameter.get());
275-
250+
if (IsUpdatePhysicsWorld)
251+
App::s_pApp->m_pDoc->GetDocMode<Sonicteam::GameMode>()->m_pGameImp->GetPhysicsWorld<Sonicteam::SoX::Physics::Havok::WorldHavok>()->m_pWorld.get()->updateCollisionFilterOnWorld(1, 1);
276252
}

0 commit comments

Comments
 (0)