Get rid of obsolete osg::Geode where it is possible

LTO-timing^2^2
Andrei Kortunov 2 years ago
parent 0b08e5e29a
commit de58c9dff3

@ -1,7 +1,6 @@
#include "cell.hpp" #include "cell.hpp"
#include <osg/PositionAttitudeTransform> #include <osg/PositionAttitudeTransform>
#include <osg/Geode>
#include <osg/Group> #include <osg/Group>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>

@ -18,7 +18,6 @@ namespace osg
{ {
class Group; class Group;
class Geometry; class Geometry;
class Geode;
} }
namespace CSMWorld namespace CSMWorld

@ -1,14 +1,11 @@
#include "cellarrow.hpp" #include "cellarrow.hpp"
#include <osg/Group> #include <osg/Group>
#include <osg/PositionAttitudeTransform> #include <osg/PositionAttitudeTransform>
#include <osg/Geode>
#include <osg/Geometry> #include <osg/Geometry>
#include <osg/PrimitiveSet> #include <osg/PrimitiveSet>
#include "../../model/prefs/state.hpp" #include "../../model/prefs/state.hpp"
#include "../../model/prefs/shortcutmanager.hpp"
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
@ -159,10 +156,7 @@ void CSVRender::CellArrow::buildShape()
geometry->getOrCreateStateSet()->setMode (GL_LIGHTING, osg::StateAttribute::OFF); geometry->getOrCreateStateSet()->setMode (GL_LIGHTING, osg::StateAttribute::OFF);
osg::ref_ptr<osg::Geode> geode (new osg::Geode); mBaseNode->addChild (geometry);
geode->addDrawable (geometry);
mBaseNode->addChild (geode);
} }
CSVRender::CellArrow::CellArrow (osg::Group *cellNode, Direction direction, CSVRender::CellArrow::CellArrow (osg::Group *cellNode, Direction direction,

@ -2,7 +2,6 @@
#include <osg/AutoTransform> #include <osg/AutoTransform>
#include <osg/Material> #include <osg/Material>
#include <osg/Geode>
#include <osgText/Text> #include <osgText/Text>
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
@ -44,9 +43,7 @@ void CSVRender::CellMarker::buildMarker()
markerText->setText(coordinatesText); markerText->setText(coordinatesText);
// Add text to marker node. // Add text to marker node.
osg::ref_ptr<osg::Geode> geode (new osg::Geode); mMarkerNode->addChild(markerText);
geode->addDrawable(markerText);
mMarkerNode->addChild(geode);
} }
void CSVRender::CellMarker::positionMarker() void CSVRender::CellMarker::positionMarker()

@ -1,6 +1,5 @@
#include "cellwater.hpp" #include "cellwater.hpp"
#include <osg/Geode>
#include <osg/Geometry> #include <osg/Geometry>
#include <osg/Group> #include <osg/Group>
#include <osg/PositionAttitudeTransform> #include <osg/PositionAttitudeTransform>
@ -28,7 +27,7 @@ namespace CSVRender
, mId(id) , mId(id)
, mParentNode(cellNode) , mParentNode(cellNode)
, mWaterTransform(nullptr) , mWaterTransform(nullptr)
, mWaterNode(nullptr) , mWaterGroup(nullptr)
, mWaterGeometry(nullptr) , mWaterGeometry(nullptr)
, mDeleted(false) , mDeleted(false)
, mExterior(false) , mExterior(false)
@ -41,8 +40,8 @@ namespace CSVRender
mWaterTransform->setNodeMask(Mask_Water); mWaterTransform->setNodeMask(Mask_Water);
mParentNode->addChild(mWaterTransform); mParentNode->addChild(mWaterTransform);
mWaterNode = new osg::Geode(); mWaterGroup = new osg::Group();
mWaterTransform->addChild(mWaterNode); mWaterTransform->addChild(mWaterGroup);
int cellIndex = mData.getCells().searchId(mId); int cellIndex = mData.getCells().searchId(mId);
if (cellIndex > -1) if (cellIndex > -1)
@ -136,7 +135,7 @@ namespace CSVRender
if (mWaterGeometry) if (mWaterGeometry)
{ {
mWaterNode->removeDrawable(mWaterGeometry); mWaterGroup->removeChild(mWaterGeometry);
mWaterGeometry = nullptr; mWaterGeometry = nullptr;
} }
@ -177,6 +176,6 @@ namespace CSVRender
mWaterGeometry->getStateSet()->setTextureAttributeAndModes(0, waterTexture, osg::StateAttribute::ON); mWaterGeometry->getStateSet()->setTextureAttributeAndModes(0, waterTexture, osg::StateAttribute::ON);
mWaterNode->addDrawable(mWaterGeometry); mWaterGroup->addChild(mWaterGeometry);
} }
} }

