diff --git a/panda/src/pgraph/geomNode.I b/panda/src/pgraph/geomNode.I index c70af9100a..640988b903 100644 --- a/panda/src/pgraph/geomNode.I +++ b/panda/src/pgraph/geomNode.I @@ -28,6 +28,17 @@ get_num_geoms() const { return cdata->get_geoms()->size(); } + +//////////////////////////////////////////////////////////////////// +// Function: GeomNode::get_num_geoms +// Access: Public +// Description: Returns the number of geoms in the node. +//////////////////////////////////////////////////////////////////// +INLINE void GeomNode:: +set_preserved(bool value){ + _preserved = value; +} + //////////////////////////////////////////////////////////////////// // Function: GeomNode::get_geom // Access: Public diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index 097d663f0c..37eb523f84 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -45,6 +45,7 @@ GeomNode(const string &name) : PandaNode(name) { // GeomNodes have a certain set of bits on by default. + _preserved = false; set_into_collide_mask(get_default_collide_mask()); } @@ -56,7 +57,8 @@ GeomNode(const string &name) : GeomNode:: GeomNode(const GeomNode ©) : PandaNode(copy), - _cycler(copy._cycler) + _cycler(copy._cycler), + _preserved(copy._preserved) { } @@ -222,6 +224,46 @@ xform(const LMatrix4f &mat) { transformer.transform_vertices(this, mat); } + +//////////////////////////////////////////////////////////////////// +// Function: GeomNode::safe_to_flatten +// Access: Public, Virtual +// Description: Transforms the contents of this node by the indicated +// matrix, if it means anything to do so. For most +// kinds of nodes, this does nothing. +// +// For a GeomNode, this does the right thing, but it is +// better to use a GeomTransformer instead, since it +// will share the new arrays properly between different +// GeomNodes. +//////////////////////////////////////////////////////////////////// +bool GeomNode:: +safe_to_flatten() const { + if(_preserved) + return false; + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomNode::safe_to_combine +// Access: Public, Virtual +// Description: Transforms the contents of this node by the indicated +// matrix, if it means anything to do so. For most +// kinds of nodes, this does nothing. +// +// For a GeomNode, this does the right thing, but it is +// better to use a GeomTransformer instead, since it +// will share the new arrays properly between different +// GeomNodes. +//////////////////////////////////////////////////////////////////// +bool GeomNode:: +safe_to_combine() const { + if(_preserved) + return false; + return true; +} + + //////////////////////////////////////////////////////////////////// // Function: GeomNode::combine_with // Access: Public, Virtual diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index ec05708c70..ffb91dd2e4 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -57,7 +57,12 @@ public: virtual bool is_renderable() const; virtual CollideMask get_legal_collide_mask() const; + virtual bool safe_to_flatten() const; + virtual bool safe_to_combine() const; + PUBLISHED: + + INLINE void set_preserved(bool value); INLINE int get_num_geoms() const; INLINE const Geom *get_geom(int n) const; INLINE Geom *get_unique_geom(int n); @@ -98,6 +103,8 @@ public: }; private: + + bool _preserved; typedef RefCountObj< pvector > GeomList; typedef pmap NameCount;