[Bf-blender-cvs] [5a7eeca97cb] experimental-build: Squashed commit of the following:

Rohan Rathi noreply at git.blender.org
Tue Sep 5 15:28:24 CEST 2017


Commit: 5a7eeca97cb4ead5ef8f5b4c5d9cec6d233f95f7
Author: Rohan Rathi
Date:   Tue Sep 5 18:57:04 2017 +0530
Branches: experimental-build
https://developer.blender.org/rB5a7eeca97cb4ead5ef8f5b4c5d9cec6d233f95f7

Squashed commit of the following:

commit dca08a4440fdc5670bffab9b28120fdacd53364c
Merge: 986b1f6f327 b0bbb5f34f4
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Sep 5 16:25:51 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit 986b1f6f32708b658fea2b77000253b37820e559
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sat Sep 2 12:13:47 2017 +0530

    Added 3 level weighting to modifier. Also did minor cleanup of code

commit 18df6576318bf020476a6f87e93484c5f4ab6dd4
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Aug 29 19:39:17 2017 +0530

    Changed T_CLNOR_INVALIDATE flag as it conflicted with prop edit. Fixed mistake with weighting in modifier making it work differently from average.

commit 8c942d9708e24589b87d6ace14b494f6256d72cd
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Mon Aug 21 22:59:04 2017 +0530

    Made changes to split tool

commit 1b92a80703b6531ff7caa1421cc44f4d23b8527c
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sun Aug 20 21:41:40 2017 +0530

    Made UI changes. Removed binary weighting in average. Changed weight calculation.

commit 96e76ea4a3e0d988389ed3ba5464696e02028628
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Aug 18 20:44:15 2017 +0530

    Made workflow changes to copy, paste. Added add and multiply.

    Did a cleanup of point_normals and split. Added ability to spherize in point_normals. Added reset. Added normal smoothing based on adjacent vertices. Did a cleanup of UI.
    The set of normal tools now share the normal vector in UI. The copy/paste operator now contains all these methods and has been renamed.

commit 342793ef756e0294940e304e251c99f2113b16d9
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Aug 15 22:39:39 2017 +0530

    Fixed bugs in copy and made UI changes

commit 2b5f825ce42e905825a2e14050bfe06dd813c9c7
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sun Aug 13 22:40:32 2017 +0530

    Fixed issues with set normals from faces with smooth faces. All loop normals of smooth fan weren't updated

commit a917e14afa20a2ca29e8fd8b55382825f296a0cf
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sun Aug 13 19:26:25 2017 +0530

    Fixed memalloc bug in lnorspacearr and removed BMO_OPTYPE_FLAG_INVALIDATE_CLNOR_ALL flag

commit 395119d5cebb7aa6e1c5834b06fb7f825e89aa69
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sat Aug 12 18:19:55 2017 +0530

    Changed merge, split and average to make them more coherent.

    Now merge and split are only used to join/split split normals. All other functionality is transferred over to average.

commit 07c700365b80b9d1a868059f2b70f12c98cb77be
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sat Aug 12 09:54:52 2017 +0530

    Added weighting, sharp edges to average.

    Made small UI changes.

commit 28afe63fb71af94757039ddf5d9867c8757e2956
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Aug 11 16:39:41 2017 +0530

    changed weight calculation in modifier

commit 29e5f37bdd86a106233dff859ff0ed7fa293a412
Author: Bastien Montagne <montagne29 at wanadoo.fr>
Date:   Mon Aug 7 10:31:19 2017 +0200

    Fix memleak in Weighted Normals modifier when autosmooth is disabled.

commit 3df612c61fc8e30bc89763ed51dff845c6aa64bc
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Mon Aug 7 07:17:21 2017 +0530

    Fix error in build by including limits.h

commit 7eb51ebaae938801ea9287d68ce8867d40d0ea9b
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sun Aug 6 23:27:59 2017 +0530

    Rewrote the code for sharp edges on weighted modifier.

commit 16289abe5042985b66e393058d9e401c664bda82
Merge: c7e8f0d6dac f5f6f9c9ac3
Author: Bastien Montagne <montagne29 at wanadoo.fr>
Date:   Sun Aug 6 18:42:20 2017 +0200

    Merge branch 'master' into soc-2017-normal-tools

