Fix a multithreading crash caused by modification of live Geometry

0.6.1
scrawl 8 years ago
parent 2873c10284
commit d8505e4f48

@ -318,9 +318,9 @@ namespace Shader
const ShaderRequirements& reqs = mRequirements.back(); const ShaderRequirements& reqs = mRequirements.back();
bool useShader = reqs.mShaderRequired || mForceShaders; bool useShader = reqs.mShaderRequired || mForceShaders;
bool generateTangents = reqs.mTexStageRequiringTangents != -1 && mAllowedToModifyStateSets; bool generateTangents = reqs.mTexStageRequiringTangents != -1;
if (useShader || generateTangents) if (mAllowedToModifyStateSets && (useShader || generateTangents))
{ {
osg::ref_ptr<osg::Geometry> sourceGeometry = &geometry; osg::ref_ptr<osg::Geometry> sourceGeometry = &geometry;
SceneUtil::RigGeometry* rig = dynamic_cast<SceneUtil::RigGeometry*>(&geometry); SceneUtil::RigGeometry* rig = dynamic_cast<SceneUtil::RigGeometry*>(&geometry);
@ -329,16 +329,13 @@ namespace Shader
bool requiresSetGeometry = false; bool requiresSetGeometry = false;
if (mAllowedToModifyStateSets) // make sure that all UV sets are there
for (std::map<int, std::string>::const_iterator it = reqs.mTextures.begin(); it != reqs.mTextures.end(); ++it)
{ {
// make sure that all UV sets are there if (sourceGeometry->getTexCoordArray(it->first) == NULL)
for (std::map<int, std::string>::const_iterator it = reqs.mTextures.begin(); it != reqs.mTextures.end(); ++it)
{ {
if (sourceGeometry->getTexCoordArray(it->first) == NULL) sourceGeometry->setTexCoordArray(it->first, sourceGeometry->getTexCoordArray(0));
{ requiresSetGeometry = true;
sourceGeometry->setTexCoordArray(it->first, sourceGeometry->getTexCoordArray(0));
requiresSetGeometry = true;
}
} }
} }

Loading…
Cancel
Save