[Bf-blender-cvs] [a8cb18c6441] functions: new Function Points modifier for testing

Jacques Lucke noreply at git.blender.org
Sun Mar 10 18:32:40 CET 2019


Commit: a8cb18c6441ae454b64657c041213b6c4c52fccc
Author: Jacques Lucke
Date:   Sun Mar 10 17:26:08 2019 +0100
Branches: functions
https://developer.blender.org/rBa8cb18c6441ae454b64657c041213b6c4c52fccc

new Function Points modifier for testing

===================================================================

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/editors/space_outliner/outliner_draw.c
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_functionpoints.c
M	source/blender/modifiers/intern/MOD_util.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 8ce897b397c..5dda74cfcc4 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1636,7 +1636,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "thresh", text="Threshold")
         col.prop(md, "face_influence")
 
-    def FUNCTION_DEFORM(self,layout, ob, md):
+    def FUNCTION_DEFORM(self, layout, ob, md):
+        layout.prop(md, "control1")
+        layout.prop(md, "control2")
+        layout.prop(md, "function_tree")
+
+    def FUNCTION_POINTS(self, layout, ob, md):
         layout.prop(md, "control1")
         layout.prop(md, "control2")
         layout.prop(md, "function_tree")
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index d312bd9cce8..4c6d5b7bbc9 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1147,6 +1147,7 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
 						case eModifierType_None:
 						case eModifierType_ShapeKey:
 						case eModifierType_FunctionDeform:
+						case eModifierType_FunctionPoints:
 
 						case NUM_MODIFIER_TYPES:
 							data.icon = ICON_DOT;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 681ae464930..c42f6df2c8f 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -89,6 +89,7 @@ typedef enum ModifierType {
 	eModifierType_SurfaceDeform     = 53,
 	eModifierType_WeightedNormal	= 54,
 	eModifierType_FunctionDeform    = 55,
+	eModifierType_FunctionPoints    = 56,
 	NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -1952,4 +1953,11 @@ typedef struct FunctionDeformModifierData {
 	struct bNodeTree *function_tree;
 } FunctionDeformModifierData;
 
+typedef struct FunctionPointsModifierData {
+	ModifierData modifier;
+	float control1;
+	int control2;
+	struct bNodeTree *function_tree;
+} FunctionPointsModifierData;
+
 #endif  /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index da69d29529b..3b55f7ab0c0 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -86,6 +86,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_FunctionPoints, "FUNCTION_POINTS", ICON_NONE, "Function Points", ""},
 	{0, "", 0, N_("Deform"), ""},
 	{eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""},
 	{eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""},
@@ -432,6 +433,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
 			return &RNA_WeightedNormalModifier;
 		case eModifierType_FunctionDeform:
 			return &RNA_FunctionDeformModifier;
+		case eModifierType_FunctionPoints:
+			return &RNA_FunctionPointsModifier;
 		/* Default */
 		case eModifierType_None:
 		case eModifierType_ShapeKey:
@@ -5087,6 +5090,28 @@ static void rna_def_modifier_function_deform(BlenderRNA *brna)
 	RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 }
 
