Don't use Geodes

pull/915/head
scrawl 9 years ago
parent 137dde7cf8
commit f898bf493f

@ -4,7 +4,6 @@
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
@ -26,13 +25,8 @@ DebugDrawer::DebugDrawer(osg::ref_ptr<osg::Group> parentNode, btCollisionWorld *
mWorld(world),
mDebugOn(true)
{
mGeode = new osg::Geode;
mParentNode->addChild(mGeode);
mGeode->setNodeMask(Mask_Debug);
createGeometry();
mParentNode->addChild(mGeode);
}
void DebugDrawer::createGeometry()
@ -40,6 +34,7 @@ void DebugDrawer::createGeometry()
if (!mGeometry)
{
mGeometry = new osg::Geometry;
mGeometry->setNodeMask(Mask_Debug);
mVertices = new osg::Vec3Array;
@ -50,7 +45,7 @@ void DebugDrawer::createGeometry()
mGeometry->setDataVariance(osg::Object::DYNAMIC);
mGeometry->addPrimitiveSet(mDrawArrays);
mGeode->addDrawable(mGeometry);
mParentNode->addChild(mGeometry);
}
}
@ -58,7 +53,7 @@ void DebugDrawer::destroyGeometry()
{
if (mGeometry)
{
mGeode->removeDrawable(mGeometry);
mParentNode->removeChild(mGeometry);
mGeometry = NULL;
mVertices = NULL;
mDrawArrays = NULL;
@ -67,7 +62,7 @@ void DebugDrawer::destroyGeometry()
DebugDrawer::~DebugDrawer()
{
mParentNode->removeChild(mGeode);
destroyGeometry();
}
void DebugDrawer::step()

@ -12,7 +12,6 @@ class btCollisionWorld;
namespace osg
{
class Group;
class Geode;
class Geometry;
}
@ -24,7 +23,6 @@ class DebugDrawer : public btIDebugDraw
protected:
osg::ref_ptr<osg::Group> mParentNode;
btCollisionWorld *mWorld;
osg::ref_ptr<osg::Geode> mGeode;
osg::ref_ptr<osg::Geometry> mGeometry;
osg::ref_ptr<osg::Vec3Array> mVertices;
osg::ref_ptr<osg::DrawArrays> mDrawArrays;

@ -6,7 +6,6 @@
#include <osg/Texture2D>
#include <osg/Group>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/Depth>
#include <osgDB/WriteFile>
@ -296,9 +295,7 @@ namespace MWRender
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(geom);
camera->addChild(geode);
camera->addChild(geom);
}
mRoot->addChild(camera);

@ -3,7 +3,6 @@
#include <cmath>
#include <osg/Group>
#include <osg/Geode>
#include <osg/UserDataContainer>
#include <osgParticle/ParticleSystem>

@ -4,7 +4,6 @@
#include <osg/Geometry>
#include <osg/PositionAttitudeTransform>
#include <osg/Geode>
#include <osg/Group>
#include <components/esm/loadstat.hpp>
@ -213,16 +212,12 @@ void Pathgrid::enableCellPathgrid(const MWWorld::CellStore *store)
osg::ref_ptr<osg::PositionAttitudeTransform> cellPathGrid = new osg::PositionAttitudeTransform;
cellPathGrid->setPosition(cellPathGridPos);
osg::ref_ptr<osg::Geode> lineGeode = new osg::Geode;
osg::ref_ptr<osg::Geometry> lines = createPathgridLines(pathgrid);
lineGeode->addDrawable(lines);
osg::ref_ptr<osg::Geode> pointGeode = new osg::Geode;
osg::ref_ptr<osg::Geometry> points = createPathgridPoints(pathgrid);
pointGeode->addDrawable(points);
cellPathGrid->addChild(lineGeode);
cellPathGrid->addChild(pointGeode);
cellPathGrid->addChild(lines);
cellPathGrid->addChild(points);
mPathGridRoot->addChild(cellPathGrid);

@ -3,7 +3,6 @@
#include <iomanip>
#include <osg/PolygonOffset>
#include <osg/Geode>
#include <osg/Texture2D>
#include <osg/Material>
#include <osg/Depth>
@ -85,10 +84,7 @@ namespace MWRender
RippleSimulation::RippleSimulation(osg::Group *parent, Resource::ResourceSystem* resourceSystem, const Fallback::Map* fallback)
: mParent(parent)
{
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
mParticleSystem = new osgParticle::ParticleSystem;
geode->addDrawable(mParticleSystem);
mParticleSystem->setParticleAlignment(osgParticle::ParticleSystem::FIXED);
mParticleSystem->setAlignVectorX(osg::Vec3f(1,0,0));
@ -106,7 +102,7 @@ RippleSimulation::RippleSimulation(osg::Group *parent, Resource::ResourceSystem*
mParticleNode = new osg::PositionAttitudeTransform;
mParticleNode->addChild(updater);
mParticleNode->addChild(geode);
mParticleNode->addChild(mParticleSystem);
mParticleNode->setNodeMask(Mask_Effect);
createWaterRippleStateSet(resourceSystem, fallback, mParticleNode);

@ -5,7 +5,6 @@
#include <osg/ClipPlane>
#include <osg/Fog>
#include <osg/Transform>
#include <osg/Geode>
#include <osg/Depth>
#include <osg/Geometry>
#include <osg/Material>
@ -347,14 +346,6 @@ public:
{
}
void apply(osg::Geode &geode)
{
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
osg::Drawable* drw = geode.getDrawable(i);
apply(*drw);
}
}
void apply(osg::Drawable& drw)
{
osg::Geometry* geom = drw.asGeometry();
@ -438,12 +429,10 @@ class CelestialBody
public:
CelestialBody(osg::Group* parentNode, float scaleFactor, int numUvSets)
{
mGeode = new osg::Geode;
osg::ref_ptr<osg::Geometry> geom = createTexturedQuad(numUvSets);
mGeode->addDrawable(geom);
mGeom = createTexturedQuad(numUvSets);
mTransform = new osg::PositionAttitudeTransform;
mTransform->setScale(osg::Vec3f(450,450,450) * scaleFactor);
mTransform->addChild(mGeode);
mTransform->addChild(mGeom);
parentNode->addChild(mTransform);
}
@ -460,7 +449,7 @@ public:
protected:
static const float mDistance;
osg::ref_ptr<osg::PositionAttitudeTransform> mTransform;
osg::ref_ptr<osg::Geode> mGeode;
osg::ref_ptr<osg::Geometry> mGeom;
};
const float CelestialBody::mDistance = 1000.0f;
@ -479,7 +468,7 @@ public:
sunTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
sunTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
mGeode->getOrCreateStateSet()->setTextureAttributeAndModes(0, sunTex, osg::StateAttribute::ON);
mGeom->getOrCreateStateSet()->setTextureAttributeAndModes(0, sunTex, osg::StateAttribute::ON);
osg::ref_ptr<osg::Group> queryNode (new osg::Group);
// Need to render after the world geometry so we can correctly test for occlusions
@ -553,12 +542,12 @@ private:
// Note the debug geometry setDebugDisplay(true) is always DYNAMIC and that can't be changed, not a big deal.
oqn->getQueryGeometry()->setDataVariance(osg::Object::STATIC);
osg::ref_ptr<osg::Geode> queryGeode = osg::clone(mGeode.get(), osg::CopyOp::DEEP_COPY_ALL);
// Disable writing to the color buffer. We are using this geode for visibility tests only.
osg::ref_ptr<osg::Geometry> queryGeom = osg::clone(mGeom.get(), osg::CopyOp::DEEP_COPY_ALL);
// Disable writing to the color buffer. We are using this geometry for visibility tests only.
osg::ref_ptr<osg::ColorMask> colormask (new osg::ColorMask(0, 0, 0, 0));
queryGeode->getOrCreateStateSet()->setAttributeAndModes(colormask, osg::StateAttribute::ON);
queryGeom->getOrCreateStateSet()->setAttributeAndModes(colormask, osg::StateAttribute::ON);
oqn->addChild(queryGeode);
oqn->addChild(queryGeom);
// Remove the default OFF|PROTECTED setting for texturing. We *want* to enable texturing for alpha testing purposes
oqn->getQueryStateSet()->removeTextureMode(0, GL_TEXTURE_2D);
@ -613,12 +602,10 @@ private:
mTransform->addChild(transform);
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
transform->addChild(geode);
osg::ref_ptr<osg::Geometry> geom = createTexturedQuad();
transform->addChild(geom);
geode->addDrawable(createTexturedQuad());
osg::StateSet* stateset = geode->getOrCreateStateSet();
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
@ -649,11 +636,9 @@ private:
camera->setRenderOrder(osg::Camera::NESTED_RENDER);
camera->setAllowEventFocus(false);
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
osg::ref_ptr<osg::Geometry> geom = osg::createTexturedQuadGeometry(osg::Vec3f(-1,-1,0), osg::Vec3f(2,0,0), osg::Vec3f(0,2,0));
geode->addDrawable(geom);
camera->addChild(geode);
camera->addChild(geom);
osg::StateSet* stateset = geom->getOrCreateStateSet();
@ -940,12 +925,12 @@ public:
setPhase(MoonState::Phase_Full);
setVisible(true);
mGeode->addUpdateCallback(mUpdater);
mGeom->addUpdateCallback(mUpdater);
}
~Moon()
{
mGeode->removeUpdateCallback(mUpdater);
mGeom->removeUpdateCallback(mUpdater);
}
virtual void adjustTransparency(const float ratio)
@ -1380,11 +1365,8 @@ void SkyManager::createRain()
osg::ref_ptr<osgParticle::ParticleSystemUpdater> updater (new osgParticle::ParticleSystemUpdater);
updater->addParticleSystem(mRainParticleSystem);
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
geode->addDrawable(mRainParticleSystem);
mRainNode->addChild(emitter);
mRainNode->addChild(geode);
mRainNode->addChild(mRainParticleSystem);
mRainNode->addChild(updater);
mRainFader = new RainFader;

@ -42,7 +42,7 @@ namespace MWRender
Mask_Scene = (1<<12),
Mask_GUI = (1<<13),
// Set on a Geode
// Set on a ParticleSystem Drawable
Mask_ParticleSystem = (1<<14),
// Set on cameras within the main scene graph

@ -5,7 +5,6 @@
#include <osg/Fog>
#include <osg/Depth>
#include <osg/Group>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Material>
#include <osg/PositionAttitudeTransform>
@ -466,25 +465,22 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem
{
mSimulation.reset(new RippleSimulation(parent, resourceSystem, fallback));
osg::ref_ptr<osg::Geometry> waterGeom = createWaterGeometry(CELL_SIZE*150, 40, 900);
waterGeom->setDrawCallback(new DepthClampCallback);
mWaterGeode = new osg::Geode;
mWaterGeode->addDrawable(waterGeom);
mWaterGeode->setNodeMask(Mask_Water);
mWaterGeom = createWaterGeometry(CELL_SIZE*150, 40, 900);
mWaterGeom->setDrawCallback(new DepthClampCallback);
mWaterGeom->setNodeMask(Mask_Water);
if (ico)
ico->add(mWaterGeode);
ico->add(mWaterGeom);
mWaterNode = new osg::PositionAttitudeTransform;
mWaterNode->addChild(mWaterGeode);
mWaterNode->addChild(mWaterGeom);
mWaterNode->addCullCallback(new FudgeCallback);
// simple water fallback for the local map
osg::ref_ptr<osg::Geode> geode2 (osg::clone(mWaterGeode.get(), osg::CopyOp::DEEP_COPY_NODES));
createSimpleWaterStateSet(geode2, mFallback->getFallbackFloat("Water_Map_Alpha"));
geode2->setNodeMask(Mask_SimpleWater);
mWaterNode->addChild(geode2);
osg::ref_ptr<osg::Geometry> geom2 (osg::clone(mWaterGeom.get(), osg::CopyOp::DEEP_COPY_NODES));
createSimpleWaterStateSet(geom2, mFallback->getFallbackFloat("Water_Map_Alpha"));
geom2->setNodeMask(Mask_SimpleWater);
mWaterNode->addChild(geom2);
mSceneRoot->addChild(mWaterNode);
@ -521,10 +517,10 @@ void Water::updateWaterMaterial()
mParent->addChild(mRefraction);
}
createShaderWaterStateSet(mWaterGeode, mReflection, mRefraction);
createShaderWaterStateSet(mWaterGeom, mReflection, mRefraction);
}
else
createSimpleWaterStateSet(mWaterGeode, mFallback->getFallbackFloat("Water_World_Alpha"));
createSimpleWaterStateSet(mWaterGeom, mFallback->getFallbackFloat("Water_World_Alpha"));
updateVisible();
}

