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

remove hackish particle setup #2446

Closed
wants to merge 3 commits into from
Closed
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
Next Next commit
remove dead code
  • Loading branch information
mp3butcher committed Jul 10, 2019
commit cde9c6b716ec974bbf57ff039fa9a0477d9c4297
47 changes: 0 additions & 47 deletions components/resource/scenemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,6 @@
namespace
{

class InitWorldSpaceParticlesCallback : public osg::NodeCallback
{
public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osgParticle::ParticleSystem* partsys = static_cast<osgParticle::ParticleSystem*>(node);

// HACK: Ignore the InverseWorldMatrix transform the particle system is attached to
if (partsys->getNumParents() && partsys->getParent(0)->getNumParents())
transformInitialParticles(partsys, partsys->getParent(0)->getParent(0));

node->removeUpdateCallback(this);
}

void transformInitialParticles(osgParticle::ParticleSystem* partsys, osg::Node* node)
{
osg::NodePathList nodepaths = node->getParentalNodePaths();
if (nodepaths.empty())
return;
osg::Matrixf worldMat = osg::computeLocalToWorld(nodepaths[0]);
worldMat.orthoNormalize(worldMat); // scale is already applied on the particle node
for (int i=0; i<partsys->numParticles(); ++i)
{
partsys->getParticle(i)->transformPositionVelocity(worldMat);
}

// transform initial bounds to worldspace
osg::BoundingSphere sphere(partsys->getInitialBound());
SceneUtil::transformBoundingSphere(worldMat, sphere);
osg::BoundingBox box;
box.expandBy(sphere);
partsys->setInitialBound(box);
}

};

class InitParticlesVisitor : public osg::NodeVisitor
{
Expand All @@ -83,22 +48,10 @@ namespace
{
}

bool isWorldSpaceParticleSystem(osgParticle::ParticleSystem* partsys)
{
// HACK: ParticleSystem has no getReferenceFrame()
return (partsys->getUserDataContainer()
&& partsys->getUserDataContainer()->getNumDescriptions() > 0
&& partsys->getUserDataContainer()->getDescriptions()[0] == "worldspace");
}

void apply(osg::Drawable& drw)
{
if (osgParticle::ParticleSystem* partsys = dynamic_cast<osgParticle::ParticleSystem*>(&drw))
{
if (isWorldSpaceParticleSystem(partsys))
{
partsys->addUpdateCallback(new InitWorldSpaceParticlesCallback);
}
partsys->setNodeMask(mMask);
}
}
Expand Down