Browse Source

add has_normals

David Rose 21 years ago
parent
commit
fb79ed6314

+ 21 - 0
panda/src/egg/eggGroupNode.cxx

@@ -803,6 +803,27 @@ joint_has_primitives() const {
   return false;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggGroupNode::has_normals
+//       Access: Published, Virtual
+//  Description: Returns true if any of the primitives (e.g. polygons)
+//               defined within this group or below have either face
+//               or vertex normals defined, false otherwise.
+////////////////////////////////////////////////////////////////////
+bool EggGroupNode::
+has_normals() const {
+  Children::const_iterator ci;
+  for (ci = _children.begin();
+       ci != _children.end();
+       ++ci) {
+    if ((*ci)->has_normals()) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: EggGroupNode::update_under
 //       Access: Protected, Virtual

+ 1 - 0
panda/src/egg/eggGroupNode.h

@@ -134,6 +134,7 @@ PUBLISHED:
   int remove_invalid_primitives();
   virtual bool has_primitives() const;
   virtual bool joint_has_primitives() const;
+  virtual bool has_normals() const;
 
 protected:
   virtual void update_under(int depth_offset);

+ 12 - 0
panda/src/egg/eggNode.cxx

@@ -346,6 +346,18 @@ joint_has_primitives() const {
   return false;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggNode::has_normals
+//       Access: Published, Virtual
+//  Description: Returns true if any of the primitives (e.g. polygons)
+//               defined within this group or below have either face
+//               or vertex normals defined, false otherwise.
+////////////////////////////////////////////////////////////////////
+bool EggNode::
+has_normals() const {
+  return false;
+}
+
 
 ////////////////////////////////////////////////////////////////////
 //     Function: EggNode::r_transform

+ 1 - 0
panda/src/egg/eggNode.h

@@ -103,6 +103,7 @@ protected:
   virtual void adjust_under();
   virtual bool has_primitives() const;
   virtual bool joint_has_primitives() const;
+  virtual bool has_normals() const;
 
   virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
                            CoordinateSystem to_cs);

+ 23 - 0
panda/src/egg/eggPrimitive.cxx

@@ -356,6 +356,29 @@ joint_has_primitives() const {
   return true;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggPrimitive::has_normals
+//       Access: Published, Virtual
+//  Description: Returns true if any of the primitives (e.g. polygons)
+//               defined within this group or below have either face
+//               or vertex normals defined, false otherwise.
+////////////////////////////////////////////////////////////////////
+bool EggPrimitive::
+has_normals() const {
+  if (has_normal()) {
+    return true;
+  }
+
+  const_iterator vi;
+  for (vi = begin(); vi != end(); ++vi) {
+    if ((*vi)->has_normal()) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 
 ////////////////////////////////////////////////////////////////////
 //     Function: EggPrimitive::erase

+ 1 - 0
panda/src/egg/eggPrimitive.h

@@ -102,6 +102,7 @@ PUBLISHED:
   void remove_nonunique_verts();
   virtual bool has_primitives() const;
   virtual bool joint_has_primitives() const;
+  virtual bool has_normals() const;
 
 
   // The EggPrimitive itself appears to be an STL container of