Panda3D
 All Classes Functions Variables Enumerations
geomVertexRewriter.I
1 // Filename: geomVertexRewriter.I
2 // Created by: drose (28Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: GeomVertexRewriter::Default Constructor
18 // Access: Published
19 // Description: Constructs an invalid GeomVertexRewriter. You must use
20 // the assignment operator to assign a valid
21 // GeomVertexRewriter to this object before you can use
22 // it.
23 ////////////////////////////////////////////////////////////////////
25 GeomVertexRewriter(Thread *current_thread) :
26  GeomVertexWriter(current_thread),
27  GeomVertexReader(current_thread)
28 {
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: GeomVertexRewriter::Constructor
33 // Access: Published
34 // Description: Constructs a new rewriter to process the vertices of
35 // the indicated data object.
36 ////////////////////////////////////////////////////////////////////
38 GeomVertexRewriter(GeomVertexData *vertex_data, Thread *current_thread) :
39  GeomVertexWriter(vertex_data, current_thread),
40  GeomVertexReader(vertex_data, current_thread)
41 {
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: GeomVertexRewriter::Constructor
46 // Access: Published
47 // Description: Constructs a new rewriter to process the vertices of
48 // the indicated data object. This flavor creates the
49 // rewriter specifically to process the named data type.
50 ////////////////////////////////////////////////////////////////////
53  Thread *current_thread) :
54  GeomVertexWriter(vertex_data, current_thread),
55  GeomVertexReader(vertex_data, current_thread)
56 {
57  set_column(MOVE(name));
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: GeomVertexRewriter::Constructor
62 // Access: Published
63 // Description: Constructs a new rewriter to process the vertices of
64 // the indicated array only.
65 ////////////////////////////////////////////////////////////////////
67 GeomVertexRewriter(GeomVertexArrayData *array_data, Thread *current_thread) :
68  GeomVertexWriter(array_data, current_thread),
69  GeomVertexReader(array_data, current_thread)
70 {
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: GeomVertexRewriter::Constructor
75 // Access: Published
76 // Description: Constructs a new rewriter to process the vertices of
77 // the indicated array only.
78 ////////////////////////////////////////////////////////////////////
80 GeomVertexRewriter(GeomVertexArrayData *array_data, int column,
81  Thread *current_thread) :
82  GeomVertexWriter(array_data, current_thread),
83  GeomVertexReader(array_data, current_thread)
84 {
85  set_column(column);
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: GeomVertexRewriter::Copy Constructor
90 // Access: Published
91 // Description:
92 ////////////////////////////////////////////////////////////////////
95  GeomVertexWriter(copy),
96  GeomVertexReader(copy)
97 {
98 }
99 
100 ////////////////////////////////////////////////////////////////////
101 // Function: GeomVertexRewriter::Copy Assignment Operator
102 // Access: Published
103 // Description:
104 ////////////////////////////////////////////////////////////////////
105 INLINE void GeomVertexRewriter::
106 operator = (const GeomVertexRewriter &copy) {
107  GeomVertexWriter::operator = (copy);
108  GeomVertexReader::operator = (copy);
109 }
110 
111 ////////////////////////////////////////////////////////////////////
112 // Function: GeomVertexRewriter::Destructor
113 // Access: Published
114 // Description:
115 ////////////////////////////////////////////////////////////////////
116 INLINE GeomVertexRewriter::
117 ~GeomVertexRewriter() {
118 }
119 
120 ////////////////////////////////////////////////////////////////////
121 // Function: GeomVertexRewriter::get_vertex_data
122 // Access: Published
123 // Description: Returns the vertex data object that the
124 // rewriter is processing.
125 ////////////////////////////////////////////////////////////////////
128  nassertr(GeomVertexWriter::get_vertex_data() ==
131 }
132 
133 ////////////////////////////////////////////////////////////////////
134 // Function: GeomVertexRewriter::get_array_data
135 // Access: Published
136 // Description: Returns the particular array object that the
137 // rewriter is currently processing.
138 ////////////////////////////////////////////////////////////////////
140 get_array_data() const {
141  nassertr(GeomVertexWriter::get_array_data() ==
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: GeomVertexRewriter::get_array_handle
148 // Access: Published
149 // Description: Returns the write handle to the array object that the
150 // rewriter is currently processing. This low-level call
151 // should be used with caution; be careful with
152 // modifying the data in the handle out from under the
153 // GeomVertexRewriter.
154 ////////////////////////////////////////////////////////////////////
158 }
159 
160 ////////////////////////////////////////////////////////////////////
161 // Function: GeomVertexRewriter::get_stride
162 // Access: Published
163 // Description: Returns the per-row stride (bytes between consecutive
164 // rows) of the underlying vertex array. This low-level
165 // information is normally not needed to use the
166 // GeomVertexRewriter directly.
167 ////////////////////////////////////////////////////////////////////
168 INLINE size_t GeomVertexRewriter::
169 get_stride() const {
172 }
173 
174 ////////////////////////////////////////////////////////////////////
175 // Function: GeomVertexRewriter::get_current_thread
176 // Access: Published
177 // Description: Returns the Thread pointer of the currently-executing
178 // thread, as passed to the constructor of this object.
179 ////////////////////////////////////////////////////////////////////
185 }
186 
187 ////////////////////////////////////////////////////////////////////
188 // Function: GeomVertexRewriter::set_column
189 // Access: Published
190 // Description: Sets up the rewriter to use the nth data type of the
191 // GeomVertexFormat, numbering from 0.
192 //
193 // This also resets both the read and write row
194 // numbers to the start row (the same value passed to
195 // a previous call to set_row(), or 0 if set_row()
196 // was never called.)
197 //
198 // The return value is true if the data type is valid,
199 // false otherwise.
200 ////////////////////////////////////////////////////////////////////
201 INLINE bool GeomVertexRewriter::
202 set_column(int column) {
203  // It's important to invoke the writer first, then the reader. See
204  // set_row().
206  return GeomVertexReader::set_column(column);
207 }
208 
209 ////////////////////////////////////////////////////////////////////
210 // Function: GeomVertexRewriter::set_column
211 // Access: Published
212 // Description: Sets up the rewriter to use the data type with the
213 // indicated name.
214 //
215 // This also resets both the read and write row
216 // numbers to the start row (the same value passed to
217 // a previous call to set_row(), or 0 if set_row()
218 // was never called.)
219 //
220 // The return value is true if the data type is valid,
221 // false otherwise.
222 ////////////////////////////////////////////////////////////////////
223 INLINE bool GeomVertexRewriter::
225  // It's important to invoke the writer first, then the reader. See
226  // set_row().
228  return GeomVertexReader::set_column(MOVE(name));
229 }
230 
231 ////////////////////////////////////////////////////////////////////
232 // Function: GeomVertexRewriter::set_column
233 // Access: Published
234 // Description: Sets up the rewriter to use the indicated column
235 // description on the given array.
236 //
237 // This also resets both the read and write row
238 // numbers to the start row (the same value passed to
239 // a previous call to set_row(), or 0 if set_row()
240 // was never called.)
241 //
242 // The return value is true if the data type is valid,
243 // false otherwise.
244 ////////////////////////////////////////////////////////////////////
245 INLINE bool GeomVertexRewriter::
246 set_column(int array, const GeomVertexColumn *column) {
247  // It's important to invoke the writer first, then the reader. See
248  // set_row().
249  GeomVertexWriter::set_column(array, column);
250  return GeomVertexReader::set_column(array, column);
251 }
252 
253 ////////////////////////////////////////////////////////////////////
254 // Function: GeomVertexRewriter::clear
255 // Access: Published
256 // Description: Resets the GeomVertexRewriter to the initial state.
257 ////////////////////////////////////////////////////////////////////
258 INLINE void GeomVertexRewriter::
259 clear() {
262 }
263 
264 ////////////////////////////////////////////////////////////////////
265 // Function: GeomVertexRewriter::has_column
266 // Access: Published
267 // Description: Returns true if a valid data type has been
268 // successfully set, or false if the data type does not
269 // exist.
270 ////////////////////////////////////////////////////////////////////
271 INLINE bool GeomVertexRewriter::
272 has_column() const {
273  nassertr(GeomVertexWriter::get_column() ==
276 }
277 
278 ////////////////////////////////////////////////////////////////////
279 // Function: GeomVertexRewriter::get_array
280 // Access: Published
281 // Description: Returns the array index containing the data type that
282 // the rewriter is working on.
283 ////////////////////////////////////////////////////////////////////
284 INLINE int GeomVertexRewriter::
285 get_array() const {
286  nassertr(GeomVertexWriter::get_array() ==
289 }
290 
291 ////////////////////////////////////////////////////////////////////
292 // Function: GeomVertexRewriter::get_column
293 // Access: Published
294 // Description: Returns the description of the data type that the
295 // rewriter is working on.
296 ////////////////////////////////////////////////////////////////////
298 get_column() const {
299  nassertr(GeomVertexWriter::get_column() ==
302 }
303 
304 ////////////////////////////////////////////////////////////////////
305 // Function: GeomVertexRewriter::set_row_unsafe
306 // Access: Published
307 // Description: Sets the start row to the indicated value, without
308 // internal checks. This is the same as set_row(), but
309 // it does not check for the possibility that the array
310 // has been reallocated internally for some reason; use
311 // only when you are confident that the array is
312 // unchanged and you really need every bit of available
313 // performance.
314 ////////////////////////////////////////////////////////////////////
315 INLINE void GeomVertexRewriter::
316 set_row_unsafe(int row) {
317  // It's important to invoke the Writer first, since that might force
318  // a recopy of the array, which might invalidate the pointer already
319  // stored by the Reader if we invoked the Reader first.
322 }
323 
324 ////////////////////////////////////////////////////////////////////
325 // Function: GeomVertexRewriter::set_row
326 // Access: Published
327 // Description: Sets the start, write, and write index to the
328 // indicated value. The rewriter will begin traversing
329 // from the given row.
330 ////////////////////////////////////////////////////////////////////
331 INLINE void GeomVertexRewriter::
332 set_row(int row) {
335 }
336 
337 ////////////////////////////////////////////////////////////////////
338 // Function: GeomVertexRewriter::get_start_row
339 // Access: Published
340 // Description: Returns the row index at which the rewriter
341 // started. It will return to this row if you reset
342 // the current column.
343 ////////////////////////////////////////////////////////////////////
344 INLINE int GeomVertexRewriter::
345 get_start_row() const {
346  nassertr(GeomVertexWriter::get_start_row() ==
349 }
350 
351 ////////////////////////////////////////////////////////////////////
352 // Function: GeomVertexRewriter::is_at_end
353 // Access: Published
354 // Description: Returns true if the reader or writer is currently at
355 // the end of the list of vertices, false otherwise.
356 ////////////////////////////////////////////////////////////////////
357 INLINE bool GeomVertexRewriter::
358 is_at_end() const {
360 }
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
Definition: internalName.h:197
int get_array() const
Returns the array index containing the data type that the reader is working on.
GeomVertexArrayDataHandle * get_array_handle() const
Returns the write handle to the array object that the writer is currently processing.
bool set_column(int column)
Sets up the reader to use the nth data type of the GeomVertexFormat, numbering from 0...
void clear()
Resets the GeomVertexWriter to the initial state.
const GeomVertexArrayData * get_array_data() const
Returns the particular array object that the reader is currently processing.
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
const GeomVertexData * get_vertex_data() const
Returns the vertex data object that the reader is processing.
bool is_at_end() const
Returns true if the reader is currently at the end of the list of vertices, false otherwise...
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
bool set_column(int column)
Sets up the rewriter to use the nth data type of the GeomVertexFormat, numbering from 0...
This defines how a single column is interleaved within a vertex array stored within a Geom...
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the rewriter is processing.
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array...
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array...
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
GeomVertexRewriter(Thread *current_thread=Thread::get_current_thread())
Constructs an invalid GeomVertexRewriter.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the reader is working on.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
GeomVertexArrayData * get_array_data() const
Returns the particular array object that the rewriter is currently processing.
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.
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 clear()
Resets the GeomVertexRewriter to the initial state.
void set_row(int row)
Sets the start row to the indicated value.
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 reader started.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the writer is working on.
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 is_at_end() const
Returns true if the reader or 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 rewriter is currently processing.
A thread; that is, a lightweight process.
Definition: thread.h:51
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
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 rewriter is working on. ...
bool set_column(int column)
Sets up the writer to use the nth data type of the GeomVertexFormat, numbering from 0...
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
void set_row(int row)
Sets the start row to the indicated value.
int get_array() const
Returns the array index containing the data type that the writer is working on.
void clear()
Resets the GeomVertexReader to the initial state.
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the writer is processing.
int get_start_row() const
Returns the row index at which the rewriter started.
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.
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...
void set_row(int row)
Sets the start, write, and write index to the indicated value.