*** empty log message ***

This commit is contained in:
David Rose 2001-03-02 00:14:22 +00:00
parent 585fd87124
commit 1faecc8269
23 changed files with 474 additions and 157 deletions

View File

@ -98,6 +98,7 @@ install-bam : $[install_bam_targets]
install-other : $[install_other_targets]
install : install-other install-bam
uninstall : uninstall-other uninstall-bam uninstall-egg
clean-bam :
#if $[bam_targets]
@ -284,6 +285,15 @@ $[dest]/$[local] : $[source_prefix]$[local]
#end egg
#end install_egg
// Egg file uninstallation.
uninstall-egg :
#forscopes install_egg
#define files $[patsubst %,$[install_model_dir]/%,$[SOURCES] $[UNPAL_SOURCES]]
#if $[files]
rm -f $[files]
#endif
#end install_egg
// Bam file installation.
#forscopes install_egg
@ -299,6 +309,16 @@ $[dest]/$[local] : $[sourcedir]/$[local]
#end egg
#end install_egg
// Bam file uninstallation.
uninstall-bam :
#forscopes install_egg
#define files $[patsubst %.egg,$[install_model_dir]/%.bam,$[SOURCES] $[UNPAL_SOURCES]]
#if $[files]
rm -f $[files]
#endif
#end install_egg
// Miscellaneous file installation.
#forscopes install_audio install_dna install_icons install_misc
@ -313,6 +333,16 @@ $[dest]/$[local] : $[local]
#end file
#end install_audio install_dna install_icons install_misc
// Miscellaneous file uninstallation.
uninstall-other:
#forscopes install_audio install_dna install_icons install_misc
#define files $[patsubst %,$[install_model_dir]/%,$[SOURCES]]
#if $[files]
rm -f $[files]
#endif
#end install_audio install_dna install_icons install_misc
#end Makefile
@ -363,6 +393,9 @@ install-egg : egg pal repal $[subdirs:%=install-egg-%]
install-bam : egg pal repal $[subdirs:%=install-bam-%]
install-other : $[subdirs:%=install-other-%]
install : egg pal repal $[subdirs:%=install-%]
uninstall-egg : $[subdirs:%=uninstall-egg-%]
uninstall-bam : $[subdirs:%=uninstall-bam-%]
uninstall-other : $[subdirs:%=uninstall-other-%]
uninstall : $[subdirs:%=uninstall-%]
#
@ -472,6 +505,21 @@ install-$[dirname] :
cd ./$[PATH] && $(MAKE) install
#end dirname
#formap dirname subdirs
uninstall-egg-$[dirname] :
cd ./$[PATH] && $(MAKE) uninstall-egg
#end dirname
#formap dirname subdirs
uninstall-bam-$[dirname] :
cd ./$[PATH] && $(MAKE) uninstall-bam
#end dirname
#formap dirname subdirs
uninstall-other-$[dirname] :
cd ./$[PATH] && $(MAKE) uninstall-other
#end dirname
#formap dirname subdirs
uninstall-$[dirname] :
cd ./$[PATH] && $(MAKE) uninstall

View File

@ -510,6 +510,10 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &,
}
node->draw_traverse();
// We have to get a new _now timestamp, just in case either of the
// above traversals changed it.
_now = last_graph_update(_graph_type);
AllTransitionsWrapper trans;
UpdateSeq last_update = arc->get_last_update();

View File

