Skip to content

Commit

Permalink
Merge branch 'reanimaterescaling' into 'master'
Browse files Browse the repository at this point in the history
Restore animated collision shape rescaling (take 3)

See merge request OpenMW/openmw!3635
  • Loading branch information
jvoisin committed Dec 10, 2023
2 parents 623a610 + 754c5a8 commit 47b87f1
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 46 deletions.
12 changes: 10 additions & 2 deletions apps/openmw/mwphysics/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace MWPhysics

osg::NodePath& nodePath = nodePathFound->second;
osg::Matrixf matrix = osg::computeLocalToWorld(nodePath);
btVector3 scale = Misc::Convert::toBullet(matrix.getScale());
matrix.orthoNormalize(matrix);

btTransform transform;
Expand All @@ -145,8 +146,15 @@ namespace MWPhysics
for (int j = 0; j < 3; ++j)
transform.getBasis()[i][j] = matrix(j, i); // NB column/row major difference

// Note: we can not apply scaling here for now since we treat scaled shapes
// as new shapes (btScaledBvhTriangleMeshShape) with 1.0 scale for now
btCollisionShape* childShape = compound->getChildShape(shapeIndex);
btVector3 newScale = compound->getLocalScaling() * scale;

if (childShape->getLocalScaling() != newScale)
{
childShape->setLocalScaling(newScale);
result = true;
}

if (!(transform == compound->getChildTransform(shapeIndex)))
{
compound->updateChildTransform(shapeIndex, transform);
Expand Down
Loading

0 comments on commit 47b87f1

Please sign in to comment.