[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46839] branches/soc-2011-tomato/source/ blender: mask parenting operator, and clear parenting.
Campbell Barton
ideasman42 at gmail.com
Mon May 21 13:09:54 CEST 2012
Revision: 46839
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46839
Author: campbellbarton
Date: 2012-05-21 11:09:53 +0000 (Mon, 21 May 2012)
Log Message:
-----------
mask parenting operator, and clear parenting. (Ctrl+P, Alt+P)
- also use offset now with parenting.
- draw line from point to parent.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt
branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
Added Paths:
-----------
branches/soc-2011-tomato/source/blender/editors/mask/mask_relationships.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-21 10:20:30 UTC (rev 46838)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-21 11:09:53 UTC (rev 46839)
@@ -757,7 +757,7 @@
}
}
-static void evaluate_mask_parent(MaskParent *parent, float ctime, float co[2])
+static void evaluate_mask_parent(MaskParent *parent, float ctime, float r_co[2])
{
if (!parent)
return;
@@ -779,7 +779,8 @@
if (track) {
MovieTrackingMarker *marker = BKE_tracking_get_marker(track, ctime);
- BKE_mask_coord_from_movieclip(clip, &user, co, marker->pos);
+ BKE_mask_coord_from_movieclip(clip, &user, r_co, marker->pos);
+ add_v2_v2(r_co, parent->offset);
}
}
}
Modified: branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt 2012-05-21 10:20:30 UTC (rev 46838)
+++ branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt 2012-05-21 11:09:53 UTC (rev 46839)
@@ -40,6 +40,7 @@
mask_draw.c
mask_editor.c
mask_ops.c
+ mask_relationships.c
mask_intern.h
)
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c 2012-05-21 10:20:30 UTC (rev 46838)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c 2012-05-21 11:09:53 UTC (rev 46839)
@@ -62,6 +62,36 @@
}
}
+static void draw_spline_parents(MaskObject *UNUSED(maskobj), MaskSpline *spline)
+{
+ int i;
+
+ if (!spline->tot_point)
+ return;
+
+ glColor3ub(0, 0, 0);
+ glEnable(GL_LINE_STIPPLE);
+ glLineStipple(1, 0xAAAA);
+
+ glBegin(GL_LINES);
+
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+
+ if (point->parent.flag & MASK_PARENT_ACTIVE) {
+ glVertex2f(point->bezt.vec[1][0],
+ point->bezt.vec[1][1]);
+
+ glVertex2f(point->bezt.vec[1][0] - point->parent.offset[0],
+ point->bezt.vec[1][1] - point->parent.offset[1]);
+ }
+ }
+
+ glEnd();
+
+ glDisable(GL_LINE_STIPPLE);
+}
+
/* return non-zero if spline is selected */
static void draw_spline_points(MaskObject *maskobj, MaskSpline *spline)
{
@@ -227,6 +257,8 @@
/* draw curve itself first... */
draw_spline_curve(maskobj, spline);
+ draw_spline_parents(maskobj, spline);
+
/* ...and then handles over the curve so they're nicely visible */
draw_spline_points(maskobj, spline);
}
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c 2012-05-21 10:20:30 UTC (rev 46838)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c 2012-05-21 11:09:53 UTC (rev 46839)
@@ -163,6 +163,10 @@
WM_operatortype_append(MASK_OT_slide_point);
WM_operatortype_append(MASK_OT_cyclic_toggle);
WM_operatortype_append(MASK_OT_handle_type_set);
+
+ /* relationships */
+ WM_operatortype_append(MASK_OT_parent_set);
+ WM_operatortype_append(MASK_OT_parent_clear);
}
void ED_keymap_mask(wmKeyConfig *keyconf)
@@ -196,6 +200,10 @@
WM_keymap_add_item(keymap, "MASK_OT_slide_point", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MASK_OT_handle_type_set", VKEY, KM_PRESS, 0, 0);
+ /* relationships */
+ WM_keymap_add_item(keymap, "MASK_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "MASK_OT_parent_set", PKEY, KM_PRESS, KM_ALT, 0);
+
transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
}
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h 2012-05-21 10:20:30 UTC (rev 46838)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h 2012-05-21 11:09:53 UTC (rev 46839)
@@ -56,6 +56,10 @@
void MASK_OT_handle_type_set(struct wmOperatorType *ot);
+/* mask_relationships.c */
+void MASK_OT_parent_set(struct wmOperatorType *ot);
+void MASK_OT_parent_clear(struct wmOperatorType *ot);
+
/* mask_editor.c */
int ED_maskediting_poll(struct bContext *C);
int ED_maskediting_mask_poll(struct bContext *C);
Added: branches/soc-2011-tomato/source/blender/editors/mask/mask_relationships.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_relationships.c (rev 0)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_relationships.c 2012-05-21 11:09:53 UTC (rev 46839)
@@ -0,0 +1,182 @@
+/*
+ * ***** 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) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation,
+ * Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/mask/mask_ops.c
+ * \ingroup edmask
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+#include "BKE_curve.h"
+#include "BKE_depsgraph.h"
+#include "BKE_mask.h"
+#include "BKE_tracking.h"
+
+#include "DNA_mask_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h" /* SELECT */
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+#include "ED_mask.h"
+#include "ED_clip.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "mask_intern.h" /* own include */
+
+static int mask_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Mask *mask = CTX_data_edit_mask(C);
+ MaskObject *maskobj;
+
+ for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
+ MaskSpline *spline;
+ int i;
+
+ for (spline = maskobj->splines.first; spline; spline = spline->next) {
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+
+ if (MASKPOINT_ISSEL(point)) {
+ point->parent.flag &= ~MASK_PARENT_ACTIVE;
+ }
+ }
+ }
+ }
+
+ WM_event_add_notifier(C, NC_MASK | ND_DATA, mask);
+ DAG_id_tag_update(&mask->id, 0);
+
+ return OPERATOR_FINISHED;
+}
+
+void MASK_OT_parent_clear(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Clear Parent";
+ ot->description = "Clear the masks parenting";
+ ot->idname = "MASK_OT_parent_clear";
+
+ /* api callbacks */
+ ot->invoke = WM_menu_invoke;
+ ot->exec = mask_parent_clear_exec;
+
+ ot->poll = ED_operator_object_active_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Mask *mask = CTX_data_edit_mask(C);
+ MaskObject *maskobj;
+
+ /* parent info */
+ SpaceClip *sc;
+ MovieClip *clip;
+ MovieTrackingTrack *track;
+ MovieTrackingMarker *marker;
+ MovieTrackingObject *tracking;
+ /* done */
+
+ float parmask_pos[2];
+
+ if ((NULL == (sc = CTX_wm_space_clip(C))) ||
+ (NULL == (clip = sc->clip)) ||
+ (NULL == (track = clip->tracking.act_track)) ||
+ (NULL == (marker = BKE_tracking_get_marker(track, sc->user.framenr))) ||
+ (NULL == (tracking = BKE_tracking_active_object(&clip->tracking))))
+ {
+ return OPERATOR_CANCELLED;
+ }
+
+ BKE_mask_coord_from_movieclip(clip, &sc->user, parmask_pos, marker->pos);
+
+ for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
+ MaskSpline *spline;
+ int i;
+
+ for (spline = maskobj->splines.first; spline; spline = spline->next) {
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+
+ if (MASKPOINT_ISSEL(point)) {
+ BezTriple *bezt = &point->bezt;
+ float tvec[2];
+
+ point->parent.id_type = ID_MC;
+ point->parent.id = &clip->id;
+ strcpy(point->parent.parent, tracking->name);
+ strcpy(point->parent.sub_parent, track->name);
+
+ point->parent.flag |= MASK_PARENT_ACTIVE;
+
+ sub_v2_v2v2(tvec, parmask_pos, bezt->vec[1]);
+
+ add_v2_v2(bezt->vec[0], tvec);
+ add_v2_v2(bezt->vec[1], tvec);
+ add_v2_v2(bezt->vec[2], tvec);
+
+ negate_v2_v2(point->parent.offset, tvec);
+ }
+ }
+ }
+ }
+
+ WM_event_add_notifier(C, NC_MASK | ND_DATA, mask);
+ DAG_id_tag_update(&mask->id, 0);
+
+ return OPERATOR_FINISHED;
+}
+
+/** based on #OBJECT_OT_parent_set */
+void MASK_OT_parent_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Make Parent";
+ ot->description = "Set the masks parenting";
+ ot->idname = "MASK_OT_parent_set";
+
+ /* api callbacks */
+ //ot->invoke = mask_parent_set_invoke;
+ ot->exec = mask_parent_set_exec;
+
+ ot->poll = ED_operator_object_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
More information about the Bf-blender-cvs
mailing list