diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-01-23 18:45:28 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-02-10 22:14:20 +0300 |
commit | 46a4cf36972fc6f125f2ae0295ea2e2fa7ec6d9f (patch) | |
tree | e24a39fc26c9f31b6a42a0de26ea3d9ef95035d5 /source | |
parent | ebc898756a93ef1c4a768d9feb4b0f8cf9b8a4f6 (diff) |
new deform modifier
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 21 | ||||
-rw-r--r-- | source/blender/modifiers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/modifiers/MOD_modifiertypes.h | 1 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_functiondeform.c | 104 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_util.c | 1 |
6 files changed, 135 insertions, 0 deletions
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index e11ee17ade5..ab7f24ddbf0 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_MeshSequenceCache = 52, eModifierType_SurfaceDeform = 53, eModifierType_WeightedNormal = 54, + eModifierType_FunctionDeform = 55, NUM_MODIFIER_TYPES } ModifierType; @@ -1942,4 +1943,10 @@ enum { #define MOD_MESHSEQ_READ_ALL \ (MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR) +typedef struct FunctionDeformModifierData { + ModifierData modifier; + float control1; + int control2; +} FunctionDeformModifierData; + #endif /* __DNA_MODIFIER_TYPES_H__ */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index d9b7b0309d0..f2fae8a7909 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -102,6 +102,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { {eModifierType_SurfaceDeform, "SURFACE_DEFORM", ICON_MOD_MESHDEFORM, "Surface Deform", ""}, {eModifierType_Warp, "WARP", ICON_MOD_WARP, "Warp", ""}, {eModifierType_Wave, "WAVE", ICON_MOD_WAVE, "Wave", ""}, + {eModifierType_FunctionDeform, "FUNCTION_DEFORM", ICON_NONE, "Function Deform", ""}, {0, "", 0, N_("Simulate"), ""}, {eModifierType_Cloth, "CLOTH", ICON_MOD_CLOTH, "Cloth", ""}, {eModifierType_Collision, "COLLISION", ICON_MOD_PHYSICS, "Collision", ""}, @@ -428,6 +429,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_SurfaceDeformModifier; case eModifierType_WeightedNormal: return &RNA_WeightedNormalModifier; + case eModifierType_FunctionDeform: + return &RNA_FunctionDeformModifier; /* Default */ case eModifierType_None: case eModifierType_ShapeKey: @@ -5059,6 +5062,23 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } +static void rna_def_modifier_function_deform(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "FunctionDeformModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Function Deform Modifier", ""); + RNA_def_struct_sdna(srna, "FunctionDeformModifierData"); + RNA_def_struct_ui_icon(srna, ICON_NONE); + + prop = RNA_def_float(srna, "control1", 0.0, -FLT_MAX, FLT_MAX, "Control 1", "", -10, 10); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_int(srna, "control2", 0, INT_MIN, INT_MAX, "Control 2", "", -10, 10); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +} + void RNA_def_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -5181,6 +5201,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_meshseqcache(brna); rna_def_modifier_surfacedeform(brna); rna_def_modifier_weightednormal(brna); + rna_def_modifier_function_deform(brna); } #endif diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 30dab865196..3628d576d18 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -57,6 +57,7 @@ set(SRC intern/MOD_explode.c intern/MOD_fluidsim.c intern/MOD_fluidsim_util.c + intern/MOD_functiondeform.c intern/MOD_hook.c intern/MOD_laplaciandeform.c intern/MOD_laplaciansmooth.c diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h index acc3ce647d7..5e491477388 100644 --- a/source/blender/modifiers/MOD_modifiertypes.h +++ b/source/blender/modifiers/MOD_modifiertypes.h @@ -80,6 +80,7 @@ extern ModifierTypeInfo modifierType_CorrectiveSmooth; extern ModifierTypeInfo modifierType_MeshSequenceCache; extern ModifierTypeInfo modifierType_SurfaceDeform; extern ModifierTypeInfo modifierType_WeightedNormal; +extern ModifierTypeInfo modifierType_FunctionDeform; /* MOD_util.c */ void modifier_type_init(ModifierTypeInfo *types[]); diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c b/source/blender/modifiers/intern/MOD_functiondeform.c new file mode 100644 index 00000000000..b782658db36 --- /dev/null +++ b/source/blender/modifiers/intern/MOD_functiondeform.c @@ -0,0 +1,104 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) 2005 by the Blender Foundation. + * All rights reserved. + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/modifiers/intern/MOD_functiondeform.c + * \ingroup modifiers + * + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_mesh_types.h" +#include "DNA_modifier_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" + +#include "BKE_mesh.h" +#include "BKE_modifier.h" +#include "BKE_scene.h" + +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "MOD_util.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" +#include "time.h" + + + +static void deformVerts( + ModifierData *md, + const ModifierEvalContext *ctx, + Mesh *UNUSED(mesh), + float (*vertexCos)[3], + int numVerts) +{ +} + + +static void initData(ModifierData *md) +{ + FunctionDeformModifierData *fdmd = (FunctionDeformModifierData *)md; + fdmd->control1 = 0.0f; + fdmd->control2 = 0; +} + +static bool dependsOnTime(ModifierData *UNUSED(md)) +{ + return true; +} + + +ModifierTypeInfo modifierType_FunctionDeform = { + /* name */ "Function Deform", + /* structName */ "FunctionDeformModifierData", + /* structSize */ sizeof(FunctionDeformModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsMesh, + /* copyData */ modifier_copyData_generic, + + /* deformVerts_DM */ NULL, + /* deformMatrices_DM */ NULL, + /* deformVertsEM_DM */ NULL, + /* deformMatricesEM_DM*/NULL, + /* applyModifier_DM */ NULL, + + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + + /* initData */ initData, + /* requiredDataMask */ NULL, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepsgraph */ NULL, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, + /* foreachObjectLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, +};
\ No newline at end of file diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index a6e6276b6e1..530cf35d97b 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -297,5 +297,6 @@ void modifier_type_init(ModifierTypeInfo *types[]) INIT_TYPE(MeshSequenceCache); INIT_TYPE(SurfaceDeform); INIT_TYPE(WeightedNormal); + INIT_TYPE(FunctionDeform); #undef INIT_TYPE } |