@ -12,7 +12,6 @@
namespace osg namespace osg
{ {
class Geode;
class Geometry; class Geometry;
class Group; class Group;
class PositionAttitudeTransform; class PositionAttitudeTransform;
@ -60,7 +59,7 @@ namespace CSVRender
osg::Group* mParentNode; osg::Group* mParentNode;
osg::ref_ptr<osg::PositionAttitudeTransform> mWaterTransform; osg::ref_ptr<osg::PositionAttitudeTransform> mWaterTransform;
osg::ref_ptr<osg::Geode> mWaterNode; osg::ref_ptr<osg::Group> mWaterGroup;
osg::ref_ptr<osg::Geometry> mWaterGeometry; osg::ref_ptr<osg::Geometry> mWaterGeometry;
bool mDeleted; bool mDeleted;

@ -2,7 +2,6 @@
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <iostream>
#include <osg/Depth> #include <osg/Depth>
#include <osg/Group> #include <osg/Group>
@ -10,17 +9,13 @@
#include <osg/ShapeDrawable> #include <osg/ShapeDrawable>
#include <osg/Shape> #include <osg/Shape>
#include <osg/Geode>
#include <osg/Geometry> #include <osg/Geometry>
#include <osg/PrimitiveSet> #include <osg/PrimitiveSet>
#include <osgFX/Scribe> #include <osgFX/Scribe>
#include "../../model/world/data.hpp" #include "../../model/world/data.hpp"
#include "../../model/world/ref.hpp"
#include "../../model/world/refidcollection.hpp"
#include "../../model/world/commands.hpp" #include "../../model/world/commands.hpp"
#include "../../model/world/universalid.hpp"
#include "../../model/world/commandmacro.hpp" #include "../../model/world/commandmacro.hpp"
#include "../../model/world/cellcoordinates.hpp" #include "../../model/world/cellcoordinates.hpp"
#include "../../model/prefs/state.hpp" #include "../../model/prefs/state.hpp"
@ -43,15 +38,15 @@ const float CSVRender::Object::MarkerHeadLength = 50;
namespace namespace
{ {
osg::ref_ptr<osg::Geode> createErrorCube() osg::ref_ptr<osg::Group> createErrorCube()
{ {
osg::ref_ptr<osg::Box> shape(new osg::Box(osg::Vec3f(0,0,0), 50.f)); osg::ref_ptr<osg::Box> shape(new osg::Box(osg::Vec3f(0,0,0), 50.f));
osg::ref_ptr<osg::ShapeDrawable> shapedrawable(new osg::ShapeDrawable); osg::ref_ptr<osg::ShapeDrawable> shapedrawable(new osg::ShapeDrawable);
shapedrawable->setShape(shape); shapedrawable->setShape(shape);
osg::ref_ptr<osg::Geode> geode (new osg::Geode); osg::ref_ptr<osg::Group> group (new osg::Group);
geode->addDrawable(shapedrawable); group->addChild(shapedrawable);
return geode; return group;
} }
} }
@ -296,10 +291,10 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeMoveOrScaleMarker (int axis)
setupCommonMarkerState(geometry); setupCommonMarkerState(geometry);
osg::ref_ptr<osg::Geode> geode (new osg::Geode); osg::ref_ptr<osg::Group> group (new osg::Group);
geode->addDrawable (geometry); group->addChild(geometry);
return geode; return group;
} }
osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis) osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
@ -382,10 +377,10 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
setupCommonMarkerState(geometry); setupCommonMarkerState(geometry);
osg::ref_ptr<osg::Geode> geode = new osg::Geode(); osg::ref_ptr<osg::Group> group = new osg::Group();
geode->addDrawable (geometry); group->addChild(geometry);
return geode; return group;
} }
void CSVRender::Object::setupCommonMarkerState(osg::ref_ptr<osg::Geometry> geometry) void CSVRender::Object::setupCommonMarkerState(osg::ref_ptr<osg::Geometry> geometry)

