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

move rig and morph update in update thread #2445

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
remove dynamic datavariance on morph
as well as mutices
  • Loading branch information
juval committed Jul 9, 2019
commit 773f03b29b714c09b0326b66ac41bea720412196
19 changes: 9 additions & 10 deletions components/sceneutil/morphgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void MorphGeometry::setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeom)
to.setSupportsDisplayList(false);
to.setUseVertexBufferObjects(true);
to.setCullingActive(false); // make sure to disable culling since that's handled by this class
to.setDataVariance(osg::Object::DYNAMIC);

// vertices are modified every frame, so we need to deep copy them.
// assign a dedicated VBO to make sure that modifications don't interfere with source geometry's VBO.
Expand Down Expand Up @@ -184,24 +183,24 @@ void MorphGeometry::update(osg::NodeVisitor *nv)
}

positionDst->dirty();

#if OSG_MIN_VERSION_REQUIRED(3, 5, 6)
geom.dirtyGLObjects();
#endif
nv->pushOntoNodePath(&geom);
nv->apply(geom);
nv->popFromNodePath();

mLastFrameMutex.lock();
//ready to consum
mLastFrameNumber = traversalNumber;
mLastFrameMutex.unlock();
}

void MorphGeometry::cull(osg::NodeVisitor *nv)
{
mLastFrameMutex.lock();
osg::Geometry& geom = *getGeometry(mLastFrameNumber);
mLastFrameMutex.unlock();
nv->pushOntoNodePath(&geom);
nv->apply(geom);
nv->popFromNodePath();
osg::Geometry& geom = *getGeometry(mLastFrameNumber);

nv->pushOntoNodePath(&geom);
nv->apply(geom);
nv->popFromNodePath();

}

Expand Down
1 change: 0 additions & 1 deletion components/sceneutil/morphgeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ namespace SceneUtil
osg::Geometry* getGeometry(unsigned int frame) const;

unsigned int mLastFrameNumber;
OpenThreads::Mutex mLastFrameMutex;
bool mDirty; // Have any morph targets changed?

mutable bool mMorphedBoundingBox;
Expand Down
5 changes: 0 additions & 5 deletions components/sceneutil/riggeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,7 @@ void RigGeometry::update(osg::NodeVisitor* nv){
nv->apply(geom);
nv->popFromNodePath();

mLastFrameMutex.lock();
//ready to consum
mLastFrameNumber = traversalNumber;
mLastFrameMutex.unlock();
}

void RigGeometry::cull(osg::NodeVisitor* nv)
Expand All @@ -269,9 +266,7 @@ void RigGeometry::cull(osg::NodeVisitor* nv)
return;
}

mLastFrameMutex.lock();
osg::Geometry& geom = *getGeometry(mLastFrameNumber);
mLastFrameMutex.unlock();

nv->pushOntoNodePath(&geom);
nv->apply(geom);
Expand Down
1 change: 0 additions & 1 deletion components/sceneutil/riggeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ namespace SceneUtil
std::vector<Bone*> mBoneNodesVector;

unsigned int mLastFrameNumber;
OpenThreads::Mutex mLastFrameMutex;
bool mBoundsFirstFrame;

bool initFromParentSkeleton(osg::NodeVisitor* nv);
Expand Down