44 if (plane_track ==
NULL) {
69 ot->
name =
"Create Plane Track";
70 ot->
description =
"Create new plane track out of selected point tracks";
71 ot->
idname =
"CLIP_OT_create_plane_track";
97 const float slide_zone[2],
101 const float pixel_co[2] = {co[0] *
width, co[1] *
height},
102 pixel_slide_zone[2] = {slide_zone[0] *
width, slide_zone[1] *
height};
103 return square_f(pixel_co[0] - pixel_slide_zone[0]) +
square_f(pixel_co[1] - pixel_slide_zone[1]);
110 const float distance_clip_squared = 12.0f * 12.0f;
127 float min_distance_squared = FLT_MAX;
131 plane_track = plane_track->next) {
134 for (
int i = 0; i < 4; i++) {
141 min_plane_track = plane_track;
147 if (min_distance_squared < distance_clip_squared / sc->zoom) {
148 if (r_corner !=
NULL) {
149 *r_corner = min_corner;
151 return min_plane_track;
250 float dx, dy, mdelta[2];
251 int next_corner_index, prev_corner_index, diag_corner_index;
252 const float *next_corner, *prev_corner, *diag_corner;
253 float next_edge[2], prev_edge[2], next_diag_edge[2], prev_diag_edge[2];
255 switch (event->
type) {
265 mdelta[0] =
event->mval[0] -
data->previous_mval[0];
266 mdelta[1] =
event->mval[1] -
data->previous_mval[1];
268 dx = mdelta[0] /
data->width / sc->
zoom;
269 dy = mdelta[1] /
data->height / sc->
zoom;
271 if (
data->accurate) {
276 data->corner[0] =
data->previous_corner[0] + dx;
277 data->corner[1] =
data->previous_corner[1] + dy;
295 next_corner_index = (
data->corner_index + 1) % 4;
296 prev_corner_index = (
data->corner_index + 3) % 4;
297 diag_corner_index = (
data->corner_index + 2) % 4;
299 next_corner =
data->plane_marker->corners[next_corner_index];
300 prev_corner =
data->plane_marker->corners[prev_corner_index];
301 diag_corner =
data->plane_marker->corners[diag_corner_index];
305 sub_v2_v2v2(next_diag_edge, prev_corner, diag_corner);
306 sub_v2_v2v2(prev_diag_edge, diag_corner, next_corner);
308 if (
cross_v2v2(prev_edge, next_edge) < 0.0f) {
312 if (
cross_v2v2(next_diag_edge, prev_edge) < 0.0f) {
316 if (
cross_v2v2(next_edge, prev_diag_edge) < 0.0f) {
320 data->previous_mval[0] =
event->mval[0];
321 data->previous_mval[1] =
event->mval[1];
367 ot->
name =
"Slide Plane Marker";
369 ot->
idname =
"CLIP_OT_slide_plane_marker";
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
void BKE_report(ReportList *reports, eReportType type, const char *message)
struct MovieTrackingPlaneMarker * BKE_tracking_plane_marker_ensure(struct MovieTrackingPlaneTrack *plane_track, int framenr)
struct ListBase * BKE_tracking_get_active_tracks(struct MovieTracking *tracking)
#define PLANE_TRACK_VIEW_SELECTED(plane_track)
struct MovieTrackingPlaneTrack * BKE_tracking_plane_track_add(struct MovieTracking *tracking, struct ListBase *plane_tracks_base, struct ListBase *tracks, int framenr)
struct MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get(struct MovieTrackingPlaneTrack *plane_track, int framenr)
void BKE_tracking_track_plane_from_existing_motion(struct MovieTrackingPlaneTrack *plane_track, int start_frame)
void BKE_tracking_tracks_deselect_all(struct ListBase *tracksbase)
struct ListBase * BKE_tracking_get_active_plane_tracks(struct MovieTracking *tracking)
MINLINE float square_f(float a)
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc)
void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height)
void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *region, const int mval[2], float co[2])
bool ED_space_clip_tracking_poll(struct bContext *C)
struct MovieClip * ED_space_clip_get_clip(struct SpaceClip *sc)
_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
Read Guarded memory(de)allocation.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
T distance_squared(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
struct MovieTracking tracking
MovieTrackingPlaneTrack * act_plane_track
MovieTrackingTrack * act_track
MovieTrackingPlaneTrack * plane_track
MovieTrackingPlaneMarker * plane_marker
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void clip_tracking_hide_cursor(struct bContext *C)
void clip_tracking_show_cursor(struct bContext *C)
void CLIP_OT_create_plane_track(wmOperatorType *ot)
static int slide_plane_marker_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void * slide_plane_marker_customdata(bContext *C, const wmEvent *event)
static MovieTrackingPlaneTrack * tracking_plane_marker_check_slide(bContext *C, const wmEvent *event, int *r_corner)
static float mouse_to_plane_slide_zone_distance_squared(const float co[2], const float slide_zone[2], int width, int height)
struct SlidePlaneMarkerData SlidePlaneMarkerData
static int slide_plane_marker_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void slide_plane_marker_update_homographies(SpaceClip *sc, SlidePlaneMarkerData *data)
void CLIP_OT_slide_plane_marker(wmOperatorType *ot)
static int create_plane_track_tracks_exec(bContext *C, wmOperator *op)
static void cancel_mouse_slide_plane_marker(SlidePlaneMarkerData *data)
static void free_slide_plane_marker_data(SlidePlaneMarkerData *data)
int WM_userdef_event_type_from_keymap_type(int kmitype)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)