[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44256] trunk/blender: BMesh Merge

Campbell Barton ideasman42 at gmail.com
Sun Feb 19 20:12:46 CET 2012


Revision: 44256
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44256
Author:   campbellbarton
Date:     2012-02-19 19:12:36 +0000 (Sun, 19 Feb 2012)
Log Message:
-----------
BMesh Merge
===========

initial merge from BMesh branch,

this replaces the existing mesh format and editmode data structures, for more info see:
http://wiki.blender.org/index.php/Dev:2.6/Source/Modeling/BMesh

this is the work of quite a few developers over the years.


Key Contributors
================

* Geoffrey Bantle (aka) Briggs, original author.
* Joe Eager (aka) joeedh

More recently
* Howard Trickey
* Ender79 aka Ender79 :)


What to Expect
==============

In general blender shouldnt crash on files or totally fail to load scenes,
painting tools etc have been tested to work.

* its quite easy to make the tesselator fail (show holes, missing faces), with non planer ngons.
* most modifiers are working fine but a few had to be re-written - bevel, array - array is much slower, bevel will probably be changed to match trunk soon.
* NavMesh BGE feature isn't functional yet.
* Some UV sticth tools still need porting.
* hair doesnt work right on ngons yet.
* many python scripts will break.
* a python api to BMesh needs to be written still.

