- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgParticle/ConnectedParticleSystem.cpp
r11482 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 44 44 Particle* particle = ParticleSystem::createParticle(ptemplate); 45 45 int particleIndex = (int)(particle - &_particles[0]); 46 46 47 47 if (particle) 48 48 { 49 49 50 50 if (_startParticle == Particle::INVALID_INDEX) 51 51 { 52 // we are the fisrt particle create, so start the connect particle list 52 // we are the fisrt particle create, so start the connect particle list 53 53 _startParticle = particleIndex; 54 54 } … … 65 65 // set the new particle as the last particle created. 66 66 _lastParticleCreated = particleIndex; 67 68 } 69 67 68 } 69 70 70 return particle; 71 71 } 72 72 73 73 void ConnectedParticleSystem::reuseParticle(int particleIndex) 74 74 { … … 76 76 77 77 if (particleIndex<0 || particleIndex>=(int)_particles.size()) return; 78 78 79 79 Particle* particle = &_particles[particleIndex]; 80 80 int previous = particle->getPreviousParticle(); … … 86 86 _startParticle = particle->getNextParticle(); 87 87 } 88 88 89 89 if (_lastParticleCreated == particleIndex) 90 90 { 91 91 _lastParticleCreated = Particle::INVALID_INDEX; 92 92 } 93 93 94 94 // join up the previous and next particles to account for 95 95 // the deletion of the this particle … … 98 98 _particles[previous].setNextParticle(next); 99 99 } 100 100 101 101 if (next != Particle::INVALID_INDEX) 102 102 { … … 107 107 particle->setPreviousParticle(Particle::INVALID_INDEX); 108 108 particle->setNextParticle(Particle::INVALID_INDEX); 109 109 110 110 // put the particle on the death stack 111 111 ParticleSystem::reuseParticle(particleIndex); … … 122 122 const Particle* particle = (_startParticle != Particle::INVALID_INDEX) ? &_particles[_startParticle] : 0; 123 123 if (!particle) return; 124 124 125 125 126 126 osg::Vec4 pixelSizeVector = osg::CullingSet::computePixelSizeVector(*state.getCurrentViewport(),state.getProjectionMatrix(),state.getModelViewMatrix()); … … 171 171 { 172 172 173 // draw the connected particles as a quad stripped aligned to be orthogonal to the eye 173 // draw the connected particles as a quad stripped aligned to be orthogonal to the eye 174 174 osg::Matrix eyeToLocalTransform; 175 175 eyeToLocalTransform.invert(state.getModelViewMatrix());
