]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/bvh/BVHDebugCollectVisitor.hxx
Make the debug geometry stuff work with a time argument.
[simgear.git] / simgear / scene / bvh / BVHDebugCollectVisitor.hxx
index 540ee45f12b4cc28e139ebe5f800787d84402e7e..07834e643df5b5010d23234c60769fc6715bf0d1 100644 (file)
@@ -25,7 +25,6 @@
 #include <osg/PolygonOffset>
 #include <osg/PrimitiveSet>
 #include <osg/MatrixTransform>
-#include <osg/PositionAttitudeTransform>
 #include <osg/ShapeDrawable>
 #include <osg/Shape>
 #include <osg/Depth>
@@ -44,7 +43,6 @@
 #include "BVHStaticData.hxx"
 
 #include "BVHStaticNode.hxx"
-#include "BVHStaticLeaf.hxx"
 #include "BVHStaticTriangle.hxx"
 #include "BVHStaticBinary.hxx"
 
@@ -57,8 +55,9 @@ class BVHStaticNode;
 
 class BVHDebugCollectVisitor : public BVHVisitor {
 public:
-    BVHDebugCollectVisitor(unsigned level = ~0u) :
+    BVHDebugCollectVisitor(const double& time, unsigned level = ~0u) :
         _group(new osg::Group),
+        _time(time),
         _level(level),
         _currentLevel(0)
     {
@@ -101,16 +100,8 @@ public:
     {
         addNodeSphere(node);
         osg::ref_ptr<osg::Group> oldGroup = _group;
-        osg::ref_ptr<osg::PositionAttitudeTransform> transform;
-        transform = new osg::PositionAttitudeTransform;
-        double tt = node.getReferenceTime() - node.getEndTime();
-        tt = 100*tt;
-        tt += node.getReferenceTime();
-//     transform->setPosition(node.getPosition(node.getEndTime()).osg());
-        transform->setPosition(node.getPosition().osg());
-        transform->setAttitude(inverse(node.getOrientation(tt)).osg());
-//     transform->setPosition(node.getPosition().osg());
-//     transform->setAttitude(inverse(node.getOrientation()).osg());
+        osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform;
+        transform->setMatrix(osg::Matrix(node.getToWorldTransform(_time).data()));
         _group = transform;
         ++_currentLevel;
         node.traverse(*this);
@@ -137,10 +128,6 @@ public:
         node.traverse(*this, data);
         --_currentLevel;
     }
-    virtual void apply(const BVHStaticLeaf& node, const BVHStaticData& data)
-    {
-        addNodeBox(node, data);
-    }
     virtual void apply(const BVHStaticTriangle& node, const BVHStaticData& data)
     {
         addNodeBox(node, data);
@@ -213,6 +200,7 @@ private:
     }
     
     osg::ref_ptr<osg::Group> _group;
+    const double _time;
     const unsigned _level;
     unsigned _currentLevel;
 };