Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-12-22 00:08:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-22 00:13:48 +0400
commitd5263c37faf73d0f6cc2466ac0806fef972119fb (patch)
tree9d5c86e3cd3a39301a6d40586324bda0155241dc /source
parent01acc2a7dcb3ba3bd99f75aac77c14619b10c539 (diff)
Modifier: New Wireframe Modifier
Based on patch originally by Thomas Beck, uses options similar to solidify.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_icons.h2
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h22
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c94
-rw-r--r--source/blender/modifiers/CMakeLists.txt1
-rw-r--r--source/blender/modifiers/MOD_modifiertypes.h1
-rw-r--r--source/blender/modifiers/intern/MOD_util.c1
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c140
9 files changed, 263 insertions, 1 deletions
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index f8e1bbb2413..bbad49d3930 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -592,8 +592,8 @@ DEF_ICON(MOD_OCEAN)
DEF_ICON(MOD_WARP)
DEF_ICON(MOD_SKIN)
DEF_ICON(MOD_TRIANGULATE)
+DEF_ICON(MOD_WIREFRAME) // DEF_ICON(BLANK166)
#ifndef DEF_ICON_BLANK_SKIP
- DEF_ICON(BLANK166)
DEF_ICON(BLANK167)
DEF_ICON(BLANK168)
DEF_ICON(BLANK169)
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index ebaeb9ccb6a..10f4e011026 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -965,6 +965,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
UI_icon_draw(x, y, ICON_MOD_TRIANGULATE); break;
case eModifierType_MeshCache:
UI_icon_draw(x, y, ICON_MOD_MESHDEFORM); break; /* XXX, needs own icon */
+ case eModifierType_Wireframe:
+ UI_icon_draw(x, y, ICON_MOD_WIREFRAME); break;
case eModifierType_LaplacianDeform:
UI_icon_draw(x, y, ICON_MOD_MESHDEFORM); break; /* XXX, needs own icon */
/* Default */
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index a3792e95804..f0573338585 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -81,6 +81,7 @@ typedef enum ModifierType {
eModifierType_UVWarp = 45,
eModifierType_MeshCache = 46,
eModifierType_LaplacianDeform = 47,
+ eModifierType_Wireframe = 48,
NUM_MODIFIER_TYPES
} ModifierType;
@@ -1321,5 +1322,26 @@ enum {
MOD_LAPLACIANDEFORM_BIND = 1,
};
+/* many of these options match 'solidify' */
+typedef struct WireframeModifierData {
+ ModifierData modifier;
+ char defgrp_name[64]; /* MAX_VGROUP_NAME */
+ float offset;
+ float offset_fac;
+ float offset_fac_vg;
+ float crease_weight;
+ short flag, mat_ofs;
+} WireframeModifierData;
+
+enum {
+ MOD_WIREFRAME_INVERT_VGROUP = (1 << 0),
+ MOD_WIREFRAME_REPLACE = (1 << 1),
+ MOD_WIREFRAME_BOUNDARY = (1 << 2),
+ MOD_MESHCACHE_OFS_EVEN = (1 << 3),
+ MOD_MESHCACHE_OFS_RELATIVE = (1 << 4),
+ MOD_MESHCACHE_CREASE = (1 << 5),
+};
+
+
#endif /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index f7909d23525..14d51ade464 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -658,6 +658,7 @@ extern StructRNA RNA_VertexWeightProximityModifier;
extern StructRNA RNA_Window;
extern StructRNA RNA_WindowManager;
extern StructRNA RNA_WipeSequence;
+extern StructRNA RNA_WireframeModifier;
extern StructRNA RNA_WoodTexture;
extern StructRNA RNA_World;
extern StructRNA RNA_WorldAmbientOcclusion;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 7427d8d54cf..04055bf0a53 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -80,6 +80,7 @@ EnumPropertyItem modifier_type_items[] = {
{eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""},
{eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
{eModifierType_Triangulate, "TRIANGULATE", ICON_MOD_TRIANGULATE, "Triangulate", ""},
+ {eModifierType_Wireframe, "WIREFRAME", ICON_MOD_WIREFRAME, "Wireframe", "Generates a wireframe on the edges of a mesh"},
{0, "", 0, N_("Deform"), ""},
{eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""},
{eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""},
@@ -241,6 +242,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_MeshCacheModifier;
case eModifierType_LaplacianDeform:
return &RNA_LaplacianDeformModifier;
+ case eModifierType_Wireframe:
+ return &RNA_WireframeModifier;
/* Default */
case eModifierType_None:
case eModifierType_ShapeKey:
@@ -486,6 +489,12 @@ static void RNA_WarpModifier_vgroup_set(PointerRNA *ptr, const char *value)
rna_object_vgroup_name_set(ptr, value, tmd->defgrp_name, sizeof(tmd->defgrp_name));
}
+static void RNA_WireframeModifier_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ WireframeModifierData *wmd = (WireframeModifierData *)ptr->data;
+ rna_object_vgroup_name_set(ptr, value, wmd->defgrp_name, sizeof(wmd->defgrp_name));
+}
+
static void rna_WeightVGModifier_mask_uvlayer_set(PointerRNA *ptr, const char *value)
{
ModifierData *md = (ModifierData *)ptr->data;
@@ -3700,6 +3709,90 @@ static void rna_def_modifier_laplaciandeform(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
+static void rna_def_modifier_wireframe(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "WireframeModifier", "Modifier");
+ RNA_def_struct_ui_text(srna, "Wireframe Modifier", "Wireframe effect modifier");
+ RNA_def_struct_sdna(srna, "WireframeModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_MOD_WIREFRAME);
+
+
+ prop = RNA_def_property(srna, "thickness", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "offset");
+ RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 4);
+ RNA_def_property_ui_text(prop, "Thickness", "Thickness factor");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "thickness_vertex_group", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "offset_fac_vg");
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
+ RNA_def_property_ui_text(prop, "Vertex Group Factor",
+ "Thickness factor to use for zero vertex group influence");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "offset_fac");
+ RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+ RNA_def_property_ui_range(prop, -1, 1, 0.1, 4);
+ RNA_def_property_ui_text(prop, "Offset", "Offset the thickness from the center");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_replace", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_REPLACE);
+ RNA_def_property_ui_text(prop, "Replace", "Remove original geometry");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_boundary", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_BOUNDARY);
+ RNA_def_property_ui_text(prop, "Boundary", "Support face boundaries");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_even_offset", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MESHCACHE_OFS_EVEN);
+ RNA_def_property_ui_text(prop, "Offset Even", "Scale the offset to give more even thickness");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_relative_offset", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MESHCACHE_OFS_RELATIVE);
+ RNA_def_property_ui_text(prop, "Offset Relative", "Scale the offset by surrounding geometry");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_crease", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MESHCACHE_CREASE);
+ RNA_def_property_ui_text(prop, "Offset Relative", "Crease hub edges for improved subsurf");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "crease_weight", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "crease_weight");
+ RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 1);
+ RNA_def_property_ui_text(prop, "Weigth", "Crease weight (if active)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "material_offset", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "mat_ofs");
+ RNA_def_property_range(prop, SHRT_MIN, SHRT_MAX);
+ RNA_def_property_ui_text(prop, "Material Offset", "Offset material index of generated faces");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+
+ prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
+ RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for selecting the affected areas");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "RNA_WireframeModifier_vgroup_set");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
void RNA_def_modifier(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3811,6 +3904,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_triangulate(brna);
rna_def_modifier_meshcache(brna);
rna_def_modifier_laplaciandeform(brna);
+ rna_def_modifier_wireframe(brna);
}
#endif
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 4eb15c0fbdb..6a8eac6ee48 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -98,6 +98,7 @@ set(SRC
intern/MOD_weightvgedit.c
intern/MOD_weightvgmix.c
intern/MOD_weightvgproximity.c
+ intern/MOD_wireframe.c
MOD_modifiertypes.h
intern/MOD_boolean_util.h
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index 7dedb8e0a13..9c7c21cc839 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -80,6 +80,7 @@ extern ModifierTypeInfo modifierType_Triangulate;
extern ModifierTypeInfo modifierType_UVWarp;
extern ModifierTypeInfo modifierType_MeshCache;
extern ModifierTypeInfo modifierType_LaplacianDeform;
+extern ModifierTypeInfo modifierType_Wireframe;
/* 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 9d8bfc6d285..a46314cd749 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -272,5 +272,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(UVWarp);
INIT_TYPE(MeshCache);
INIT_TYPE(LaplacianDeform);
+ INIT_TYPE(Wireframe);
#undef INIT_TYPE
}
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
new file mode 100644
index 00000000000..371c8d62590
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -0,0 +1,140 @@
+/*
+* ***** 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_wireframe.c
+* \ingroup modifiers
+*/
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_deform.h"
+
+#include "MOD_modifiertypes.h"
+#include "MOD_util.h"
+
+#include "bmesh.h"
+#include "tools/bmesh_wireframe.h"
+
+static void initData(ModifierData *md)
+{
+ WireframeModifierData *wmd = (WireframeModifierData *)md;
+ wmd->offset = 0.02f;
+ wmd->flag = MOD_WIREFRAME_REPLACE | MOD_MESHCACHE_OFS_EVEN;
+ wmd->crease_weight = 1.0f;
+}
+
+static void copyData(ModifierData *md, ModifierData *target)
+{
+#if 0
+ WireframeModifierData *wmd = (WireframeModifierData *)md;
+ WireframeModifierData *twmd = (WireframeModifierData *)target;
+#endif
+ modifier_copyData_generic(md, target);
+}
+
+static bool isDisabled(ModifierData *UNUSED(md), int UNUSED(useRenderParams))
+{
+ return 0;
+}
+
+static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+{
+ WireframeModifierData *wmd = (WireframeModifierData *)md;
+ CustomDataMask dataMask = 0;
+
+ /* ask for vertexgroups if we need them */
+ if (wmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
+
+ return dataMask;
+
+}
+
+static DerivedMesh* WireframeModifier_do( WireframeModifierData *wmd, Object *ob, DerivedMesh *dm)
+{
+ DerivedMesh *result;
+ BMesh *bm;
+
+ const int defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);;
+
+ bm = DM_to_bmesh(dm, true);
+
+ BM_mesh_wireframe(
+ bm,
+ wmd->offset, wmd->offset_fac, wmd->offset_fac_vg,
+ (wmd->flag & MOD_WIREFRAME_REPLACE) != 0,
+ (wmd->flag & MOD_WIREFRAME_BOUNDARY) != 0,
+ (wmd->flag & MOD_MESHCACHE_OFS_EVEN) != 0,
+ (wmd->flag & MOD_MESHCACHE_OFS_RELATIVE) != 0,
+ (wmd->flag & MOD_MESHCACHE_CREASE) != 0,
+ wmd->crease_weight,
+ defgrp_index,
+ (wmd->flag & MOD_WIREFRAME_INVERT_VGROUP) != 0,
+ wmd->mat_ofs,
+ MAX2(ob->totcol - 1, 0),
+ false);
+
+ result = CDDM_from_bmesh(bm, true);
+ BM_mesh_free(bm);
+
+ return result;
+
+}
+
+static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
+{
+ return WireframeModifier_do((WireframeModifierData *)md, ob, dm);
+}
+
+
+ModifierTypeInfo modifierType_Wireframe = {
+ /* name */ "Wireframe",
+ /* structName */ "WireframeModifierData",
+ /* structSize */ sizeof(WireframeModifierData),
+ /* type */ eModifierTypeType_Constructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh |
+ eModifierTypeFlag_SupportsEditmode,
+
+ /* copyData */ copyData,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+ /* applyModifierEM */ NULL,
+ /* initData */ initData,
+ /* requiredDataMask */ requiredDataMask,
+ /* freeData */ NULL,
+ /* isDisabled */ isDisabled,
+ /* updateDepgraph */ NULL,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
+ /* foreachObjectLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
+};