15 #ifndef GEOMVERTEXDATA_H
16 #define GEOMVERTEXDATA_H
18 #include "pandabase.h"
19 #include "copyOnWriteObject.h"
20 #include "copyOnWritePointer.h"
21 #include "geomVertexFormat.h"
22 #include "geomVertexColumn.h"
23 #include "geomVertexArrayData.h"
24 #include "geomEnums.h"
25 #include "geomCacheEntry.h"
26 #include "transformTable.h"
27 #include "transformBlendTable.h"
28 #include "sliderTable.h"
29 #include "internalName.h"
30 #include "cycleData.h"
31 #include "cycleDataLockedReader.h"
32 #include "cycleDataReader.h"
33 #include "cycleDataWriter.h"
34 #include "cycleDataStageReader.h"
35 #include "cycleDataStageWriter.h"
36 #include "pipelineCycler.h"
37 #include "pStatCollector.h"
38 #include "pointerTo.h"
41 #include "deletedChain.h"
84 const GeomVertexFormat *format,
85 UsageHint usage_hint);
88 const GeomVertexFormat *format);
95 INLINE
const string &get_name()
const;
96 void set_name(
const string &name);
98 INLINE UsageHint get_usage_hint()
const;
99 void set_usage_hint(UsageHint usage_hint);
101 INLINE
const GeomVertexFormat *get_format()
const;
102 void set_format(
const GeomVertexFormat *format);
103 void unclean_set_format(
const GeomVertexFormat *format);
105 INLINE
bool has_column(
const InternalName *name)
const;
107 INLINE
int get_num_rows()
const;
108 INLINE
bool set_num_rows(
int n);
109 INLINE
bool unclean_set_num_rows(
int n);
110 INLINE
bool reserve_num_rows(
int n);
113 INLINE
int get_num_arrays()
const;
115 MAKE_SEQ(get_arrays, get_num_arrays, get_array);
121 INLINE
void clear_transform_table();
126 INLINE
void clear_transform_blend_table();
128 INLINE
const SliderTable *get_slider_table()
const;
130 INLINE
void clear_slider_table();
132 INLINE
int get_num_bytes()
const;
135 bool request_resident()
const;
137 void copy_from(
const GeomVertexData *source,
bool keep_data_objects,
140 int source_row,
Thread *current_thread);
141 CPT(
GeomVertexData) convert_to(
const GeomVertexFormat *new_format)
const;
143 scale_color(
const LVecBase4 &color_scale)
const;
145 scale_color(
const LVecBase4 &color_scale,
int num_components,
146 NumericType numeric_type, Contents contents)
const;
150 set_color(
const LColor &color,
int num_components,
151 NumericType numeric_type, Contents contents)
const;
156 void clear_animated_vertices();
157 void transform_vertices(
const LMatrix4 &mat);
158 void transform_vertices(
const LMatrix4 &mat,
int begin_row,
int end_row);
161 replace_column(InternalName *name,
int num_components,
162 NumericType numeric_type, Contents contents)
const;
164 void output(ostream &out)
const;
165 void write(ostream &out,
int indent_level = 0)
const;
166 void describe_vertex(ostream &out,
int row)
const;
169 void clear_cache_stage();
172 static INLINE PN_uint32 pack_abcd(
unsigned int a,
unsigned int b,
173 unsigned int c,
unsigned int d);
174 static INLINE
unsigned int unpack_abcd_a(PN_uint32 data);
175 static INLINE
unsigned int unpack_abcd_b(PN_uint32 data);
176 static INLINE
unsigned int unpack_abcd_c(PN_uint32 data);
177 static INLINE
unsigned int unpack_abcd_d(PN_uint32 data);
180 static void bytewise_copy(
unsigned char *to,
int to_stride,
181 const unsigned char *from,
int from_stride,
185 packed_argb_to_uint8_rgba(
unsigned char *to,
int to_stride,
186 const unsigned char *from,
int from_stride,
189 uint8_rgba_to_packed_argb(
unsigned char *to,
int to_stride,
190 const unsigned char *from,
int from_stride,
204 class EXPCL_PANDA_GOBJ CDataCache :
public CycleData {
207 INLINE CDataCache(
const CDataCache ©);
208 ALLOC_DELETED_CHAIN(CDataCache);
211 return GeomVertexData::get_class_type();
220 static void init_type() {
221 register_type(_type_handle,
"GeomVertexData::CDataCache");
238 INLINE
CacheKey(
const GeomVertexFormat *modifier);
239 INLINE CacheKey(
const CacheKey ©);
240 #ifdef USE_MOVE_SEMANTICS
241 INLINE CacheKey(CacheKey &&from) NOEXCEPT;
244 INLINE
bool operator < (
const CacheKey &other)
const;
246 CPT(GeomVertexFormat) _modifier;
252 const GeomVertexFormat *modifier);
254 #ifdef USE_MOVE_SEMANTICS
257 ALLOC_DELETED_CHAIN(CacheEntry);
259 virtual void evict_callback();
260 virtual void output(ostream &out)
const;
271 static void init_type() {
272 GeomCacheEntry::init_type();
273 register_type(_type_handle,
"GeomVertexData::CacheEntry",
274 GeomCacheEntry::get_class_type());
284 class EXPCL_PANDA_GOBJ CData :
public CycleData {
287 INLINE CData(
const CData ©);
288 ALLOC_DELETED_CHAIN(CData);
294 return GeomVertexData::get_class_type();
297 UsageHint _usage_hint;
298 CPT(GeomVertexFormat) _format;
311 static void init_type() {
312 register_type(_type_handle,
"GeomVertexData::CData");
330 void update_animated_vertices(CData *cdata,
Thread *current_thread);
331 void do_transform_point_column(
const GeomVertexFormat *format,
GeomVertexRewriter &data,
332 const LMatrix4 &mat,
int begin_row,
int end_row);
333 void do_transform_vector_column(
const GeomVertexFormat *format,
GeomVertexRewriter &data,
334 const LMatrix4 &mat,
int begin_row,
int end_row);
335 static void table_xform_point3f(
unsigned char *datat,
size_t num_rows,
337 static void table_xform_normal3f(
unsigned char *datat,
size_t num_rows,
339 static void table_xform_vector3f(
unsigned char *datat,
size_t num_rows,
341 static void table_xform_vecbase4f(
unsigned char *datat,
size_t num_rows,
355 static void register_with_read_factory();
358 virtual bool require_fully_complete()
const;
360 virtual void finalize(
BamReader *manager);
370 static void init_type() {
371 CopyOnWriteObject::init_type();
372 register_type(_type_handle,
"GeomVertexData",
373 CopyOnWriteObject::get_class_type());
374 CDataCache::init_type();
375 CacheEntry::init_type();
379 return get_class_type();
381 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
386 friend class CacheEntry;
402 GeomVertexData::CData *cdata);
405 INLINE ~GeomVertexDataPipelineBase();
408 INLINE
Thread *get_current_thread()
const;
410 INLINE
const GeomVertexFormat *get_format()
const;
411 INLINE
bool has_column(
const InternalName *name)
const;
413 INLINE UsageHint get_usage_hint()
const;
414 INLINE
int get_num_arrays()
const;
418 INLINE
const SliderTable *get_slider_table()
const;
419 int get_num_bytes()
const;
425 GeomVertexData::CData *_cdata;
437 INLINE GeomVertexDataPipelineReader(
const GeomVertexDataPipelineReader ©);
438 INLINE
void operator = (
const GeomVertexDataPipelineReader ©);
441 INLINE ~GeomVertexDataPipelineReader();
442 ALLOC_DELETED_CHAIN(GeomVertexDataPipelineReader);
446 INLINE
void check_array_readers()
const;
448 int get_num_rows()
const;
450 bool get_array_info(
const InternalName *name,
452 int &num_values, NumericType &numeric_type,
453 int &start,
int &stride)
const;
455 bool get_array_info(
const InternalName *name,
457 int &num_values, NumericType &numeric_type,
458 int &start,
int &stride,
int &divisor,
459 int &num_elements,
int &element_stride)
const;
461 INLINE
bool has_vertex()
const;
462 INLINE
bool is_vertex_transformed()
const;
464 int &num_values, NumericType &numeric_type,
465 int &start,
int &stride)
const;
467 INLINE
bool has_normal()
const;
469 NumericType &numeric_type,
470 int &start,
int &stride)
const;
472 INLINE
bool has_color()
const;
474 int &num_values, NumericType &numeric_type,
475 int &start,
int &stride)
const;
478 void make_array_readers();
479 void delete_array_readers();
481 bool _got_array_readers;
489 static void init_type() {
490 register_type(_type_handle,
"GeomVertexDataPipelineReader");
507 INLINE GeomVertexDataPipelineWriter(
const GeomVertexDataPipelineWriter ©);
508 INLINE
void operator = (
const GeomVertexDataPipelineWriter ©);
511 INLINE ~GeomVertexDataPipelineWriter();
512 ALLOC_DELETED_CHAIN(GeomVertexDataPipelineWriter);
516 INLINE
void check_array_writers()
const;
522 int get_num_rows()
const;
523 bool set_num_rows(
int n);
524 bool unclean_set_num_rows(
int n);
525 bool reserve_num_rows(
int n);
528 void make_array_writers();
529 void delete_array_writers();
532 bool _got_array_writers;
540 static void init_type() {
541 register_type(_type_handle,
"GeomVertexDataPipelineWriter");
548 INLINE ostream &operator << (ostream &out,
const GeomVertexData &obj);
550 #include "geomVertexData.I"
The common code from GeomVertexDataPipelineReader and GeomVertexDataPipelineWriter.
This is our own Panda specialization on the default STL map.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
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 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().
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
This defines how a single column is interleaved within a vertex array stored within a Geom...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
A lightweight class that represents a single element that may be timed and/or counted via stats...
Stores the total set of VertexSliders that the vertices in a particular GeomVertexData object might d...
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...
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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()...
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 is the base class for all three-component vectors and points.
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
An STL function object class, this is intended to be used on any ordered collection of class objects ...
This base class provides basic reference counting, but also can be used with a CopyOnWritePointer to ...
A thread; that is, a lightweight process.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
This object contains a single cache entry in the GeomCacheManager.
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.
This is a standard, non-reentrant mutex, similar to the Mutex class.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter, combined together into one convenient package.
This is the data for one array of a GeomVertexData structure.