commit c7e8f0d6dacd3239d9171aa467fc48cce1fb768f
Merge: c174f1c8885 e6daa161ddb
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Aug 4 22:13:59 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit c174f1c888584a09d70bc75620db2a1517a6144b
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Aug 4 21:42:59 2017 +0530

    Fixed potential memory leak in modifier

commit 5aab60e60f78c470a87af7e1eafb6b03a1824d4a
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Aug 4 21:35:34 2017 +0530

    Fixed issues with modifier: Adding vertgroups now does not overwrite data. Also added proper weights to sharp edges

commit fd3960a4eb8060c5b86f57778431ee1f0dca4e18
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Aug 4 17:39:56 2017 +0530

    Fixed vgroups editing all loop data in modifier

commit c1af648c33dd9d830bcbfd78540ae5e13e209e60
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Thu Aug 3 19:21:35 2017 +0530

    Fixed the following for weighted modifier:

    1) Now correctly splits loop normal according to sharp edges
    2) Modifier now only acts on active vertex group
    3) Added a check to use smooth/sharp flags as boolean weights

commit d0c25f82966f9bc9b4528814b3bdd074b98edee6
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sun Jul 30 21:38:33 2017 +0530

    Added the following to weighted modifier:

    1) Modifier now respects sharp edges, requires bool value to be checked.
    2) Can now use vertex groups to apply modifier to only selected vgroup
    3) Added boolean (0-1) weights in the form of Smooth/Sharp flags. Smooth flag means the face will hold 0 weight.

commit 8b4d448ec70fe5e000d74e05333757d3cdbbe806
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Jul 28 23:42:01 2017 +0530

    Fixed issues with set_normal_from_faces

commit 6a06b247d85145b6bbd8aadd99d80549064410e7
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Jul 28 19:54:06 2017 +0530

    Added Average and weighting modes to merge.

commit 7c8ecd9226090326e1069f392af6392eef5aa97b
Merge: 33a95c40a35 1bd9531fda7
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Thu Jul 27 22:37:53 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit 33a95c40a35a2adfeb30f8cf8030edbf1aa47a1b
Merge: d586e5557be edc6bec9d60
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Wed Jul 26 14:50:24 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit d586e5557be5a66d19c4934c184a706f6ce894c5
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Wed Jul 26 14:45:15 2017 +0530

    Changed set_normals_from_faces to respect sharp edges.

commit 86e63507470b05cfe290adcbd925879fa8445b48
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Jul 25 23:18:41 2017 +0530

    Fixed issues with Copy Normals

commit 3858f956db41f7c61b04041937e7ff7b0dd468db
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sat Jul 22 17:37:02 2017 +0530

    Added weighted normal modifier.

    Has a weight int which specifies the weights with which face area/corner angle will be exponentially divided. Threshold provides the limit in values which will be weighted equally.

commit 604bd8799e88960bb3472178f25c4f3889b0c791
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Jul 18 18:40:50 2017 +0530

    Added snapping to rotate normal.

    Also added a ui function to point_normals which allows easier editing by creating a sphere box. Shown when align is enabled.

commit 94007a1769864dc0c509f5d46da26adde74b6f70
Merge: 51d49a0f7c0 5c30bc285cd
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sun Jul 16 18:50:00 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit 51d49a0f7c00111a85bf797ca765d9d3f07acd66
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Thu Jul 13 20:50:39 2017 +0530

    Added ability to copy clnors.

    Also contains commented code for averaging, I'll finish it after weighting modes. No hotkeys for copy (yet). You can copy either face normals or single loop normals.
    Here single loop normal means: selecting a vert then a face of the vert will copy loop normal of the face associated with this vert. So, standard vert ->click-> copy wont work.

    click on vert then copy will work if a) Loops of vert are merged b) Loops of vert have same normal value.
    Pasting works with the same standard selection rules

commit 9773709cf1fc53476ddc63abe1756e0584d24fee
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Wed Jul 12 21:34:15 2017 +0530

    Optimised split to faces and fixed preserve_clnor not keeping clnors

commit d438bbfa4378e6a204553ee96b12287fd89df2c4
Merge: 4a7653005b9 440c91b1f64
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Mon Jul 10 17:05:25 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit 4a7653005b99d3f0f186f9c9f80ca979fb15d7e6
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Mon Jul 10 17:00:22 2017 +0530

    Now invalidates all loops in an lnor space

