[Bf-blender-cvs] [dd752476b97] soc-2018-bevel: Added face strength in bevel modifier

Rohan Rathi noreply at git.blender.org
Tue Jun 19 19:56:24 CEST 2018


Commit: dd752476b97aa3b35d1359422ca42e33d99ac851
Author: Rohan Rathi
Date:   Tue Jun 19 19:27:08 2018 +0530
Branches: soc-2018-bevel
https://developer.blender.org/rBdd752476b97aa3b35d1359422ca42e33d99ac851

Added face strength in bevel modifier

The selected face strength (Weak/Medium/High) can be used by the WN Modifier
to determine influence of current face in

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_bevel.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index acd1edc022a..428c45697a3 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -142,6 +142,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "loop_slide")
         col.prop(md, "mark_seam")
         col.prop(md, "mark_sharp")
+        
+        col.prop(md, "set_wn_strength")
 
         layout.label(text="Limit Method:")
         layout.row().prop(md, "limit_method", expand=True)
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 148196ec505..d8a7f59cf65 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -5661,6 +5661,7 @@ void BM_mesh_bevel(
 			}
 		}
 
+
 		BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) {
 			if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
 				BLI_assert(find_bevvert(&bp, v) != NULL);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 2400069a49a..3cf1d9f30f2 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -335,7 +335,7 @@ typedef struct BevelModifierData {
 	float bevel_angle;
 	/* if the MOD_BEVEL_VWEIGHT option is set, this will be the name of the vert group, MAX_VGROUP_NAME */
 	int hnmode;
-	float strength;
+	float hn_strength;
 	char defgrp_name[64];
 } BevelModifierData;
 
@@ -357,6 +357,7 @@ enum {
 /*	MOD_BEVEL_DIST          = (1 << 12), */  /* same as above */
 	MOD_BEVEL_OVERLAP_OK    = (1 << 13),
 	MOD_BEVEL_EVEN_WIDTHS   = (1 << 14),
+	MOD_BEVEL_SET_WN_STR	= (1 << 15),
 };
 
 /* BevelModifierData->val_flags (not used as flags any more) */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 04d8613c8d8..568b5b81ade 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3127,11 +3127,16 @@ static void rna_def_modifier_bevel(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Normal Mode", "Weighting mode for Harden Normals");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
-	prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
+	prop = RNA_def_property(srna, "hn_strength", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0, 10);
 	RNA_def_property_ui_range(prop, 0, 10, 1, 2);
 	RNA_def_property_ui_text(prop, "Normal Strength", "Strength of calculated normal");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "set_wn_strength", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_BEVEL_SET_WN_STR);
+	RNA_def_property_ui_text(prop, "Face Strength", "Set face strength of beveled faces for use in WN Modifier");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 4df8f1d06ae..7a20eb005f3 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -34,6 +34,7 @@
  
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_scene_types.h"
 
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
@@ -77,6 +78,30 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
 	return dataMask;
 }
 
+static void bevel_set_weighted_normal_face_strength(BMesh *bm, Scene *scene)
+{
+	BMFace *f;
+	BMIter fiter;
+	const char *wn_layer_id = MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID;
+	int cd_prop_int_idx = CustomData_get_named_layer_index(&bm->pdata, CD_PROP_INT, wn_layer_id);
+
+	if (cd_prop_int_idx == -1) {
+		BM_data_layer_add_named(bm, &bm->pdata, CD_PROP_INT, wn_layer_id);
+		cd_prop_int_idx = CustomData_get_named_layer_index(&bm->pdata, CD_PROP_INT, wn_layer_id);
+	}
+	cd_prop_int_idx -= CustomData_get_layer_index(&bm->pdata, CD_PROP_INT);
+	const int cd_prop_int_offset = CustomData_get_n_offset(&bm->pdata, CD_PROP_INT, cd_prop_int_idx);
+
+	const int face_strength = scene->toolsettings->face_strength;
+
+	BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
+		if (BM_elem_flag_test(f, BM_ELEM_TAG)) {
+			int *strength = BM_ELEM_CD_GET_VOID_P(f, cd_prop_int_offset);
+			*strength = face_strength;
+		}
+	}
+}
+
 /*
  * This calls the new bevel code (added since 2.64)
  */
@@ -99,6 +124,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
 	const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
 	const bool mark_seam = (bmd->edge_flags & MOD_BEVEL_MARK_SEAM);
 	const bool mark_sharp = (bmd->edge_flags & MOD_BEVEL_MARK_SHARP);
+	const bool set_wn_strength = (bmd->flags & MOD_BEVEL_SET_WN_STR);
 
 	bm = BKE_mesh_to_bmesh_ex(
 	        mesh,
@@ -171,6 +197,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
 	              vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
 	              dvert, vgroup, mat, loop_slide, mark_seam, mark_sharp, bmd->hnmode, NULL);
 
+	if(set_wn_strength)
+		bevel_set_weighted_normal_face_strength(bm, md->scene);
+
 	result = BKE_bmesh_to_mesh_nomain(bm, &(struct BMeshToMeshParams){0});
 
 	BLI_assert(bm->vtoolflagpool == NULL &&



More information about the Bf-blender-cvs mailing list