From 61201ca54bb3b6b3e91c0a85579ff3424658e6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 29 Jan 2022 12:36:59 +0100 Subject: [PATCH] ksys/phys: Rename RigidBody/UserTag broadphase border callbacks --- data/uking_functions.csv | 4 ++-- src/KingSystem/ActorSystem/actPhysicsUserTag.h | 2 +- src/KingSystem/Physics/RigidBody/physRigidBody.cpp | 2 +- src/KingSystem/Physics/RigidBody/physRigidBody.h | 13 +++++++++++-- src/KingSystem/Physics/System/physUserTag.cpp | 5 +++-- src/KingSystem/Physics/System/physUserTag.h | 5 +++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 117b9dec..33f17857 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -83127,7 +83127,7 @@ Address,Quality,Size,Name 0x0000007100f964dc,O,000148,_ZNK4ksys4phys9RigidBody25getMagneMassScalingFactorEv 0x0000007100f96570,O,000008,_ZN4ksys4phys9RigidBody11getNewShapeEv 0x0000007100f96578,O,000008,_ZN4ksys4phys9RigidBody3m11Ev -0x0000007100f96580,O,000240,_ZN4ksys4phys9RigidBody13resetPositionEv +0x0000007100f96580,O,000240,_ZN4ksys4phys9RigidBody21onMaxPositionExceededEv 0x0000007100f96670,O,000144,_ZN4ksys4phys9RigidBody7getNameEv 0x0000007100f96700,O,000068,_ZNK4ksys4phys9RigidBody11logPositionEv 0x0000007100f96744,O,000176,_ZNK4ksys4phys9RigidBody14getAabbInLocalEPN4sead9BoundBox3IfEE @@ -84271,7 +84271,7 @@ Address,Quality,Size,Name 0x0000007100fcd5cc,U,000380, 0x0000007100fcd748,U,000036, 0x0000007100fcd76c,U,000052, -0x0000007100fcd7a0,U,000016,phys::UserTag::m2 +0x0000007100fcd7a0,O,000016,_ZN4ksys4phys7UserTag21onMaxPositionExceededEPNS0_9RigidBodyE 0x0000007100fcd7b0,U,000020,phys::UserTag::m3 0x0000007100fcd7c4,U,000004,phys::UserTag::m4n 0x0000007100fcd7c8,U,000004,phys::UserTag::m5n diff --git a/src/KingSystem/ActorSystem/actPhysicsUserTag.h b/src/KingSystem/ActorSystem/actPhysicsUserTag.h index d076c15e..641cd0f2 100644 --- a/src/KingSystem/ActorSystem/actPhysicsUserTag.h +++ b/src/KingSystem/ActorSystem/actPhysicsUserTag.h @@ -18,7 +18,7 @@ public: Actor* getActor(ActorLinkConstDataAccess* accessor, Actor* other_actor) const; bool acquireActor(ActorLinkConstDataAccess* accessor) const; - void m2(void* a) override; + void onMaxPositionExceeded(phys::RigidBody* body) override; void m3(void* a, void* b, float c) override; void onBodyShapeChanged(phys::RigidBody* body) override; void m5() override; diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp index b4daedec..de1b1af3 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp +++ b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp @@ -1746,7 +1746,7 @@ void* RigidBody::m11() { return nullptr; } -void RigidBody::resetPosition() { +void RigidBody::onMaxPositionExceeded() { // debug logging? [[maybe_unused]] sead::Vector3f position = getPosition(); setPosition(sead::Vector3f::zero, true); diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.h b/src/KingSystem/Physics/RigidBody/physRigidBody.h index 7cdd1514..3375e9d5 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBody.h +++ b/src/KingSystem/Physics/RigidBody/physRigidBody.h @@ -456,7 +456,7 @@ public: void setMotionFlag(MotionFlag flag); hkpRigidBody* getHkBody() const { return mHkBody; } - + UserTag* getUserTag() const { return mUserTag; } Type getType() const { return mType; } bool isCharacterControllerType() const { return mType == Type::CharacterController; } @@ -498,7 +498,16 @@ public: virtual const hkpShape* getNewShape(); virtual void* m11(); virtual float m12(float x, float y); - virtual void resetPosition(); + + /// Called when the rigid body goes beyond the broadphase border. + /// + /// Note: this is not guaranteed to be called if we have a user tag. + /// The tag may choose not to invoke this callback. + /// + /// The default implementation just resets the position to the origin. + virtual void onMaxPositionExceeded(); + + /// Get the name of this rigid body or its user. virtual const char* getName(); // Internal. diff --git a/src/KingSystem/Physics/System/physUserTag.cpp b/src/KingSystem/Physics/System/physUserTag.cpp index 03f0fcb8..99a05991 100644 --- a/src/KingSystem/Physics/System/physUserTag.cpp +++ b/src/KingSystem/Physics/System/physUserTag.cpp @@ -1,9 +1,10 @@ #include "KingSystem/Physics/System/physUserTag.h" +#include "KingSystem/Physics/RigidBody/physRigidBody.h" namespace ksys::phys { -void UserTag::m2(void* a) { - // FIXME +void UserTag::onMaxPositionExceeded(RigidBody* body) { + body->onMaxPositionExceeded(); } void UserTag::m3(void* a, void* b, float c) { diff --git a/src/KingSystem/Physics/System/physUserTag.h b/src/KingSystem/Physics/System/physUserTag.h index 5942ee45..247d7c00 100644 --- a/src/KingSystem/Physics/System/physUserTag.h +++ b/src/KingSystem/Physics/System/physUserTag.h @@ -13,8 +13,9 @@ class UserTag { public: UserTag() = default; - // FIXME: names and types - virtual void m2(void* a); + /// Called when a rigid body goes beyond the broadphase border. + /// The default implementation just notifies the rigid body of this callback. + virtual void onMaxPositionExceeded(RigidBody* body); // a and b are probably physics bodies? virtual void m3(void* a, void* b, float c); virtual void onBodyShapeChanged(RigidBody* body);