@ -13,7 +13,7 @@ namespace osg
{
class Group;
class PositionAttitudeTransform;
class Geode;
class Geometry;
class Node;
}
@ -53,7 +53,7 @@ namespace MWRender
osg::ref_ptr<osg::Group> mParent;
osg::ref_ptr<osg::Group> mSceneRoot;
osg::ref_ptr<osg::PositionAttitudeTransform> mWaterNode;
osg::ref_ptr<osg::Geode> mWaterGeode;
osg::ref_ptr<osg::Geometry> mWaterGeom;
Resource::ResourceSystem* mResourceSystem;
const Fallback::Map* mFallback;
osg::ref_ptr<osgUtil::IncrementalCompileOperation> mIncrementalCompileOperation;

@ -6,7 +6,6 @@
#include <MyGUI_Timer.h>
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/BlendFunc>
#include <osg/Texture2D>
#include <osg/TexMat>
@ -394,9 +393,6 @@ void RenderManager::initialise()
mDrawable = new Drawable(this);
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(mDrawable.get());
osg::ref_ptr<osg::Camera> camera = new osg::Camera();
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setProjectionResizePolicy(osg::Camera::FIXED);
@ -404,8 +400,8 @@ void RenderManager::initialise()
camera->setViewMatrix(osg::Matrix::identity());
camera->setRenderOrder(osg::Camera::POST_RENDER);
camera->setClearMask(GL_NONE);
geode->setCullingActive(false);
camera->addChild(geode.get());
mDrawable->setCullingActive(false);
camera->addChild(mDrawable.get());
mGuiRoot = camera;
mSceneRoot->addChild(mGuiRoot.get());