commit 626c9888d7d0fe6038a90a3d5abebf4f641fb7f4
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Jul 4 23:53:06 2017 +0530

    cleanup of point_normals and added poll

commit 55237cfe975e210b1b1cbc865ad5b87040c135fd
Merge: 7376444b842 15fd758bd63
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Jul 4 11:47:40 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit 7376444b842786252da67551dbad756d8cf76217
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Jul 4 11:31:24 2017 +0530

    Fixed all clnors in lnorspace not updating

commit 28061ac85e5d45e7a8cac9b6f678a3c6765f76c2
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Mon Jul 3 13:02:00 2017 +0530

    Fixed bugs and cleanup

commit 448c61b8610b7ae4d9056411762cc21afafe1667
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sat Jul 1 12:03:08 2017 +0530

    Added Split/Merge normals.

    Doesn't work on the basis of any weighting mode. Will have to implement that first. I'll add more methods as I progress in other areas.

commit 41b118c9d96514399f464e21fb778200cd687541
Merge: 5c8a38a8588 bb0e8f1c552
Author: Bastien Montagne <montagne29 at wanadoo.fr>
Date:   Tue Jun 27 15:08:56 2017 +0200

    Merge branch 'master' into soc-2017-normal-tools

    Conflicts:
    	source/blender/python/intern/bpy_props.c

commit 5c8a38a8588e6acf34ad175b580a2d007db6c95d
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Fri Jun 23 11:35:45 2017 +0530

    Added ability to edit individual normal.

    Works by using multiple selection modes, so if yo
    works by using multiple selection modes, so if you select vert then face. Th
    Works by using multiple selection modes.
    So, if you select vert then face, only clnor linked with
    both vert and face will be edited.

    Has some issues though, as vert + edge selection can
    be associated to either of 2 clnors. Need to fix.

commit a2ad1b4e88e155fa0b7457312373c49eeb13754d
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Jun 20 23:03:32 2017 +0530

    Added invalidate for transform ops.

    Can now keep clnors when transform ops are applied. As now invalidation for each function is harder to keep track of, Added a function which rebuilds all the lnor spaces in the mesh when BM_lnorspace_rebuild is called to detect if any unmarked spaces are rebuilt.

commit 137bcc528aeb93ce00294ccf377995392979c99e
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Mon Jun 19 11:11:04 2017 +0530

    Merge branch 'master' into soc-2017-normal-tools

commit 66199cf5409cbc275974ffc92e1981c227758bfb
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Mon Jun 19 11:00:48 2017 +0530

    Added normals to follow mouse location.

    Now M key can be used after ALT - L to have clnors point to mouse location.

commit 1516d8d1d1de3ec178c28e4146b470ae86332dd0
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Thu Jun 15 20:27:01 2017 +0530

    Added point to origin and LMB click

commit 19ff231ff5bbc62425a5c81b00bd3712bc34e01b
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Tue Jun 13 11:34:03 2017 +0530

    Fixed issues with Point Normals.

    Added header, fixed bugs and logic errors in point normals to target. Target location is now editable from UI.
    Also renamed 'bmspacearr' to 'lnor_spacearr'

commit 201689daeb30448f0fa25d3561961b9a33bbf9a6
Author: Bastien Montagne <montagne29 at wanadoo.fr>
Date:   Mon Jun 12 09:32:15 2017 +0200

    Remove support of lnorspacearray in editmesh undo/redo, fix memleak.

    Supporting lnorspacearray in undo/redo would require a deep copy of lnor
    spaces, not only a shallow copy of top struct. And it would eat a fair
    amount of memory, think we'd rather recompute those on undo for now!

    Also, fixed memory leaked by not correctly freeing lnorspace array on
    BMesh deletion.

commit 15279c04d7946946f7b56f97783338958e4f2e0a
Author: Bastien Montagne <montagne29 at wanadoo.fr>
Date:   Mon Jun 12 09:22:19 2017 +0200

    Do not include BKE_mesh.h in bmesh_class.h

    We absolutely avoid such include unless totally mandatory, here we can
    simply keep lnorspaces array a pointer in BMesh struct, and allocate it
    on demand. Also, was breaking bmesh tests building.

    Note: this totally breaks undo/redo, but previous code was utterly
    wrong here as well (shallow copy of lnorspaces, ending up sharing whole
    internal memory -> crash garanteed ;) ). Think we can skip that struct
    for undo/redo for now at least, we can rebuild it in those cases imho...

