Panda3D

Loading...
Searching...
No Matches
geomPrimitive.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file geomPrimitive.h
10 * @author drose
11 * @date 2005-03-06
12 */
13
14#ifndef GEOMPRIMITIVE_H
15#define GEOMPRIMITIVE_H
16
17#include "pandabase.h"
18#include "geomEnums.h"
19#include "geomVertexArrayData.h"
20#include "geomVertexData.h"
21#include "copyOnWriteObject.h"
22#include "luse.h"
23#include "updateSeq.h"
24#include "pointerTo.h"
25#include "pta_int.h"
26#include "pStatCollector.h"
27#include "cycleData.h"
28#include "cycleDataReader.h"
29#include "cycleDataWriter.h"
30#include "cycleDataStageReader.h"
31#include "cycleDataStageWriter.h"
32#include "pipelineCycler.h"
33#include "deletedChain.h"
34
35 class PreparedGraphicsObjects;
36 class IndexBufferContext;
37 class GraphicsStateGuardianBase;
38 class FactoryParams;
39 class GeomPrimitivePipelineReader;
40
41/**
42 * This is an abstract base class for a family of classes that represent the
43 * fundamental geometry primitives that may be stored in a Geom.
44 *
45 * They all have in common the fact that they are defined by tables of vertex
46 * data stored in a GeomVertexData object. Each GeomPrimitive object contains
47 * an ordered list of integers, which index into the vertex array defined by
48 * the GeomVertexData and define the particular vertices of the GeomVertexData
49 * that are used for this primitive.
50 *
51 * The meaning of a given arrangement of vertices is defined by each
52 * individual primitive type; for instance, a GeomTriangle renders a triangle
53 * from each three consecutive vertices, while a GeomTriangleStrip renders a
54 * strip of (n - 2) connected triangles from each sequence of n vertices.
55 */
56 class EXPCL_PANDA_GOBJ GeomPrimitive : public CopyOnWriteObject, public GeomEnums {
57 protected:
58 GeomPrimitive();
59 virtual PT(CopyOnWriteObject) make_cow_copy();
60
61PUBLISHED:
62 explicit GeomPrimitive(UsageHint usage_hint);
63 GeomPrimitive(const GeomPrimitive &copy);
64 void operator = (const GeomPrimitive &copy);
65 virtual ~GeomPrimitive();
66 ALLOC_DELETED_CHAIN(GeomPrimitive);
67
68 virtual PT(GeomPrimitive) make_copy() const=0;
69
70 virtual PrimitiveType get_primitive_type() const=0;
71 virtual int get_geom_rendering() const;
72 MAKE_PROPERTY(primitive_type, get_primitive_type);
73 MAKE_PROPERTY(geom_rendering, get_geom_rendering);
74
75 INLINE ShadeModel get_shade_model() const;
76 INLINE void set_shade_model(ShadeModel shade_model);
77 MAKE_PROPERTY(shade_model, get_shade_model);
78
79 INLINE UsageHint get_usage_hint() const;
80 void set_usage_hint(UsageHint usage_hint);
81 MAKE_PROPERTY(usage_hint, get_usage_hint);
82
83 INLINE NumericType get_index_type() const;
84 void set_index_type(NumericType index_type);
85 MAKE_PROPERTY(index_type, get_index_type);
86
87 // The following published methods are provided for safe, high-level
88 // iteration through the vertices and sub-primitives within the
89 // GeomPrimitive class. These work correctly regardless of the primitive
90 // type and without depending on knowledge about the way primitives' lengths
91 // are encoded. You can also safely build up a composite primitive using
92 // these methods.
93
94 INLINE bool is_composite() const;
95 INLINE bool is_indexed() const;
96 INLINE int get_first_vertex() const;
97 INLINE int get_num_vertices() const;
98 INLINE int get_vertex(int i) const;
99 MAKE_SEQ(get_vertex_list, get_num_vertices, get_vertex);
100 void add_vertex(int vertex);
101 INLINE void add_vertices(int v1, int v2);
102 INLINE void add_vertices(int v1, int v2, int v3);
103 INLINE void add_vertices(int v1, int v2, int v3, int v4);
104 void add_consecutive_vertices(int start, int num_vertices);
105 void add_next_vertices(int num_vertices);
106 void reserve_num_vertices(int num_vertices);
107 bool close_primitive();
108 void clear_vertices();
109 void offset_vertices(int offset);
110 void offset_vertices(int offset, int begin_row, int end_row);
111 void make_nonindexed(GeomVertexData *dest, const GeomVertexData *source);
112 void pack_vertices(GeomVertexData *dest, const GeomVertexData *source);
113 void make_indexed();
114
115 INLINE int get_num_primitives() const;
116 int get_primitive_start(int n) const;
117 int get_primitive_end(int n) const;
118 int get_primitive_num_vertices(int n) const;
119 int get_num_used_vertices() const;
120
121 INLINE int get_num_faces() const;
122 INLINE int get_primitive_num_faces(int n) const;
123
124 INLINE int get_min_vertex() const;
125 int get_primitive_min_vertex(int n) const;
126 INLINE int get_max_vertex() const;
127 int get_primitive_max_vertex(int n) const;
128
129 CPT(GeomPrimitive) decompose() const;
130 CPT(GeomPrimitive) rotate() const;
131 CPT(GeomPrimitive) doubleside() const;
132 CPT(GeomPrimitive) reverse() const;
133 CPT(GeomPrimitive) match_shade_model(ShadeModel shade_model) const;
134 CPT(GeomPrimitive) make_points() const;
135 CPT(GeomPrimitive) make_lines() const;
136 CPT(GeomPrimitive) make_patches() const;
137 virtual CPT(GeomPrimitive) make_adjacency() const;
138
139 int get_num_bytes() const;
140 INLINE int get_data_size_bytes() const;
141 INLINE UpdateSeq get_modified() const;
142 MAKE_PROPERTY(num_bytes, get_num_bytes);
143 MAKE_PROPERTY(data_size_bytes, get_data_size_bytes);
144 MAKE_PROPERTY(modified, get_modified);
145
146 bool request_resident(Thread *current_thread = Thread::get_current_thread()) const;
147
148 INLINE bool check_valid(const GeomVertexData *vertex_data) const;
149 INLINE bool check_valid(const GeomVertexDataPipelineReader *data_reader) const;
150
151 virtual void output(std::ostream &out) const;
152 virtual void write(std::ostream &out, int indent_level) const;
153
154PUBLISHED:
155/*
156 * These public methods are not intended for high-level usage. They are
157 * public so that low-level code that absolutely needs fast access to the
158 * primitive data can get to it, but using them requires knowledge about how
159 * the component primitives are encoded within the GeomPrimitive class, and
160 * it's easy to screw something up. Also, if too many code samples depend on
161 * this internal knowledge, it may make it difficult to extend this class
162 * later. It is recommended that application-level code use the above
163 * interfaces instead.
164 */
165
166 INLINE CPT(GeomVertexArrayData) get_vertices() const;
167 INLINE CPT(GeomVertexArrayDataHandle) get_vertices_handle(Thread *current_thread) const;
168 PT(GeomVertexArrayData) modify_vertices(int num_vertices = -1);
169 INLINE PT(GeomVertexArrayDataHandle) modify_vertices_handle(Thread *current_thread);
170 void set_vertices(const GeomVertexArrayData *vertices, int num_vertices = -1);
171 void set_nonindexed_vertices(int first_vertex, int num_vertices);
172
173 INLINE int get_index_stride() const;
174 INLINE int get_strip_cut_index() const;
175 MAKE_PROPERTY(index_stride, get_index_stride);
176 MAKE_PROPERTY(strip_cut_index, get_strip_cut_index);
177
178 INLINE CPTA_int get_ends() const;
179 PTA_int modify_ends();
180 void set_ends(PTA_int ends);
181
182 INLINE CPT(GeomVertexArrayData) get_mins() const;
183 INLINE CPT(GeomVertexArrayData) get_maxs() const;
184 MAKE_PROPERTY(mins, get_mins);
185 MAKE_PROPERTY(maxs, get_maxs);
186
187 void set_minmax(int min_vertex, int max_vertex,
188 GeomVertexArrayData *mins, GeomVertexArrayData *maxs);
189 void clear_minmax();
190
191 virtual int get_num_vertices_per_primitive() const;
192 virtual int get_min_num_vertices_per_primitive() const;
193 virtual int get_num_unused_vertices_per_primitive() const;
194 MAKE_PROPERTY(num_vertices_per_primitive, get_num_vertices_per_primitive);
195 MAKE_PROPERTY(min_num_vertices_per_primitive, get_min_num_vertices_per_primitive);
196 MAKE_PROPERTY(num_unused_vertices_per_primitive, get_num_unused_vertices_per_primitive);
197
198 public:
199 void prepare(PreparedGraphicsObjects *prepared_objects);
200 bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
201
202 IndexBufferContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
203 GraphicsStateGuardianBase *gsg);
204 bool release(PreparedGraphicsObjects *prepared_objects);
205 int release_all();
206
207 static const GeomVertexArrayFormat *get_index_format(NumericType index_type);
208 INLINE const GeomVertexArrayFormat *get_index_format() const;
209 INLINE PT(GeomVertexArrayData) make_index_data() const;
210
211 private:
212 static CPT(GeomVertexArrayFormat) make_index_format(NumericType index_type);
213
214 void clear_prepared(PreparedGraphicsObjects *prepared_objects);
215 static int get_highest_index_value(NumericType index_type);
216 static int get_strip_cut_index(NumericType index_type);
217
218 public:
219 virtual bool draw(GraphicsStateGuardianBase *gsg,
220 const GeomPrimitivePipelineReader *reader,
221 bool force) const=0;
222
223 void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
224 PN_stdfloat &sq_center_dist, bool &found_any,
225 const GeomVertexData *vertex_data,
226 bool got_mat, const LMatrix4 &mat,
227 const InternalName *column_name,
228 Thread *current_thread) const;
229
230 void calc_sphere_radius(const LPoint3 &center,
231 PN_stdfloat &sq_radius, bool &found_any,
232 const GeomVertexData *vertex_data,
233 Thread *current_thread) const;
234
235 protected:
236 virtual CPT(GeomPrimitive) decompose_impl() const;
237 virtual CPT(GeomVertexArrayData) rotate_impl() const;
238 virtual CPT(GeomPrimitive) doubleside_impl() const;
239 virtual CPT(GeomPrimitive) reverse_impl() const;
240 virtual bool requires_unused_vertices() const;
241 virtual void append_unused_vertices(GeomVertexArrayData *vertices,
242 int vertex);
243
244 private:
245 class CData;
246
247 void recompute_minmax(CData *cdata);
248 void do_make_indexed(CData *cdata);
249 void consider_elevate_index_type(CData *cdata, int vertex);
250 void do_set_index_type(CData *cdata, NumericType index_type);
251 PT(GeomVertexArrayData) do_modify_vertices(CData *cdata);
252
253 private:
254 // A GeomPrimitive keeps a list (actually, a map) of all the
255 // PreparedGraphicsObjects tables that it has been prepared into. Each PGO
256 // conversely keeps a list (a set) of all the Geoms that have been prepared
257 // there. When either destructs, it removes itself from the other's list.
258 typedef pmap<PreparedGraphicsObjects *, IndexBufferContext *> Contexts;
259 Contexts _contexts;
260
261 // This is the data that must be cycled between pipeline stages.
262 class EXPCL_PANDA_GOBJ CData : public CycleData {
263 public:
264 INLINE CData();
265 INLINE CData(const CData &copy);
266 ALLOC_DELETED_CHAIN(CData);
267
268 virtual CycleData *make_copy() const;
269 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
270 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
271 virtual void fillin(DatagramIterator &scan, BamReader *manager);
272 virtual TypeHandle get_parent_type() const {
273 return GeomPrimitive::get_class_type();
274 }
275
276 ShadeModel _shade_model;
277 int _first_vertex;
278 int _num_vertices;
279 NumericType _index_type;
280 UsageHint _usage_hint;
281 COWPT(GeomVertexArrayData) _vertices;
282 PTA_int _ends;
283 COWPT(GeomVertexArrayData) _mins;
284 COWPT(GeomVertexArrayData) _maxs;
285 UpdateSeq _modified;
286
287 bool _got_minmax;
288 unsigned int _min_vertex;
289 unsigned int _max_vertex;
290
291 public:
292 static TypeHandle get_class_type() {
293 return _type_handle;
294 }
295 static void init_type() {
296 register_type(_type_handle, "GeomPrimitive::CData");
297 }
298
299 private:
300 static TypeHandle _type_handle;
301
302 friend class GeomPrimitive;
303 };
304
305 PipelineCycler<CData> _cycler;
306 typedef CycleDataReader<CData> CDReader;
307 typedef CycleDataWriter<CData> CDWriter;
308 typedef CycleDataStageReader<CData> CDStageReader;
309 typedef CycleDataStageWriter<CData> CDStageWriter;
310
311 private:
312 static PStatCollector _decompose_pcollector;
313 static PStatCollector _doubleside_pcollector;
314 static PStatCollector _reverse_pcollector;
315 static PStatCollector _rotate_pcollector;
316
317 public:
318 virtual void write_datagram(BamWriter *manager, Datagram &dg);
319
320 virtual void finalize(BamReader *manager);
321
322 protected:
323 void fillin(DatagramIterator &scan, BamReader *manager);
324
325 public:
326 static TypeHandle get_class_type() {
327 return _type_handle;
328 }
329 static void init_type() {
330 CopyOnWriteObject::init_type();
331 register_type(_type_handle, "GeomPrimitive",
332 CopyOnWriteObject::get_class_type());
333 CData::init_type();
334 }
335 virtual TypeHandle get_type() const {
336 return get_class_type();
337 }
338 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
339
340 private:
341 static TypeHandle _type_handle;
342
343 friend class Geom;
344 friend class PreparedGraphicsObjects;
345 friend class GeomPrimitivePipelineReader;
346};
347
348/**
349 * Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of
350 * the pipeline.
351 */
352 class EXPCL_PANDA_GOBJ GeomPrimitivePipelineReader : public GeomEnums {
353 public:
354 INLINE GeomPrimitivePipelineReader(CPT(GeomPrimitive) object, Thread *current_thread);
355 GeomPrimitivePipelineReader(const GeomPrimitivePipelineReader &copy) = delete;
356 INLINE ~GeomPrimitivePipelineReader();
357
358 ALLOC_DELETED_CHAIN(GeomPrimitivePipelineReader);
359
360 GeomPrimitivePipelineReader &operator = (const GeomPrimitivePipelineReader &copy) = delete;
361
362 INLINE const GeomPrimitive *get_object() const;
363 INLINE Thread *get_current_thread() const;
364
365 void check_minmax() const;
366
367 INLINE ShadeModel get_shade_model() const;
368 INLINE UsageHint get_usage_hint() const;
369 INLINE NumericType get_index_type() const;
370 INLINE bool is_indexed() const;
371 int get_first_vertex() const;
372 INLINE int get_num_vertices() const;
373 int get_vertex(int i) const;
374 int get_num_primitives() const;
375 void get_referenced_vertices(BitArray &bits) const;
376 INLINE int get_min_vertex() const;
377 INLINE int get_max_vertex() const;
378 INLINE int get_data_size_bytes() const;
379 INLINE UpdateSeq get_modified() const;
380 bool check_valid(const GeomVertexDataPipelineReader *data_reader) const;
381 INLINE int get_index_stride() const;
382 INLINE const unsigned char *get_read_pointer(bool force) const;
383 INLINE int get_strip_cut_index() const;
384 INLINE CPTA_int get_ends() const;
385 INLINE CPT(GeomVertexArrayData) get_mins() const;
386 INLINE CPT(GeomVertexArrayData) get_maxs() const;
387
388 INLINE IndexBufferContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
389 GraphicsStateGuardianBase *gsg) const;
390 INLINE bool draw(GraphicsStateGuardianBase *gsg, bool force) const;
391
392 private:
393 CPT(GeomPrimitive) _object;
394 Thread *_current_thread;
395 const GeomPrimitive::CData *_cdata;
396
397 CPT(GeomVertexArrayData) _vertices;
398 const GeomVertexArrayData::CData *_vertices_cdata;
399
400 public:
401 static TypeHandle get_class_type() {
402 return _type_handle;
403 }
404 static void init_type() {
405 register_type(_type_handle, "GeomPrimitivePipelineReader");
406 }
407
408 private:
409 static TypeHandle _type_handle;
410};
411
412INLINE std::ostream &operator << (std::ostream &out, const GeomPrimitive &obj);
413
414#include "geomPrimitive.I"
415
416#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
BitArray
A dynamic array with an unlimited number of bits.
Definition bitArray.h:40
CycleData
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
GeomEnums
This class exists just to provide scoping for the various enumerated types used by Geom,...
Definition geomEnums.h:24
GeomPrimitivePipelineReader
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
Definition geomPrimitive.h:352
GeomPrimitivePipelineReader::get_data_size_bytes
int get_data_size_bytes() const
Returns the number of bytes stored in the vertices array.
Definition geomPrimitive.I:595
GeomPrimitivePipelineReader::get_referenced_vertices
void get_referenced_vertices(BitArray &bits) const
Turns on all the bits corresponding to the vertices that are referenced by this GeomPrimitive.
Definition geomPrimitive.cxx:2370
GeomPrimitivePipelineReader::check_minmax
void check_minmax() const
Ensures that the primitive's minmax cache has been computed.
Definition geomPrimitive.cxx:2267
GeomPrimitivePipelineReader::get_vertex
int get_vertex(int i) const
Returns the ith vertex index in the table.
Definition geomPrimitive.cxx:2319
GeomPrimitive
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition geomPrimitive.h:56
GeomPrimitive::get_data_size_bytes
get_data_size_bytes
Returns the number of bytes stored in the vertices array.
Definition geomPrimitive.h:143
GeomPrimitive::get_min_num_vertices_per_primitive
get_min_num_vertices_per_primitive
Returns the minimum number of vertices that must be added before close_primitive() may legally be cal...
Definition geomPrimitive.h:195
GeomPrimitive::rotate
ConstPointerTo< GeomPrimitive > rotate() const
Returns a new primitive with the shade_model reversed (if it is flat shaded), if possible.
Definition geomPrimitive.cxx:865
GeomPrimitive::clear_vertices
void clear_vertices()
Removes all of the vertices and primitives from the object, so they can be re-added.
Definition geomPrimitive.cxx:405
GeomPrimitive::make_adjacency
virtual ConstPointerTo< GeomPrimitive > make_adjacency() const
Adds adjacency information to this primitive.
Definition geomPrimitive.cxx:1113
GeomPrimitive::get_primitive_num_faces
int get_primitive_num_faces(int n) const
Returns the number of triangles or other fundamental type (such as line segments) represented by the ...
Definition geomPrimitive.I:166
GeomPrimitive::get_max_vertex
int get_max_vertex() const
Returns the maximum vertex index number used by all the primitives in this object.
Definition geomPrimitive.I:192
GeomPrimitive::get_num_primitives
int get_num_primitives() const
Returns the number of individual primitives stored within this object.
Definition geomPrimitive.I:126
GeomPrimitive::calc_tight_bounds
void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, PN_stdfloat &sq_center_dist, bool &found_any, const GeomVertexData *vertex_data, bool got_mat, const LMatrix4 &mat, const InternalName *column_name, Thread *current_thread) const
Expands min_point and max_point to include all of the vertices in the Geom, if any (or the data of an...
Definition geomPrimitive.cxx:1657
GeomPrimitive::make_points
ConstPointerTo< GeomPrimitive > make_points() const
Returns a new GeomPoints primitive that represents each of the vertices in the original primitive,...
Definition geomPrimitive.cxx:983
GeomPrimitive::get_geom_rendering
get_geom_rendering
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
Definition geomPrimitive.h:73
GeomPrimitive::get_ends
CPTA_int get_ends() const
Returns a const pointer to the primitive ends array so application code can read it directly.
Definition geomPrimitive.I:314
GeomPrimitive::get_modified
get_modified
Returns a sequence number which is guaranteed to change at least every time the vertex index array is...
Definition geomPrimitive.h:144
GeomPrimitive::get_vertex
get_vertex
Returns the ith vertex index in the table.
Definition geomPrimitive.h:99
GeomPrimitive::reserve_num_vertices
void reserve_num_vertices(int num_vertices)
This ensures that enough memory space for n vertices is allocated, so that you may increase the numbe...
Definition geomPrimitive.cxx:333
GeomPrimitive::get_num_faces
int get_num_faces() const
Returns the number of triangles or other fundamental type (such as line segments) represented by all ...
Definition geomPrimitive.I:147
GeomPrimitive::get_num_used_vertices
int get_num_used_vertices() const
Returns the number of vertices used by all of the primitives.
Definition geomPrimitive.cxx:787
GeomPrimitive::make_lines
ConstPointerTo< GeomPrimitive > make_lines() const
Returns a new GeomLines primitive that represents each of the edges in the original primitive rendere...
Definition geomPrimitive.cxx:1026
GeomPrimitive::get_usage_hint
get_usage_hint
Returns the usage hint for this primitive.
Definition geomPrimitive.h:81
GeomPrimitive::reverse
ConstPointerTo< GeomPrimitive > reverse() const
Reverses the winding order in the primitive so that each triangle is facing in the opposite direction...
Definition geomPrimitive.cxx:930
GeomPrimitive::is_prepared
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG,...
Definition geomPrimitive.cxx:1455
GeomPrimitive::make_indexed
void make_indexed()
Converts the primitive from nonindexed form to indexed form.
Definition geomPrimitive.cxx:692
GeomPrimitive::add_consecutive_vertices
void add_consecutive_vertices(int start, int num_vertices)
Adds a consecutive sequence of vertices, beginning at start, to the primitive.
Definition geomPrimitive.cxx:241
GeomPrimitive::doubleside
ConstPointerTo< GeomPrimitive > doubleside() const
Duplicates triangles in the primitive so that each triangle is back-to-back with another triangle fac...
Definition geomPrimitive.cxx:909
GeomPrimitive::get_num_vertices
get_num_vertices
Returns the number of indices used by all the primitives in this object.
Definition geomPrimitive.h:99
GeomPrimitive::check_valid
bool check_valid(const GeomVertexData *vertex_data) const
Verifies that the primitive only references vertices that actually exist within the indicated GeomVer...
Definition geomPrimitive.I:224
GeomPrimitive::is_composite
bool is_composite() const
Returns true if the primitive is a composite primitive such as a tristrip or trifan,...
Definition geomPrimitive.I:74
GeomPrimitive::get_strip_cut_index
get_strip_cut_index
Returns the index of the indicated type that is reserved for use as a strip cut index,...
Definition geomPrimitive.h:176
GeomPrimitive::match_shade_model
ConstPointerTo< GeomPrimitive > match_shade_model(ShadeModel shade_model) const
Returns a new primitive that is compatible with the indicated shade model, if possible,...
Definition geomPrimitive.cxx:949
GeomPrimitive::pack_vertices
void pack_vertices(GeomVertexData *dest, const GeomVertexData *source)
Packs the vertices used by the primitive from the indicated source array onto the end of the indicate...
Definition geomPrimitive.cxx:639
GeomPrimitive::close_primitive
bool close_primitive()
Indicates that the previous n calls to add_vertex(), since the last call to close_primitive(),...
Definition geomPrimitive.cxx:355
GeomPrimitive::get_first_vertex
int get_first_vertex() const
Returns the first vertex number referenced by the primitive.
Definition geomPrimitive.I:98
GeomPrimitive::set_shade_model
void set_shade_model(ShadeModel shade_model)
Changes the ShadeModel hint for this primitive.
Definition geomPrimitive.I:36
GeomPrimitive::get_primitive_max_vertex
int get_primitive_max_vertex(int n) const
Returns the maximum vertex index number used by the nth primitive in this object.
Definition geomPrimitive.cxx:821
GeomPrimitive::get_index_type
get_index_type
Returns the numeric type of the index column.
Definition geomPrimitive.h:85
GeomPrimitive::set_nonindexed_vertices
void set_nonindexed_vertices(int first_vertex, int num_vertices)
Sets the primitive up as a nonindexed primitive, using the indicated vertex range.
Definition geomPrimitive.cxx:1279
GeomPrimitive::get_num_bytes
get_num_bytes
Returns the number of bytes consumed by the primitive and its index table(s).
Definition geomPrimitive.h:142
GeomPrimitive::request_resident
bool request_resident(Thread *current_thread=Thread::get_current_thread()) const
Returns true if the primitive data is currently resident in memory.
Definition geomPrimitive.cxx:1138
GeomPrimitive::get_num_unused_vertices_per_primitive
get_num_unused_vertices_per_primitive
Returns the number of vertices that are added between primitives that aren't, strictly speaking,...
Definition geomPrimitive.h:196
GeomPrimitive::get_index_stride
get_index_stride
A convenience function to return the gap between successive index numbers, in bytes,...
Definition geomPrimitive.h:175
GeomPrimitive::decompose
ConstPointerTo< GeomPrimitive > decompose() const
Decomposes a complex primitive type into a simpler primitive type, for instance triangle strips to tr...
Definition geomPrimitive.cxx:845
GeomPrimitive::set_index_type
void set_index_type(NumericType index_type)
Changes the numeric type of the index column.
Definition geomPrimitive.cxx:142
GeomPrimitive::set_vertices
void set_vertices(const GeomVertexArrayData *vertices, int num_vertices=-1)
Completely replaces the vertex index list with a new table.
Definition geomPrimitive.cxx:1253
GeomPrimitive::set_ends
void set_ends(PTA_int ends)
Completely replaces the primitive ends array with a new table.
Definition geomPrimitive.cxx:1341
GeomPrimitive::offset_vertices
void offset_vertices(int offset)
Adds the indicated offset to all vertices used by the primitive.
Definition geomPrimitive.cxx:430
GeomPrimitive::release
bool release(PreparedGraphicsObjects *prepared_objects)
Frees the data context only on the indicated object, if it exists there.
Definition geomPrimitive.cxx:1498
GeomPrimitive::get_num_vertices_per_primitive
get_num_vertices_per_primitive
If the primitive type is a simple type in which all primitives have the same number of vertices,...
Definition geomPrimitive.h:194
GeomPrimitive::get_index_format
static const GeomVertexArrayFormat * get_index_format(NumericType index_type)
Returns a registered GeomVertexArrayFormat of the indicated unsigned integer numeric type for storing...
Definition geomPrimitive.cxx:1543
GeomPrimitive::modify_ends
PTA_int modify_ends()
Returns a modifiable pointer to the primitive ends array, so application code can directly fiddle wit...
Definition geomPrimitive.cxx:1310
GeomPrimitive::get_primitive_min_vertex
int get_primitive_min_vertex(int n) const
Returns the minimum vertex index number used by the nth primitive in this object.
Definition geomPrimitive.cxx:803
GeomPrimitive::add_next_vertices
void add_next_vertices(int num_vertices)
Adds the next n vertices in sequence, beginning from the last vertex added to the primitive + 1.
Definition geomPrimitive.cxx:308
GeomPrimitive::make_nonindexed
void make_nonindexed(GeomVertexData *dest, const GeomVertexData *source)
Converts the primitive from indexed to nonindexed by duplicating vertices as necessary into the indic...
Definition geomPrimitive.cxx:607
GeomPrimitive::set_usage_hint
void set_usage_hint(UsageHint usage_hint)
Changes the UsageHint hint for this primitive.
Definition geomPrimitive.cxx:119
GeomPrimitive::get_primitive_start
int get_primitive_start(int n) const
Returns the element within the _vertices list at which the nth primitive starts.
Definition geomPrimitive.cxx:708
GeomPrimitive::get_min_vertex
int get_min_vertex() const
Returns the minimum vertex index number used by all the primitives in this object.
Definition geomPrimitive.I:181
GeomPrimitive::get_shade_model
get_shade_model
Returns the ShadeModel hint for this primitive.
Definition geomPrimitive.h:77
GeomPrimitive::clear_minmax
void clear_minmax()
Undoes a previous call to set_minmax(), and allows the minimum and maximum values to be recomputed no...
Definition geomPrimitive.cxx:1386
GeomPrimitive::calc_sphere_radius
void calc_sphere_radius(const LPoint3 &center, PN_stdfloat &sq_radius, bool &found_any, const GeomVertexData *vertex_data, Thread *current_thread) const
Expands radius so that a sphere with the given center point fits all of the vertices.
Definition geomPrimitive.cxx:1826
GeomPrimitive::release_all
int release_all()
Frees the context allocated on all objects for which the data has been declared.
Definition geomPrimitive.cxx:1516
GeomPrimitive::get_primitive_num_vertices
int get_primitive_num_vertices(int n) const
Returns the number of vertices used by the nth primitive.
Definition geomPrimitive.cxx:758
GeomPrimitive::get_primitive_end
int get_primitive_end(int n) const
Returns the element within the _vertices list at which the nth primitive ends.
Definition geomPrimitive.cxx:735
GeomPrimitive::add_vertex
void add_vertex(int vertex)
Adds the indicated vertex to the list of vertex indices used by the graphics primitive type.
Definition geomPrimitive.cxx:161
GeomPrimitive::prepare
void prepare(PreparedGraphicsObjects *prepared_objects)
Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the be...
Definition geomPrimitive.cxx:1444
GeomPrimitive::is_indexed
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
Definition geomPrimitive.I:86
GeomPrimitive::prepare_now
IndexBufferContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the data on the particular GSG, if it does not already exist.
Definition geomPrimitive.cxx:1476
GeomPrimitive::set_minmax
void set_minmax(int min_vertex, int max_vertex, GeomVertexArrayData *mins, GeomVertexArrayData *maxs)
Explicitly specifies the minimum and maximum vertices, as well as the lists of per-component min and ...
Definition geomPrimitive.cxx:1365
GeomPrimitive::make_patches
ConstPointerTo< GeomPrimitive > make_patches() const
Decomposes a complex primitive type into a simpler primitive type, for instance triangle strips to tr...
Definition geomPrimitive.cxx:1086
GeomPrimitive::modify_vertices
PointerTo< GeomVertexArrayData > modify_vertices(int num_vertices=-1)
Returns a modifiable pointer to the vertex index list, so application code can directly fiddle with t...
Definition geomPrimitive.cxx:1229
GeomVertexArrayDataHandle
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
Definition geomVertexArrayData.h:250
GeomVertexArrayData
This is the data for one array of a GeomVertexData structure.
Definition geomVertexArrayData.h:58
GeomVertexArrayFormat
This describes the structure of a single array within a Geom data.
Definition geomVertexArrayFormat.h:47
GeomVertexDataPipelineReader
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
Definition geomVertexData.h:442
GeomVertexData
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
Definition geomVertexData.h:68
GraphicsStateGuardianBase
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Definition graphicsStateGuardianBase.h:110
IndexBufferContext
This is a special class object that holds all the information returned by a particular GSG to indicat...
Definition indexBufferContext.h:33
InternalName
Encodes a string name in a hash table, mapping it to a pointer.
Definition internalName.h:38
PreparedGraphicsObjects
A table of objects that are saved within the graphics context for reference by handle later.
Definition preparedGraphicsObjects.h:58
Thread
A thread; that is, a lightweight process.
Definition thread.h:46
Thread::get_current_thread
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition thread.h:109
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition typedWritable.h:35
TypedWritable::finalize
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
Definition typedWritable.cxx:113
TypedWritable::fillin
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
TypedWritable::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition typedWritable.cxx:81
UpdateSeq
This is a sequence number that increments monotonically.
Definition updateSeq.h:37
plist
This is our own Panda specialization on the default STL list.
Definition plist.h:35
copyOnWriteObject.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataStageReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataStageWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
deletedChain.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomEnums.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomPrimitive.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomVertexArrayData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomVertexData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatCollector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pipelineCycler.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_int.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
updateSeq.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.