copy constructors, other minor refinements

This commit is contained in:
David Rose 2005-10-03 22:54:25 +00:00
parent 18dbe6527c
commit 4cc9dba771
9 changed files with 146 additions and 31 deletions

View File

@ -147,9 +147,9 @@ modify_primitive(int i) {
// returning the result. See // returning the result. See
// GeomPrimitive::decompose(). // GeomPrimitive::decompose().
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CPT(Geom) Geom:: INLINE PT(Geom) Geom::
decompose() const { decompose() const {
PT(Geom) new_geom = new Geom(*this); PT(Geom) new_geom = make_copy();
new_geom->decompose_in_place(); new_geom->decompose_in_place();
return new_geom; return new_geom;
} }
@ -161,9 +161,9 @@ decompose() const {
// returning the result. See // returning the result. See
// GeomPrimitive::rotate(). // GeomPrimitive::rotate().
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CPT(Geom) Geom:: INLINE PT(Geom) Geom::
rotate() const { rotate() const {
PT(Geom) new_geom = new Geom(*this); PT(Geom) new_geom = make_copy();
new_geom->rotate_in_place(); new_geom->rotate_in_place();
return new_geom; return new_geom;
} }
@ -177,9 +177,9 @@ rotate() const {
// the Geom contains both triangle strips and triangle // the Geom contains both triangle strips and triangle
// fans. // fans.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CPT(Geom) Geom:: INLINE PT(Geom) Geom::
unify() const { unify() const {
PT(Geom) new_geom = new Geom(*this); PT(Geom) new_geom = make_copy();
new_geom->unify_in_place(); new_geom->unify_in_place();
return new_geom; return new_geom;
} }

View File

@ -83,9 +83,9 @@ PUBLISHED:
void remove_primitive(int i); void remove_primitive(int i);
void clear_primitives(); void clear_primitives();
INLINE CPT(Geom) decompose() const; INLINE PT(Geom) decompose() const;
INLINE CPT(Geom) rotate() const; INLINE PT(Geom) rotate() const;
INLINE CPT(Geom) unify() const; INLINE PT(Geom) unify() const;
void decompose_in_place(); void decompose_in_place();
void rotate_in_place(); void rotate_in_place();

View File

@ -161,21 +161,27 @@ decompose_impl() const {
++vi; ++vi;
bool reversed = false; bool reversed = false;
while (vi < end) { while (vi < end) {
triangles->add_vertex(v0);
int v2 = get_vertex(vi); int v2 = get_vertex(vi);
++vi; ++vi;
if (reversed) { if (reversed) {
triangles->add_vertex(v2); if (v0 != v1 && v0 != v2 && v1 != v2) {
triangles->add_vertex(v1); triangles->add_vertex(v0);
triangles->add_vertex(v2);
triangles->add_vertex(v1);
triangles->close_primitive();
}
reversed = false; reversed = false;
} else { } else {
triangles->add_vertex(v1); if (v0 != v1 && v0 != v2 && v1 != v2) {
triangles->add_vertex(v2); triangles->add_vertex(v0);
triangles->add_vertex(v1);
triangles->add_vertex(v2);
triangles->close_primitive();
}
reversed = true; reversed = true;
} }
v0 = v1; v0 = v1;
v1 = v2; v1 = v2;
triangles->close_primitive();
} }
++li; ++li;
} }
@ -197,21 +203,27 @@ decompose_impl() const {
++vi; ++vi;
bool reversed = false; bool reversed = false;
while (vi < end) { while (vi < end) {
int v2 = get_vertex(vi);
if (reversed) { if (reversed) {
triangles->add_vertex(v1); if (v0 != v1 && v0 != v2 && v1 != v2) {
triangles->add_vertex(v0); triangles->add_vertex(v1);
triangles->add_vertex(v0);
triangles->add_vertex(v2);
triangles->close_primitive();
}
reversed = false; reversed = false;
} else { } else {
triangles->add_vertex(v0); if (v0 != v1 && v0 != v2 && v1 != v2) {
triangles->add_vertex(v1); triangles->add_vertex(v0);
triangles->add_vertex(v1);
triangles->add_vertex(v2);
triangles->close_primitive();
}
reversed = true; reversed = true;
} }
int v2 = get_vertex(vi);
++vi; ++vi;
triangles->add_vertex(v2);
v0 = v1; v0 = v1;
v1 = v2; v1 = v2;
triangles->close_primitive();
} }
++li; ++li;
} }

View File

@ -88,6 +88,43 @@ GeomVertexReader(const GeomVertexArrayData *array_data, int column) :
set_column(column); set_column(column);
} }
////////////////////////////////////////////////////////////////////
// Function: GeomVertexReader::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE GeomVertexReader::
GeomVertexReader(const GeomVertexReader &copy) :
_vertex_data(copy._vertex_data),
_array(copy._array),
_array_data(copy._array_data),
_packer(copy._packer),
_stride(copy._stride),
_pointer_begin(copy._pointer_begin),
_pointer_end(copy._pointer_end),
_pointer(copy._pointer),
_start_row(copy._start_row)
{
}
////////////////////////////////////////////////////////////////////
// Function: GeomVertexReader::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void GeomVertexReader::
operator = (const GeomVertexReader &copy) {
_vertex_data = copy._vertex_data;
_array = copy._array;
_array_data = copy._array_data;
_packer = copy._packer;
_stride = copy._stride;
_pointer_begin = copy._pointer_begin;
_pointer_end = copy._pointer_end;
_pointer = copy._pointer;
_start_row = copy._start_row;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: GeomVertexReader::Destructor // Function: GeomVertexReader::Destructor
// Access: Published // Access: Published

View File

@ -61,12 +61,14 @@ class EXPCL_PANDA GeomVertexReader : public GeomEnums {
PUBLISHED: PUBLISHED:
INLINE GeomVertexReader(const GeomVertexData *vertex_data); INLINE GeomVertexReader(const GeomVertexData *vertex_data);
INLINE GeomVertexReader(const GeomVertexData *vertex_data, INLINE GeomVertexReader(const GeomVertexData *vertex_data,
const string &name); const string &name);
INLINE GeomVertexReader(const GeomVertexData *vertex_data, INLINE GeomVertexReader(const GeomVertexData *vertex_data,
const InternalName *name); const InternalName *name);
INLINE GeomVertexReader(const GeomVertexArrayData *array_data); INLINE GeomVertexReader(const GeomVertexArrayData *array_data);
INLINE GeomVertexReader(const GeomVertexArrayData *array_data, INLINE GeomVertexReader(const GeomVertexArrayData *array_data,
int column); int column);
INLINE GeomVertexReader(const GeomVertexReader &copy);
INLINE void operator = (const GeomVertexReader &copy);
INLINE ~GeomVertexReader(); INLINE ~GeomVertexReader();
INLINE const GeomVertexData *get_vertex_data() const; INLINE const GeomVertexData *get_vertex_data() const;

View File

@ -87,6 +87,29 @@ GeomVertexRewriter(GeomVertexArrayData *array_data, int column) :
set_column(column); set_column(column);
} }
////////////////////////////////////////////////////////////////////
// Function: GeomVertexRewriter::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE GeomVertexRewriter::
GeomVertexRewriter(const GeomVertexRewriter &copy) :
GeomVertexWriter(copy),
GeomVertexReader(copy)
{
}
////////////////////////////////////////////////////////////////////
// Function: GeomVertexRewriter::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void GeomVertexRewriter::
operator = (const GeomVertexRewriter &copy) {
GeomVertexWriter::operator = (copy);
GeomVertexReader::operator = (copy);
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: GeomVertexRewriter::Destructor // Function: GeomVertexRewriter::Destructor
// Access: Published // Access: Published

View File

@ -44,12 +44,14 @@ class EXPCL_PANDA GeomVertexRewriter : public GeomVertexWriter, public GeomVerte
PUBLISHED: PUBLISHED:
INLINE GeomVertexRewriter(GeomVertexData *vertex_data); INLINE GeomVertexRewriter(GeomVertexData *vertex_data);
INLINE GeomVertexRewriter(GeomVertexData *vertex_data, INLINE GeomVertexRewriter(GeomVertexData *vertex_data,
const string &name); const string &name);
INLINE GeomVertexRewriter(GeomVertexData *vertex_data, INLINE GeomVertexRewriter(GeomVertexData *vertex_data,
const InternalName *name); const InternalName *name);
INLINE GeomVertexRewriter(GeomVertexArrayData *array_data); INLINE GeomVertexRewriter(GeomVertexArrayData *array_data);
INLINE GeomVertexRewriter(GeomVertexArrayData *array_data, INLINE GeomVertexRewriter(GeomVertexArrayData *array_data,
int column); int column);
INLINE GeomVertexRewriter(const GeomVertexRewriter &copy);
INLINE void operator = (const GeomVertexRewriter &copy);
INLINE ~GeomVertexRewriter(); INLINE ~GeomVertexRewriter();
INLINE GeomVertexData *get_vertex_data() const; INLINE GeomVertexData *get_vertex_data() const;

View File

@ -87,6 +87,43 @@ GeomVertexWriter(GeomVertexArrayData *array_data, int column) :
set_column(column); set_column(column);
} }
////////////////////////////////////////////////////////////////////
// Function: GeomVertexWriter::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE GeomVertexWriter::
GeomVertexWriter(const GeomVertexWriter &copy) :
_vertex_data(copy._vertex_data),
_array(copy._array),
_array_data(copy._array_data),
_packer(copy._packer),
_stride(copy._stride),
_pointer_begin(copy._pointer_begin),
_pointer_end(copy._pointer_end),
_pointer(copy._pointer),
_start_row(copy._start_row)
{
}
////////////////////////////////////////////////////////////////////
// Function: GeomVertexWriter::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void GeomVertexWriter::
operator = (const GeomVertexWriter &copy) {
_vertex_data = copy._vertex_data;
_array = copy._array;
_array_data = copy._array_data;
_packer = copy._packer;
_stride = copy._stride;
_pointer_begin = copy._pointer_begin;
_pointer_end = copy._pointer_end;
_pointer = copy._pointer;
_start_row = copy._start_row;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: GeomVertexWriter::Destructor // Function: GeomVertexWriter::Destructor
// Access: Published // Access: Published

View File

@ -74,12 +74,14 @@ class EXPCL_PANDA GeomVertexWriter : public GeomEnums {
PUBLISHED: PUBLISHED:
INLINE GeomVertexWriter(GeomVertexData *vertex_data); INLINE GeomVertexWriter(GeomVertexData *vertex_data);
INLINE GeomVertexWriter(GeomVertexData *vertex_data, INLINE GeomVertexWriter(GeomVertexData *vertex_data,
const string &name); const string &name);
INLINE GeomVertexWriter(GeomVertexData *vertex_data, INLINE GeomVertexWriter(GeomVertexData *vertex_data,
const InternalName *name); const InternalName *name);
INLINE GeomVertexWriter(GeomVertexArrayData *array_data); INLINE GeomVertexWriter(GeomVertexArrayData *array_data);
INLINE GeomVertexWriter(GeomVertexArrayData *array_data, INLINE GeomVertexWriter(GeomVertexArrayData *array_data,
int column); int column);
INLINE GeomVertexWriter(const GeomVertexWriter &copy);
INLINE void operator = (const GeomVertexWriter &copy);
INLINE ~GeomVertexWriter(); INLINE ~GeomVertexWriter();
INLINE GeomVertexData *get_vertex_data() const; INLINE GeomVertexData *get_vertex_data() const;