use of org.sunflow.core.Geometry in project joons-renderer by joonhyublee.
the class RenderObjectMap method remove.
final void remove(String name) {
RenderObjectHandle obj = renderObjects.get(name);
if (obj == null) {
UI.printWarning(Module.API, "Unable to remove \"%s\" - object was not defined yet");
return;
}
UI.printDetailed(Module.API, "Removing object \"%s\"", name);
renderObjects.remove(name);
// references to the old object still around
switch(obj.type) {
case SHADER:
Shader s = obj.getShader();
for (FastHashMap.Entry<String, RenderObjectHandle> e : renderObjects) {
Instance i = e.getValue().getInstance();
if (i != null) {
UI.printWarning(Module.API, "Removing shader \"%s\" from instance \"%s\"", name, e.getKey());
i.removeShader(s);
}
}
break;
case MODIFIER:
Modifier m = obj.getModifier();
for (FastHashMap.Entry<String, RenderObjectHandle> e : renderObjects) {
Instance i = e.getValue().getInstance();
if (i != null) {
UI.printWarning(Module.API, "Removing modifier \"%s\" from instance \"%s\"", name, e.getKey());
i.removeModifier(m);
}
}
break;
case GEOMETRY:
{
Geometry g = obj.getGeometry();
for (FastHashMap.Entry<String, RenderObjectHandle> e : renderObjects) {
Instance i = e.getValue().getInstance();
if (i != null && i.hasGeometry(g)) {
UI.printWarning(Module.API, "Removing instance \"%s\" because it referenced geometry \"%s\"", e.getKey(), name);
remove(e.getKey());
}
}
break;
}
case INSTANCE:
rebuildInstanceList = true;
break;
case LIGHT:
rebuildLightList = true;
break;
default:
// no dependencies
break;
}
}
Aggregations