Commit: c36d7df933dd248b16823ac01a952741f325fc64
Author: Antony Riakiotakis
Date:   Tue Jun 24 17:08:54 2014 +0300
https://developer.blender.org/rBc36d7df933dd248b16823ac01a952741f325fc64

Fix dm material array generation after last corrections.

===================================================================

M       source/blender/blenkernel/intern/DerivedMesh.c

===================================================================

diff --git a/source/blender/blenkernel/intern/DerivedMesh.c 
b/source/blender/blenkernel/intern/DerivedMesh.c
index 1536820..25cd1a8 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -501,8 +501,11 @@ void DM_update_materials(DerivedMesh *dm, Object *ob)
 
        dm->mat = MEM_callocN(totmat * sizeof(*dm->mat), "DerivedMesh.mat");
 
-       for (i = 1; i < totmat; i++) {
-               dm->mat[i] = give_current_material(ob, i);
+       /* we leave last material as empty - rationale here is being able to 
index
+        * the materials by using the mf->mat_nr directly and leaving the last
+        * material as NULL in case no materials exist on mesh, so indexing 
will not fail */
+       for (i = 0; i < totmat - 1; i++) {
+               dm->mat[i] = give_current_material(ob, i + 1);
        }
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to