public IShader lookupShader(string name) { if (name == null) { return(null); } RenderObjectHandle handle = renderObjects.ContainsKey(name) ? renderObjects[name] : null; return((handle == null) ? null : handle.getShader()); }
public void remove(string name) { RenderObjectHandle obj = renderObjects[name]; if (obj == null) { UI.printWarning(UI.Module.API, "Unable to remove \"%s\" - object was not defined yet"); return; } UI.printDetailed(UI.Module.API, "Removing object \"%s\"", name); renderObjects.Remove(name); // scan through all objects to make sure we don't have any // references to the old object still around switch (obj.type) { case RenderObjectType.SHADER: IShader s = obj.getShader(); foreach (KeyValuePair <string, RenderObjectHandle> e in renderObjects) { Instance i = e.Value.getInstance(); if (i != null) { UI.printWarning(UI.Module.API, "Removing shader \"%s\" from instance \"%s\"", name, e.Key); i.removeShader(s); } } break; case RenderObjectType.MODIFIER: Modifier m = obj.getModifier(); foreach (KeyValuePair <string, RenderObjectHandle> e in renderObjects) { Instance i = e.Value.getInstance(); if (i != null) { UI.printWarning(UI.Module.API, "Removing modifier \"%s\" from instance \"%s\"", name, e.Key); i.removeModifier(m); } } break; case RenderObjectType.GEOMETRY: { Geometry g = obj.getGeometry(); foreach (KeyValuePair <string, RenderObjectHandle> e in renderObjects) { Instance i = e.Value.getInstance(); if (i != null && i.hasGeometry(g)) { UI.printWarning(UI.Module.API, "Removing instance \"%s\" because it referenced geometry \"%s\"", e.Key, name); remove(e.Key); } } break; } case RenderObjectType.INSTANCE: rebuildInstanceList = true; break; case RenderObjectType.LIGHT: rebuildLightList = true; break; default: // no dependencies break; } }