From: <sv...@ww...> - 2005-11-12 08:54:09
|
Author: mkrose Date: 2005-11-12 00:53:58 -0800 (Sat, 12 Nov 2005) New Revision: 1663 Modified: trunk/CSP/Demeter/DemeterDrawable.cpp trunk/CSP/Demeter/DemeterDrawable.h Log: Fix Demeter to work with OSG 0.9.9. It should still work with 0.9.8 too. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1663 Modified: trunk/CSP/Demeter/DemeterDrawable.cpp =================================================================== --- trunk/CSP/Demeter/DemeterDrawable.cpp 2005-11-09 07:37:43 UTC (rev 1662) +++ trunk/CSP/Demeter/DemeterDrawable.cpp 2005-11-12 08:53:58 UTC (rev 1663) @@ -98,11 +98,9 @@ } } -bool DemeterDrawable::computeBound() const -{ - if (m_RefTerrain.valid()) - { - +#ifdef OSG_OLD_COMPUTE_BOUND +bool DemeterDrawable::computeBound() const { + if (m_RefTerrain.valid()) { float width = m_RefTerrain->GetWidth(); float height = m_RefTerrain->GetHeight(); int latticeX, latticeY; @@ -117,6 +115,24 @@ } return true; } +#else +osg::BoundingBox DemeterDrawable::computeBound() const { + osg::BoundingBox bbox; + if (m_RefTerrain.valid()) { + float width = m_RefTerrain->GetWidth(); + float height = m_RefTerrain->GetHeight(); + int latticeX, latticeY; + m_RefTerrain->GetLatticePosition(latticeX, latticeY); + bbox._min.x() = width*latticeX; + bbox._min.y() = height*latticeY; + bbox._min.z() = 0.0f; + bbox._max.x() = width*(latticeX+1); + bbox._max.y() = height*(latticeY+1); + bbox._max.z() = m_RefTerrain->GetMaxElevation(); + } + return bbox; +} +#endif // DemeterLatticeDrawable @@ -226,6 +242,7 @@ } +#ifdef OSG_OLD_COMPUTE_BOUND bool DemeterLatticeDrawable::computeBound() const { if (m_RefTerrainLattice.valid()) @@ -244,5 +261,17 @@ } return true; } +#else +osg::BoundingBox DemeterLatticeDrawable::computeBound() const { + osg::BoundingBox bbox(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); + if (m_RefTerrainLattice.valid()) { + bbox._min.x() = bbox._min.y() = bbox._min.z() = 0.0f; + bbox._max.x() = 1000000; + bbox._max.y() = 1000000; + bbox._max.z() = 10000; + } + return bbox; +} +#endif }; Modified: trunk/CSP/Demeter/DemeterDrawable.h =================================================================== --- trunk/CSP/Demeter/DemeterDrawable.h 2005-11-09 07:37:43 UTC (rev 1662) +++ trunk/CSP/Demeter/DemeterDrawable.h 2005-11-12 08:53:58 UTC (rev 1663) @@ -24,7 +24,14 @@ #include <osg/Drawable> +#include <osg/Version> +// OSG_VERSION_MAJOR was first defined in 0.9.9. +#ifndef OSG_VERSION_MAJOR +// The interface to Drawable::computeBound changed in 0.9.9. +# define OSG_OLD_COMPUTE_BOUND +#endif + #include "Terrain.h" namespace Demeter @@ -54,7 +61,11 @@ protected: - virtual bool computeBound() const; +#ifdef OSG_OLD_COMPUTE_BOUND + virtual bool computeBound() const; +#else + virtual osg::BoundingBox computeBound() const; +#endif mutable osg::ref_ptr<Terrain> m_RefTerrain; }; @@ -97,7 +108,11 @@ protected: - virtual bool computeBound() const; +#ifdef OSG_OLD_COMPUTE_BOUND + virtual bool computeBound() const; +#else + virtual osg::BoundingBox computeBound() const; +#endif mutable osg::ref_ptr<TerrainLattice> m_RefTerrainLattice; DemeterLatticeDrawableLoadListener * m_pLatticeLoadListener; |