2
0
Эх сурвалжийг харах

Now can use nodepath.show() to visualize the navigation mesh

Ashwini Jha 5 жил өмнө
parent
commit
3650363138

+ 1 - 1
panda/src/navigation/navMesh.cxx

@@ -143,7 +143,7 @@ PT(GeomNode) NavMesh::draw_nav_mesh_geom() {
     //vertex.add_data3(x, -z, y); //if origingally model is z-up
     //vertex.add_data3(x, y, z); //if originally model is y-up
     
-    colour.add_data4((float)rand() / RAND_MAX, (float)rand() / RAND_MAX, (float)rand() / RAND_MAX, 1);
+    colour.add_data4(0, 0, 1, 1);
   }
 
   PT(GeomNode) node;

+ 19 - 15
panda/src/navigation/navMeshNode.cxx

@@ -13,6 +13,7 @@
 
 
 #include "navMeshNode.h"
+#include "omniBoundingVolume.h"
 #include <iostream>
 
 TypeHandle NavMeshNode::_type_handle;
@@ -25,6 +26,8 @@ NavMeshNode::NavMeshNode(const std::string &name, PT(NavMesh) nav_mesh):
 {
   _nav_mesh = nav_mesh;
   set_cull_callback();
+  // CollisionNodes are hidden by default.
+  set_overall_hidden(true);
 }
 
 NavMeshNode::NavMeshNode(const std::string &name):
@@ -52,33 +55,34 @@ NavMeshNode::~NavMeshNode() {}
  */
 bool NavMeshNode::
 cull_callback(CullTraverser *trav, CullTraverserData &data) {
-  // Append our collision vizzes to the drawing, even though they're not
+  // Append our navigation mesh vizzes to the drawing, even though they're not
   // actually part of the scene graph.
   PT(PandaNode) node = _nav_mesh->draw_nav_mesh_geom();
+  
   if(node != nullptr) {
   	CullTraverserData next_data(data, node);
   	next_data._state = RenderState::make_empty();
   	trav->traverse(next_data);
   }
-  // Solids::const_iterator si;
-  // for (si = _solids.begin(); si != _solids.end(); ++si) {
-  //   CPT(CollisionSolid) solid = (*si).get_read_pointer();
-  //   PT(PandaNode) node = solid->get_viz(trav, data, false);
-  //   if (node != nullptr) {
-  //     CullTraverserData next_data(data, node);
-
-  //     // We don't want to inherit the render state from above for these guys.
-  //     next_data._state = RenderState::make_empty();
-  //     trav->traverse(next_data);
-  //   }
-  // }
-
-  
 
   // Now carry on to render our child nodes.
   return true;
 }
 
+/**
+ * Called when needed to recompute the node's _internal_bound object.  Nodes
+ * that contain anything of substance should redefine this to do the right
+ * thing.
+ */
+void NavMeshNode::
+compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
+                        int &internal_vertices,
+                        int pipeline_stage,
+                        Thread *current_thread) const {
+  internal_bounds = new OmniBoundingVolume;
+  internal_vertices = 0;
+}
+
 /**
  * Returns true if there is some value to visiting this particular node during
  * the cull traversal for any camera, false otherwise.  This will be used to

+ 4 - 0
panda/src/navigation/navMeshNode.h

@@ -65,6 +65,10 @@ public:
 protected:
   static TypedWritable *make_from_bam(const FactoryParams &params);
   void fillin(DatagramIterator &scan, BamReader *manager);
+  virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
+                                       int &internal_vertices,
+                                       int pipeline_stage,
+                                       Thread *current_thread) const;
 
 };