From fb79ed631482dca26419b52586576def6cab3c93 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 4 May 2004 23:34:11 +0000 Subject: [PATCH] add has_normals --- panda/src/egg/eggGroupNode.cxx | 21 +++++++++++++++++++++ panda/src/egg/eggGroupNode.h | 1 + panda/src/egg/eggNode.cxx | 12 ++++++++++++ panda/src/egg/eggNode.h | 1 + panda/src/egg/eggPrimitive.cxx | 23 +++++++++++++++++++++++ panda/src/egg/eggPrimitive.h | 1 + 6 files changed, 59 insertions(+) diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index f55bc8fc37..b8b8150a7c 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/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 diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index f2479979e5..01e8fd86f1 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/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); diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index 6484bd5233..84aeb2c775 100644 --- a/panda/src/egg/eggNode.cxx +++ b/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 diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index 25d32819f1..bae53e363d 100644 --- a/panda/src/egg/eggNode.h +++ b/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); diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index b62578d629..7cd9534d54 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/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 diff --git a/panda/src/egg/eggPrimitive.h b/panda/src/egg/eggPrimitive.h index d37fe1dade..94bd7ac0d4 100644 --- a/panda/src/egg/eggPrimitive.h +++ b/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