Fix #29555: cycles crash rendering with no material in material slot.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 9 Dec 2011 00:24:48 +0000 (00:24 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 9 Dec 2011 00:24:48 +0000 (00:24 +0000)
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/blender/blender_sync.h

index e247b3744fa4216d1d4daef9e96fe12d4e98e97c..4b7651dba4c62690bc00768c98eeff4b50a1fade 100644 (file)
@@ -233,9 +233,9 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated)
        BL::Object::material_slots_iterator slot;
        for(b_ob.material_slots.begin(slot); slot != b_ob.material_slots.end(); ++slot) {
                if(render_layer.material_override)
-                       find_shader(render_layer.material_override, used_shaders);
+                       find_shader(render_layer.material_override, used_shaders, scene->default_surface);
                else
-                       find_shader(slot->material(), used_shaders);
+                       find_shader(slot->material(), used_shaders, scene->default_surface);
        }
 
        if(used_shaders.size() == 0)
index abadee9328ea935829a0bf2ce709d1e59722404c..ec22d3db6f71c197ef79495cd59ee19b2c39f63c 100644 (file)
@@ -137,7 +137,7 @@ void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob,
        /* shader */
        vector<uint> used_shaders;
 
-       find_shader(b_lamp, used_shaders);
+       find_shader(b_lamp, used_shaders, scene->default_light);
 
        if(used_shaders.size() == 0)
                used_shaders.push_back(scene->default_light);
index 930ac1d495aaca557f194709b94eb4a37000eb17..b0dd6988457aaf5a1c7e05877f9e8a38a69fc0d9 100644 (file)
@@ -36,9 +36,9 @@ typedef map<void*, SocketPair> PtrSockMap;
 
 /* Find */
 
-void BlenderSync::find_shader(BL::ID id, vector<uint>& used_shaders)
+void BlenderSync::find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader)
 {
-       Shader *shader = shader_map.find(id);
+       Shader *shader = (id)? shader_map.find(id): scene->shaders[default_shader];
 
        for(size_t i = 0; i < scene->shaders.size(); i++) {
                if(scene->shaders[i] == shader) {
index bde3207e1be4bccf558feffdb55144df115f43f3..83c7f70fd596876f07af39426189e9d312e0ac9b 100644 (file)
@@ -81,7 +81,7 @@ private:
        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);
+       void find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader);
        bool object_is_modified(BL::Object b_ob);
        bool object_is_mesh(BL::Object b_ob);
        bool object_is_light(BL::Object b_ob);