Fix [#30684] Bmesh AddTorus.execute failure.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 26 Mar 2012 12:43:48 +0000 (12:43 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 26 Mar 2012 12:43:48 +0000 (12:43 +0000)
Done BMESH_TODO (use polys/loops instead of tessfaces).

release/scripts/startup/bl_operators/add_mesh_torus.py

index 74f7b9c0f780eada7bbec45567df294c8fd41065..0cd781f550f573dd10e14f16b55df571a3baa5eb 100644 (file)
@@ -140,19 +140,23 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
             self.minor_radius = extra_helper
 
         verts_loc, faces = add_torus(self.major_radius,
-                                    self.minor_radius,
-                                    self.major_segments,
-                                    self.minor_segments)
+                                     self.minor_radius,
+                                     self.major_segments,
+                                     self.minor_segments)
 
         mesh = bpy.data.meshes.new("Torus")
 
         mesh.vertices.add(len(verts_loc) // 3)
 
-        # BMESH_TODO, use polygons
-        mesh.faces.add(len(faces) // 4)
+        nbr_loops = len(faces)
+        nbr_polys = nbr_loops // 4
+        mesh.loops.add(nbr_loops)
+        mesh.polygons.add(nbr_polys)
 
         mesh.vertices.foreach_set("co", verts_loc)
-        mesh.faces.foreach_set("vertices_raw", faces)
+        mesh.polygons.foreach_set("loop_start", range(0, nbr_loops, 4))
+        mesh.polygons.foreach_set("loop_total", (4,) * nbr_polys)
+        mesh.loops.foreach_set("vertex_index", faces)
         mesh.update()
 
         object_utils.object_data_add(context, mesh, operator=self)