Blender  V3.3
COM_PlaneTrackOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2013 Blender Foundation. */
3 
5 
6 #include "DNA_defaults.h"
7 
8 #include "BKE_movieclip.h"
9 #include "BKE_tracking.h"
10 
11 namespace blender::compositor {
12 
13 /* ******** PlaneTrackCommon ******** */
14 
16 {
17  movie_clip_ = nullptr;
18  framenumber_ = 0;
19  tracking_object_name_[0] = '\0';
20  plane_track_name_[0] = '\0';
21 }
22 
24 {
25  float corners[4][2];
26  if (distort_op->motion_blur_samples_ == 1) {
27  read_corners_from_track(corners, framenumber_);
28  distort_op->calculate_corners(corners, true, 0);
29  }
30  else {
31  const float frame = (float)framenumber_ - distort_op->motion_blur_shutter_;
32  const float frame_step = (distort_op->motion_blur_shutter_ * 2.0f) /
33  distort_op->motion_blur_samples_;
34  float frame_iter = frame;
35  for (int sample = 0; sample < distort_op->motion_blur_samples_; sample++) {
36  read_corners_from_track(corners, frame_iter);
37  distort_op->calculate_corners(corners, true, sample);
38  frame_iter += frame_step;
39  }
40  }
41 }
42 
43 void PlaneTrackCommon::read_corners_from_track(float corners[4][2], float frame)
44 {
45  MovieTracking *tracking;
46  MovieTrackingObject *object;
47 
48  if (!movie_clip_) {
49  return;
50  }
51 
52  tracking = &movie_clip_->tracking;
53 
55  if (object) {
56  MovieTrackingPlaneTrack *plane_track;
57  plane_track = BKE_tracking_plane_track_get_named(tracking, object, plane_track_name_);
58  if (plane_track) {
59  float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movie_clip_, frame);
60  BKE_tracking_plane_marker_get_subframe_corners(plane_track, clip_framenr, corners);
61  }
62  }
63 }
64 
65 void PlaneTrackCommon::determine_canvas(const rcti &preferred_area, rcti &r_area)
66 {
67  r_area = COM_AREA_NONE;
68  if (movie_clip_) {
69  int width, height;
73  r_area = preferred_area;
74  r_area.xmax = r_area.xmin + width;
75  r_area.ymax = r_area.ymin + height;
76  }
77 }
78 
79 /* ******** PlaneTrackMaskOperation ******** */
80 
82 {
86  }
87 }
88 
89 /* TODO(manzanilla): to be removed with tiled implementation. */
91 {
95  }
96 }
97 
98 /* ******** PlaneTrackWarpImageOperation ******** */
99 
101 {
105  }
106 }
107 
108 /* TODO(manzanilla): to be removed with tiled implementation. */
110 {
114  }
115 }
116 
117 } // namespace blender::compositor
typedef float(TangentPoint)[2]
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
Definition: movieclip.c:1614
void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height)
Definition: movieclip.c:1520
struct MovieTrackingPlaneTrack * BKE_tracking_plane_track_get_named(struct MovieTracking *tracking, struct MovieTrackingObject *object, const char *name)
Definition: tracking.c:1703
struct MovieTrackingObject * BKE_tracking_object_get_named(struct MovieTracking *tracking, const char *name)
Definition: tracking.c:2077
void BKE_tracking_plane_marker_get_subframe_corners(struct MovieTrackingPlaneTrack *plane_track, float framenr, float corners[4][2])
Definition: tracking.c:1967
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
virtual void calculate_corners(const float corners[4][2], bool normalized, int sample)
void determine_canvas(const rcti &preferred_area, rcti &r_area)
void read_and_calculate_corners(PlaneDistortBaseOperation *distort_op)
static void sample(SocketReader *reader, int x, int y, float color[4])
constexpr rcti COM_AREA_NONE
Definition: COM_defines.h:112
struct MovieTracking tracking
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63