Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RigTransformSoftware: update bounding box for RigGeometry each update… #1150

Open
wants to merge 1 commit into
base: OpenSceneGraph-3.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions include/osgAnimation/RigTransformSoftware
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace osgAnimation
};

template <class V>
inline void compute(const osg::Matrix& transform, const osg::Matrix& invTransform, const V* src, V* dst)
inline void compute(const osg::Matrix& transform, const osg::Matrix& invTransform, const V* src, V* dst, osg::BoundingBox* bbox = NULL)
{
// the result of matrix mult should be cached to be used for vertices transform and normal transform and maybe other computation
for(VertexGroupList::iterator itvg=_uniqVertexGroupList.begin(); itvg!=_uniqVertexGroupList.end(); ++itvg)
Expand All @@ -145,7 +145,10 @@ namespace osgAnimation
const IndexList& vertices = uniq.getVertices();
for(IndexList::const_iterator vertIDit=vertices.begin(); vertIDit!=vertices.end(); ++vertIDit)
{
dst[*vertIDit] = src[*vertIDit] * matrix;
osg::Vec3 v = src[*vertIDit] * matrix;
dst[*vertIDit] = v;
if (bbox)
bbox->expandBy(v);
}

}
Expand Down
4 changes: 3 additions & 1 deletion src/osgAnimation/RigTransformSoftware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,12 @@ void RigTransformSoftware::operator()(RigGeometry& geom)
osg::Vec3Array* normalDst = static_cast<osg::Vec3Array*>(destination.getNormalArray());


osg::BoundingBox bbox;
compute<osg::Vec3>(geom.getMatrixFromSkeletonToGeometry(),
geom.getInvMatrixFromSkeletonToGeometry(),
&positionSrc->front(),
&positionDst->front());
&positionDst->front(), &bbox);
geom.setInitialBound(bbox);
positionDst->dirty();

if (normalSrc )
Expand Down