21 INLINE Geom::PrimitiveType Geom::
22 get_primitive_type()
const {
23 CDReader cdata(_cycler);
24 return cdata->_primitive_type;
31 INLINE Geom::ShadeModel Geom::
32 get_shade_model()
const {
33 CDReader cdata(_cycler);
34 return cdata->_shade_model;
42 get_geom_rendering()
const {
43 CDReader cdata(_cycler);
44 return cdata->_geom_rendering;
52 get_vertex_data(
Thread *current_thread)
const {
53 CDReader cdata(_cycler, current_thread);
54 return cdata->_data.get_read_pointer(current_thread);
63 CDReader cdata(_cycler);
64 return cdata->_primitives.empty();
72 get_num_primitives()
const {
73 CDReader cdata(_cycler);
74 return cdata->_primitives.size();
83 get_primitive(
size_t i)
const {
84 CDReader cdata(_cycler);
85 nassertr(i < cdata->_primitives.size(),
nullptr);
86 return cdata->_primitives[i].get_read_pointer();
98 modify_primitive(
size_t i) {
100 CDWriter cdata(_cycler,
true, current_thread);
101 nassertr(i < cdata->_primitives.size(),
nullptr);
104 return cdata->_primitives[i].get_write_pointer();
127 new_geom->decompose_in_place();
138 new_geom->doubleside_in_place();
149 new_geom->reverse_in_place();
160 new_geom->rotate_in_place();
176 unify(
int max_indices,
bool preserve_order)
const {
178 new_geom->unify_in_place(max_indices, preserve_order);
187 make_points()
const {
189 new_geom->make_points_in_place();
200 new_geom->make_lines_in_place();
209 make_patches()
const {
211 new_geom->make_patches_in_place();
222 make_adjacency()
const {
224 new_geom->make_adjacency_in_place();
235 get_modified(
Thread *current_thread)
const {
236 CDReader cdata(_cycler, current_thread);
237 return cdata->_modified;
245 mark_bounds_stale()
const {
246 CDWriter cdata(((
Geom *)
this)->_cycler,
false);
247 ((
Geom *)
this)->mark_internal_bounds_stale(cdata);
263 set_bounds_type(BoundingVolume::BoundsType bounds_type) {
264 CDWriter cdata(_cycler,
true);
265 cdata->_bounds_type = bounds_type;
266 mark_internal_bounds_stale(cdata);
272 INLINE BoundingVolume::BoundsType Geom::
273 get_bounds_type()
const {
274 CDReader cdata(_cycler);
275 return cdata->_bounds_type;
290 if (volume ==
nullptr) {
291 cdata->_user_bounds =
nullptr;
293 cdata->_user_bounds = volume->make_copy();
308 cdata->_user_bounds =
nullptr;
309 mark_internal_bounds_stale(cdata);
327 bool got_mat,
const LMatrix4 &mat,
328 Thread *current_thread)
const {
329 CDReader cdata(_cycler, current_thread);
331 PN_stdfloat sq_radius;
332 do_calc_tight_bounds(min_point, max_point, sq_radius, found_any,
333 vertex_data, got_mat, mat,
334 InternalName::get_vertex(),
335 cdata, current_thread);
349 bool &found_any,
Thread *current_thread)
const {
352 get_vertex_data(current_thread),
false,
353 LMatrix4::ident_mat(),
364 bool got_mat,
const LMatrix4 &mat,
366 Thread *current_thread)
const {
367 CDReader cdata(_cycler, current_thread);
369 PN_stdfloat sq_radius;
370 do_calc_tight_bounds(min_point, max_point, sq_radius, found_any,
371 vertex_data, got_mat, mat,
372 column_name, cdata, current_thread);
381 mark_internal_bounds_stale(CData *cdata) {
382 cdata->_internal_bounds_stale =
true;
388 INLINE Geom::CDataCache::
391 _geom_result(nullptr),
392 _data_result(nullptr)
399 INLINE Geom::CDataCache::
400 CDataCache(
const Geom::CDataCache ©) :
401 _source(copy._source),
402 _geom_result(copy._geom_result),
403 _data_result(copy._data_result)
405 if (_geom_result != _source && _geom_result !=
nullptr) {
414 INLINE
void Geom::CDataCache::
416 if (geom_result != _geom_result) {
417 if (_geom_result != _source && _geom_result !=
nullptr) {
420 _geom_result = geom_result;
421 if (_geom_result != _source && _geom_result !=
nullptr) {
425 _data_result = data_result;
431 INLINE Geom::CacheKey::
433 _source_data(source_data),
441 INLINE Geom::CacheKey::
442 CacheKey(
const CacheKey ©) :
443 _source_data(copy._source_data),
444 _modifier(copy._modifier)
451 INLINE Geom::CacheKey::
452 CacheKey(CacheKey &&from) noexcept :
453 _source_data(std::move(from._source_data)),
454 _modifier(std::move(from._modifier))
463 if (_modifier != other._modifier) {
464 int compare = _modifier->geom_compare_to(*other._modifier);
466 return (compare < 0);
469 if (_source_data != other._source_data) {
470 return (_source_data < other._source_data);
478 INLINE Geom::CacheEntry::
482 _key(source_data, modifier)
489 INLINE Geom::CacheEntry::
499 INLINE Geom::CacheEntry::
511 _primitive_type(PT_none),
512 _shade_model(SM_uniform),
515 _internal_bounds_stale(true),
526 _primitive_type(PT_none),
527 _shade_model(SM_uniform),
530 _internal_bounds_stale(true),
538 INLINE GeomPipelineReader::
539 GeomPipelineReader(
Thread *current_thread) :
541 _current_thread(current_thread),
549 INLINE GeomPipelineReader::
550 GeomPipelineReader(
const Geom *
object,
Thread *current_thread) :
552 _current_thread(current_thread),
553 _cdata(object->_cycler.read_unlocked(current_thread))
556 nassertv(_object->test_ref_count_nonzero());
560 #endif // DO_PIPELINING 566 INLINE GeomPipelineReader::
567 ~GeomPipelineReader() {
569 if (_object !=
nullptr) {
570 nassertv(_object->test_ref_count_nonzero());
576 if (_cdata !=
nullptr) {
579 #endif // DO_PIPELINING 590 INLINE
void GeomPipelineReader::
591 set_object(
const Geom *
object) {
592 if (
object != _object) {
596 if (_cdata !=
nullptr) {
599 #endif // DO_PIPELINING 601 _cdata =
object->_cycler.read_unlocked(_current_thread);
605 #endif // DO_PIPELINING 614 INLINE
const Geom *GeomPipelineReader::
622 INLINE
Thread *GeomPipelineReader::
623 get_current_thread()
const {
624 return _current_thread;
630 INLINE GeomPipelineReader::PrimitiveType GeomPipelineReader::
631 get_primitive_type()
const {
632 return _cdata->_primitive_type;
638 INLINE GeomPipelineReader::ShadeModel GeomPipelineReader::
639 get_shade_model()
const {
640 return _cdata->_shade_model;
646 INLINE
int GeomPipelineReader::
647 get_geom_rendering()
const {
648 return _cdata->_geom_rendering;
655 get_vertex_data()
const {
656 return _cdata->_data.get_read_pointer();
662 INLINE
int GeomPipelineReader::
663 get_num_primitives()
const {
664 return _cdata->_primitives.size();
671 get_primitive(
int i)
const {
672 nassertr(i >= 0 && i < (
int)_cdata->_primitives.size(),
nullptr);
673 return _cdata->_primitives[i].get_read_pointer();
680 get_modified()
const {
681 return _cdata->_modified;
698 return ((
Geom *)_object)->prepare_now(prepared_objects, gsg);
701 INLINE std::ostream &
702 operator << (std::ostream &out,
const Geom &obj) {
This is a special class object that holds all the information returned by a particular GSG to indicat...
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
void set_bounds(const BoundingVolume *volume)
Resets the bounding volume so that it is the indicated volume.
A single page of data maintained by a PipelineCycler.
insert_primitive
Inserts a new GeomPrimitive structure to the Geom object.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
void add_primitive(const GeomPrimitive *primitive)
Inserts a new GeomPrimitive structure to the Geom object.
void clear_bounds()
Reverses the effect of a previous call to set_bounds(), and allows the bounding volume to be automati...
A table of objects that are saved within the graphics context for reference by handle later.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
get_current_thread
Returns a pointer to the currently-executing Thread object.
void clear_cache_stage(Thread *current_thread)
Removes all of the previously-cached results of munge_geom(), at the current pipeline stage and upstr...
virtual Geom * make_copy() const
Returns a newly-allocated Geom that is a shallow copy of this one.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
bool operator<(const CacheKey &other) const
Provides a unique ordering within the map.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
PT(Geom) Geom
Decomposes all of the primitives within this Geom, returning the result.
Encodes a string name in a hash table, mapping it to a pointer.
void ref() const
Explicitly increments the reference count.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
static UpdateSeq get_next_modified()
Returns a monotonically increasing sequence.
CPT(GeomVertexData) Geom
Returns a const pointer to the GeomVertexData, for application code to directly examine (but not modi...
This is a sequence number that increments monotonically.
void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, bool got_mat, const LMatrix4 &mat, Thread *current_thread) const
Expands min_point and max_point to include all of the vertices in the Geom, if any.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...