Changeset 13428

Show
Ignore:
Timestamp:
03/01/15 12:08:58 (86 minutes ago)
Author:
robert
Message:

From Jannik Heller, "I noticed the rotation in the OrbitManipulator? depends on the framerate. To reproduce this issue, start the osganimate example, rotate the model with the left mouse button, then let go of the mouse button while still moving. You will notice that with V-Sync enabled, the model rotates slower.

The OrbitManipulator? calculates a scale to counteract the framerate dependency, but it turns out this scale wasn't used for the rotation yet."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgParticle/ParticleSystem.cpp

    r13041 r13428  
    140140        { 
    141141            osg::Matrixd modelview = *(cv->getModelViewMatrix()); 
    142             float scale = (_sortMode==SORT_FRONT_TO_BACK ? -1.0f : 1.0f); 
     142            double scale = (_sortMode==SORT_FRONT_TO_BACK ? -1.0 : 1.0); 
     143            double deadDistance = DBL_MAX; 
    143144            for (unsigned int i=0; i<_particles.size(); ++i) 
    144145            { 
     
    147148                    particle.setDepth(distance(particle.getPosition(), modelview) * scale); 
    148149                else 
    149                     particle.setDepth(0.0f); 
     150                    particle.setDepth(deadDistance); 
    150151            } 
    151152            std::sort<Particle_vector::iterator>(_particles.begin(), _particles.end()); 
     153 
     154            // Repopulate the death stack as it will have been invalidated by the sort. 
     155            unsigned int numDead = _deadparts.size(); 
     156            if (numDead>0) 
     157            {             
     158                 // clear the death stack 
     159                _deadparts = Death_stack(); 
     160                 
     161                // copy the tail of the _particles vector as this will contain all the dead Particle thanks to the depth sort against DBL_MAX 
     162                Particle* first_dead_ptr  = &_particles[_particles.size()-numDead]; 
     163                Particle* last_dead_ptr  = &_particles[_particles.size()-1]; 
     164                for(Particle* dead_ptr  = first_dead_ptr; dead_ptr<=last_dead_ptr; ++dead_ptr) 
     165                { 
     166                    _deadparts.push(dead_ptr); 
     167                } 
     168            } 
    152169        } 
    153170    }