[Bf-blender-cvs] [3858f956db4] soc-2017-normal-tools: Added weighted normal modifier.
Rohan Rathi
noreply at git.blender.org
Sat Jul 22 14:07:26 CEST 2017
Commit: 3858f956db41f7c61b04041937e7ff7b0dd468db
Author: Rohan Rathi
Date: Sat Jul 22 17:37:02 2017 +0530
Branches: soc-2017-normal-tools
https://developer.blender.org/rB3858f956db41f7c61b04041937e7ff7b0dd468db
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.
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/bmesh/intern/bmesh_opdefines.c
M source/blender/editors/mesh/editmesh_tools.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_modifier.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_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index d72855fab6b..ef7f46e0954 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1529,6 +1529,14 @@ 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):
+ col = layout.column()
+ col.label("Weighting Mode:")
+ col.prop(md, "mode", text="")
+
+ layout.prop(md, "weight", text="Weight")
+ layout.prop(md, "thresh", text="Threshold")
+
classes = (
DATA_PT_modifiers,
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 65a0be596c0..286fe401eae 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -973,7 +973,8 @@ static BMOpDefine bmo_connect_verts_def = {
bmo_connect_verts_exec,
(BMO_OPTYPE_FLAG_UNTAN_MULTIRES |
BMO_OPTYPE_FLAG_NORMALS_CALC |
- BMO_OPTYPE_FLAG_SELECT_FLUSH),
+ BMO_OPTYPE_FLAG_SELECT_FLUSH |
+ BMO_OPTYPE_FLAG_INVALIDATE_CLNOR_ALL),
};
/*
@@ -1041,7 +1042,8 @@ static BMOpDefine bmo_connect_vert_pair_def = {
bmo_connect_vert_pair_exec,
(BMO_OPTYPE_FLAG_UNTAN_MULTIRES |
BMO_OPTYPE_FLAG_NORMALS_CALC |
- BMO_OPTYPE_FLAG_SELECT_FLUSH),
+ BMO_OPTYPE_FLAG_SELECT_FLUSH |
+ BMO_OPTYPE_FLAG_INVALIDATE_CLNOR_ALL),
};
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index e2ac9552c32..26800d51811 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -6290,8 +6290,6 @@ static int edbm_point_normals_exec(bContext *C, wmOperator *op)
float *center = MEM_mallocN(sizeof(*center) * 3, "__func__");
LoopNormalData *ld = op->customdata;
TransDataLoopNormal *t = ld->normal;
- BMVert *v;
- BMIter viter;
int i = 0;
copy_v3_v3(center, obedit->loc);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 823a7f0812f..1699ef39270 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -87,6 +87,7 @@ typedef enum ModifierType {
eModifierType_CorrectiveSmooth = 51,
eModifierType_MeshSequenceCache = 52,
eModifierType_SurfaceDeform = 53,
+ eModifierType_WeightedNormal = 54,
NUM_MODIFIER_TYPES
} ModifierType;
@@ -1612,6 +1613,21 @@ enum {
MOD_SDEF_MODE_CENTROID = 2,
};
+typedef struct WeightedNormalModifierData {
+ ModifierData modifier;
+
+ short weight;
+ short mode;
+ float thresh;
+} WeightedNormalModifierData;
+
+/* WeightedNormalModifierData.mode */
+enum {
+ MOD_WEIGHTEDNORMAL_MODE_FACE = 0,
+ MOD_WEIGHTEDNORMAL_MODE_ANGLE = 1,
+ MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE = 2,
+};
+
#define MOD_MESHSEQ_READ_ALL \
(MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index a1af3f98274..b86c9956607 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -695,6 +695,7 @@ extern StructRNA RNA_WaveModifier;
extern StructRNA RNA_VertexWeightEditModifier;
extern StructRNA RNA_VertexWeightMixModifier;
extern StructRNA RNA_VertexWeightProximityModifier;
+extern StructRNA RNA_WeightedNormalModifier;
extern StructRNA RNA_Window;
extern StructRNA RNA_WindowManager;
extern StructRNA RNA_WipeSequence;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 1a8dd05a7b5..1cd9b304019 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -74,6 +74,7 @@ EnumPropertyItem rna_enum_object_modifier_type_items[] = {
{eModifierType_WeightVGMix, "VERTEX_WEIGHT_MIX", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Mix", ""},
{eModifierType_WeightVGProximity, "VERTEX_WEIGHT_PROXIMITY", ICON_MOD_VERTEX_WEIGHT,
"Vertex Weight Proximity", ""},
+ {eModifierType_WeightedNormal, "WEIGHTED_NORMAL", ICON_MOD_NORMALEDIT, "Weighted Normal", ""},
{0, "", 0, N_("Generate"), ""},
{eModifierType_Array, "ARRAY", ICON_MOD_ARRAY, "Array", ""},
{eModifierType_Bevel, "BEVEL", ICON_MOD_BEVEL, "Bevel", ""},
@@ -411,6 +412,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_MeshSequenceCacheModifier;
case eModifierType_SurfaceDeform:
return &RNA_SurfaceDeformModifier;
+ case eModifierType_WeightedNormal:
+ return &RNA_WeightedNormalModifier;
/* Default */
case eModifierType_None:
case eModifierType_ShapeKey:
@@ -4752,6 +4755,42 @@ static void rna_def_modifier_surfacedeform(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
+static void rna_def_modifier_weightednormal(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static EnumPropertyItem prop_weighting_mode_items[] = {
+ {MOD_WEIGHTEDNORMAL_MODE_FACE, "FACE_AREA", 0, "Face Area", "Generate face area weighted normals"},
+ {MOD_WEIGHTEDNORMAL_MODE_ANGLE, "CORNER_ANGLE", 0, "Corner Angle", "Generate corner angle weighted normals"},
+ {MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE, "FACE_AREA_WITH_ANGLE", 0, "Face Area with Angle",
+ "Generated normals weighted by both Face Area and Angle" },
+ { 0, NULL, 0, NULL, NULL }
+ };
+
+ srna = RNA_def_struct(brna, "WeightedNormalModifier", "Modifier");
+ RNA_def_struct_ui_text(srna, "WeightedNormal Modifier", "");
+ RNA_def_struct_sdna(srna, "WeightedNormalModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_MOD_NORMALEDIT);
+
+ prop = RNA_def_property(srna, "weight", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 2, 15);
+ RNA_def_property_ui_range(prop, 2, 15, 1, -1);
+ RNA_def_property_ui_text(prop, "Weight", "Weights given to Face Normal for each mode");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_weighting_mode_items);
+ RNA_def_property_ui_text(prop, "Weighting Mode", "Weighted vertex normal mode to use");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "thresh", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0, 5);
+ RNA_def_property_ui_range(prop, 0, 5, 1, 2);
+ RNA_def_property_ui_text(prop, "Thresh", "Threshold value for different weights to be considered equal");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
void RNA_def_modifier(BlenderRNA *brna)
{
StructRNA *srna;
@@ -4870,6 +4909,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_normaledit(brna);
rna_def_modifier_meshseqcache(brna);
rna_def_modifier_surfacedeform(brna);
+ rna_def_modifier_weightednormal(brna);
}
#endif
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index ad2b862141c..687279a15e3 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -100,6 +100,7 @@ set(SRC
intern/MOD_uvproject.c
intern/MOD_warp.c
intern/MOD_wave.c
+ intern/MOD_weighted_normal.c
intern/MOD_weightvg_util.c
intern/MOD_weightvgedit.c
intern/MOD_weightvgmix.c
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index bf121af2bd1..3511b0edbec 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -86,6 +86,7 @@ extern ModifierTypeInfo modifierType_NormalEdit;
extern ModifierTypeInfo modifierType_CorrectiveSmooth;
extern ModifierTypeInfo modifierType_MeshSequenceCache;
extern ModifierTypeInfo modifierType_SurfaceDeform;
+extern ModifierTypeInfo modifierType_WeightedNormal;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index ded1f0b77e6..0fa688fcfef 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -288,5 +288,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(CorrectiveSmooth);
INIT_TYPE(MeshSequenceCache);
INIT_TYPE(SurfaceDeform);
+ INIT_TYPE(WeightedNormal);
#undef INIT_TYPE
}
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
new file mode 100644
index 00000000000..6b42307332e
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -0,0 +1,299 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/modifiers/intern/MOD_weighted_normal.c
+ * \ingroup modifiers
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_mesh.h"
+
+#include "BLI_math.h"
+
+#include "MOD_modifiertypes.h"
+
+typedef struct pair {
+ float val; /* contains mode based value (face area/ corner angle) */
+ int index; /* index value per poly or per loop */
+} pair;
+
+/* Sorting function used in modifier, sorts in non increasing order */
+stat
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list