[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43076] trunk/blender/intern/cycles/ blender/blender_mesh.cpp: Fix #29755: cycles crash with array modifier that can produce material indices

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jan 2 16:51:55 CET 2012


Revision: 43076
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43076
Author:   blendix
Date:     2012-01-02 15:51:49 +0000 (Mon, 02 Jan 2012)
Log Message:
-----------
Fix #29755: cycles crash with array modifier that can produce material indices
that are out of bounds.

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/blender_mesh.cpp

Modified: trunk/blender/intern/cycles/blender/blender_mesh.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_mesh.cpp	2012-01-02 15:28:16 UTC (rev 43075)
+++ trunk/blender/intern/cycles/blender/blender_mesh.cpp	2012-01-02 15:51:49 UTC (rev 43076)
@@ -78,8 +78,9 @@
 
 	for(b_mesh.faces.begin(f); f != b_mesh.faces.end(); ++f) {
 		int4 vi = get_int4(f->vertices_raw());
-		int n= (vi[3] == 0)? 3: 4;
-		int shader = used_shaders[f->material_index()];
+		int n = (vi[3] == 0)? 3: 4;
+		int mi = clamp(f->material_index(), 0, used_shaders.size()-1);
+		int shader = used_shaders[mi];
 		bool smooth = f->use_smooth();
 
 		mesh->add_triangle(vi[0], vi[1], vi[2], shader, smooth);



More information about the Bf-blender-cvs mailing list