Cycles: fix instanced mesh sync being a bit too slow.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 31 May 2011 10:57:43 +0000 (10:57 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 31 May 2011 10:57:43 +0000 (10:57 +0000)
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_sync.h

index e18a67bed8f2009c7abd38d763abe881a4212710..36f87a6100ae41228aa469633a0d1ff77a2ff086 100644 (file)
@@ -252,6 +252,12 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated)
                }
        }
 
+       /* ensure we only sync instanced meshes once */
+       if(mesh_synced.find(mesh) != mesh_synced.end())
+               return mesh;
+       
+       mesh_synced.insert(mesh);
+
        /* create derived mesh */
        BL::Mesh b_mesh = object_to_mesh(b_ob, b_scene, true, !preview);
        /* todo: this will crash on non-mesh types! */
index 932cb2bad417192df7998ef9fc0668124f506f92..241cbf07357b2cc0b74a3604c725719813e0e7c9 100644 (file)
@@ -139,6 +139,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
        light_map.pre_sync();
        mesh_map.pre_sync();
        object_map.pre_sync();
+       mesh_synced.clear();
 
        /* object loop */
        BL::Scene::objects_iterator b_ob;
@@ -177,6 +178,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
                scene->mesh_manager->tag_update(scene);
        if(object_map.post_sync())
                scene->object_manager->tag_update(scene);
+       mesh_synced.clear();
 }
 
 CCL_NAMESPACE_END
index 732a1b30260b76aa64194fab025d61dc5066729a..16ce1998a246e2ef668cee958bdcc83acc37b79c 100644 (file)
@@ -92,6 +92,7 @@ private:
        id_map<ObjectKey, Object> object_map;
        id_map<void*, Mesh> mesh_map;
        id_map<ObjectKey, Light> light_map;
+       set<Mesh*> mesh_synced;
        void *world_map;
        bool world_recalc;