forked from bartvdbraak/blender
Modifier: New Wireframe Modifier
Based on patch originally by Thomas Beck, uses options similar to solidify.
This commit is contained in:
parent
01acc2a7dc
commit
d5263c37fa
@ -1189,5 +1189,36 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
||||
col.label(text="UV Map:")
|
||||
col.prop_search(md, "uv_layer", ob.data, "uv_textures", text="")
|
||||
|
||||
def WIREFRAME(self, layout, ob, md):
|
||||
has_vgroup = bool(md.vertex_group)
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.prop(md, "thickness", text="Thickness")
|
||||
|
||||
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, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
|
||||
row = col.row(align=True)
|
||||
row.active = has_vgroup
|
||||
row.prop(md, "thickness_vertex_group", text="Factor")
|
||||
|
||||
col.prop(md, "use_crease", text="Crease Edges")
|
||||
col.prop(md, "crease_weight", text="Crease Weight")
|
||||
|
||||
col = split.column()
|
||||
|
||||
col.prop(md, "offset")
|
||||
col.prop(md, "use_even_offset", text="Even Thickness")
|
||||
col.prop(md, "use_relative_offset", text="Relative Thickness")
|
||||
col.prop(md, "use_boundary", text="Boundary")
|
||||
col.prop(md, "use_replace", text="Replace Original")
|
||||
|
||||
col.prop(md, "material_offset", text="Material Offset")
|
||||
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
bpy.utils.register_module(__name__)
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -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__ */
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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[]);
|
||||
|
@ -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
|
||||
}
|
||||
|
140
source/blender/modifiers/intern/MOD_wireframe.c
Normal file
140
source/blender/modifiers/intern/MOD_wireframe.c
Normal file
@ -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,
|
||||
};
|
Loading…
Reference in New Issue
Block a user