add an update revision, to make it easier to sync with Bullet 3.x
add set/getUserindex in addition to set/getUserPointer
This commit is contained in:
@@ -38,7 +38,8 @@ btCollisionObject::btCollisionObject()
|
|||||||
m_hitFraction(btScalar(1.)),
|
m_hitFraction(btScalar(1.)),
|
||||||
m_ccdSweptSphereRadius(btScalar(0.)),
|
m_ccdSweptSphereRadius(btScalar(0.)),
|
||||||
m_ccdMotionThreshold(btScalar(0.)),
|
m_ccdMotionThreshold(btScalar(0.)),
|
||||||
m_checkCollideWith(false)
|
m_checkCollideWith(false),
|
||||||
|
m_updateRevision(0)
|
||||||
{
|
{
|
||||||
m_worldTransform.setIdentity();
|
m_worldTransform.setIdentity();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,11 @@ protected:
|
|||||||
int m_internalType;
|
int m_internalType;
|
||||||
|
|
||||||
///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer
|
///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer
|
||||||
void* m_userObjectPointer;
|
union
|
||||||
|
{
|
||||||
|
void* m_userObjectPointer;
|
||||||
|
int m_userIndex;
|
||||||
|
};
|
||||||
|
|
||||||
///time of impact calculation
|
///time of impact calculation
|
||||||
btScalar m_hitFraction;
|
btScalar m_hitFraction;
|
||||||
@@ -106,6 +110,9 @@ protected:
|
|||||||
/// If some object should have elaborate collision filtering by sub-classes
|
/// If some object should have elaborate collision filtering by sub-classes
|
||||||
int m_checkCollideWith;
|
int m_checkCollideWith;
|
||||||
|
|
||||||
|
///internal update revision number. It will be increased when the object changes. This allows some subsystems to perform lazy evaluation.
|
||||||
|
int m_updateRevision;
|
||||||
|
|
||||||
virtual bool checkCollideWithOverride(const btCollisionObject* /* co */) const
|
virtual bool checkCollideWithOverride(const btCollisionObject* /* co */) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -202,6 +209,7 @@ public:
|
|||||||
|
|
||||||
virtual void setCollisionShape(btCollisionShape* collisionShape)
|
virtual void setCollisionShape(btCollisionShape* collisionShape)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_collisionShape = collisionShape;
|
m_collisionShape = collisionShape;
|
||||||
m_rootCollisionShape = collisionShape;
|
m_rootCollisionShape = collisionShape;
|
||||||
}
|
}
|
||||||
@@ -257,6 +265,7 @@ public:
|
|||||||
|
|
||||||
void setRestitution(btScalar rest)
|
void setRestitution(btScalar rest)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_restitution = rest;
|
m_restitution = rest;
|
||||||
}
|
}
|
||||||
btScalar getRestitution() const
|
btScalar getRestitution() const
|
||||||
@@ -265,6 +274,7 @@ public:
|
|||||||
}
|
}
|
||||||
void setFriction(btScalar frict)
|
void setFriction(btScalar frict)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_friction = frict;
|
m_friction = frict;
|
||||||
}
|
}
|
||||||
btScalar getFriction() const
|
btScalar getFriction() const
|
||||||
@@ -274,6 +284,7 @@ public:
|
|||||||
|
|
||||||
void setRollingFriction(btScalar frict)
|
void setRollingFriction(btScalar frict)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_rollingFriction = frict;
|
m_rollingFriction = frict;
|
||||||
}
|
}
|
||||||
btScalar getRollingFriction() const
|
btScalar getRollingFriction() const
|
||||||
@@ -300,6 +311,7 @@ public:
|
|||||||
|
|
||||||
void setWorldTransform(const btTransform& worldTrans)
|
void setWorldTransform(const btTransform& worldTrans)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_worldTransform = worldTrans;
|
m_worldTransform = worldTrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,16 +344,19 @@ public:
|
|||||||
|
|
||||||
void setInterpolationWorldTransform(const btTransform& trans)
|
void setInterpolationWorldTransform(const btTransform& trans)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_interpolationWorldTransform = trans;
|
m_interpolationWorldTransform = trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInterpolationLinearVelocity(const btVector3& linvel)
|
void setInterpolationLinearVelocity(const btVector3& linvel)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_interpolationLinearVelocity = linvel;
|
m_interpolationLinearVelocity = linvel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInterpolationAngularVelocity(const btVector3& angvel)
|
void setInterpolationAngularVelocity(const btVector3& angvel)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_interpolationAngularVelocity = angvel;
|
m_interpolationAngularVelocity = angvel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,13 +446,28 @@ public:
|
|||||||
{
|
{
|
||||||
return m_userObjectPointer;
|
return m_userObjectPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getUserIndex() const
|
||||||
|
{
|
||||||
|
return m_userIndex;
|
||||||
|
}
|
||||||
///users can point to their objects, userPointer is not used by Bullet
|
///users can point to their objects, userPointer is not used by Bullet
|
||||||
void setUserPointer(void* userPointer)
|
void setUserPointer(void* userPointer)
|
||||||
{
|
{
|
||||||
m_userObjectPointer = userPointer;
|
m_userObjectPointer = userPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///users can point to their objects, userPointer is not used by Bullet
|
||||||
|
void setUserIndex(int index)
|
||||||
|
{
|
||||||
|
m_userIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getUpdateRevisionInternal() const
|
||||||
|
{
|
||||||
|
return m_updateRevision;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool checkCollideWith(const btCollisionObject* co) const
|
inline bool checkCollideWith(const btCollisionObject* co) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -363,11 +363,13 @@ public:
|
|||||||
|
|
||||||
inline void setLinearVelocity(const btVector3& lin_vel)
|
inline void setLinearVelocity(const btVector3& lin_vel)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_linearVelocity = lin_vel;
|
m_linearVelocity = lin_vel;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setAngularVelocity(const btVector3& ang_vel)
|
inline void setAngularVelocity(const btVector3& ang_vel)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_angularVelocity = ang_vel;
|
m_angularVelocity = ang_vel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,11 +486,13 @@ public:
|
|||||||
|
|
||||||
void setAngularFactor(const btVector3& angFac)
|
void setAngularFactor(const btVector3& angFac)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_angularFactor = angFac;
|
m_angularFactor = angFac;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAngularFactor(btScalar angFac)
|
void setAngularFactor(btScalar angFac)
|
||||||
{
|
{
|
||||||
|
m_updateRevision++;
|
||||||
m_angularFactor.setValue(angFac,angFac,angFac);
|
m_angularFactor.setValue(angFac,angFac,angFac);
|
||||||
}
|
}
|
||||||
const btVector3& getAngularFactor() const
|
const btVector3& getAngularFactor() const
|
||||||
|
|||||||
Reference in New Issue
Block a user