Panda3D

geomPrimitive.I

00001 // Filename: geomPrimitive.I
00002 // Created by:  drose (06Mar05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: GeomPrimitive::get_shade_model
00018 //       Access: Published
00019 //  Description: Returns the ShadeModel hint for this primitive.
00020 //               This is intended as a hint to the renderer to tell it
00021 //               how the per-vertex colors and normals are applied.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE GeomPrimitive::ShadeModel GeomPrimitive::
00024 get_shade_model() const {
00025   CDReader cdata(_cycler);
00026   return cdata->_shade_model;
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: GeomPrimitive::set_shade_model
00031 //       Access: Published
00032 //  Description: Changes the ShadeModel hint for this primitive.
00033 //               This is different from the ShadeModelAttrib that
00034 //               might also be applied from the scene graph.  This
00035 //               does not affect the shade model that is in effect
00036 //               when rendering, but rather serves as a hint to the
00037 //               renderer to tell it how the per-vertex colors and
00038 //               normals on this primitive are applied.
00039 //
00040 //               Don't call this in a downstream thread unless you
00041 //               don't mind it blowing away other changes you might
00042 //               have recently made in an upstream thread.
00043 ////////////////////////////////////////////////////////////////////
00044 INLINE void GeomPrimitive::
00045 set_shade_model(GeomPrimitive::ShadeModel shade_model) {
00046   CDWriter cdata(_cycler, true);
00047   cdata->_shade_model = shade_model;
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: GeomPrimitive::get_usage_hint
00052 //       Access: Published
00053 //  Description: Returns the usage hint for this primitive.  See
00054 //               geomEnums.h.  This has nothing to do with the usage
00055 //               hint associated with the primitive's vertices; this
00056 //               only specifies how often the vertex indices that
00057 //               define the primitive will be modified.
00058 //
00059 //               It is perfectly legal (and, in fact, common) for a
00060 //               GeomPrimitive to have UH_static on itself, while
00061 //               referencing vertex data with UH_dynamic.  This means
00062 //               that the vertices themselves will be animated, but
00063 //               the primitive will always reference the same set of
00064 //               vertices from the pool.
00065 ////////////////////////////////////////////////////////////////////
00066 INLINE GeomPrimitive::UsageHint GeomPrimitive::
00067 get_usage_hint() const {
00068   CDReader cdata(_cycler);
00069   return cdata->_usage_hint;
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: GeomPrimitive::get_index_type
00074 //       Access: Public
00075 //  Description: Returns the numeric type of the index column.
00076 //               Normally, this will be either NT_uint16 or NT_uint32.
00077 ////////////////////////////////////////////////////////////////////
00078 INLINE GeomPrimitive::NumericType GeomPrimitive::
00079 get_index_type() const {
00080   CDReader cdata(_cycler);
00081   return cdata->_index_type;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: GeomPrimitive::is_composite
00086 //       Access: Published
00087 //  Description: Returns true if the primitive is a composite
00088 //               primitive such as a tristrip or trifan, or false if
00089 //               it is a fundamental primitive such as a collection of
00090 //               triangles.
00091 ////////////////////////////////////////////////////////////////////
00092 INLINE bool GeomPrimitive::
00093 is_composite() const {
00094   return (get_num_vertices_per_primitive() == 0);
00095 }
00096 
00097 ////////////////////////////////////////////////////////////////////
00098 //     Function: GeomPrimitive::is_indexed
00099 //       Access: Published
00100 //  Description: Returns true if the primitive is indexed, false
00101 //               otherwise.  An indexed primitive stores a table of
00102 //               index numbers into its GeomVertexData, so that it can
00103 //               reference the vertices in any order.  A nonindexed
00104 //               primitive, on the other hand, stores only the first
00105 //               vertex number and number of vertices used, so that it
00106 //               can only reference the vertices consecutively.
00107 ////////////////////////////////////////////////////////////////////
00108 INLINE bool GeomPrimitive::
00109 is_indexed() const {
00110   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00111   return reader.is_indexed();
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: GeomPrimitive::get_first_vertex
00116 //       Access: Published
00117 //  Description: Returns the first vertex number referenced by the
00118 //               primitive.  This is particularly important in the
00119 //               case of a nonindexed primitive, in which case
00120 //               get_first_vertex() and get_num_vertices() completely
00121 //               define the extent of the vertex range.
00122 ////////////////////////////////////////////////////////////////////
00123 INLINE int GeomPrimitive::
00124 get_first_vertex() const {
00125   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00126   return reader.get_first_vertex();
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //     Function: GeomPrimitive::get_num_vertices
00131 //       Access: Published
00132 //  Description: Returns the number of vertices used by all the
00133 //               primitives in this object.
00134 ////////////////////////////////////////////////////////////////////
00135 INLINE int GeomPrimitive::
00136 get_num_vertices() const {
00137   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00138   return reader.get_num_vertices();
00139 }
00140 
00141 ////////////////////////////////////////////////////////////////////
00142 //     Function: GeomPrimitive::get_vertex
00143 //       Access: Published
00144 //  Description: Returns the ith vertex index in the table.
00145 ////////////////////////////////////////////////////////////////////
00146 INLINE int GeomPrimitive::
00147 get_vertex(int i) const {
00148   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00149   return reader.get_vertex(i);
00150 }
00151 
00152 ////////////////////////////////////////////////////////////////////
00153 //     Function: GeomPrimitive::get_num_primitives
00154 //       Access: Published
00155 //  Description: Returns the number of individual primitives stored
00156 //               within this object.  All primitives are the same
00157 //               type.
00158 ////////////////////////////////////////////////////////////////////
00159 INLINE int GeomPrimitive::
00160 get_num_primitives() const {
00161   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00162   return reader.get_num_primitives();
00163 }
00164 
00165 ////////////////////////////////////////////////////////////////////
00166 //     Function: GeomPrimitive::get_num_faces
00167 //       Access: Published
00168 //  Description: Returns the number of triangles or other fundamental
00169 //               type (such as line segments) represented by all the
00170 //               primitives in this object.
00171 ////////////////////////////////////////////////////////////////////
00172 INLINE int GeomPrimitive::
00173 get_num_faces() const {
00174   int num_vertices_per_primitive = get_num_vertices_per_primitive();
00175 
00176   if (num_vertices_per_primitive == 0) {
00177     int num_primitives = get_num_primitives();
00178     int num_vertices = get_num_vertices();
00179     int min_num_vertices_per_primitive = get_min_num_vertices_per_primitive();
00180     int num_unused_vertices_per_primitive = get_num_unused_vertices_per_primitive();
00181     return num_vertices - (num_primitives * (min_num_vertices_per_primitive - 1)) - ((num_primitives - 1) * num_unused_vertices_per_primitive);
00182   } else {
00183     return get_num_primitives();
00184   }
00185 }
00186 
00187 ////////////////////////////////////////////////////////////////////
00188 //     Function: GeomPrimitive::get_primitive_num_faces
00189 //       Access: Published
00190 //  Description: Returns the number of triangles or other fundamental
00191 //               type (such as line segments) represented by the nth
00192 //               primitive in this object.
00193 ////////////////////////////////////////////////////////////////////
00194 INLINE int GeomPrimitive::
00195 get_primitive_num_faces(int n) const {
00196   int num_vertices_per_primitive = get_num_vertices_per_primitive();
00197 
00198   if (num_vertices_per_primitive == 0) {
00199     return get_primitive_num_vertices(n) - get_min_num_vertices_per_primitive() + 1;
00200   } else {
00201     return 1;
00202   }
00203 }
00204 
00205 ////////////////////////////////////////////////////////////////////
00206 //     Function: GeomPrimitive::get_min_vertex
00207 //       Access: Published
00208 //  Description: Returns the minimum vertex index number used by all
00209 //               the primitives in this object.
00210 ////////////////////////////////////////////////////////////////////
00211 INLINE int GeomPrimitive::
00212 get_min_vertex() const {
00213   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00214   reader.check_minmax();
00215   return reader.get_min_vertex();
00216 }
00217 
00218 ////////////////////////////////////////////////////////////////////
00219 //     Function: GeomPrimitive::get_max_vertex
00220 //       Access: Published
00221 //  Description: Returns the maximum vertex index number used by all
00222 //               the primitives in this object.
00223 ////////////////////////////////////////////////////////////////////
00224 INLINE int GeomPrimitive::
00225 get_max_vertex() const {
00226   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00227   reader.check_minmax();
00228   return reader.get_max_vertex();
00229 }
00230 
00231 ////////////////////////////////////////////////////////////////////
00232 //     Function: GeomPrimitive::get_data_size_bytes
00233 //       Access: Published
00234 //  Description: Returns the number of bytes stored in the vertices
00235 //               array.
00236 ////////////////////////////////////////////////////////////////////
00237 INLINE int GeomPrimitive::
00238 get_data_size_bytes() const {
00239   CDReader cdata(_cycler);
00240   return cdata->_vertices.get_read_pointer()->get_data_size_bytes();
00241 }
00242 
00243 ////////////////////////////////////////////////////////////////////
00244 //     Function: GeomPrimitive::get_modified
00245 //       Access: Published
00246 //  Description: Returns a sequence number which is guaranteed to
00247 //               change at least every time the vertex index array is
00248 //               modified.
00249 ////////////////////////////////////////////////////////////////////
00250 INLINE UpdateSeq GeomPrimitive::
00251 get_modified() const {
00252   CDReader cdata(_cycler);
00253   return cdata->_modified;
00254 }
00255 
00256 ////////////////////////////////////////////////////////////////////
00257 //     Function: GeomPrimitive::check_valid
00258 //       Access: Published
00259 //  Description: Verifies that the primitive only references vertices
00260 //               that actually exist within the indicated
00261 //               GeomVertexData.  Returns true if the primitive
00262 //               appears to be valid, false otherwise.
00263 ////////////////////////////////////////////////////////////////////
00264 INLINE bool GeomPrimitive::
00265 check_valid(const GeomVertexData *vertex_data) const {
00266   Thread *current_thread = Thread::get_current_thread();
00267   GeomPrimitivePipelineReader reader(this, current_thread);
00268   reader.check_minmax();
00269   GeomVertexDataPipelineReader data_reader(vertex_data, current_thread);
00270   data_reader.check_array_readers();
00271   return reader.check_valid(&data_reader);
00272 }
00273 
00274 ////////////////////////////////////////////////////////////////////
00275 //     Function: GeomPrimitive::get_vertices
00276 //       Access: Published
00277 //  Description: Returns a const pointer to the vertex index array so
00278 //               application code can read it directly.  This might
00279 //               return NULL if the primitive is nonindexed.  Do not
00280 //               attempt to modify the returned array; use
00281 //               modify_vertices() or set_vertices() for this.
00282 //
00283 //               This method is intended for low-level usage only.
00284 //               There are higher-level methods for more common usage.
00285 //               We recommend you do not use this method directly.  If
00286 //               you do, be sure you know what you are doing!
00287 ////////////////////////////////////////////////////////////////////
00288 INLINE CPT(GeomVertexArrayData) GeomPrimitive::
00289 get_vertices() const {
00290   CDReader cdata(_cycler);
00291   return cdata->_vertices.get_read_pointer();
00292 }
00293 
00294 ////////////////////////////////////////////////////////////////////
00295 //     Function: GeomPrimitive::get_index_stride
00296 //       Access: Published
00297 //  Description: A convenience function to return the gap between
00298 //               successive index numbers, in bytes, of the index
00299 //               data.
00300 //
00301 //               This method is intended for low-level usage only.
00302 //               There are higher-level methods for more common usage.
00303 //               We recommend you do not use this method directly.  If
00304 //               you do, be sure you know what you are doing!
00305 ////////////////////////////////////////////////////////////////////
00306 INLINE int GeomPrimitive::
00307 get_index_stride() const {
00308   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00309   return reader.get_index_stride();
00310 }
00311 
00312 ////////////////////////////////////////////////////////////////////
00313 //     Function: GeomPrimitive::get_ends
00314 //       Access: Published
00315 //  Description: Returns a const pointer to the primitive ends
00316 //               array so application code can read it directly.  Do
00317 //               not attempt to modify the returned array; use
00318 //               modify_ends() or set_ends() for this.
00319 //
00320 //               Note that simple primitive types, like triangles, do
00321 //               not have a ends array: since all the primitives
00322 //               have the same number of vertices, it is not needed.
00323 //
00324 //               This method is intended for low-level usage only.
00325 //               There are higher-level methods for more common usage.
00326 //               We recommend you do not use this method directly.  If
00327 //               you do, be sure you know what you are doing!
00328 ////////////////////////////////////////////////////////////////////
00329 INLINE CPTA_int GeomPrimitive::
00330 get_ends() const {
00331   CDReader cdata(_cycler);
00332   return cdata->_ends;
00333 }
00334 
00335 ////////////////////////////////////////////////////////////////////
00336 //     Function: GeomPrimitive::get_mins
00337 //       Access: Published
00338 //  Description: Returns a const pointer to the primitive mins
00339 //               array so application code can read it directly.  Do
00340 //               not attempt to modify the returned array; use
00341 //               set_minmax() for this.
00342 //
00343 //               Note that simple primitive types, like triangles, do
00344 //               not have a mins array.
00345 //
00346 //               This method is intended for low-level usage only.
00347 //               There are higher-level methods for more common usage.
00348 //               We recommend you do not use this method directly.  If
00349 //               you do, be sure you know what you are doing!
00350 ////////////////////////////////////////////////////////////////////
00351 INLINE CPT(GeomVertexArrayData) GeomPrimitive::
00352 get_mins() const {
00353   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00354   reader.check_minmax();
00355   return reader.get_mins();
00356 }
00357 
00358 ////////////////////////////////////////////////////////////////////
00359 //     Function: GeomPrimitive::get_maxs
00360 //       Access: Published
00361 //  Description: Returns a const pointer to the primitive maxs
00362 //               array so application code can read it directly.  Do
00363 //               not attempt to modify the returned array; use
00364 //               set_minmax().
00365 //
00366 //               Note that simple primitive types, like triangles, do
00367 //               not have a maxs array.
00368 //
00369 //               This method is intended for low-level usage only.
00370 //               There are higher-level methods for more common usage.
00371 //               We recommend you do not use this method directly.  If
00372 //               you do, be sure you know what you are doing!
00373 ////////////////////////////////////////////////////////////////////
00374 INLINE CPT(GeomVertexArrayData) GeomPrimitive::
00375 get_maxs() const {
00376   GeomPrimitivePipelineReader reader(this, Thread::get_current_thread());
00377   reader.check_minmax();
00378   return reader.get_maxs();
00379 }
00380 
00381 ////////////////////////////////////////////////////////////////////
00382 //     Function: GeomPrimitive::add_vertices
00383 //       Access: Public
00384 //  Description: Adds several vertices in a row.
00385 ////////////////////////////////////////////////////////////////////
00386 INLINE void GeomPrimitive::
00387 add_vertices(int v1, int v2) {
00388   add_vertex(v1);
00389   add_vertex(v2);
00390 }
00391 
00392 ////////////////////////////////////////////////////////////////////
00393 //     Function: GeomPrimitive::add_vertices
00394 //       Access: Public
00395 //  Description: Adds several vertices in a row.
00396 ////////////////////////////////////////////////////////////////////
00397 INLINE void GeomPrimitive::
00398 add_vertices(int v1, int v2, int v3) {
00399   add_vertex(v1);
00400   add_vertex(v2);
00401   add_vertex(v3);
00402 }
00403 
00404 ////////////////////////////////////////////////////////////////////
00405 //     Function: GeomPrimitive::add_vertices
00406 //       Access: Public
00407 //  Description: Adds several vertices in a row.
00408 ////////////////////////////////////////////////////////////////////
00409 INLINE void GeomPrimitive::
00410 add_vertices(int v1, int v2, int v3, int v4) {
00411   add_vertex(v1);
00412   add_vertex(v2);
00413   add_vertex(v3);
00414   add_vertex(v4);
00415 }
00416 
00417 ////////////////////////////////////////////////////////////////////
00418 //     Function: GeomPrimitive::get_index_format
00419 //       Access: Public
00420 //  Description: Returns a registered format appropriate for using to
00421 //               store the index table.
00422 ////////////////////////////////////////////////////////////////////
00423 INLINE CPT(GeomVertexArrayFormat) GeomPrimitive::
00424 get_index_format() const {
00425   return GeomVertexArrayFormat::register_format
00426     (new GeomVertexArrayFormat(InternalName::get_index(), 1, 
00427                                get_index_type(), C_index));
00428 }
00429 
00430 ////////////////////////////////////////////////////////////////////
00431 //     Function: GeomPrimitive::make_index_data
00432 //       Access: Public
00433 //  Description: Creates and returns a new, empty index table.
00434 ////////////////////////////////////////////////////////////////////
00435 INLINE PT(GeomVertexArrayData) GeomPrimitive::
00436 make_index_data() const {
00437   return new GeomVertexArrayData(get_index_format(), get_usage_hint());
00438 }
00439 
00440 ////////////////////////////////////////////////////////////////////
00441 //     Function: GeomPrimitive::CData::Constructor
00442 //       Access: Public
00443 //  Description:
00444 ////////////////////////////////////////////////////////////////////
00445 INLINE GeomPrimitive::CData::
00446 CData() :
00447   _shade_model(SM_smooth),
00448   _first_vertex(0),
00449   _num_vertices(0),
00450   _index_type(NT_uint16),
00451   _usage_hint(UH_unspecified),
00452   _got_minmax(true),
00453   _min_vertex(0),
00454   _max_vertex(0)
00455 {
00456 }
00457 
00458 ////////////////////////////////////////////////////////////////////
00459 //     Function: GeomPrimitive::CData::Copy Constructor
00460 //       Access: Public
00461 //  Description:
00462 ////////////////////////////////////////////////////////////////////
00463 INLINE GeomPrimitive::CData::
00464 CData(const GeomPrimitive::CData &copy) :
00465   _shade_model(copy._shade_model),
00466   _first_vertex(copy._first_vertex),
00467   _num_vertices(copy._num_vertices),
00468   _index_type(copy._index_type),
00469   _usage_hint(copy._usage_hint),
00470   _vertices(copy._vertices),
00471   _ends(copy._ends),
00472   _mins(copy._mins),
00473   _maxs(copy._maxs),
00474   _modified(copy._modified),
00475   _got_minmax(copy._got_minmax),
00476   _min_vertex(copy._min_vertex),
00477   _max_vertex(copy._max_vertex)
00478 {
00479 }
00480 ////////////////////////////////////////////////////////////////////
00481 //     Function: GeomPrimitivePipelineReader::Constructor
00482 //       Access: Public
00483 //  Description:
00484 ////////////////////////////////////////////////////////////////////
00485 INLINE GeomPrimitivePipelineReader::
00486 GeomPrimitivePipelineReader(const GeomPrimitive *object, 
00487                             Thread *current_thread) :
00488   _object(object),
00489   _current_thread(current_thread),
00490   _cdata(object->_cycler.read_unlocked(current_thread)),
00491   _vertices_reader(NULL)
00492 {
00493   nassertv(_object->test_ref_count_nonzero());
00494 #ifdef DO_PIPELINING
00495   _cdata->ref();
00496 #endif  // DO_PIPELINING
00497   if (!_cdata->_vertices.is_null()) {
00498     _vertices_reader = _cdata->_vertices.get_read_pointer()->get_handle();
00499   }
00500 }
00501 
00502 ////////////////////////////////////////////////////////////////////
00503 //     Function: GeomPrimitivePipelineReader::Copy Constructor
00504 //       Access: Private
00505 //  Description: Don't attempt to copy these objects.
00506 ////////////////////////////////////////////////////////////////////
00507 INLINE GeomPrimitivePipelineReader::
00508 GeomPrimitivePipelineReader(const GeomPrimitivePipelineReader &) {
00509   nassertv(false);
00510 }
00511 
00512 ////////////////////////////////////////////////////////////////////
00513 //     Function: GeomPrimitivePipelineReader::Copy Assignment Operator
00514 //       Access: Private
00515 //  Description: Don't attempt to copy these objects.
00516 ////////////////////////////////////////////////////////////////////
00517 INLINE void GeomPrimitivePipelineReader::
00518 operator = (const GeomPrimitivePipelineReader &) {
00519   nassertv(false);
00520 }
00521 
00522 ////////////////////////////////////////////////////////////////////
00523 //     Function: GeomPrimitivePipelineReader::Destructor
00524 //       Access: Public
00525 //  Description:
00526 ////////////////////////////////////////////////////////////////////
00527 INLINE GeomPrimitivePipelineReader::
00528 ~GeomPrimitivePipelineReader() {
00529 #ifdef _DEBUG
00530   nassertv(_object->test_ref_count_nonzero());
00531 #endif // _DEBUG
00532   //  _object->_cycler.release_read(_cdata);
00533 
00534 #ifdef DO_PIPELINING
00535   unref_delete((CycleData *)_cdata);
00536 #endif  // DO_PIPELINING
00537 
00538 #ifdef _DEBUG
00539   _vertices_reader = NULL;
00540   _object = NULL;
00541   _cdata = NULL;
00542 #endif  // _DEBUG
00543 }
00544 
00545 ////////////////////////////////////////////////////////////////////
00546 //     Function: GeomPrimitivePipelineReader::get_object
00547 //       Access: Public
00548 //  Description:
00549 ////////////////////////////////////////////////////////////////////
00550 INLINE const GeomPrimitive *GeomPrimitivePipelineReader::
00551 get_object() const {
00552   return _object;
00553 }
00554 
00555 ////////////////////////////////////////////////////////////////////
00556 //     Function: GeomPrimitivePipelineReader::get_current_thread
00557 //       Access: Public
00558 //  Description:
00559 ////////////////////////////////////////////////////////////////////
00560 INLINE Thread *GeomPrimitivePipelineReader::
00561 get_current_thread() const {
00562   return _current_thread;
00563 }
00564 
00565 ////////////////////////////////////////////////////////////////////
00566 //     Function: GeomPrimitivePipelineReader::get_shade_model
00567 //       Access: Public
00568 //  Description: 
00569 ////////////////////////////////////////////////////////////////////
00570 INLINE GeomPrimitivePipelineReader::ShadeModel GeomPrimitivePipelineReader::
00571 get_shade_model() const {
00572   return _cdata->_shade_model;
00573 }
00574 
00575 ////////////////////////////////////////////////////////////////////
00576 //     Function: GeomPrimitivePipelineReader::get_usage_hint
00577 //       Access: Public
00578 //  Description: 
00579 ////////////////////////////////////////////////////////////////////
00580 INLINE GeomPrimitivePipelineReader::UsageHint GeomPrimitivePipelineReader::
00581 get_usage_hint() const {
00582   return _cdata->_usage_hint;
00583 }
00584 
00585 ////////////////////////////////////////////////////////////////////
00586 //     Function: GeomPrimitivePipelineReader::get_index_type
00587 //       Access: Public
00588 //  Description: 
00589 ////////////////////////////////////////////////////////////////////
00590 INLINE GeomPrimitivePipelineReader::NumericType GeomPrimitivePipelineReader::
00591 get_index_type() const {
00592   return _cdata->_index_type;
00593 }
00594 
00595 ////////////////////////////////////////////////////////////////////
00596 //     Function: GeomPrimitivePipelineReader::is_indexed
00597 //       Access: Public
00598 //  Description: 
00599 ////////////////////////////////////////////////////////////////////
00600 INLINE bool GeomPrimitivePipelineReader::
00601 is_indexed() const {
00602   return (!_cdata->_vertices.is_null());
00603 }
00604 
00605 ////////////////////////////////////////////////////////////////////
00606 //     Function: GeomPrimitivePipelineReader::get_num_vertices
00607 //       Access: Public
00608 //  Description: 
00609 ////////////////////////////////////////////////////////////////////
00610 INLINE int GeomPrimitivePipelineReader::
00611 get_num_vertices() const {
00612   if (_cdata->_num_vertices != -1) {
00613     return _cdata->_num_vertices;
00614   } else {
00615     nassertr(!_cdata->_vertices.is_null(), 0);
00616     return _vertices_reader->get_num_rows();
00617   }
00618 }
00619 
00620 ////////////////////////////////////////////////////////////////////
00621 //     Function: GeomPrimitivePipelineReader::get_min_vertex
00622 //       Access: Public
00623 //  Description: 
00624 ////////////////////////////////////////////////////////////////////
00625 INLINE int GeomPrimitivePipelineReader::
00626 get_min_vertex() const {
00627   nassertr(_cdata->_got_minmax, 0);
00628   return _cdata->_min_vertex;
00629 }
00630 
00631 ////////////////////////////////////////////////////////////////////
00632 //     Function: GeomPrimitivePipelineReader::get_max_vertex
00633 //       Access: Public
00634 //  Description: 
00635 ////////////////////////////////////////////////////////////////////
00636 INLINE int GeomPrimitivePipelineReader::
00637 get_max_vertex() const {
00638   nassertr(_cdata->_got_minmax, 0);
00639   return _cdata->_max_vertex;
00640 }
00641 
00642 ////////////////////////////////////////////////////////////////////
00643 //     Function: GeomPrimitivePipelineReader::get_data_size_bytes
00644 //       Access: Published
00645 //  Description: Returns the number of bytes stored in the vertices
00646 //               array.
00647 ////////////////////////////////////////////////////////////////////
00648 INLINE int GeomPrimitivePipelineReader::
00649 get_data_size_bytes() const {
00650   return _vertices_reader->get_data_size_bytes();
00651 }
00652 
00653 ////////////////////////////////////////////////////////////////////
00654 //     Function: GeomPrimitivePipelineReader::get_modified
00655 //       Access: Public
00656 //  Description: 
00657 ////////////////////////////////////////////////////////////////////
00658 INLINE UpdateSeq GeomPrimitivePipelineReader::
00659 get_modified() const {
00660   return _cdata->_modified;
00661 }
00662 
00663 ////////////////////////////////////////////////////////////////////
00664 //     Function: GeomPrimitivePipelineReader::get_index_stride
00665 //       Access: Public
00666 //  Description: 
00667 ////////////////////////////////////////////////////////////////////
00668 INLINE int GeomPrimitivePipelineReader::
00669 get_index_stride() const {
00670   nassertr(is_indexed(), 0);
00671   return _cdata->_vertices.get_read_pointer()->get_array_format()->get_stride();
00672 }
00673 
00674 ////////////////////////////////////////////////////////////////////
00675 //     Function: GeomPrimitivePipelineReader::get_vertices_reader
00676 //       Access: Public
00677 //  Description: 
00678 ////////////////////////////////////////////////////////////////////
00679 INLINE const GeomVertexArrayDataHandle *GeomPrimitivePipelineReader::
00680 get_vertices_reader() const {
00681   return _vertices_reader;
00682 }
00683 
00684 ////////////////////////////////////////////////////////////////////
00685 //     Function: GeomPrimitivePipelineReader::get_read_pointer
00686 //       Access: Public
00687 //  Description: 
00688 ////////////////////////////////////////////////////////////////////
00689 INLINE const unsigned char *GeomPrimitivePipelineReader::
00690 get_read_pointer(bool force) const {
00691   return _vertices_reader->get_read_pointer(force);
00692 }
00693 
00694 ////////////////////////////////////////////////////////////////////
00695 //     Function: GeomPrimitivePipelineReader::get_ends
00696 //       Access: Public
00697 //  Description: 
00698 ////////////////////////////////////////////////////////////////////
00699 INLINE CPTA_int GeomPrimitivePipelineReader::
00700 get_ends() const {
00701   return _cdata->_ends;
00702 }
00703 
00704 ////////////////////////////////////////////////////////////////////
00705 //     Function: GeomPrimitivePipelineReader::get_mins
00706 //       Access: Public
00707 //  Description: 
00708 ////////////////////////////////////////////////////////////////////
00709 INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader::
00710 get_mins() const {
00711   nassertr(is_indexed(), NULL);
00712   nassertr(_cdata->_got_minmax, NULL);
00713   return _cdata->_mins.get_read_pointer();
00714 }
00715 
00716 ////////////////////////////////////////////////////////////////////
00717 //     Function: GeomPrimitivePipelineReader::get_maxs
00718 //       Access: Public
00719 //  Description: 
00720 ////////////////////////////////////////////////////////////////////
00721 INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader::
00722 get_maxs() const {
00723   nassertr(is_indexed(), NULL);
00724   nassertr(_cdata->_got_minmax, NULL);
00725   return _cdata->_maxs.get_read_pointer();
00726 }
00727 
00728 INLINE ostream &
00729 operator << (ostream &out, const GeomPrimitive &obj) {
00730   obj.output(out);
00731   return out;
00732 }
 All Classes Functions Variables Enumerations