14#ifndef GEOMVERTEXDATA_H
15#define GEOMVERTEXDATA_H
68class EXPCL_PANDA_GOBJ GeomVertexData :
public CopyOnWriteObject,
public GeomEnums {
72 virtual PT(CopyOnWriteObject) make_cow_copy();
75 explicit GeomVertexData(
const std::string &name,
77 UsageHint usage_hint);
78 GeomVertexData(
const GeomVertexData ©);
79 explicit GeomVertexData(
const GeomVertexData ©,
81 void operator = (
const GeomVertexData ©);
82 virtual ~GeomVertexData();
83 ALLOC_DELETED_CHAIN(GeomVertexData);
85 int compare_to(
const GeomVertexData &other)
const;
87 INLINE
const std::string &
get_name()
const;
88 void set_name(
const std::string &name);
125 INLINE
void clear_transform_blend_table();
139 void copy_from(
const GeomVertexData *source,
bool keep_data_objects,
141 void copy_row_from(
int dest_row,
const GeomVertexData *source,
142 int source_row,
Thread *current_thread);
147 scale_color(
const LVecBase4 &color_scale,
int num_components,
148 NumericType numeric_type, Contents contents)
const;
152 set_color(
const LColor &color,
int num_components,
153 NumericType numeric_type, Contents contents)
const;
165 NumericType numeric_type, Contents contents)
const;
167 void output(std::ostream &out)
const;
168 void write(std::ostream &out,
int indent_level = 0)
const;
175 static INLINE uint32_t
pack_abcd(
unsigned int a,
unsigned int b,
176 unsigned int c,
unsigned int d);
182 static INLINE uint32_t
pack_ufloat(
float a,
float b,
float c);
188 static void do_set_color(GeomVertexData *vdata,
const LColor &color);
190 static void bytewise_copy(
unsigned char *to,
int to_stride,
191 const unsigned char *from,
int from_stride,
195 packed_argb_to_uint8_rgba(
unsigned char *to,
int to_stride,
196 const unsigned char *from,
int from_stride,
199 uint8_rgba_to_packed_argb(
unsigned char *to,
int to_stride,
200 const unsigned char *from,
int from_stride,
203 typedef pmap<const VertexTransform *, int> TransformMap;
206 TransformMap &already_added);
214 class EXPCL_PANDA_GOBJ CDataCache :
public CycleData {
217 INLINE CDataCache(
const CDataCache ©);
218 ALLOC_DELETED_CHAIN(CDataCache);
221 return GeomVertexData::get_class_type();
230 static void init_type() {
235 static TypeHandle _type_handle;
237 typedef CycleDataReader<CDataCache> CDCacheReader;
238 typedef CycleDataWriter<CDataCache> CDCacheWriter;
245 class EXPCL_PANDA_GOBJ CacheKey {
248 INLINE CacheKey(
const CacheKey ©);
249 INLINE CacheKey(CacheKey &&from)
noexcept;
251 INLINE
bool operator < (
const CacheKey &other)
const;
256 class EXPCL_PANDA_GOBJ CacheEntry :
public GeomCacheEntry {
258 INLINE CacheEntry(GeomVertexData *source,
260 INLINE CacheEntry(GeomVertexData *source,
const CacheKey &key);
261 INLINE CacheEntry(GeomVertexData *source,
CacheKey &&key)
noexcept;
263 ALLOC_DELETED_CHAIN(CacheEntry);
266 virtual void output(std::ostream &out)
const;
268 GeomVertexData *_source;
277 static void init_type() {
278 GeomCacheEntry::init_type();
280 GeomCacheEntry::get_class_type());
290 class EXPCL_PANDA_GOBJ CData :
public CycleData {
295 ALLOC_DELETED_CHAIN(CData);
301 return GeomVertexData::get_class_type();
304 UsageHint _usage_hint;
318 static void init_type() {
323 static TypeHandle _type_handle;
326 PipelineCycler<CData> _cycler;
327 typedef CycleDataLockedReader<CData> CDLockedReader;
328 typedef CycleDataReader<CData> CDReader;
329 typedef CycleDataWriter<CData> CDWriter;
330 typedef CycleDataStageReader<CData> CDStageReader;
331 typedef CycleDataStageWriter<CData> CDStageWriter;
334 LightMutex _cache_lock;
337 void update_animated_vertices(CData *cdata, Thread *current_thread);
338 void do_transform_point_column(
const GeomVertexFormat *format, GeomVertexRewriter &data,
339 const LMatrix4 &mat,
int begin_row,
int end_row);
340 void do_transform_vector_column(
const GeomVertexFormat *format, GeomVertexRewriter &data,
341 const LMatrix4 &mat,
int begin_row,
int end_row);
342 static void table_xform_point3f(
unsigned char *datat,
size_t num_rows,
343 size_t stride,
const LMatrix4f &matf);
344 static void table_xform_normal3f(
unsigned char *datat,
size_t num_rows,
345 size_t stride,
const LMatrix4f &matf);
346 static void table_xform_vector3f(
unsigned char *datat,
size_t num_rows,
347 size_t stride,
const LMatrix4f &matf);
348 static void table_xform_vecbase4f(
unsigned char *datat,
size_t num_rows,
349 size_t stride,
const LMatrix4f &matf);
351 static PStatCollector _convert_pcollector;
352 static PStatCollector _scale_color_pcollector;
353 static PStatCollector _set_color_pcollector;
354 static PStatCollector _animation_pcollector;
356 PStatCollector _char_pcollector;
357 PStatCollector _skinning_pcollector;
358 PStatCollector _morphs_pcollector;
359 PStatCollector _blends_pcollector;
362 static void register_with_read_factory();
367 virtual void finalize(BamReader *manager);
370 static TypedWritable *make_from_bam(
const FactoryParams ¶ms);
371 void fillin(DatagramIterator &scan, BamReader *manager);
374 static TypeHandle get_class_type() {
377 static void init_type() {
378 CopyOnWriteObject::init_type();
380 CopyOnWriteObject::get_class_type());
381 CDataCache::init_type();
382 CacheEntry::init_type();
385 virtual TypeHandle get_type()
const {
386 return get_class_type();
388 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
391 static TypeHandle _type_handle;
393 friend class CacheEntry;
394 friend class GeomVertexDataPipelineBase;
395 friend class GeomVertexDataPipelineReader;
396 friend class GeomVertexDataPipelineWriter;
403class EXPCL_PANDA_GOBJ GeomVertexDataPipelineBase :
public GeomEnums {
405 INLINE GeomVertexDataPipelineBase(
Thread *current_thread);
408 GeomVertexData::CData *cdata);
411 GeomVertexDataPipelineBase(
const GeomVertexDataPipelineBase ©) =
delete;
412 INLINE ~GeomVertexDataPipelineBase();
414 GeomVertexDataPipelineBase &operator = (
const GeomVertexDataPipelineBase ©) =
delete;
416 INLINE
Thread *get_current_thread()
const;
421 INLINE UsageHint get_usage_hint()
const;
422 INLINE
size_t get_num_arrays()
const;
426 INLINE
const SliderTable *get_slider_table()
const;
427 int get_num_bytes()
const;
433 GeomVertexData::CData *_cdata;
442class EXPCL_PANDA_GOBJ GeomVertexDataPipelineReader :
public GeomVertexDataPipelineBase {
444 INLINE GeomVertexDataPipelineReader(
Thread *current_thread);
447 ALLOC_DELETED_CHAIN(GeomVertexDataPipelineReader);
452 INLINE
void check_array_readers()
const;
454 int get_num_rows()
const;
458 int &num_values, NumericType &numeric_type,
459 int &start,
int &stride)
const;
463 int &num_values, NumericType &numeric_type,
464 bool &normalized,
int &start,
int &stride,
int &divisor,
465 int &num_elements,
int &element_stride)
const;
467 INLINE
bool has_vertex()
const;
468 INLINE
bool is_vertex_transformed()
const;
470 int &num_values, NumericType &numeric_type,
471 int &start,
int &stride)
const;
473 INLINE
bool has_normal()
const;
475 NumericType &numeric_type,
476 int &start,
int &stride)
const;
478 INLINE
bool has_color()
const;
480 int &num_values, NumericType &numeric_type,
481 int &start,
int &stride)
const;
484 void make_array_readers();
486 bool _got_array_readers;
488 ArrayReaders _array_readers;
494 static void init_type() {
508class EXPCL_PANDA_GOBJ GeomVertexDataPipelineWriter :
public GeomVertexDataPipelineBase {
510 INLINE GeomVertexDataPipelineWriter(
GeomVertexData *
object,
bool force_to_0,
513 INLINE ~GeomVertexDataPipelineWriter();
514 ALLOC_DELETED_CHAIN(GeomVertexDataPipelineWriter);
518 INLINE
void check_array_writers()
const;
524 int get_num_rows()
const;
525 bool set_num_rows(
int n);
526 bool unclean_set_num_rows(
int n);
527 bool reserve_num_rows(
int n);
533 void make_array_writers();
534 void delete_array_writers();
536 bool _got_array_writers;
538 ArrayWriters _array_writers;
544 static void init_type() {
552INLINE std::ostream &operator << (std::ostream &out,
const GeomVertexData &obj);
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A single page of data maintained by a PipelineCycler.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
This is the data for one array of a GeomVertexData structure.
This defines how a single column is interleaved within a vertex array stored within a Geom.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
void copy_row_from(int dest_row, const GeomVertexDataPipelineReader &source, int source_row)
Copies a single row of the data from the other array into the indicated row of this array.
virtual void evict_callback()
Called when the entry is evicted from the cache, this should clean up the owning object appropriately...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
bool set_num_rows(int n)
Sets the length of the array to n rows in all of the various arrays (presumably by adding rows).
void copy_row_from(int dest_row, const GeomVertexData *source, int source_row, Thread *current_thread)
Copies a single row of the data from the other array into the indicated row of this array.
PointerTo< GeomVertexData > replace_column(InternalName *name, int num_components, NumericType numeric_type, Contents contents) const
Returns a new GeomVertexData object, suitable for modification, with the indicated data type replaced...
ConstPointerTo< GeomVertexData > scale_color(const LVecBase4 &color_scale) const
Returns a new GeomVertexData object with the color table modified in-place to apply the indicated sca...
static uint32_t pack_ufloat(float a, float b, float c)
Packs three float values in an unsigned 32-bit int.
get_name
Returns the name passed to the constructor, if any.
int compare_to(const GeomVertexData &other) const
Returns 0 if the two objects are equivalent, even if they are not the same pointer.
get_transform_table
Returns a const pointer to the TransformTable assigned to this data.
void clear_cache_stage()
Removes all of the previously-cached results of convert_to(), at the current pipeline stage and upstr...
static float unpack_ufloat_c(uint32_t data)
Unpacks an unsigned float10 value from an uint32.
set_format
Changes the format of the vertex data.
static float unpack_ufloat_a(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
void clear_transform_table()
Sets the TransformTable pointer to NULL, removing the table from the vertex data.
bool has_column(const InternalName *name) const
Returns true if the data has the named column, false otherwise.
int get_num_rows() const
Returns the number of rows stored within all the arrays.
static float unpack_ufloat_b(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
set_array
Replaces the indicated vertex data array with a completely new array.
bool reserve_num_rows(int n)
This ensures that enough memory space for n rows is allocated, so that you may increase the number of...
void describe_vertex(std::ostream &out, int row) const
Writes a verbose, human-friendly description of the indicated vertex number.
void clear_rows()
Removes all of the rows from the arrays; functionally equivalent to set_num_rows(0) (but faster).
get_num_arrays
Returns the number of individual arrays stored within the data.
get_slider_table
Returns a const pointer to the SliderTable assigned to this data.
set_usage_hint
Changes the UsageHint hint for this vertex data, and for all of the arrays that share this data.
void clear_animated_vertices()
Removes the cache of animated vertices computed by a previous call to animate_vertices() within the s...
set_transform_table
Replaces the TransformTable on this vertex data with the indicated table.
static unsigned int unpack_abcd_b(uint32_t data)
Returns the second packed value from a DirectX-style NT_packed_abcd.
ConstPointerTo< GeomVertexData > convert_to(const GeomVertexFormat *new_format) const
Returns a new GeomVertexData that represents the same contents as this one, with all data types match...
static unsigned int unpack_abcd_a(uint32_t data)
Returns the first packed value from a DirectX-style NT_packed_abcd.
set_slider_table
Replaces the SliderTable on this vertex data with the indicated table.
set_name
Changes the name of the vertex data.
get_num_bytes
Returns the total number of bytes consumed by the different arrays of the vertex data.
ConstPointerTo< GeomVertexData > set_color(const LColor &color) const
Returns a new GeomVertexData object with the color data modified in-place with the new value.
ConstPointerTo< GeomVertexData > animate_vertices(bool force, Thread *current_thread) const
Returns a GeomVertexData that represents the results of computing the vertex animation on the CPU for...
void set_transform_blend_table(const TransformBlendTable *table)
Replaces the TransformBlendTable on this vertex data with the indicated table.
static uint32_t pack_abcd(unsigned int a, unsigned int b, unsigned int c, unsigned int d)
Packs four values in a DirectX-style NT_packed_abcd value.
get_modified
Returns a sequence number which is guaranteed to change at least every time the vertex data is modifi...
static unsigned int unpack_abcd_c(uint32_t data)
Returns the third packed value from a DirectX-style NT_packed_abcd.
static unsigned int unpack_abcd_d(uint32_t data)
Returns the fourth packed value from a DirectX-style NT_packed_abcd.
PointerTo< TransformBlendTable > modify_transform_blend_table()
Returns a modifiable pointer to the current TransformBlendTable on this vertex data,...
get_format
Returns a pointer to the GeomVertexFormat structure that defines this data.
get_usage_hint
Returns the usage hint that was passed to the constructor, and which will be passed to each array dat...
bool unclean_set_num_rows(int n)
This method behaves like set_num_rows(), except the new data is not initialized.
void unclean_set_format(const GeomVertexFormat *format)
Changes the format of the vertex data, without reformatting the data to match.
bool request_resident() const
Returns true if the vertex data is currently resident in memory.
void copy_from(const GeomVertexData *source, bool keep_data_objects, Thread *current_thread=Thread::get_current_thread())
Copies all the data from the other array into the corresponding data types in this array,...
void clear_slider_table()
Sets the SliderTable pointer to NULL, removing the table from the vertex data.
void transform_vertices(const LMatrix4 &mat)
Applies the indicated transform matrix to all of the vertices in the GeomVertexData.
ConstPointerTo< GeomVertexData > reverse_normals() const
Returns a new GeomVertexData object with the normal data modified in-place, so that each lighting nor...
void clear_cache()
Removes all of the previously-cached results of convert_to().
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter,...
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
Encodes a string name in a hash table, mapping it to a pointer.
Stores the total set of VertexSliders that the vertices in a particular GeomVertexData object might d...
This class records a set of integers, where each integer is either present or not present in the set.
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.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual bool require_fully_complete() const
Some objects require all of their nested pointers to have been completed before the objects themselve...
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...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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 is a sequence number that increments monotonically.
This is our own Panda specialization on the default STL list.
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.
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...