diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index 732936aa9..ceb39a24b 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -126,10 +127,6 @@ osg::ref_ptr TerrainGrid::buildTerrain (osg::Group* parent, float chu osg::BoundingBox bounds(min, max); geometry->setComputeBoundingBoxCallback(new StaticBoundingBoxCallback(bounds)); - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable(geometry); - - std::vector layerList; std::vector > blendmaps; mStorage->getBlendmaps(chunkSize, chunkCenter, false, blendmaps, layerList); @@ -169,11 +166,20 @@ osg::ref_ptr TerrainGrid::buildTerrain (osg::Group* parent, float chu effect->addCullCallback(new SceneUtil::LightListCallback); transform->addChild(effect); - effect->addChild(geode); + +#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) + osg::Node* toAttach = geometry.get(); +#else + osg::ref_ptr geode (new osg::Geode); + geode->addDrawable(geometry); + osg::Node* toAttach = geode.get(); +#endif + + effect->addChild(toAttach); if (mIncrementalCompileOperation) { - mIncrementalCompileOperation->add(geode); + mIncrementalCompileOperation->add(toAttach); mIncrementalCompileOperation->add(textureCompileDummy); }