mirror of
https://github.com/overte-org/overte.git
synced 2025-04-24 20:34:20 +02:00
first set shape THEN use it
This commit is contained in:
parent
bd6f00e707
commit
e336c9276d
1 changed files with 3 additions and 6 deletions
|
@ -181,15 +181,12 @@ float AvatarMotionState::getMass() const {
|
|||
|
||||
void AvatarMotionState::cacheShapeDiameter() {
|
||||
if (_shape) {
|
||||
// measure XZ diameter of capsule shape
|
||||
// shape is capsuleY
|
||||
btVector3 aabbMin, aabbMax;
|
||||
btTransform transform;
|
||||
transform.setIdentity();
|
||||
_shape->getAabb(transform, aabbMin, aabbMax);
|
||||
aabbMax -= aabbMin;
|
||||
aabbMax.setY(0.0f);
|
||||
const float SQRT_TWO = 1.414213562f;
|
||||
_diameter = SQRT_TWO * aabbMax.length();
|
||||
_diameter = (aabbMax - aabbMin).getX();
|
||||
} else {
|
||||
_diameter = 0.0f;
|
||||
}
|
||||
|
@ -204,6 +201,6 @@ void AvatarMotionState::setRigidBody(btRigidBody* body) {
|
|||
}
|
||||
|
||||
void AvatarMotionState::setShape(const btCollisionShape* shape) {
|
||||
cacheShapeDiameter();
|
||||
ObjectMotionState::setShape(shape);
|
||||
cacheShapeDiameter();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue