[Bf-blender-cvs] [3d4f540] testbuild: Squashed commit of current custom split normals work.

Bastien Montagne noreply at git.blender.org
Fri Nov 14 04:28:10 CET 2014


Commit: 3d4f540cf42a46520a03ada98f1d2015a5830316
Author: Bastien Montagne
Date:   Thu Jul 31 17:43:12 2014 +0200
Branches: testbuild
https://developer.blender.org/rB3d4f540cf42a46520a03ada98f1d2015a5830316

Squashed commit of current custom split normals work.

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

M	release/scripts/startup/bl_ui/properties_data_mesh.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/BKE_cdderivedmesh.h
M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/BKE_shrinkwrap.h
M	source/blender/blenkernel/intern/cdderivedmesh.c
M	source/blender/blenkernel/intern/customdata.c
M	source/blender/blenkernel/intern/editderivedmesh.c
M	source/blender/blenkernel/intern/mesh.c
M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/blenkernel/intern/shrinkwrap.c
M	source/blender/blenkernel/intern/subsurf_ccg.c
M	source/blender/bmesh/intern/bmesh_mesh.c
M	source/blender/bmesh/intern/bmesh_mesh.h
M	source/blender/editors/mesh/mesh_data.c
M	source/blender/editors/mesh/mesh_intern.h
M	source/blender/editors/mesh/mesh_ops.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/makesdna/DNA_customdata_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_mesh.c
M	source/blender/makesrna/intern/rna_mesh_api.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
A	source/blender/modifiers/intern/MOD_setsplitnormal.c
M	source/blender/modifiers/intern/MOD_util.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 909c6ab..0270295 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -146,17 +146,26 @@ class DATA_PT_normals(MeshButtonsPanel, Panel):
         layout = self.layout
 
         mesh = context.mesh
+        has_clnors = mesh.has_custom_normals
 
         split = layout.split()
 
         col = split.column()
         col.prop(mesh, "use_auto_smooth")
         sub = col.column()
-        sub.active = mesh.use_auto_smooth
+        sub.active = mesh.use_auto_smooth and not has_clnors
         sub.prop(mesh, "auto_smooth_angle", text="Angle")
 
         split.prop(mesh, "show_double_sided")
 
+        row = layout.row()
+        if has_clnors:
+            row.operator("mesh.customdata_add_clear_custom_splitnormals",
+                         icon='X', text="Clear Custom Split Normals Data")
+        else:
+            row.operator("mesh.customdata_add_clear_custom_splitnormals",
+                         icon='ZOOMIN', text="Add Custom Split Normals Data")
+
 
 class DATA_PT_texture_space(MeshButtonsPanel, Panel):
     bl_label = "Texture Space"
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 5769db5..72ae059 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1222,6 +1222,35 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         col.prop(md, "material_offset", text="Material Offset")
 
