diff --git a/src/osg/ShadowVolumeOccluder.cpp b/src/osg/ShadowVolumeOccluder.cpp index 93ea66a26..e330ee18a 100644 --- a/src/osg/ShadowVolumeOccluder.cpp +++ b/src/osg/ShadowVolumeOccluder.cpp @@ -138,6 +138,57 @@ Plane computeFrontPlane(const PointList& front) return Plane(front[2].second,front[1].second,front[0].second); } + +// compute the volume of tetrahedron +inline float computeVolume(const osg::Vec3& a,const osg::Vec3& b,const osg::Vec3& c,const osg::Vec3& d) +{ + return fabs(((b-c)^(a-b))*(d-b)); +} + +// compute the volume of prism. +inline float computeVolume(const osg::Vec3& f1,const osg::Vec3& f2,const osg::Vec3& f3, + const osg::Vec3& b1,const osg::Vec3& b2,const osg::Vec3& b3) +{ + return computeVolume(f1,f2,f3,b1)+ + computeVolume(b1,b2,b3,f2)+ + computeVolume(b1,b3,f2,f3); +} + +// compute the volume between the front and back polygons of the occluder/hole. +float computeVolume(const PointList& front, const PointList& back) +{ + float volume = 0.0f; + Vec3 frontStart = front[0].second; + Vec3 backStart = back[0].second; + for(unsigned int i=1;i(nodePath.back()); @@ -330,6 +390,7 @@ bool ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const Convex } + std::cout << "final volume = "<<_volume<