Blender V4.3
mask_relationships.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_listbase.h"
10#include "BLI_math_vector.h"
11#include "BLI_string.h"
12
13#include "BKE_context.hh"
14#include "BKE_mask.h"
15#include "BKE_tracking.h"
16
17#include "DEG_depsgraph.hh"
18
19#include "DNA_mask_types.h"
20
21#include "WM_api.hh"
22#include "WM_types.hh"
23
24#include "ED_clip.hh" /* frame remapping functions */
25#include "ED_mask.hh"
26#include "ED_screen.hh"
27
28#include "mask_intern.hh" /* own include */
29
31{
33
34 LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
35 if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
36 continue;
37 }
38
39 LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
40 for (int i = 0; i < spline->tot_point; i++) {
41 MaskSplinePoint *point = &spline->points[i];
42
44 point->parent.id = nullptr;
45 }
46 }
47 }
48 }
49
51 DEG_id_tag_update(&mask->id, 0);
52
53 return OPERATOR_FINISHED;
54}
55
57{
58 /* identifiers */
59 ot->name = "Clear Parent";
60 ot->description = "Clear the mask's parenting";
61 ot->idname = "MASK_OT_parent_clear";
62
63 /* api callbacks */
65
67
68 /* flags */
70}
71
73{
75
76 /* parent info */
79 MovieTrackingTrack *track;
80 MovieTrackingPlaneTrack *plane_track;
81 MovieTrackingObject *tracking_object;
82 /* done */
83
84 int framenr, parent_type;
85 float parmask_pos[2], orig_corners[4][2];
86 const char *sub_parent_name;
87
88 if (ELEM(nullptr, sc, clip)) {
89 return OPERATOR_CANCELLED;
90 }
91
93
94 tracking_object = BKE_tracking_object_get_active(&clip->tracking);
95
96 if (tracking_object == nullptr) {
97 return OPERATOR_CANCELLED;
98 }
99
100 if ((track = tracking_object->active_track) != nullptr) {
101 MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
102 float marker_pos_ofs[2];
103
104 add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset);
105
106 BKE_mask_coord_from_movieclip(clip, &sc->user, parmask_pos, marker_pos_ofs);
107
108 sub_parent_name = track->name;
109 parent_type = MASK_PARENT_POINT_TRACK;
110 memset(orig_corners, 0, sizeof(orig_corners));
111 }
112 else if ((plane_track = tracking_object->active_plane_track) != nullptr) {
113 MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
114
115 zero_v2(parmask_pos);
116 sub_parent_name = plane_track->name;
117 parent_type = MASK_PARENT_PLANE_TRACK;
118 memcpy(orig_corners, plane_marker->corners, sizeof(orig_corners));
119 }
120 else {
121 return OPERATOR_CANCELLED;
122 }
123
124 LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
125 if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
126 continue;
127 }
128
129 LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
130 for (int i = 0; i < spline->tot_point; i++) {
131 MaskSplinePoint *point = &spline->points[i];
132
134 point->parent.id_type = ID_MC;
135 point->parent.id = &clip->id;
136 point->parent.type = parent_type;
137 STRNCPY(point->parent.parent, tracking_object->name);
138 STRNCPY(point->parent.sub_parent, sub_parent_name);
139
140 copy_v2_v2(point->parent.parent_orig, parmask_pos);
141 memcpy(point->parent.parent_corners_orig,
142 orig_corners,
143 sizeof(point->parent.parent_corners_orig));
144 }
145 }
146 }
147 }
148
150 DEG_id_tag_update(&mask->id, 0);
151
152 return OPERATOR_FINISHED;
153}
154
156{
157 /* identifiers */
158 ot->name = "Make Parent";
159 ot->description = "Set the mask's parenting";
160 ot->idname = "MASK_OT_parent_set";
161
162 /* api callbacks */
163 // ot->invoke = mask_parent_set_invoke;
164 ot->exec = mask_parent_set_exec;
165
167
168 /* flags */
170}
Mask * CTX_data_edit_mask(const bContext *C)
SpaceClip * CTX_wm_space_clip(const bContext *C)
#define MASKPOINT_ISSEL_ANY(p)
Definition BKE_mask.h:297
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition tracking.cc:1358
struct MovieTrackingObject * BKE_tracking_object_get_active(const struct MovieTracking *tracking)
struct MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get(struct MovieTrackingPlaneTrack *plane_track, int framenr)
Definition tracking.cc:1791
#define LISTBASE_FOREACH(type, var, list)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v2(float r[2])
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define ELEM(...)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_MC
@ MASK_PARENT_PLANE_TRACK
@ MASK_PARENT_POINT_TRACK
@ MASK_HIDE_SELECT
@ MASK_HIDE_VIEW
MovieClip * ED_space_clip_get_clip(const SpaceClip *sc)
bool ED_space_clip_maskedit_mask_poll(bContext *C)
int ED_space_clip_get_clip_frame_number(const SpaceClip *sc)
bool ED_maskedit_mask_visible_splines_poll(bContext *C)
Definition mask_edit.cc:78
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
#define C
Definition RandGen.cpp:29
#define ND_DATA
Definition WM_types.hh:475
@ OPTYPE_UNDO
Definition WM_types.hh:162
@ OPTYPE_REGISTER
Definition WM_types.hh:160
#define NC_MASK
Definition WM_types.hh:365
static int mask_parent_set_exec(bContext *C, wmOperator *)
static int mask_parent_clear_exec(bContext *C, wmOperator *)
void MASK_OT_parent_clear(wmOperatorType *ot)
void MASK_OT_parent_set(wmOperatorType *ot)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
struct MovieTracking tracking
MovieTrackingPlaneTrack * active_plane_track
MovieTrackingTrack * active_track
struct MovieClipUser user
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4125