[Bf-blender-cvs] [76a9333] temp_custom_loop_normals: Review updates: Replace 'bbox center' option by an offset one.

Bastien Montagne noreply at git.blender.org
Mon Feb 2 20:23:01 CET 2015


Commit: 76a93336c6cf0c9a28a2a84fbff71261b02dd58b
Author: Bastien Montagne
Date:   Mon Feb 2 19:33:46 2015 +0100
Branches: temp_custom_loop_normals
https://developer.blender.org/rB76a93336c6cf0c9a28a2a84fbff71261b02dd58b

Review updates: Replace 'bbox center' option by an offset one.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_normal_edit.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index d53bd04..91c0abe 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1342,8 +1342,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
     def NORMAL_EDIT(self, layout, ob, md):
         has_vgroup = bool(md.vertex_group)
-        needs_object_bbox_center = (((md.mode == 'RADIAL') and not md.target) or
-                                    ((md.mode == 'DIRECTIONAL') and md.use_directional_parallel))
+        needs_object_offset = (((md.mode == 'RADIAL') and not md.target) or
+                               ((md.mode == 'DIRECTIONAL') and md.use_directional_parallel))
 
         row = layout.row()
         row.prop(md, "mode", expand=True)
@@ -1352,26 +1352,22 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         col = split.column()
         col.prop(md, "target", text="")
-        sub = col.row()
-        sub.active = needs_object_bbox_center
-        sub.prop(md, "use_center_bounds")
-
-        col = split.column()
+        sub = col.column(align=True)
+        sub.active = needs_object_offset
+        sub.prop(md, "offset")
         row = col.row(align=True)
         row.active = (md.mode == 'DIRECTIONAL')
         row.prop(md, "use_directional_parallel")
-        col.prop(md, "use_current_normals")
-
-        split = layout.split()
-        split.active = md.use_current_normals
 
-        col = split.column(align=True)
-        col.label("Mix Mode:")
-        col.prop(md, "mix_mode", text="")
+        col = split.column()
+        col.prop(md, "use_current_normals")
 
-        col = split.column(align=True)
-        col.prop(md, "mix_factor")
-        row = col.row(align=True)
+        subcol = col.column(align=True)
+        subcol.active = md.use_current_normals
+        subcol.label("Mix Mode:")
+        subcol.prop(md, "mix_mode", text="")
+        subcol.prop(md, "mix_factor")
+        row = subcol.row(align=True)
         row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
         sub = row.row(align=True)
         sub.active = has_vgroup
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 86b202e..32a02b5 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1430,7 +1430,7 @@ typedef struct NormalEditModifierData {
 	short mix_mode;
 	short pad_s1;
 	float mix_factor;
-	float pad_f1;
+	float offset[3];
 } NormalEditModifierData;
 
 /* NormalEditModifierData.mode */
