diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 738dd5d0..2fe25104 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -237,7 +237,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options, osg::Image* image = osgDB::readImageFile(fullMaskPath, options); if (image && image->valid()) { - osg::Texture2D* object_mask = new osg::Texture2D; + Texture2DRef object_mask = new osg::Texture2D; bool dds_mask = (ompath.lower_extension() == "dds"); @@ -485,7 +485,7 @@ osg::Texture2D* SGMaterial::get_object_mask(const SGTexturedTriangleBin& triangl // so we index based on the texture index, unsigned int i = triangleBin.getTextureIndex() % _status.size(); if (i < _masks.size()) { - return _masks[i]; + return _masks[i].get(); } else { return 0; } diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index 7ed5958c..c0a65132 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -42,6 +42,9 @@ namespace osg class StateSet; } + +typedef osg::ref_ptr Texture2DRef; + #include #include // for SGMutex #include @@ -466,7 +469,7 @@ private: // Object mask, a simple RGB texture used as a mask when placing // random vegetation, objects and buildings - std::vector _masks; + std::vector _masks; // Condition, indicating when this material is active SGSharedPtr condition;