uncache method
Implementation
uncache(List<Mesh> items) {
var objects = _objects,
indicesByUUID = _indicesByUUID,
bindings = _bindings,
nBindings = bindings.length;
var nCachedObjects = nCachedObjects_, nObjects = objects.length;
for (var i = 0, n = items.length; i != n; ++i) {
var 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
var 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;
pop(objects);
// accounting is done, now do the same for all bindings
for (var j = 0, m = nBindings; j != m; ++j) {
var bindingsForPath = bindings[j],
lastCached = bindingsForPath[firstActiveIndex],
last = bindingsForPath[lastIndex];
bindingsForPath[index] = lastCached;
bindingsForPath[firstActiveIndex] = last;
bindingsForPath.pop();
}
} else {
// object is active, just swap with the last and pop
var lastIndex = --nObjects, lastObject = objects[lastIndex];
if (lastIndex > 0) {
indicesByUUID[lastObject.uuid] = index;
}
objects[index] = lastObject;
pop(objects);
// accounting is done, now do the same for all bindings
for (var j = 0, m = nBindings; j != m; ++j) {
var bindingsForPath = bindings[j];
bindingsForPath[index] = bindingsForPath[lastIndex];
pop(bindingsForPath);
}
} // cached or active
} // if object is known
} // for arguments
nCachedObjects_ = nCachedObjects;
}