summaryrefslogtreecommitdiff
path: root/src/KingSystem
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2022-03-20 13:15:46 +0100
committerLéo Lam <leo@leolam.fr>2022-03-20 13:21:51 +0100
commitcc270ee3ff82d7766dcbc0eee54cdc34d09bff4c (patch)
treeadd6a86423931e1f4789de25084623084f5e2c47 /src/KingSystem
parent5a31fe8a9d660d0242a29843ecadb16eb9999d4e (diff)
ksys/phys: Change getRigidBody to take a const-ref for consistency
Diffstat (limited to 'src/KingSystem')
-rw-r--r--src/KingSystem/Physics/System/physContactListener.cpp12
-rw-r--r--src/KingSystem/Physics/System/physEntityContactListener.cpp10
-rw-r--r--src/KingSystem/Physics/System/physShapeCast.cpp4
-rw-r--r--src/KingSystem/Physics/physConversions.h6
4 files changed, 16 insertions, 16 deletions
diff --git a/src/KingSystem/Physics/System/physContactListener.cpp b/src/KingSystem/Physics/System/physContactListener.cpp
index 8236d74f..8e436f4b 100644
--- a/src/KingSystem/Physics/System/physContactListener.cpp
+++ b/src/KingSystem/Physics/System/physContactListener.cpp
@@ -56,24 +56,24 @@ void ContactListener::clearTable() {
}
void ContactListener::collisionAddedCallback(const hkpCollisionEvent& event) {
- auto* bodyA = getRigidBody(event.getBody(0));
- auto* bodyB = getRigidBody(event.getBody(1));
+ auto* bodyA = getRigidBody(*event.getBody(0));
+ auto* bodyB = getRigidBody(*event.getBody(1));
handleCollisionAdded(event, bodyA, bodyB);
bodyA->onCollisionAdded();
bodyB->onCollisionAdded();
}
void ContactListener::collisionRemovedCallback(const hkpCollisionEvent& event) {
- auto* bodyA = getRigidBody(event.getBody(0));
- auto* bodyB = getRigidBody(event.getBody(1));
+ auto* bodyA = getRigidBody(*event.getBody(0));
+ auto* bodyB = getRigidBody(*event.getBody(1));
handleCollisionRemoved(event, bodyA, bodyB);
bodyA->onCollisionRemoved();
bodyB->onCollisionRemoved();
}
void ContactListener::contactPointCallback(const hkpContactPointEvent& event) {
- RigidBody* body_a = getRigidBody(event.getBody(0));
- RigidBody* body_b = getRigidBody(event.getBody(1));
+ RigidBody* body_a = getRigidBody(*event.getBody(0));
+ RigidBody* body_b = getRigidBody(*event.getBody(1));
if (event.m_contactPoint->getPosition().getInt24W() == hkpCharacterRigidBody::m_magicNumber) {
const auto layer_a = body_a->getContactLayer();
diff --git a/src/KingSystem/Physics/System/physEntityContactListener.cpp b/src/KingSystem/Physics/System/physEntityContactListener.cpp
index c7986c87..a5ccdda6 100644
--- a/src/KingSystem/Physics/System/physEntityContactListener.cpp
+++ b/src/KingSystem/Physics/System/physEntityContactListener.cpp
@@ -54,7 +54,7 @@ static bool hasEntityWithMotionFlag80(const hkpCollisionEvent& event) {
if (!entity)
continue;
- bool on = getRigidBody(entity)->isEntityMotionFlag80On();
+ bool on = getRigidBody(*entity)->isEntityMotionFlag80On();
has_flag_80 |= on;
if (on)
break;
@@ -74,8 +74,8 @@ EntityContactListener::EntityContactListener(ContactMgr* mgr, sead::Heap* heap)
EntityContactListener::~EntityContactListener() = default;
void EntityContactListener::collisionAddedCallback(const hkpCollisionEvent& event) {
- auto* body_a = getRigidBody(event.getBody(0));
- auto* body_b = getRigidBody(event.getBody(1));
+ auto* body_a = getRigidBody(*event.getBody(0));
+ auto* body_b = getRigidBody(*event.getBody(1));
handleCollisionAdded(event, body_a, body_b);
@@ -106,8 +106,8 @@ void EntityContactListener::collisionAddedCallback(const hkpCollisionEvent& even
}
void EntityContactListener::collisionRemovedCallback(const hkpCollisionEvent& event) {
- auto* body_a = getRigidBody(event.getBody(0));
- auto* body_b = getRigidBody(event.getBody(1));
+ auto* body_a = getRigidBody(*event.getBody(0));
+ auto* body_b = getRigidBody(*event.getBody(1));
handleCollisionRemoved(event, body_a, body_b);
removeViscousSurfaceModifierAndCollision(event, body_a, body_b);
diff --git a/src/KingSystem/Physics/System/physShapeCast.cpp b/src/KingSystem/Physics/System/physShapeCast.cpp
index cefed97b..024cb395 100644
--- a/src/KingSystem/Physics/System/physShapeCast.cpp
+++ b/src/KingSystem/Physics/System/physShapeCast.cpp
@@ -156,7 +156,7 @@ bool ShapeCast::registerContactPoint(const hkpRootCdPoint& point, RigidBody* bod
if (!mContactPointInfo->testContactPointDistance(point.getContact().getDistance()))
return false;
- auto* hit_body = getRigidBody(hit_entity);
+ auto* hit_body = getRigidBody(*hit_entity);
if (System::instance()->getEntityContactListenerField91() && hit_body->isEntity() &&
EntityContactListener::isObjectOrGroundOrNPCOrTree(*hit_body)) {
@@ -216,7 +216,7 @@ void FilteredClosestCdPointCollector::addCdPoint(const hkpCdPoint& point) {
if (!hit_entity)
return;
- auto* hit_body = getRigidBody(hit_entity);
+ auto* hit_body = getRigidBody(*hit_entity);
if (System::instance()->getEntityContactListenerField91() && hit_body->isEntity() &&
EntityContactListener::isObjectOrGroundOrNPCOrTree(*hit_body)) {
diff --git a/src/KingSystem/Physics/physConversions.h b/src/KingSystem/Physics/physConversions.h
index 70076e12..7647a3f5 100644
--- a/src/KingSystem/Physics/physConversions.h
+++ b/src/KingSystem/Physics/physConversions.h
@@ -108,9 +108,9 @@ inline const hkpEntity* getHkpEntity(const hkpCollidable& collidable) {
return static_cast<const hkpEntity*>(collidable.getOwner());
}
-inline RigidBody* getRigidBody(const hkpEntity* entity) {
+inline RigidBody* getRigidBody(const hkpEntity& entity) {
// This needs to be kept in sync with the RigidBody constructor!
- return reinterpret_cast<RigidBody*>(entity->getUserData());
+ return reinterpret_cast<RigidBody*>(entity.getUserData());
}
inline RigidBody* getRigidBody(const hkpCollidable& collidable) {
@@ -118,7 +118,7 @@ inline RigidBody* getRigidBody(const hkpCollidable& collidable) {
if (!entity)
return nullptr;
- return getRigidBody(entity);
+ return getRigidBody(*entity);
}
} // namespace ksys::phys