21 _vertex_data(nullptr),
22 _current_thread(current_thread)
33 _vertex_data(vertex_data),
34 _current_thread(current_thread)
47 _vertex_data(vertex_data),
48 _current_thread(current_thread)
61 _array_data(array_data),
62 _current_thread(current_thread)
74 _array_data(array_data),
75 _current_thread(current_thread)
89 _vertex_data(data_writer->get_object()),
90 _current_thread(data_writer->get_current_thread())
104 _vertex_data(copy._vertex_data),
106 _array_data(copy._array_data),
107 _current_thread(copy._current_thread),
108 _packer(copy._packer),
109 _stride(copy._stride),
110 _handle(copy._handle),
111 _pointer_begin(copy._pointer_begin),
112 _pointer_end(copy._pointer_end),
113 _pointer(copy._pointer),
114 _start_row(copy._start_row)
121 INLINE
void GeomVertexWriter::
123 _vertex_data = copy._vertex_data;
124 _array = copy._array;
125 _array_data = copy._array_data;
126 _current_thread = copy._current_thread;
127 _packer = copy._packer;
128 _stride = copy._stride;
129 _handle = copy._handle;
130 _pointer_begin = copy._pointer_begin;
131 _pointer_end = copy._pointer_end;
132 _pointer = copy._pointer;
133 _start_row = copy._start_row;
139 INLINE GeomVertexWriter::
140 ~GeomVertexWriter() {
187 return _current_thread;
202 if (_vertex_data !=
nullptr) {
204 writer.check_array_writers();
210 if (_array_data !=
nullptr) {
211 return set_array_column(_array_data->get_array_format()->get_column(column));
226 if (_vertex_data !=
nullptr) {
228 writer.check_array_writers();
234 if (_array_data !=
nullptr) {
235 return set_array_column(_array_data->get_array_format()->get_column(name));
254 return (_packer !=
nullptr);
271 if (_packer !=
nullptr) {
272 return _packer->_column;
288 quick_set_pointer(_start_row);
302 set_pointer(_start_row);
321 return (
int)(_pointer - _pointer_begin) / _stride;
331 return _pointer >= _pointer_end;
343 _packer->set_data1f(inc_pointer(), data);
366 _packer->set_data2f(inc_pointer(), data);
389 _packer->set_data3f(inc_pointer(), data);
412 _packer->set_data4f(inc_pointer(), data);
424 _packer->_column->get_contents() == C_matrix &&
425 _packer->_column->get_num_elements() == 3);
427 size_t col_stride = _packer->_column->get_element_stride();
428 unsigned char *pointer = inc_pointer();
430 _packer->set_data3f(pointer, mat.get_row(0));
431 pointer += col_stride;
432 _packer->set_data3f(pointer, mat.get_row(1));
433 pointer += col_stride;
434 _packer->set_data3f(pointer, mat.get_row(2));
446 _packer->_column->get_contents() == C_matrix &&
447 _packer->_column->get_num_elements() == 4);
449 size_t col_stride = _packer->_column->get_element_stride();
450 unsigned char *pointer = inc_pointer();
452 _packer->set_data4f(pointer, mat.get_row(0));
453 pointer += col_stride;
454 _packer->set_data4f(pointer, mat.get_row(1));
455 pointer += col_stride;
456 _packer->set_data4f(pointer, mat.get_row(2));
457 pointer += col_stride;
458 _packer->set_data4f(pointer, mat.get_row(3));
470 _packer->set_data1d(inc_pointer(), data);
493 _packer->set_data2d(inc_pointer(), data);
516 _packer->set_data3d(inc_pointer(), data);
539 _packer->set_data4d(inc_pointer(), data);
551 _packer->_column->get_contents() == C_matrix &&
552 _packer->_column->get_num_elements() == 3);
554 size_t col_stride = _packer->_column->get_element_stride();
555 unsigned char *pointer = inc_pointer();
557 _packer->set_data3d(pointer, mat.get_row(0));
558 pointer += col_stride;
559 _packer->set_data3d(pointer, mat.get_row(1));
560 pointer += col_stride;
561 _packer->set_data3d(pointer, mat.get_row(2));
573 _packer->_column->get_contents() == C_matrix &&
574 _packer->_column->get_num_elements() == 4);
576 size_t col_stride = _packer->_column->get_element_stride();
577 unsigned char *pointer = inc_pointer();
579 _packer->set_data4d(pointer, mat.get_row(0));
580 pointer += col_stride;
581 _packer->set_data4d(pointer, mat.get_row(1));
582 pointer += col_stride;
583 _packer->set_data4d(pointer, mat.get_row(2));
584 pointer += col_stride;
585 _packer->set_data4d(pointer, mat.get_row(3));
596 #ifndef STDFLOAT_DOUBLE 611 #ifndef STDFLOAT_DOUBLE 626 #ifndef STDFLOAT_DOUBLE 640 set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
641 #ifndef STDFLOAT_DOUBLE 656 #ifndef STDFLOAT_DOUBLE 670 set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) {
671 #ifndef STDFLOAT_DOUBLE 686 #ifndef STDFLOAT_DOUBLE 701 #ifndef STDFLOAT_DOUBLE 716 #ifndef STDFLOAT_DOUBLE 732 _packer->set_data1i(inc_pointer(), data);
755 _packer->set_data2i(inc_pointer(), data);
778 _packer->set_data3i(inc_pointer(), data);
801 _packer->set_data4i(inc_pointer(), data);
814 _packer->set_data1f(inc_add_pointer(), data);
839 _packer->set_data2f(inc_add_pointer(), data);
864 _packer->set_data3f(inc_add_pointer(), data);
889 _packer->set_data4f(inc_add_pointer(), data);
902 _packer->_column->get_contents() == C_matrix &&
903 _packer->_column->get_num_elements() == 3);
905 size_t col_stride = _packer->_column->get_element_stride();
906 unsigned char *pointer = inc_add_pointer();
908 _packer->set_data3f(pointer, mat.get_row(0));
909 pointer += col_stride;
910 _packer->set_data3f(pointer, mat.get_row(1));
911 pointer += col_stride;
912 _packer->set_data3f(pointer, mat.get_row(2));
925 _packer->_column->get_contents() == C_matrix &&
926 _packer->_column->get_num_elements() == 4);
928 size_t col_stride = _packer->_column->get_element_stride();
929 unsigned char *pointer = inc_add_pointer();
931 _packer->set_data4f(pointer, mat.get_row(0));
932 pointer += col_stride;
933 _packer->set_data4f(pointer, mat.get_row(1));
934 pointer += col_stride;
935 _packer->set_data4f(pointer, mat.get_row(2));
936 pointer += col_stride;
937 _packer->set_data4f(pointer, mat.get_row(3));
950 _packer->set_data1d(inc_add_pointer(), data);
975 _packer->set_data2d(inc_add_pointer(), data);
1000 _packer->set_data3d(inc_add_pointer(), data);
1025 _packer->set_data4d(inc_add_pointer(), data);
1038 _packer->_column->get_contents() == C_matrix &&
1039 _packer->_column->get_num_elements() == 3);
1041 size_t col_stride = _packer->_column->get_element_stride();
1042 unsigned char *pointer = inc_add_pointer();
1044 _packer->set_data3d(pointer, mat.get_row(0));
1045 pointer += col_stride;
1046 _packer->set_data3d(pointer, mat.get_row(1));
1047 pointer += col_stride;
1048 _packer->set_data3d(pointer, mat.get_row(2));
1061 _packer->_column->get_contents() == C_matrix &&
1062 _packer->_column->get_num_elements() == 4);
1064 size_t col_stride = _packer->_column->get_element_stride();
1065 unsigned char *pointer = inc_add_pointer();
1067 _packer->set_data4d(pointer, mat.get_row(0));
1068 pointer += col_stride;
1069 _packer->set_data4d(pointer, mat.get_row(1));
1070 pointer += col_stride;
1071 _packer->set_data4d(pointer, mat.get_row(2));
1072 pointer += col_stride;
1073 _packer->set_data4d(pointer, mat.get_row(3));
1085 #ifndef STDFLOAT_DOUBLE 1101 #ifndef STDFLOAT_DOUBLE 1117 #ifndef STDFLOAT_DOUBLE 1133 #ifndef STDFLOAT_DOUBLE 1149 #ifndef STDFLOAT_DOUBLE 1164 add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) {
1165 #ifndef STDFLOAT_DOUBLE 1181 #ifndef STDFLOAT_DOUBLE 1197 #ifndef STDFLOAT_DOUBLE 1213 #ifndef STDFLOAT_DOUBLE 1230 _packer->set_data1i(inc_add_pointer(), data);
1255 _packer->set_data2i(inc_add_pointer(), data);
1280 _packer->set_data3i(inc_add_pointer(), data);
1305 _packer->set_data4i(inc_add_pointer(), data);
1311 INLINE GeomVertexColumn::Packer *GeomVertexWriter::
1312 get_packer()
const {
1321 INLINE
void GeomVertexWriter::
1322 set_pointer(
int row) {
1323 _pointer_begin = _handle->get_write_pointer();
1324 _pointer_end = _pointer_begin + _handle->get_data_size_bytes();
1325 quick_set_pointer(row);
1332 INLINE
void GeomVertexWriter::
1333 quick_set_pointer(
int row) {
1338 nassertv(_pointer_begin == _handle->get_write_pointer());
1341 _pointer = _pointer_begin + _packer->_column->get_start() + _stride * row;
1346 nassertv(_pointer_begin == _pointer_end || (_pointer - _packer->_column->get_start()) <= _pointer_end);
1354 INLINE
unsigned char *GeomVertexWriter::
1357 nassertr(_pointer < _pointer_end, empty_buffer);
1359 nassertr(_pointer_begin == _handle->get_write_pointer(), empty_buffer);
1360 nassertr(_pointer < _pointer_begin + _handle->get_data_size_bytes(), empty_buffer);
1363 unsigned char *orig_pointer = _pointer;
1364 _pointer += _stride;
1365 return orig_pointer;
1373 INLINE
unsigned char *GeomVertexWriter::
1375 if (_pointer >= _pointer_end) {
1379 if (_vertex_data !=
nullptr) {
1384 writer.check_array_writers();
1385 writer.set_num_rows(std::max(write_row + 1, writer.get_num_rows()));
1386 _handle = writer.get_array_writer(_array);
1391 _handle->set_num_rows(std::max(write_row + 1, _handle->get_num_rows()));
1394 set_pointer(write_row);
1396 return inc_pointer();
void add_data4f(float x, float y, float z, float w)
Sets the write row to a particular 4-component value, and advances the write row.
void add_data1d(double data)
Sets the write row to a particular 1-component value, and advances the write row.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
void set_matrix3f(const LMatrix3f &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
void set_data2i(int a, int b)
Sets the write row to a particular 2-component value, and advances the write row.
void set_matrix4f(const LMatrix4f &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
void add_data2i(int a, int b)
Sets the write row to a particular 2-component value, and advances the write row.
void set_data3i(int a, int b, int c)
Sets the write row to a particular 3-component value, and advances the write row.
void add_data1i(int data)
Sets the write row to a particular 1-component value, and advances the write row.
void set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row.
void add_data2f(float x, float y)
Sets the write row to a particular 2-component value, and advances the write row.
void set_data4i(int a, int b, int c, int d)
Sets the write row to a particular 4-component value, and advances the write row.
void clear()
Resets the GeomVertexWriter to the initial state.
int get_array() const
Returns the array index containing the data type that the writer is working on.
void add_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row.
void set_data1i(int data)
Sets the write row to a particular 1-component value, and advances the write row.
void set_matrix3(const LMatrix3 &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
void add_data3i(int a, int b, int c)
Sets the write row to a particular 3-component value, and advances the write row.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
void add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row.
void set_data2d(double x, double y)
Sets the write row to a particular 2-component value, and advances the write row.
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.
void add_data2d(double x, double y)
Sets the write row to a particular 2-component value, and advances the write row.
void set_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row.
void add_data1f(float data)
Sets the write row to a particular 1-component value, and advances the write row.
GeomVertexArrayDataHandle * get_array_handle() const
Returns the write handle to the array object that the writer is currently processing.
void set_data3f(float x, float y, float z)
Sets the write row to a particular 3-component value, and advances the write row.
bool is_at_end() const
Returns true if the writer is currently at the end of the list of vertices, false otherwise.
void set_data3d(double x, double y, double z)
Sets the write row to a particular 3-component value, and advances the write row.
void set_data1f(float data)
Sets the write row to a particular 1-component value, and advances the write row.
void set_data4d(double x, double y, double z, double w)
Sets the write row to a particular 4-component value, and advances the write row.
void add_data4d(double x, double y, double z, double w)
Sets the write row to a particular 4-component value, and advances the write row.
void set_data4f(float x, float y, float z, float w)
Sets the write row to a particular 4-component value, and advances the write row.
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
void set_data1(PN_stdfloat data)
Sets the write row to a particular 1-component value, and advances the write row.
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row.
void set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row.
void add_matrix4(const LMatrix4 &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void add_data3d(double x, double y, double z)
Sets the write row to a particular 3-component value, and advances the write row.
Encodes a string name in a hash table, mapping it to a pointer.
void add_matrix4f(const LMatrix4f &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void add_data3f(float x, float y, float z)
Sets the write row to a particular 3-component value, and advances the write row.
void add_matrix3(const LMatrix3 &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
void add_data1(PN_stdfloat data)
Sets the write row to a particular 1-component value, and advances the write row.
void add_matrix3d(const LMatrix3d &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
bool has_column() const
Returns true if a valid data type has been successfully set, or false if the data type does not exist...
void set_matrix3d(const LMatrix3d &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
A thread; that is, a lightweight process.
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
void set_matrix4(const LMatrix4 &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void set_matrix4d(const LMatrix4d &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
GeomVertexArrayData * get_array_data() const
Returns the particular array object that the writer is currently processing.
void set_data2f(float x, float y)
Sets the write row to a particular 2-component value, and advances the write row.
void add_matrix3f(const LMatrix3f &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
bool set_column(int column)
Sets up the writer to use the nth data type of the GeomVertexFormat, numbering from 0.
void set_row(int row)
Sets the start row to the indicated value.
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the writer is processing.
void add_matrix4d(const LMatrix4d &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void set_data1d(double data)
Sets the write row to a particular 1-component value, and advances the write row.
GeomVertexWriter(Thread *current_thread=Thread::get_current_thread())
Constructs an invalid GeomVertexWriter.
int get_write_row() const
Returns the row index to which the data will be written at the next call to set_data*() or add_data*(...
int get_start_row() const
Returns the row index at which the writer started.
This is the data for one array of a GeomVertexData structure.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the writer is working on.
void add_data4i(int a, int b, int c, int d)
Sets the write row to a particular 4-component value, and advances the write row.