21 GeomMunger::Registry *GeomMunger::_registry =
nullptr;
35 Registry *registry = get_registry();
37 _registered_key = registry->_mungers.end();
49 Registry *registry = get_registry();
51 _registered_key = registry->_mungers.end();
60 nassertv(!_is_registered);
69 nassertv(_formats_by_animation.empty());
80 nassertv(_is_registered);
96 bool force,
Thread *current_thread) {
104 Geom::Cache::const_iterator ci = geom->_cache.find(&key);
105 if (ci == geom->_cache.end()) {
108 entry = (*ci).second;
110 nassertr(entry->_source == geom,
false);
114 entry->refresh(current_thread);
118 if (cdata->_source == geom &&
119 cdata->_geom_result !=
nullptr &&
120 geom->get_modified(current_thread) <= cdata->_geom_result->get_modified(current_thread) &&
121 data->get_modified(current_thread) <= cdata->_data_result->get_modified(current_thread)) {
124 geom = cdata->_geom_result;
125 data = cdata->_data_result;
141 PStatTimer timer(_munge_pcollector, current_thread);
143 PT(
Geom) orig_geom = (
Geom *)geom.p();
144 data = munge_data(data);
145 munge_geom_impl(geom, data, current_thread);
148 if (entry ==
nullptr) {
155 bool inserted = orig_geom->_cache.insert(Geom::Cache::value_type(&entry->_key, entry)).second;
164 entry->record(current_thread);
169 cdata->_source = (
Geom *)orig_geom.p();
170 cdata->set_result(geom, data);
182 nassertr(_is_registered,
nullptr);
187 Formats &formats = _formats_by_animation[animation];
189 Formats::iterator fi;
190 fi = formats.find(format);
191 if (fi != formats.end()) {
197 CPT(
GeomVertexFormat) derived_format = munge_format_impl(format, animation);
198 nassertr(derived_format->is_registered(),
nullptr);
201 bool inserted = formats.insert(Formats::value_type(format, derived_format)).second;
202 nassertr(inserted,
nullptr);
204 return derived_format;
221 nassertr(_is_registered,
nullptr);
225 munge_format(orig_format, orig_format->get_animation());
227 if (new_format == orig_format) {
232 return data->convert_to(new_format);
250 nassertr(_is_registered,
nullptr);
255 Formats::iterator fi;
256 fi = _premunge_formats.find(format);
257 if (fi != _premunge_formats.end()) {
264 nassertr(derived_format->is_registered(),
nullptr);
267 bool inserted = _premunge_formats.insert(Formats::value_type(format, derived_format)).second;
268 nassertr(inserted,
nullptr);
270 return derived_format;
287 nassertr(_is_registered,
nullptr);
292 if (new_format == orig_format) {
297 return data->convert_to(new_format);
315 compare_to_impl(
const GeomMunger *other)
const {
326 geom_compare_to_impl(
const GeomMunger *other)
const {
335 if (_registry ==
nullptr) {
336 _registry =
new Registry;
344 do_register(
Thread *current_thread) {
345 if (gobj_cat.is_debug()) {
347 <<
"GeomMunger::do_register(): " << (
void *)
this <<
"\n";
349 nassertv(!_is_registered);
350 nassertv(_formats_by_animation.empty());
354 CacheEntry *entry =
new CacheEntry;
355 entry->_munger =
this;
356 entry->record(current_thread);
358 _is_registered =
true;
366 if (gobj_cat.is_debug()) {
368 <<
"GeomMunger::do_unregister(): " << (
void *)
this <<
"\n";
370 nassertv(_is_registered);
371 _is_registered =
false;
374 _formats_by_animation.clear();
380 void GeomMunger::CacheEntry::
381 output(std::ostream &out)
const {
382 out <<
"munger " << _munger;
388 GeomMunger::Registry::
415 Mungers::iterator mi = _mungers.insert(munger).first;
418 new_munger->_registered_key = mi;
419 new_munger->do_register(current_thread);
429 void GeomMunger::Registry::
434 nassertv(munger->_registered_key != _mungers.end());
435 _mungers.erase(munger->_registered_key);
436 munger->_registered_key = _mungers.end();
437 munger->do_unregister();
444 void GeomMunger::Registry::
448 Mungers::iterator mi = _mungers.begin();
449 while (mi != _mungers.end()) {
451 Mungers::iterator mnext = mi;
454 if (munger->
get_gsg() == gsg) {
455 nassertv(mi == munger->_registered_key);
457 munger->_registered_key = _mungers.end();
458 munger->do_unregister();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(GeomVertexFormat) GeomMunger
The protected implementation of munge_format().
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded.
void remove_data(const GeomVertexData *data)
Removes a prepared GeomVertexData from the cache.
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_registered() const
Returns true if this munger has been registered, false if it has not.
PT(GeomMunger) GeomMunger
Adds the indicated munger to the registry, if there is not an equivalent munger already there; in eit...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that represents a single element that may be timed and/or counted via stats.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to MutexHolder, but for a light mutex.
void acquire() const
Grabs the lightMutex if it is available.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
void release() const
Releases the lightMutex.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
Similar to MutexHolder, but for a light reentrant mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
TypeHandle is the identifier used to differentiate C++ class types.
GraphicsStateGuardianBase * get_gsg() const
Returns a pointer to the GSG that created this munger.
bool munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, bool force, Thread *current_thread)
Applies the indicated munger to the geom and its data, and returns a (possibly different) geom and da...
bool request_resident() const
Returns true if all the primitive arrays are currently resident in memory.