@ -20,7 +20,6 @@ namespace osg
class PositionAttitudeTransform; class PositionAttitudeTransform;
class Group; class Group;
class Node; class Node;
class Geode;
} }
namespace osgFX namespace osgFX

@ -3,7 +3,6 @@
#include <algorithm> #include <algorithm>
#include <osg/Array> #include <osg/Array>
#include <osg/Geode>
#include <osg/Geometry> #include <osg/Geometry>
#include <osg/Group> #include <osg/Group>
#include <osg/PositionAttitudeTransform> #include <osg/PositionAttitudeTransform>
@ -11,7 +10,6 @@
#include <components/sceneutil/pathgridutil.hpp> #include <components/sceneutil/pathgridutil.hpp>
#include "../../model/world/cell.hpp"
#include "../../model/world/commands.hpp" #include "../../model/world/commands.hpp"
#include "../../model/world/commandmacro.hpp" #include "../../model/world/commandmacro.hpp"
#include "../../model/world/data.hpp" #include "../../model/world/data.hpp"
@ -77,8 +75,8 @@ namespace CSVRender
mBaseNode->setNodeMask(Mask_Pathgrid); mBaseNode->setNodeMask(Mask_Pathgrid);
mParent->addChild(mBaseNode); mParent->addChild(mBaseNode);
mPathgridGeode = new osg::Geode(); mPathgridGroup = new osg::Group();
mBaseNode->addChild(mPathgridGeode); mBaseNode->addChild(mPathgridGroup);
recreateGeometry(); recreateGeometry();
@ -222,7 +220,7 @@ namespace CSVRender
mUseOffset = false; mUseOffset = false;
mMoveOffset.set(0, 0, 0); mMoveOffset.set(0, 0, 0);
mPathgridGeode->removeDrawable(mDragGeometry); mPathgridGroup->removeChild(mDragGeometry);
mDragGeometry = nullptr; mDragGeometry = nullptr;
} }
@ -524,7 +522,7 @@ namespace CSVRender
removePathgridGeometry(); removePathgridGeometry();
mPathgridGeometry = SceneUtil::createPathgridGeometry(*source); mPathgridGeometry = SceneUtil::createPathgridGeometry(*source);
mPathgridGeode->addDrawable(mPathgridGeometry); mPathgridGroup->addChild(mPathgridGeometry);
createSelectedGeometry(*source); createSelectedGeometry(*source);
} }
@ -553,14 +551,14 @@ namespace CSVRender
removeSelectedGeometry(); removeSelectedGeometry();
mSelectedGeometry = SceneUtil::createPathgridSelectedWireframe(source, mSelected); mSelectedGeometry = SceneUtil::createPathgridSelectedWireframe(source, mSelected);
mPathgridGeode->addDrawable(mSelectedGeometry); mPathgridGroup->addChild(mSelectedGeometry);
} }
void Pathgrid::removePathgridGeometry() void Pathgrid::removePathgridGeometry()
{ {
if (mPathgridGeometry) if (mPathgridGeometry)
{ {
mPathgridGeode->removeDrawable(mPathgridGeometry); mPathgridGroup->removeChild(mPathgridGeometry);
mPathgridGeometry = nullptr; mPathgridGeometry = nullptr;
} }
} }
@ -569,7 +567,7 @@ namespace CSVRender
{ {
if (mSelectedGeometry) if (mSelectedGeometry)
{ {
mPathgridGeode->removeDrawable(mSelectedGeometry); mPathgridGroup->removeChild(mSelectedGeometry);
mSelectedGeometry = nullptr; mSelectedGeometry = nullptr;
} }
} }
@ -577,7 +575,7 @@ namespace CSVRender
void Pathgrid::createDragGeometry(const osg::Vec3f& start, const osg::Vec3f& end, bool valid) void Pathgrid::createDragGeometry(const osg::Vec3f& start, const osg::Vec3f& end, bool valid)
{ {
if (mDragGeometry) if (mDragGeometry)
mPathgridGeode->removeDrawable(mDragGeometry); mPathgridGroup->removeChild(mDragGeometry);
mDragGeometry = new osg::Geometry(); mDragGeometry = new osg::Geometry();
@ -605,7 +603,7 @@ namespace CSVRender
mDragGeometry->addPrimitiveSet(indices); mDragGeometry->addPrimitiveSet(indices);
mDragGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); mDragGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mPathgridGeode->addDrawable(mDragGeometry); mPathgridGroup->addChild(mDragGeometry);
} }
const CSMWorld::Pathgrid* Pathgrid::getPathgridSource() const CSMWorld::Pathgrid* Pathgrid::getPathgridSource()