+static void rna_def_modifier_function_points(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna = RNA_def_struct(brna, "FunctionPointsModifier", "Modifier");
+	RNA_def_struct_ui_text(srna, "Function Points Modifier", "");
+	RNA_def_struct_sdna(srna, "FunctionPointsModifierData");
+	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");
+
+	prop = RNA_def_property(srna, "function_tree", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Function Tree", "Function node tree");
+	RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
+}
+
 void RNA_def_modifier(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -5210,6 +5235,7 @@ void RNA_def_modifier(BlenderRNA *brna)
 	rna_def_modifier_surfacedeform(brna);
 	rna_def_modifier_weightednormal(brna);
 	rna_def_modifier_function_deform(brna);
+	rna_def_modifier_function_points(brna);
 }
 
 #endif
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index bb02f8cc035..e9b596c3890 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -59,6 +59,7 @@ set(SRC
 	intern/MOD_fluidsim.c
 	intern/MOD_fluidsim_util.c
 	intern/MOD_functiondeform.c
+	intern/MOD_functionpoints.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 33aa075df18..dc961a852af 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -82,6 +82,7 @@ extern ModifierTypeInfo modifierType_MeshSequenceCache;
 extern ModifierTypeInfo modifierType_SurfaceDeform;
 extern ModifierTypeInfo modifierType_WeightedNormal;
 extern ModifierTypeInfo modifierType_FunctionDeform;
+extern ModifierTypeInfo modifierType_FunctionPoints;
 
 /* MOD_util.c */
 void modifier_type_init(ModifierTypeInfo *types[]);
diff --git a/source/blender/modifiers/intern/MOD_functionpoints.c b/source/blender/modifiers/intern/MOD_functionpoints.c
new file mode 100644
index 00000000000..b049c06ad53
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_functionpoints.c
@@ -0,0 +1,152 @@
+/*
+ * ***** 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 "BKE_library_query.h"
+
+#include "BKE_global.h"
+#include "BKE_main.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"
+
+#include "FN-C.h"
+
+static FnFunction get_current_function(FunctionPointsModifierData *fpmd)
+{
+	bNodeTree *tree = (bNodeTree *)DEG_get_original_id((ID *)fpmd->function_tree);
+
+	FnType float_ty = FN_type_borrow_float();
+	FnType int32_ty = FN_type_borrow_int32();
+	FnType fvec3_ty = FN_type_borrow_fvec3();
+
+    FnType float_list_ty = FN_type_borrow_float_list();
+
+	FnType inputs[] = { int32_ty, NULL };
+	FnType outputs[] = { float_list_ty, NULL };
+
+	return FN_function_get_with_signature(tree, inputs, outputs);
+}
+
+static Mesh *build_point_mesh(FunctionPointsModifierData *fpmd)
+{
+	Mesh *mesh = BKE_mesh_new_nomain(2, 0, 0, 0, 0);
+	float vec1[] = {4, 6, 3};
+	float vec2[] = {1, 2, 3};
+	copy_v3_v3(mesh->mvert + 0, vec1);
+	copy_v3_v3(mesh->mvert + 1, vec2);
+	return mesh;
+}
+
+static Mesh *applyModifier(
+        ModifierData *md,
+        const struct ModifierEvalContext *ctx,
+        struct Mesh *mesh)
+{
+	return build_point_mesh((FunctionPointsModifierData *)md);
+}
+
+static void initData(ModifierData *md)
+{
+	FunctionPointsModifierData *fpmd = (FunctionPointsModifierData *)md;
+	fpmd->control1 = 1.0f;
+	fpmd->control2 = 0;
+}
+
+static bool dependsOnTime(ModifierData *UNUSED(md))
+{
+	return true;
+}
+
+static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
+{
+	FunctionPointsModifierData *fpmd = (FunctionPointsModifierData *)md;
+
+	FnFunction fn = get_current_function(fpmd);
+	if (fn) {
+		FN_function_update_dependencies(fn, ctx->node);
+		FN_function_free(fn);
+	}
+}
+
+static void foreachIDLink(
+        ModifierData *md, Object *ob,
+        IDWalkFunc walk, void *userData)
+{
+	FunctionPointsModifierData *fpmd = (FunctionPointsModifierData *)md;
+
+	walk(userData, ob, (ID **)&fpmd->function_tree, IDWALK_CB_USER);
+}
+
+
+ModifierTypeInfo modifierType_FunctionPoints = {
+	/* name */              "Function Points",
+	/* structName */        "FunctionPointsModifierData",
+	/* structSize */        sizeof(FunctionPointsModifierData),
+	/* type */              eModifierTypeType_Constructive,
+	/* flags */             eModifierTypeFlag_AcceptsMesh,
+	/* copyData */          modifier_copyData_generic,
+
+	/* PointsVerts_DM */    NULL,
+	/* deformMatrices_DM */ NULL,
+	/* deformVertsEM_DM */  NULL,
+	/* deformMatricesEM_DM*/NULL,
+	/* applyModifier_DM */  NULL,
+
+	/* deformVerts */       NULL,
+	/* deformMatrices */    NULL,
+	/* deformVertsEM */     NULL,
+	/* deformMatricesEM */  NULL,
+	/* applyModifier */     applyModifier,
+
+	/* i

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list