31GeomTristrips(GeomTristrips::UsageHint usage_hint) :
57 return new GeomTristrips(*
this);
80 return GR_triangle_strip | GR_indexed_other;
82 return GR_triangle_strip;
98 GeomPrimitivePipelineReader from(
this, current_thread);
99 int num_vertices = from.get_num_vertices();
100 const int num_unused = 2;
103 map<std::pair<int, int>,
int> edge_map;
105 int vi = -num_unused;
107 while (li < (
int)ends.size()) {
111 nassertr(vi + 2 <= end,
nullptr);
116 edge_map[make_pair(v0, v1)] = v2;
120 edge_map[make_pair(v2, v0)] = v1;
124 edge_map[make_pair(v1, v2)] = v0;
131 edge_map[make_pair(v0, v2)] = v1;
135 edge_map[make_pair(v2, v1)] = v0;
144 nassertr(vi == num_vertices,
nullptr);
150 while (li < (
int)ends.size()) {
154 nassertr(vi + 2 <= end,
nullptr);
162 auto it = edge_map.find(make_pair(v1, v0));
163 if (it != edge_map.end()) {
164 adj->add_vertex(it->second);
173 it = edge_map.find(make_pair(v0, v2));
174 if (it != edge_map.end()) {
175 adj->add_vertex(it->second);
183 it = edge_map.find(make_pair(v2, v1));
184 if (it != edge_map.end()) {
185 adj->add_vertex(it->second);
195 it = edge_map.find(make_pair(v2, v0));
196 if (it != edge_map.end()) {
197 adj->add_vertex(it->second);
205 it = edge_map.find(make_pair(v1, v2));
206 if (it != edge_map.end()) {
207 adj->add_vertex(it->second);
217 adj->close_primitive();
220 nassertr(vi == num_vertices,
nullptr);
251 return gsg->draw_tristrips(reader, force);
265decompose_impl()
const {
279 int vi = -num_unused;
281 while (li < (
int)ends.size()) {
285 nassertr(vi + 2 <= end,
nullptr);
290 bool reversed =
false;
295 if (v0 != v1 && v0 != v2 && v1 != v2) {
296 triangles->add_vertex(v0);
297 triangles->add_vertex(v2);
298 triangles->add_vertex(v1);
299 triangles->close_primitive();
303 if (v0 != v1 && v0 != v2 && v1 != v2) {
304 triangles->add_vertex(v0);
305 triangles->add_vertex(v1);
306 triangles->add_vertex(v2);
307 triangles->close_primitive();
316 nassertr(vi == num_vertices,
nullptr);
321 int vi = -num_unused;
323 while (li < (
int)ends.size()) {
327 nassertr(vi + 2 <= end,
nullptr);
332 bool reversed =
false;
336 if (v0 != v1 && v0 != v2 && v1 != v2) {
337 triangles->add_vertex(v1);
338 triangles->add_vertex(v0);
339 triangles->add_vertex(v2);
340 triangles->close_primitive();
344 if (v0 != v1 && v0 != v2 && v1 != v2) {
345 triangles->add_vertex(v0);
346 triangles->add_vertex(v1);
347 triangles->add_vertex(v2);
348 triangles->close_primitive();
358 nassertr(vi == num_vertices,
nullptr);
368doubleside_impl()
const {
371 return decompose_impl()->doubleside();
378reverse_impl()
const {
381 return decompose_impl()->reverse();
396 PT(GeomVertexArrayData) new_vertices = make_index_data();
400 CPT(GeomVertexArrayData) vertices = get_vertices();
401 GeomVertexReader from(vertices, 0);
402 GeomVertexWriter to(new_vertices, 0);
406 CPTA_int::const_iterator ei;
407 for (ei = ends.begin(); ei != ends.end(); ++ei) {
409 int num_vertices = end - begin;
413 to.set_data1i(last_added);
414 from.set_row_unsafe(end - 1);
415 to.set_data1i(from.get_data1i());
421 nassertr((num_vertices & 1) == 0,
nullptr);
422 for (
int vi = end - 1; vi >= begin; --vi) {
423 from.set_row_unsafe(vi);
424 last_added = from.get_data1i();
425 to.set_data1i(last_added);
431 nassertr(to.is_at_end(),
nullptr);
436 GeomVertexWriter to(new_vertices, 0);
440 CPTA_int::const_iterator ei;
441 for (ei = ends.begin(); ei != ends.end(); ++ei) {
443 int num_vertices = end - begin;
447 to.set_data1i(last_added);
448 to.set_data1i(end - 1 + first_vertex);
454 nassertr((num_vertices & 1) == 0,
nullptr);
455 for (
int vi = end - 1; vi >= begin; --vi) {
456 last_added = vi + first_vertex;
457 to.set_data1i(last_added);
463 nassertr(to.is_at_end(),
nullptr);
473requires_unused_vertices()
const {
485 GeomVertexReader from(vertices, 0);
487 int prev = from.get_data1i();
489 GeomVertexWriter to(vertices, 0);
493 to.add_data1i(vertex);
516 object->fillin(scan, manager);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A class to retrieve the individual data elements previously stored in a Datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
int get_vertex(int i) const
Returns the ith vertex index in the table.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
CPTA_int get_ends() const
Returns a const pointer to the primitive ends array so application code can read it directly.
get_vertex
Returns the ith vertex index in the table.
get_usage_hint
Returns the usage hint for this primitive.
get_num_vertices
Returns the number of indices used by all the primitives in this object.
int get_first_vertex() const
Returns the first vertex number referenced by the primitive.
get_shade_model
Returns the ShadeModel hint for this primitive.
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
Defines a series of disconnected triangles.
Defines a series of triangle strips with adjacency information.
Defines a series of triangle strips.
virtual bool draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const
Calls the appropriate method on the GSG to draw the primitive.
virtual int get_min_num_vertices_per_primitive() const
Returns the minimum number of vertices that must be added before close_primitive() may legally be cal...
virtual int get_num_unused_vertices_per_primitive() const
Returns the number of vertices that are added between primitives that aren't, strictly speaking,...
static void register_with_read_factory()
Tells the BamReader how to create objects of type Geom.
virtual PrimitiveType get_primitive_type() const
Returns the fundamental rendering type of this primitive: whether it is points, lines,...
virtual int get_geom_rendering() const
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
ConstPointerTo< GeomPrimitive > make_adjacency() const
Adds adjacency information to this primitive.
This is the data for one array of a GeomVertexData structure.
int get_num_rows() const
Returns the number of rows stored in the array, based on the number of bytes and the stride.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
get_current_thread
Returns a pointer to the currently-executing Thread object.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.