@ -15,7 +15,6 @@
namespace osg namespace osg
{ {
class Geode;
class Geometry; class Geometry;
class Group; class Group;
class PositionAttitudeTransform; class PositionAttitudeTransform;
@ -107,7 +106,7 @@ namespace CSVRender
osg::Group* mParent; osg::Group* mParent;
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode; osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
osg::ref_ptr<osg::Geode> mPathgridGeode; osg::ref_ptr<osg::Group> mPathgridGroup;
osg::ref_ptr<osg::Geometry> mPathgridGeometry; osg::ref_ptr<osg::Geometry> mPathgridGeometry;
osg::ref_ptr<osg::Geometry> mSelectedGeometry; osg::ref_ptr<osg::Geometry> mSelectedGeometry;
osg::ref_ptr<osg::Geometry> mDragGeometry; osg::ref_ptr<osg::Geometry> mDragGeometry;

@ -9,10 +9,10 @@ namespace Misc
"osg::Group {" "osg::Group {"
" UniqueID 1 " " UniqueID 1 "
" Children 5 {" " Children 5 {"
" osg::Geode {" " osg::Group {"
" UniqueID 2 " " UniqueID 2 "
" Name \"Error\" " " Name \"Error\" "
" Drawables 1 {" " Children 1 {"
" osg::Geometry {" " osg::Geometry {"
" UniqueID 3 " " UniqueID 3 "
" DataVariance STATIC " " DataVariance STATIC "
@ -245,10 +245,10 @@ namespace Misc
" }" " }"
" }" " }"
" }" " }"
" osg::Geode {" " osg::Group {"
" UniqueID 12 " " UniqueID 12 "
" Name \"Error\" " " Name \"Error\" "
" Drawables 1 {" " Children 1 {"
" osg::Geometry {" " osg::Geometry {"
" UniqueID 13 " " UniqueID 13 "
" DataVariance STATIC " " DataVariance STATIC "
@ -476,10 +476,10 @@ namespace Misc
" }" " }"
" }" " }"
" }" " }"
" osg::Geode {" " osg::Group {"
" UniqueID 20 " " UniqueID 20 "
" Name \"Error\" " " Name \"Error\" "
" Drawables 1 {" " Children 1 {"
" osg::Geometry {" " osg::Geometry {"
" UniqueID 21 " " UniqueID 21 "
" DataVariance STATIC " " DataVariance STATIC "
@ -852,10 +852,10 @@ namespace Misc
" }" " }"
" }" " }"
" }" " }"
" osg::Geode {" " osg::Group {"
" UniqueID 30 " " UniqueID 30 "
" Name \"Error\" " " Name \"Error\" "
" Drawables 1 {" " Children 1 {"
" osg::Geometry {" " osg::Geometry {"
" UniqueID 31 " " UniqueID 31 "
" DataVariance STATIC " " DataVariance STATIC "
@ -1221,10 +1221,10 @@ namespace Misc
" }" " }"
" }" " }"
" }" " }"
" osg::Geode {" " osg::Group {"
" UniqueID 38 " " UniqueID 38 "
" Name \"Cube\" " " Name \"Cube\" "
" Drawables 1 {" " Children 1 {"
" osg::Geometry {" " osg::Geometry {"
" UniqueID 39 " " UniqueID 39 "
" DataVariance STATIC " " DataVariance STATIC "

@ -210,7 +210,7 @@ class CollectLowestTransformsVisitor : public BaseOptimizerVisitor
traverse(node); traverse(node);
} }
void apply(osg::Geometry& geode) override void apply(osg::Geometry& geometry) override
{ {
} }
@ -1615,9 +1615,6 @@ bool Optimizer::MergeGeometryVisitor::mergeGroup(osg::Group& group)
} }
// geode.dirtyBound();
return false; return false;
} }

