added a geom tag, setPreserved, which prevents flattening

This commit is contained in:
Zachary Pavlov 2007-01-08 22:59:05 +00:00
parent 7454d3e33e
commit be02db659d
3 changed files with 61 additions and 1 deletions

View File

@ -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

View File

@ -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 &copy) :
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

View File

@ -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<GeomEntry> > GeomList;
typedef pmap<const InternalName *, int> NameCount;