gobj: Don't wastefully compute bounds for Geom with custom bounds
This was done by `get_nested_vertices()`, which now won't call the expensive `compute_internal_bounds()` if there was a custom bounding volume set.
This commit is contained in:
parent
32297ecd02
commit
7f916eeb74
|
|
@ -83,6 +83,7 @@ Miscellaneous
|
|||
* Fix interrogate syntax error with C++11-style attributes in declarators
|
||||
* Fix regression with BufferViewer in double-precision build (#1365)
|
||||
* Fix `PandaNode.nested_vertices` not updating properly
|
||||
* Prevent Panda calculating bounding volume of Geom with custom bounding volume
|
||||
* Add `do_events()` and `process_event()` snake_case aliases in eventMgr
|
||||
* Support second arg of None in `replace_texture()` / `replace_material()`
|
||||
* Support `os.fspath()` for ConfigVariableFilename objects (#1406)
|
||||
|
|
|
|||
|
|
@ -379,6 +379,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
|
|||
*/
|
||||
INLINE void Geom::
|
||||
mark_internal_bounds_stale(CData *cdata) {
|
||||
cdata->_nested_vertices = 0;
|
||||
cdata->_internal_bounds_stale = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1119,9 +1119,28 @@ int Geom::
|
|||
get_nested_vertices(Thread *current_thread) const {
|
||||
CDLockedReader cdata(_cycler, current_thread);
|
||||
if (cdata->_internal_bounds_stale) {
|
||||
CDWriter cdataw(((Geom *)this)->_cycler, cdata, false);
|
||||
compute_internal_bounds(cdataw, current_thread);
|
||||
return cdataw->_nested_vertices;
|
||||
if (cdata->_user_bounds != nullptr) {
|
||||
// Don't do the expensive compute_internal_bounds call.
|
||||
if (cdata->_nested_vertices == 0) {
|
||||
CDWriter cdataw(((Geom *)this)->_cycler, cdata, false);
|
||||
int num_vertices = 0;
|
||||
|
||||
Primitives::const_iterator pi;
|
||||
for (pi = cdataw->_primitives.begin();
|
||||
pi != cdataw->_primitives.end();
|
||||
++pi) {
|
||||
GeomPrimitivePipelineReader reader((*pi).get_read_pointer(current_thread), current_thread);
|
||||
num_vertices += reader.get_num_vertices();
|
||||
}
|
||||
|
||||
cdataw->_nested_vertices = num_vertices;
|
||||
return num_vertices;
|
||||
}
|
||||
} else {
|
||||
CDWriter cdataw(((Geom *)this)->_cycler, cdata, false);
|
||||
compute_internal_bounds(cdataw, current_thread);
|
||||
return cdataw->_nested_vertices;
|
||||
}
|
||||
}
|
||||
return cdata->_nested_vertices;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue