[Bf-blender-cvs] [12ff7b5c36c] nodes_playground: add a new custom modifier
Jacques Lucke
noreply at git.blender.org
Sun Jan 6 17:25:09 CET 2019
Commit: 12ff7b5c36ca1c9723545222ef976a6a4f5d74b3
Author: Jacques Lucke
Date: Fri Nov 30 12:03:13 2018 +0100
Branches: nodes_playground
https://developer.blender.org/rB12ff7b5c36ca1c9723545222ef976a6a4f5d74b3
add a new custom modifier
===================================================================
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/CMakeLists.txt
M source/blender/modifiers/MOD_modifiertypes.h
A source/blender/modifiers/intern/MOD_custom.c
M source/blender/modifiers/intern/MOD_util.c
===================================================================
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 748c68c3fd4..f45472a7d2a 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -91,6 +91,7 @@ typedef enum ModifierType {
eModifierType_MeshSequenceCache = 52,
eModifierType_SurfaceDeform = 53,
eModifierType_WeightedNormal = 54,
+ eModifierType_Custom = 55,
NUM_MODIFIER_TYPES
} ModifierType;
@@ -1735,4 +1736,8 @@ enum {
#define MOD_MESHSEQ_READ_ALL \
(MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)
+typedef struct CustomModifierData {
+ ModifierData modifier;
+} CustomModifierData;
+
#endif /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 541e5c772f8..0bd9d9accb3 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -92,6 +92,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
{eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
{eModifierType_Triangulate, "TRIANGULATE", ICON_MOD_TRIANGULATE, "Triangulate", ""},
{eModifierType_Wireframe, "WIREFRAME", ICON_MOD_WIREFRAME, "Wireframe", "Generate a wireframe on the edges of a mesh"},
+ {eModifierType_Custom, "CUSTOM", ICON_NODETREE, "Custom", "Playground"},
{0, "", 0, N_("Deform"), ""},
{eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""},
{eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""},
@@ -5038,6 +5039,17 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
+static void rna_def_modifier_custom(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *UNUSED(prop);
+
+ srna = RNA_def_struct(brna, "CustomModifier", "Modifier");
+ RNA_def_struct_ui_text(srna, "Custom Modifier", "");
+ RNA_def_struct_sdna(srna, "CustomModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_NODETREE);
+}
+
void RNA_def_modifier(BlenderRNA *brna)
{
StructRNA *srna;
@@ -5160,6 +5172,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_custom(brna);
}
#endif
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index e914100249b..d9a89b30e67 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -54,6 +54,7 @@ set(SRC
intern/MOD_cloth.c
intern/MOD_collision.c
intern/MOD_correctivesmooth.c
+ intern/MOD_custom.c
intern/MOD_curve.c
intern/MOD_datatransfer.c
intern/MOD_decimate.c
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index 3511b0edbec..4c48c92fc5d 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -87,6 +87,7 @@ extern ModifierTypeInfo modifierType_CorrectiveSmooth;
extern ModifierTypeInfo modifierType_MeshSequenceCache;
extern ModifierTypeInfo modifierType_SurfaceDeform;
extern ModifierTypeInfo modifierType_WeightedNormal;
+extern ModifierTypeInfo modifierType_Custom;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);
diff --git a/source/blender/modifiers/intern/MOD_custom.c b/source/blender/modifiers/intern/MOD_custom.c
new file mode 100644
index 00000000000..2ab874f29ee
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_custom.c
@@ -0,0 +1,92 @@
+/*
+ * ***** 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_custom.c
+ * \ingroup modifiers
+ *
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "MOD_util.h"
+
+#include "DEG_depsgraph.h"
+
+static Mesh *applyModifier(
+ ModifierData *md, const ModifierEvalContext *ctx,
+ Mesh *mesh)
+{
+ Mesh *new_mesh = BKE_mesh_new_nomain(1, 0, 0, 0, 0);
+ new_mesh->mvert[0].co[0] = 1;
+ new_mesh->mvert[0].co[1] = 2;
+ new_mesh->mvert[0].co[2] = 3;
+ return new_mesh;
+}
+
+static void initData(ModifierData *md)
+{
+}
+
+
+ModifierTypeInfo modifierType_Custom = {
+ /* name */ "Custom",
+ /* structName */ "CustomModifierData",
+ /* structSize */ sizeof(CustomModifierData),
+ /* type */ eModifierTypeType_Constructive,
+ /* flags */ eModifierTypeFlag_AcceptsMesh,
+ /* copyData */ modifier_copyData_generic,
+
+ /* deformVerts_DM */ NULL,
+ /* deformMatrices_DM */ NULL,
+ /* deformVertsEM_DM */ NULL,
+ /* deformMatricesEM_DM*/NULL,
+ /* applyModifier_DM */ NULL,
+
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
+ /* applyModifier */ applyModifier,
+
+ /* initData */ initData,
+ /* requiredDataMask */ NULL,
+ /* freeData */ NULL,
+ /* isDisabled */ NULL,
+ /* updateDepsgraph */ NULL,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
+ /* foreachObjectLink */ NULL,
+ /* foreachIDLink */ NULL,
+ /* foreachTexLink */ NULL,
+};
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index dca2d536a5d..46cb094d3c4 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -310,5 +310,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(MeshSequenceCache);
INIT_TYPE(SurfaceDeform);
INIT_TYPE(WeightedNormal);
+ INIT_TYPE(Custom);
#undef INIT_TYPE
}
More information about the Bf-blender-cvs
mailing list