(for todo's in code do a searh for BMESH_TODO)

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/blender_mesh.cpp
    trunk/blender/release/scripts/modules/bpy_types.py
    trunk/blender/release/scripts/startup/bl_operators/uvcalc_follow_active.py
    trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py
    trunk/blender/release/scripts/startup/bl_operators/uvcalc_smart_project.py
    trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
    trunk/blender/release/scripts/startup/bl_ui/space_view3d.py
    trunk/blender/source/blender/CMakeLists.txt
    trunk/blender/source/blender/SConscript
    trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    trunk/blender/source/blender/blenkernel/BKE_bmesh.h
    trunk/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
    trunk/blender/source/blender/blenkernel/BKE_customdata.h
    trunk/blender/source/blender/blenkernel/BKE_key.h
    trunk/blender/source/blender/blenkernel/BKE_mesh.h
    trunk/blender/source/blender/blenkernel/BKE_modifier.h
    trunk/blender/source/blender/blenkernel/BKE_multires.h
    trunk/blender/source/blender/blenkernel/BKE_paint.h
    trunk/blender/source/blender/blenkernel/BKE_subsurf.h
    trunk/blender/source/blender/blenkernel/CMakeLists.txt
    trunk/blender/source/blender/blenkernel/SConscript
    trunk/blender/source/blender/blenkernel/intern/BME_Customdata.c
    trunk/blender/source/blender/blenkernel/intern/BME_conversions.c
    trunk/blender/source/blender/blenkernel/intern/BME_eulers.c
    trunk/blender/source/blender/blenkernel/intern/BME_mesh.c
    trunk/blender/source/blender/blenkernel/intern/BME_structure.c
    trunk/blender/source/blender/blenkernel/intern/BME_tools.c
    trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
    trunk/blender/source/blender/blenkernel/intern/anim.c
    trunk/blender/source/blender/blenkernel/intern/bvhutils.c
    trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
    trunk/blender/source/blender/blenkernel/intern/cloth.c
    trunk/blender/source/blender/blenkernel/intern/collision.c
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/blenkernel/intern/customdata.c
    trunk/blender/source/blender/blenkernel/intern/displist.c
    trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
    trunk/blender/source/blender/blenkernel/intern/editderivedmesh.c
    trunk/blender/source/blender/blenkernel/intern/effect.c
    trunk/blender/source/blender/blenkernel/intern/fluidsim.c
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/blenkernel/intern/key.c
    trunk/blender/source/blender/blenkernel/intern/library.c
    trunk/blender/source/blender/blenkernel/intern/mesh.c
    trunk/blender/source/blender/blenkernel/intern/mesh_validate.c
    trunk/blender/source/blender/blenkernel/intern/multires.c
    trunk/blender/source/blender/blenkernel/intern/navmesh_conversion.c
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/blenkernel/intern/particle_system.c
    trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c
    trunk/blender/source/blender/blenkernel/intern/smoke.c
    trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
    trunk/blender/source/blender/blenlib/BLI_scanfill.h
    trunk/blender/source/blender/blenlib/CMakeLists.txt
    trunk/blender/source/blender/blenlib/SConscript
    trunk/blender/source/blender/blenlib/intern/BLI_ghash.c
    trunk/blender/source/blender/blenlib/intern/pbvh.c
    trunk/blender/source/blender/blenlib/intern/scanfill.c
    trunk/blender/source/blender/blenlib/intern/threads.c
    trunk/blender/source/blender/blenloader/SConscript
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/blenpluginapi/SConscript
    trunk/blender/source/blender/collada/GeometryExporter.cpp
    trunk/blender/source/blender/collada/MeshImporter.cpp
    trunk/blender/source/blender/editors/animation/SConscript
    trunk/blender/source/blender/editors/armature/SConscript
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/armature/meshlaplacian.c
    trunk/blender/source/blender/editors/armature/reeb.c
    trunk/blender/source/blender/editors/curve/SConscript
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/curve/editfont.c
    trunk/blender/source/blender/editors/datafiles/SConscript
    trunk/blender/source/blender/editors/gpencil/SConscript
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/include/ED_object.h
    trunk/blender/source/blender/editors/include/ED_util.h
    trunk/blender/source/blender/editors/include/ED_uvedit.h
    trunk/blender/source/blender/editors/include/ED_view3d.h
    trunk/blender/source/blender/editors/interface/SConscript
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/mesh/CMakeLists.txt
    trunk/blender/source/blender/editors/mesh/SConscript
    trunk/blender/source/blender/editors/mesh/editface.c
    trunk/blender/source/blender/editors/mesh/editmesh_add.c
    trunk/blender/source/blender/editors/mesh/loopcut.c
    trunk/blender/source/blender/editors/mesh/mesh_data.c
    trunk/blender/source/blender/editors/mesh/mesh_intern.h
    trunk/blender/source/blender/editors/mesh/mesh_navmesh.c
    trunk/blender/source/blender/editors/mesh/mesh_ops.c
    trunk/blender/source/blender/editors/mesh/meshtools.c
    trunk/blender/source/blender/editors/metaball/mball_edit.c
    trunk/blender/source/blender/editors/object/CMakeLists.txt
    trunk/blender/source/blender/editors/object/SConscript
    trunk/blender/source/blender/editors/object/object_add.c
    trunk/blender/source/blender/editors/object/object_bake.c
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/blender/editors/object/object_hook.c
    trunk/blender/source/blender/editors/object/object_intern.h
    trunk/blender/source/blender/editors/object/object_lattice.c
    trunk/blender/source/blender/editors/object/object_modifier.c
    trunk/blender/source/blender/editors/object/object_ops.c
    trunk/blender/source/blender/editors/object/object_relations.c
    trunk/blender/source/blender/editors/object/object_transform.c
    trunk/blender/source/blender/editors/object/object_vgroup.c
    trunk/blender/source/blender/editors/physics/SConscript
    trunk/blender/source/blender/editors/physics/particle_edit.c
    trunk/blender/source/blender/editors/physics/particle_object.c
    trunk/blender/source/blender/editors/render/CMakeLists.txt
    trunk/blender/source/blender/editors/render/SConscript
    trunk/blender/source/blender/editors/render/render_shading.c
    trunk/blender/source/blender/editors/screen/CMakeLists.txt
    trunk/blender/source/blender/editors/screen/SConscript
    trunk/blender/source/blender/editors/screen/screen_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/CMakeLists.txt
    trunk/blender/source/blender/editors/sculpt_paint/SConscript
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/sculpt_undo.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt_uv.c
    trunk/blender/source/blender/editors/space_api/CMakeLists.txt
    trunk/blender/source/blender/editors/space_api/SConscript
    trunk/blender/source/blender/editors/space_buttons/SConscript
    trunk/blender/source/blender/editors/space_image/CMakeLists.txt
    trunk/blender/source/blender/editors/space_image/SConscript
    trunk/blender/source/blender/editors/space_image/space_image.c
    trunk/blender/source/blender/editors/space_info/CMakeLists.txt
    trunk/blender/source/blender/editors/space_info/SConscript
    trunk/blender/source/blender/editors/space_info/info_stats.c
    trunk/blender/source/blender/editors/space_node/SConscript
    trunk/blender/source/blender/editors/space_view3d/CMakeLists.txt
    trunk/blender/source/blender/editors/space_view3d/SConscript
    trunk/blender/source/blender/editors/space_view3d/drawmesh.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/editors/space_view3d/drawvolume.c
    trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
    trunk/blender/source/blender/editors/space_view3d/view3d_header.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c
    trunk/blender/source/blender/editors/space_view3d/view3d_snap.c
    trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c
    trunk/blender/source/blender/editors/space_view3d/view3d_view.c
    trunk/blender/source/blender/editors/transform/CMakeLists.txt
    trunk/blender/source/blender/editors/transform/SConscript
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform.h
    trunk/blender/source/blender/editors/transform/transform_conversions.c
    trunk/blender/source/blender/editors/transform/transform_generics.c
    trunk/blender/source/blender/editors/transform/transform_manipulator.c
    trunk/blender/source/blender/editors/transform/transform_orientations.c
    trunk/blender/source/blender/editors/transform/transform_snap.c
    trunk/blender/source/blender/editors/util/CMakeLists.txt
    trunk/blender/source/blender/editors/util/SConscript
    trunk/blender/source/blender/editors/util/crazyspace.c
    trunk/blender/source/blender/editors/util/ed_util.c
    trunk/blender/source/blender/editors/util/editmode_undo.c
    trunk/blender/source/blender/editors/util/undo.c
    trunk/blender/source/blender/editors/uvedit/CMakeLists.txt
    trunk/blender/source/blender/editors/uvedit/SConscript
    trunk/blender/source/blender/editors/uvedit/uvedit_buttons.c
    trunk/blender/source/blender/editors/uvedit/uvedit_draw.c
    trunk/blender/source/blender/editors/uvedit/uvedit_intern.h
    trunk/blender/source/blender/editors/uvedit/uvedit_ops.c
    trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c
    trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.h
    trunk/blender/source/blender/editors/uvedit/uvedit_smart_stitch.c
    trunk/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
    trunk/blender/source/blender/gpu/intern/gpu_buffers.c
    trunk/blender/source/blender/makesdna/DNA_customdata_types.h
    trunk/blender/source/blender/makesdna/DNA_defs.h
    trunk/blender/source/blender/makesdna/DNA_key_types.h
    trunk/blender/source/blender/makesdna/DNA_mesh_types.h
    trunk/blender/source/blender/makesdna/DNA_meshdata_types.h
    trunk/blender/source/blender/makesdna/DNA_modifier_types.h
    trunk/blender/source/blender/makesdna/DNA_vec_types.h
    trunk/blender/source/blender/makesdna/intern/SConscript
    trunk/blender/source/blender/makesdna/intern/dna_genfile.c
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/SConscript
    trunk/blender/source/blender/makesrna/intern/CMakeLists.txt
    trunk/blender/source/blender/makesrna/intern/SConscript
    trunk/blender/source/blender/makesrna/intern/rna_mesh.c
    trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c
    trunk/blender/source/blender/makesrna/intern/rna_modifier.c
    trunk/blender/source/blender/makesrna/intern/rna_object.c
    trunk/blender/source/blender/makesrna/intern/rna_object_api.c
    trunk/blender/source/blender/makesrna/intern/rna_scene.c
    trunk/blender/source/blender/makesrna/intern/rna_ui_api.c
    trunk/blender/source/blender/modifiers/CMakeLists.txt
    trunk/blender/source/blender/modifiers/MOD_modifiertypes.h
    trunk/blender/source/blender/modifiers/SConscript
    trunk/blender/source/blender/modifiers/intern/MOD_armature.c
    trunk/blender/source/blender/modifiers/intern/MOD_array.c
    trunk/blender/source/blender/modifiers/intern/MOD_bevel.c
    trunk/blender/source/blender/modifiers/intern/MOD_boolean.c
    trunk/blender/source/blender/modifiers/intern/MOD_boolean_util.c
    trunk/blender/source/blender/modifiers/intern/MOD_build.c
    trunk/blender/source/blender/modifiers/intern/MOD_cast.c
    trunk/blender/source/blender/modifiers/intern/MOD_collision.c
    trunk/blender/source/blender/modifiers/intern/MOD_curve.c
    trunk/blender/source/blender/modifiers/intern/MOD_decimate.c
    trunk/blender/source/blender/modifiers/intern/MOD_displace.c
    trunk/blender/source/blender/modifiers/intern/MOD_edgesplit.c
    trunk/blender/source/blender/modifiers/intern/MOD_explode.c
    trunk/blender/source/blender/modifiers/intern/MOD_fluidsim_util.c
    trunk/blender/source/blender/modifiers/intern/MOD_hook.c
    trunk/blender/source/blender/modifiers/intern/MOD_lattice.c
    trunk/blender/source/blender/modifiers/intern/MOD_mask.c
    trunk/blender/source/blender/modifiers/intern/MOD_meshdeform.c
    trunk/blender/source/blender/modifiers/intern/MOD_mirror.c
    trunk/blender/source/blender/modifiers/intern/MOD_multires.c
    trunk/blender/source/blender/modifiers/intern/MOD_ocean.c
    trunk/blender/source/blender/modifiers/intern/MOD_particleinstance.c
    trunk/blender/source/blender/modifiers/intern/MOD_particlesystem.c
    trunk/blender/source/blender/modifiers/intern/MOD_remesh.c
    trunk/blender/source/blender/modifiers/intern/MOD_screw.c
    trunk/blender/source/blender/modifiers/intern/MOD_shapekey.c
    trunk/blender/source/blender/modifiers/intern/MOD_shrinkwrap.c
    trunk/blender/source/blender/modifiers/intern/MOD_simpledeform.c
    trunk/blender/source/blender/modifiers/intern/MOD_smooth.c
    trunk/blender/source/blender/modifiers/intern/MOD_solidify.c
    trunk/blender/source/blender/modifiers/intern/MOD_subsurf.c
    trunk/blender/source/blender/modifiers/intern/MOD_surface.c
    trunk/blender/source/blender/modifiers/intern/MOD_util.c
    trunk/blender/source/blender/modifiers/intern/MOD_util.h
    trunk/blender/source/blender/modifiers/intern/MOD_uvproject.c
    trunk/blender/source/blender/modifiers/intern/MOD_warp.c
    trunk/blender/source/blender/modifiers/intern/MOD_wave.c
    trunk/blender/source/blender/modifiers/intern/MOD_weightvgedit.c
    trunk/blender/source/blender/modifiers/intern/MOD_weightvgmix.c
    trunk/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c
    trunk/blender/source/blender/render/SConscript
    trunk/blender/source/blender/render/intern/source/convertblender.c
    trunk/blender/source/blender/render/intern/source/render_texture.c
    trunk/blender/source/blender/render/intern/source/strand.c
    trunk/blender/source/blender/windowmanager/SConscript
    trunk/blender/source/blender/windowmanager/intern/wm_gesture.c
    trunk/blender/source/blenderplayer/CMakeLists.txt
    trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c
    trunk/blender/source/creator/CMakeLists.txt
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    trunk/blender/source/gameengine/Ketsji/KX_NavMeshObject.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp

Added Paths:
-----------
    trunk/blender/source/blender/blenkernel/BKE_tessmesh.h
    trunk/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
    trunk/blender/source/blender/blenlib/BLI_smallhash.h
    trunk/blender/source/blender/blenlib/BLI_sparsemap.h
    trunk/blender/source/blender/blenlib/intern/smallhash.c
    trunk/blender/source/blender/editors/mesh/bmesh_select.c
    trunk/blender/source/blender/editors/mesh/bmesh_selecthistory.c
    trunk/blender/source/blender/editors/mesh/bmesh_tools.c
    trunk/blender/source/blender/editors/mesh/bmesh_utils.c
    trunk/blender/source/blender/editors/mesh/editmesh_bvh.c
    trunk/blender/source/blender/editors/mesh/editmesh_bvh.h
    trunk/blender/source/blender/editors/mesh/knifetool.c
    trunk/blender/source/blender/makesrna/intern/rna_mesh_utils.h
    trunk/blender/source/blender/modifiers/intern/MOD_ngoninterp.c

Removed Paths:
-------------
    trunk/blender/source/blender/editors/mesh/editmesh.c
    trunk/blender/source/blender/editors/mesh/editmesh_lib.c
    trunk/blender/source/blender/editors/mesh/editmesh_loop.c
    trunk/blender/source/blender/editors/mesh/editmesh_mods.c
    trunk/blender/source/blender/editors/mesh/editmesh_tools.c

Modified: trunk/blender/intern/cycles/blender/blender_mesh.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_mesh.cpp	2012-02-19 18:41:30 UTC (rev 44255)
+++ trunk/blender/intern/cycles/blender/blender_mesh.cpp	2012-02-19 19:12:36 UTC (rev 44256)
@@ -115,9 +115,9 @@
 
 	/* create vertex color attributes */
 	{
-		BL::Mesh::vertex_colors_iterator l;
+		BL::Mesh::tessface_vertex_colors_iterator l;
 
-		for(b_mesh.vertex_colors.begin(l); l != b_mesh.vertex_colors.end(); ++l) {
+		for(b_mesh.tessface_vertex_colors.begin(l); l != b_mesh.tessface_vertex_colors.end(); ++l) {
 			if(!mesh_need_attribute(scene, mesh, ustring(l->name().c_str())))
 				continue;
 
@@ -147,9 +147,9 @@
 
 	/* create uv map attributes */
 	{
-		BL::Mesh::uv_textures_iterator l;
+		BL::Mesh::tessface_uv_textures_iterator l;
 
-		for(b_mesh.uv_textures.begin(l); l != b_mesh.uv_textures.end(); ++l) {
+		for(b_mesh.tessface_uv_textures.begin(l); l != b_mesh.tessface_uv_textures.end(); ++l) {
 			Attribute::Standard std = (l->active_render())? Attribute::STD_UV: Attribute::STD_NONE;
 			ustring name = ustring(l->name().c_str());
 

Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py	2012-02-19 18:41:30 UTC (rev 44255)
+++ trunk/blender/release/scripts/modules/bpy_types.py	2012-02-19 19:12:36 UTC (rev 44256)
@@ -373,7 +373,8 @@
         """
         self.vertices.add(len(vertices))
         self.edges.add(len(edges))
-        self.faces.add(len(faces))
+        self.loops.add(sum((len(f) for f in faces)))
+        self.polygons.add(len(faces))
 
         vertices_flat = [f for v in vertices for f in v]
         self.vertices.foreach_set("co", vertices_flat)
@@ -383,20 +384,16 @@
         self.edges.foreach_set("vertices", edges_flat)
         del edges_flat
 
-        def treat_face(f):
-            if len(f) == 3:
-                if f[2] == 0:
-                    return f[2], f[0], f[1], 0
-                else:
-                    return f[0], f[1], f[2], 0
-            elif f[2] == 0 or f[3] == 0:
-                return f[2], f[3], f[0], f[1]
-            return f
+        # this is different in bmesh
+        loop_index = 0
+        for i, p in enumerate(self.polygons):
+            f = faces[i]
+            loop_len = len(f)
+            p.loop_start = loop_index
+            p.loop_total = loop_len
+            p.vertices = f
+            loop_index += loop_len
 
-        faces_flat = [v for f in faces for v in treat_face(f)]
-        self.faces.foreach_set("vertices_raw", faces_flat)
-        del faces_flat
-
     @property
     def edge_keys(self):
         return [ed.key for ed in self.edges]
@@ -445,7 +442,21 @@
                     ord_ind(verts[3], verts[0]),
                     )
 
+class MeshPolygon(StructRNA):
+    __slots__ = ()
 
+    @property
+    def edge_keys(self):
+        verts = self.vertices[:]
+        vlen = len(self.vertices)
+        return [ord_ind(verts[i], verts[(i+1) % vlen]) for i in range(vlen)]
+
+    @property
+    def loops(self):
+        start = self.loop_start
+        end = start + self.loop_total
+        return range(start, end)
+
 class Text(bpy_types.ID):
     __slots__ = ()
 

Modified: trunk/blender/release/scripts/startup/bl_operators/uvcalc_follow_active.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/uvcalc_follow_active.py	2012-02-19 18:41:30 UTC (rev 44255)
+++ trunk/blender/release/scripts/startup/bl_operators/uvcalc_follow_active.py	2012-02-19 19:12:36 UTC (rev 44256)
@@ -30,6 +30,7 @@
 
     me = obj.data
     me_verts = me.vertices
+
     # script will fail without UVs
     if not me.uv_textures:
         me.uv_textures.new()
@@ -52,18 +53,16 @@
         '''
 
         def face_edge_vs(vi):
-            # assume a quad
-            return [(vi[0], vi[1]), (vi[1], vi[2]), (vi[2], vi[3]), (vi[3], vi[0])]
+            vlen = len(vi)
+            return [(vi[i], vi[(i+1) % vlen]) for i in range(vlen)]
 
         vidx_source = face_source.vertices
         vidx_target = face_target.vertices
 
-        faceUVsource = me.uv_textures.active.data[face_source.index]
-        uvs_source = [faceUVsource.uv1, faceUVsource.uv2, faceUVsource.uv3, faceUVsource.uv4]
+        uv_layer = me.uv_loop_layers.active.data
+        uvs_source = [uv_layer[i].uv for i in face_source.loops]
+        uvs_target = [uv_layer[i].uv for i in face_target.loops]
 
-        faceUVtarget = me.uv_textures.active.data[face_target.index]
-        uvs_target = [faceUVtarget.uv1, faceUVtarget.uv2, faceUVtarget.uv3, faceUVtarget.uv4]
-
         # vertex index is the key, uv is the value
 
         uvs_vhash_source = {vindex: uvs_source[i] for i, vindex in enumerate(vidx_source)}
@@ -135,15 +134,12 @@
             uvs_vhash_target[edgepair_outer_target[iB]][:] = uvs_vhash_source[edgepair_inner_source[0]] + (uvs_vhash_source[edgepair_inner_source[0]] - uvs_vhash_source[edgepair_outer_source[1]])
             uvs_vhash_target[edgepair_outer_target[iA]][:] = uvs_vhash_source[edgepair_inner_source[1]] + (uvs_vhash_source[edgepair_inner_source[1]] - uvs_vhash_source[edgepair_outer_source[0]])
 
-    if not me.uv_textures:
-        me.uv_textures.new()
-
-    face_act = me.faces.active
+    face_act = me.polygons.active
     if face_act == -1:
         operator.report({'ERROR'}, "No active face")
         return
 
-    face_sel = [f for f in me.faces if len(f.vertices) == 4 and f.select]
+    face_sel = [f for f in me.polygons if len(f.vertices) == 4 and f.select]
 
     face_act_local_index = -1
     for i, f in enumerate(face_sel):

Modified: trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py	2012-02-19 18:41:30 UTC (rev 44255)
+++ trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py	2012-02-19 19:12:36 UTC (rev 44256)
@@ -88,8 +88,8 @@
             self.children = []
 
         else:  # blender face
-            # self.uv = data.uv
-            self.uv = data.id_data.uv_textures.active.data[data.index].uv  # XXX25
+            uv_layer = data.id_data.uv_loop_layers.active.data
+            self.uv = [uv_layer[i].uv for i in data.loops]
 
             # cos = [v.co for v in data]
             cos = [data.id_data.vertices[v].co for v in data.vertices]  # XXX25
@@ -158,7 +158,8 @@
                 I = [i for a, i in angles_co]
 
                 #~ fuv = f.uv
-                fuv = f.id_data.uv_textures.active.data[f.index].uv  # XXX25
+                uv_layer = f.id_data.uv_loop_layers.active.data
+                fuv = [uv_layer[i].uv for i in f.loops]  # XXX25
 
                 if self.rot:
                     fuv[I[2]] = p1
@@ -219,15 +220,10 @@
         face_groups = []
 
     for me in meshes:
-        # Add face UV if it does not exist.
-        # All new faces are selected.
-        if not me.uv_textures:
-            me.uv_textures.new()
-
         if PREF_SEL_ONLY:
-            faces = [f for f in me.faces if f.select]
+            faces = [f for f in me.polygons if f.select]
         else:
-            faces = me.faces[:]
+            faces = me.polygons[:]
 
         if PREF_PACK_IN_ONE:
             face_groups[0].extend(faces)
@@ -237,6 +233,11 @@
         if PREF_NEW_UVLAYER:
             me.uv_textures.new()
 
+        # Add face UV if it does not exist.
+        # All new faces are selected.
+        if not me.uv_textures:
+            me.uv_textures.new()
+
     for face_sel in face_groups:
         print("\nStarting unwrap")
 
@@ -504,7 +505,7 @@
 
             for f in face_sel:
                 # f.image = image
-                f.id_data.uv_textures.active.data[f.index].image = image  # XXX25
+                f.id_data.uv_loop_layers.active.data[f.index].image = image  # XXX25
 
     for me in meshes:
         me.update()
@@ -528,7 +529,7 @@
         if obj and obj.type == 'MESH':
             meshes = [obj.data]
     else:
-        meshes = list({me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if me.faces and me.library is None})
+        meshes = list({me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if me.polygons and me.library is None})
 
     if not meshes:
         operator.report({'ERROR'}, "No mesh object")

Modified: trunk/blender/release/scripts/startup/bl_operators/uvcalc_smart_project.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/uvcalc_smart_project.py	2012-02-19 18:41:30 UTC (rev 44255)
+++ trunk/blender/release/scripts/startup/bl_operators/uvcalc_smart_project.py	2012-02-19 19:12:36 UTC (rev 44256)
@@ -757,12 +757,9 @@
 
 class thickface(object):
     __slost__= "v", "uv", "no", "area", "edge_keys"
-    def __init__(self, face, uvface, mesh_verts):
+    def __init__(self, face, uv_layer, mesh_verts):
         self.v = [mesh_verts[i] for i in face.vertices]
-        if len(self.v)==4:
-            self.uv = uvface.uv1, uvface.uv2, uvface.uv3, uvface.uv4
-        else:
-            self.uv = uvface.uv1, uvface.uv2, uvface.uv3
+        self.uv = [uv_layer[i].uv for i in face.loops]
 
         self.no = face.normal
         self.area = face.area
@@ -892,13 +889,13 @@
         if not me.uv_textures: # Mesh has no UV Coords, don't bother.
             me.uv_textures.new()
 
-        uv_layer = me.uv_textures.active.data
+        uv_layer = me.uv_loop_layers.active.data
         me_verts = list(me.vertices)
 
         if USER_ONLY_SELECTED_FACES:
-            meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces) if f.select]
+            meshFaces = [thickface(f, uv_layer, me_verts) for i, f in enumerate(me.polygons) if f.select]
         else:
-        	meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces)]
+            meshFaces = [thickface(f, uv_layer, me_verts) for i, f in enumerate(me.polygons)]
 
         if not meshFaces:
             continue

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list