commit cd9939fa50472ff38ab6266d53264d8f93915414
Merge: 9673aa8c151 00c4f49a6d8
Author: Bastien Montagne <montagne29 at wanadoo.fr>
Date:   Mon Jun 12 08:52:23 2017 +0200

    Merge branch 'master' into soc-2017-normal-tools

commit 9673aa8c151b463e05922b192bcd403c2c7c319e
Author: Rohan Rathi <rohanrathi08 at gmail.com>
Date:   Sun Jun 11 23:21:42 2017 +0530

    Added point normals to target.
    Moved common loop functions and made changes to structure

commit bf892c10fc353aee82cf423de4bebbac5ac7dbd6
Author: RohanRathi <rohanrathi08 at gmail.com>
Date:   Tue Jun 6 11:00:47 2017 +0530

    Added ability to rotate custom normal

commit 5bc15b3f75d5f5ad761b5d7c9ae60d96b8f6b58e
Author: RohanRathi <rohanrathi08 at gmail.com>
Date:   Fri Jun 2 11:46:19 2017 +0530

    Added clnor invalidate for all BMOps

commit cf811e7828d75d9e4b4e83869e60a0069010f68f
Author: RohanRathi <rohanrathi08 at gmail.com>
Date:   Thu Jun 1 11:00:56 2017 +0530

    Cached lnorspace array and added dirty Mechanic

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

M	release/scripts/startup/bl_operators/mesh.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/editderivedmesh.c
M	source/blender/bmesh/bmesh_class.h
M	source/blender/bmesh/intern/bmesh_mesh.c
M	source/blender/bmesh/intern/bmesh_mesh.h
M	source/blender/bmesh/intern/bmesh_operator_api.h
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/editors/mesh/editmesh_undo.c
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/mesh/mesh_intern.h
M	source/blender/editors/mesh/mesh_ops.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_ops.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
M	source/blender/modifiers/intern/MOD_util.c
A	source/blender/modifiers/intern/MOD_weighted_normal.c

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

diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py
index 4edefd7bf9b..95e1fa0a1f2 100644
--- a/release/scripts/startup/bl_operators/mesh.py
+++ b/release/scripts/startup/bl_operators/mesh.py
@@ -203,57 +203,7 @@ class MeshSelectPrev(Operator):
         return {'FINISHED'}
 
 
