BVDistRot.h

Go to the documentation of this file.
00001 /* $Id: BVDistRot.h,v 1.4 2002/11/05 14:31:15 anonymous Exp $ */
00002 
00003 #ifndef __BV_DIST_ROT_H
00004 #define __BV_DIST_ROT_H
00005 
00006 #include <esg/geometry/includes.h>
00007 #include <esg/spacesorting/DistRot.h>
00008 
00009 #include <esg/Export>
00010 
00011 /*
00012  * Class for general bounding volumes.
00013  * See DistRot for more details.
00014  */
00015 
00016 namespace esg {
00017 
00018 class OGSCENE_EXPORT BVDistRot : public DistRot {
00019 protected:
00020     Geometry * _pTwin;
00021 
00022 public:
00023     BVDistRot (const Geometry& g,
00024                const Matrix4&  multi,
00025                double          sr = 1.0)
00026         : DistRot(sr)
00027     {
00028         _pTwin = (Geometry*) g.clone(&multi);
00029     }
00030     
00031     virtual ~BVDistRot () { if (_pTwin) delete _pTwin; }
00032     
00033     virtual double distance (Geometry& g /* static geometry   */,
00034                              double    d /* minimal distance  */,
00035                              Vector3*  v /* approx. direction */)
00036     {
00037         if (!_pTwin) return MAXFLOAT;
00038         double dd = g.distance(*_pTwin, v) / _scaleRatio;
00039         return ((dd >= d) ? MAXFLOAT : dd);
00040     }
00041 
00042     /*
00043      * Output separation diraction is valid only for objects that are
00044      * penetrated and represents the approximately shortest way to
00045      * get them separated.
00046      */
00047     virtual bool separation (Geometry& g /* static geometry  */,
00048                              Vector3*  v /* approx. direction */)
00049     {
00050         return ((_pTwin) ? g.separation(*_pTwin, v) : true);
00051     }
00052 };
00053 
00054 }; // namespace
00055 
00056 #endif // __BV_DIST_ROT_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6