Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pinzon Fernandez <apinzonf@gmail.com>2013-11-21 05:25:53 +0400
committerAlexander Pinzon Fernandez <apinzonf@gmail.com>2013-11-21 05:25:53 +0400
commit70174fd1c2a906b845aae18b5c18082f31843b69 (patch)
treec4eb7a4037d1f1099e3fe68c3bd6edffc2a1a67f /source/blender
parent9c826cf9f527083f72b6e7018378bbaa565218f2 (diff)
Create of new Operator for bind Laplacian Deform Modifier
The Laplacian Deform Modifier bind the initial vertexes positions. I Modified the LaplacianDeformModifierData struct to store bind state.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_modifier.c50
-rw-r--r--source/blender/editors/object/object_ops.c1
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h6
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c10
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c10
6 files changed, 78 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index bfed1f2f982..ce509e2ffe7 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -173,6 +173,7 @@ void OBJECT_OT_skin_root_mark(struct wmOperatorType *ot);
void OBJECT_OT_skin_loose_mark_clear(struct wmOperatorType *ot);
void OBJECT_OT_skin_radii_equalize(struct wmOperatorType *ot);
void OBJECT_OT_skin_armature_create(struct wmOperatorType *ot);
+void OBJECT_OT_laplaciandeform_bind(struct wmOperatorType *ot);
/* object_constraint.c */
void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 01dafe69d31..22f7a445d70 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2209,3 +2209,53 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "free", FALSE, "Free", "Free the bake, rather than generating it");
}
+/************************ LaplacianDeform bind operator *********************/
+
+static int laplaciandeform_poll(bContext *C)
+{
+ return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0);
+}
+
+static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = ED_object_active_context(C);
+ LaplacianDeformModifierData *mmd = (LaplacianDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_LaplacianDeform);
+
+ if (!mmd)
+ return OPERATOR_CANCELLED;
+ if (mmd->bind) {
+ mmd->bind = 0;
+ }
+ else {
+ mmd->bind = 1;
+ }
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
+ return OPERATOR_FINISHED;
+}
+
+static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ if (edit_modifier_invoke_properties(C, op))
+ return laplaciandeform_bind_exec(C, op);
+ else
+ return OPERATOR_CANCELLED;
+}
+
+void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Laplacian Deform Bind";
+ ot->description = "Bind mesh to system in laplacian deform modifier";
+ ot->idname = "OBJECT_OT_laplaciandeform_bind";
+
+ /* api callbacks */
+ ot->poll = laplaciandeform_poll;
+ ot->invoke = laplaciandeform_bind_invoke;
+ ot->exec = laplaciandeform_bind_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
+ edit_modifier_properties(ot);
+} \ No newline at end of file
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 6d760acb698..74ac487b687 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -241,6 +241,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_bake_image);
WM_operatortype_append(OBJECT_OT_drop_named_material);
+ WM_operatortype_append(OBJECT_OT_laplaciandeform_bind);
}
void ED_operatormacros_object(void)
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 24817fa8f43..76f80da7902 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1300,8 +1300,14 @@ typedef struct LaplacianDeformModifierData {
int total_verts, repeat;
float *vertexco;
void *cacheSystem;
+ short bind, pad[3];
} LaplacianDeformModifierData;
+/* Smooth modifier flags */
+enum {
+ MOD_LAPLACIANDEFORM_BIND = 1,
+};
+
#endif /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 08c8c79cb54..ec868600853 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -795,6 +795,11 @@ static void rna_LaplacianDeformModifier_vgroup_set(PointerRNA *ptr, const char *
rna_object_vgroup_name_set(ptr, value, lmd->anchor_grp_name, sizeof(lmd->anchor_grp_name));
}
+static int rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
+{
+ return (((LaplacianDeformModifierData *)ptr->data)->bind == 1);
+}
+
#else
static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[])
@@ -3712,6 +3717,11 @@ static void rna_def_modifier_laplaciandeform(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Repeat", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "is_bind", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LaplacianDeformModifier_is_bind_get", NULL);
+ RNA_def_property_ui_text(prop, "Bind", "Whether geometry has been bind to anchors");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index c5e552fce13..b08f1b4a6f0 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -694,6 +694,16 @@ static void LaplacianDeformModifier_do(
int sysdif;
LaplacianSystem *sys = NULL;
filevertexCos = NULL;
+ if (!smd->bind) {
+ if (smd->cacheSystem) {
+ sys = smd->cacheSystem;
+ deleteLaplacianSystem(sys);
+ smd->cacheSystem = NULL;
+ smd->total_verts = 0;
+ MEM_SAFE_FREE(smd->vertexco);
+ }
+ return;
+ }
if (smd->cacheSystem) {
sysdif = isSystemDifferent(smd, ob, dm, numVerts);
sys = smd->cacheSystem;