15 #ifndef GEOMPRIMITIVE_H
16 #define GEOMPRIMITIVE_H
18 #include "pandabase.h"
19 #include "geomEnums.h"
20 #include "geomVertexArrayData.h"
21 #include "geomVertexData.h"
22 #include "copyOnWriteObject.h"
24 #include "updateSeq.h"
25 #include "pointerTo.h"
27 #include "pStatCollector.h"
28 #include "cycleData.h"
29 #include "cycleDataReader.h"
30 #include "cycleDataWriter.h"
31 #include "cycleDataStageReader.h"
32 #include "cycleDataStageWriter.h"
33 #include "pipelineCycler.h"
34 #include "deletedChain.h"
77 virtual PrimitiveType get_primitive_type()
const=0;
78 virtual int get_geom_rendering()
const;
80 INLINE ShadeModel get_shade_model()
const;
81 INLINE
void set_shade_model(ShadeModel shade_model);
83 INLINE UsageHint get_usage_hint()
const;
84 void set_usage_hint(UsageHint usage_hint);
86 INLINE NumericType get_index_type()
const;
87 void set_index_type(NumericType index_type);
96 INLINE
bool is_composite()
const;
97 INLINE
bool is_indexed()
const;
98 INLINE
int get_first_vertex()
const;
99 INLINE
int get_num_vertices()
const;
100 INLINE
int get_vertex(
int i)
const;
101 MAKE_SEQ(get_vertex_list, get_num_vertices, get_vertex);
102 void add_vertex(
int vertex);
103 INLINE
void add_vertices(
int v1,
int v2);
104 INLINE
void add_vertices(
int v1,
int v2,
int v3);
105 INLINE
void add_vertices(
int v1,
int v2,
int v3,
int v4);
106 void add_consecutive_vertices(
int start,
int num_vertices);
107 void add_next_vertices(
int num_vertices);
108 void reserve_num_vertices(
int num_vertices);
109 bool close_primitive();
110 void clear_vertices();
111 void offset_vertices(
int offset);
112 void offset_vertices(
int offset,
int begin_row,
int end_row);
117 INLINE
int get_num_primitives()
const;
118 int get_primitive_start(
int n)
const;
119 int get_primitive_end(
int n)
const;
120 int get_primitive_num_vertices(
int n)
const;
121 int get_num_used_vertices()
const;
123 INLINE
int get_num_faces()
const;
124 INLINE
int get_primitive_num_faces(
int n)
const;
126 INLINE
int get_min_vertex()
const;
127 int get_primitive_min_vertex(
int n)
const;
128 INLINE
int get_max_vertex()
const;
129 int get_primitive_max_vertex(
int n)
const;
135 CPT(
GeomPrimitive) match_shade_model(ShadeModel shade_model)
const;
140 int get_num_bytes()
const;
141 INLINE
int get_data_size_bytes()
const;
144 bool request_resident()
const;
148 virtual void output(ostream &out)
const;
149 virtual void write(ostream &out,
int indent_level)
const;
165 void set_nonindexed_vertices(
int first_vertex,
int num_vertices);
167 INLINE
int get_index_stride()
const;
168 INLINE
int get_strip_cut_index()
const;
171 PTA_int modify_ends();
177 void set_minmax(
int min_vertex,
int max_vertex,
181 virtual int get_num_vertices_per_primitive()
const;
182 virtual int get_min_num_vertices_per_primitive()
const;
183 virtual int get_num_unused_vertices_per_primitive()
const;
194 static const GeomVertexArrayFormat *get_index_format(NumericType index_type);
195 INLINE
const GeomVertexArrayFormat *get_index_format()
const;
199 static CPT(GeomVertexArrayFormat) make_index_format(NumericType index_type);
202 static int get_highest_index_value(NumericType index_type);
203 static int get_strip_cut_index(NumericType index_type);
211 PN_stdfloat &sq_center_dist,
bool &found_any,
214 const InternalName *column_name,
215 Thread *current_thread)
const;
217 void calc_sphere_radius(
const LPoint3 ¢er,
218 PN_stdfloat &sq_radius,
bool &found_any,
220 Thread *current_thread)
const;
227 virtual bool requires_unused_vertices()
const;
234 void recompute_minmax(CData *cdata);
235 void do_make_indexed(CData *cdata);
236 void consider_elevate_index_type(CData *cdata,
int vertex);
237 void do_set_index_type(CData *cdata, NumericType index_type);
250 class EXPCL_PANDA_GOBJ CData :
public CycleData {
253 INLINE CData(
const CData ©);
254 ALLOC_DELETED_CHAIN(CData);
261 return GeomPrimitive::get_class_type();
264 ShadeModel _shade_model;
267 NumericType _index_type;
268 UsageHint _usage_hint;
276 unsigned int _min_vertex;
277 unsigned int _max_vertex;
283 static void init_type() {
284 register_type(_type_handle,
"GeomPrimitive::CData");
317 static void init_type() {
318 CopyOnWriteObject::init_type();
319 register_type(_type_handle,
"GeomPrimitive",
320 CopyOnWriteObject::get_class_type());
324 return get_class_type();
326 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
345 INLINE GeomPrimitivePipelineReader(
const GeomPrimitivePipelineReader ©);
346 INLINE
void operator = (
const GeomPrimitivePipelineReader ©);
349 INLINE ~GeomPrimitivePipelineReader();
350 ALLOC_DELETED_CHAIN(GeomPrimitivePipelineReader);
353 INLINE
Thread *get_current_thread()
const;
355 void check_minmax()
const;
357 INLINE ShadeModel get_shade_model()
const;
358 INLINE UsageHint get_usage_hint()
const;
359 INLINE NumericType get_index_type()
const;
360 INLINE
bool is_indexed()
const;
361 int get_first_vertex()
const;
362 INLINE
int get_num_vertices()
const;
363 int get_vertex(
int i)
const;
364 int get_num_primitives()
const;
365 INLINE
int get_min_vertex()
const;
366 INLINE
int get_max_vertex()
const;
367 INLINE
int get_data_size_bytes()
const;
370 INLINE
int get_index_stride()
const;
372 INLINE
const unsigned char *get_read_pointer(
bool force)
const;
373 INLINE
int get_strip_cut_index()
const;
384 const GeomPrimitive::CData *_cdata;
392 static void init_type() {
393 register_type(_type_handle,
"GeomPrimitivePipelineReader");
400 INLINE ostream &operator << (ostream &out,
const GeomPrimitive &obj);
402 #include "geomPrimitive.I"
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is a special class object that holds all the information returned by a particular GSG to indicat...
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
A single page of data maintained by a PipelineCycler.
Base class for objects that can be written to and read from Bam files.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is our own Panda specialization on the default STL list.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
A table of objects that are saved within the graphics context for reference by handle later...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This is a 4-by-4 transform matrix.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
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...
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
This base class provides basic reference counting, but also can be used with a CopyOnWritePointer to ...
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.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
A class to retrieve the individual data elements previously stored in a Datagram. ...
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Similar to PointerToArray, except that its contents may not be modified.
This is the data for one array of a GeomVertexData structure.