@ -168,7 +168,7 @@ get_vertex_frame_inv() const {
// Function: EggNode::get_node_frame_inv
// Access: Public
// Description: Returns the inverse of the matrix returned by
// get_vertex_frame(). See get_vertex_frame().
// get_node_frame(). See get_node_frame().
////////////////////////////////////////////////////////////////////
INLINE const LMatrix4d &EggNode::
get_node_frame_inv() const {

View File

@ -342,18 +342,37 @@ determine_primitive_home(EggPrimitive *egg_primitive) {
nassertr(home != NULL, NULL);
// So, all the vertices are assigned to the same group. This means
// the polygon belongs entirely to one joint. If that joint happens
// to have a <DCS> flag, and will therefore be an explicit animated
// node, we might as well put the polygon under that joint.
// Otherwise, we'll leave the polygon under the character node and
// animate it there explicitly.
// the polygon belongs entirely to one joint.
// If the group is not, in fact, a joint then we return the first
// joint above the group.
EggGroup *egg_group = (EggGroup *)NULL;
if (home->is_of_type(EggGroup::get_class_type())) {
EggGroup *egg_group = DCAST(EggGroup, home);
if (egg_group->get_dcs_flag()) {
return home;
egg_group = DCAST(EggGroup, home);
}
while (egg_group != (EggGroup *)NULL &&
egg_group->get_group_type() != EggGroup::GT_joint &&
egg_group->get_dart_type() == EggGroup::DT_none) {
nassertr(egg_group->get_parent() != (EggGroupNode *)NULL, NULL);
home = egg_group->get_parent();
egg_group = (EggGroup *)NULL;
if (home->is_of_type(EggGroup::get_class_type())) {
egg_group = DCAST(EggGroup, home);
}
}
if (egg_group != (EggGroup *)NULL &&
egg_group->get_group_type() == EggGroup::GT_joint &&
!egg_group->get_dcs_flag()) {
// If the home is a joint without a <DCS> flag--this is the normal
// case--we'll move the polygon under the character node and
// animate it from there explicitly.
return NULL;
}
// Otherwise, if the joint *does* have a <DCS> flag, we'll create
// static geometry that we parent directly to the joint node.
// We'll also create static geometry for polygons that have no
// explicit joint assignment.
return home;
}

View File

@ -10,6 +10,8 @@
#include <character.h>
#include <computedVertices.h>
#include <eggNode.h>
#include <eggGroup.h>
#include <eggVertex.h>
#include <algorithm>
@ -67,6 +69,53 @@ add_joint(EggNode *joint, double membership) {
}
}
////////////////////////////////////////////////////////////////////
// Function: ComputedVerticesMaker::add_vertex_joints
// Access: Public
// Description: Adds the joints the vertex belongs to, along with
// their respective memberships, to the current
// transform space definition.
////////////////////////////////////////////////////////////////////
void ComputedVerticesMaker::
add_vertex_joints(EggVertex *vertex, EggNode *object) {
if (vertex->gref_size() == 0) {
// This vertex belongs in the same group as the primitive that
// contains it.
EggGroupNode *egg_joint = object->get_parent();
// We actually walk up to find the first group above that that's a
// joint, or the character root itself, so we won't (a) be fooled
// by meaningless transforms on non-joints within a character
// hierarchy, or (b) consider meaninglessly different groups to be
// significant.
EggGroup *egg_group = (EggGroup *)NULL;
if (egg_joint->is_of_type(EggGroup::get_class_type())) {
egg_group = DCAST(EggGroup, egg_joint);
}
while (egg_group != (EggGroup *)NULL &&
egg_group->get_group_type() != EggGroup::GT_joint &&
egg_group->get_dart_type() == EggGroup::DT_none) {
nassertv(egg_group->get_parent() != (EggGroupNode *)NULL);
egg_joint = egg_group->get_parent();
egg_group = (EggGroup *)NULL;
if (egg_joint->is_of_type(EggGroup::get_class_type())) {
egg_group = DCAST(EggGroup, egg_joint);
}
}
add_joint(egg_joint, 1.0);
} else {
// This vertex belongs in the joint or joints that reference it.
EggVertex::GroupRef::const_iterator gri;
for (gri = vertex->gref_begin(); gri != vertex->gref_end(); ++gri) {
EggGroup *egg_joint = (*gri);
double membership = egg_joint->get_vertex_membership(vertex);
add_joint(egg_joint, membership);
}
}
}
////////////////////////////////////////////////////////////////////
// Function: ComputedVerticesMaker::mark_space

View File

@ -26,10 +26,26 @@
class ComputedVertices;
class CharacterMaker;
class EggNode;
class EggVertex;
///////////////////////////////////////////////////////////////////
// Class : ComputedVerticesMaker
// Description :
// Description : An object to collect together all the vertices of a
// character, indicate what the transform space of each
// vertex is (which may be a soft-skinned combination of
// one or more joints), and identify which vertices may
// be shared together.
//
// Generally, you use a ComputedVerticesMaker by first
// defining a transform space via begin_new_space(),
// repeated calls to add_joint() (or
// add_vertex_joints()), and then mark_space(). Having
// done that, you can then add any number of vertices to
// the space via add_vertex(), add_normal(), etc., and
// it will return an index number for each vertex,
// collapsing duplicate vertices together properly.
// When you are ready to define a new space, simply
// repeat the process from begin_new_space().
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAEGG ComputedVerticesMaker {
public:
@ -37,6 +53,7 @@ public:
void begin_new_space();
void add_joint(EggNode *joint, double membership);
void add_vertex_joints(EggVertex *vertex, EggNode *object);
void mark_space();
int add_vertex(const Vertexd &vertex, const EggMorphVertexList &morphs,

View File

@ -266,10 +266,12 @@ make_nonindexed_primitive(EggPrimitive *egg_prim, NamedNode *parent,
BuilderBucket bucket;
setup_bucket(bucket, parent, egg_prim);
LMatrix4d mat = egg_prim->get_vertex_to_node();
LMatrix4d mat;
if (transform != NULL) {
mat = (*transform) * mat;
mat = (*transform);
} else {
mat = egg_prim->get_vertex_to_node();
}
BuilderPrim bprim;
@ -340,10 +342,12 @@ make_indexed_primitive(EggPrimitive *egg_prim, NamedNode *parent,
bucket.set_texcoords(_comp_verts_maker._texcoords);
bucket.set_colors(_comp_verts_maker._colors);
LMatrix4d mat = egg_prim->get_vertex_to_node();
LMatrix4d mat;
if (transform != NULL) {
mat = (*transform) * mat;
mat = (*transform);
} else {
mat = egg_prim->get_vertex_to_node();
}
BuilderPrimI bprim;
@ -359,12 +363,7 @@ make_indexed_primitive(EggPrimitive *egg_prim, NamedNode *parent,
EggPrimitive::const_iterator vi;
for (vi = egg_prim->begin(); vi != egg_prim->end(); ++vi) {
EggVertex *egg_vert = *vi;
EggVertex::GroupRef::const_iterator gri;
for (gri = egg_vert->gref_begin(); gri != egg_vert->gref_end(); ++gri) {
EggGroup *egg_joint = (*gri);
double membership = egg_joint->get_vertex_membership(egg_vert);
_comp_verts_maker.add_joint(egg_joint, membership);
}
_comp_verts_maker.add_vertex_joints(egg_vert, egg_prim);
}
_comp_verts_maker.mark_space();
@ -390,20 +389,7 @@ make_indexed_primitive(EggPrimitive *egg_prim, NamedNode *parent,
// Set up the ComputedVerticesMaker for the coordinate space of
// the vertex.
_comp_verts_maker.begin_new_space();
if (egg_vert->gref_size() == 0) {
// This vertex belongs where the primitive is.
EggGroupNode *egg_joint = egg_prim->get_parent();
_comp_verts_maker.add_joint(egg_joint, 1.0);
} else {
// This vertex belongs in the joint or joints that reference it.
EggVertex::GroupRef::const_iterator gri;
for (gri = egg_vert->gref_begin(); gri != egg_vert->gref_end(); ++gri) {
EggGroup *egg_joint = (*gri);
double membership = egg_joint->get_vertex_membership(egg_vert);
_comp_verts_maker.add_joint(egg_joint, membership);
}
}
_comp_verts_maker.add_vertex_joints(egg_vert, egg_prim);
_comp_verts_maker.mark_space();
int vindex =

View File

@ -3,6 +3,172 @@
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: Geom::get_binding
// Access: Published
// Description: Returns the GeomBindType which indicates the
// assignment of colors (or normals, etc.) to the
// primitives.
////////////////////////////////////////////////////////////////////
INLINE GeomBindType Geom::
get_binding(int attr) const {
return _bind[attr];
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_coords_array
// Access: Published
// Description: Returns the array of vertex coordinates associated
// with the Geom. This must have binding type
// G_PER_VERTEX. It may either be indexed or
// nonindexed, depending on whether get_coords_index()
// returns a NULL array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_Vertexf &Geom::
get_coords_array() const {
return _coords;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_normals_array
// Access: Published
// Description: Returns the array of normals associated with the
// Geom. This may have any binding type. It may either
// be indexed or nonindexed, depending on whether
// get_normals_index() returns a NULL array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_Normalf &Geom::
get_normals_array() const {
return _norms;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_colors_array
// Access: Published
// Description: Returns the array of colors associated with the
// Geom. This may have any binding type. It may either
// be indexed or nonindexed, depending on whether
// get_colors_index() returns a NULL array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_Colorf &Geom::
get_colors_array() const {
return _colors;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_texcoords_array
// Access: Published
// Description: Returns the array of texcoords associated with the
// Geom. This may have a binding type of G_PER_VERTEX
// or G_OFF. It may either be indexed or nonindexed,
// depending on whether get_texcoords_index() returns a
// NULL array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_TexCoordf &Geom::
get_texcoords_array() const {
return _texcoords;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_coords_index
// Access: Published
// Description: Returns the array of indices that, if nonempty, will
// be used to traverse the vertices in coords_array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_ushort &Geom::
get_coords_index() const {
return _vindex;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_normals_index
// Access: Published
// Description: Returns the array of indices that, if nonempty, will
// be used to traverse the vertices in normals_array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_ushort &Geom::
get_normals_index() const {
return _nindex;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_colors_index
// Access: Published
// Description: Returns the array of indices that, if nonempty, will
// be used to traverse the vertices in colors_array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_ushort &Geom::
get_colors_index() const {
return _cindex;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_texcoords_index
// Access: Published
// Description: Returns the array of indices that, if nonempty, will
// be used to traverse the vertices in texcoords_array.
////////////////////////////////////////////////////////////////////
INLINE const PTA_ushort &Geom::
get_texcoords_index() const {
return _tindex;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::set_num_prims
// Access: Public
// Description: Sets the number of primitives in the Geom. The
// meaning of this depends on the precise type of Geom;
// generally, each prim is one triangle in a GeomTri, or
// one tristrip in a GeomTristrip.
////////////////////////////////////////////////////////////////////
INLINE void Geom::
set_num_prims(int num) {
_numprims = num;
make_dirty();
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_num_prims
// Access: Public
// Description: Returns the number of primitives in the Geom.
////////////////////////////////////////////////////////////////////
INLINE int Geom::
get_num_prims(void) const {
return _numprims;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::set_lengths
// Access: Public
// Description: Sets the array that indicates the length (number of
// vertices) of each primitive. This array should have
// get_num_prims() entries. This only has meaning for
// composite type Geoms, like a GeomTristrip; it is
// ignored for simple Geoms, like a GeomTri.
////////////////////////////////////////////////////////////////////
INLINE void Geom::
set_lengths(const PTA_int &lengths) {
_primlengths = lengths;
make_dirty();
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_lengths
// Access: Public
// Description: Returns the array the indicates the length (number of
// vertices) of each primitive. This array will
// generally only be defined for composite type Geoms,
// like a GeomTristrip; it is meaningless for simple
// Geoms.
////////////////////////////////////////////////////////////////////
INLINE PTA_int Geom::
get_lengths() const {
return _primlengths;
}
////////////////////////////////////////////////////////////////////
//
// make_vertex_iterator(), get_next_vertex()
@ -33,8 +199,7 @@
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE Geom::
VertexIterator Geom::
INLINE Geom::VertexIterator Geom::
make_vertex_iterator() const {
check_config();
VertexIterator i;

View File

@ -306,27 +306,6 @@ get_texcoords(PTA_TexCoordf &texcoords, GeomBindType &bind,
tindex = _tindex;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::set_lengths
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void Geom::
set_lengths(const PTA_int &lengths) {
_primlengths = lengths;
make_dirty();
}
////////////////////////////////////////////////////////////////////
// Function: Geom::get_lengths
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
PTA_int Geom::
get_lengths() const {
return _primlengths;
}
////////////////////////////////////////////////////////////////////
// Function: Geom::explode
// Access: Public, Virtual
@ -424,23 +403,15 @@ write(ostream &out, int indent_level) const {
////////////////////////////////////////////////////////////////////
void Geom::
output(ostream &out) const {
out << get_type() << " (" << _numprims << ") ";
out << "v:";
if ( _coords != (Vertexf*)0L ) out << "1 "; else out << "0 ";
out << "n:";
if ( _norms != (Normalf*)0L ) out << "1 "; else out << "0 ";
out << "c:";
if ( _colors != (Colorf*)0L ) out << "1 "; else out << "0 ";
out << "t:";
if ( _texcoords != (TexCoordf*)0L ) out << "1 "; else out << "0 ";
out << "vi:";
if ( _vindex != (ushort*)0L ) out << "1 "; else out << "0 ";
out << "ni:";
if ( _nindex != (ushort*)0L ) out << "1 "; else out << "0 ";
out << "ci:";
if ( _cindex != (ushort*)0L ) out << "1 "; else out << "0 ";
out << "ti:";
if ( _tindex != (ushort*)0L ) out << "1 "; else out << "0 ";
out << get_type() << " (" << _numprims << ")"
<< " v:" << _coords.size()
<< " n:" << _norms.size()
<< " c:" << _colors.size()
<< " t:" << _texcoords.size()
<< " vi:" << _vindex.size()
<< " ni:" << _nindex.size()
<< " ci:" << _cindex.size()
<< " ti:" << _tindex.size();
}
////////////////////////////////////////////////////////////////////

View File

@ -33,6 +33,7 @@ class BamWriter;
////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////
BEGIN_PUBLISH
enum GeomBindType
{
G_OFF,
@ -41,6 +42,7 @@ enum GeomBindType
G_PER_COMPONENT,
G_PER_VERTEX
};
END_PUBLISH
static const int num_GeomBindTypes = 5;
enum GeomAttrType
@ -127,9 +129,6 @@ public:
void get_min_max( Vertexf& min, Vertexf& max ) const;
GeomBindType get_binding( int attr ) const {
return _bind[attr];
}
void set_coords( const PTA_Vertexf &coords,
GeomBindType bind,
@ -161,11 +160,23 @@ public:
GeomBindType &bind,
PTA_ushort &tindex) const;
INLINE void set_num_prims(int num) { _numprims = num; make_dirty(); }
INLINE int get_num_prims(void) const { return _numprims; }
PUBLISHED:
INLINE GeomBindType get_binding(int attr) const;
INLINE const PTA_Vertexf &get_coords_array() const;
INLINE const PTA_Normalf &get_normals_array() const;
INLINE const PTA_Colorf &get_colors_array() const;
INLINE const PTA_TexCoordf &get_texcoords_array() const;
INLINE const PTA_ushort &get_coords_index() const;
INLINE const PTA_ushort &get_normals_index() const;
INLINE const PTA_ushort &get_colors_index() const;
INLINE const PTA_ushort &get_texcoords_index() const;
void set_lengths( const PTA_int &lengths );
PTA_int get_lengths() const;
public:
INLINE void set_num_prims(int num);
INLINE int get_num_prims(void) const;
INLINE void set_lengths(const PTA_int &lengths);
INLINE PTA_int get_lengths() const;
virtual int get_num_vertices_per_prim() const=0;
virtual int get_num_more_vertices_than_components() const=0;

View File

@ -53,10 +53,11 @@ public:
protected:
void fillin(DatagramIterator& scan, BamReader* manager);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomLine",

View File

@ -52,10 +52,11 @@ public:
protected:
void fillin(DatagramIterator& scan, BamReader* manager);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomLinestrip",

View File

@ -53,10 +53,11 @@ public:
protected:
void fillin(DatagramIterator& scan, BamReader* manager);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomPoint",

View File

@ -41,10 +41,11 @@ public:
static void register_with_read_factory(void);
static TypedWriteable *make_GeomPolygon(const FactoryParams &params);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomPolygon",

View File

@ -39,10 +39,11 @@ public:
static void register_with_read_factory(void);
static TypedWriteable *make_GeomQuad(const FactoryParams &params);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomQuad",

View File

@ -54,10 +54,11 @@ public:
static TypedWriteable *make_GeomSphere(const FactoryParams &params);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomSphere",

View File

@ -73,10 +73,11 @@ public:
protected:
void fillin(DatagramIterator &scan, BamReader *manager);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomSprite",

View File

@ -39,10 +39,11 @@ public:
static void register_with_read_factory(void);
static TypedWriteable *make_GeomTri(const FactoryParams &params);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomTri",

View File

@ -42,10 +42,11 @@ public:
static void register_with_read_factory(void);
static TypedWriteable *make_GeomTrifan(const FactoryParams &params);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomTrifan",

View File

@ -41,10 +41,11 @@ public:
static void register_with_read_factory(void);
static TypedWriteable *make_GeomTristrip(const FactoryParams &params);
public:
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;
}
public:
static void init_type() {
Geom::init_type();
register_type(_type_handle, "GeomTristrip",

View File

@ -73,3 +73,13 @@ forcetype LOrientationf
forcetype LQuaterniond
forcetype LRotationd
forcetype LOrientationd
forcetype PTA_Vertexf
forcetype PTA_Normalf
forcetype PTA_TexCoordf
forcetype PTA_Colorf
renametype PTA_Vertexf PTA_Vertexf
renametype PTA_Normalf PTA_Normalf
renametype PTA_TexCoordf PTA_TexCoordf
renametype PTA_Colorf PTA_Colorf

View File

@ -11,7 +11,7 @@ vector<Element> ConstPointerToArray<Element>::_empty_array;
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::Constructor
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
@ -23,7 +23,7 @@ PointerToArray() :
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::Constructor
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
@ -36,7 +36,7 @@ PointerToArray(size_type n) :
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::Constructor
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
@ -49,7 +49,7 @@ PointerToArray(size_type n, const Element &value) :
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::Copy Constructor
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
@ -117,7 +117,7 @@ rend() const {
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::size
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
@ -177,26 +177,6 @@ capacity() const {
return _ptr->capacity();
}
#ifndef WIN32_VC
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::Indexing operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
INLINE PointerToArray<Element>::reference PointerToArray<Element>::
operator[](size_type n) const {
nassertd(_ptr != NULL) {
((PointerToArray<Element> *)this)->reassign(new RefCountObj<vector<Element> >);
}
nassertd(!_ptr->empty()) {
_ptr->push_back(Element());
}
nassertr(n < _ptr->size(), _ptr->operator[](0));
return _ptr->operator[](n);
}
#endif
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::front
// Access: Public
@ -231,20 +211,6 @@ back() const {
return _ptr->back();
}
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::push_back
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
INLINE void PointerToArray<Element>::
push_back(const Element &x) {
if (_ptr == NULL) {
reassign(new RefCountObj<vector<Element> >);
}
_ptr->push_back(x);
}
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::insert
// Access: Public
@ -318,21 +284,6 @@ insert(iterator position, const Element *first, const Element *last) const {
}
#endif
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::pop_back
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
INLINE void PointerToArray<Element>::
pop_back() const {
nassertd(_ptr != NULL) {
((PointerToArray<Element> *)this)->reassign(new RefCountObj<vector<Element> >);
}
nassertv(!_ptr->empty());
_ptr->pop_back();
}
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::erase
// Access: Public
@ -365,6 +316,72 @@ erase(iterator first, iterator last) const {
_ptr->erase(first, last);
}
#if !defined(WIN32_VC) || defined(CPPPARSER)
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::Indexing operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
INLINE PointerToArray<Element>::reference PointerToArray<Element>::
operator [](size_type n) const {
nassertd(_ptr != NULL) {
((PointerToArray<Element> *)this)->reassign(new RefCountObj<vector<Element> >);
}
nassertd(!_ptr->empty()) {
_ptr->push_back(Element());
}
nassertr(n < _ptr->size(), _ptr->operator[](0));
return _ptr->operator[](n);
}
#endif
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::push_back
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
INLINE void PointerToArray<Element>::
push_back(const Element &x) {
if (_ptr == NULL) {
reassign(new RefCountObj<vector<Element> >);
}
_ptr->push_back(x);
}
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::pop_back
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
template<class Element>
INLINE void PointerToArray<Element>::
pop_back() {
nassertd(_ptr != NULL) {
((PointerToArray<Element> *)this)->reassign(new RefCountObj<vector<Element> >);
}
nassertv(!_ptr->empty());
_ptr->pop_back();
}
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::make_empty
// Access: Published
// Description: Empties the array pointed to. This is different from
// clear(), which reassigns the pointer to a NULL
// pointer.
////////////////////////////////////////////////////////////////////
template<class Element>
INLINE void PointerToArray<Element>::
make_empty() {
nassertd(_ptr != NULL) {
((PointerToArray<Element> *)this)->reassign(new RefCountObj<vector<Element> >);
}
nassertv(!_ptr->empty());
_ptr->clear();
}
////////////////////////////////////////////////////////////////////
// Function: PointerToArray::Typecast operator
// Access: Public

View File

@ -83,11 +83,13 @@ public:
typedef vector<Element>::difference_type difference_type;
typedef vector<Element>::size_type size_type;
PUBLISHED:
INLINE PointerToArray();
INLINE PointerToArray(size_type n);
INLINE PointerToArray(size_type n, const Element &value);
INLINE PointerToArray(const PointerToArray<Element> &copy);
public:
// Duplicating the interface of vector. The following member
// functions are all const, because they do not reassign the
// pointer--they operate only within the vector itself, which is
@ -101,19 +103,18 @@ public:
// Equality and comparison operators are pointerwise for
// PointerToArrays, not elementwise as in vector.
PUBLISHED:
INLINE size_type size() const;
public:
INLINE size_type max_size() const;
INLINE bool empty() const;
// Functions specific to vectors.
INLINE void reserve(size_type n);
INLINE size_type capacity() const;
#ifndef WIN32_VC
INLINE reference operator[](size_type n) const;
#endif
INLINE reference front() const;
INLINE reference back() const;
INLINE void push_back(const Element &x);
INLINE iterator insert(iterator position) const;
INLINE iterator insert(iterator position, const Element &x) const;
INLINE void insert(iterator position, size_type n, const Element &x) const;
@ -125,10 +126,19 @@ public:
INLINE void insert(iterator position, const Element *first, const Element *last) const;
#endif
INLINE void pop_back() const;
INLINE void erase(iterator position) const;
INLINE void erase(iterator first, iterator last) const;
PUBLISHED:
#if !defined(WIN32_VC) || defined(CPPPARSER)
INLINE reference operator [](size_type n) const;
#endif
INLINE void push_back(const Element &x);
INLINE void pop_back();
INLINE void make_empty();
public:
INLINE operator Element *() const;
INLINE Element *p() const;
INLINE vector<Element> &v() const;