+    def SET_SPLIT_NORMAL(self, layout, ob, md):
+        has_vgroup = bool(md.vertex_group)
+        needs_object_geom = (md.mode == 'OBJECT')
+        needs_object_center = (md.mode == 'ELLIPSOID')
+        has_object_center = bool(md.object_center)
+
+        row = layout.row(align=True)
+        row.prop(md, "mode", expand=True)
+
+        split = layout.split()
+
+        col = split.column()
+        row = col.row()
+        row.active = needs_object_geom
+        row.prop(md, "object_geometry", text="")
+
+        row = col.row(align=True)
+        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        sub = row.row(align=True)
+        sub.active = has_vgroup
+        sub.prop(md, "use_invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
+
+        col = split.column()
+        col.active = needs_object_center
+        col.prop(md, "object_center", text="")
+        row = col.row()
+        row.active = not has_object_center
+        row.prop(md, "use_bbox_center")
+
 
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 868d976..58b07d1 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -88,6 +88,7 @@ struct MTFace;
 struct Object;
 struct Scene;
 struct Mesh;
+struct MLoopsNorSpaces;
 struct BMEditMesh;
 struct KeyBlock;
 struct ModifierData;
@@ -198,6 +199,9 @@ struct DerivedMesh {
 	/** Calculate loop (split) normals */
 	void (*calcLoopNormals)(DerivedMesh *dm, const float split_angle);
 
+	/** Calculate loop (split) normals, and returns split loop normal spaces. */
+	void (*calcLoopNormalsSpaces)(DerivedMesh *dm, const float split_angle, struct MLoopsNorSpaces *r_lnors_spaces);
+
 	/** Recalculates mesh tessellation */
 	void (*recalcTessellation)(DerivedMesh *dm);
 
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index dffc2b6..03e6aff 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -40,6 +40,7 @@
 struct DerivedMesh;
 struct BMEditMesh;
 struct Mesh;
+struct MLoopsNorSpaces;
 struct Object;
 
 /* creates a new CDDerivedMesh */
@@ -101,6 +102,8 @@ void CDDM_calc_normals(struct DerivedMesh *dm);
 void CDDM_calc_normals_tessface(struct DerivedMesh *dm);
 
 void CDDM_calc_loop_normals(struct DerivedMesh *dm, const float split_angle);
+void CDDM_calc_loop_normals_spaces(struct DerivedMesh *dm, const float split_angle,
+                                   struct MLoopsNorSpaces *r_lnors_spaces);
 
 /* calculates edges for a CDDerivedMesh (from face data)
  * this completely replaces the current edge data in the DerivedMesh
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index d0c268d..85e8aa5 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -36,6 +36,8 @@ struct BoundBox;
 struct DispList;
 struct EdgeHash;
 struct ListBase;
+struct LinkNode;
+struct MemArena;
 struct BMEditMesh;
 struct BMesh;
 struct Main;
@@ -173,10 +175,6 @@ void BKE_mesh_calc_normals_tessface(
         struct MVert *mverts, int numVerts,
         struct MFace *mfaces, int numFaces,
         float (*r_faceNors)[3]);
-void BKE_mesh_normals_loop_split(
-        struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges,
-        struct MLoop *mloops, float (*r_loopnors)[3], const int numLoops,
-        struct MPoly *mpolys, float (*polynors)[3], const int numPolys, float split_angle);
 void BKE_mesh_loop_tangents_ex(
         struct MVert *mverts, const int numVerts, struct MLoop *mloops, float (*r_looptangent)[4], float (*loopnors)[3],
         struct MLoopUV *loopuv, const int numLoops, struct MPoly *mpolys, const int numPolys,
@@ -184,6 +182,50 @@ void BKE_mesh_loop_tangents_ex(
 void BKE_mesh_loop_tangents(
         struct Mesh *mesh, const char *uvmap, float (*r_looptangents)[4], struct ReportList *reports);
 
+/* XXX This is ugly! */
+#include "BLI_linklist.h"
+#include "BLI_memarena.h"
+#include "BLI_stack.h"
+
+typedef struct MLoopNorSpace {
+	float vec_lnor[3];   /* Automatically computed loop normal. */
+	float vec_ref[3];    /* Reference vector, orthogonal to vec_lnor. */
+	float vec_ortho[3];  /* Third vector, orthogonal to vec_lnor and vec_ref. */
+	float ref_alpha;     /* Reference angle, around vec_ortho, in ]0, pi] range (0.0 marks that space as invalid). */
+	float ref_beta;      /* Reference angle, around vec_lnor, in ]0, 2pi] range (0.0 marks that space as invalid). */
+	LinkNode *loops;     /* All indices (uint_in_ptr) of loops using this lnor space (i.e. smooth fan of loops). */
+} MLoopNorSpace;
+typedef struct MLoopsNorSpaces {
+	MLoopNorSpace **lspaces;
+	MemArena *mem;
+} MLoopsNorSpaces;
+void BKE_init_loops_normal_spaces(MLoopsNorSpaces *lnors_spaces, const int numLoops);
+void BKE_free_loops_normal_spaces(MLoopsNorSpaces *lnors_spaces);
+MLoopNorSpace *BKE_lnor_space_create(MLoopsNorSpaces *lnors_spaces);
+void BKE_lnor_space_define(MLoopNorSpace *lnor_space, const float lnor[3], float vec_ref[3], float vec_other[3],
+                           struct BLI_Stack *edge_vectors);
+void BKE_lnor_space_add_loop(MLoopsNorSpaces *lnors_spaces, MLoopNorSpace *lnor_space, const int ml_index,
+                             const bool add_to_list);
+void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space, float r_custom_lnor[3], const float clnor_data[2]);
+void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space, const float custom_lnor[3], float r_clnor_data[2]);
+
+bool BKE_mesh_has_custom_loop_normals(struct Mesh *me);
+
+void BKE_mesh_normals_loop_split(
+        struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges,
+        struct MLoop *mloops, float (*r_loopnors)[3], const int numLoops,
+        struct MPoly *mpolys, const float (*polynors)[3], const int numPolys, float split_angle,
+        MLoopsNorSpaces *r_lnors_spaces, float (*clnors_data)[2], int *r_loop_to_poly);
+
+void BKE_mesh_normals_loop_custom_set(
+        struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges,
+        struct MLoop *mloops, float (*custom_loopnors)[3], const float *custom_loopnors_facs, const int numLoops,
+        struct MPoly *mpolys, const float (*polynors)[3], const int numPolys, float (*r_clnors_data)[2]);
+void BKE_mesh_normals_loop_custom_from_vertices_set(
+        struct MVert *mverts, float (*custom_vertnors)[3], const float *custom_vertnors_facs, const int numVerts,
+        struct MEdge *medges, const int numEdges, struct MLoop *mloops, const int numLoops,
+        struct MPoly *mpolys, const float (*polynors)[3], const int numPolys, float (*r_clnors_data)[2]);
+
 void BKE_mesh_calc_poly_normal(
         struct MPoly *mpoly, struct MLoop *loopstart,
         struct MVert *mvarray, float no[3]);
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 59de43a..3ada39f 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -74,6 +74,7 @@ typedef struct SpaceTransform {
 void space_transform_from_matrixs(struct SpaceTransform *data, float local[4][4], float target[4][4]);
 void space_transform_apply(const struct SpaceTransform *data, float co[3]);
 void space_transform_invert(const struct SpaceTransform *data, float co[3]);
+void space_transform_invert_normal(const struct SpaceTransform *data, float no[3]);
 
 #define SPACE_TRANSFORM_SETUP(data, local, target) space_transform_from_matrixs(data, (local)->obmat, (target)->obmat)
 
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index ca4a4b3..87383ca 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1889,6 +1889,7 @@ static CDDerivedMesh *cdDM_create(const char *desc)
 
 	dm->calcNormals = CDDM_calc_normals;
 	dm->calcLoopNormals = CDDM_calc_loop_normals;
+	dm->calcLoopNormalsSpaces = CDDM_calc_loop_normals_spaces;
 	dm->recalcTessellation = CDDM_recalc_tessellation;
 
 	dm->getVertCos = cdDM_getVertCos;
@@ -2507,6 +2508,11 @@ void CDDM_calc_normals(DerivedMesh *dm)
 
 void CDDM_calc_loop_normals(DerivedMesh *dm, const float split_angle)
 {
+	CDDM_calc_loop_normals_sp

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list