transform optimization

This commit is contained in:
David Rose 2002-04-10 00:48:04 +00:00
parent 4c1e4ad1e2
commit 220601848e
2 changed files with 24 additions and 0 deletions

View File

@ -150,6 +150,18 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
_effects = DCAST(RenderEffects, 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.
pi += complete_up_list(_up, p_list + pi, manager);
pi += complete_down_list(_down, p_list + pi, manager);

View File

@ -235,8 +235,20 @@ operator < (const TransformState &other) const {
return c < 0;
}
/*
// Otherwise, compare the matrices.
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);
}
////////////////////////////////////////////////////////////////////