uncache method
Deallocates all memory resources for the passed objects of this AnimationObjectGroup
.
Implementation
void uncache(List<Mesh> items) {
final objects = _objects,
indicesByUUID = _indicesByUUID,
bindings = _bindings,
nBindings = bindings.length;
int nCachedObjects = nCachedObjects_, nObjects = objects.length;
for (int i = 0, n = items.length; i != n; ++i) {
final object = items[i], uuid = object.uuid, index = indicesByUUID[uuid];
if (index != null) {
// delete indicesByUUID[ uuid ];
indicesByUUID.remove(uuid);
if (index < nCachedObjects) {
// object is cached, shrink the CACHED region
final firstActiveIndex = --nCachedObjects,
lastCachedObject = objects[firstActiveIndex],
lastIndex = --nObjects,
lastObject = objects[lastIndex];
// last cached object takes this object's place
indicesByUUID[lastCachedObject.uuid] = index;
objects[index] = lastCachedObject;
// last object goes to the activated slot and pop
indicesByUUID[lastObject.uuid] = firstActiveIndex;
objects[firstActiveIndex] = lastObject;
objects.removeLast();
// accounting is done, now do the same for all bindings
for (int j = 0, m = nBindings; j != m; ++j) {
final bindingsForPath = bindings[j],
lastCached = bindingsForPath[firstActiveIndex],
last = bindingsForPath[lastIndex];
bindingsForPath[index] = lastCached;
bindingsForPath[firstActiveIndex] = last;
bindingsForPath.removeLast();
}
}
else {
// object is active, just swap with the last and pop
final lastIndex = --nObjects, lastObject = objects[lastIndex];
if (lastIndex > 0) {
indicesByUUID[lastObject.uuid] = index;
}
objects[index] = lastObject;
objects.removeLast();
// accounting is done, now do the same for all bindings
for (int j = 0, m = nBindings; j != m; ++j) {
final bindingsForPath = bindings[j];
bindingsForPath[index] = bindingsForPath[lastIndex];
bindingsForPath.removeLast();
}
} // cached or active
} // if object is known
} // for arguments
nCachedObjects_ = nCachedObjects;
}