[Bf-blender-cvs] [9215e2a0971] greasepencil-object: WIP: Hook modifier initial basic stage

Antonio Vazquez noreply at git.blender.org
Sat Nov 25 13:55:33 CET 2017


Commit: 9215e2a09717db3acfb4da8f3595c76d7afc3b16
Author: Antonio Vazquez
Date:   Sat Nov 25 13:36:57 2017 +0100
Branches: greasepencil-object
https://developer.blender.org/rB9215e2a09717db3acfb4da8f3595c76d7afc3b16

WIP: Hook modifier initial basic stage

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/RNA_access.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_gpencilhook.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 d109e6819e1..96d6f946a4d 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1883,6 +1883,53 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.separator()
         col.prop(md, "transparent")
 
+    def GP_HOOK(self, layout, ob, md):
+        gpd = ob.data
+        split = layout.split()
+
+        col = split.column()
+        col.label(text="Object:")
+        col.prop(md, "object", text="")
+        if md.object and md.object.type == 'ARMATURE':
+            col.label(text="Bone:")
+            col.prop_search(md, "subtarget", md.object.data, "bones", text="")
+
+        col = split.column()
+        col.label("Layer:")
+        row = col.row(align=True)
+        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
+        row.prop(md, "inverse_layers", text="", icon="ARROW_LEFTRIGHT")
+
+        col.label("Vertex Group:")
+        row = col.row(align=True)
+        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        row.prop(md, "inverse_vertex", text="", icon="ARROW_LEFTRIGHT")
+
+        row = col.row(align=True)
+        row.prop(md, "pass_index", text="Pass")
+        row.prop(md, "inverse_pass", text="", icon="ARROW_LEFTRIGHT")
+
+        use_falloff = (md.falloff_type != 'NONE')
+        split = layout.split()
+
+        layout.separator()
+
+        row = layout.row(align=True)
+        if use_falloff:
+            row.prop(md, "falloff_radius")
+        row.prop(md, "strength", slider=True)
+        layout.prop(md, "falloff_type")
+
+        col = layout.column()
+        if use_falloff:
+            if md.falloff_type == 'CURVE':
+                col.template_curve_mapping(md, "falloff_curve")
+
+        split = layout.split()
+
+        col = split.column()
+        col.prop(md, "use_falloff_uniform")
+
 
 classes = (
     DATA_PT_modifiers,
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 40472ea911c..9c726b25311 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -70,6 +70,7 @@ void BKE_object_free_derived_caches(struct Object *ob);
 void BKE_object_free_caches(struct Object *object);
 
 void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd);
+void BKE_object_modifier_gpencil_hook_reset(struct Object *ob, struct GpencilHookModifierData *hmd);
 
 bool BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type);
 
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f210611bf74..d5564b85388 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -239,6 +239,28 @@ void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd)
 	}
 }
 
