2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spclip
|
2012-06-15 11:40:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_movieclip_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_lasso_2d.h"
|
2022-10-07 16:55:43 +02:00
|
|
|
#include "BLI_listbase.h"
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
#include "BLI_math_geom.h"
|
|
|
|
|
#include "BLI_math_vector.h"
|
2012-06-15 11:40:04 +00:00
|
|
|
#include "BLI_rect.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2012-06-15 11:40:04 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_tracking.h"
|
|
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_clip.hh"
|
|
|
|
|
#include "ED_mask.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_select_utils.hh"
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
|
|
|
|
#include "RNA_define.hh"
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_view2d.hh"
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2018-08-13 16:59:42 -03:00
|
|
|
|
2016-01-28 17:23:12 +11:00
|
|
|
#include "clip_intern.h" /* own include */
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "tracking_ops_intern.h" /* own include */
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Point track marker picking.
|
|
|
|
|
* \{ */
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2023-07-02 19:37:22 +10:00
|
|
|
BLI_INLINE PointTrackPick point_track_pick_make_null()
|
2022-10-07 16:55:43 +02:00
|
|
|
{
|
2023-03-01 12:32:15 +01:00
|
|
|
PointTrackPick pick = {nullptr};
|
2022-10-07 16:55:43 +02:00
|
|
|
|
|
|
|
|
pick.area = TRACK_AREA_NONE;
|
|
|
|
|
pick.area_detail = TRACK_PICK_AREA_DETAIL_NONE;
|
|
|
|
|
pick.corner_index = -1;
|
|
|
|
|
pick.distance_px_squared = FLT_MAX;
|
|
|
|
|
|
|
|
|
|
return pick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void slide_marker_tilt_slider_relative(const float pattern_corners[4][2], float r_slider[2])
|
|
|
|
|
{
|
|
|
|
|
add_v2_v2v2(r_slider, pattern_corners[1], pattern_corners[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void slide_marker_tilt_slider(const float marker_pos[2],
|
|
|
|
|
const float pattern_corners[4][2],
|
|
|
|
|
float r_slider[2])
|
|
|
|
|
{
|
|
|
|
|
slide_marker_tilt_slider_relative(pattern_corners, r_slider);
|
|
|
|
|
add_v2_v2(r_slider, marker_pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float mouse_to_slide_zone_distance_squared(const float co[2],
|
|
|
|
|
const float slide_zone[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
|
|
|
|
const float pixel_co[2] = {co[0] * width, co[1] * height},
|
|
|
|
|
pixel_slide_zone[2] = {slide_zone[0] * width, slide_zone[1] * height};
|
|
|
|
|
return square_f(pixel_co[0] - pixel_slide_zone[0]) + square_f(pixel_co[1] - pixel_slide_zone[1]);
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
static float mouse_to_search_corner_distance_squared(
|
|
|
|
|
const MovieTrackingMarker *marker, const float co[2], int corner, int width, int height)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2022-10-07 16:55:43 +02:00
|
|
|
float side_zone[2];
|
|
|
|
|
if (corner == 0) {
|
|
|
|
|
side_zone[0] = marker->pos[0] + marker->search_max[0];
|
|
|
|
|
side_zone[1] = marker->pos[1] + marker->search_min[1];
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2022-10-07 16:55:43 +02:00
|
|
|
else {
|
|
|
|
|
side_zone[0] = marker->pos[0] + marker->search_min[0];
|
|
|
|
|
side_zone[1] = marker->pos[1] + marker->search_max[1];
|
|
|
|
|
}
|
|
|
|
|
return mouse_to_slide_zone_distance_squared(co, side_zone, width, height);
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
static float mouse_to_closest_pattern_corner_distance_squared(
|
|
|
|
|
const MovieTrackingMarker *marker, const float co[2], int width, int height, int *r_corner)
|
|
|
|
|
{
|
|
|
|
|
float min_distance_squared = FLT_MAX;
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
float corner_co[2];
|
|
|
|
|
add_v2_v2v2(corner_co, marker->pattern_corners[i], marker->pos);
|
|
|
|
|
float distance_squared = mouse_to_slide_zone_distance_squared(co, corner_co, width, height);
|
|
|
|
|
if (distance_squared < min_distance_squared) {
|
|
|
|
|
min_distance_squared = distance_squared;
|
|
|
|
|
*r_corner = i;
|
|
|
|
|
}
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2022-10-07 16:55:43 +02:00
|
|
|
return min_distance_squared;
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
static float mouse_to_offset_distance_squared(const MovieTrackingTrack *track,
|
|
|
|
|
const MovieTrackingMarker *marker,
|
|
|
|
|
const float co[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
|
|
|
|
float pos[2];
|
|
|
|
|
add_v2_v2v2(pos, marker->pos, track->offset);
|
|
|
|
|
return mouse_to_slide_zone_distance_squared(co, pos, width, height);
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
static float mouse_to_tilt_distance_squared(const MovieTrackingMarker *marker,
|
|
|
|
|
const float co[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2022-10-07 16:55:43 +02:00
|
|
|
float slider[2];
|
|
|
|
|
slide_marker_tilt_slider(marker->pos, marker->pattern_corners, slider);
|
|
|
|
|
return mouse_to_slide_zone_distance_squared(co, slider, width, height);
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
static float mouse_to_closest_corners_edge_distance_squared(const float co[2],
|
|
|
|
|
const float corners_offset[2],
|
|
|
|
|
const float corners[4][2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2022-10-07 16:55:43 +02:00
|
|
|
const float co_px[2] = {co[0] * width, co[1] * height};
|
|
|
|
|
|
|
|
|
|
float prev_corner_co_px[2];
|
|
|
|
|
add_v2_v2v2(prev_corner_co_px, corners_offset, corners[3]);
|
|
|
|
|
prev_corner_co_px[0] *= width;
|
|
|
|
|
prev_corner_co_px[1] *= height;
|
|
|
|
|
|
|
|
|
|
float min_distance_squared = FLT_MAX;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
|
float corner_co_px[2];
|
|
|
|
|
add_v2_v2v2(corner_co_px, corners_offset, corners[i]);
|
|
|
|
|
corner_co_px[0] *= width;
|
|
|
|
|
corner_co_px[1] *= height;
|
|
|
|
|
|
|
|
|
|
const float distance_squared = dist_squared_to_line_segment_v2(
|
|
|
|
|
co_px, corner_co_px, prev_corner_co_px);
|
|
|
|
|
|
|
|
|
|
if (distance_squared < min_distance_squared) {
|
|
|
|
|
min_distance_squared = distance_squared;
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
copy_v2_v2(prev_corner_co_px, corner_co_px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return min_distance_squared;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
static float mouse_to_closest_pattern_edge_distance_squared(const MovieTrackingMarker *marker,
|
|
|
|
|
const float co[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2022-10-07 16:55:43 +02:00
|
|
|
return mouse_to_closest_corners_edge_distance_squared(
|
|
|
|
|
co, marker->pos, marker->pattern_corners, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float mouse_to_closest_search_edge_distance_squared(const MovieTrackingMarker *marker,
|
|
|
|
|
const float co[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
|
|
|
|
const float corners[4][2] = {
|
|
|
|
|
{marker->search_min[0], marker->search_min[1]},
|
|
|
|
|
{marker->search_max[0], marker->search_min[1]},
|
|
|
|
|
{marker->search_max[0], marker->search_max[1]},
|
|
|
|
|
{marker->search_min[0], marker->search_max[1]},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return mouse_to_closest_corners_edge_distance_squared(co, marker->pos, corners, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PointTrackPick ed_tracking_pick_point_track(const TrackPickOptions *options,
|
|
|
|
|
bContext *C,
|
|
|
|
|
const float co[2])
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
|
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
int width, height;
|
2022-10-07 16:55:43 +02:00
|
|
|
ED_space_clip_get_size(space_clip, &width, &height);
|
|
|
|
|
if (width == 0 || height == 0) {
|
|
|
|
|
return point_track_pick_make_null();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(space_clip);
|
|
|
|
|
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
const float distance_tolerance_px_squared = (12.0f * 12.0f) / space_clip->zoom;
|
|
|
|
|
const bool are_disabled_markers_visible = (space_clip->flag & SC_HIDE_DISABLED) == 0;
|
|
|
|
|
const int framenr = ED_space_clip_get_clip_frame_number(space_clip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
PointTrackPick pick = point_track_pick_make_null();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
|
|
|
|
const bool is_track_selected = TRACK_VIEW_SELECTED(space_clip, track);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
if (options->selected_only && !is_track_selected) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (options->unlocked_only && (track->flag & TRACK_LOCKED)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
|
|
|
|
const bool is_marker_enabled = ((marker->flag & MARKER_DISABLED) == 0);
|
|
|
|
|
|
|
|
|
|
if (!is_marker_enabled) {
|
|
|
|
|
if (options->enabled_only) {
|
|
|
|
|
/* Disabled marker is requested to not be in the pick result, so skip it. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See whether the disabled marker is visible.
|
|
|
|
|
*
|
|
|
|
|
* If the clip editor is not hiding disabled markers, then all disabled markers are visible.
|
|
|
|
|
* Otherwise only disabled marker of the active track is visible. */
|
|
|
|
|
if (!are_disabled_markers_visible && track != tracking_object->active_track) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
float distance_squared;
|
|
|
|
|
|
|
|
|
|
/* Initialize the current pick with the offset point of the track. */
|
|
|
|
|
PointTrackPick current_pick = point_track_pick_make_null();
|
|
|
|
|
current_pick.track = track;
|
|
|
|
|
current_pick.marker = marker;
|
|
|
|
|
current_pick.area = TRACK_AREA_POINT;
|
|
|
|
|
current_pick.distance_px_squared = mouse_to_offset_distance_squared(
|
|
|
|
|
track, marker, co, width, height);
|
|
|
|
|
|
|
|
|
|
/* If search area is visible, check how close to its sliding zones mouse is.
|
|
|
|
|
* NOTE: The search area is only visible for selected tracks. */
|
|
|
|
|
if (is_track_selected && (space_clip->flag & SC_SHOW_MARKER_SEARCH)) {
|
|
|
|
|
distance_squared = mouse_to_search_corner_distance_squared(marker, co, 1, width, height);
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.area = TRACK_AREA_SEARCH;
|
|
|
|
|
current_pick.area_detail = TRACK_PICK_AREA_DETAIL_OFFSET;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
distance_squared = mouse_to_search_corner_distance_squared(marker, co, 0, width, height);
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.area = TRACK_AREA_SEARCH;
|
|
|
|
|
current_pick.area_detail = TRACK_PICK_AREA_DETAIL_SIZE;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
/* If pattern area is visible, check which corner is closest to the mouse. */
|
|
|
|
|
if (space_clip->flag & SC_SHOW_MARKER_PATTERN) {
|
|
|
|
|
int current_corner = -1;
|
|
|
|
|
distance_squared = mouse_to_closest_pattern_corner_distance_squared(
|
|
|
|
|
marker, co, width, height, ¤t_corner);
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.area = TRACK_AREA_PAT;
|
|
|
|
|
current_pick.area_detail = TRACK_PICK_AREA_DETAIL_POSITION;
|
|
|
|
|
current_pick.corner_index = current_corner;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
/* Here we also check whether the mouse is actually closer to the widget which controls scale
|
|
|
|
|
* and tilt.
|
2022-12-05 12:58:18 +11:00
|
|
|
* NOTE: The tilt control is only visible for selected tracks. */
|
2022-10-07 16:55:43 +02:00
|
|
|
if (is_track_selected) {
|
|
|
|
|
distance_squared = mouse_to_tilt_distance_squared(marker, co, width, height);
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.area = TRACK_AREA_PAT;
|
|
|
|
|
current_pick.area_detail = TRACK_PICK_AREA_DETAIL_TILT_SIZE;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Whenever a manipulation "widgets" are not within distance tolerance test the edges as well.
|
|
|
|
|
* This allows to pick tracks by clicking on the pattern/search areas edges but prefer to use
|
|
|
|
|
* more actionable "widget" for sliding. */
|
|
|
|
|
if (current_pick.distance_px_squared > distance_tolerance_px_squared) {
|
|
|
|
|
if (is_track_selected && (space_clip->flag & SC_SHOW_MARKER_SEARCH)) {
|
|
|
|
|
distance_squared = mouse_to_closest_search_edge_distance_squared(
|
|
|
|
|
marker, co, width, height);
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.area = TRACK_AREA_SEARCH;
|
|
|
|
|
current_pick.area_detail = TRACK_PICK_AREA_DETAIL_EDGE;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (space_clip->flag & SC_SHOW_MARKER_PATTERN) {
|
|
|
|
|
distance_squared = mouse_to_closest_pattern_edge_distance_squared(
|
|
|
|
|
marker, co, width, height);
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.area = TRACK_AREA_PAT;
|
|
|
|
|
current_pick.area_detail = TRACK_PICK_AREA_DETAIL_EDGE;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current_pick.distance_px_squared < pick.distance_px_squared) {
|
|
|
|
|
pick = current_pick;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
if (pick.distance_px_squared > distance_tolerance_px_squared) {
|
|
|
|
|
return point_track_pick_make_null();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pick;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
bool ed_tracking_point_track_pick_can_slide(const SpaceClip *space_clip,
|
|
|
|
|
const PointTrackPick *pick)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2023-03-01 12:32:15 +01:00
|
|
|
if (pick->track == nullptr) {
|
2022-10-07 16:55:43 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
BLI_assert(pick->marker != nullptr);
|
2022-10-07 16:55:43 +02:00
|
|
|
|
|
|
|
|
if (!TRACK_VIEW_SELECTED(space_clip, pick->track)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
if (pick->track->flag & TRACK_LOCKED) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (pick->marker->flag & MARKER_DISABLED) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pick->area_detail != TRACK_PICK_AREA_DETAIL_EDGE;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Plane track marker picking.
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2023-07-02 19:37:22 +10:00
|
|
|
BLI_INLINE PlaneTrackPick plane_track_pick_make_null()
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2023-03-01 12:32:15 +01:00
|
|
|
PlaneTrackPick result = {nullptr};
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
result.corner_index = -1;
|
|
|
|
|
result.distance_px_squared = FLT_MAX;
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
return result;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
static float mouse_to_plane_slide_zone_distance_squared(const float co[2],
|
|
|
|
|
const float slide_zone[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
{
|
2022-10-07 16:55:43 +02:00
|
|
|
const float pixel_co[2] = {co[0] * width, co[1] * height};
|
|
|
|
|
const float pixel_slide_zone[2] = {slide_zone[0] * width, slide_zone[1] * height};
|
|
|
|
|
return square_f(pixel_co[0] - pixel_slide_zone[0]) + square_f(pixel_co[1] - pixel_slide_zone[1]);
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
PlaneTrackPick ed_tracking_pick_plane_track(const TrackPickOptions *options,
|
|
|
|
|
bContext *C,
|
|
|
|
|
const float co[2])
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2022-10-07 16:55:43 +02:00
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
int width, height;
|
|
|
|
|
ED_space_clip_get_size(space_clip, &width, &height);
|
|
|
|
|
if (width == 0 || height == 0) {
|
|
|
|
|
return plane_track_pick_make_null();
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(space_clip);
|
|
|
|
|
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
|
|
|
|
const int framenr = ED_space_clip_get_clip_frame_number(space_clip);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
const float distance_tolerance_px_squared = (12.0f * 12.0f) / space_clip->zoom;
|
|
|
|
|
PlaneTrackPick pick = plane_track_pick_make_null();
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) {
|
|
|
|
|
if (options->selected_only && !PLANE_TRACK_VIEW_SELECTED(plane_track)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
PlaneTrackPick current_pick = plane_track_pick_make_null();
|
|
|
|
|
current_pick.plane_track = plane_track;
|
|
|
|
|
current_pick.plane_marker = plane_marker;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
const float distance_squared = mouse_to_plane_slide_zone_distance_squared(
|
|
|
|
|
co, plane_marker->corners[i], width, height);
|
|
|
|
|
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.corner_index = i;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
if (current_pick.distance_px_squared > distance_tolerance_px_squared) {
|
|
|
|
|
const float zero_offset[2] = {0.0f, 0.0f};
|
|
|
|
|
const float distance_squared = mouse_to_closest_corners_edge_distance_squared(
|
|
|
|
|
co, zero_offset, plane_marker->corners, width, height);
|
|
|
|
|
if (distance_squared < current_pick.distance_px_squared) {
|
|
|
|
|
current_pick.corner_index = -1;
|
|
|
|
|
current_pick.distance_px_squared = distance_squared;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
if (current_pick.distance_px_squared < pick.distance_px_squared) {
|
|
|
|
|
pick = current_pick;
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
if (pick.distance_px_squared > distance_tolerance_px_squared) {
|
|
|
|
|
return plane_track_pick_make_null();
|
|
|
|
|
}
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
return pick;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
bool ed_tracking_plane_track_pick_can_slide(const PlaneTrackPick *pick)
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
{
|
2023-03-01 12:32:15 +01:00
|
|
|
if (pick->plane_track == nullptr) {
|
2022-10-07 16:55:43 +02:00
|
|
|
return false;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
BLI_assert(pick->plane_marker != nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
if (!PLANE_TRACK_VIEW_SELECTED(pick->plane_track)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pick->corner_index != -1;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2022-12-01 16:29:20 +01:00
|
|
|
/** \name Pick closest point or plane track.
|
2022-10-07 16:55:43 +02:00
|
|
|
* \{ */
|
|
|
|
|
|
2023-07-02 19:37:22 +10:00
|
|
|
BLI_INLINE TrackingPick tracking_pick_make_null()
|
2022-10-07 16:55:43 +02:00
|
|
|
{
|
|
|
|
|
TrackingPick result;
|
|
|
|
|
|
|
|
|
|
result.point_track_pick = point_track_pick_make_null();
|
|
|
|
|
result.plane_track_pick = plane_track_pick_make_null();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool tracking_should_prefer_point_track(bContext *C,
|
|
|
|
|
const PointTrackPick *point_track_pick,
|
|
|
|
|
const PlaneTrackPick *plane_track_pick)
|
|
|
|
|
{
|
|
|
|
|
/* Simple case: one of the pick results is empty, so prefer the other one. */
|
2023-03-01 12:32:15 +01:00
|
|
|
if (point_track_pick->track == nullptr) {
|
2022-10-07 16:55:43 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2023-03-01 12:32:15 +01:00
|
|
|
if (plane_track_pick->plane_track == nullptr) {
|
2022-10-07 16:55:43 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
|
|
|
|
|
|
|
|
|
/* If one of the picks can be slid prefer it. */
|
|
|
|
|
const bool can_slide_point_track = ed_tracking_point_track_pick_can_slide(space_clip,
|
|
|
|
|
point_track_pick);
|
|
|
|
|
const bool can_slide_plane_track = ed_tracking_plane_track_pick_can_slide(plane_track_pick);
|
|
|
|
|
if (can_slide_point_track && !can_slide_plane_track) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (!can_slide_point_track && can_slide_plane_track) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Prefer the closest pick. */
|
|
|
|
|
if (point_track_pick->distance_px_squared > plane_track_pick->distance_px_squared) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TrackingPick ed_tracking_pick_closest(const TrackPickOptions *options,
|
|
|
|
|
bContext *C,
|
|
|
|
|
const float co[2])
|
|
|
|
|
{
|
|
|
|
|
TrackingPick pick;
|
|
|
|
|
|
|
|
|
|
pick.point_track_pick = ed_tracking_pick_point_track(options, C, co);
|
|
|
|
|
pick.plane_track_pick = ed_tracking_pick_plane_track(options, C, co);
|
|
|
|
|
|
|
|
|
|
if (tracking_should_prefer_point_track(C, &pick.point_track_pick, &pick.plane_track_pick)) {
|
|
|
|
|
pick.plane_track_pick = plane_track_pick_make_null();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pick.point_track_pick = point_track_pick_make_null();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/********************** mouse select operator *********************/
|
|
|
|
|
|
2019-04-29 17:05:54 +02:00
|
|
|
void ed_tracking_deselect_all_tracks(ListBase *tracks_base)
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
{
|
2023-03-01 12:32:15 +01:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, tracks_base) {
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-29 17:05:54 +02:00
|
|
|
void ed_tracking_deselect_all_plane_tracks(ListBase *plane_tracks_base)
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
{
|
2023-03-01 12:32:15 +01:00
|
|
|
LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
plane_track->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-13 17:21:55 +02:00
|
|
|
static bool select_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
|
|
|
|
|
|
|
|
|
if (sc) {
|
|
|
|
|
return sc->clip && sc->view == SC_VIEW_CLIP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int select_exec(bContext *C, wmOperator *op)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2012-06-15 11:40:04 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2022-10-04 17:39:57 +02:00
|
|
|
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
|
2022-05-13 17:21:55 +02:00
|
|
|
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
|
|
|
|
const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
|
|
|
|
|
|
|
|
|
|
float co[2];
|
|
|
|
|
RNA_float_get_array(op->ptr, "location", co);
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
const TrackPickOptions options = ed_tracking_pick_options_defaults();
|
|
|
|
|
const TrackingPick pick = ed_tracking_pick_closest(&options, C, co);
|
|
|
|
|
|
2022-05-13 17:21:55 +02:00
|
|
|
/* Special code which allows to slide a marker which belongs to currently selected but not yet
|
|
|
|
|
* active track. If such track is found activate it and return pass-though so that marker slide
|
|
|
|
|
* operator can be used immediately after.
|
2022-10-07 16:55:43 +02:00
|
|
|
* This logic makes it convenient to slide markers when left mouse selection is used. Without it
|
|
|
|
|
* selection will be lost which causes inconvenience for the VFX artist. */
|
|
|
|
|
const bool activate_selected = !extend;
|
|
|
|
|
if (activate_selected && ed_tracking_pick_can_slide(sc, &pick)) {
|
2023-03-01 12:32:15 +01:00
|
|
|
if (pick.point_track_pick.track != nullptr) {
|
2022-10-07 16:55:43 +02:00
|
|
|
tracking_object->active_track = pick.point_track_pick.track;
|
2023-03-01 12:32:15 +01:00
|
|
|
tracking_object->active_plane_track = nullptr;
|
2022-10-07 16:55:43 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2023-03-01 12:32:15 +01:00
|
|
|
tracking_object->active_track = nullptr;
|
2022-10-07 16:55:43 +02:00
|
|
|
tracking_object->active_plane_track = pick.plane_track_pick.plane_track;
|
2022-05-13 17:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, nullptr);
|
2022-10-07 16:55:43 +02:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-19 14:28:44 +01:00
|
|
|
ClipViewLockState lock_state;
|
|
|
|
|
ED_clip_view_lock_state_store(C, &lock_state);
|
|
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
if (pick.point_track_pick.track != nullptr) {
|
2019-04-29 17:29:05 +02:00
|
|
|
if (!extend) {
|
2022-10-04 17:39:57 +02:00
|
|
|
ed_tracking_deselect_all_plane_tracks(&tracking_object->plane_tracks);
|
2019-04-29 17:29:05 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
MovieTrackingTrack *track = pick.point_track_pick.track;
|
|
|
|
|
int area = pick.point_track_pick.area;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!extend || !TRACK_VIEW_SELECTED(sc, track)) {
|
2012-06-15 11:40:04 +00:00
|
|
|
area = TRACK_AREA_ALL;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
if (extend && TRACK_AREA_SELECTED(track, area)) {
|
2022-10-04 17:39:57 +02:00
|
|
|
if (track == tracking_object->active_track) {
|
2012-06-15 11:40:04 +00:00
|
|
|
BKE_tracking_track_deselect(track, area);
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2022-10-04 17:39:57 +02:00
|
|
|
tracking_object->active_track = track;
|
2023-03-01 12:32:15 +01:00
|
|
|
tracking_object->active_plane_track = nullptr;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (area == TRACK_AREA_POINT) {
|
2012-06-15 11:40:04 +00:00
|
|
|
area = TRACK_AREA_ALL;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-04 17:39:57 +02:00
|
|
|
BKE_tracking_track_select(&tracking_object->tracks, track, area, extend);
|
|
|
|
|
tracking_object->active_track = track;
|
2023-03-01 12:32:15 +01:00
|
|
|
tracking_object->active_plane_track = nullptr;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-03-01 12:32:15 +01:00
|
|
|
else if (pick.plane_track_pick.plane_track != nullptr) {
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
if (!extend) {
|
2022-10-04 17:39:57 +02:00
|
|
|
ed_tracking_deselect_all_tracks(&tracking_object->tracks);
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
MovieTrackingPlaneTrack *plane_track = pick.plane_track_pick.plane_track;
|
|
|
|
|
|
2014-03-06 20:07:14 +06:00
|
|
|
if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
if (extend) {
|
|
|
|
|
plane_track->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
plane_track->flag |= SELECT;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
tracking_object->active_track = nullptr;
|
2022-10-04 17:39:57 +02:00
|
|
|
tracking_object->active_plane_track = plane_track;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-29 17:29:05 +02:00
|
|
|
else if (deselect_all) {
|
2022-10-04 17:39:57 +02:00
|
|
|
ed_tracking_deselect_all_tracks(&tracking_object->tracks);
|
|
|
|
|
ed_tracking_deselect_all_plane_tracks(&tracking_object->plane_tracks);
|
2019-04-29 17:29:05 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-19 14:28:44 +01:00
|
|
|
ED_clip_view_lock_state_restore_no_jump(C, &lock_state);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
BKE_tracking_dopesheet_tag_update(tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, nullptr);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 16:55:43 +02:00
|
|
|
/* This is a bit implicit, but when the selection operator is used from a LMB Add Marker and
|
|
|
|
|
* tweak tool we do not want the pass-through here and only want selection to happen. This way
|
|
|
|
|
* the selection operator will not fall-through to Add Marker operator. */
|
|
|
|
|
if (activate_selected) {
|
|
|
|
|
if (ed_tracking_pick_can_slide(sc, &pick)) {
|
|
|
|
|
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ed_tracking_pick_empty(&pick)) {
|
|
|
|
|
/* When nothing was selected pass-though and allow Add Marker part of the keymap to add new
|
|
|
|
|
* marker at the position. */
|
|
|
|
|
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-15 15:21:46 +10:00
|
|
|
/* Pass-through + finished to allow tweak to transform. */
|
|
|
|
|
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2012-07-26 22:41:40 +00:00
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2012-07-26 22:41:40 +00:00
|
|
|
|
2022-05-13 17:14:28 +02:00
|
|
|
float co[2];
|
|
|
|
|
ED_clip_mouse_pos(sc, region, event->mval, co);
|
2012-06-15 11:40:04 +00:00
|
|
|
RNA_float_set_array(op->ptr, "location", co);
|
|
|
|
|
|
|
|
|
|
return select_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_select(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select";
|
|
|
|
|
ot->description = "Select tracking markers";
|
|
|
|
|
ot->idname = "CLIP_OT_select";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = select_exec;
|
|
|
|
|
ot->invoke = select_invoke;
|
2013-03-09 10:52:43 +00:00
|
|
|
ot->poll = select_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* properties */
|
2019-04-29 17:29:05 +02:00
|
|
|
PropertyRNA *prop;
|
2021-08-25 17:59:47 +10:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"extend",
|
2023-07-22 11:36:59 +10:00
|
|
|
false,
|
2021-08-25 17:59:47 +10:00
|
|
|
"Extend",
|
|
|
|
|
"Extend selection rather than clearing the existing selection");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2019-04-29 17:29:05 +02:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"deselect_all",
|
|
|
|
|
false,
|
|
|
|
|
"Deselect On Nothing",
|
|
|
|
|
"Deselect all when nothing under the cursor");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
RNA_def_float_vector(
|
|
|
|
|
ot->srna,
|
|
|
|
|
"location",
|
|
|
|
|
2,
|
2023-03-01 12:32:15 +01:00
|
|
|
nullptr,
|
2012-06-15 11:40:04 +00:00
|
|
|
-FLT_MAX,
|
|
|
|
|
FLT_MAX,
|
|
|
|
|
"Location",
|
|
|
|
|
"Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds",
|
|
|
|
|
-100.0f,
|
|
|
|
|
100.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-04 14:47:29 +02:00
|
|
|
bool ED_clip_can_select(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
/* To avoid conflicts with mask select deselect all in empty space. */
|
|
|
|
|
return select_poll(C);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
/********************** box select operator *********************/
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
static int box_select_exec(bContext *C, wmOperator *op)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2022-10-07 11:32:21 +02:00
|
|
|
const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
2012-06-15 11:40:04 +00:00
|
|
|
rcti rect;
|
|
|
|
|
rctf rectf;
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = false;
|
2012-06-19 14:26:29 +00:00
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* get rectangle from operator */
|
2012-08-08 20:38:55 +00:00
|
|
|
WM_operator_properties_border_to_rcti(op, &rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_point_stable_pos(sc, region, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
|
|
|
|
|
ED_clip_point_stable_pos(sc, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
|
2019-03-07 20:33:57 +11:00
|
|
|
const bool select = (sel_op != SEL_OP_SUB);
|
|
|
|
|
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
2023-03-01 12:32:15 +01:00
|
|
|
ED_clip_select_all(sc, SEL_DESELECT, nullptr);
|
2019-03-07 20:33:57 +11:00
|
|
|
changed = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* do actual selection */
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2022-10-07 17:26:35 +02:00
|
|
|
if (track->flag & TRACK_HIDDEN) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
|
|
|
|
|
|
|
|
|
if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
|
|
|
|
|
if (BLI_rctf_isect_pt_v(&rectf, marker->pos)) {
|
|
|
|
|
if (select) {
|
|
|
|
|
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2022-10-07 17:26:35 +02:00
|
|
|
changed = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) {
|
2022-10-07 17:26:35 +02:00
|
|
|
if (plane_track->flag & PLANE_TRACK_HIDDEN) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track,
|
|
|
|
|
framenr);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
if (BLI_rctf_isect_pt_v(&rectf, plane_marker->corners[i])) {
|
|
|
|
|
if (select) {
|
|
|
|
|
plane_track->flag |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
plane_track->flag &= ~SELECT;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2022-10-07 17:26:35 +02:00
|
|
|
changed = true;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
if (changed) {
|
2022-10-07 11:32:21 +02:00
|
|
|
BKE_tracking_dopesheet_tag_update(&clip->tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, nullptr);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
void CLIP_OT_select_box(wmOperatorType *ot)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->name = "Box Select";
|
|
|
|
|
ot->description = "Select markers using box selection";
|
|
|
|
|
ot->idname = "CLIP_OT_select_box";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* api callbacks */
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->invoke = WM_gesture_box_invoke;
|
|
|
|
|
ot->exec = box_select_exec;
|
|
|
|
|
ot->modal = WM_gesture_box_modal;
|
2012-06-15 11:40:04 +00:00
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* properties */
|
2019-03-07 20:33:57 +11:00
|
|
|
WM_operator_properties_gesture_box(ot);
|
|
|
|
|
WM_operator_properties_select_operation_simple(ot);
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** lasso select operator *********************/
|
|
|
|
|
|
2014-03-31 15:31:28 +06:00
|
|
|
static int do_lasso_select_marker(bContext *C,
|
2020-05-04 19:50:06 +10:00
|
|
|
const int mcoords[][2],
|
2020-05-05 16:12:36 +10:00
|
|
|
const int mcoords_len,
|
2014-03-31 15:31:28 +06:00
|
|
|
bool select)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2022-10-07 11:32:21 +02:00
|
|
|
const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
2012-06-15 11:40:04 +00:00
|
|
|
rcti rect;
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = false;
|
2022-10-07 11:32:21 +02:00
|
|
|
const int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* get rectangle from operator */
|
2020-05-04 19:50:06 +10:00
|
|
|
BLI_lasso_boundbox(&rect, mcoords, mcoords_len);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* do actual selection */
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2022-10-07 17:26:35 +02:00
|
|
|
if (track->flag & TRACK_HIDDEN) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 17:26:35 +02:00
|
|
|
const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
|
|
|
|
|
|
|
|
|
if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
|
|
|
|
|
float screen_co[2];
|
|
|
|
|
|
|
|
|
|
/* marker in screen coords */
|
|
|
|
|
ED_clip_point_stable_pos__reverse(sc, region, marker->pos, screen_co);
|
|
|
|
|
|
|
|
|
|
if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
|
|
|
|
|
BLI_lasso_is_point_inside(
|
|
|
|
|
mcoords, mcoords_len, screen_co[0], screen_co[1], V2D_IS_CLIPPED))
|
|
|
|
|
{
|
|
|
|
|
if (select) {
|
|
|
|
|
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2022-10-07 17:26:35 +02:00
|
|
|
|
|
|
|
|
changed = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) {
|
2022-10-07 17:26:35 +02:00
|
|
|
if (plane_track->flag & PLANE_TRACK_HIDDEN) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track,
|
|
|
|
|
framenr);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
float screen_co[2];
|
|
|
|
|
|
|
|
|
|
/* marker in screen coords */
|
|
|
|
|
ED_clip_point_stable_pos__reverse(sc, region, plane_marker->corners[i], screen_co);
|
|
|
|
|
|
|
|
|
|
if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
|
|
|
|
|
BLI_lasso_is_point_inside(
|
|
|
|
|
mcoords, mcoords_len, screen_co[0], screen_co[1], V2D_IS_CLIPPED))
|
|
|
|
|
{
|
|
|
|
|
if (select) {
|
|
|
|
|
plane_track->flag |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
plane_track->flag &= ~SELECT;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2022-10-07 17:26:35 +02:00
|
|
|
|
|
|
|
|
changed = true;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
if (changed) {
|
2022-10-07 11:32:21 +02:00
|
|
|
BKE_tracking_dopesheet_tag_update(&clip->tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, nullptr);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
return changed;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int clip_lasso_select_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2020-05-04 19:50:06 +10:00
|
|
|
int mcoords_len;
|
|
|
|
|
const int(*mcoords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcoords_len);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2020-05-04 19:50:06 +10:00
|
|
|
if (mcoords) {
|
2023-03-01 12:32:15 +01:00
|
|
|
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
|
2019-03-07 23:41:32 +11:00
|
|
|
const bool select = (sel_op != SEL_OP_SUB);
|
|
|
|
|
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2023-03-01 12:32:15 +01:00
|
|
|
ED_clip_select_all(sc, SEL_DESELECT, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-07 23:41:32 +11:00
|
|
|
|
2020-05-04 19:50:06 +10:00
|
|
|
do_lasso_select_marker(C, mcoords, mcoords_len, select);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2020-05-04 19:50:06 +10:00
|
|
|
MEM_freeN((void *)mcoords);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_select_lasso(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Lasso Select";
|
|
|
|
|
ot->description = "Select markers using lasso selection";
|
|
|
|
|
ot->idname = "CLIP_OT_select_lasso";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke = WM_gesture_lasso_invoke;
|
|
|
|
|
ot->modal = WM_gesture_lasso_modal;
|
|
|
|
|
ot->exec = clip_lasso_select_exec;
|
|
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
|
|
|
|
ot->cancel = WM_gesture_lasso_cancel;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* flags */
|
2021-09-17 12:09:26 +10:00
|
|
|
ot->flag = OPTYPE_UNDO | OPTYPE_DEPENDS_ON_CURSOR;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* properties */
|
2019-03-07 23:41:32 +11:00
|
|
|
WM_operator_properties_gesture_lasso(ot);
|
|
|
|
|
WM_operator_properties_select_operation_simple(ot);
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** circle select operator *********************/
|
|
|
|
|
|
2020-07-13 11:27:09 +02:00
|
|
|
static int point_inside_ellipse(const float point[2],
|
|
|
|
|
const float offset[2],
|
|
|
|
|
const float ellipse[2])
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
|
|
|
|
/* normalized ellipse: ell[0] = scaleX, ell[1] = scaleY */
|
|
|
|
|
float x, y;
|
|
|
|
|
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
x = (point[0] - offset[0]) * ellipse[0];
|
|
|
|
|
y = (point[1] - offset[1]) * ellipse[1];
|
2012-06-15 11:40:04 +00:00
|
|
|
|
|
|
|
|
return x * x + y * y < 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-07 17:26:35 +02:00
|
|
|
static int marker_inside_ellipse(const MovieTrackingMarker *marker,
|
2020-08-07 22:56:13 +10:00
|
|
|
const float offset[2],
|
|
|
|
|
const float ellipse[2])
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
{
|
|
|
|
|
return point_inside_ellipse(marker->pos, offset, ellipse);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
static int circle_select_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2022-10-07 11:32:21 +02:00
|
|
|
const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
2017-10-16 21:58:51 +11:00
|
|
|
int width, height;
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = false;
|
2012-06-15 11:40:04 +00:00
|
|
|
float zoomx, zoomy, offset[2], ellipse[2];
|
2012-06-19 14:26:29 +00:00
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* get operator properties */
|
2017-10-16 21:58:51 +11:00
|
|
|
const int x = RNA_int_get(op->ptr, "x");
|
|
|
|
|
const int y = RNA_int_get(op->ptr, "y");
|
|
|
|
|
const int radius = RNA_int_get(op->ptr, "radius");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
const eSelectOp sel_op = ED_select_op_modal(
|
|
|
|
|
eSelectOp(RNA_enum_get(op->ptr, "mode")),
|
|
|
|
|
WM_gesture_is_modal_first(static_cast<wmGesture *>(op->customdata)));
|
2019-03-05 22:26:45 +11:00
|
|
|
const bool select = (sel_op != SEL_OP_SUB);
|
|
|
|
|
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
2023-03-01 12:32:15 +01:00
|
|
|
ED_clip_select_all(sc, SEL_DESELECT, nullptr);
|
2019-03-05 22:26:45 +11:00
|
|
|
changed = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* compute ellipse and position in unified coordinates */
|
2012-07-26 22:41:40 +00:00
|
|
|
ED_space_clip_get_size(sc, &width, &height);
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_space_clip_get_zoom(sc, region, &zoomx, &zoomy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
ellipse[0] = width * zoomx / radius;
|
|
|
|
|
ellipse[1] = height * zoomy / radius;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_point_stable_pos(sc, region, x, y, &offset[0], &offset[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* do selection */
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2022-10-07 17:26:35 +02:00
|
|
|
if (track->flag & TRACK_HIDDEN) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 17:26:35 +02:00
|
|
|
const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
|
|
|
|
|
|
|
|
|
if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker) &&
|
|
|
|
|
marker_inside_ellipse(marker, offset, ellipse))
|
|
|
|
|
{
|
|
|
|
|
if (select) {
|
|
|
|
|
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2022-10-07 17:26:35 +02:00
|
|
|
changed = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) {
|
2022-10-07 17:26:35 +02:00
|
|
|
if (plane_track->flag & PLANE_TRACK_HIDDEN) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track,
|
|
|
|
|
framenr);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
if (point_inside_ellipse(plane_marker->corners[i], offset, ellipse)) {
|
|
|
|
|
if (select) {
|
|
|
|
|
plane_track->flag |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
plane_track->flag &= ~SELECT;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2022-10-07 17:26:35 +02:00
|
|
|
|
|
|
|
|
changed = true;
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
if (changed) {
|
2022-10-07 11:32:21 +02:00
|
|
|
BKE_tracking_dopesheet_tag_update(&clip->tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, nullptr);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_select_circle(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Circle Select";
|
|
|
|
|
ot->description = "Select markers using circle selection";
|
|
|
|
|
ot->idname = "CLIP_OT_select_circle";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke = WM_gesture_circle_invoke;
|
|
|
|
|
ot->modal = WM_gesture_circle_modal;
|
|
|
|
|
ot->exec = circle_select_exec;
|
|
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
2022-05-17 11:23:04 +02:00
|
|
|
ot->get_name = ED_select_circle_get_name;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* properties */
|
2019-03-05 22:26:45 +11:00
|
|
|
WM_operator_properties_gesture_circle(ot);
|
|
|
|
|
WM_operator_properties_select_operation_simple(ot);
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** select all operator *********************/
|
|
|
|
|
|
|
|
|
|
static int select_all_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2012-06-15 11:40:04 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
|
2021-01-19 14:28:44 +01:00
|
|
|
const int action = RNA_enum_get(op->ptr, "action");
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2021-01-19 14:28:44 +01:00
|
|
|
ClipViewLockState lock_state;
|
|
|
|
|
ED_clip_view_lock_state_store(C, &lock_state);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2021-01-19 14:28:44 +01:00
|
|
|
bool has_selection = false;
|
2019-03-05 18:33:09 +11:00
|
|
|
ED_clip_select_all(sc, action, &has_selection);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
2021-01-27 17:07:48 +01:00
|
|
|
if (has_selection) {
|
2021-01-19 14:28:44 +01:00
|
|
|
ED_clip_view_lock_state_restore_no_jump(C, &lock_state);
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
|
|
|
|
|
BKE_tracking_dopesheet_tag_update(tracking);
|
|
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, nullptr);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
|
2012-06-15 11:40:04 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_select_all(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "(De)select All";
|
|
|
|
|
ot->description = "Change selection of all tracking markers";
|
|
|
|
|
ot->idname = "CLIP_OT_select_all";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = select_all_exec;
|
|
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
WM_operator_properties_select_all(ot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** select grouped operator *********************/
|
|
|
|
|
|
2018-01-08 14:11:43 +01:00
|
|
|
static int select_grouped_exec(bContext *C, wmOperator *op)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2022-10-07 11:32:21 +02:00
|
|
|
const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
|
|
|
|
const int group = RNA_enum_get(op->ptr, "group");
|
|
|
|
|
const int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2013-09-05 13:37:53 +00:00
|
|
|
bool ok = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
if (group == 0) { /* Keyframed */
|
|
|
|
|
ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED) == 0;
|
|
|
|
|
}
|
|
|
|
|
else if (group == 1) { /* Estimated */
|
|
|
|
|
ok = marker->framenr != framenr;
|
|
|
|
|
}
|
|
|
|
|
else if (group == 2) { /* tracked */
|
|
|
|
|
ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED);
|
|
|
|
|
}
|
|
|
|
|
else if (group == 3) { /* locked */
|
|
|
|
|
ok = track->flag & TRACK_LOCKED;
|
|
|
|
|
}
|
|
|
|
|
else if (group == 4) { /* disabled */
|
|
|
|
|
ok = marker->flag & MARKER_DISABLED;
|
|
|
|
|
}
|
|
|
|
|
else if (group == 5) { /* color */
|
2022-10-07 11:32:21 +02:00
|
|
|
const MovieTrackingTrack *act_track = tracking_object->active_track;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
if (act_track) {
|
|
|
|
|
ok = (track->flag & TRACK_CUSTOMCOLOR) == (act_track->flag & TRACK_CUSTOMCOLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ok && track->flag & TRACK_CUSTOMCOLOR) {
|
2012-06-15 11:40:04 +00:00
|
|
|
ok = equals_v3v3(track->color, act_track->color);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (group == 6) { /* failed */
|
|
|
|
|
ok = (track->flag & TRACK_HAS_BUNDLE) == 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
if (ok) {
|
|
|
|
|
track->flag |= SELECT;
|
2019-04-22 09:19:45 +10:00
|
|
|
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
|
2012-06-15 11:40:04 +00:00
|
|
|
track->pat_flag |= SELECT;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
if (sc->flag & SC_SHOW_MARKER_SEARCH) {
|
2012-06-15 11:40:04 +00:00
|
|
|
track->search_flag |= SELECT;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
BKE_tracking_dopesheet_tag_update(&clip->tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_select_grouped(wmOperatorType *ot)
|
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem select_group_items[] = {
|
2020-10-24 11:42:17 -07:00
|
|
|
{0, "KEYFRAMED", 0, "Keyframed Tracks", "Select all keyframed tracks"},
|
|
|
|
|
{1, "ESTIMATED", 0, "Estimated Tracks", "Select all estimated tracks"},
|
|
|
|
|
{2, "TRACKED", 0, "Tracked Tracks", "Select all tracked tracks"},
|
|
|
|
|
{3, "LOCKED", 0, "Locked Tracks", "Select all locked tracks"},
|
|
|
|
|
{4, "DISABLED", 0, "Disabled Tracks", "Select all disabled tracks"},
|
2012-06-15 11:40:04 +00:00
|
|
|
{5,
|
|
|
|
|
"COLOR",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Tracks with Same Color",
|
2012-06-15 11:40:04 +00:00
|
|
|
"Select all tracks with same color as active track"},
|
|
|
|
|
{6, "FAILED", 0, "Failed Tracks", "Select all tracks which failed to be reconstructed"},
|
2023-03-01 12:32:15 +01:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-06-15 11:40:04 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Grouped";
|
|
|
|
|
ot->description = "Select all tracks from specified group";
|
|
|
|
|
ot->idname = "CLIP_OT_select_grouped";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* api callbacks */
|
2018-01-08 14:11:43 +01:00
|
|
|
ot->exec = select_grouped_exec;
|
2012-06-15 11:40:04 +00:00
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-05-01 05:45:41 +10:00
|
|
|
/* properties */
|
2012-06-15 11:40:04 +00:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"group",
|
|
|
|
|
select_group_items,
|
|
|
|
|
TRACK_CLEAR_REMAINED,
|
|
|
|
|
"Action",
|
|
|
|
|
"Clear action to execute");
|
|
|
|
|
}
|