diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 28d62519d1..5efea51875 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -147,9 +147,9 @@ modify_primitive(int i) { // returning the result. See // GeomPrimitive::decompose(). //////////////////////////////////////////////////////////////////// -INLINE CPT(Geom) Geom:: +INLINE PT(Geom) Geom:: decompose() const { - PT(Geom) new_geom = new Geom(*this); + PT(Geom) new_geom = make_copy(); new_geom->decompose_in_place(); return new_geom; } @@ -161,9 +161,9 @@ decompose() const { // returning the result. See // GeomPrimitive::rotate(). //////////////////////////////////////////////////////////////////// -INLINE CPT(Geom) Geom:: +INLINE PT(Geom) Geom:: rotate() const { - PT(Geom) new_geom = new Geom(*this); + PT(Geom) new_geom = make_copy(); new_geom->rotate_in_place(); return new_geom; } @@ -177,9 +177,9 @@ rotate() const { // the Geom contains both triangle strips and triangle // fans. //////////////////////////////////////////////////////////////////// -INLINE CPT(Geom) Geom:: +INLINE PT(Geom) Geom:: unify() const { - PT(Geom) new_geom = new Geom(*this); + PT(Geom) new_geom = make_copy(); new_geom->unify_in_place(); return new_geom; } diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index a1d1ce7947..cef8bf8afe 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -83,9 +83,9 @@ PUBLISHED: void remove_primitive(int i); void clear_primitives(); - INLINE CPT(Geom) decompose() const; - INLINE CPT(Geom) rotate() const; - INLINE CPT(Geom) unify() const; + INLINE PT(Geom) decompose() const; + INLINE PT(Geom) rotate() const; + INLINE PT(Geom) unify() const; void decompose_in_place(); void rotate_in_place(); diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index c1890c2860..23f1e7c3be 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -161,21 +161,27 @@ decompose_impl() const { ++vi; bool reversed = false; while (vi < end) { - triangles->add_vertex(v0); int v2 = get_vertex(vi); ++vi; if (reversed) { - triangles->add_vertex(v2); - triangles->add_vertex(v1); + if (v0 != v1 && v0 != v2 && v1 != v2) { + triangles->add_vertex(v0); + triangles->add_vertex(v2); + triangles->add_vertex(v1); + triangles->close_primitive(); + } reversed = false; } else { - triangles->add_vertex(v1); - triangles->add_vertex(v2); + if (v0 != v1 && v0 != v2 && v1 != v2) { + triangles->add_vertex(v0); + triangles->add_vertex(v1); + triangles->add_vertex(v2); + triangles->close_primitive(); + } reversed = true; } v0 = v1; v1 = v2; - triangles->close_primitive(); } ++li; } @@ -197,21 +203,27 @@ decompose_impl() const { ++vi; bool reversed = false; while (vi < end) { + int v2 = get_vertex(vi); if (reversed) { - triangles->add_vertex(v1); - triangles->add_vertex(v0); + if (v0 != v1 && v0 != v2 && v1 != v2) { + triangles->add_vertex(v1); + triangles->add_vertex(v0); + triangles->add_vertex(v2); + triangles->close_primitive(); + } reversed = false; } else { - triangles->add_vertex(v0); - triangles->add_vertex(v1); + if (v0 != v1 && v0 != v2 && v1 != v2) { + triangles->add_vertex(v0); + triangles->add_vertex(v1); + triangles->add_vertex(v2); + triangles->close_primitive(); + } reversed = true; } - int v2 = get_vertex(vi); ++vi; - triangles->add_vertex(v2); v0 = v1; v1 = v2; - triangles->close_primitive(); } ++li; } diff --git a/panda/src/gobj/geomVertexReader.I b/panda/src/gobj/geomVertexReader.I index 416b2084fe..e78f131bcc 100644 --- a/panda/src/gobj/geomVertexReader.I +++ b/panda/src/gobj/geomVertexReader.I @@ -88,6 +88,43 @@ GeomVertexReader(const GeomVertexArrayData *array_data, int column) : set_column(column); } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexReader::Copy Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE GeomVertexReader:: +GeomVertexReader(const GeomVertexReader ©) : + _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 ©) { + _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 // Access: Published diff --git a/panda/src/gobj/geomVertexReader.h b/panda/src/gobj/geomVertexReader.h index 808e3655d3..828affcbcc 100644 --- a/panda/src/gobj/geomVertexReader.h +++ b/panda/src/gobj/geomVertexReader.h @@ -61,12 +61,14 @@ class EXPCL_PANDA GeomVertexReader : public GeomEnums { PUBLISHED: INLINE GeomVertexReader(const GeomVertexData *vertex_data); INLINE GeomVertexReader(const GeomVertexData *vertex_data, - const string &name); + const string &name); INLINE GeomVertexReader(const GeomVertexData *vertex_data, - const InternalName *name); + const InternalName *name); INLINE GeomVertexReader(const GeomVertexArrayData *array_data); INLINE GeomVertexReader(const GeomVertexArrayData *array_data, - int column); + int column); + INLINE GeomVertexReader(const GeomVertexReader ©); + INLINE void operator = (const GeomVertexReader ©); INLINE ~GeomVertexReader(); INLINE const GeomVertexData *get_vertex_data() const; diff --git a/panda/src/gobj/geomVertexRewriter.I b/panda/src/gobj/geomVertexRewriter.I index 7c22eebde6..35761da0ab 100644 --- a/panda/src/gobj/geomVertexRewriter.I +++ b/panda/src/gobj/geomVertexRewriter.I @@ -87,6 +87,29 @@ GeomVertexRewriter(GeomVertexArrayData *array_data, int column) : set_column(column); } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexRewriter::Copy Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE GeomVertexRewriter:: +GeomVertexRewriter(const GeomVertexRewriter ©) : + GeomVertexWriter(copy), + GeomVertexReader(copy) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexRewriter::Copy Assignment Operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexRewriter:: +operator = (const GeomVertexRewriter ©) { + GeomVertexWriter::operator = (copy); + GeomVertexReader::operator = (copy); +} + //////////////////////////////////////////////////////////////////// // Function: GeomVertexRewriter::Destructor // Access: Published diff --git a/panda/src/gobj/geomVertexRewriter.h b/panda/src/gobj/geomVertexRewriter.h index 4b3a751946..b0faf78b89 100644 --- a/panda/src/gobj/geomVertexRewriter.h +++ b/panda/src/gobj/geomVertexRewriter.h @@ -44,12 +44,14 @@ class EXPCL_PANDA GeomVertexRewriter : public GeomVertexWriter, public GeomVerte PUBLISHED: INLINE GeomVertexRewriter(GeomVertexData *vertex_data); INLINE GeomVertexRewriter(GeomVertexData *vertex_data, - const string &name); + const string &name); INLINE GeomVertexRewriter(GeomVertexData *vertex_data, - const InternalName *name); + const InternalName *name); INLINE GeomVertexRewriter(GeomVertexArrayData *array_data); INLINE GeomVertexRewriter(GeomVertexArrayData *array_data, - int column); + int column); + INLINE GeomVertexRewriter(const GeomVertexRewriter ©); + INLINE void operator = (const GeomVertexRewriter ©); INLINE ~GeomVertexRewriter(); INLINE GeomVertexData *get_vertex_data() const; diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index 38d84ecd16..470a4b430b 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/panda/src/gobj/geomVertexWriter.I @@ -87,6 +87,43 @@ GeomVertexWriter(GeomVertexArrayData *array_data, int column) : set_column(column); } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::Copy Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE GeomVertexWriter:: +GeomVertexWriter(const GeomVertexWriter ©) : + _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 ©) { + _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 // Access: Published diff --git a/panda/src/gobj/geomVertexWriter.h b/panda/src/gobj/geomVertexWriter.h index c74f20dd98..14d465902b 100644 --- a/panda/src/gobj/geomVertexWriter.h +++ b/panda/src/gobj/geomVertexWriter.h @@ -74,12 +74,14 @@ class EXPCL_PANDA GeomVertexWriter : public GeomEnums { PUBLISHED: INLINE GeomVertexWriter(GeomVertexData *vertex_data); INLINE GeomVertexWriter(GeomVertexData *vertex_data, - const string &name); + const string &name); INLINE GeomVertexWriter(GeomVertexData *vertex_data, - const InternalName *name); + const InternalName *name); INLINE GeomVertexWriter(GeomVertexArrayData *array_data); INLINE GeomVertexWriter(GeomVertexArrayData *array_data, - int column); + int column); + INLINE GeomVertexWriter(const GeomVertexWriter ©); + INLINE void operator = (const GeomVertexWriter ©); INLINE ~GeomVertexWriter(); INLINE GeomVertexData *get_vertex_data() const;