mirror of https://github.com/zeldaret/botw.git
ksys/phys: Add RigidBody::isEntity to make certain checks clearer
The pattern we want to use is: ``` if (isEntity()) do entity stuff (e.g. get entity motion accessor) ``` or ``` if (!isEntity()) return; do entity stuff ``` That's clearer than ``` if (isSensor()) return; do entity stuff ``` because the fact that !isSensor() is equivalent to isEntity() is not always immediately clear.
This commit is contained in:
parent
a2cba75b19
commit
ddef936b26
|
@ -326,7 +326,7 @@ bool RigidBody::setLinearVelocity(const sead::Vector3f& velocity, float epsilon)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSensor() && RigidBodyRequestMgr::Config::isLinearVelocityTooHigh(velocity)) {
|
if (isEntity() && RigidBodyRequestMgr::Config::isLinearVelocityTooHigh(velocity)) {
|
||||||
onInvalidParameter(1);
|
onInvalidParameter(1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ void RigidBody::applyLinearImpulse(const sead::Vector3f& impulse) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSensor())
|
if (isEntity())
|
||||||
getEntityMotionAccessor()->applyLinearImpulse(impulse);
|
getEntityMotionAccessor()->applyLinearImpulse(impulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ void RigidBody::applyAngularImpulse(const sead::Vector3f& impulse) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSensor())
|
if (isEntity())
|
||||||
getEntityMotionAccessor()->applyAngularImpulse(impulse);
|
getEntityMotionAccessor()->applyAngularImpulse(impulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,24 +480,24 @@ void RigidBody::applyPointImpulse(const sead::Vector3f& impulse, const sead::Vec
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSensor())
|
if (isEntity())
|
||||||
getEntityMotionAccessor()->applyPointImpulse(impulse, point);
|
getEntityMotionAccessor()->applyPointImpulse(impulse, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::setMass(float mass) {
|
void RigidBody::setMass(float mass) {
|
||||||
if (isSensor())
|
if (!isEntity())
|
||||||
return;
|
return;
|
||||||
getEntityMotionAccessor()->setMass(mass);
|
getEntityMotionAccessor()->setMass(mass);
|
||||||
}
|
}
|
||||||
|
|
||||||
float RigidBody::getMass() const {
|
float RigidBody::getMass() const {
|
||||||
if (isSensor())
|
if (!isEntity())
|
||||||
return 0.0;
|
return 0.0;
|
||||||
return getEntityMotionAccessor()->getMass();
|
return getEntityMotionAccessor()->getMass();
|
||||||
}
|
}
|
||||||
|
|
||||||
float RigidBody::getMassInv() const {
|
float RigidBody::getMassInv() const {
|
||||||
if (isSensor())
|
if (!isEntity())
|
||||||
return 0.0;
|
return 0.0;
|
||||||
return getEntityMotionAccessor()->getMassInv();
|
return getEntityMotionAccessor()->getMassInv();
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,7 @@ public:
|
||||||
float getGravityFactor() const;
|
float getGravityFactor() const;
|
||||||
|
|
||||||
bool isSensor() const { return mFlags.isOn(Flag::IsSensor); }
|
bool isSensor() const { return mFlags.isOn(Flag::IsSensor); }
|
||||||
|
bool isEntity() const { return !mFlags.isOn(Flag::IsSensor); }
|
||||||
ContactLayerType getLayerType() const {
|
ContactLayerType getLayerType() const {
|
||||||
return isSensor() ? ContactLayerType::Sensor : ContactLayerType::Entity;
|
return isSensor() ? ContactLayerType::Sensor : ContactLayerType::Entity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ void RigidBodyMotionSensor::setLinkedRigidBody(RigidBody* body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body) {
|
if (body) {
|
||||||
if (!body->isSensor() && mFlags.isOff(Flag::HasLinkedRigidBodyWithoutFlag10)) {
|
if (body->isEntity() && mFlags.isOff(Flag::HasLinkedRigidBodyWithoutFlag10)) {
|
||||||
RigidBodyMotionEntity* accessor = body->getEntityMotionAccessorForSensor();
|
RigidBodyMotionEntity* accessor = body->getEntityMotionAccessorForSensor();
|
||||||
if (accessor && accessor->registerAccessor(this)) {
|
if (accessor && accessor->registerAccessor(this)) {
|
||||||
mLinkedRigidBody = body;
|
mLinkedRigidBody = body;
|
||||||
|
|
Loading…
Reference in New Issue