Canvas Image: fix updating while showing nested canvas.
This commit is contained in:
@@ -149,6 +149,24 @@ namespace canvas
|
|||||||
{
|
{
|
||||||
Element::update(dt);
|
Element::update(dt);
|
||||||
|
|
||||||
|
osg::Texture2D* texture = dynamic_cast<osg::Texture2D*>
|
||||||
|
(
|
||||||
|
_geom->getOrCreateStateSet()
|
||||||
|
->getTextureAttribute(0, osg::StateAttribute::TEXTURE)
|
||||||
|
);
|
||||||
|
simgear::canvas::CanvasPtr canvas = _src_canvas.lock();
|
||||||
|
|
||||||
|
if( (_attributes_dirty & SRC_CANVAS)
|
||||||
|
// check if texture has changed (eg. due to resizing)
|
||||||
|
|| (canvas && texture != canvas->getTexture()) )
|
||||||
|
{
|
||||||
|
_geom->getOrCreateStateSet()
|
||||||
|
->setTextureAttribute(0, canvas ? canvas->getTexture() : 0);
|
||||||
|
|
||||||
|
if( !canvas || canvas->isInit() )
|
||||||
|
_attributes_dirty &= ~SRC_CANVAS;
|
||||||
|
}
|
||||||
|
|
||||||
if( !_attributes_dirty )
|
if( !_attributes_dirty )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -335,8 +353,7 @@ namespace canvas
|
|||||||
_canvas.lock()->removeChildCanvas(_src_canvas);
|
_canvas.lock()->removeChildCanvas(_src_canvas);
|
||||||
|
|
||||||
_src_canvas = canvas;
|
_src_canvas = canvas;
|
||||||
_geom->getOrCreateStateSet()
|
_attributes_dirty |= SRC_CANVAS;
|
||||||
->setTextureAttribute(0, canvas ? canvas->getTexture() : 0);
|
|
||||||
_geom->setCullCallback(canvas ? new CullCallback(canvas) : 0);
|
_geom->setCullCallback(canvas ? new CullCallback(canvas) : 0);
|
||||||
|
|
||||||
if( !_src_canvas.expired() )
|
if( !_src_canvas.expired() )
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ namespace canvas
|
|||||||
enum ImageAttributes
|
enum ImageAttributes
|
||||||
{
|
{
|
||||||
SRC_RECT = LAST_ATTRIBUTE << 1, // Source image rectangle
|
SRC_RECT = LAST_ATTRIBUTE << 1, // Source image rectangle
|
||||||
DEST_SIZE = SRC_RECT << 1 // Element size
|
DEST_SIZE = SRC_RECT << 1, // Element size
|
||||||
|
SRC_CANVAS = DEST_SIZE << 1
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void childChanged(SGPropertyNode * child);
|
virtual void childChanged(SGPropertyNode * child);
|
||||||
|
|||||||
Reference in New Issue
Block a user