Changeset 10420

Show
Ignore:
Timestamp:
06/25/09 20:31:43 (5 years ago)
Author:
robert
Message:

Simplified throw rate code, and add throw rate compensation into zoom in/out code.

Location:
OpenSceneGraph/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgGA/TrackballManipulator

    r10419 r10420  
    149149        bool _allowThrow; 
    150150        bool _thrown; 
    151          
    152151 
    153         /** Indicates whether "thrown" display should match rate of motion at time of throw. 
    154           * This is significant on systems where the delta between mouse events can be radically different 
    155           * from the delta in display update events. 
    156           */ 
    157         bool _rate_sensitive; 
    158  
    159         /** The approximate amount of time it is currently taking to draw a frame.  
     152        /** The approximate amount of time it is currently taking to draw a frame. 
    160153          * This is used to compute the delta in translation/rotation during a thrown display update. 
    161154          * It allows us to match an delta in position/rotation independent of the rendering frame rate. 
  • OpenSceneGraph/trunk/src/osgGA/TrackballManipulator.cpp

    r10419 r10420  
    1313    _allowThrow = true; 
    1414    _thrown = false; 
    15     _rate_sensitive = true; 
    1615 
    1716    _distance = 1.0f; 
     
    311310        buttonMask = _ga_t1->getButtonMask(); 
    312311    } 
    313      
     312 
     313 
     314    double throwScale =  (_thrown && _ga_t0.valid() && _ga_t1.valid()) ? 
     315            _delta_frame_time / (_ga_t0->getTime() - _ga_t1->getTime()) : 
     316            1.0; 
     317 
    314318    if (buttonMask==GUIEventAdapter::LEFT_MOUSE_BUTTON) 
    315319    { 
     
    331335        osg::Quat new_rotate; 
    332336 
    333         if (_thrown && _rate_sensitive && _ga_t0.valid() && _ga_t1.valid()) 
    334         { 
    335             // frame_time / delta_event_time 
    336             double rate = _delta_frame_time / (_ga_t0->getTime() - _ga_t1->getTime()); 
    337             new_rotate.makeRotate(angle * rate,axis); 
    338         } else { 
    339             new_rotate.makeRotate(angle,axis); 
    340         } 
    341          
     337        new_rotate.makeRotate(angle * throwScale,axis); 
     338 
    342339        _rotation = _rotation*new_rotate; 
    343340 
     
    351348        // pan model. 
    352349 
    353         float scale = -0.3f*_distance; 
     350        float scale = -0.3f * _distance * throwScale; 
    354351 
    355352        osg::Matrix rotation_matrix; 
    356353        rotation_matrix.makeRotate(_rotation); 
    357  
    358         if (_thrown && _rate_sensitive && _ga_t0.valid() && _ga_t1.valid()) 
    359         { 
    360             // frame_time / delta_event_time 
    361             double rate = _delta_frame_time / (_ga_t0->getTime() - _ga_t1->getTime()); 
    362             scale *= rate; 
    363         } 
    364354 
    365355        osg::Vec3 dv(dx*scale,dy*scale,0.0f); 
     
    376366 
    377367        float fd = _distance; 
    378         float scale = 1.0f+dy; 
     368        float scale = 1.0f+ dy * throwScale; 
    379369        if (fd*scale>_modelScale*_minimumZoomScale) 
    380370        {