Show
Ignore:
Timestamp:
01/07/10 13:14:47 (4 years ago)
Author:
robert
Message:

Refactored the way that osg::Image/ImageSequence manages the update callback that needs to be attached to Textures to make it possible to use the Image::update() mechansim in other subclasses from osg::Image.
To enable the automatic attachment of the required update callback to call osg::Image::update(..) subclasses from osg::Image will
need to implement the osg::Image::requestUpdateCall() and return true, and implement the osg::Image::update(NodeVisitor?*) method to recieve the update call during the update traversal.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osg/Texture2DArray.cpp

    r10867 r10924  
    1414#include <osg/Texture2DArray> 
    1515#include <osg/State> 
    16 #include <osg/ImageSequence> 
    1716#include <osg/Notify> 
    1817 
     
    114113    if (_images[layer] == image) return; 
    115114 
    116     unsigned numImageSequencesBefore = 0; 
     115    unsigned numImageRequireUpdateBefore = 0; 
    117116    for (unsigned int i=0; i<getNumImages(); ++i) 
    118117    { 
    119         osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 
    120         if (is) ++numImageSequencesBefore; 
     118        if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateBefore; 
    121119    } 
    122120 
     
    125123   _modifiedCount[layer].setAllElementsTo(0); 
    126124 
    127     // find out if we need to reset the update callback to handle the animation of ImageSequence 
    128     unsigned numImageSequencesAfter = 0; 
     125    // find out if we need to reset the update callback to handle the animation of image 
     126    unsigned numImageRequireUpdateAfter = 0; 
    129127    for (unsigned int i=0; i<getNumImages(); ++i) 
    130128    { 
    131         osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 
    132         if (is) ++numImageSequencesAfter; 
    133     } 
    134  
    135     if (numImageSequencesBefore>0) 
    136     { 
    137         if (numImageSequencesAfter==0) 
     129        if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateAfter; 
     130    } 
     131 
     132    if (numImageRequireUpdateBefore>0) 
     133    { 
     134        if (numImageRequireUpdateAfter==0) 
    138135        { 
    139136            setUpdateCallback(0); 
     
    141138        } 
    142139    } 
    143     else if (numImageSequencesAfter>0) 
    144     { 
    145         setUpdateCallback(new ImageSequence::UpdateCallback()); 
     140    else if (numImageRequireUpdateAfter>0) 
     141    { 
     142        setUpdateCallback(new Image::UpdateCallback()); 
    146143        setDataVariance(osg::Object::DYNAMIC); 
    147144    }