@ -2,7 +2,6 @@
#include <osg/Matrixf>
#include <osg/MatrixTransform>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Array>
#include <osg/LOD>

@ -5,7 +5,6 @@
#include <osg/NodeVisitor>
#include <osg/Group>
#include <osg/Geode>
#include <osg/FrontFace>
#include <osg/PositionAttitudeTransform>
#include <osg/MatrixTransform>

@ -3,7 +3,6 @@
#include "statesetupdater.hpp"
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/NodeCallback>
namespace SceneUtil
@ -85,21 +84,6 @@ namespace SceneUtil
traverse(node);
}
void ControllerVisitor::apply(osg::Geode &geode)
{
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
osg::Drawable* drw = geode.getDrawable(i);
osg::Callback* callback = drw->getUpdateCallback();
if (Controller* ctrl = dynamic_cast<Controller*>(callback))
visit(geode, *ctrl);
}
apply(static_cast<osg::Node&>(geode));
}
AssignControllerSourcesVisitor::AssignControllerSourcesVisitor()
: ControllerVisitor()
{

@ -63,7 +63,6 @@ namespace SceneUtil
ControllerVisitor();
virtual void apply(osg::Node& node);
virtual void apply(osg::Geode& geode);
virtual void visit(osg::Node& node, Controller& ctrl) = 0;
};

@ -3,7 +3,6 @@
#include <stdexcept>
#include <osg/NodeVisitor>
#include <osg/Geode>
#include <osgUtil/CullVisitor>

@ -1,7 +1,5 @@
#include "visitor.hpp"
#include <osg/Geode>
#include <osgParticle/ParticleSystem>
#include <components/misc/stringops.hpp>
@ -19,12 +17,6 @@ namespace SceneUtil
traverse(group);
}
void DisableFreezeOnCullVisitor::apply(osg::Geode &geode)
{
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
apply(*geode.getDrawable(i));
}
void DisableFreezeOnCullVisitor::apply(osg::Drawable& drw)
{
if (osgParticle::ParticleSystem* partsys = dynamic_cast<osgParticle::ParticleSystem*>(&drw))

@ -34,7 +34,6 @@ namespace SceneUtil
{
}
virtual void apply(osg::Geode &geode);
virtual void apply(osg::Drawable& drw);
};

@ -17,7 +17,6 @@
#include <components/esm/loadland.hpp>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/KdTree>
#include <osgFX/Effect>

Loading…
Cancel
Save