Search in sources :

Example 1 with Geometry

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;
    }
}
Also used : Geometry(org.sunflow.core.Geometry) Instance(org.sunflow.core.Instance) Shader(org.sunflow.core.Shader) FastHashMap(org.sunflow.util.FastHashMap) Modifier(org.sunflow.core.Modifier)

Aggregations

Geometry (org.sunflow.core.Geometry)1 Instance (org.sunflow.core.Instance)1 Modifier (org.sunflow.core.Modifier)1 Shader (org.sunflow.core.Shader)1 FastHashMap (org.sunflow.util.FastHashMap)1