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 */
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spclip
|
2011-10-29 07:14:31 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-04-29 12:32:26 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2011-10-29 07:14:31 +00: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_matrix.h"
|
2025-02-24 16:08:30 +01:00
|
|
|
#include "BLI_math_vector.h"
|
2021-01-19 14:28:44 +01:00
|
|
|
#include "BLI_rect.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2013-10-26 13:22:38 +00:00
|
|
|
#include "BKE_animsys.h"
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2021-01-19 14:28:44 +01:00
|
|
|
#include "BKE_mask.h"
|
2011-10-29 07:14:31 +00:00
|
|
|
#include "BKE_movieclip.h"
|
|
|
|
|
#include "BKE_tracking.h"
|
2017-06-08 10:14:53 +02:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
|
|
|
|
#include "DEG_depsgraph_build.hh"
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_immediate.hh"
|
|
|
|
|
#include "GPU_state.hh"
|
2012-04-29 12:32:26 +00:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_clip.hh"
|
|
|
|
|
#include "ED_mask.hh"
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_resources.hh"
|
|
|
|
|
#include "UI_view2d.hh"
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2024-03-26 20:34:48 -04:00
|
|
|
#include "clip_intern.hh" /* own include */
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2019-07-28 17:03:03 +02:00
|
|
|
bool clip_graph_value_visible(SpaceClip *sc, eClipCurveValueSource value_source)
|
|
|
|
|
{
|
|
|
|
|
if (ELEM(value_source, CLIP_VALUE_SOURCE_SPEED_X, CLIP_VALUE_SOURCE_SPEED_Y)) {
|
|
|
|
|
if ((sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (value_source == CLIP_VALUE_SOURCE_REPROJECTION_ERROR) {
|
|
|
|
|
if ((sc->flag & SC_SHOW_GRAPH_TRACKS_ERROR) == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void clip_graph_tracking_values_iterate_track_speed_values(
|
|
|
|
|
SpaceClip *sc,
|
|
|
|
|
MovieTrackingTrack *track,
|
|
|
|
|
void *userdata,
|
|
|
|
|
ClipTrackValueCallback func,
|
|
|
|
|
ClipTrackValueSegmentStartCallback segment_start,
|
|
|
|
|
ClipTrackValueSegmentEndCallback segment_end)
|
2011-10-29 07:14:31 +00:00
|
|
|
{
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2017-04-04 19:36:07 -04:00
|
|
|
int width, height, coord;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-29 07:14:31 +00:00
|
|
|
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-04 19:36:07 -04:00
|
|
|
for (coord = 0; coord < 2; coord++) {
|
2019-07-28 15:55:02 +02:00
|
|
|
eClipCurveValueSource value_source = (coord == 0) ? CLIP_VALUE_SOURCE_SPEED_X :
|
|
|
|
|
CLIP_VALUE_SOURCE_SPEED_Y;
|
2017-04-10 16:16:12 +02:00
|
|
|
int i, prevfra = track->markers[0].framenr;
|
2013-09-05 13:37:53 +00:00
|
|
|
bool open = false;
|
2012-03-25 23:19:21 +00:00
|
|
|
float prevval = 0.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-04 19:36:07 -04:00
|
|
|
for (i = 0; i < track->markersnr; i++) {
|
2012-03-25 23:19:21 +00:00
|
|
|
MovieTrackingMarker *marker = &track->markers[i];
|
2017-04-04 19:36:07 -04:00
|
|
|
float val;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
if (marker->flag & MARKER_DISABLED) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (open) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (segment_end) {
|
2019-07-28 15:55:02 +02:00
|
|
|
segment_end(userdata, value_source);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-05 13:37:53 +00:00
|
|
|
open = false;
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-29 07:14:31 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!open) {
|
2017-02-23 13:35:16 -03:00
|
|
|
if (segment_start) {
|
|
|
|
|
if ((i + 1) == track->markersnr) {
|
2019-07-28 15:55:02 +02:00
|
|
|
segment_start(userdata, track, value_source, true);
|
2017-02-23 13:35:16 -03:00
|
|
|
}
|
|
|
|
|
else {
|
2019-07-28 15:55:02 +02:00
|
|
|
segment_start(
|
|
|
|
|
userdata, track, value_source, (track->markers[i + 1].flag & MARKER_DISABLED));
|
2017-02-23 13:35:16 -03:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-05 13:37:53 +00:00
|
|
|
open = true;
|
2012-03-25 23:19:21 +00:00
|
|
|
prevval = marker->pos[coord];
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-29 07:14:31 +00:00
|
|
|
/* value is a pixels per frame speed */
|
2017-04-04 19:36:07 -04:00
|
|
|
val = (marker->pos[coord] - prevval) * ((coord == 0) ? (width) : (height));
|
2012-03-25 23:19:21 +00:00
|
|
|
val /= marker->framenr - prevfra;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 17:09:35 +00:00
|
|
|
if (func) {
|
|
|
|
|
int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-07-28 15:55:02 +02:00
|
|
|
func(userdata, track, marker, value_source, scene_framenr, val);
|
2012-06-10 17:09:35 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
prevval = marker->pos[coord];
|
|
|
|
|
prevfra = marker->framenr;
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (open) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (segment_end) {
|
2019-07-28 15:55:02 +02:00
|
|
|
segment_end(userdata, value_source);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-07-28 17:03:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float calculate_reprojection_error_at_marker(MovieClip *clip,
|
|
|
|
|
MovieTracking *tracking,
|
|
|
|
|
MovieTrackingObject *tracking_object,
|
|
|
|
|
MovieTrackingTrack *track,
|
|
|
|
|
MovieTrackingMarker *marker,
|
|
|
|
|
const int clip_width,
|
|
|
|
|
const int clip_height,
|
|
|
|
|
const int scene_framenr)
|
|
|
|
|
{
|
|
|
|
|
float reprojected_position[4], bundle_position[4], marker_position[2], delta[2];
|
|
|
|
|
float weight = BKE_tracking_track_get_weight_for_marker(clip, track, marker);
|
|
|
|
|
const float aspy = 1.0f / tracking->camera.pixel_aspect;
|
|
|
|
|
|
|
|
|
|
float projection_matrix[4][4];
|
|
|
|
|
BKE_tracking_get_projection_matrix(
|
|
|
|
|
tracking, tracking_object, scene_framenr, clip_width, clip_height, projection_matrix);
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(bundle_position, track->bundle_pos);
|
|
|
|
|
bundle_position[3] = 1;
|
|
|
|
|
|
|
|
|
|
mul_v4_m4v4(reprojected_position, projection_matrix, bundle_position);
|
|
|
|
|
reprojected_position[0] = (reprojected_position[0] / (reprojected_position[3] * 2.0f) + 0.5f) *
|
|
|
|
|
clip_width;
|
|
|
|
|
reprojected_position[1] = (reprojected_position[1] / (reprojected_position[3] * 2.0f) + 0.5f) *
|
|
|
|
|
clip_height * aspy;
|
|
|
|
|
|
2020-04-17 16:51:00 +02:00
|
|
|
BKE_tracking_distort_v2(
|
|
|
|
|
tracking, clip_width, clip_height, reprojected_position, reprojected_position);
|
2019-07-28 17:03:03 +02:00
|
|
|
|
|
|
|
|
marker_position[0] = (marker->pos[0] + track->offset[0]) * clip_width;
|
|
|
|
|
marker_position[1] = (marker->pos[1] + track->offset[1]) * clip_height * aspy;
|
|
|
|
|
|
|
|
|
|
sub_v2_v2v2(delta, reprojected_position, marker_position);
|
|
|
|
|
return len_v2(delta) * weight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void clip_graph_tracking_values_iterate_track_reprojection_error_values(
|
|
|
|
|
SpaceClip *sc,
|
|
|
|
|
MovieTrackingTrack *track,
|
|
|
|
|
void *userdata,
|
|
|
|
|
ClipTrackValueCallback func,
|
|
|
|
|
ClipTrackValueSegmentStartCallback segment_start,
|
|
|
|
|
ClipTrackValueSegmentEndCallback segment_end)
|
|
|
|
|
{
|
|
|
|
|
/* Tracks without bundle can not have any reprojection error curve. */
|
|
|
|
|
if ((track->flag & TRACK_HAS_BUNDLE) == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
|
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
|
|
|
|
|
|
|
|
|
|
int clip_width, clip_height;
|
|
|
|
|
BKE_movieclip_get_size(clip, &sc->user, &clip_width, &clip_height);
|
|
|
|
|
|
|
|
|
|
/* Iterate over segments. */
|
|
|
|
|
bool is_segment_open = false;
|
|
|
|
|
for (int marker_index = 0; marker_index < track->markersnr; marker_index++) {
|
|
|
|
|
MovieTrackingMarker *marker = &track->markers[marker_index];
|
|
|
|
|
|
|
|
|
|
/* End of tracked segment, no reprojection error can be calculated here since the ground truth
|
|
|
|
|
* 2D position is not known. */
|
|
|
|
|
if (marker->flag & MARKER_DISABLED) {
|
|
|
|
|
if (is_segment_open) {
|
2023-03-01 12:32:15 +01:00
|
|
|
if (segment_end != nullptr) {
|
2019-07-28 17:03:03 +02:00
|
|
|
segment_end(userdata, CLIP_VALUE_SOURCE_REPROJECTION_ERROR);
|
|
|
|
|
}
|
|
|
|
|
is_segment_open = false;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Begin new segment if it is not open yet. */
|
|
|
|
|
if (!is_segment_open) {
|
2023-03-01 12:32:15 +01:00
|
|
|
if (segment_start != nullptr) {
|
2019-07-28 17:03:03 +02:00
|
|
|
if ((marker_index + 1) == track->markersnr) {
|
|
|
|
|
segment_start(userdata, track, CLIP_VALUE_SOURCE_REPROJECTION_ERROR, true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
segment_start(userdata,
|
|
|
|
|
track,
|
|
|
|
|
CLIP_VALUE_SOURCE_REPROJECTION_ERROR,
|
|
|
|
|
(track->markers[marker_index + 1].flag & MARKER_DISABLED));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
is_segment_open = true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
if (func != nullptr) {
|
2019-07-28 17:03:03 +02:00
|
|
|
const int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
|
|
|
|
|
const float reprojection_error = calculate_reprojection_error_at_marker(
|
|
|
|
|
clip, tracking, tracking_object, track, marker, clip_width, clip_height, scene_framenr);
|
|
|
|
|
func(userdata,
|
|
|
|
|
track,
|
|
|
|
|
marker,
|
|
|
|
|
CLIP_VALUE_SOURCE_REPROJECTION_ERROR,
|
|
|
|
|
scene_framenr,
|
|
|
|
|
reprojection_error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
if (is_segment_open && segment_end != nullptr) {
|
2019-07-28 17:03:03 +02:00
|
|
|
segment_end(userdata, CLIP_VALUE_SOURCE_REPROJECTION_ERROR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clip_graph_tracking_values_iterate_track(SpaceClip *sc,
|
|
|
|
|
MovieTrackingTrack *track,
|
|
|
|
|
void *userdata,
|
|
|
|
|
ClipTrackValueCallback func,
|
|
|
|
|
ClipTrackValueSegmentStartCallback segment_start,
|
|
|
|
|
ClipTrackValueSegmentEndCallback segment_end)
|
|
|
|
|
{
|
|
|
|
|
clip_graph_tracking_values_iterate_track_speed_values(
|
|
|
|
|
sc, track, userdata, func, segment_start, segment_end);
|
|
|
|
|
|
|
|
|
|
clip_graph_tracking_values_iterate_track_reprojection_error_values(
|
|
|
|
|
sc, track, userdata, func, segment_start, segment_end);
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-28 15:55:02 +02:00
|
|
|
void clip_graph_tracking_values_iterate(SpaceClip *sc,
|
|
|
|
|
bool selected_only,
|
|
|
|
|
bool include_hidden,
|
|
|
|
|
void *userdata,
|
|
|
|
|
ClipTrackValueCallback func,
|
|
|
|
|
ClipTrackValueSegmentStartCallback segment_start,
|
|
|
|
|
ClipTrackValueSegmentEndCallback segment_end)
|
2011-10-29 07:14:31 +00: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);
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) {
|
2012-06-12 17:11:16 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-06-12 17:11:16 +00:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (selected_only && !TRACK_SELECTED(track)) {
|
2012-06-12 17:11:16 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2012-06-12 17:11:16 +00:00
|
|
|
clip_graph_tracking_values_iterate_track(
|
|
|
|
|
sc, track, userdata, func, segment_start, segment_end);
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-15 15:21:28 +00:00
|
|
|
void clip_graph_tracking_iterate(SpaceClip *sc,
|
|
|
|
|
bool selected_only,
|
|
|
|
|
bool include_hidden,
|
|
|
|
|
void *userdata,
|
2012-06-10 19:59:02 +00:00
|
|
|
void (*func)(void *userdata, MovieTrackingMarker *marker))
|
2011-10-29 07:14:31 +00: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);
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) {
|
2012-06-12 17:11:16 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (selected_only && !TRACK_SELECTED(track)) {
|
2012-06-12 17:11:16 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2020-09-09 18:41:07 +02:00
|
|
|
for (int i = 0; i < track->markersnr; i++) {
|
2012-06-12 17:11:16 +00:00
|
|
|
MovieTrackingMarker *marker = &track->markers[i];
|
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (marker->flag & MARKER_DISABLED) {
|
2012-06-12 17:11:16 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (func) {
|
2012-06-12 17:11:16 +00:00
|
|
|
func(userdata, marker);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-06-12 17:11:16 +00:00
|
|
|
}
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track)
|
2011-10-29 07:14:31 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2022-10-04 17:39:57 +02:00
|
|
|
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
|
Rework 2D stabilizator
See this page for motivation and description of concepts:
https://github.com/Ichthyostega/blender/wiki
See this video for UI explanation and demonstration of usage
http://vimeo.com/blenderHack/stabilizerdemo
This proposal attempts to improve usability of Blender's image stabilization
feature for real-world footage esp. with moving and panning camera. It builds
upon the feature tracking to get a measurement of 2D image movement.
- Use a weighted average of movement contributions (instead of a median).
- Allow for rotation compensation and zoom (image scale) compensation.
- Allow to pick a different set of tracks for translation and for
rotation/zoom.
- Treat translation / rotation / zoom contributions systematically in a
similar way.
- Improve handling of partial tracking data with gaps and varying
start / end points.
- Have a user definable anchor frame and interpolate / extrapolate data to
avoid jumping back to "neutral" position when no tracking data is available.
- Support for travelling and panning shots by including an //intended//
position/rotation/zoom ("target position"). The idea is for these parameters
to be //animated// by the user, in order to supply an smooth, intended
camera movement. This way, we can keep the image content roughly in frame
even when moving completely away from the initial view.
A known shortcoming is that the pivot point for rotation compensation is set to
the translation compensated image center. This can produce spurious rotation on
travelling shots, which needs to be compensated manually (by animating the
target rotation parameter). There are several possible ways to address that
problem, yet all of them are considered beyond the scope of this improvement
proposal for now.
Own modifications:
- Restrict line length, it's really handy for split-view editing
- In motion tracking we prefer fully human-readable comments, meaning we
don't use doxygen with it's weird markup and comments are supposed to
start with capital and end with a full stop,
- Add explicit comparison of pointer to NULL.
Reviewers: sergey
Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung
Maniphest Tasks: T49036
Differential Revision: https://developer.blender.org/D583
2016-08-16 10:32:55 +02:00
|
|
|
bool has_bundle = false;
|
2017-12-19 12:52:20 +01:00
|
|
|
const bool used_for_stabilization = (track->flag &
|
|
|
|
|
(TRACK_USE_2D_STAB | TRACK_USE_2D_STAB_ROT)) != 0;
|
2022-10-04 17:39:57 +02:00
|
|
|
if (track == tracking_object->active_track) {
|
2023-03-01 12:32:15 +01:00
|
|
|
tracking_object->active_track = nullptr;
|
2017-12-19 12:51:45 +01:00
|
|
|
}
|
|
|
|
|
/* Handle reconstruction display in 3d viewport. */
|
|
|
|
|
if (track->flag & TRACK_HAS_BUNDLE) {
|
2013-09-05 13:37:53 +00:00
|
|
|
has_bundle = true;
|
2017-12-19 12:51:45 +01:00
|
|
|
}
|
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
|
|
|
/* Make sure no plane will use freed track */
|
2015-04-22 01:54:45 +05:00
|
|
|
BKE_tracking_plane_tracks_remove_point_track(tracking, track);
|
2013-10-26 13:22:38 +00:00
|
|
|
/* Delete f-curves associated with the track (such as weight, i.e.) */
|
2017-12-19 12:51:45 +01:00
|
|
|
/* Escaped object name, escaped track name, rest of the path. */
|
|
|
|
|
char rna_path[MAX_NAME * 4 + 64];
|
|
|
|
|
BKE_tracking_get_rna_path_for_track(tracking, track, rna_path, sizeof(rna_path));
|
2018-11-23 16:46:19 +01:00
|
|
|
if (BKE_animdata_fix_paths_remove(&clip->id, rna_path)) {
|
|
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
|
|
|
|
}
|
2017-12-19 12:58:42 +01:00
|
|
|
/* Delete track itself. */
|
2012-06-15 11:03:23 +00:00
|
|
|
BKE_tracking_track_free(track);
|
2022-10-04 17:39:57 +02:00
|
|
|
BLI_freelinkN(&tracking_object->tracks, track);
|
2017-12-19 12:51:45 +01:00
|
|
|
/* Send notifiers. */
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
|
2017-04-10 16:01:58 +02:00
|
|
|
if (used_for_stabilization) {
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
2017-12-19 13:42:01 +01:00
|
|
|
/* Inform dependency graph. */
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&clip->id, 0);
|
2017-12-19 12:51:45 +01:00
|
|
|
if (has_bundle) {
|
2023-03-01 12:32:15 +01:00
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr);
|
2017-12-19 12:51:45 +01:00
|
|
|
}
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
void clip_delete_marker(bContext *C,
|
|
|
|
|
MovieClip *clip,
|
|
|
|
|
MovieTrackingTrack *track,
|
|
|
|
|
MovieTrackingMarker *marker)
|
2011-10-29 07:14:31 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
if (track->markersnr == 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
|
|
|
clip_delete_track(C, clip, track);
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-06-15 11:03:23 +00:00
|
|
|
BKE_tracking_marker_delete(track, marker->framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 12:58:42 +01:00
|
|
|
void clip_delete_plane_track(bContext *C, MovieClip *clip, MovieTrackingPlaneTrack *plane_track)
|
|
|
|
|
{
|
|
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2022-10-07 11:32:21 +02:00
|
|
|
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
2022-12-01 10:10:33 +01:00
|
|
|
|
|
|
|
|
if (plane_track == tracking_object->active_plane_track) {
|
2023-03-01 12:32:15 +01:00
|
|
|
tracking_object->active_plane_track = nullptr;
|
2022-12-01 10:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-19 12:58:42 +01:00
|
|
|
/* Delete f-curves associated with the track (such as weight, i.e.) */
|
|
|
|
|
/* Escaped object name, escaped track name, rest of the path. */
|
|
|
|
|
char rna_path[MAX_NAME * 4 + 64];
|
|
|
|
|
BKE_tracking_get_rna_path_for_plane_track(tracking, plane_track, rna_path, sizeof(rna_path));
|
2018-11-23 16:46:19 +01:00
|
|
|
if (BKE_animdata_fix_paths_remove(&clip->id, rna_path)) {
|
|
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
|
|
|
|
}
|
2017-12-19 12:58:42 +01:00
|
|
|
/* Delete the plane track itself. */
|
|
|
|
|
BKE_tracking_plane_track_free(plane_track);
|
2022-10-07 11:32:21 +02:00
|
|
|
BLI_freelinkN(&tracking_object->plane_tracks, plane_track);
|
2017-12-19 12:58:42 +01:00
|
|
|
/* TODO(sergey): Any notifiers to be sent here? */
|
|
|
|
|
(void)C;
|
|
|
|
|
/* Inform dependency graph. */
|
2017-12-19 13:42:01 +01:00
|
|
|
DEG_id_tag_update(&clip->id, 0);
|
2017-12-19 12:58:42 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 14:28:44 +01:00
|
|
|
void clip_view_offset_for_center_to_point(
|
|
|
|
|
SpaceClip *sc, const float x, const float y, float *r_offset_x, float *r_offset_y)
|
2011-10-29 07:14:31 +00:00
|
|
|
{
|
|
|
|
|
int width, height;
|
2021-01-19 14:28:44 +01:00
|
|
|
ED_space_clip_get_size(sc, &width, &height);
|
|
|
|
|
|
2011-10-29 07:14:31 +00:00
|
|
|
float aspx, aspy;
|
2021-01-19 14:28:44 +01:00
|
|
|
ED_space_clip_get_aspect(sc, &aspx, &aspy);
|
|
|
|
|
|
|
|
|
|
*r_offset_x = (x - 0.5f) * width * aspx;
|
|
|
|
|
*r_offset_y = (y - 0.5f) * height * aspy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clip_view_center_to_point(SpaceClip *sc, float x, float y)
|
|
|
|
|
{
|
|
|
|
|
clip_view_offset_for_center_to_point(sc, x, y, &sc->xof, &sc->yof);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool selected_tracking_boundbox(SpaceClip *sc, float min[2], float max[2])
|
|
|
|
|
{
|
|
|
|
|
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 framenr = ED_space_clip_get_clip_frame_number(sc);
|
2021-01-19 14:28:44 +01:00
|
|
|
int width, height;
|
|
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
|
|
INIT_MINMAX2(min, max);
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2012-07-26 22:41:40 +00:00
|
|
|
ED_space_clip_get_size(sc, &width, &height);
|
2011-10-29 07:14:31 +00:00
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2021-01-19 14:28:44 +01:00
|
|
|
if (TRACK_VIEW_SELECTED(sc, track)) {
|
|
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
|
|
|
|
|
|
|
|
|
if (marker) {
|
|
|
|
|
float pos[3];
|
|
|
|
|
|
|
|
|
|
pos[0] = marker->pos[0] + track->offset[0];
|
|
|
|
|
pos[1] = marker->pos[1] + track->offset[1];
|
|
|
|
|
pos[2] = 0.0f;
|
|
|
|
|
|
|
|
|
|
/* undistortion happens for normalized coords */
|
|
|
|
|
if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
|
|
|
|
|
/* undistortion happens for normalized coords */
|
|
|
|
|
ED_clip_point_undistorted_pos(sc, pos, pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos[0] *= width;
|
|
|
|
|
pos[1] *= height;
|
|
|
|
|
|
|
|
|
|
mul_v3_m4v3(pos, sc->stabmat, pos);
|
|
|
|
|
|
|
|
|
|
minmax_v2v2_v2(min, max, pos);
|
|
|
|
|
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-27 17:07:48 +01:00
|
|
|
static bool tracking_has_selection(SpaceClip *space_clip)
|
|
|
|
|
{
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(space_clip);
|
2022-10-07 11:32:21 +02:00
|
|
|
const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
2021-01-27 17:07:48 +01:00
|
|
|
const int framenr = ED_space_clip_get_clip_frame_number(space_clip);
|
|
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2021-01-27 17:07:48 +01:00
|
|
|
if (!TRACK_VIEW_SELECTED(space_clip, track)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
2023-03-01 12:32:15 +01:00
|
|
|
if (marker != nullptr) {
|
2021-01-27 17:07:48 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 11:11:33 +01:00
|
|
|
static bool mask_has_selection(const bContext *C)
|
2021-01-27 17:07:48 +01:00
|
|
|
{
|
|
|
|
|
Mask *mask = CTX_data_edit_mask(C);
|
2023-03-01 12:32:15 +01:00
|
|
|
if (mask == nullptr) {
|
2021-01-27 17:07:48 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
|
2021-08-04 17:46:55 +02:00
|
|
|
if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
|
2021-01-27 17:07:48 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
|
|
|
|
|
for (int i = 0; i < spline->tot_point; i++) {
|
|
|
|
|
const MaskSplinePoint *point = &spline->points[i];
|
|
|
|
|
const BezTriple *bezt = &point->bezt;
|
|
|
|
|
if (!MASKPOINT_ISSEL_ANY(point)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bezt->f2 & SELECT) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 11:11:33 +01:00
|
|
|
if (BKE_mask_point_handles_mode_get(point) == MASK_HANDLE_MODE_STICK) {
|
2021-01-27 17:07:48 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2021-02-15 15:30:17 +01:00
|
|
|
|
|
|
|
|
if ((bezt->f1 & SELECT) && (bezt->h1 != HD_VECT)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if ((bezt->f3 & SELECT) && (bezt->h2 != HD_VECT)) {
|
|
|
|
|
return true;
|
2021-01-27 17:07:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 11:11:33 +01:00
|
|
|
static bool selected_boundbox(const bContext *C,
|
|
|
|
|
float min[2],
|
|
|
|
|
float max[2],
|
|
|
|
|
bool handles_as_control_point)
|
2021-01-19 14:28:44 +01:00
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
|
|
|
|
if (sc->mode == SC_MODE_TRACKING) {
|
|
|
|
|
return selected_tracking_boundbox(sc, min, max);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 11:11:33 +01:00
|
|
|
if (ED_mask_selected_minmax(C, min, max, handles_as_control_point)) {
|
2021-01-19 14:28:44 +01:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
|
|
|
|
int width, height;
|
|
|
|
|
ED_space_clip_get_size(sc, &width, &height);
|
|
|
|
|
BKE_mask_coord_to_movieclip(clip, &sc->user, min, min);
|
|
|
|
|
BKE_mask_coord_to_movieclip(clip, &sc->user, max, max);
|
|
|
|
|
min[0] *= width;
|
|
|
|
|
min[1] *= height;
|
|
|
|
|
max[0] *= width;
|
|
|
|
|
max[1] *= height;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool clip_view_calculate_view_selection(
|
|
|
|
|
const bContext *C, bool fit, float *r_offset_x, float *r_offset_y, float *r_zoom)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
|
|
|
|
|
|
|
|
|
int frame_width, frame_height;
|
|
|
|
|
ED_space_clip_get_size(sc, &frame_width, &frame_height);
|
|
|
|
|
|
2023-03-01 12:32:15 +01:00
|
|
|
if ((frame_width == 0) || (frame_height == 0) || (sc->clip == nullptr)) {
|
2021-01-19 14:28:44 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-27 15:23:46 +11:00
|
|
|
/* NOTE: The `fit` argument is set to truth when doing "View to Selected" operator, and it set to
|
2021-01-19 14:28:44 +01:00
|
|
|
* false when this function is used for Lock-to-Selection functionality. When locking to
|
2021-02-08 11:11:33 +01:00
|
|
|
* selection the handles are to use control point position. So we can derive the
|
|
|
|
|
* `handles_as_control_point` from `fit`.
|
2021-01-19 14:28:44 +01:00
|
|
|
*
|
2021-01-27 15:23:46 +11:00
|
|
|
* TODO(sergey): Make such decision more explicit. Maybe pass use-case for the calculation to
|
|
|
|
|
* tell operator from lock-to-selection apart. */
|
2021-01-19 14:28:44 +01:00
|
|
|
float min[2], max[2];
|
2021-02-08 11:11:33 +01:00
|
|
|
if (!selected_boundbox(C, min, max, !fit)) {
|
2021-01-19 14:28:44 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* center view */
|
|
|
|
|
clip_view_offset_for_center_to_point(sc,
|
|
|
|
|
(max[0] + min[0]) / (2 * frame_width),
|
|
|
|
|
(max[1] + min[1]) / (2 * frame_height),
|
|
|
|
|
r_offset_x,
|
|
|
|
|
r_offset_y);
|
|
|
|
|
|
|
|
|
|
const int w = max[0] - min[0];
|
|
|
|
|
const int h = max[1] - min[1];
|
|
|
|
|
|
|
|
|
|
/* set zoom to see all selection */
|
|
|
|
|
*r_zoom = sc->zoom;
|
|
|
|
|
if (w > 0 && h > 0) {
|
|
|
|
|
ARegion *region = CTX_wm_region(C);
|
|
|
|
|
|
|
|
|
|
int width, height;
|
|
|
|
|
float zoomx, zoomy, newzoom, aspx, aspy;
|
|
|
|
|
|
|
|
|
|
ED_space_clip_get_aspect(sc, &aspx, &aspy);
|
|
|
|
|
|
|
|
|
|
width = BLI_rcti_size_x(®ion->winrct) + 1;
|
|
|
|
|
height = BLI_rcti_size_y(®ion->winrct) + 1;
|
|
|
|
|
|
2023-03-03 23:27:50 +11:00
|
|
|
zoomx = float(width) / w / aspx;
|
|
|
|
|
zoomy = float(height) / h / aspy;
|
2021-01-19 14:28:44 +01:00
|
|
|
|
|
|
|
|
newzoom = 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy));
|
|
|
|
|
|
|
|
|
|
if (fit) {
|
|
|
|
|
*r_zoom = newzoom;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2011-10-29 07:14:31 +00:00
|
|
|
}
|
2012-04-29 12:32:26 +00:00
|
|
|
|
2021-01-27 17:07:48 +01:00
|
|
|
bool clip_view_has_locked_selection(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
|
|
|
|
|
|
|
|
|
if ((space_clip->flag & SC_LOCK_SELECTION) == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (space_clip->mode == SC_MODE_TRACKING) {
|
|
|
|
|
return tracking_has_selection(space_clip);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 11:11:33 +01:00
|
|
|
return mask_has_selection(C);
|
2021-01-27 17:07:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-29 12:32:26 +00:00
|
|
|
void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
|
|
|
|
|
{
|
|
|
|
|
UI_view2d_view_ortho(v2d);
|
|
|
|
|
|
|
|
|
|
/* currently clip editor supposes that editing clip length is equal to scene frame range */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2012-04-29 12:32:26 +00:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2022-09-01 09:31:07 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
2017-02-11 00:59:43 -05:00
|
|
|
|
|
|
|
|
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
|
2023-03-03 23:27:50 +11:00
|
|
|
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, float(scene->r.sfra), v2d->cur.ymax);
|
|
|
|
|
immRectf(pos, float(scene->r.efra), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
|
2017-02-11 00:59:43 -05:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2012-04-29 12:32:26 +00:00
|
|
|
|
2017-02-11 00:59:43 -05:00
|
|
|
immUniformThemeColorShade(TH_BACK, -60);
|
2012-04-29 12:32:26 +00:00
|
|
|
|
|
|
|
|
/* thin lines where the actual frames are */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2017-02-11 00:59:43 -05:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2023-03-03 23:27:50 +11:00
|
|
|
immVertex2f(pos, float(scene->r.sfra), v2d->cur.ymin);
|
|
|
|
|
immVertex2f(pos, float(scene->r.sfra), v2d->cur.ymax);
|
|
|
|
|
immVertex2f(pos, float(scene->r.efra), v2d->cur.ymin);
|
|
|
|
|
immVertex2f(pos, float(scene->r.efra), v2d->cur.ymax);
|
2017-02-11 00:59:43 -05:00
|
|
|
immEnd();
|
|
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2012-04-29 12:32:26 +00:00
|
|
|
}
|