@@ -1442,9 +1442,8 @@ enum {
 /* NormalEditModifierData.flags */
 enum {
 	MOD_NORMALEDIT_INVERT_VGROUP            = (1 << 0),
-	MOD_NORMALEDIT_CENTER_BBOX              = (1 << 1),
-	MOD_NORMALEDIT_USE_CURCLNORS            = (1 << 2),
-	MOD_NORMALEDIT_USE_PARALLEL_DIRECTIONAL = (1 << 3),
+	MOD_NORMALEDIT_USE_CURCLNORS            = (1 << 1),
+	MOD_NORMALEDIT_USE_PARALLEL_DIRECTIONAL = (1 << 2),
 };
 
 /* NormalEditModifierData.mix_mode */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 544043d..55b88dd 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4381,6 +4381,11 @@ static void rna_def_modifier_normaledit(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Use Current Normals", "Use current split normals to mix generated ones in");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_float_array(srna, "offset", 3, NULL, -FLT_MAX, FLT_MAX, "Offset",
+	                           "Offset from object's center", -100.0f, 100.0f);
+	RNA_def_property_subtype(prop, PROP_COORDS);
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	prop = RNA_def_property(srna, "mix_mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_items(prop, prop_mix_mode_items);
 	RNA_def_property_ui_text(prop, "Mix Mode", "How to mix new generated normals with existing ones");
@@ -4407,12 +4412,6 @@ static void rna_def_modifier_normaledit(BlenderRNA *brna)
 	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
 	RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 
-	prop = RNA_def_property(srna, "use_bbox_center", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_NORMALEDIT_CENTER_BBOX);
-	RNA_def_property_ui_text(prop, "BoundingBox Center",
-	                         "Use bounding box center instead of own object center as origin");
-	RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
 	prop = RNA_def_property(srna, "use_directional_parallel", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_NORMALEDIT_USE_PARALLEL_DIRECTIONAL);
 	RNA_def_property_boolean_default(prop, true);
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 78638f0..1303a84 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -52,7 +52,7 @@
 #include "MOD_util.h"
 
 
-static void generate_vert_coordinates(DerivedMesh *dm, Object *ob, Object *ob_center, const bool use_bbox_center,
+static void generate_vert_coordinates(DerivedMesh *dm, Object *ob, Object *ob_center, const float offset[3],
                                       const int num_verts, float (*r_cos)[3], float r_size[3])
 {
 	float min_co[3], max_co[3];
@@ -102,12 +102,8 @@ static void generate_vert_coordinates(DerivedMesh *dm, Object *ob, Object *ob_ce
 
 		do_diff = true;
 	}
-	else if (use_bbox_center) {
-		/* Translate our coordinates so that center of bounding box is at (0, 0, 0). */
-
-		/* Compute bbox center in local coordinates. */
-		add_v3_v3v3(diff, min_co, max_co);
-		mul_v3_fl(diff, -0.5f);
+	else if (!is_zero_v3(offset)) {
+		negate_v3_v3(diff, offset);
 
 		do_diff = true;
 	}
@@ -171,7 +167,6 @@ static void normalEditModifier_do_radial(
         MVert *mvert, const int num_verts, MEdge *medge, const int num_edges,
         MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys)
 {
-	const bool use_bbox_center = ((smd->flags & MOD_NORMALEDIT_CENTER_BBOX) != 0) && (smd->target == NULL);
 	int i;
 
 	float (*cos)[3] = MEM_mallocN(sizeof(*cos) * num_verts, __func__);
@@ -180,7 +175,7 @@ static void normalEditModifier_do_radial(
 
 	BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)num_verts, __func__);
 
-	generate_vert_coordinates(dm, ob, smd->target, use_bbox_center, num_verts, cos, size);
+	generate_vert_coordinates(dm, ob, smd->target, smd->offset, num_verts, cos, size);
 
 	/* size gives us our spheroid coefficients (A, B, C).
 	 * Then, we want to find out for each vert its (a, b, c) triple (proportional to (A, B, C) one).
@@ -258,7 +253,6 @@ static void normalEditModifier_do_directional(
         MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys)
 {
 	const bool use_parallel_normals = (smd->flags & MOD_NORMALEDIT_USE_PARALLEL_DIRECTIONAL) != 0;
-	const bool use_bbox_center = (smd->flags & MOD_NORMALEDIT_CENTER_BBOX) != 0;
 
 	float (*cos)[3] = MEM_mallocN(sizeof(*cos) * num_verts, __func__);
 	float (*nos)[3] = MEM_mallocN(sizeof(*nos) * num_loops, __func__);
@@ -280,18 +274,8 @@ static void normalEditModifier_do_directional(
 	if (use_parallel_normals) {
 		float no[3];
 
-		if (use_bbox_center) {
-			float min_co[3], max_co[3];
-
-			/* We use bbox center as ref, instead of object's center (i.e. (0, 0, 0) in local space). */
-			minmax_v3v3_v3_array(min_co, max_co, cos, num_verts);
-			madd_v3_v3v3fl(no, min_co, max_co, 0.5f);
-			sub_v3_v3v3(no, target_co, no);
-			normalize_v3(no);
-		}
-		else {
-			normalize_v3_v3(no, target_co);
-		}
+		sub_v3_v3v3(no, target_co, smd->offset);
+		normalize_v3(no);
 
 		for (i = num_loops; i--; ) {
 			copy_v3_v3(nos[i], no);




More information about the Bf-blender-cvs mailing list