mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 12:43:44 -04:00
transform optimization
This commit is contained in:
parent
4c1e4ad1e2
commit
220601848e
@ -150,6 +150,18 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
|
|||||||
_effects = DCAST(RenderEffects, p_list[pi++]);
|
_effects = DCAST(RenderEffects, p_list[pi++]);
|
||||||
_transform = DCAST(TransformState, p_list[pi++]);
|
_transform = DCAST(TransformState, p_list[pi++]);
|
||||||
|
|
||||||
|
// Finalize these pointers now to decrement their artificially-held
|
||||||
|
// reference counts. We do this now, rather than later, in case
|
||||||
|
// some other object reassigns them a little later on during
|
||||||
|
// initialization, before they can finalize themselves normally (for
|
||||||
|
// instance, the character may change the node's transform). If
|
||||||
|
// that happens, the pointer may discover that no one else holds its
|
||||||
|
// reference count when it finalizes, which will constitute a memory
|
||||||
|
// leak (see the comments in TransformState::finalize(), etc.).
|
||||||
|
manager->finalize_now((RenderState *)_state.p());
|
||||||
|
manager->finalize_now((RenderEffects *)_effects.p());
|
||||||
|
manager->finalize_now((TransformState *)_transform.p());
|
||||||
|
|
||||||
// Get the parent and child pointers.
|
// Get the parent and child pointers.
|
||||||
pi += complete_up_list(_up, p_list + pi, manager);
|
pi += complete_up_list(_up, p_list + pi, manager);
|
||||||
pi += complete_down_list(_down, p_list + pi, manager);
|
pi += complete_down_list(_down, p_list + pi, manager);
|
||||||
|
@ -235,8 +235,20 @@ operator < (const TransformState &other) const {
|
|||||||
return c < 0;
|
return c < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Otherwise, compare the matrices.
|
// Otherwise, compare the matrices.
|
||||||
return get_mat() < other.get_mat();
|
return get_mat() < other.get_mat();
|
||||||
|
*/
|
||||||
|
|
||||||
|
// On second thought, we don't gain a lot of benefit by going
|
||||||
|
// through all the work of comparing different transforms by matrix.
|
||||||
|
// Doing so ensures that two differently-computed transforms that
|
||||||
|
// happen to encode the same matrix (an unlikely occurrence) will be
|
||||||
|
// collapsed into a single pointer (a tiny benefit). We're better
|
||||||
|
// off not paying the cost of this comparison, and just assuming
|
||||||
|
// that any two differently-computed transforms are essentially
|
||||||
|
// different.
|
||||||
|
return (this < &other);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user