diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 390b92ce..afb94a0c 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -94007,9 +94007,9 @@ Address,Quality,Size,Name 0x000000710121677c,U,000012,PhysicsMemSys::setPauseState 0x0000007101216788,O,000008,_ZNK4ksys4phys6System8isPausedEv 0x0000007101216790,U,000092,PhysicsMemSys::__auto17 -0x00000071012167ec,U,000020,PhysicsMemSys::__auto11 -0x0000007101216800,U,000020,PhysicsMemSys::setEntityContactListenerField91 -0x0000007101216814,U,000016,_ZNK4ksys4phys6System31getEntityContactListenerField91Ev +0x00000071012167ec,O,000020,_ZN4ksys4phys6System45setDisableSensorContactPointInfoNotificationsEb +0x0000007101216800,O,000020,_ZN4ksys4phys6System31setEntityContactListenerField91Eb +0x0000007101216814,O,000016,_ZNK4ksys4phys6System31getEntityContactListenerField91Ev 0x0000007101216824,U,000004,nullsub_6154 0x0000007101216828,U,000004,nullsub_4711 0x000000710121682c,U,000032, @@ -94029,7 +94029,7 @@ Address,Quality,Size,Name 0x00000071012169b4,O,000012,_ZN4ksys4phys6System34makeContactLayerCollisionInfoGroupEPN4sead4HeapENS0_12ContactLayerEiRKNS2_14SafeStringBaseIcEE 0x00000071012169c0,O,000008,_ZN4ksys4phys6System34freeContactLayerCollisionInfoGroupEPNS0_30ContactLayerCollisionInfoGroupE 0x00000071012169c8,O,000088,_ZN4ksys4phys6System14trackLayerPairENS0_12ContactLayerES2_ -0x0000007101216a20,U,000136,_ZN4ksys4phys6System32removeRigidBodyFromContactSystemEPNS0_9RigidBodyE +0x0000007101216a20,O,000136,_ZN4ksys4phys6System32removeRigidBodyFromContactSystemEPNS0_9RigidBodyE 0x0000007101216aa8,U,000008, 0x0000007101216ab0,U,000008, 0x0000007101216ab8,U,000008, @@ -94039,10 +94039,10 @@ Address,Quality,Size,Name 0x0000007101216af4,U,000276, 0x0000007101216c08,O,000080,_ZNK4ksys4phys6System18isHavokMainHeapOomEv 0x0000007101216c58,U,000008,PhysicsMemSys::setRigidBodyDividedMeshShapeMgr -0x0000007101216c60,U,000020,phys::System::setEntityContactListenerField90 -0x0000007101216c74,U,000016,_ZNK4ksys4phys6System31getEntityContactListenerField90Ev +0x0000007101216c60,O,000020,_ZN4ksys4phys6System26setMagneMassScalingEnabledEb +0x0000007101216c74,O,000016,_ZNK4ksys4phys6System25isMagneMassScalingEnabledEv 0x0000007101216c84,O,000032,_ZNK4ksys4phys6System21getRagdollCtrlKeyListEv -0x0000007101216ca4,U,000072,_ZNK4ksys4phys6System17isActorSystemIdleEv +0x0000007101216ca4,O,000072,_ZNK4ksys4phys6System17isActorSystemIdleEv 0x0000007101216cec,O,000148,_ZNK4ksys4phys6System18getPhysicsTempHeapENS0_11LowPriorityE 0x0000007101216d80,U,000112, 0x0000007101216df0,U,000152,PhysicsMemSys::__auto9 diff --git a/src/KingSystem/Physics/System/physContactListener.h b/src/KingSystem/Physics/System/physContactListener.h index 086f4131..11344186 100644 --- a/src/KingSystem/Physics/System/physContactListener.h +++ b/src/KingSystem/Physics/System/physContactListener.h @@ -42,6 +42,14 @@ class ContactListener : public hkpContactListener, public sead::hostio::Node { void unregisterCollisionWithBody(RigidBody* body); + bool isMagneMassScalingEnabled() const { return mMagneMassScalingEnabled; } + void setMagneMassScalingEnabled(bool enabled) { mMagneMassScalingEnabled = enabled; } + bool get91() const { return _91; } + void set91(bool value) { _91 = value; } + void setDisableContactPointInfoNotifications(bool value) { + mDisableContactPointInfoNotifications = value; + } + void contactPointCallback(const hkpContactPointEvent& event) override; void collisionAddedCallback(const hkpCollisionEvent& event) override; void collisionRemovedCallback(const hkpCollisionEvent& event) override; @@ -125,7 +133,7 @@ class ContactListener : public hkpContactListener, public sead::hostio::Node { u32 mTrackedLayersBufferSize{}; u32 mLayerCount{}; sead::CriticalSection mCS; - bool _90 = false; + bool mMagneMassScalingEnabled = false; bool _91 = false; bool mDisableContactPointInfoNotifications = false; }; diff --git a/src/KingSystem/Physics/System/physEntityContactListener.cpp b/src/KingSystem/Physics/System/physEntityContactListener.cpp index a5ccdda6..678ba2e1 100644 --- a/src/KingSystem/Physics/System/physEntityContactListener.cpp +++ b/src/KingSystem/Physics/System/physEntityContactListener.cpp @@ -275,7 +275,7 @@ static void updateMotionAccessorFlagsForMagneMassScaling(RigidBody* body_a, Rigi void EntityContactListener::setMagneMassScalingForContactIfNeeded(const hkpCollisionEvent& event, RigidBody* body_a, RigidBody* body_b) { - if (!System::instance()->getEntityContactListenerField90()) + if (!System::instance()->isMagneMassScalingEnabled()) return; if (!needsMagneMassScaling(event, body_a, body_b)) @@ -490,19 +490,19 @@ bool EntityContactListener::regularContactPointCallback(const hkpContactPointEve auto* modifier = hkpWorldConstraintUtil::findModifier( constraint, hkpConstraintAtom::TYPE_MODIFIER_VISCOUS_SURFACE); - const bool field90 = System::instance()->getEntityContactListenerField90(); + const bool magne_mass_scaling_enabled = System::instance()->isMagneMassScalingEnabled(); if (modifier && constraint->getUserData() & 1) { clearCallbackDelay(event); - if (field90 && hasEntityWithMotionFlag80(event)) { + if (magne_mass_scaling_enabled && hasEntityWithMotionFlag80(event)) { updateMotionFlagsAtEndOfStep(event, body_a, body_b); } else { body_a->getEntityMotionAccessor()->getContactFlags().makeAllZero(); body_b->getEntityMotionAccessor()->getContactFlags().makeAllZero(); removeViscousSurfaceModifier(event); } - } else if (field90 && needsMagneMassScaling(event, body_a, body_b) && + } else if (magne_mass_scaling_enabled && needsMagneMassScaling(event, body_a, body_b) && !shouldProcessEntityContact(body_a, body_b)) { updateMotionAccessorFlagsForMagneMassScaling(body_a, body_b); setMagneMassScalingForContact(event, body_a, body_b); diff --git a/src/KingSystem/Physics/System/physSystem.cpp b/src/KingSystem/Physics/System/physSystem.cpp index acc926fc..3a78a07c 100644 --- a/src/KingSystem/Physics/System/physSystem.cpp +++ b/src/KingSystem/Physics/System/physSystem.cpp @@ -1,10 +1,12 @@ #include "KingSystem/Physics/System/physSystem.h" #include #include +#include "KingSystem/ActorSystem/actBaseProcMgr.h" #include "KingSystem/Physics/Cloth/physClothResource.h" #include "KingSystem/Physics/Ragdoll/physRagdollControllerKeyList.h" #include "KingSystem/Physics/Ragdoll/physRagdollResource.h" #include "KingSystem/Physics/RigidBody/TeraMesh/physTeraMeshRigidBodyResource.h" +#include "KingSystem/Physics/RigidBody/physRigidBody.h" #include "KingSystem/Physics/RigidBody/physRigidBodyResource.h" #include "KingSystem/Physics/StaticCompound/physStaticCompound.h" #include "KingSystem/Physics/SupportBone/physSupportBoneResource.h" @@ -154,4 +156,49 @@ sead::Heap* System::getPhysicsTempHeap(LowPriority low_priority) const { return mPhysicsTempDefaultHeap; } +void System::removeRigidBodyFromContactSystem(RigidBody* body) { + const auto layer_type = getContactLayerType(body->getContactLayer()); + + if (mPaused) + mContactMgr->removeContactPointsWithBody(body); + + mContactListeners[static_cast(layer_type)]->unregisterCollisionWithBody(body); + mContactMgr->removeCollisionEntriesWithBody(body); + mContactMgr->removeImpulseEntriesWithBody(body); +} + +void System::setMagneMassScalingEnabled(bool enabled) { + mContactListeners[static_cast(ContactLayerType::Entity)]->setMagneMassScalingEnabled( + enabled); +} + +bool System::isMagneMassScalingEnabled() const { + return mContactListeners[static_cast(ContactLayerType::Entity)] + ->isMagneMassScalingEnabled(); +} + +void System::setEntityContactListenerField91(bool value) { + mContactListeners[static_cast(ContactLayerType::Entity)]->set91(value); +} + +bool System::getEntityContactListenerField91() const { + return mContactListeners[static_cast(ContactLayerType::Entity)]->get91(); +} + +void System::setDisableSensorContactPointInfoNotifications(bool disable) { + mContactListeners[static_cast(ContactLayerType::Sensor)] + ->setDisableContactPointInfoNotifications(disable); +} + +bool System::isActorSystemIdle() const { + const bool is_idle = _62 || _61; + + auto* mgr = act::BaseProcMgr::instance(); + if (!mgr) + return true; + + const bool actor_jobs_idle = mgr->getStatus() != act::BaseProcMgr::Status::ProcessingActorJobs; + return is_idle || actor_jobs_idle; +} + } // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physSystem.h b/src/KingSystem/Physics/System/physSystem.h index 9c48510d..c77f9689 100644 --- a/src/KingSystem/Physics/System/physSystem.h +++ b/src/KingSystem/Physics/System/physSystem.h @@ -115,11 +115,10 @@ class System { RagdollControllerKeyList* getRagdollCtrlKeyList() const; - // TODO: rename // 0x0000007101216c60 - void setEntityContactListenerField90(bool value); + void setMagneMassScalingEnabled(bool enabled); // 0x0000007101216c74 - bool getEntityContactListenerField90() const; + bool isMagneMassScalingEnabled() const; // 0x0000007101216ca4 bool isActorSystemIdle() const; @@ -129,6 +128,9 @@ class System { // 0x0000007101216814 bool getEntityContactListenerField91() const; + // 0x00000071012167ec + void setDisableSensorContactPointInfoNotifications(bool disable); + // 0x000000710121682c void incrementWorldUnkCounter(ContactLayerType layer_type); // 0x000000710121684c @@ -141,7 +143,9 @@ class System { private: u8 _28[0x60 - 0x28]; bool mPaused; - u8 _61[0x64 - 0x61]; + bool _61; + bool _62; + u8 _63; float _64 = 1.0 / 30.0; float _68 = 1.0 / 30.0; float _6c = 1.0;