mirror of https://github.com/zeldaret/botw.git
Havok: Add hkpRigidBody and hkpMotion getters/setters
This commit is contained in:
parent
17a5192490
commit
a526afbdb6
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Havok/Physics2012/Dynamics/Entity/hkpEntity.h>
|
||||
#include <Havok/Physics2012/Dynamics/World/hkpWorld.h>
|
||||
|
||||
class hkpRigidBodyCinfo;
|
||||
|
||||
|
@ -9,14 +10,119 @@ public:
|
|||
HK_DECLARE_CLASS_ALLOCATOR(hkpRigidBody)
|
||||
HK_DECLARE_REFLECTION()
|
||||
|
||||
hkpRigidBody(const hkpRigidBodyCinfo& info);
|
||||
explicit hkpRigidBody(const hkpRigidBodyCinfo& info);
|
||||
explicit hkpRigidBody(hkFinishLoadedObjectFlag flag);
|
||||
|
||||
~hkpRigidBody() override;
|
||||
|
||||
/// Returns the rigid body's current state.
|
||||
void getCinfo(hkpRigidBodyCinfo& info) const;
|
||||
|
||||
inline hkReal getMass() const;
|
||||
inline hkReal getMassInv() const;
|
||||
void setMass(hkReal m);
|
||||
void setMassInv(hkReal mInv);
|
||||
|
||||
inline void getInertiaLocal(hkMatrix3& inertiaOut) const;
|
||||
inline void getInertiaWorld(hkMatrix3& inertiaOut) const;
|
||||
void setInertiaLocal(const hkMatrix3& inertia);
|
||||
void setInertiaInvLocal(const hkMatrix3& inertiaInv);
|
||||
inline void getInertiaInvLocal(hkMatrix3& inertiaInv) const;
|
||||
inline void getInertiaInvWorld(hkMatrix3& inertiaInvOut) const;
|
||||
|
||||
void setCenterOfMassLocal(const hkVector4& centerOfMass);
|
||||
inline const hkVector4& getCenterOfMassLocal() const;
|
||||
inline const hkVector4& getCenterOfMassInWorld() const;
|
||||
|
||||
inline const hkVector4& getPosition() const;
|
||||
void setPosition(const hkVector4& position);
|
||||
inline const hkQuaternion& getRotation() const;
|
||||
void setRotation(const hkQuaternion& rotation);
|
||||
void setPositionAndRotation(const hkVector4& position, const hkQuaternion& rotation);
|
||||
inline const hkTransform& getTransform() const;
|
||||
void setTransform(const hkTransform& transform);
|
||||
void setPositionAndRotationAsCriticalOperation(const hkVector4& position,
|
||||
const hkQuaternion& rotation);
|
||||
inline void approxTransformAt(hkTime time, hkTransform& transformOut) const;
|
||||
inline void approxCurrentTransform(hkTransform& transformOut) const;
|
||||
|
||||
inline const hkVector4& getLinearVelocity() const;
|
||||
inline void setLinearVelocity(const hkVector4& newVel);
|
||||
inline const hkVector4& getAngularVelocity() const;
|
||||
inline void setAngularVelocity(const hkVector4& newVel);
|
||||
inline void getPointVelocity(const hkVector4& p, hkVector4& vecOut) const;
|
||||
void setLinearVelocityAsCriticalOperation(const hkVector4& newVel);
|
||||
void setAngularVelocityAsCriticalOperation(const hkVector4& newVel);
|
||||
|
||||
inline void applyLinearImpulse(const hkVector4& imp);
|
||||
inline void applyPointImpulse(const hkVector4& imp, const hkVector4& p);
|
||||
inline void applyAngularImpulse(const hkVector4& imp);
|
||||
void applyLinearImpulseAsCriticalOperation(const hkVector4& imp);
|
||||
void applyPointImpulseAsCriticalOperation(const hkVector4& imp, const hkVector4& p);
|
||||
void applyAngularImpulseAsCriticalOperation(const hkVector4& imp);
|
||||
|
||||
inline void applyForce(hkReal deltaTime, const hkVector4& force);
|
||||
inline void applyForce(hkReal deltaTime, const hkVector4& force, const hkVector4& p);
|
||||
inline void applyTorque(hkReal deltaTime, const hkVector4& torque);
|
||||
|
||||
inline hkReal getLinearDamping() const;
|
||||
inline void setLinearDamping(hkReal d);
|
||||
inline hkReal getAngularDamping() const;
|
||||
inline void setAngularDamping(hkReal d);
|
||||
inline hkReal getTimeFactor() const;
|
||||
inline void setTimeFactor(hkReal f);
|
||||
inline hkReal getGravityFactor() const;
|
||||
inline void setGravityFactor(hkReal f);
|
||||
|
||||
inline hkReal getMaxLinearVelocity() const;
|
||||
inline void setMaxLinearVelocity(hkReal maxVel);
|
||||
inline hkReal getMaxAngularVelocity() const;
|
||||
inline void setMaxAngularVelocity(hkReal maxVel);
|
||||
|
||||
void enableDeactivation(bool enable);
|
||||
bool isDeactivationEnabled() const;
|
||||
|
||||
inline hkUint32 getCollisionFilterInfo() const;
|
||||
inline void setCollisionFilterInfo(hkUint32 info);
|
||||
|
||||
inline hkpCollidableQualityType getQualityType() const;
|
||||
inline void setQualityType(hkpCollidableQualityType type);
|
||||
|
||||
inline hkReal getAllowedPenetrationDepth() const;
|
||||
inline void setAllowedPenetrationDepth(hkReal val);
|
||||
|
||||
void
|
||||
setMotionType(hkpMotion::MotionType newState,
|
||||
hkpEntityActivation preferredActivationState = HK_ENTITY_ACTIVATION_DO_ACTIVATE,
|
||||
hkpUpdateCollisionFilterOnEntityMode collisionFilterUpdateMode =
|
||||
HK_UPDATE_FILTER_ON_ENTITY_FULL_CHECK);
|
||||
inline hkpMotion::MotionType getMotionType() const;
|
||||
hkpMotion* getStoredDynamicMotion();
|
||||
const hkpMotion* getStoredDynamicMotion() const;
|
||||
void updateCachedShapeInfo(const hkpShape* shape, hkVector4& extentOut);
|
||||
|
||||
inline hkReal getFriction() const;
|
||||
inline hkReal getRollingFrictionMultiplier() const;
|
||||
inline hkReal getRestitution() const;
|
||||
void setFriction(hkReal newFriction);
|
||||
void setRollingFrictionMultiplier(hkReal multiplier);
|
||||
void setRestitution(hkReal newRestitution);
|
||||
|
||||
hkWorldOperation::Result setShape(const hkpShape* shape) override;
|
||||
hkWorldOperation::Result updateShape(hkpShapeModifier* shapeModifier = nullptr) override;
|
||||
virtual hkpRigidBody* clone() const;
|
||||
|
||||
void enableDeactivation(bool _enableDeactivation);
|
||||
inline hkpMotion* getRigidMotion() const;
|
||||
hkBool checkPerformance() const;
|
||||
|
||||
static void createDynamicRigidMotion(hkpMotion::MotionType motionType,
|
||||
const hkVector4& position, const hkQuaternion& rotation,
|
||||
hkReal mass, const hkMatrix3& inertiaLocal,
|
||||
const hkVector4& centreOfMassLocal,
|
||||
hkReal maxLinearVelocity, hkReal maxAngularVelocity,
|
||||
hkpMaxSizeMotion* motionBufferOut);
|
||||
|
||||
static void updateBroadphaseAndResetCollisionInformationOfWarpedBody(hkpEntity* entity);
|
||||
|
||||
protected:
|
||||
hkMotionState* getMotionState() override;
|
||||
|
@ -32,3 +138,192 @@ inline hkpRigidBody* hkpGetRigidBody(const hkpCollidable* collidable) {
|
|||
inline hkpRigidBody* hkpGetRigidBodyUnchecked(const hkpCollidable* collidable) {
|
||||
return static_cast<hkpRigidBody*>(hkpGetWorldObject(collidable));
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getMass() const {
|
||||
return getRigidMotion()->getMass();
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getMassInv() const {
|
||||
return getRigidMotion()->getMassInv();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::getInertiaLocal(hkMatrix3& inertiaOut) const {
|
||||
getRigidMotion()->getInertiaLocal(inertiaOut);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::getInertiaWorld(hkMatrix3& inertiaOut) const {
|
||||
getRigidMotion()->getInertiaWorld(inertiaOut);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::getInertiaInvLocal(hkMatrix3& inertiaInv) const {
|
||||
getRigidMotion()->getInertiaInvLocal(inertiaInv);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::getInertiaInvWorld(hkMatrix3& inertiaInvOut) const {
|
||||
getRigidMotion()->getInertiaInvWorld(inertiaInvOut);
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpRigidBody::getCenterOfMassLocal() const {
|
||||
return getRigidMotion()->getCenterOfMassLocal();
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpRigidBody::getCenterOfMassInWorld() const {
|
||||
return getRigidMotion()->getCenterOfMassInWorld();
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpRigidBody::getPosition() const {
|
||||
return getRigidMotion()->getPosition();
|
||||
}
|
||||
|
||||
inline const hkQuaternion& hkpRigidBody::getRotation() const {
|
||||
return getRigidMotion()->getRotation();
|
||||
}
|
||||
|
||||
inline const hkTransform& hkpRigidBody::getTransform() const {
|
||||
return getRigidMotion()->getTransform();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::approxTransformAt(hkTime time, hkTransform& transformOut) const {
|
||||
getRigidMotion()->approxTransformAt(time, transformOut);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::approxCurrentTransform(hkTransform& transformOut) const {
|
||||
getRigidMotion()->approxTransformAt(m_world->getCurrentTime(), transformOut);
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpRigidBody::getLinearVelocity() const {
|
||||
return getRigidMotion()->getLinearVelocity();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setLinearVelocity(const hkVector4& newVel) {
|
||||
getRigidMotion()->setLinearVelocity(newVel);
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpRigidBody::getAngularVelocity() const {
|
||||
return getRigidMotion()->getAngularVelocity();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setAngularVelocity(const hkVector4& newVel) {
|
||||
getRigidMotion()->setAngularVelocity(newVel);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::getPointVelocity(const hkVector4& p, hkVector4& vecOut) const {
|
||||
getRigidMotion()->getPointVelocity(p, vecOut);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::applyLinearImpulse(const hkVector4& imp) {
|
||||
getRigidMotion()->applyLinearImpulse(imp);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::applyPointImpulse(const hkVector4& imp, const hkVector4& p) {
|
||||
getRigidMotion()->applyPointImpulse(imp, p);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::applyAngularImpulse(const hkVector4& imp) {
|
||||
getRigidMotion()->applyAngularImpulse(imp);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::applyForce(const hkReal deltaTime, const hkVector4& force) {
|
||||
getRigidMotion()->applyForce(deltaTime, force);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::applyForce(const hkReal deltaTime, const hkVector4& force,
|
||||
const hkVector4& p) {
|
||||
getRigidMotion()->applyForce(deltaTime, force, p);
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::applyTorque(const hkReal deltaTime, const hkVector4& torque) {
|
||||
getRigidMotion()->applyTorque(deltaTime, torque);
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getLinearDamping() const {
|
||||
return getRigidMotion()->getLinearDamping();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setLinearDamping(hkReal d) {
|
||||
getRigidMotion()->setLinearDamping(d);
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getAngularDamping() const {
|
||||
return getRigidMotion()->getAngularDamping();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setAngularDamping(hkReal d) {
|
||||
getRigidMotion()->setAngularDamping(d);
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getTimeFactor() const {
|
||||
return getRigidMotion()->getTimeFactor();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setTimeFactor(hkReal f) {
|
||||
getRigidMotion()->setTimeFactor(f);
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getGravityFactor() const {
|
||||
return getRigidMotion()->getGravityFactor();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setGravityFactor(hkReal f) {
|
||||
getRigidMotion()->setGravityFactor(f);
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getMaxLinearVelocity() const {
|
||||
return getRigidMotion()->getMotionState()->m_maxLinearVelocity;
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setMaxLinearVelocity(hkReal maxVel) {
|
||||
getRigidMotion()->getMotionState()->m_maxLinearVelocity = maxVel;
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getMaxAngularVelocity() const {
|
||||
return getRigidMotion()->getMotionState()->m_maxAngularVelocity;
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setMaxAngularVelocity(hkReal maxVel) {
|
||||
getRigidMotion()->getMotionState()->m_maxAngularVelocity = maxVel;
|
||||
}
|
||||
|
||||
inline hkUint32 hkpRigidBody::getCollisionFilterInfo() const {
|
||||
return getCollidable()->getCollisionFilterInfo();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setCollisionFilterInfo(hkUint32 info) {
|
||||
getCollidableRw()->setCollisionFilterInfo(info);
|
||||
}
|
||||
|
||||
inline hkpCollidableQualityType hkpRigidBody::getQualityType() const {
|
||||
return getCollidable()->getQualityType();
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setQualityType(hkpCollidableQualityType type) {
|
||||
getCollidableRw()->setQualityType(type);
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getAllowedPenetrationDepth() const {
|
||||
return getCollidable()->m_allowedPenetrationDepth;
|
||||
}
|
||||
|
||||
inline void hkpRigidBody::setAllowedPenetrationDepth(hkReal val) {
|
||||
getCollidableRw()->m_allowedPenetrationDepth = val;
|
||||
}
|
||||
|
||||
inline hkpMotion::MotionType hkpRigidBody::getMotionType() const {
|
||||
return getRigidMotion()->getType();
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getFriction() const {
|
||||
return m_material.getFriction();
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getRollingFrictionMultiplier() const {
|
||||
return m_material.getRollingFrictionMultiplier();
|
||||
}
|
||||
|
||||
inline hkReal hkpRigidBody::getRestitution() const {
|
||||
return m_material.getRestitution();
|
||||
}
|
||||
|
||||
inline hkpMotion* hkpRigidBody::getRigidMotion() const {
|
||||
return const_cast<hkpMaxSizeMotion*>(&m_motion);
|
||||
}
|
||||
|
|
|
@ -35,9 +35,11 @@ public:
|
|||
|
||||
inline MotionType getType() const { return m_type; }
|
||||
|
||||
hkReal getMass() const;
|
||||
virtual void setMass(hkReal m);
|
||||
virtual void setMass(hkSimdRealParameter m);
|
||||
|
||||
inline hkSimdReal getMassInv() const;
|
||||
virtual void setMassInv(hkReal mInv);
|
||||
virtual void setMassInv(hkSimdRealParameter mInv);
|
||||
|
||||
|
@ -48,17 +50,29 @@ public:
|
|||
virtual void getInertiaInvLocal(hkMatrix3& inertiaInvOut) const = 0;
|
||||
virtual void getInertiaInvWorld(hkMatrix3& inertiaInvOut) const = 0;
|
||||
virtual void setCenterOfMassInLocal(const hkVector4& centerOfMass);
|
||||
inline const hkVector4& getCenterOfMassLocal() const;
|
||||
inline const hkVector4& getCenterOfMassInWorld() const;
|
||||
|
||||
inline hkMotionState* getMotionState();
|
||||
inline const hkMotionState* getMotionState() const;
|
||||
|
||||
inline const hkVector4& getPosition() const;
|
||||
virtual void setPosition(const hkVector4& position);
|
||||
|
||||
inline const hkQuaternion& getRotation() const;
|
||||
virtual void setRotation(const hkQuaternion& rotation);
|
||||
|
||||
virtual void setPositionAndRotation(const hkVector4& position, const hkQuaternion& rotation);
|
||||
|
||||
inline const hkTransform& getTransform() const;
|
||||
virtual void setTransform(const hkTransform& transform);
|
||||
void approxTransformAt(hkTime time, hkTransform& transformOut);
|
||||
|
||||
inline const hkVector4& getLinearVelocity() const;
|
||||
virtual void setLinearVelocity(const hkVector4& newVel);
|
||||
inline const hkVector4& getAngularVelocity() const;
|
||||
virtual void setAngularVelocity(const hkVector4& newVel);
|
||||
inline void getPointVelocity(const hkVector4& p, hkVector4& vecOut) const;
|
||||
virtual void getProjectedPointVelocity(const hkVector4& p, const hkVector4& normal,
|
||||
hkReal& velOut, hkReal& invVirtMassOut) const = 0;
|
||||
virtual void getProjectedPointVelocitySimd(const hkVector4& p, const hkVector4& normal,
|
||||
|
@ -73,8 +87,39 @@ public:
|
|||
virtual void applyForce(hkReal deltaTime, const hkVector4& force, const hkVector4& p) = 0;
|
||||
virtual void applyTorque(hkReal deltaTime, const hkVector4& torque) = 0;
|
||||
|
||||
virtual void getMotionStateAndVelocitiesAndDeactivationType(hkpMotion* motionOut);
|
||||
inline hkReal getLinearDamping() const;
|
||||
inline void setLinearDamping(hkReal d);
|
||||
inline hkReal getAngularDamping() const;
|
||||
inline void setAngularDamping(hkReal d);
|
||||
inline hkReal getTimeFactor() const;
|
||||
inline void setTimeFactor(hkReal f);
|
||||
|
||||
inline hkReal getGravityFactor() const;
|
||||
inline void setGravityFactor(hkReal gravityFactor);
|
||||
|
||||
inline int getDeactivationClass() const;
|
||||
void setDeactivationClass(int deactivationClass);
|
||||
inline void enableDeactivation(bool value, int randomNumber = 0, int worldFlag0 = 0,
|
||||
int worldFlag1 = 0, int worldDeactivationIntegrateCounter = 0);
|
||||
inline bool isDeactivationEnabled() const;
|
||||
void requestDeactivation();
|
||||
|
||||
virtual void getMotionStateAndVelocitiesAndDeactivationType(hkpMotion* motionOut);
|
||||
inline int getNumInactiveFrames(int select) const;
|
||||
inline int getNumInactiveFramesMt(int select,
|
||||
int worldDeactivationNumInactiveFramesSelectFlag) const;
|
||||
inline void setWorldSelectFlagsNeg(int worldFlag0, int worldFlag1,
|
||||
int worldDeactivationIntegrateCounter);
|
||||
inline void incrementNumInactiveFramesMt(int select,
|
||||
int worldDeactivationNumInactiveFramesSelectFlag);
|
||||
inline void zeroNumInactiveFramesMt(int select,
|
||||
int worldDeactivationNumInactiveFramesSelectFlag);
|
||||
|
||||
private:
|
||||
void init(const hkVector4& position, const hkQuaternion& rotation,
|
||||
bool wantDeactivation = false);
|
||||
|
||||
public:
|
||||
hkEnum<MotionType, hkUint8> m_type;
|
||||
hkUint8 m_deactivationIntegrateCounter;
|
||||
hkUint16 m_deactivationNumInactiveFrames[2];
|
||||
|
@ -88,10 +133,159 @@ public:
|
|||
hkUint16 m_savedQualityTypeIndex;
|
||||
hkHalf m_gravityFactor;
|
||||
};
|
||||
|
||||
class hkpRigidMotion : public hkpMotion {
|
||||
public:
|
||||
HK_DECLARE_CLASS_ALLOCATOR(hkpRigidMotion)
|
||||
|
||||
explicit hkpRigidMotion(hkFinishLoadedObjectFlag flag) : hkpMotion(flag) {}
|
||||
};
|
||||
|
||||
inline hkSimdReal hkpMotion::getMassInv() const {
|
||||
return m_inertiaAndMassInv(3);
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpMotion::getCenterOfMassLocal() const {
|
||||
return m_motionState.getSweptTransform().m_centerOfMassLocal;
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpMotion::getCenterOfMassInWorld() const {
|
||||
return m_motionState.getSweptTransform().m_centerOfMass1;
|
||||
}
|
||||
|
||||
inline hkMotionState* hkpMotion::getMotionState() {
|
||||
return &m_motionState;
|
||||
}
|
||||
|
||||
inline const hkMotionState* hkpMotion::getMotionState() const {
|
||||
return &m_motionState;
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpMotion::getPosition() const {
|
||||
return getTransform().getTranslation();
|
||||
}
|
||||
|
||||
inline const hkQuaternion& hkpMotion::getRotation() const {
|
||||
return m_motionState.getSweptTransform().m_rotation1;
|
||||
}
|
||||
|
||||
inline const hkTransform& hkpMotion::getTransform() const {
|
||||
return m_motionState.getTransform();
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpMotion::getLinearVelocity() const {
|
||||
return m_linearVelocity;
|
||||
}
|
||||
|
||||
inline const hkVector4& hkpMotion::getAngularVelocity() const {
|
||||
return m_linearVelocity;
|
||||
}
|
||||
|
||||
inline void hkpMotion::getPointVelocity(const hkVector4& p, hkVector4& vecOut) const {
|
||||
hkVector4 relPos;
|
||||
relPos.setSub(p, getCenterOfMassInWorld());
|
||||
vecOut.setCross(m_angularVelocity, relPos);
|
||||
vecOut.add(m_linearVelocity);
|
||||
}
|
||||
|
||||
inline hkReal hkpMotion::getLinearDamping() const {
|
||||
return m_motionState.m_linearDamping;
|
||||
}
|
||||
|
||||
inline void hkpMotion::setLinearDamping(hkReal d) {
|
||||
m_motionState.m_linearDamping = d;
|
||||
}
|
||||
|
||||
inline hkReal hkpMotion::getAngularDamping() const {
|
||||
return m_motionState.m_angularDamping;
|
||||
}
|
||||
|
||||
inline void hkpMotion::setAngularDamping(hkReal d) {
|
||||
m_motionState.m_angularDamping = d;
|
||||
}
|
||||
|
||||
inline hkReal hkpMotion::getTimeFactor() const {
|
||||
return m_motionState.m_timeFactor;
|
||||
}
|
||||
|
||||
inline void hkpMotion::setTimeFactor(hkReal f) {
|
||||
m_motionState.m_timeFactor = f;
|
||||
}
|
||||
|
||||
inline hkReal hkpMotion::getGravityFactor() const {
|
||||
return m_gravityFactor;
|
||||
}
|
||||
|
||||
inline void hkpMotion::setGravityFactor(hkReal gravityFactor) {
|
||||
m_gravityFactor = gravityFactor;
|
||||
}
|
||||
|
||||
inline int hkpMotion::getDeactivationClass() const {
|
||||
return m_motionState.m_deactivationClass;
|
||||
}
|
||||
|
||||
inline void hkpMotion::enableDeactivation(bool value, int randomNumber, int worldFlag0,
|
||||
int worldFlag1, int worldDeactivationIntegrateCounter) {
|
||||
if (value) {
|
||||
m_deactivationIntegrateCounter = hkUint8(0xf & randomNumber);
|
||||
setWorldSelectFlagsNeg(worldFlag0, worldFlag1, worldDeactivationIntegrateCounter);
|
||||
} else {
|
||||
m_deactivationIntegrateCounter = 0xff;
|
||||
for (auto& frame : m_deactivationNumInactiveFrames)
|
||||
frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool hkpMotion::isDeactivationEnabled() const {
|
||||
return m_deactivationIntegrateCounter != 0xff;
|
||||
}
|
||||
|
||||
inline int hkpMotion::getNumInactiveFrames(int select) const {
|
||||
return m_deactivationNumInactiveFrames[select] & 0x7f;
|
||||
}
|
||||
|
||||
inline int
|
||||
hkpMotion::getNumInactiveFramesMt(int select,
|
||||
int worldDeactivationNumInactiveFramesSelectFlag) const {
|
||||
int dc = m_deactivationNumInactiveFrames[select];
|
||||
int motionDeactivationFlag = dc >> 14;
|
||||
if (worldDeactivationNumInactiveFramesSelectFlag != motionDeactivationFlag)
|
||||
return dc & 0x7f;
|
||||
return (dc >> 7) & 0x7f;
|
||||
}
|
||||
|
||||
inline void hkpMotion::setWorldSelectFlagsNeg(int worldFlag0, int worldFlag1,
|
||||
int worldDeactivationIntegrateCounter) {
|
||||
if (static_cast<unsigned int>(worldDeactivationIntegrateCounter) % 4 <
|
||||
static_cast<unsigned int>(m_deactivationIntegrateCounter) % 4) {
|
||||
worldFlag0 = ~worldFlag0 << 14;
|
||||
} else {
|
||||
worldFlag0 <<= 14;
|
||||
}
|
||||
|
||||
if (worldDeactivationIntegrateCounter < m_deactivationIntegrateCounter) {
|
||||
worldFlag1 = ~worldFlag1 << 14;
|
||||
} else {
|
||||
worldFlag1 <<= 14;
|
||||
}
|
||||
|
||||
m_deactivationNumInactiveFrames[0] =
|
||||
hkUint16((m_deactivationNumInactiveFrames[0] & 0x3fff) | worldFlag0);
|
||||
m_deactivationNumInactiveFrames[1] =
|
||||
hkUint16((m_deactivationNumInactiveFrames[1] & 0x3fff) | worldFlag1);
|
||||
}
|
||||
|
||||
inline void
|
||||
hkpMotion::incrementNumInactiveFramesMt(int select,
|
||||
int worldDeactivationNumInactiveFramesSelectFlag) {
|
||||
int dc = m_deactivationNumInactiveFrames[select] & 0x7f;
|
||||
int newdc = dc + 1 - (dc >> 6);
|
||||
dc = newdc | (dc << 7) | (worldDeactivationNumInactiveFramesSelectFlag << 14);
|
||||
m_deactivationNumInactiveFrames[select] = hkUint16(dc);
|
||||
}
|
||||
|
||||
inline void hkpMotion::zeroNumInactiveFramesMt(int select,
|
||||
int worldDeactivationNumInactiveFramesSelectFlag) {
|
||||
int dc = m_deactivationNumInactiveFrames[select] & 0x7f;
|
||||
dc = (dc << 7) | (worldDeactivationNumInactiveFramesSelectFlag << 14);
|
||||
m_deactivationNumInactiveFrames[select] = hkUint16(dc);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
class hkpWorld {
|
||||
hkpWorld();
|
||||
#include <Havok/Common/Base/hkBase.h>
|
||||
|
||||
enum hkpUpdateCollisionFilterOnWorldMode {
|
||||
HK_UPDATE_FILTER_ON_WORLD_FULL_CHECK,
|
||||
HK_UPDATE_FILTER_ON_WORLD_DISABLE_ENTITY_ENTITY_COLLISIONS_ONLY,
|
||||
};
|
||||
|
||||
enum hkpUpdateCollisionFilterOnEntityMode {
|
||||
HK_UPDATE_FILTER_ON_ENTITY_FULL_CHECK,
|
||||
HK_UPDATE_FILTER_ON_ENTITY_DISABLE_ENTITY_ENTITY_COLLISIONS_ONLY,
|
||||
};
|
||||
|
||||
enum hkpEntityActivation {
|
||||
HK_ENTITY_ACTIVATION_DO_NOT_ACTIVATE,
|
||||
HK_ENTITY_ACTIVATION_DO_ACTIVATE,
|
||||
};
|
||||
|
||||
class hkpWorld {
|
||||
public:
|
||||
hkpWorld();
|
||||
|
||||
hkTime getCurrentTime() const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue