Panda3D
Loading...
Searching...
No Matches
geomVertexRewriter.I
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 geomVertexRewriter.I
10 * @author drose
11 * @date 2005-03-28
12 */
13
14/**
15 * Constructs an invalid GeomVertexRewriter. You must use the assignment
16 * operator to assign a valid GeomVertexRewriter to this object before you can
17 * use it.
18 */
20GeomVertexRewriter(Thread *current_thread) :
21 GeomVertexWriter(current_thread),
22 GeomVertexReader(current_thread)
23{
24}
25
26/**
27 * Constructs a new rewriter to process the vertices of the indicated data
28 * object.
29 */
31GeomVertexRewriter(GeomVertexData *vertex_data, Thread *current_thread) :
32 GeomVertexWriter(vertex_data, current_thread),
33 GeomVertexReader(vertex_data, current_thread)
34{
35}
36
37/**
38 * Constructs a new rewriter to process the vertices of the indicated data
39 * object. This flavor creates the rewriter specifically to process the named
40 * data type.
41 */
44 Thread *current_thread) :
45 GeomVertexWriter(vertex_data, current_thread),
46 GeomVertexReader(vertex_data, current_thread)
47{
48 set_column(std::move(name));
49}
50
51/**
52 * Constructs a new rewriter to process the vertices of the indicated array
53 * only.
54 */
56GeomVertexRewriter(GeomVertexArrayData *array_data, Thread *current_thread) :
57 GeomVertexWriter(array_data, current_thread),
58 GeomVertexReader(array_data, current_thread)
59{
60}
61
62/**
63 * Constructs a new rewriter to process the vertices of the indicated array
64 * only.
65 */
67GeomVertexRewriter(GeomVertexArrayData *array_data, int column,
68 Thread *current_thread) :
69 GeomVertexWriter(array_data, current_thread),
70 GeomVertexReader(array_data, current_thread)
71{
72 set_column(column);
73}
74
75/**
76 *
77 */
80 GeomVertexWriter(copy),
82{
83}
84
85/**
86 *
87 */
88INLINE void GeomVertexRewriter::
89operator = (const GeomVertexRewriter &copy) {
90 GeomVertexWriter::operator = (copy);
91 GeomVertexReader::operator = (copy);
92}
93
94/**
95 *
96 */
97INLINE GeomVertexRewriter::
98~GeomVertexRewriter() {
99}
100
101/**
102 * Returns the vertex data object that the rewriter is processing.
103 */
110
111/**
112 * Returns the particular array object that the rewriter is currently
113 * processing.
114 */
121
122/**
123 * Returns the write handle to the array object that the rewriter is currently
124 * processing. This low-level call should be used with caution; be careful
125 * with modifying the data in the handle out from under the
126 * GeomVertexRewriter.
127 */
132
133/**
134 * Returns the per-row stride (bytes between consecutive rows) of the
135 * underlying vertex array. This low-level information is normally not needed
136 * to use the GeomVertexRewriter directly.
137 */
143
144/**
145 * Returns the Thread pointer of the currently-executing thread, as passed to
146 * the constructor of this object.
147 */
154
155/**
156 * Sets up the rewriter to use the nth data type of the GeomVertexFormat,
157 * numbering from 0.
158 *
159 * This also resets both the read and write row numbers to the start row (the
160 * same value passed to a previous call to set_row(), or 0 if set_row() was
161 * never called.)
162 *
163 * The return value is true if the data type is valid, false otherwise.
164 */
166set_column(int column) {
167 // It's important to invoke the writer first, then the reader. See
168 // set_row().
170 return GeomVertexReader::set_column(column);
171}
172
173/**
174 * Sets up the rewriter to use the data type with the indicated name.
175 *
176 * This also resets both the read and write row numbers to the start row (the
177 * same value passed to a previous call to set_row(), or 0 if set_row() was
178 * never called.)
179 *
180 * The return value is true if the data type is valid, false otherwise.
181 */
184 // It's important to invoke the writer first, then the reader. See
185 // set_row().
187 return GeomVertexReader::set_column(std::move(name));
188}
189
190/**
191 * Sets up the rewriter to use the indicated column description on the given
192 * array.
193 *
194 * This also resets both the read and write row numbers to the start row (the
195 * same value passed to a previous call to set_row(), or 0 if set_row() was
196 * never called.)
197 *
198 * The return value is true if the data type is valid, false otherwise.
199 */
201set_column(int array, const GeomVertexColumn *column) {
202 // It's important to invoke the writer first, then the reader. See
203 // set_row().
204 GeomVertexWriter::set_column(array, column);
205 return GeomVertexReader::set_column(array, column);
206}
207
208/**
209 * Resets the GeomVertexRewriter to the initial state.
210 */
216
217/**
218 * Returns true if a valid data type has been successfully set, or false if
219 * the data type does not exist.
220 */
222has_column() const {
223 nassertr(GeomVertexWriter::get_column() ==
226}
227
228/**
229 * Returns the array index containing the data type that the rewriter is
230 * working on.
231 */
233get_array() const {
234 nassertr(GeomVertexWriter::get_array() ==
237}
238
239/**
240 * Returns the description of the data type that the rewriter is working on.
241 */
248
249/**
250 * Sets the start row to the indicated value, without internal checks. This
251 * is the same as set_row(), but it does not check for the possibility that
252 * the array has been reallocated internally for some reason; use only when
253 * you are confident that the array is unchanged and you really need every bit
254 * of available performance.
255 */
257set_row_unsafe(int row) {
258 // It's important to invoke the Writer first, since that might force a
259 // recopy of the array, which might invalidate the pointer already stored by
260 // the Reader if we invoked the Reader first.
263}
264
265/**
266 * Sets the start, write, and write index to the indicated value. The
267 * rewriter will begin traversing from the given row.
268 */
270set_row(int row) {
273}
274
275/**
276 * Returns the row index at which the rewriter started. It will return to
277 * this row if you reset the current column.
278 */
285
286/**
287 * Returns true if the reader or writer is currently at the end of the list of
288 * vertices, false otherwise.
289 */
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
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.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
bool set_column(int column)
Sets up the reader to use the nth data type of the GeomVertexFormat, numbering from 0.
bool is_at_end() const
Returns true if the reader is currently at the end of the list of vertices, false otherwise.
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
int get_array() const
Returns the array index containing the data type that the reader is working on.
void clear()
Resets the GeomVertexReader to the initial state.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the reader is working on.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
const GeomVertexData * get_vertex_data() const
Returns the vertex data object that the reader is processing.
int get_start_row() const
Returns the row index at which the reader started.
void set_row(int row)
Sets the start row to the indicated value.
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array.
const GeomVertexArrayData * get_array_data() const
Returns the particular array object that the reader is currently processing.
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter,...
GeomVertexRewriter(Thread *current_thread=Thread::get_current_thread())
Constructs an invalid GeomVertexRewriter.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the rewriter is processing.
bool is_at_end() const
Returns true if the reader or writer is currently at the end of the list of vertices,...
void clear()
Resets the GeomVertexRewriter to the initial state.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the rewriter is working on.
int get_start_row() const
Returns the row index at which the rewriter started.
void set_row(int row)
Sets the start, write, and write index to the indicated value.
GeomVertexArrayData * get_array_data() const
Returns the particular array object that the rewriter is currently processing.
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array.
bool has_column() const
Returns true if a valid data type has been successfully set, or false if the data type does not exist...
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
bool set_column(int column)
Sets up the rewriter to use the nth data type of the GeomVertexFormat, numbering from 0.
GeomVertexArrayDataHandle * get_array_handle() const
Returns the write handle to the array object that the rewriter is currently processing.
int get_array() const
Returns the array index containing the data type that the rewriter is working on.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array.
bool set_column(int column)
Sets up the writer to use the nth data type of the GeomVertexFormat, numbering from 0.
void clear()
Resets the GeomVertexWriter to the initial state.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
bool is_at_end() const
Returns true if the writer is currently at the end of the list of vertices, false otherwise.
GeomVertexArrayDataHandle * get_array_handle() const
Returns the write handle to the array object that the writer is currently processing.
void set_row(int row)
Sets the start row to the indicated value.
bool has_column() const
Returns true if a valid data type has been successfully set, or false if the data type does not exist...
int get_array() const
Returns the array index containing the data type that the writer is working on.
GeomVertexArrayData * get_array_data() const
Returns the particular array object that the writer is currently processing.
int get_start_row() const
Returns the row index at which the writer started.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the writer is working on.
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the writer is processing.
A thread; that is, a lightweight process.
Definition thread.h:46