@ -284,10 +284,10 @@ class Optimizer
FlattenStaticTransformsVisitor(Optimizer* optimizer=0): FlattenStaticTransformsVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {} BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {}
void apply(osg::Node& geode) override; void apply(osg::Node& node) override;
void apply(osg::Geometry& drawable) override; void apply(osg::Geometry& geometry) override;
void apply(osg::Drawable& drawable) override; void apply(osg::Drawable& drawable) override;
void apply(osg::Billboard& geode) override; void apply(osg::Billboard& billboard) override;
void apply(osg::Transform& transform) override final; void apply(osg::Transform& transform) override final;
void apply(osg::MatrixTransform& transform) override; void apply(osg::MatrixTransform& transform) override;

@ -65,10 +65,10 @@ osg::ref_ptr<osg::Group> CellBorder::createBorderGeometry(float x, float y, floa
border->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size())); border->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size()));
osg::ref_ptr<osg::Group> borderGeode = new osg::Group; osg::ref_ptr<osg::Group> borderGroup = new osg::Group;
borderGeode->addChild(border.get()); borderGroup->addChild(border.get());
osg::StateSet *stateSet = borderGeode->getOrCreateStateSet(); osg::StateSet *stateSet = borderGroup->getOrCreateStateSet();
osg::ref_ptr<osg::Material> material (new osg::Material); osg::ref_ptr<osg::Material> material (new osg::Material);
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
stateSet->setAttribute(material); stateSet->setAttribute(material);
@ -77,18 +77,18 @@ osg::ref_ptr<osg::Group> CellBorder::createBorderGeometry(float x, float y, floa
polygonmode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE); polygonmode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
stateSet->setAttributeAndModes(polygonmode,osg::StateAttribute::ON); stateSet->setAttributeAndModes(polygonmode,osg::StateAttribute::ON);
sceneManager->recreateShaders(borderGeode, "debug"); sceneManager->recreateShaders(borderGroup, "debug");
borderGeode->setNodeMask(mask); borderGroup->setNodeMask(mask);
return borderGeode; return borderGroup;
} }
void CellBorder::createCellBorderGeometry(int x, int y) void CellBorder::createCellBorderGeometry(int x, int y)
{ {
auto borderGeode = createBorderGeometry(x, y, 1.f, mWorld->getStorage(), mSceneManager, mBorderMask); auto borderGroup = createBorderGeometry(x, y, 1.f, mWorld->getStorage(), mSceneManager, mBorderMask);
mRoot->addChild(borderGeode); mRoot->addChild(borderGroup);
mCellBorderNodes[std::make_pair(x,y)] = borderGeode; mCellBorderNodes[std::make_pair(x,y)] = borderGroup;
} }
void CellBorder::destroyCellBorderGeometry(int x, int y) void CellBorder::destroyCellBorderGeometry(int x, int y)

Loading…
Cancel
Save