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/TextureCubeMap.cpp

    r10867 r10924  
    1616#include <osg/State> 
    1717#include <osg/TextureCubeMap> 
    18 #include <osg/ImageSequence> 
    1918#include <osg/Notify> 
    2019 
     
    132131    if (_images[face] == image) return; 
    133132 
    134     unsigned numImageSequencesBefore = 0; 
     133    unsigned numImageRequireUpdateBefore = 0; 
    135134    for (unsigned int i=0; i<getNumImages(); ++i) 
    136135    { 
    137         osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 
    138         if (is) ++numImageSequencesBefore; 
     136        if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateBefore; 
    139137    } 
    140138 
     
    143141 
    144142 
    145     // find out if we need to reset the update callback to handle the animation of ImageSequence 
    146     unsigned numImageSequencesAfter = 0; 
     143    // find out if we need to reset the update callback to handle the animation of image 
     144    unsigned numImageRequireUpdateAfter = 0; 
    147145    for (unsigned int i=0; i<getNumImages(); ++i) 
    148146    { 
    149         osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 
    150         if (is) ++numImageSequencesAfter; 
    151     } 
    152  
    153     if (numImageSequencesBefore>0) 
    154     { 
    155         if (numImageSequencesAfter==0) 
     147        if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateAfter; 
     148    } 
     149 
     150    if (numImageRequireUpdateBefore>0) 
     151    { 
     152        if (numImageRequireUpdateAfter==0) 
    156153        { 
    157154            setUpdateCallback(0); 
     
    159156        } 
    160157    } 
    161     else if (numImageSequencesAfter>0) 
    162     { 
    163         setUpdateCallback(new ImageSequence::UpdateCallback()); 
     158    else if (numImageRequireUpdateAfter>0) 
     159    { 
     160        setUpdateCallback(new Image::UpdateCallback()); 
    164161        setDataVariance(osg::Object::DYNAMIC); 
    165162    }