1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-19 12:40:49 +00:00

Replace release by assigning nullptr

release does not call a destructor if it's the last reference. This is not a
right choice here. Even though the functions accept raw pointers they convert
them into osg::ref_ptr. So it's ok to share the ownership.
This commit is contained in:
elsid 2024-05-20 16:52:50 +02:00
parent 4b8897e33e
commit 10e14a3c21
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

View File

@ -86,15 +86,16 @@ namespace SceneUtil
void DebugDraw::end()
{
const osg::ref_ptr<osg::DrawArrays> drawArrays
= new osg::DrawArrays(mMode, 0, static_cast<int>(mVertices->size()));
osg::ref_ptr<osg::Geometry> geometry(new osg::Geometry);
geometry->setStateSet(mStateSet);
geometry->setVertexArray(mVertices);
geometry->setColorArray(mColors, osg::Array::BIND_PER_VERTEX);
geometry->addPrimitiveSet(new osg::DrawArrays(mMode, 0, static_cast<int>(mVertices->size())));
geometry->addPrimitiveSet(drawArrays);
geometry->setVertexArray(std::exchange(mVertices, nullptr));
geometry->setColorArray(std::exchange(mColors, nullptr), osg::Array::BIND_PER_VERTEX);
mGroup.addChild(geometry);
mColors.release();
mVertices.release();
}
void DebugDraw::addVertex(osg::Vec3f&& position)