Ashwini Jha 5 anni fa
parent
commit
0b2d6861d4

+ 12 - 6
panda/src/navigation/navMesh.cxx

@@ -27,10 +27,16 @@ NavMesh::~NavMesh() {
   _nav_mesh = 0;
 }
 
+/**
+ * NavMesh constructor to store dtNavMesh object as _nav_mesh.
+ */
 NavMesh::NavMesh(dtNavMesh *nav_mesh) {
   _nav_mesh = nav_mesh;
 }
 
+/**
+ * NavMesh constructor to store NavMesh Parameters.
+ */
 NavMesh::NavMesh(NavMeshParams mesh_params):
   _nav_mesh(0) {
   memset(&(_params), 0, sizeof(_params));
@@ -69,6 +75,9 @@ NavMesh::NavMesh(NavMeshParams mesh_params):
   init_nav_mesh();
 }
 
+/**
+ * Function to build navigation mesh from the parameters.
+ */
 bool NavMesh::init_nav_mesh() {
 	unsigned char *nav_data = 0;
   int nav_data_size = 0;
@@ -96,7 +105,9 @@ bool NavMesh::init_nav_mesh() {
   }
 }
 
-
+/**
+ * Function to return geomnode for the navigation mesh.
+ */
 PT(GeomNode) NavMesh::draw_nav_mesh_geom() {
 
   PT(GeomVertexData) vdata;
@@ -178,10 +189,6 @@ PT(GeomNode) NavMesh::draw_nav_mesh_geom() {
   return node;
 }
 
-
-
-
-
 /**
  * Tells the BamReader how to create objects of type NavMesh.
  */
@@ -366,7 +373,6 @@ fillin(DatagramIterator &scan, BamReader *manager) {
   _params.detailTris = detail_tris;
   _params.detailTriCount = detail_tri_count;
 
-
   _params.walkableHeight = walkable_height;
   _params.walkableRadius = walkable_radius;
   _params.walkableClimb = walkable_climb;

+ 3 - 0
panda/src/navigation/navMeshNode.cxx

@@ -17,6 +17,9 @@
 
 TypeHandle NavMeshNode::_type_handle;
 
+/**
+ * NavMeshNode contructor which stores the NavMesh object as _nav_mesh
+ */
 NavMeshNode::NavMeshNode(const std::string &name, PT(NavMesh) nav_mesh):
   PandaNode(name)
 {

+ 16 - 2
panda/src/navigation/navMeshQuery.cxx

@@ -17,13 +17,17 @@
 #include "lvecBase3.h"
 #include <iostream>
 
+/**
+ * NavMeshQuery constructor to initialize member variables. The function set_nav_query()
+ * should be called after this constructor is called.
+ */
 NavMeshQuery::NavMeshQuery():
   _nav_query(0) {
   _nav_query = dtAllocNavMeshQuery();
 }
 
 /**
- * This function forms and initialises query object. No need to call set_nav_query() 
+ * This constructor forms and initialises query object. No need to call set_nav_query() 
  * after calling this constructor.
  */
 NavMeshQuery::NavMeshQuery(PT(NavMesh) nav_mesh):
@@ -33,6 +37,11 @@ NavMeshQuery::NavMeshQuery(PT(NavMesh) nav_mesh):
   set_nav_query(nav_mesh);
 
 }
+
+/**
+ * This constructor forms and initialises query object. No need to call set_nav_query() 
+ * after calling this constructor.
+ */
 NavMeshQuery::NavMeshQuery(NodePath nav_mesh_node_path):
   _nav_query(0) {
   
@@ -48,7 +57,7 @@ NavMeshQuery::~NavMeshQuery() {
 
 /**
  * This function initializes the query object.
- * It must be the first function called after construction, before other functions are used
+ * It must be the first function called after constructor, before other functions are used
  * and can be used multiple times.
  */
 bool NavMeshQuery::set_nav_query(PT(NavMesh) nav_mesh) {
@@ -63,6 +72,11 @@ bool NavMeshQuery::set_nav_query(PT(NavMesh) nav_mesh) {
   return true;
 }
 
+/**
+ * This function initializes the query object.
+ * It must be the first function called after constructor, before other functions are used
+ * and can be used multiple times.
+ */
 bool NavMeshQuery::set_nav_query(NodePath nav_mesh_node_path) {
   NavMeshNode *node = dynamic_cast<NavMeshNode*>(nav_mesh_node_path.node());
   return set_nav_query(node->get_nav_mesh());

+ 44 - 13
panda/src/navmeshgen/navMeshBuilder.cxx

@@ -28,6 +28,10 @@
 
 #include "string_utils.h"
 
+
+/**
+ * NavMeshBuilder contructor which initiates the member variables
+ */
 NavMeshBuilder::NavMeshBuilder() :
   _filter_low_hanging_obstacles(true),
   _filter_ledge_spans(true),
@@ -66,6 +70,9 @@ NavMeshBuilder::~NavMeshBuilder() {
 }
 
 
+/**
+ * Function to add vertex to the vertex array.
+ */
 void NavMeshBuilder::add_vertex(float x, float y, float z, int &cap) {
   if (_vert_count + 1 > cap) {
     cap = !cap ? 8 : cap * 2;
@@ -83,6 +90,9 @@ void NavMeshBuilder::add_vertex(float x, float y, float z, int &cap) {
   _vert_count++;
 }
 
+/**
+ * Function to add triangles to the triangles array.
+ */
 void NavMeshBuilder::add_triangle(int a, int b, int c, int &cap) {
   if (_tri_count + 1 > cap) {
     cap = !cap ? 8 : cap * 2;
@@ -100,6 +110,9 @@ void NavMeshBuilder::add_triangle(int a, int b, int c, int &cap) {
   _tri_count++;
 }
 
+/**
+ * Function to build vertex array and triangles array from a geom.
+ */
 bool NavMeshBuilder::from_geom(PT(Geom) geom) {
   int vcap = 0;
   int tcap = 0;
@@ -109,6 +122,9 @@ bool NavMeshBuilder::from_geom(PT(Geom) geom) {
   return true;
 }
 
+/**
+ * Function to build vertex array and triangles array from a node path.
+ */
 bool NavMeshBuilder::from_node_path(NodePath node) {
   NodePathCollection geom_node_collection = node.find_all_matches("**/+GeomNode");
 
@@ -132,6 +148,9 @@ bool NavMeshBuilder::from_node_path(NodePath node) {
   return true;
 }
 
+/**
+ * Function to find vertices and faces in a geom primitive.
+ */
 void NavMeshBuilder::process_primitive(const GeomPrimitive *orig_prim, const GeomVertexData *vdata, int &tcap) {
 
   GeomVertexReader vertex(vdata, "vertex");
@@ -196,6 +215,9 @@ void NavMeshBuilder::process_primitive(const GeomPrimitive *orig_prim, const Geo
   
 }
 
+/**
+ * Function to find vertices from GeomVertexData.
+ */
 void NavMeshBuilder::process_vertex_data(const GeomVertexData *vdata, int &vcap) {
   GeomVertexReader vertex(vdata, "vertex");
   float x, y, z;
@@ -220,8 +242,9 @@ void NavMeshBuilder::process_vertex_data(const GeomVertexData *vdata, int &vcap)
   return;
 }
 
-
-
+/**
+ * Function to process geom to find primitives.
+ */
 void NavMeshBuilder::process_geom(CPT(Geom) geom, int& vcap, int& tcap) {
 
   CPT(GeomVertexData) vdata = geom->get_vertex_data();
@@ -235,6 +258,9 @@ void NavMeshBuilder::process_geom(CPT(Geom) geom, int& vcap, int& tcap) {
   return;
 }
 
+/**
+ * Function to process geom node to find geoms.
+ */
 void NavMeshBuilder::process_geom_node(GeomNode *geomnode, int &vcap, int &tcap) {
 
 
@@ -249,10 +275,9 @@ void NavMeshBuilder::process_geom_node(GeomNode *geomnode, int &vcap, int &tcap)
   return;
 }
 
-
-
-
-
+/**
+ *
+ */
 void NavMeshBuilder::cleanup()
 {
   delete[] _triareas;
@@ -270,6 +295,9 @@ void NavMeshBuilder::cleanup()
   
 }
 
+/**
+ * Function to set partition type for the navigation mesh.
+ */
 void NavMeshBuilder::set_partition_type(std::string partition) {
   if (downcase(partition) == "watershed") {
     _partition_type = SAMPLE_PARTITION_WATERSHED;
@@ -303,6 +331,9 @@ void NavMeshBuilder::collect_settings(BuildSettings& settings)
   settings.partition_type = _partition_type;
 }
 
+/**
+ * Function to reset common settings to default values.
+ */
 void NavMeshBuilder::reset_common_settings()
 {
   _cell_size = 0.3f;
@@ -324,6 +355,10 @@ void NavMeshBuilder::reset_common_settings()
 static const int NAVMESHSET_MAGIC = 'M' << 24 | 'S' << 16 | 'E' << 8 | 'T'; //'MSET';
 static const int NAVMESHSET_VERSION = 1;
 
+/**
+ * Function to build the navigation mesh from the vertex array, triangles array
+ * and on the basis of the settings such as actor radius, actor height, max climb etc.
+ */
 PT(NavMesh) NavMeshBuilder::build() {
   if (!loaded_geom()) {
 
@@ -608,8 +643,6 @@ PT(NavMesh) NavMeshBuilder::build() {
         _pmesh->flags[i] = SAMPLE_POLYFLAGS_WALK | SAMPLE_POLYFLAGS_DOOR;
       }
     }
-
-    
     
     NavMeshParams mesh_params;
 
@@ -626,7 +659,6 @@ PT(NavMesh) NavMeshBuilder::build() {
     mesh_params.detail_tris = _dmesh->tris;
     mesh_params.detail_tri_count = _dmesh->ntris;
 
-
     mesh_params.walkable_height = _agent_height;
     mesh_params.walkable_radius = _agent_radius;
     mesh_params.walkable_climb = _agent_max_climb;
@@ -642,7 +674,6 @@ PT(NavMesh) NavMeshBuilder::build() {
 
   }
 
-
   _ctx->stopTimer(RC_TIMER_TOTAL);
 
   // Show performance stats.
@@ -650,12 +681,12 @@ PT(NavMesh) NavMeshBuilder::build() {
 
   _total_build_time_ms = _ctx->getAccumulatedTime(RC_TIMER_TOTAL) / 1000.0f;
 
-  
-  
   return _nav_mesh_obj;
 }
 
-
+/**
+ * Function to return geomnode for the navigation mesh.
+ */
 PT(GeomNode) NavMeshBuilder::draw_poly_mesh_geom() {
 
   PT(GeomVertexData) vdata;