mirror of https://github.com/zeldaret/botw.git
ksys/phys: Change getRigidBody to take a const-ref for consistency
This commit is contained in:
parent
5a31fe8a9d
commit
cc270ee3ff
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue