From de58c9dff3a014816773a28fbc310d187a8ddf9a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 20 Jul 2022 15:25:37 +0400 Subject: [PATCH] Get rid of obsolete osg::Geode where it is possible --- apps/opencs/view/render/cell.cpp | 1 - apps/opencs/view/render/cell.hpp | 1 - apps/opencs/view/render/cellarrow.cpp | 8 +------- apps/opencs/view/render/cellmarker.cpp | 5 +---- apps/opencs/view/render/cellwater.cpp | 11 +++++------ apps/opencs/view/render/cellwater.hpp | 3 +-- apps/opencs/view/render/object.cpp | 25 ++++++++++--------------- apps/opencs/view/render/object.hpp | 1 - apps/opencs/view/render/pathgrid.cpp | 20 +++++++++----------- apps/opencs/view/render/pathgrid.hpp | 3 +-- components/misc/errorMarker.cpp | 20 ++++++++++---------- components/sceneutil/optimizer.cpp | 5 +---- components/sceneutil/optimizer.hpp | 6 +++--- components/terrain/cellborder.cpp | 18 +++++++++--------- 14 files changed, 51 insertions(+), 76 deletions(-) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 3395e90e11..9ece61a979 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -1,7 +1,6 @@ #include "cell.hpp" #include -#include #include #include diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 5998a4ee62..12f6f0ccdb 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -18,7 +18,6 @@ namespace osg { class Group; class Geometry; - class Geode; } namespace CSMWorld diff --git a/apps/opencs/view/render/cellarrow.cpp b/apps/opencs/view/render/cellarrow.cpp index 776dbf7890..9ad4932698 100644 --- a/apps/opencs/view/render/cellarrow.cpp +++ b/apps/opencs/view/render/cellarrow.cpp @@ -1,14 +1,11 @@ - #include "cellarrow.hpp" #include #include -#include #include #include #include "../../model/prefs/state.hpp" -#include "../../model/prefs/shortcutmanager.hpp" #include @@ -159,10 +156,7 @@ void CSVRender::CellArrow::buildShape() geometry->getOrCreateStateSet()->setMode (GL_LIGHTING, osg::StateAttribute::OFF); - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable (geometry); - - mBaseNode->addChild (geode); + mBaseNode->addChild (geometry); } CSVRender::CellArrow::CellArrow (osg::Group *cellNode, Direction direction, diff --git a/apps/opencs/view/render/cellmarker.cpp b/apps/opencs/view/render/cellmarker.cpp index 3de96ab023..ddd4f4caf3 100644 --- a/apps/opencs/view/render/cellmarker.cpp +++ b/apps/opencs/view/render/cellmarker.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -44,9 +43,7 @@ void CSVRender::CellMarker::buildMarker() markerText->setText(coordinatesText); // Add text to marker node. - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable(markerText); - mMarkerNode->addChild(geode); + mMarkerNode->addChild(markerText); } void CSVRender::CellMarker::positionMarker() diff --git a/apps/opencs/view/render/cellwater.cpp b/apps/opencs/view/render/cellwater.cpp index 9e4dbd9f14..b9391b7697 100644 --- a/apps/opencs/view/render/cellwater.cpp +++ b/apps/opencs/view/render/cellwater.cpp @@ -1,6 +1,5 @@ #include "cellwater.hpp" -#include #include #include #include @@ -28,7 +27,7 @@ namespace CSVRender , mId(id) , mParentNode(cellNode) , mWaterTransform(nullptr) - , mWaterNode(nullptr) + , mWaterGroup(nullptr) , mWaterGeometry(nullptr) , mDeleted(false) , mExterior(false) @@ -41,8 +40,8 @@ namespace CSVRender mWaterTransform->setNodeMask(Mask_Water); mParentNode->addChild(mWaterTransform); - mWaterNode = new osg::Geode(); - mWaterTransform->addChild(mWaterNode); + mWaterGroup = new osg::Group(); + mWaterTransform->addChild(mWaterGroup); int cellIndex = mData.getCells().searchId(mId); if (cellIndex > -1) @@ -136,7 +135,7 @@ namespace CSVRender if (mWaterGeometry) { - mWaterNode->removeDrawable(mWaterGeometry); + mWaterGroup->removeChild(mWaterGeometry); mWaterGeometry = nullptr; } @@ -177,6 +176,6 @@ namespace CSVRender mWaterGeometry->getStateSet()->setTextureAttributeAndModes(0, waterTexture, osg::StateAttribute::ON); - mWaterNode->addDrawable(mWaterGeometry); + mWaterGroup->addChild(mWaterGeometry); } } diff --git a/apps/opencs/view/render/cellwater.hpp b/apps/opencs/view/render/cellwater.hpp index 47e5867071..be1786955b 100644 --- a/apps/opencs/view/render/cellwater.hpp +++ b/apps/opencs/view/render/cellwater.hpp @@ -12,7 +12,6 @@ namespace osg { - class Geode; class Geometry; class Group; class PositionAttitudeTransform; @@ -60,7 +59,7 @@ namespace CSVRender osg::Group* mParentNode; osg::ref_ptr mWaterTransform; - osg::ref_ptr mWaterNode; + osg::ref_ptr mWaterGroup; osg::ref_ptr mWaterGeometry; bool mDeleted; diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 93c348ecc5..6ab24928e6 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -10,17 +9,13 @@ #include #include -#include #include #include #include #include "../../model/world/data.hpp" -#include "../../model/world/ref.hpp" -#include "../../model/world/refidcollection.hpp" #include "../../model/world/commands.hpp" -#include "../../model/world/universalid.hpp" #include "../../model/world/commandmacro.hpp" #include "../../model/world/cellcoordinates.hpp" #include "../../model/prefs/state.hpp" @@ -43,15 +38,15 @@ const float CSVRender::Object::MarkerHeadLength = 50; namespace { - osg::ref_ptr createErrorCube() + osg::ref_ptr createErrorCube() { osg::ref_ptr shape(new osg::Box(osg::Vec3f(0,0,0), 50.f)); osg::ref_ptr shapedrawable(new osg::ShapeDrawable); shapedrawable->setShape(shape); - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable(shapedrawable); - return geode; + osg::ref_ptr group (new osg::Group); + group->addChild(shapedrawable); + return group; } } @@ -296,10 +291,10 @@ osg::ref_ptr CSVRender::Object::makeMoveOrScaleMarker (int axis) setupCommonMarkerState(geometry); - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable (geometry); + osg::ref_ptr group (new osg::Group); + group->addChild(geometry); - return geode; + return group; } osg::ref_ptr CSVRender::Object::makeRotateMarker (int axis) @@ -382,10 +377,10 @@ osg::ref_ptr CSVRender::Object::makeRotateMarker (int axis) setupCommonMarkerState(geometry); - osg::ref_ptr geode = new osg::Geode(); - geode->addDrawable (geometry); + osg::ref_ptr group = new osg::Group(); + group->addChild(geometry); - return geode; + return group; } void CSVRender::Object::setupCommonMarkerState(osg::ref_ptr geometry) diff --git a/apps/opencs/view/render/object.hpp b/apps/opencs/view/render/object.hpp index 56337cf037..6c477b57d8 100644 --- a/apps/opencs/view/render/object.hpp +++ b/apps/opencs/view/render/object.hpp @@ -20,7 +20,6 @@ namespace osg class PositionAttitudeTransform; class Group; class Node; - class Geode; } namespace osgFX diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index 6a52c3f8ac..a45a4b427e 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -11,7 +10,6 @@ #include -#include "../../model/world/cell.hpp" #include "../../model/world/commands.hpp" #include "../../model/world/commandmacro.hpp" #include "../../model/world/data.hpp" @@ -77,8 +75,8 @@ namespace CSVRender mBaseNode->setNodeMask(Mask_Pathgrid); mParent->addChild(mBaseNode); - mPathgridGeode = new osg::Geode(); - mBaseNode->addChild(mPathgridGeode); + mPathgridGroup = new osg::Group(); + mBaseNode->addChild(mPathgridGroup); recreateGeometry(); @@ -222,7 +220,7 @@ namespace CSVRender mUseOffset = false; mMoveOffset.set(0, 0, 0); - mPathgridGeode->removeDrawable(mDragGeometry); + mPathgridGroup->removeChild(mDragGeometry); mDragGeometry = nullptr; } @@ -524,7 +522,7 @@ namespace CSVRender removePathgridGeometry(); mPathgridGeometry = SceneUtil::createPathgridGeometry(*source); - mPathgridGeode->addDrawable(mPathgridGeometry); + mPathgridGroup->addChild(mPathgridGeometry); createSelectedGeometry(*source); } @@ -553,14 +551,14 @@ namespace CSVRender removeSelectedGeometry(); mSelectedGeometry = SceneUtil::createPathgridSelectedWireframe(source, mSelected); - mPathgridGeode->addDrawable(mSelectedGeometry); + mPathgridGroup->addChild(mSelectedGeometry); } void Pathgrid::removePathgridGeometry() { if (mPathgridGeometry) { - mPathgridGeode->removeDrawable(mPathgridGeometry); + mPathgridGroup->removeChild(mPathgridGeometry); mPathgridGeometry = nullptr; } } @@ -569,7 +567,7 @@ namespace CSVRender { if (mSelectedGeometry) { - mPathgridGeode->removeDrawable(mSelectedGeometry); + mPathgridGroup->removeChild(mSelectedGeometry); mSelectedGeometry = nullptr; } } @@ -577,7 +575,7 @@ namespace CSVRender void Pathgrid::createDragGeometry(const osg::Vec3f& start, const osg::Vec3f& end, bool valid) { if (mDragGeometry) - mPathgridGeode->removeDrawable(mDragGeometry); + mPathgridGroup->removeChild(mDragGeometry); mDragGeometry = new osg::Geometry(); @@ -605,7 +603,7 @@ namespace CSVRender mDragGeometry->addPrimitiveSet(indices); mDragGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); - mPathgridGeode->addDrawable(mDragGeometry); + mPathgridGroup->addChild(mDragGeometry); } const CSMWorld::Pathgrid* Pathgrid::getPathgridSource() diff --git a/apps/opencs/view/render/pathgrid.hpp b/apps/opencs/view/render/pathgrid.hpp index fa1b360e78..284b98d0b6 100644 --- a/apps/opencs/view/render/pathgrid.hpp +++ b/apps/opencs/view/render/pathgrid.hpp @@ -15,7 +15,6 @@ namespace osg { - class Geode; class Geometry; class Group; class PositionAttitudeTransform; @@ -107,7 +106,7 @@ namespace CSVRender osg::Group* mParent; osg::ref_ptr mBaseNode; - osg::ref_ptr mPathgridGeode; + osg::ref_ptr mPathgridGroup; osg::ref_ptr mPathgridGeometry; osg::ref_ptr mSelectedGeometry; osg::ref_ptr mDragGeometry; diff --git a/components/misc/errorMarker.cpp b/components/misc/errorMarker.cpp index fd2b0b53ac..9fb2f178ee 100644 --- a/components/misc/errorMarker.cpp +++ b/components/misc/errorMarker.cpp @@ -9,10 +9,10 @@ namespace Misc "osg::Group {" " UniqueID 1 " " Children 5 {" -" osg::Geode {" +" osg::Group {" " UniqueID 2 " " Name \"Error\" " -" Drawables 1 {" +" Children 1 {" " osg::Geometry {" " UniqueID 3 " " DataVariance STATIC " @@ -245,10 +245,10 @@ namespace Misc " }" " }" " }" -" osg::Geode {" +" osg::Group {" " UniqueID 12 " " Name \"Error\" " -" Drawables 1 {" +" Children 1 {" " osg::Geometry {" " UniqueID 13 " " DataVariance STATIC " @@ -476,10 +476,10 @@ namespace Misc " }" " }" " }" -" osg::Geode {" +" osg::Group {" " UniqueID 20 " " Name \"Error\" " -" Drawables 1 {" +" Children 1 {" " osg::Geometry {" " UniqueID 21 " " DataVariance STATIC " @@ -852,10 +852,10 @@ namespace Misc " }" " }" " }" -" osg::Geode {" +" osg::Group {" " UniqueID 30 " " Name \"Error\" " -" Drawables 1 {" +" Children 1 {" " osg::Geometry {" " UniqueID 31 " " DataVariance STATIC " @@ -1221,10 +1221,10 @@ namespace Misc " }" " }" " }" -" osg::Geode {" +" osg::Group {" " UniqueID 38 " " Name \"Cube\" " -" Drawables 1 {" +" Children 1 {" " osg::Geometry {" " UniqueID 39 " " DataVariance STATIC " diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index 1aee434845..9012349804 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -210,7 +210,7 @@ class CollectLowestTransformsVisitor : public BaseOptimizerVisitor 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; } diff --git a/components/sceneutil/optimizer.hpp b/components/sceneutil/optimizer.hpp index 196180f112..946f2e1f55 100644 --- a/components/sceneutil/optimizer.hpp +++ b/components/sceneutil/optimizer.hpp @@ -284,10 +284,10 @@ class Optimizer FlattenStaticTransformsVisitor(Optimizer* optimizer=0): BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {} - void apply(osg::Node& geode) override; - void apply(osg::Geometry& drawable) override; + void apply(osg::Node& node) override; + void apply(osg::Geometry& geometry) 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::MatrixTransform& transform) override; diff --git a/components/terrain/cellborder.cpp b/components/terrain/cellborder.cpp index 342df759a5..fb6593483d 100644 --- a/components/terrain/cellborder.cpp +++ b/components/terrain/cellborder.cpp @@ -65,10 +65,10 @@ osg::ref_ptr CellBorder::createBorderGeometry(float x, float y, floa border->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size())); - osg::ref_ptr borderGeode = new osg::Group; - borderGeode->addChild(border.get()); + osg::ref_ptr borderGroup = new osg::Group; + borderGroup->addChild(border.get()); - osg::StateSet *stateSet = borderGeode->getOrCreateStateSet(); + osg::StateSet *stateSet = borderGroup->getOrCreateStateSet(); osg::ref_ptr material (new osg::Material); material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); stateSet->setAttribute(material); @@ -77,18 +77,18 @@ osg::ref_ptr CellBorder::createBorderGeometry(float x, float y, floa polygonmode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE); stateSet->setAttributeAndModes(polygonmode,osg::StateAttribute::ON); - sceneManager->recreateShaders(borderGeode, "debug"); - borderGeode->setNodeMask(mask); + sceneManager->recreateShaders(borderGroup, "debug"); + borderGroup->setNodeMask(mask); - return borderGeode; + return borderGroup; } void CellBorder::createCellBorderGeometry(int x, int y) { - auto borderGeode = createBorderGeometry(x, y, 1.f, mWorld->getStorage(), mSceneManager, mBorderMask); - mRoot->addChild(borderGeode); + auto borderGroup = createBorderGeometry(x, y, 1.f, mWorld->getStorage(), mSceneManager, mBorderMask); + mRoot->addChild(borderGroup); - mCellBorderNodes[std::make_pair(x,y)] = borderGeode; + mCellBorderNodes[std::make_pair(x,y)] = borderGroup; } void CellBorder::destroyCellBorderGeometry(int x, int y)