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();
220 make_adjacency()
const {
222 new_geom->make_adjacency_in_place();
233 get_modified(
Thread *current_thread)
const {
234 CDReader cdata(_cycler, current_thread);
235 return cdata->_modified;
243 mark_bounds_stale()
const {
244 CDWriter cdata(((
Geom *)
this)->_cycler,
false);
245 ((
Geom *)
this)->mark_internal_bounds_stale(cdata);
261 set_bounds_type(BoundingVolume::BoundsType bounds_type) {
262 CDWriter cdata(_cycler,
true);
263 cdata->_bounds_type = bounds_type;
264 mark_internal_bounds_stale(cdata);
270 INLINE BoundingVolume::BoundsType Geom::
271 get_bounds_type()
const {
272 CDReader cdata(_cycler);
273 return cdata->_bounds_type;
288 if (volume ==
nullptr) {
289 cdata->_user_bounds =
nullptr;
291 cdata->_user_bounds = volume->make_copy();
306 cdata->_user_bounds =
nullptr;
307 mark_internal_bounds_stale(cdata);
325 bool got_mat,
const LMatrix4 &mat,
326 Thread *current_thread)
const {
327 CDReader cdata(_cycler, current_thread);
329 PN_stdfloat sq_radius;
330 do_calc_tight_bounds(min_point, max_point, sq_radius, found_any,
331 vertex_data, got_mat, mat,
332 InternalName::get_vertex(),
333 cdata, current_thread);
347 bool &found_any,
Thread *current_thread)
const {
350 get_vertex_data(current_thread),
false,
351 LMatrix4::ident_mat(),
362 bool got_mat,
const LMatrix4 &mat,
364 Thread *current_thread)
const {
365 CDReader cdata(_cycler, current_thread);
367 PN_stdfloat sq_radius;
368 do_calc_tight_bounds(min_point, max_point, sq_radius, found_any,
369 vertex_data, got_mat, mat,
370 column_name, cdata, current_thread);
379 mark_internal_bounds_stale(CData *cdata) {
380 cdata->_internal_bounds_stale =
true;
386 INLINE Geom::CDataCache::
389 _geom_result(nullptr),
390 _data_result(nullptr)
397 INLINE Geom::CDataCache::
398 CDataCache(
const Geom::CDataCache ©) :
399 _source(copy._source),
400 _geom_result(copy._geom_result),
401 _data_result(copy._data_result)
403 if (_geom_result != _source && _geom_result !=
nullptr) {
412 INLINE
void Geom::CDataCache::
414 if (geom_result != _geom_result) {
415 if (_geom_result != _source && _geom_result !=
nullptr) {
418 _geom_result = geom_result;
419 if (_geom_result != _source && _geom_result !=
nullptr) {
423 _data_result = data_result;
429 INLINE Geom::CacheKey::
431 _source_data(source_data),
439 INLINE Geom::CacheKey::
440 CacheKey(
const CacheKey ©) :
441 _source_data(copy._source_data),
442 _modifier(copy._modifier)
449 INLINE Geom::CacheKey::
450 CacheKey(CacheKey &&from) noexcept :
451 _source_data(std::move(from._source_data)),
452 _modifier(std::move(from._modifier))
461 if (_modifier != other._modifier) {
462 int compare = _modifier->geom_compare_to(*other._modifier);
464 return (compare < 0);
467 if (_source_data != other._source_data) {
468 return (_source_data < other._source_data);
476 INLINE Geom::CacheEntry::
480 _key(source_data, modifier)
487 INLINE Geom::CacheEntry::
497 INLINE Geom::CacheEntry::
509 _primitive_type(PT_none),
510 _shade_model(SM_uniform),
513 _internal_bounds_stale(true),
524 _primitive_type(PT_none),
525 _shade_model(SM_uniform),
528 _internal_bounds_stale(true),
536 INLINE GeomPipelineReader::
537 GeomPipelineReader(
Thread *current_thread) :
539 _current_thread(current_thread),
547 INLINE GeomPipelineReader::
548 GeomPipelineReader(
const Geom *
object,
Thread *current_thread) :
550 _current_thread(current_thread),
551 _cdata(object->_cycler.read_unlocked(current_thread))
554 nassertv(_object->test_ref_count_nonzero());
558 #endif // DO_PIPELINING 564 INLINE GeomPipelineReader::
565 ~GeomPipelineReader() {
567 if (_object !=
nullptr) {
568 nassertv(_object->test_ref_count_nonzero());
574 if (_cdata !=
nullptr) {
577 #endif // DO_PIPELINING 588 INLINE
void GeomPipelineReader::
589 set_object(
const Geom *
object) {
590 if (
object != _object) {
594 if (_cdata !=
nullptr) {
597 #endif // DO_PIPELINING 599 _cdata =
object->_cycler.read_unlocked(_current_thread);
603 #endif // DO_PIPELINING 612 INLINE
const Geom *GeomPipelineReader::
620 INLINE
Thread *GeomPipelineReader::
621 get_current_thread()
const {
622 return _current_thread;
628 INLINE GeomPipelineReader::PrimitiveType GeomPipelineReader::
629 get_primitive_type()
const {
630 return _cdata->_primitive_type;
636 INLINE GeomPipelineReader::ShadeModel GeomPipelineReader::
637 get_shade_model()
const {
638 return _cdata->_shade_model;
644 INLINE
int GeomPipelineReader::
645 get_geom_rendering()
const {
646 return _cdata->_geom_rendering;
653 get_vertex_data()
const {
654 return _cdata->_data.get_read_pointer();
660 INLINE
int GeomPipelineReader::
661 get_num_primitives()
const {
662 return _cdata->_primitives.size();
669 get_primitive(
int i)
const {
670 nassertr(i >= 0 && i < (
int)_cdata->_primitives.size(),
nullptr);
671 return _cdata->_primitives[i].get_read_pointer();
678 get_modified()
const {
679 return _cdata->_modified;
696 return ((
Geom *)_object)->prepare_now(prepared_objects, gsg);
699 INLINE std::ostream &
700 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...