Cycles: fix sync issue with group instances.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 31 May 2011 10:41:01 +0000 (10:41 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 31 May 2011 10:41:01 +0000 (10:41 +0000)
intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/blender/blender_util.h

index 51fd743956d638040377e42f65f46002020db606..932cb2bad417192df7998ef9fc0668124f506f92 100644 (file)
@@ -65,13 +65,13 @@ bool BlenderSync::object_is_light(BL::Object b_ob)
 
 /* Light */
 
-void BlenderSync::sync_light(BL::Object b_ob, Transform& tfm)
+void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm)
 {
        /* test if we need to sync */
        Light *light;
+       ObjectKey key(b_parent, b_index, b_ob);
 
-       /* todo: account for instancing */
-       if(!light_map.sync(&light, b_ob))
+       if(!light_map.sync(&light, b_ob, b_parent, key))
                return;
 
        /* location */
@@ -98,7 +98,7 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
 {
        /* light is handled separately */
        if(object_is_light(b_ob)) {
-               sync_light(b_ob, tfm);
+               sync_light(b_parent, b_index, b_ob, tfm);
                return;
        }
 
@@ -112,7 +112,7 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
        bool object_updated = false;
 
        /* object sync */
-       if(object_map.sync(&object, b_ob, key)) {
+       if(object_map.sync(&object, b_ob, b_parent, key)) {
                object->name = b_ob.name();
                object->tfm = tfm;
                object->tag_update(scene);
index f1fce37bfaf7eefab6bea1952d0c1a38877ffd8b..732a1b30260b76aa64194fab025d61dc5066729a 100644 (file)
@@ -76,7 +76,7 @@ private:
        void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
        Mesh *sync_mesh(BL::Object b_ob, bool object_updated);
        void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm);
-       void sync_light(BL::Object b_ob, Transform& tfm);
+       void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm);
 
        /* util */
        void find_shader(BL::ID id, vector<uint>& used_shaders);
@@ -91,7 +91,7 @@ private:
        id_map<void*, Shader> shader_map;
        id_map<ObjectKey, Object> object_map;
        id_map<void*, Mesh> mesh_map;
-       id_map<void*, Light> light_map;
+       id_map<ObjectKey, Light> light_map;
        void *world_map;
        bool world_recalc;
 
index 715dc7e6fb02f8b34ee0d380817a9abebf1dd9cb..354a195758ffe2fd3194b015888bc81da1c6069e 100644 (file)
@@ -225,10 +225,10 @@ public:
 
        bool sync(T **r_data, BL::ID id)
        {
-               return sync(r_data, id, id.ptr.id.data);
+               return sync(r_data, id, id, id.ptr.id.data);
        }
 
-       bool sync(T **r_data, BL::ID id, const K& key)
+       bool sync(T **r_data, BL::ID id, BL::ID parent, const K& key)
        {
                T *data = find(key);
                bool recalc;
@@ -240,8 +240,11 @@ public:
                        b_map[key] = data;
                        recalc = true;
                }
-               else
+               else {
                        recalc = (b_recalc.find(id.ptr.data) != b_recalc.end());
+                       if(parent.ptr.data)
+                               recalc = recalc || (b_recalc.find(parent.ptr.data) != b_recalc.end());
+               }
 
                used(data);