Make sure each carrier gets its own valocity.
Modified Files: simgear/scene/model/ModelRegistry.cxx
This commit is contained in:
@@ -226,6 +226,28 @@ private:
|
|||||||
FilePathList _pathList;
|
FilePathList _pathList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create new userdata structs in a copied model.
|
||||||
|
// The BVH trees are shared with the original model, but the velocity fields
|
||||||
|
// should usually be distinct fields for distinct models.
|
||||||
|
class UserDataCopyVisitor : public osg::NodeVisitor {
|
||||||
|
public:
|
||||||
|
UserDataCopyVisitor() :
|
||||||
|
osg::NodeVisitor(osg::NodeVisitor::NODE_VISITOR,
|
||||||
|
osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void apply(osg::Node& node)
|
||||||
|
{
|
||||||
|
osg::ref_ptr<SGSceneUserData> userData;
|
||||||
|
userData = SGSceneUserData::getSceneUserData(&node);
|
||||||
|
if (userData.valid()) {
|
||||||
|
SGSceneUserData* newUserData = new SGSceneUserData(*userData);
|
||||||
|
newUserData->setVelocity(0);
|
||||||
|
node.setUserData(newUserData);
|
||||||
|
}
|
||||||
|
node.traverse(*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SGTexCompressionVisitor : public SGTextureStateAttributeVisitor {
|
class SGTexCompressionVisitor : public SGTextureStateAttributeVisitor {
|
||||||
public:
|
public:
|
||||||
@@ -427,6 +449,11 @@ osg::Node* DefaultCopyPolicy::copy(osg::Node* model, const string& fileName,
|
|||||||
TextureUpdateVisitor liveryUpdate(opt->getDatabasePathList());
|
TextureUpdateVisitor liveryUpdate(opt->getDatabasePathList());
|
||||||
res->accept(liveryUpdate);
|
res->accept(liveryUpdate);
|
||||||
|
|
||||||
|
// Copy the userdata fields, still sharing the boundingvolumes,
|
||||||
|
// but introducing new data for velocities.
|
||||||
|
UserDataCopyVisitor userDataCopyVisitor;
|
||||||
|
res->accept(userDataCopyVisitor);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user