+void BKE_object_modifier_gpencil_hook_reset(Object *ob, GpencilHookModifierData *hmd)
+{
+	/* reset functionality */
+	if (hmd->object) {
+		bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget);
+
+		if (hmd->subtarget[0] && pchan) {
+			float imat[4][4], mat[4][4];
+
+			/* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
+			mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
+
+			invert_m4_m4(imat, mat);
+			mul_m4_m4m4(hmd->parentinv, imat, ob->obmat);
+		}
+		else {
+			invert_m4_m4(hmd->object->imat, hmd->object->obmat);
+			mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat);
+		}
+	}
+}
+
 bool BKE_object_support_modifier_type_check(Object *ob, int modifier_type)
 {
 	const ModifierTypeInfo *mti;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index d5c83d8e784..c161fb5ebab 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5480,6 +5480,14 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
 			GpencilLatticeModifierData *gpmd = (GpencilLatticeModifierData*)md;
 			gpmd->cache_data = NULL;
 		}
+		else if (md->type == eModifierType_GpencilHook) {
+			GpencilHookModifierData *hmd = (GpencilHookModifierData *)md;
+
+			hmd->curfalloff = newdataadr(fd, hmd->curfalloff);
+			if (hmd->curfalloff) {
+				direct_link_curvemapping(fd, hmd->curfalloff);
+			}
+		}
 		else if (md->type == eModifierType_GpencilThick) {
 			GpencilThickModifierData *gpmd = (GpencilThickModifierData *)md;
 
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 8a0641d7163..7aca6f9ffe0 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1056,6 +1056,9 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
 					case eModifierType_GpencilSmooth:
 						ICON_DRAW(ICON_MOD_SMOOTH);
 						break;
+					case eModifierType_GpencilHook:
+						ICON_DRAW(ICON_HOOK);
+						break;
 
 					/* GPencil VFX Modifiers */
 					case eModifierType_GpencilBlur:
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 21c7cdd37fc..73b79001929 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -102,6 +102,7 @@ typedef enum ModifierType {
 	eModifierType_GpencilPixel      = 66,
 	eModifierType_GpencilSwirl      = 67,
 	eModifierType_GpencilSmooth     = 68,
+	eModifierType_GpencilHook       = 69,
 	NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -1841,6 +1842,44 @@ typedef enum eGpencilLattice_Flag {
 	GP_LATTICE_INVERSE_VGROUP = (1 << 2),
 } eGpencilLattice_Flag;
 
+typedef struct GpencilHookModifierData {
+	ModifierData modifier;
+
+	struct Object *object;
+	char subtarget[64];     /* optional name of bone target, MAX_ID_NAME-2 */
+	char layername[64];     /* layer name */
+	char vgname[64];        /* optional vertexgroup name, MAX_VGROUP_NAME */
+	int pass_index;         /* custom index for passes */
+
+	int flag;
+	char falloff_type;      /* use enums from WarpModifier (exact same functionality) */
+	char pad[3];
+	float parentinv[4][4];  /* matrix making current transform unmodified */
+	float cent[3];          /* visualization of hook */
+	float falloff;          /* if not zero, falloff is distance where influence zero */
+	float force;
+	struct CurveMapping *curfalloff;
+} GpencilHookModifierData;
+
+typedef enum eGpencilHook_Flag {
+	GP_HOOK_INVERSE_LAYER = (1 << 0),
+	GP_HOOK_INVERSE_PASS = (1 << 1),
+	GP_HOOK_INVERSE_VGROUP = (1 << 2),
+	GP_HOOK_UNIFORM_SPACE = (1 << 3),
+} eGpencilHook_Flag;
+
+typedef enum eGpencilHook_Falloff {
+	eGPHook_Falloff_None = 0,
+	eGPHook_Falloff_Curve = 1,
+	eGPHook_Falloff_Sharp = 2,
+	eGPHook_Falloff_Smooth = 3,
+	eGPHook_Falloff_Root = 4,
+	eGPHook_Falloff_Linear = 5,
+	eGPHook_Falloff_Const = 6,
+	eGPHook_Falloff_Sphere = 7,
+	eGPHook_Falloff_InvSquare = 8,
+} eGpencilHook_Falloff;
+
 typedef struct GpencilSimplifyModifierData {
 	ModifierData modifier;
 	char layername[64];          /* layer name */
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 56f56d8cfaf..c4d239711ab 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -626,6 +626,7 @@ extern StructRNA RNA_GpencilWaveModifier;
 extern StructRNA RNA_GpencilPixelModifier;
 extern StructRNA RNA_GpencilSwirlModifier;
 extern StructRNA RNA_GpencilSmoothModifier;
+extern StructRNA RNA_GpencilHookModifier;
 extern StructRNA RNA_TexMapping;
 extern StructRNA RNA_Text;
 extern StructRNA RNA_TextBox;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 30bbc8cc95d..4eede4213d3 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -128,6 +128,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
 	{eModifierType_GpencilSubdiv, "GP_SUBDIV", ICON_MOD_SUBSURF, "Subdivide", "Subdivide stroke adding more control points" },
 	{eModifierType_GpencilSimplify, "GP_SIMPLIFY", ICON_MOD_DECIM, "Simplify", "Simplify stroke reducing number of points" },
 	{eModifierType_GpencilLattice, "GP_LATTICE", ICON_MOD_LATTICE, "Lattice", "Change stroke using lattice to deform" },
+	{eModifierType_GpencilHook, "GP_HOOK", ICON_HOOK, "Hook", "Change stroke using object as hook to deform" },
 	{eModifierType_GpencilThick, "GP_THICK", ICON_MAN_ROT, "Thickness", "Change stroke thickness" },
 	{eModifierType_GpencilTint, "GP_TINT", ICON_COLOR, "Tint", "Tint strokes with new color" },
 	{eModifierType_GpencilColor, "GP_COLOR", ICON_GROUP_VCOL, "Hue/Saturation", "Apply changes to color" },
@@ -468,6 +469,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
 			return &RNA_GpencilSwirlModifier;
 		case eModifierType_GpencilSmooth:
 			return &RNA_GpencilSmoothModifier;
+		case eModifierType_GpencilHook:
+			return &RNA_GpencilHookModifier;
 			/* Default */
 		case eModifierType_None:
 		case eModifierType_ShapeKey:
@@ -564,6 +567,7 @@ RNA_MOD_VGROUP_NAME_SET(GpencilThick, vgname);
 RNA_MOD_VGROUP_NAME_SET(GpencilOpacity, vgname);
 RNA_MOD_VGROUP_NAME_SET(GpencilLattice, vgname);
 RNA_MOD_VGROUP_NAME_SET(GpencilSmooth, vgname);
+RNA_MOD_VGROUP_NAME_SET(GpencilHook, vgname);
 
 static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value)
 {
@@ -651,6 +655,16 @@ static void rna_HookModifier_object_set(PointerRNA *ptr, PointerRNA value)
 	BKE_object_modifier_hook_reset(ob, hmd);
 }
 
+static void rna_GpencilHookModifier_object_set(PointerRNA *ptr, PointerRNA value)
+{
+	GpencilHookModifierData *hmd = ptr->data;
+	Object *ob = (Object *)value.data;
+
+	hmd->object = ob;
+	id_lib_extern((ID *)ob);
+	BKE_object_modifier_gpencil_hook_reset(ob, hmd);
+}
+
 static PointerRNA rna_UVProjector_object_get(PointerRNA *ptr)
 {
 	Object **ob = (Object **)ptr->data;
@@ -5582,6 +5596,101 @@ static void rna_def_modifier_gpencillatt

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list