mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 03:45:35 +00:00
Fix NPC physics scale problem
This commit is contained in:
parent
b0199c703c
commit
af6409b9f5
1 changed files with 5 additions and 4 deletions
|
@ -89,18 +89,19 @@ namespace Physic
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicActor::setScale(float scale){
|
void PhysicActor::setScale(float scale){
|
||||||
Ogre::Vector3 position = getPosition();
|
|
||||||
Ogre::Quaternion rotation = getRotation();
|
|
||||||
//We only need to change the scaled box translation, box rotations remain the same.
|
//We only need to change the scaled box translation, box rotations remain the same.
|
||||||
mBoxScaledTranslation = mBoxScaledTranslation / mBody->getCollisionShape()->getLocalScaling().getX();
|
mBoxScaledTranslation = mBoxScaledTranslation / mBody->getCollisionShape()->getLocalScaling().getX();
|
||||||
mBoxScaledTranslation *= scale;
|
mBoxScaledTranslation *= scale;
|
||||||
if(mBody){
|
if(mBody){
|
||||||
mEngine->dynamicsWorld->removeRigidBody(mBody);
|
mEngine->dynamicsWorld->removeRigidBody(mBody);
|
||||||
|
mEngine->dynamicsWorld->removeRigidBody(mRaycastingBody);
|
||||||
delete mBody;
|
delete mBody;
|
||||||
|
delete mRaycastingBody;
|
||||||
}
|
}
|
||||||
//Create the newly scaled rigid body
|
//Create the newly scaled rigid body
|
||||||
mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation);
|
mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, getPosition(), getRotation());
|
||||||
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
mRaycastingBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, getPosition(), getRotation(), 0, 0, true);
|
||||||
|
mEngine->addRigidBody(mBody, false, mRaycastingBody); //Add rigid body to dynamics world, but do not add to object map
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::Vector3 PhysicActor::getHalfExtents() const
|
Ogre::Vector3 PhysicActor::getHalfExtents() const
|
||||||
|
|
Loading…
Reference in a new issue