-# XXX This is hackish (going forth and back from Object mode...), to be redone once we have proper support of
-#     custom normals in BMesh/edit mode.
-class MehsSetNormalsFromFaces(Operator):
-    """Set the custom vertex normals from the selected faces ones"""
-    bl_idname = "mesh.set_normals_from_faces"
-    bl_label = "Set Normals From Faces"
-    bl_options = {'REGISTER', 'UNDO'}
-
-    @classmethod
-    def poll(cls, context):
-        return (context.mode == 'EDIT_MESH' and context.edit_object.data.polygons)
-
-    def execute(self, context):
-        import mathutils
-
-        bpy.ops.object.mode_set(mode='OBJECT')
-        obj = context.active_object
-        me = obj.data
-
-        v2nors = {}
-        for p in me.polygons:
-            if not p.select:
-                continue
-            for lidx, vidx in zip(p.loop_indices, p.vertices):
-                assert(me.loops[lidx].vertex_index == vidx)
-                v2nors.setdefault(vidx, []).append(p.normal)
-
-        for nors in v2nors.values():
-            nors[:] = [sum(nors, mathutils.Vector((0, 0, 0))).normalized()]
-
-        if not me.has_custom_normals:
-            me.create_normals_split()
-        me.calc_normals_split()
-
-        normals = []
-        for l in me.loops:
-            nor = v2nors.get(l.vertex_index, [None])[0]
-            if nor is None:
-                nor = l.normal
-            normals.append(nor.to_tuple())
-
-        me.normals_split_custom_set(normals)
-
-        me.free_normals_split()
-        bpy.ops.object.mode_set(mode='EDIT')
-
-        return {'FINISHED'}
-
-
 classes = (
-    MehsSetNormalsFromFaces,
     MeshMirrorUV,
     MeshSelectNext,
     MeshSelectPrev,
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 14d016dca5f..d489cc9c3a6 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1530,6 +1530,22 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         if md.rest_source == 'BIND':
             layout.operator("object.correctivesmooth_bind", text="Unbind" if is_bind else "Bind")
 
+    def WEIGHTED_NORMAL(self, layout, ob, md):
+        has_vgroup = bool(md.vertex_group)
+
+        col = layout.column()
+        col.label("Weighting Mode:")
+        col.prop(md, "mode", text="")
+
+        layout.prop(md, "weight", text="Weight")
+        layout.prop(md, "thresh", text="Threshold")
+        row = layout.row(align=True)
+        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        row.active = has_vgroup
+        row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
+        layout.prop(md, "keep_sharp")
+        layout.prop(md, "face_influence")
+
 
 classes = (
     DATA_PT_modifiers,
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index eb1b2e5971d..af8d8ee84e4 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -432,7 +432,56 @@ class VIEW3D_PT_tools_shading(View3DPanel, Panel):
         col.label(text="Normals:")
         col.operator("mesh.normals_make_consistent", text="Recalculate")
         col.operator("mesh.flip_normals", text="Flip Direction")
-        col.operator("mesh.set_normals_from_faces", text="Set From Faces")
+
+
+class VIEW3D_PT_tools_normal(View3DPanel, Panel):
+	bl_category = "Shading / UVs"
+	bl_context = "mesh_edit"
+	bl_label = "Normal Tools"
+
+	def draw(self, context):
+		layout = self.layout
+		toolsettings = context.tool_settings
+
+		col = layout.column(align=True)
+		col.operator("mesh.set_normals_from_faces", text="Set From Faces")
+		col.operator("transform.rotate_normal", text = "Rotate Normal")
+		col.operator("mesh.point_normals")
+
+		col = layout.column(align=True)
+		col.label(text="Split/Merge: ")
+
+		col.operator("mesh.merge_loop_normals", text = "Merge Normals")
+		col.operator("mesh.split_loop_normals", text = "Split Normals")
+		
+		col = layout.column(align=True)
+		col.label(text="Average by: ")
+		
+		col.operator_menu_enum("mesh.average_loop_normals", "average_type")
+		
+		col = layout.column(align=True)
+		col.label(text="Normal Vector: ")
+		col.operator("mesh.custom_normal_tools", text="Reset").mode = "Reset"
+		col.prop(toolsettings, "normal_vector", text = '')
+
+		row = col.row(align=True)
+		row.operator("mesh.custom_normal_tools", text="Copy").mode = "Copy"
+		row.operator("mesh.custom_normal_tools", text="Paste").mode = "Paste"
+
+		row = col.row(align=True)
+		row.operator("mesh.custom_normal_tools", text = "Multiply").mode = "Multiply"
+		row.operator("mesh.custom_normal_tools", text="Add").mode = "Add"
+
+		col = layout.column(align=True)
+		col.operator("mesh.smoothen_custom_normals", text="Smoothen")
+
+		col = layout.column(align=True)
+		col.label(text="Face Strength")
+		row = col.row(align=True)
+		
+		row.prop(toolsettings, "face_strength", text="")
+		row.operator("mesh.mod_weighted_strength", text="", icon = "FACESEL").set=False
+		row.operator("mesh.mod_weighted_strength", text="", icon = "ZOOMIN").set=True	
 
 
 class VIEW3D_PT_tools_uvs(View3DPanel, Panel):
@@ -2024,6 +2073,7 @@ classes = (
     VIEW3D_PT_tools_meshweight,
     VIEW3D_PT_tools_add_mesh_edit,
     VIEW3D_PT_tools_shading,
+	VIEW3D_PT_tools_normal,
     VIEW3D_PT_tools_uvs,
     VIEW3D_PT_tools_meshedit_options,
     VIEW3D_PT_tools_transform_curve,
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index f29af28a782..a4c56532df9 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -212,7 +212,7 @@ static void emDM_calcLoopNormalsSpaceArray(
 	cd_loop_clnors_offset = clnors_data ? -1 : CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
 
 	BM_loops_calc_normal_vcos(bm, vertexCos, vertexNos, polyNos, use_split_normals, split_angle, loopNos,
-	                          r_lnors_spacearr, clnors_data, cd_loop_clnors_offset);
+	                          r_lnors_spacearr, clnors_data, cd_loop_clnors_offset, false);
 #ifdef DEBUG_CLNORS
 	if (r_lnors_spacearr) {
 		int i;
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 64a5cad812a..b080c634cdf 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -38,6 +38,8 @@ struct BMEdge;
 struct BMLoop;
 struct BMFace;
 
+struct MLoopNorSpaceArray;
+
 struct BLI_mempool;
 
 /* note: it is very important for BMHeader to start with two
@@ -253,6 +255,9 @@ typedef struct BMesh {
 	ListBase errorstack;
 
 	void *py_handle;
+
+	struct MLoopNorSpaceArray *lnor_spacearr;  /* Stores MLoopNorSpaceArray for this BMesh */
+	char spacearr_dirty;
 } BMesh;
 
 /* BMHeader->htype (char) */
@@ -263,9 +268,31 @@ enum {
 	BM_FACE = 8
 };
 
+typedef struct TransDataLoopNormal {
+	int loop_index;
+	float mtx[3][3];
+	float smtx[3][3];
+	float niloc[3];
+	float nloc[3];
+	float *loc;
+	short *clnors_data;
+} TransDataLoopNormal;
+
+typedef struct LoopNormalData {
+	TransDataLoopNormal *normal;
+
+	int offset;
+	int totloop;
+	void *funcdata;
+} LoopNormalData;
+
 #define BM_ALL (BM_VERT | BM_EDGE | BM_LOOP | BM_FACE)
 #define BM_ALL_NOLOOP (BM_VERT | BM_EDGE | BM_FACE)
 
+#define BM_SPACEARR_DIRTY (1 << 1)
+#define BM_SPACEARR_DIRTY_ALL (1 << 2)
+#define BM_SPACEARR_BMO_SET (1 << 3)
+
 /* args for _Generic */
 #define _BM_GENERIC_TYPE_ELEM_NONCONST \
 	void *, BMVert *, BMEdge *, BMLoop *, BMFace *, \
@@ -345,6 +372,9 @@ enum {
 	 * since tools may want to tag verts and
 	 * not have functions clobber them */
 	BM_ELEM_INTERNAL_TAG = (1 << 7),
+
+	/* Space invalid when set. */
+	BM_ELEM_LNORSPACE = (1 << 6)
 };
 
 struct BPy_BMGeneric;
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index d5d9e4abe2c..b3d1c6b3348 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -30,6 +30,7 @@
 
 #include "DNA_listBase.h"
 #include "DNA_object_types.h"
+#include "DNA_scene_types.h"
 
 #include "BLI_linklist_stack.h"
 #include "BLI_listbase.h"
@@ -270,6 +271,11 @@ void BM_mesh_data_free(BMesh *bm)
 
 	BLI_freelistN(&bm->selected);
 
+	if (bm->lnor_spacearr) {
+		BKE_lnor_spacearr_free(bm->lnor_spacearr);
+		MEM_freeN(bm->lnor_spacearr);
+	}
+
 	BMO_error_clear(bm);
 }
 
@@ -552,7 +558,7 @@ static void bm_mesh_edges_sharp_tag(
 
 /* Check whether gievn loop is part of an unknown-so-far cyclic smooth fan, or not.
  * Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once. */
-static bool bm_mesh_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
+bool bm_mesh_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
 {
 	BMLoop *lfan_pivot_next = l_curr;
 	BMEdge *e_next = l_curr->e;
@@ -589,7 +595,7 @@ static bool bm_mesh_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
  * Will use first clnors_data array, and fallback to cd_loop_clnors_offset (use NULL and -1 to not use clnors). */
 static void bm_mesh_loops_calc_normals(
         BMesh *bm, const float (*vcos)[3], const float (*fnos)[3], float (*r_lnos)[3],
-        MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2], const int cd_loop_clnors_offset)
+        MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2], const int cd_loop_clnors_offset, bool rebuild)
 {
 	BMIter fiter;
 	BMFace *f_curr;
@@ -645,6 +651,8 @@ static void bm_mesh_loops_calc_normals(
 
 		l_curr = l_first = BM_FACE_FIRST_LOOP(f_curr);
 		do {
+			if (rebuild && !BM_elem_flag_test(l_curr, BM_ELEM_LNORSPACE) && !(bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL))
+				continue;
 			/* A smooth edge, we have to check 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list