Code style cleaup for motion-tracking modules.
Should be no functional changes.
This commit is contained in:
@@ -61,7 +61,7 @@ void BKE_movieclip_update_scopes(struct MovieClip *clip, struct MovieClipUser *u
|
||||
void BKE_movieclip_get_cache_segments(struct MovieClip *clip, struct MovieClipUser *user, int *totseg_r, int **points_r);
|
||||
|
||||
void BKE_movieclip_build_proxy_frame(struct MovieClip *clip, int clip_flag, struct MovieDistortion *distortion,
|
||||
int cfra, int *build_sizes, int build_count, int undistorted);
|
||||
int cfra, int *build_sizes, int build_count, int undistorted);
|
||||
|
||||
/* cacheing flags */
|
||||
#define MOVIECLIP_CACHE_SKIP (1<<0)
|
||||
|
@@ -52,9 +52,9 @@ void BKE_tracking_clamp_track(struct MovieTrackingTrack *track, int event);
|
||||
void BKE_tracking_track_flag(struct MovieTrackingTrack *track, int area, int flag, int clear);
|
||||
|
||||
struct MovieTrackingTrack *BKE_tracking_add_track(struct MovieTracking *tracking, struct ListBase *tracksbase,
|
||||
float x, float y, int framenr, int width, int height);
|
||||
float x, float y, int framenr, int width, int height);
|
||||
struct MovieTrackingMarker *BKE_tracking_insert_marker(struct MovieTrackingTrack *track,
|
||||
struct MovieTrackingMarker *marker);
|
||||
struct MovieTrackingMarker *marker);
|
||||
void BKE_tracking_delete_marker(struct MovieTrackingTrack *track, int framenr);
|
||||
|
||||
struct MovieTrackingMarker *BKE_tracking_get_marker(struct MovieTrackingTrack *track, int framenr);
|
||||
@@ -71,9 +71,11 @@ void BKE_tracking_join_tracks(struct MovieTrackingTrack *dst_track, struct Movie
|
||||
void BKE_tracking_free(struct MovieTracking *tracking);
|
||||
|
||||
struct ImBuf *BKE_tracking_get_pattern_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
|
||||
struct MovieTrackingMarker *marker, int margin, int anchored, float pos[2], int origin[2]);
|
||||
struct MovieTrackingMarker *marker, int margin, int anchored,
|
||||
float pos[2], int origin[2]);
|
||||
struct ImBuf *BKE_tracking_get_search_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
|
||||
struct MovieTrackingMarker *marker, int margin, int anchored, float pos[2], int origin[2]);
|
||||
struct MovieTrackingMarker *marker, int margin, int anchored,
|
||||
float pos[2], int origin[2]);
|
||||
|
||||
void BKE_track_unique_name(struct ListBase *tracksbase, struct MovieTrackingTrack *track);
|
||||
|
||||
@@ -85,7 +87,7 @@ void BKE_tracking_camera_to_blender(struct MovieTracking *tracking, struct Scene
|
||||
|
||||
void BKE_get_tracking_mat(struct Scene *scene, struct Object *ob, float mat[4][4]);
|
||||
void BKE_tracking_projection_matrix(struct MovieTracking *tracking, struct MovieTrackingObject *object,
|
||||
int framenr, int winx, int winy, float mat[4][4]);
|
||||
int framenr, int winx, int winy, float mat[4][4]);
|
||||
|
||||
struct ListBase *BKE_tracking_get_tracks(struct MovieTracking *tracking);
|
||||
struct MovieTrackingReconstruction *BKE_tracking_get_reconstruction(struct MovieTracking *tracking);
|
||||
@@ -95,7 +97,7 @@ struct MovieTrackingObject *BKE_tracking_active_object(struct MovieTracking *tra
|
||||
struct MovieTrackingObject *BKE_tracking_get_camera_object(struct MovieTracking *tracking);
|
||||
struct ListBase *BKE_tracking_object_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
|
||||
struct MovieTrackingReconstruction *BKE_tracking_object_reconstruction(struct MovieTracking *tracking,
|
||||
struct MovieTrackingObject *object);
|
||||
struct MovieTrackingObject *object);
|
||||
|
||||
void BKE_tracking_disable_imbuf_channels(struct ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, int grayscale);
|
||||
|
||||
@@ -115,24 +117,24 @@ int BKE_tracking_next(struct MovieTrackingContext *context);
|
||||
|
||||
/* Camera solving */
|
||||
int BKE_tracking_can_reconstruct(struct MovieTracking *tracking, struct MovieTrackingObject *object,
|
||||
char *error_msg, int error_size);
|
||||
char *error_msg, int error_size);
|
||||
|
||||
struct MovieReconstructContext* BKE_tracking_reconstruction_context_new(struct MovieTracking *tracking,
|
||||
struct MovieTrackingObject *object, int keyframe1, int keyframe2, int width, int height);
|
||||
void BKE_tracking_reconstruction_context_free(struct MovieReconstructContext *context);
|
||||
void BKE_tracking_solve_reconstruction(struct MovieReconstructContext *context,
|
||||
short *stop, short *do_update, float *progress, char *stats_message, int message_size);
|
||||
void BKE_tracking_solve_reconstruction(struct MovieReconstructContext *context, short *stop, short *do_update,
|
||||
float *progress, char *stats_message, int message_size);
|
||||
int BKE_tracking_finish_reconstruction(struct MovieReconstructContext *context, struct MovieTracking *tracking);
|
||||
|
||||
struct MovieReconstructedCamera *BKE_tracking_get_reconstructed_camera(struct MovieTracking *tracking,
|
||||
struct MovieTrackingObject *object, int framenr);
|
||||
void BKE_tracking_get_interpolated_camera(struct MovieTracking *tracking,
|
||||
struct MovieTrackingObject *object, int framenr, float mat[4][4]);
|
||||
void BKE_tracking_get_interpolated_camera(struct MovieTracking *tracking, struct MovieTrackingObject *object,
|
||||
int framenr, float mat[4][4]);
|
||||
|
||||
/* Feature detection */
|
||||
void BKE_tracking_detect_fast(struct MovieTracking *tracking, struct ListBase *tracksbase, struct ImBuf *imbuf,
|
||||
int framenr, int margin, int min_trackness, int min_distance, struct bGPDlayer *layer,
|
||||
int place_outside_layer);
|
||||
int framenr, int margin, int min_trackness, int min_distance, struct bGPDlayer *layer,
|
||||
int place_outside_layer);
|
||||
|
||||
/* 2D stabilization */
|
||||
void BKE_tracking_stabilization_data(struct MovieTracking *tracking, int framenr, int width, int height, float loc[2], float *scale, float *angle);
|
||||
@@ -146,7 +148,7 @@ void BKE_tracking_invert_intrinsics(struct MovieTracking *tracking, float co[2],
|
||||
struct MovieDistortion *BKE_tracking_distortion_create(void);
|
||||
struct MovieDistortion *BKE_tracking_distortion_copy(struct MovieDistortion *distortion);
|
||||
struct ImBuf *BKE_tracking_distortion_exec(struct MovieDistortion *distortion, struct MovieTracking *tracking,
|
||||
struct ImBuf *ibuf, int width, int height, float overscan, int undistort);
|
||||
struct ImBuf *ibuf, int width, int height, float overscan, int undistort);
|
||||
void BKE_tracking_distortion_destroy(struct MovieDistortion *distortion);
|
||||
|
||||
struct ImBuf *BKE_tracking_undistort(struct MovieTracking *tracking, struct ImBuf *ibuf, int width, int height, float overscan);
|
||||
|
@@ -3927,28 +3927,28 @@ static bConstraintTypeInfo CTI_PIVOT = {
|
||||
|
||||
/* ----------- Follow Track ------------- */
|
||||
|
||||
static void followtrack_new_data (void *cdata)
|
||||
static void followtrack_new_data(void *cdata)
|
||||
{
|
||||
bFollowTrackConstraint *data= (bFollowTrackConstraint *)cdata;
|
||||
|
||||
data->clip= NULL;
|
||||
bFollowTrackConstraint *data = (bFollowTrackConstraint *)cdata;
|
||||
|
||||
data->clip = NULL;
|
||||
data->flag |= FOLLOWTRACK_ACTIVECLIP;
|
||||
}
|
||||
|
||||
static void followtrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bFollowTrackConstraint *data= con->data;
|
||||
|
||||
bFollowTrackConstraint *data = con->data;
|
||||
|
||||
func(con, (ID**)&data->clip, userdata);
|
||||
func(con, (ID**)&data->camera, userdata);
|
||||
func(con, (ID**)&data->depth_ob, userdata);
|
||||
}
|
||||
|
||||
static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
{
|
||||
Scene *scene= cob->scene;
|
||||
bFollowTrackConstraint *data= con->data;
|
||||
MovieClip *clip= data->clip;
|
||||
Scene *scene = cob->scene;
|
||||
bFollowTrackConstraint *data = con->data;
|
||||
MovieClip *clip = data->clip;
|
||||
MovieTracking *tracking;
|
||||
MovieTrackingTrack *track;
|
||||
MovieTrackingObject *tracking_object;
|
||||
@@ -3960,17 +3960,17 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
if (!clip || !data->track[0] || !camob)
|
||||
return;
|
||||
|
||||
tracking= &clip->tracking;
|
||||
tracking = &clip->tracking;
|
||||
|
||||
if (data->object[0])
|
||||
tracking_object= BKE_tracking_named_object(tracking, data->object);
|
||||
tracking_object = BKE_tracking_named_object(tracking, data->object);
|
||||
else
|
||||
tracking_object= BKE_tracking_get_camera_object(tracking);
|
||||
tracking_object = BKE_tracking_get_camera_object(tracking);
|
||||
|
||||
if (!tracking_object)
|
||||
return;
|
||||
|
||||
track= BKE_tracking_named_track(tracking, tracking_object, data->track);
|
||||
track = BKE_tracking_named_track(tracking, tracking_object, data->track);
|
||||
|
||||
if (!track)
|
||||
return;
|
||||
@@ -3981,7 +3981,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
|
||||
copy_m4_m4(obmat, cob->matrix);
|
||||
|
||||
if ((tracking_object->flag&TRACKING_OBJECT_CAMERA)==0) {
|
||||
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA)==0) {
|
||||
float imat[4][4];
|
||||
|
||||
copy_m4_m4(mat, camob->obmat);
|
||||
@@ -4003,15 +4003,15 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
else {
|
||||
MovieTrackingMarker *marker;
|
||||
float vec[3], disp[3], axis[3], mat[4][4];
|
||||
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
|
||||
float aspect= (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
|
||||
float len, d;
|
||||
|
||||
where_is_object_mat(scene, camob, mat);
|
||||
|
||||
/* camera axis */
|
||||
vec[0]= 0.0f;
|
||||
vec[1]= 0.0f;
|
||||
vec[2]= 1.0f;
|
||||
vec[0] = 0.0f;
|
||||
vec[1] = 0.0f;
|
||||
vec[2] = 1.0f;
|
||||
mul_v3_m4v3(axis, mat, vec);
|
||||
|
||||
/* distance to projection plane */
|
||||
@@ -4019,13 +4019,13 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
sub_v3_v3(vec, mat[3]);
|
||||
project_v3_v3v3(disp, vec, axis);
|
||||
|
||||
len= len_v3(disp);
|
||||
len = len_v3(disp);
|
||||
|
||||
if (len > FLT_EPSILON) {
|
||||
CameraParams params;
|
||||
float pos[2], rmat[4][4];
|
||||
|
||||
marker= BKE_tracking_get_marker(track, scene->r.cfra);
|
||||
marker = BKE_tracking_get_marker(track, scene->r.cfra);
|
||||
|
||||
add_v2_v2v2(pos, marker->pos, track->offset);
|
||||
|
||||
@@ -4033,12 +4033,14 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
camera_params_from_object(¶ms, camob);
|
||||
|
||||
if (params.is_ortho) {
|
||||
vec[0]= params.ortho_scale * (pos[0]-0.5f+params.shiftx);
|
||||
vec[1]= params.ortho_scale * (pos[1]-0.5f+params.shifty);
|
||||
vec[2]= -len;
|
||||
vec[0] = params.ortho_scale * (pos[0] - 0.5f + params.shiftx);
|
||||
vec[1] = params.ortho_scale * (pos[1] - 0.5f + params.shifty);
|
||||
vec[2] = -len;
|
||||
|
||||
if (aspect > 1.0f) vec[1] /= aspect;
|
||||
else vec[0] *= aspect;
|
||||
if (aspect > 1.0f)
|
||||
vec[1] /= aspect;
|
||||
else
|
||||
vec[0] *= aspect;
|
||||
|
||||
mul_v3_m4v3(disp, camob->obmat, vec);
|
||||
|
||||
@@ -4049,14 +4051,16 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
copy_v3_v3(cob->matrix[3], disp);
|
||||
}
|
||||
else {
|
||||
d= (len*params.sensor_x) / (2.0f*params.lens);
|
||||
d= (len * params.sensor_x) / (2.0f * params.lens);
|
||||
|
||||
vec[0]= d*(2.0f*(pos[0]+params.shiftx)-1.0f);
|
||||
vec[1]= d*(2.0f*(pos[1]+params.shifty)-1.0f);
|
||||
vec[2]= -len;
|
||||
vec[0] = d * (2.0f * (pos[0] + params.shiftx) - 1.0f);
|
||||
vec[1] = d * (2.0f * (pos[1] + params.shifty) - 1.0f);
|
||||
vec[2] = -len;
|
||||
|
||||
if (aspect > 1.0f) vec[1] /= aspect;
|
||||
else vec[0] *= aspect;
|
||||
if (aspect > 1.0f)
|
||||
vec[1] /= aspect;
|
||||
else
|
||||
vec[0] *= aspect;
|
||||
|
||||
mul_v3_m4v3(disp, camob->obmat, vec);
|
||||
|
||||
@@ -4069,8 +4073,8 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
}
|
||||
|
||||
if (data->depth_ob && data->depth_ob->derivedFinal) {
|
||||
Object *depth_ob= data->depth_ob;
|
||||
BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh;
|
||||
Object *depth_ob = data->depth_ob;
|
||||
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
|
||||
BVHTreeRayHit hit;
|
||||
float ray_start[3], ray_end[3], ray_nor[3], imat[4][4];
|
||||
int result;
|
||||
@@ -4084,10 +4088,10 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
|
||||
bvhtree_from_mesh_faces(&treeData, depth_ob->derivedFinal, 0.0f, 4, 6);
|
||||
|
||||
hit.dist= FLT_MAX;
|
||||
hit.index= -1;
|
||||
hit.dist = FLT_MAX;
|
||||
hit.index = -1;
|
||||
|
||||
result= BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
|
||||
result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
|
||||
|
||||
if (result != -1) {
|
||||
mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
|
||||
@@ -4117,34 +4121,34 @@ static bConstraintTypeInfo CTI_FOLLOWTRACK = {
|
||||
|
||||
/* ----------- Camre Solver ------------- */
|
||||
|
||||
static void camerasolver_new_data (void *cdata)
|
||||
static void camerasolver_new_data(void *cdata)
|
||||
{
|
||||
bCameraSolverConstraint *data= (bCameraSolverConstraint *)cdata;
|
||||
|
||||
bCameraSolverConstraint *data = (bCameraSolverConstraint *)cdata;
|
||||
|
||||
data->clip = NULL;
|
||||
data->flag |= CAMERASOLVER_ACTIVECLIP;
|
||||
}
|
||||
|
||||
static void camerasolver_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void camerasolver_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bCameraSolverConstraint *data= con->data;
|
||||
|
||||
bCameraSolverConstraint *data = con->data;
|
||||
|
||||
func(con, (ID**)&data->clip, userdata);
|
||||
}
|
||||
|
||||
static void camerasolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
{
|
||||
Scene *scene= cob->scene;
|
||||
bCameraSolverConstraint *data= con->data;
|
||||
MovieClip *clip= data->clip;
|
||||
Scene *scene = cob->scene;
|
||||
bCameraSolverConstraint *data = con->data;
|
||||
MovieClip *clip = data->clip;
|
||||
|
||||
if (data->flag & CAMERASOLVER_ACTIVECLIP)
|
||||
clip= scene->clip;
|
||||
clip = scene->clip;
|
||||
|
||||
if (clip) {
|
||||
float mat[4][4], obmat[4][4];
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTrackingObject *object= BKE_tracking_get_camera_object(tracking);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingObject *object = BKE_tracking_get_camera_object(tracking);
|
||||
|
||||
BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, mat);
|
||||
|
||||
@@ -4172,16 +4176,16 @@ static bConstraintTypeInfo CTI_CAMERASOLVER = {
|
||||
|
||||
/* ----------- Object Solver ------------- */
|
||||
|
||||
static void objectsolver_new_data (void *cdata)
|
||||
static void objectsolver_new_data(void *cdata)
|
||||
{
|
||||
bObjectSolverConstraint *data= (bObjectSolverConstraint *)cdata;
|
||||
bObjectSolverConstraint *data = (bObjectSolverConstraint *)cdata;
|
||||
|
||||
data->clip = NULL;
|
||||
data->flag |= OBJECTSOLVER_ACTIVECLIP;
|
||||
unit_m4(data->invmat);
|
||||
}
|
||||
|
||||
static void objectsolver_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
static void objectsolver_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bObjectSolverConstraint *data= con->data;
|
||||
|
||||
@@ -4189,12 +4193,12 @@ static void objectsolver_id_looper (bConstraint *con, ConstraintIDFunc func, voi
|
||||
func(con, (ID**)&data->camera, userdata);
|
||||
}
|
||||
|
||||
static void objectsolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||
{
|
||||
Scene *scene= cob->scene;
|
||||
bObjectSolverConstraint *data= con->data;
|
||||
MovieClip *clip= data->clip;
|
||||
Object *camob= data->camera ? data->camera : scene->camera;
|
||||
Scene *scene = cob->scene;
|
||||
bObjectSolverConstraint *data = con->data;
|
||||
MovieClip *clip = data->clip;
|
||||
Object *camob = data->camera ? data->camera : scene->camera;
|
||||
|
||||
if (data->flag & OBJECTSOLVER_ACTIVECLIP)
|
||||
clip= scene->clip;
|
||||
@@ -4203,10 +4207,10 @@ static void objectsolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
|
||||
return;
|
||||
|
||||
if (clip) {
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingObject *object;
|
||||
|
||||
object= BKE_tracking_named_object(tracking, data->object);
|
||||
object = BKE_tracking_named_object(tracking, data->object);
|
||||
|
||||
if (object) {
|
||||
float mat[4][4], obmat[4][4], imat[4][4], cammat[4][4], camimat[4][4], parmat[4][4];
|
||||
|
@@ -82,19 +82,19 @@
|
||||
|
||||
static int sequence_guess_offset(const char *full_name, int head_len, int numlen)
|
||||
{
|
||||
char num[FILE_MAX]= {0};
|
||||
char num[FILE_MAX] = {0};
|
||||
|
||||
BLI_strncpy(num, full_name+head_len, numlen+1);
|
||||
BLI_strncpy(num, full_name + head_len, numlen + 1);
|
||||
|
||||
return atoi(num);
|
||||
}
|
||||
|
||||
static int rendersize_to_proxy(MovieClipUser *user, int flag)
|
||||
{
|
||||
if ((flag&MCLIP_USE_PROXY)==0)
|
||||
if ((flag & MCLIP_USE_PROXY) == 0)
|
||||
return IMB_PROXY_NONE;
|
||||
|
||||
switch(user->render_size) {
|
||||
switch (user->render_size) {
|
||||
case MCLIP_PROXY_RENDER_SIZE_25:
|
||||
return IMB_PROXY_25;
|
||||
|
||||
@@ -116,7 +116,7 @@ static int rendersize_to_proxy(MovieClipUser *user, int flag)
|
||||
|
||||
static int rendersize_to_number(int render_size)
|
||||
{
|
||||
switch(render_size) {
|
||||
switch (render_size) {
|
||||
case MCLIP_PROXY_RENDER_SIZE_25:
|
||||
return 25;
|
||||
|
||||
@@ -138,7 +138,7 @@ static int rendersize_to_number(int render_size)
|
||||
|
||||
static int get_timecode(MovieClip *clip, int flag)
|
||||
{
|
||||
if ((flag&MCLIP_USE_PROXY)==0)
|
||||
if ((flag & MCLIP_USE_PROXY) == 0)
|
||||
return IMB_TC_NONE;
|
||||
|
||||
return clip->proxy.tc;
|
||||
@@ -157,8 +157,10 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name)
|
||||
* autoguess offset for now. could be something smarter in the future */
|
||||
offset= sequence_guess_offset(clip->name, strlen(head), numlen);
|
||||
|
||||
if (numlen) BLI_stringenc(name, head, tail, numlen, offset+framenr-1);
|
||||
else BLI_strncpy(name, clip->name, sizeof(clip->name));
|
||||
if (numlen)
|
||||
BLI_stringenc(name, head, tail, numlen, offset + framenr - 1);
|
||||
else
|
||||
BLI_strncpy(name, clip->name, sizeof(clip->name));
|
||||
|
||||
BLI_path_abs(name, ID_BLEND_PATH(G.main, &clip->id));
|
||||
}
|
||||
@@ -166,12 +168,12 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name)
|
||||
/* supposed to work with sequences only */
|
||||
static void get_proxy_fname(MovieClip *clip, int proxy_render_size, int undistorted, int framenr, char *name)
|
||||
{
|
||||
int size= rendersize_to_number(proxy_render_size);
|
||||
int size = rendersize_to_number(proxy_render_size);
|
||||
char dir[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX];
|
||||
|
||||
BLI_split_dirfile(clip->name, clipdir, clipfile, FILE_MAX, FILE_MAX);
|
||||
|
||||
if (clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
|
||||
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
|
||||
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
|
||||
}
|
||||
else {
|
||||
@@ -195,27 +197,27 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user,
|
||||
char name[FILE_MAX];
|
||||
int loadflag, use_proxy= 0;
|
||||
|
||||
use_proxy= (flag&MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL;
|
||||
use_proxy = (flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL;
|
||||
if (use_proxy) {
|
||||
int undistort= user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT;
|
||||
int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
|
||||
get_proxy_fname(clip, user->render_size, undistort, framenr, name);
|
||||
}
|
||||
else
|
||||
get_sequence_fname(clip, framenr, name);
|
||||
|
||||
loadflag= IB_rect|IB_multilayer;
|
||||
loadflag = IB_rect|IB_multilayer;
|
||||
|
||||
/* read ibuf */
|
||||
ibuf= IMB_loadiffname(name, loadflag);
|
||||
ibuf = IMB_loadiffname(name, loadflag);
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, int framenr, int flag)
|
||||
{
|
||||
ImBuf *ibuf= NULL;
|
||||
int tc= get_timecode(clip, flag);
|
||||
int proxy= rendersize_to_proxy(user, flag);
|
||||
ImBuf *ibuf = NULL;
|
||||
int tc = get_timecode(clip, flag);
|
||||
int proxy = rendersize_to_proxy(user, flag);
|
||||
char str[FILE_MAX];
|
||||
|
||||
if (!clip->anim) {
|
||||
@@ -223,10 +225,10 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
|
||||
BLI_path_abs(str, ID_BLEND_PATH(G.main, &clip->id));
|
||||
|
||||
/* FIXME: make several stream accessible in image editor, too */
|
||||
clip->anim= openanim(str, IB_rect, 0);
|
||||
clip->anim = openanim(str, IB_rect, 0);
|
||||
|
||||
if (clip->anim) {
|
||||
if (clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
|
||||
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
|
||||
char dir[FILE_MAX];
|
||||
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
|
||||
BLI_path_abs(dir, G.main->name);
|
||||
@@ -239,16 +241,16 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
|
||||
int dur;
|
||||
int fra;
|
||||
|
||||
dur= IMB_anim_get_duration(clip->anim, tc);
|
||||
fra= framenr-1;
|
||||
dur = IMB_anim_get_duration(clip->anim, tc);
|
||||
fra = framenr - 1;
|
||||
|
||||
if (fra<0)
|
||||
fra= 0;
|
||||
fra = 0;
|
||||
|
||||
if (fra>(dur-1))
|
||||
fra= dur-1;
|
||||
if (fra > (dur - 1))
|
||||
fra = dur - 1;
|
||||
|
||||
ibuf= IMB_anim_absolute(clip->anim, fra, tc, proxy);
|
||||
ibuf = IMB_anim_absolute(clip->anim, fra, tc, proxy);
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
@@ -295,34 +297,40 @@ typedef struct MovieClipImBufCacheKey {
|
||||
|
||||
static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags)
|
||||
{
|
||||
MovieClipImBufCacheKey *key= (MovieClipImBufCacheKey*)userkey;
|
||||
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)userkey;
|
||||
|
||||
*framenr= key->framenr;
|
||||
*proxy= key->proxy;
|
||||
*render_flags= key->render_flag;
|
||||
*framenr = key->framenr;
|
||||
*proxy = key->proxy;
|
||||
*render_flags = key->render_flag;
|
||||
}
|
||||
|
||||
static unsigned int moviecache_hashhash(const void *keyv)
|
||||
{
|
||||
MovieClipImBufCacheKey *key= (MovieClipImBufCacheKey*)keyv;
|
||||
int rval= key->framenr;
|
||||
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)keyv;
|
||||
int rval = key->framenr;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static int moviecache_hashcmp(const void *av, const void *bv)
|
||||
{
|
||||
const MovieClipImBufCacheKey *a= (MovieClipImBufCacheKey*)av;
|
||||
const MovieClipImBufCacheKey *b= (MovieClipImBufCacheKey*)bv;
|
||||
const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey*)av;
|
||||
const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey*)bv;
|
||||
|
||||
if (a->framenr<b->framenr) return -1;
|
||||
else if (a->framenr>b->framenr) return 1;
|
||||
if (a->framenr < b->framenr)
|
||||
return -1;
|
||||
else if (a->framenr > b->framenr)
|
||||
return 1;
|
||||
|
||||
if (a->proxy<b->proxy) return -1;
|
||||
else if (a->proxy>b->proxy) return 1;
|
||||
if (a->proxy < b->proxy)
|
||||
return -1;
|
||||
else if (a->proxy > b->proxy)
|
||||
return 1;
|
||||
|
||||
if (a->render_flag<b->render_flag) return -1;
|
||||
else if (a->render_flag>b->render_flag) return 1;
|
||||
if (a->render_flag < b->render_flag)
|
||||
return -1;
|
||||
else if (a->render_flag > b->render_flag)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -332,15 +340,15 @@ static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag)
|
||||
if (clip->cache) {
|
||||
MovieClipImBufCacheKey key;
|
||||
|
||||
key.framenr= user->framenr;
|
||||
key.framenr = user->framenr;
|
||||
|
||||
if (flag&MCLIP_USE_PROXY) {
|
||||
key.proxy= rendersize_to_proxy(user, flag);
|
||||
key.render_flag= user->render_flag;
|
||||
if (flag & MCLIP_USE_PROXY) {
|
||||
key.proxy = rendersize_to_proxy(user, flag);
|
||||
key.render_flag = user->render_flag;
|
||||
}
|
||||
else {
|
||||
key.proxy= IMB_PROXY_NONE;
|
||||
key.render_flag= 0;
|
||||
key.proxy = IMB_PROXY_NONE;
|
||||
key.render_flag = 0;
|
||||
}
|
||||
|
||||
return IMB_moviecache_get(clip->cache->moviecache, &key);
|
||||
@@ -354,21 +362,21 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i
|
||||
MovieClipImBufCacheKey key;
|
||||
|
||||
if (!clip->cache) {
|
||||
clip->cache= MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
|
||||
clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
|
||||
|
||||
clip->cache->moviecache= IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash,
|
||||
clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash,
|
||||
moviecache_hashcmp, moviecache_keydata);
|
||||
}
|
||||
|
||||
key.framenr= user->framenr;
|
||||
key.framenr = user->framenr;
|
||||
|
||||
if (flag&MCLIP_USE_PROXY) {
|
||||
key.proxy= rendersize_to_proxy(user, flag);
|
||||
key.render_flag= user->render_flag;
|
||||
if (flag & MCLIP_USE_PROXY) {
|
||||
key.proxy = rendersize_to_proxy(user, flag);
|
||||
key.render_flag = user->render_flag;
|
||||
}
|
||||
else {
|
||||
key.proxy= IMB_PROXY_NONE;
|
||||
key.render_flag= 0;
|
||||
key.proxy = IMB_PROXY_NONE;
|
||||
key.render_flag = 0;
|
||||
}
|
||||
|
||||
IMB_moviecache_put(clip->cache->moviecache, &key, ibuf);
|
||||
@@ -381,18 +389,18 @@ static MovieClip *movieclip_alloc(const char *name)
|
||||
{
|
||||
MovieClip *clip;
|
||||
|
||||
clip= alloc_libblock(&G.main->movieclip, ID_MC, name);
|
||||
clip = alloc_libblock(&G.main->movieclip, ID_MC, name);
|
||||
|
||||
clip->aspx= clip->aspy= 1.0f;
|
||||
clip->aspx = clip->aspy= 1.0f;
|
||||
|
||||
BKE_tracking_init_settings(&clip->tracking);
|
||||
|
||||
clip->proxy.build_size_flag= IMB_PROXY_25;
|
||||
clip->proxy.build_tc_flag= IMB_TC_RECORD_RUN |
|
||||
IMB_TC_FREE_RUN |
|
||||
IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN |
|
||||
IMB_TC_RECORD_RUN_NO_GAPS;
|
||||
clip->proxy.quality= 90;
|
||||
clip->proxy.build_size_flag = IMB_PROXY_25;
|
||||
clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN |
|
||||
IMB_TC_FREE_RUN |
|
||||
IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN |
|
||||
IMB_TC_RECORD_RUN_NO_GAPS;
|
||||
clip->proxy.quality = 90;
|
||||
|
||||
return clip;
|
||||
}
|
||||
@@ -413,16 +421,17 @@ MovieClip *BKE_add_movieclip_file(const char *name)
|
||||
BLI_path_abs(str, G.main->name);
|
||||
|
||||
/* exists? */
|
||||
file= BLI_open(str, O_BINARY|O_RDONLY,0);
|
||||
if (file== -1) return NULL;
|
||||
file = BLI_open(str, O_BINARY|O_RDONLY,0);
|
||||
if (file == -1)
|
||||
return NULL;
|
||||
close(file);
|
||||
|
||||
/* ** first search an identical clip ** */
|
||||
for (clip= G.main->movieclip.first; clip; clip= clip->id.next) {
|
||||
for (clip = G.main->movieclip.first; clip; clip = clip->id.next) {
|
||||
BLI_strncpy(strtest, clip->name, sizeof(clip->name));
|
||||
BLI_path_abs(strtest, G.main->name);
|
||||
|
||||
if (strcmp(strtest, str)==0) {
|
||||
if (strcmp(strtest, str) == 0) {
|
||||
BLI_strncpy(clip->name, name, sizeof(clip->name)); /* for stringcode */
|
||||
clip->id.us++; /* officially should not, it doesn't link here! */
|
||||
|
||||
@@ -433,24 +442,27 @@ MovieClip *BKE_add_movieclip_file(const char *name)
|
||||
/* ** add new movieclip ** */
|
||||
|
||||
/* create a short library name */
|
||||
len= strlen(name);
|
||||
len = strlen(name);
|
||||
|
||||
while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\') len--;
|
||||
libname= name+len;
|
||||
while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\')
|
||||
len--;
|
||||
libname = name + len;
|
||||
|
||||
clip= movieclip_alloc(libname);
|
||||
clip = movieclip_alloc(libname);
|
||||
BLI_strncpy(clip->name, name, sizeof(clip->name));
|
||||
|
||||
if (BLI_testextensie_array(name, imb_ext_movie)) clip->source= MCLIP_SRC_MOVIE;
|
||||
else clip->source= MCLIP_SRC_SEQUENCE;
|
||||
if (BLI_testextensie_array(name, imb_ext_movie))
|
||||
clip->source= MCLIP_SRC_MOVIE;
|
||||
else
|
||||
clip->source= MCLIP_SRC_SEQUENCE;
|
||||
|
||||
user.framenr= 1;
|
||||
user.framenr = 1;
|
||||
BKE_movieclip_get_size(clip, &user, &width, &height);
|
||||
if (width && height) {
|
||||
clip->tracking.camera.principal[0]= ((float)width)/2;
|
||||
clip->tracking.camera.principal[1]= ((float)height)/2;
|
||||
clip->tracking.camera.principal[0] = ((float)width) / 2.0f;
|
||||
clip->tracking.camera.principal[1] = ((float)height) / 2.0f;
|
||||
|
||||
clip->tracking.camera.focal= 24.0f*width/clip->tracking.camera.sensor_width;
|
||||
clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width;
|
||||
}
|
||||
|
||||
return clip;
|
||||
@@ -458,24 +470,24 @@ MovieClip *BKE_add_movieclip_file(const char *name)
|
||||
|
||||
static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int *width, int *height)
|
||||
{
|
||||
*width= ibuf->x;
|
||||
*height= ibuf->y;
|
||||
*width = ibuf->x;
|
||||
*height = ibuf->y;
|
||||
|
||||
if (clip->flag&MCLIP_USE_PROXY) {
|
||||
if (clip->flag & MCLIP_USE_PROXY) {
|
||||
switch(user->render_size) {
|
||||
case MCLIP_PROXY_RENDER_SIZE_25:
|
||||
(*width)*= 4;
|
||||
(*height)*= 4;
|
||||
(*width) *= 4;
|
||||
(*height) *= 4;
|
||||
break;
|
||||
|
||||
case MCLIP_PROXY_RENDER_SIZE_50:
|
||||
(*width)*= 2.0f;
|
||||
(*height)*= 2.0f;
|
||||
(*width) *= 2.0f;
|
||||
(*height) *= 2.0f;
|
||||
break;
|
||||
|
||||
case MCLIP_PROXY_RENDER_SIZE_75:
|
||||
*width= ((float)*width)*4.0f/3.0f;
|
||||
*height= ((float)*height)*4.0f/3.0f;
|
||||
*width = ((float)*width)*4.0f/3.0f;
|
||||
*height = ((float)*height)*4.0f/3.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -490,12 +502,12 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip, struct MovieDistortion *dist
|
||||
imb_freerectfloatImBuf(ibuf);
|
||||
|
||||
if (distortion)
|
||||
undistibuf= BKE_tracking_distortion_exec(distortion, &clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f, 1);
|
||||
undistibuf = BKE_tracking_distortion_exec(distortion, &clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f, 1);
|
||||
else
|
||||
undistibuf= BKE_tracking_undistort(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
|
||||
undistibuf = BKE_tracking_undistort(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
|
||||
|
||||
if (undistibuf->userflags&IB_RECT_INVALID) {
|
||||
ibuf->userflags&= ~IB_RECT_INVALID;
|
||||
if (undistibuf->userflags & IB_RECT_INVALID) {
|
||||
ibuf->userflags &= ~IB_RECT_INVALID;
|
||||
IMB_rect_from_float(undistibuf);
|
||||
}
|
||||
|
||||
@@ -528,29 +540,29 @@ static int need_postprocessed_frame(MovieClipUser *user, int flag, int postproce
|
||||
|
||||
static int check_undistortion_cache_flags(MovieClip *clip)
|
||||
{
|
||||
MovieClipCache *cache= clip->cache;
|
||||
MovieTrackingCamera *camera= &clip->tracking.camera;
|
||||
MovieClipCache *cache = clip->cache;
|
||||
MovieTrackingCamera *camera = &clip->tracking.camera;
|
||||
|
||||
/* check for distortion model changes */
|
||||
if (!equals_v2v2(camera->principal, cache->postprocessed.principal))
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
if (!equals_v3v3(&camera->k1, &cache->postprocessed.k1))
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *user, int flag, int postprocess_flag)
|
||||
{
|
||||
MovieClipCache *cache= clip->cache;
|
||||
int framenr= user->framenr;
|
||||
short proxy= IMB_PROXY_NONE;
|
||||
int render_flag= 0;
|
||||
MovieClipCache *cache = clip->cache;
|
||||
int framenr = user->framenr;
|
||||
short proxy = IMB_PROXY_NONE;
|
||||
int render_flag = 0;
|
||||
|
||||
if (flag&MCLIP_USE_PROXY) {
|
||||
proxy= rendersize_to_proxy(user, flag);
|
||||
render_flag= user->render_flag;
|
||||
if (flag & MCLIP_USE_PROXY) {
|
||||
proxy = rendersize_to_proxy(user, flag);
|
||||
render_flag = user->render_flag;
|
||||
}
|
||||
|
||||
/* no cache or no cached postprocessed image */
|
||||
@@ -582,19 +594,19 @@ static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *use
|
||||
|
||||
static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag)
|
||||
{
|
||||
MovieClipCache *cache= clip->cache;
|
||||
MovieTrackingCamera *camera= &clip->tracking.camera;
|
||||
MovieClipCache *cache = clip->cache;
|
||||
MovieTrackingCamera *camera = &clip->tracking.camera;
|
||||
ImBuf *postproc_ibuf = NULL;
|
||||
|
||||
if (cache->postprocessed.ibuf)
|
||||
IMB_freeImBuf(cache->postprocessed.ibuf);
|
||||
|
||||
cache->postprocessed.framenr= user->framenr;
|
||||
cache->postprocessed.framenr = user->framenr;
|
||||
cache->postprocessed.flag = postprocess_flag;
|
||||
|
||||
if (flag&MCLIP_USE_PROXY) {
|
||||
cache->postprocessed.proxy= rendersize_to_proxy(user, flag);
|
||||
cache->postprocessed.render_flag= user->render_flag;
|
||||
if (flag & MCLIP_USE_PROXY) {
|
||||
cache->postprocessed.proxy = rendersize_to_proxy(user, flag);
|
||||
cache->postprocessed.render_flag = user->render_flag;
|
||||
}
|
||||
else {
|
||||
cache->postprocessed.proxy = IMB_PROXY_NONE;
|
||||
@@ -604,10 +616,12 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
|
||||
if (need_undistortion_postprocess(user, flag)) {
|
||||
copy_v2_v2(cache->postprocessed.principal, camera->principal);
|
||||
copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
|
||||
cache->postprocessed.undistoriton_used = 1;
|
||||
cache->postprocessed.undistoriton_used = TRUE;
|
||||
postproc_ibuf= get_undistorted_ibuf(clip, NULL, ibuf);
|
||||
}
|
||||
else cache->postprocessed.undistoriton_used = 0;
|
||||
else {
|
||||
cache->postprocessed.undistoriton_used = FALSE;
|
||||
}
|
||||
|
||||
if (postprocess_flag) {
|
||||
int disable_red = postprocess_flag & MOVIECLIP_DISABLE_RED,
|
||||
@@ -624,12 +638,12 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
|
||||
|
||||
IMB_refImBuf(postproc_ibuf);
|
||||
|
||||
cache->postprocessed.ibuf= postproc_ibuf;
|
||||
cache->postprocessed.ibuf = postproc_ibuf;
|
||||
|
||||
if (cache->stabilized.ibuf) {
|
||||
/* force stable buffer be re-calculated */
|
||||
IMB_freeImBuf(cache->stabilized.ibuf);
|
||||
cache->stabilized.ibuf= NULL;
|
||||
cache->stabilized.ibuf = NULL;
|
||||
}
|
||||
|
||||
return postproc_ibuf;
|
||||
@@ -638,8 +652,8 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
|
||||
static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int flag,
|
||||
int postprocess_flag, int cache_flag)
|
||||
{
|
||||
ImBuf *ibuf= NULL;
|
||||
int framenr= user->framenr, need_postprocess= 0;
|
||||
ImBuf *ibuf = NULL;
|
||||
int framenr = user->framenr, need_postprocess = FALSE;
|
||||
|
||||
/* cache isn't threadsafe itself and also loading of movies
|
||||
* can't happen from concurent threads that's why we use lock here */
|
||||
@@ -650,23 +664,24 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u
|
||||
ibuf= get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
|
||||
|
||||
if (!ibuf)
|
||||
need_postprocess= 1;
|
||||
need_postprocess = TRUE;
|
||||
}
|
||||
|
||||
if (!ibuf)
|
||||
ibuf= get_imbuf_cache(clip, user, flag);
|
||||
|
||||
if (!ibuf) {
|
||||
int use_sequence= 0;
|
||||
int use_sequence = FALSE;
|
||||
|
||||
/* undistorted proxies for movies should be read as image sequence */
|
||||
use_sequence= (user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT) &&
|
||||
(user->render_size!=MCLIP_PROXY_RENDER_SIZE_FULL);
|
||||
use_sequence = (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) &&
|
||||
(user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL);
|
||||
|
||||
if (clip->source==MCLIP_SRC_SEQUENCE || use_sequence)
|
||||
ibuf= movieclip_load_sequence_file(clip, user, framenr, flag);
|
||||
if (clip->source == MCLIP_SRC_SEQUENCE || use_sequence) {
|
||||
ibuf = movieclip_load_sequence_file(clip, user, framenr, flag);
|
||||
}
|
||||
else {
|
||||
ibuf= movieclip_load_movie_file(clip, user, framenr, flag);
|
||||
ibuf = movieclip_load_movie_file(clip, user, framenr, flag);
|
||||
}
|
||||
|
||||
if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0)
|
||||
@@ -674,13 +689,13 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u
|
||||
}
|
||||
|
||||
if (ibuf) {
|
||||
clip->lastframe= framenr;
|
||||
clip->lastframe = framenr;
|
||||
real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]);
|
||||
|
||||
/* postprocess frame and put to cache */
|
||||
if (need_postprocess) {
|
||||
ImBuf *tmpibuf= ibuf;
|
||||
ibuf= put_postprocessed_frame_to_cache(clip, user, tmpibuf, flag, postprocess_flag);
|
||||
ImBuf *tmpibuf = ibuf;
|
||||
ibuf = put_postprocessed_frame_to_cache(clip, user, tmpibuf, flag, postprocess_flag);
|
||||
IMB_freeImBuf(tmpibuf);
|
||||
}
|
||||
}
|
||||
@@ -714,7 +729,7 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
|
||||
short proxy = IMB_PROXY_NONE;
|
||||
int render_flag = 0;
|
||||
|
||||
if (clip->flag&MCLIP_USE_PROXY) {
|
||||
if (clip->flag & MCLIP_USE_PROXY) {
|
||||
proxy = rendersize_to_proxy(user, clip->flag);
|
||||
render_flag = user->render_flag;
|
||||
}
|
||||
@@ -724,7 +739,7 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
|
||||
return NULL;
|
||||
|
||||
/* cached ibuf used different proxy settings */
|
||||
if (cache->stabilized.render_flag!=render_flag || cache->stabilized.proxy!=proxy)
|
||||
if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy)
|
||||
return NULL;
|
||||
|
||||
if (cache->stabilized.postprocess_flag != postprocess_flag)
|
||||
@@ -777,9 +792,9 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user
|
||||
cache->stabilized.aspect = tracking->camera.pixel_aspect;
|
||||
cache->stabilized.filter = tracking->stabilization.filter;
|
||||
|
||||
if (clip->flag&MCLIP_USE_PROXY) {
|
||||
cache->stabilized.proxy= rendersize_to_proxy(user, clip->flag);
|
||||
cache->stabilized.render_flag= user->render_flag;
|
||||
if (clip->flag & MCLIP_USE_PROXY) {
|
||||
cache->stabilized.proxy = rendersize_to_proxy(user, clip->flag);
|
||||
cache->stabilized.render_flag = user->render_flag;
|
||||
}
|
||||
else {
|
||||
cache->stabilized.proxy = IMB_PROXY_NONE;
|
||||
@@ -795,37 +810,47 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user
|
||||
|
||||
ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag)
|
||||
{
|
||||
ImBuf *ibuf, *stableibuf= NULL;
|
||||
int framenr= user->framenr;
|
||||
ImBuf *ibuf, *stableibuf = NULL;
|
||||
int framenr = user->framenr;
|
||||
|
||||
ibuf= BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);
|
||||
ibuf = BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);
|
||||
|
||||
if (!ibuf)
|
||||
return NULL;
|
||||
|
||||
if (clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) {
|
||||
if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
|
||||
MovieClipCache *cache= clip->cache;
|
||||
|
||||
stableibuf= get_stable_cached_frame(clip, user, framenr, postprocess_flag);
|
||||
stableibuf = get_stable_cached_frame(clip, user, framenr, postprocess_flag);
|
||||
|
||||
if (!stableibuf)
|
||||
stableibuf= put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);
|
||||
stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);
|
||||
|
||||
if (loc) copy_v2_v2(loc, cache->stabilized.loc);
|
||||
if (scale) *scale= cache->stabilized.scale;
|
||||
if (angle) *angle= cache->stabilized.angle;
|
||||
if (loc)
|
||||
copy_v2_v2(loc, cache->stabilized.loc);
|
||||
|
||||
if (scale)
|
||||
*scale= cache->stabilized.scale;
|
||||
|
||||
if (angle)
|
||||
*angle= cache->stabilized.angle;
|
||||
}
|
||||
else {
|
||||
if (loc) zero_v2(loc);
|
||||
if (scale) *scale= 1.0f;
|
||||
if (angle) *angle= 0.0f;
|
||||
if (loc)
|
||||
zero_v2(loc);
|
||||
|
||||
stableibuf= ibuf;
|
||||
if (scale)
|
||||
*scale= 1.0f;
|
||||
|
||||
if (angle)
|
||||
*angle= 0.0f;
|
||||
|
||||
stableibuf = ibuf;
|
||||
}
|
||||
|
||||
if (stableibuf!=ibuf) {
|
||||
if (stableibuf != ibuf) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
ibuf= stableibuf;
|
||||
ibuf = stableibuf;
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
@@ -834,31 +859,31 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float
|
||||
|
||||
int BKE_movieclip_has_frame(MovieClip *clip, MovieClipUser *user)
|
||||
{
|
||||
ImBuf *ibuf= BKE_movieclip_get_ibuf(clip, user);
|
||||
ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
|
||||
|
||||
if (ibuf) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, int *height)
|
||||
{
|
||||
if (user->framenr==clip->lastframe) {
|
||||
*width= clip->lastsize[0];
|
||||
*height= clip->lastsize[1];
|
||||
if (user->framenr == clip->lastframe) {
|
||||
*width = clip->lastsize[0];
|
||||
*height = clip->lastsize[1];
|
||||
}
|
||||
else {
|
||||
ImBuf *ibuf= BKE_movieclip_get_ibuf(clip, user);
|
||||
ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
|
||||
|
||||
if (ibuf && ibuf->x && ibuf->y) {
|
||||
real_ibuf_size(clip, user, ibuf, width, height);
|
||||
}
|
||||
else {
|
||||
*width= 0;
|
||||
*height= 0;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
}
|
||||
|
||||
if (ibuf)
|
||||
@@ -873,20 +898,20 @@ int BKE_movieclip_get_duration(struct MovieClip *clip)
|
||||
|
||||
void BKE_movieclip_aspect(MovieClip *clip, float *aspx, float *aspy)
|
||||
{
|
||||
*aspx= *aspy= 1.0;
|
||||
*aspx = *aspy = 1.0;
|
||||
|
||||
/* x is always 1 */
|
||||
*aspy = clip->aspy/clip->aspx/clip->tracking.camera.pixel_aspect;
|
||||
*aspy = clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect;
|
||||
}
|
||||
|
||||
/* get segments of cached frames. useful for debugging cache policies */
|
||||
void BKE_movieclip_get_cache_segments(MovieClip *clip, MovieClipUser *user, int *totseg_r, int **points_r)
|
||||
{
|
||||
*totseg_r= 0;
|
||||
*points_r= NULL;
|
||||
*totseg_r = 0;
|
||||
*points_r = NULL;
|
||||
|
||||
if (clip->cache) {
|
||||
int proxy= rendersize_to_proxy(user, clip->flag);
|
||||
int proxy = rendersize_to_proxy(user, clip->flag);
|
||||
|
||||
IMB_moviecache_get_cache_segments(clip->cache->moviecache, proxy, user->render_flag, totseg_r, points_r);
|
||||
}
|
||||
@@ -896,7 +921,7 @@ void BKE_movieclip_user_set_frame(MovieClipUser *iuser, int framenr)
|
||||
{
|
||||
/* TODO: clamp framenr here? */
|
||||
|
||||
iuser->framenr= framenr;
|
||||
iuser->framenr = framenr;
|
||||
}
|
||||
|
||||
static void free_buffers(MovieClip *clip)
|
||||
@@ -911,12 +936,12 @@ static void free_buffers(MovieClip *clip)
|
||||
IMB_freeImBuf(clip->cache->stabilized.ibuf);
|
||||
|
||||
MEM_freeN(clip->cache);
|
||||
clip->cache= NULL;
|
||||
clip->cache = NULL;
|
||||
}
|
||||
|
||||
if (clip->anim) {
|
||||
IMB_free_anim(clip->anim);
|
||||
clip->anim= FALSE;
|
||||
clip->anim = NULL;
|
||||
}
|
||||
|
||||
BKE_free_animdata((ID *) clip);
|
||||
@@ -927,11 +952,13 @@ void BKE_movieclip_reload(MovieClip *clip)
|
||||
/* clear cache */
|
||||
free_buffers(clip);
|
||||
|
||||
clip->tracking.stabilization.ok= 0;
|
||||
clip->tracking.stabilization.ok = FALSE;
|
||||
|
||||
/* update clip source */
|
||||
if (BLI_testextensie_array(clip->name, imb_ext_movie)) clip->source= MCLIP_SRC_MOVIE;
|
||||
else clip->source= MCLIP_SRC_SEQUENCE;
|
||||
if (BLI_testextensie_array(clip->name, imb_ext_movie))
|
||||
clip->source = MCLIP_SRC_MOVIE;
|
||||
else
|
||||
clip->source = MCLIP_SRC_SEQUENCE;
|
||||
}
|
||||
|
||||
void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)
|
||||
@@ -941,44 +968,44 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
|
||||
|
||||
if (scopes->track_preview) {
|
||||
IMB_freeImBuf(scopes->track_preview);
|
||||
scopes->track_preview= NULL;
|
||||
scopes->track_preview = NULL;
|
||||
}
|
||||
|
||||
scopes->marker= NULL;
|
||||
scopes->track= NULL;
|
||||
scopes->marker = NULL;
|
||||
scopes->track = NULL;
|
||||
|
||||
if (clip) {
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(&clip->tracking);
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(&clip->tracking);
|
||||
|
||||
if (act_track) {
|
||||
MovieTrackingTrack *track= act_track;
|
||||
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr);
|
||||
MovieTrackingTrack *track = act_track;
|
||||
MovieTrackingMarker *marker = BKE_tracking_get_marker(track, user->framenr);
|
||||
|
||||
if (marker->flag&MARKER_DISABLED) {
|
||||
scopes->track_disabled= 1;
|
||||
if (marker->flag & MARKER_DISABLED) {
|
||||
scopes->track_disabled = TRUE;
|
||||
}
|
||||
else {
|
||||
ImBuf *ibuf= BKE_movieclip_get_ibuf(clip, user);
|
||||
ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
|
||||
|
||||
scopes->track_disabled= 0;
|
||||
scopes->track_disabled = FALSE;
|
||||
|
||||
if (ibuf && ibuf->rect) {
|
||||
ImBuf *tmpibuf;
|
||||
MovieTrackingMarker undist_marker= *marker;
|
||||
MovieTrackingMarker undist_marker = *marker;
|
||||
|
||||
if (user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT) {
|
||||
if (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
|
||||
int width, height;
|
||||
float aspy= 1.0f/clip->tracking.camera.pixel_aspect;
|
||||
float aspy= 1.0f / clip->tracking.camera.pixel_aspect;
|
||||
|
||||
BKE_movieclip_get_size(clip, user, &width, &height);
|
||||
|
||||
undist_marker.pos[0]*= width;
|
||||
undist_marker.pos[1]*= height*aspy;
|
||||
undist_marker.pos[0] *= width;
|
||||
undist_marker.pos[1] *= height*aspy;
|
||||
|
||||
BKE_tracking_invert_intrinsics(&clip->tracking, undist_marker.pos, undist_marker.pos);
|
||||
|
||||
undist_marker.pos[0]/= width;
|
||||
undist_marker.pos[1]/= height*aspy;
|
||||
undist_marker.pos[0] /= width;
|
||||
undist_marker.pos[1] /= height*aspy;
|
||||
}
|
||||
|
||||
/* NOTE: margin should be kept in sync with value from ui_draw_but_TRACKPREVIEW */
|
||||
@@ -997,46 +1024,46 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
|
||||
if ((track->flag&TRACK_LOCKED)==0) {
|
||||
scopes->marker= marker;
|
||||
scopes->track= track;
|
||||
scopes->slide_scale[0]= track->pat_max[0]-track->pat_min[0];
|
||||
scopes->slide_scale[1]= track->pat_max[1]-track->pat_min[1];
|
||||
if ((track->flag & TRACK_LOCKED)==0) {
|
||||
scopes->marker = marker;
|
||||
scopes->track = track;
|
||||
scopes->slide_scale[0] = track->pat_max[0]-track->pat_min[0];
|
||||
scopes->slide_scale[1] = track->pat_max[1]-track->pat_min[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scopes->framenr= user->framenr;
|
||||
scopes->ok= 1;
|
||||
scopes->framenr = user->framenr;
|
||||
scopes->ok = TRUE;
|
||||
}
|
||||
|
||||
static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, int proxy_render_size, int undistorted)
|
||||
{
|
||||
char name[FILE_MAX];
|
||||
int quality, rectx, recty;
|
||||
int size= rendersize_to_number(proxy_render_size);
|
||||
int size = rendersize_to_number(proxy_render_size);
|
||||
ImBuf *scaleibuf;
|
||||
|
||||
get_proxy_fname(clip, proxy_render_size, undistorted, cfra, name);
|
||||
|
||||
rectx= ibuf->x*size/100.0f;
|
||||
recty= ibuf->y*size/100.0f;
|
||||
rectx = ibuf->x * size / 100.0f;
|
||||
recty = ibuf->y * size / 100.0f;
|
||||
|
||||
scaleibuf= IMB_dupImBuf(ibuf);
|
||||
scaleibuf = IMB_dupImBuf(ibuf);
|
||||
|
||||
IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty);
|
||||
|
||||
quality= clip->proxy.quality;
|
||||
scaleibuf->ftype= JPG | quality;
|
||||
quality = clip->proxy.quality;
|
||||
scaleibuf->ftype = JPG | quality;
|
||||
|
||||
/* unsupported feature only confuses other s/w */
|
||||
if (scaleibuf->planes==32)
|
||||
scaleibuf->planes= 24;
|
||||
if (scaleibuf->planes == 32)
|
||||
scaleibuf->planes = 24;
|
||||
|
||||
BLI_lock_thread(LOCK_MOVIECLIP);
|
||||
|
||||
BLI_make_existing_file(name);
|
||||
if (IMB_saveiff(scaleibuf, name, IB_rect)==0)
|
||||
if (IMB_saveiff(scaleibuf, name, IB_rect) == 0)
|
||||
perror(name);
|
||||
|
||||
BLI_unlock_thread(LOCK_MOVIECLIP);
|
||||
@@ -1045,30 +1072,30 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i
|
||||
}
|
||||
|
||||
void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct MovieDistortion *distortion,
|
||||
int cfra, int *build_sizes, int build_count, int undistorted)
|
||||
int cfra, int *build_sizes, int build_count, int undistorted)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
MovieClipUser user;
|
||||
|
||||
user.framenr= cfra;
|
||||
user.render_flag= 0;
|
||||
user.render_size= MCLIP_PROXY_RENDER_SIZE_FULL;
|
||||
user.framenr = cfra;
|
||||
user.render_flag = 0;
|
||||
user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
|
||||
|
||||
ibuf= BKE_movieclip_get_ibuf_flag(clip, &user, clip_flag, MOVIECLIP_CACHE_SKIP);
|
||||
ibuf = BKE_movieclip_get_ibuf_flag(clip, &user, clip_flag, MOVIECLIP_CACHE_SKIP);
|
||||
|
||||
if (ibuf) {
|
||||
ImBuf *tmpibuf= ibuf;
|
||||
ImBuf *tmpibuf = ibuf;
|
||||
int i;
|
||||
|
||||
if (undistorted)
|
||||
tmpibuf= get_undistorted_ibuf(clip, distortion, ibuf);
|
||||
tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf);
|
||||
|
||||
for (i= 0; i<build_count; i++)
|
||||
for (i = 0; i < build_count; i++)
|
||||
movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted);
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
||||
if (tmpibuf!=ibuf)
|
||||
if (tmpibuf != ibuf)
|
||||
IMB_freeImBuf(tmpibuf);
|
||||
}
|
||||
}
|
||||
@@ -1088,53 +1115,53 @@ void unlink_movieclip(Main *bmain, MovieClip *clip)
|
||||
Scene *sce;
|
||||
Object *ob;
|
||||
|
||||
for (scr= bmain->screen.first; scr; scr= scr->id.next) {
|
||||
for (area= scr->areabase.first; area; area= area->next) {
|
||||
for (sl= area->spacedata.first; sl; sl= sl->next) {
|
||||
if (sl->spacetype==SPACE_CLIP) {
|
||||
SpaceClip *sc= (SpaceClip *) sl;
|
||||
for (scr = bmain->screen.first; scr; scr = scr->id.next) {
|
||||
for (area = scr->areabase.first; area; area = area->next) {
|
||||
for (sl = area->spacedata.first; sl; sl = sl->next) {
|
||||
if (sl->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *sc = (SpaceClip *) sl;
|
||||
|
||||
if (sc->clip==clip)
|
||||
sc->clip= NULL;
|
||||
if (sc->clip == clip)
|
||||
sc->clip = NULL;
|
||||
}
|
||||
else if (sl->spacetype==SPACE_VIEW3D) {
|
||||
View3D *v3d= (View3D *) sl;
|
||||
else if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *) sl;
|
||||
BGpic *bgpic;
|
||||
|
||||
for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) {
|
||||
if (bgpic->clip==clip)
|
||||
bgpic->clip= NULL;
|
||||
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
|
||||
if (bgpic->clip == clip)
|
||||
bgpic->clip = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (sce= bmain->scene.first; sce; sce= sce->id.next) {
|
||||
if (sce->clip==clip)
|
||||
sce->clip= NULL;
|
||||
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
|
||||
if (sce->clip == clip)
|
||||
sce->clip = NULL;
|
||||
}
|
||||
|
||||
for (ob= bmain->object.first; ob; ob= ob->id.next) {
|
||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||
bConstraint *con;
|
||||
|
||||
for (con= ob->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = ob->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
|
||||
if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
|
||||
bFollowTrackConstraint *data= (bFollowTrackConstraint *) con->data;
|
||||
if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
|
||||
bFollowTrackConstraint *data = (bFollowTrackConstraint *) con->data;
|
||||
|
||||
if (data->clip==clip)
|
||||
data->clip= NULL;
|
||||
if (data->clip == clip)
|
||||
data->clip = NULL;
|
||||
}
|
||||
else if (cti->type==CONSTRAINT_TYPE_CAMERASOLVER) {
|
||||
bCameraSolverConstraint *data= (bCameraSolverConstraint *) con->data;
|
||||
else if (cti->type == CONSTRAINT_TYPE_CAMERASOLVER) {
|
||||
bCameraSolverConstraint *data = (bCameraSolverConstraint *) con->data;
|
||||
|
||||
if (data->clip==clip)
|
||||
data->clip= NULL;
|
||||
if (data->clip == clip)
|
||||
data->clip = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clip->id.us= 0;
|
||||
clip->id.us = 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -67,11 +67,11 @@ void ED_clip_buttons_register(ARegionType *art)
|
||||
{
|
||||
PanelType *pt;
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype clip panel gpencil");
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel gpencil");
|
||||
strcpy(pt->idname, "CLIP_PT_gpencil");
|
||||
strcpy(pt->label, "Grease Pencil");
|
||||
pt->draw= gpencil_panel_standard;
|
||||
pt->flag|= PNL_DEFAULT_CLOSED;
|
||||
pt->draw = gpencil_panel_standard;
|
||||
pt->flag |= PNL_DEFAULT_CLOSED;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
|
||||
if (!ptr->data)
|
||||
return;
|
||||
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
prop = RNA_struct_find_property(ptr, propname);
|
||||
if (!prop) {
|
||||
printf("%s: property not found: %s.%s\n",
|
||||
__func__, RNA_struct_identifier(ptr->type), propname);
|
||||
@@ -101,8 +101,8 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
|
||||
return;
|
||||
}
|
||||
|
||||
clipptr= RNA_property_pointer_get(ptr, prop);
|
||||
clip= clipptr.data;
|
||||
clipptr = RNA_property_pointer_get(ptr, prop);
|
||||
clip = clipptr.data;
|
||||
|
||||
uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr);
|
||||
|
||||
@@ -110,13 +110,13 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
|
||||
uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL);
|
||||
|
||||
if (clip) {
|
||||
row= uiLayoutRow(layout, 0);
|
||||
block= uiLayoutGetBlock(row);
|
||||
row = uiLayoutRow(layout, 0);
|
||||
block = uiLayoutGetBlock(row);
|
||||
uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, "");
|
||||
|
||||
row= uiLayoutRow(layout, 0);
|
||||
row = uiLayoutRow(layout, 0);
|
||||
split = uiLayoutSplit(row, 0.0, 0);
|
||||
row= uiLayoutRow(split, 1);
|
||||
row = uiLayoutRow(split, 1);
|
||||
|
||||
uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE);
|
||||
uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload");
|
||||
@@ -136,7 +136,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
||||
if (!ptr->data)
|
||||
return;
|
||||
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
prop = RNA_struct_find_property(ptr, propname);
|
||||
if (!prop) {
|
||||
printf("%s: property not found: %s.%s\n",
|
||||
__func__, RNA_struct_identifier(ptr->type), propname);
|
||||
@@ -149,15 +149,15 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
||||
return;
|
||||
}
|
||||
|
||||
scopesptr= RNA_property_pointer_get(ptr, prop);
|
||||
scopes= (MovieClipScopes *)scopesptr.data;
|
||||
scopesptr = RNA_property_pointer_get(ptr, prop);
|
||||
scopes = (MovieClipScopes *)scopesptr.data;
|
||||
|
||||
rect.xmin = 0; rect.xmax = 200;
|
||||
rect.ymin = 0; rect.ymax = 120;
|
||||
|
||||
block= uiLayoutAbsoluteBlock(layout);
|
||||
block = uiLayoutAbsoluteBlock(layout);
|
||||
|
||||
scopes->track_preview_height= (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height;
|
||||
scopes->track_preview_height = (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height;
|
||||
|
||||
uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->track_preview_height, scopes, 0, 0, 0, 0, "");
|
||||
}
|
||||
@@ -189,89 +189,89 @@ typedef struct {
|
||||
static void to_pixel_space(float r[2], float a[2], int width, int height)
|
||||
{
|
||||
copy_v2_v2(r, a);
|
||||
r[0]*= width;
|
||||
r[1]*= height;
|
||||
r[0] *= width;
|
||||
r[1] *= height;
|
||||
}
|
||||
|
||||
static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
|
||||
{
|
||||
MarkerUpdateCb *cb= (MarkerUpdateCb*) arg_cb;
|
||||
MarkerUpdateCb *cb = (MarkerUpdateCb*) arg_cb;
|
||||
MovieTrackingMarker *marker;
|
||||
|
||||
if (!cb->compact)
|
||||
return;
|
||||
|
||||
marker= BKE_tracking_ensure_marker(cb->track, cb->framenr);
|
||||
marker = BKE_tracking_ensure_marker(cb->track, cb->framenr);
|
||||
|
||||
marker->flag= cb->marker_flag;
|
||||
marker->flag = cb->marker_flag;
|
||||
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL);
|
||||
}
|
||||
|
||||
static void marker_block_handler(bContext *C, void *arg_cb, int event)
|
||||
{
|
||||
MarkerUpdateCb *cb= (MarkerUpdateCb*) arg_cb;
|
||||
MarkerUpdateCb *cb = (MarkerUpdateCb*) arg_cb;
|
||||
MovieTrackingMarker *marker;
|
||||
int width, height, ok= 0;
|
||||
int width, height, ok = FALSE;
|
||||
|
||||
BKE_movieclip_get_size(cb->clip, cb->user, &width, &height);
|
||||
|
||||
marker= BKE_tracking_ensure_marker(cb->track, cb->framenr);
|
||||
marker = BKE_tracking_ensure_marker(cb->track, cb->framenr);
|
||||
|
||||
if (event==B_MARKER_POS) {
|
||||
marker->pos[0]= cb->marker_pos[0]/width;
|
||||
marker->pos[1]= cb->marker_pos[1]/height;
|
||||
if (event == B_MARKER_POS) {
|
||||
marker->pos[0] = cb->marker_pos[0]/width;
|
||||
marker->pos[1] = cb->marker_pos[1]/height;
|
||||
|
||||
/* to update position of "parented" objects */
|
||||
DAG_id_tag_update(&cb->clip->id, 0);
|
||||
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
ok= 1;
|
||||
ok = TRUE;
|
||||
}
|
||||
else if (event==B_MARKER_PAT_DIM) {
|
||||
else if (event == B_MARKER_PAT_DIM) {
|
||||
float dim[2], pat_dim[2];
|
||||
|
||||
sub_v2_v2v2(pat_dim, cb->track->pat_max, cb->track->pat_min);
|
||||
|
||||
dim[0]= cb->track_pat[0]/width;
|
||||
dim[1]= cb->track_pat[1]/height;
|
||||
dim[0] = cb->track_pat[0] / width;
|
||||
dim[1] = cb->track_pat[1] / height;
|
||||
|
||||
sub_v2_v2(dim, pat_dim);
|
||||
mul_v2_fl(dim, 0.5f);
|
||||
|
||||
cb->track->pat_min[0]-= dim[0];
|
||||
cb->track->pat_min[1]-= dim[1];
|
||||
cb->track->pat_min[0] -= dim[0];
|
||||
cb->track->pat_min[1] -= dim[1];
|
||||
|
||||
cb->track->pat_max[0]+= dim[0];
|
||||
cb->track->pat_max[1]+= dim[1];
|
||||
cb->track->pat_max[0] += dim[0];
|
||||
cb->track->pat_max[1] += dim[1];
|
||||
|
||||
BKE_tracking_clamp_track(cb->track, CLAMP_PAT_DIM);
|
||||
|
||||
ok= 1;
|
||||
ok = TRUE;
|
||||
}
|
||||
else if (event==B_MARKER_SEARCH_POS) {
|
||||
else if (event == B_MARKER_SEARCH_POS) {
|
||||
float delta[2], side[2];
|
||||
|
||||
sub_v2_v2v2(side, cb->track->search_max, cb->track->search_min);
|
||||
mul_v2_fl(side, 0.5f);
|
||||
|
||||
delta[0]= cb->track_search_pos[0]/width;
|
||||
delta[1]= cb->track_search_pos[1]/height;
|
||||
delta[0] = cb->track_search_pos[0] / width;
|
||||
delta[1] = cb->track_search_pos[1] / height;
|
||||
|
||||
sub_v2_v2v2(cb->track->search_min, delta, side);
|
||||
add_v2_v2v2(cb->track->search_max, delta, side);
|
||||
|
||||
BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_POS);
|
||||
|
||||
ok= 1;
|
||||
ok = TRUE;
|
||||
}
|
||||
else if (event==B_MARKER_SEARCH_DIM) {
|
||||
else if (event == B_MARKER_SEARCH_DIM) {
|
||||
float dim[2], search_dim[2];
|
||||
|
||||
sub_v2_v2v2(search_dim, cb->track->search_max, cb->track->search_min);
|
||||
|
||||
dim[0]= cb->track_search[0]/width;
|
||||
dim[1]= cb->track_search[1]/height;
|
||||
dim[0] = cb->track_search[0]/width;
|
||||
dim[1] = cb->track_search[1]/height;
|
||||
|
||||
sub_v2_v2(dim, search_dim);
|
||||
mul_v2_fl(dim, 0.5f);
|
||||
@@ -284,31 +284,31 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
|
||||
|
||||
BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM);
|
||||
|
||||
ok= 1;
|
||||
ok = TRUE;
|
||||
}
|
||||
else if (event==B_MARKER_FLAG) {
|
||||
marker->flag= cb->marker_flag;
|
||||
else if (event == B_MARKER_FLAG) {
|
||||
marker->flag = cb->marker_flag;
|
||||
|
||||
ok= 1;
|
||||
ok = TRUE;
|
||||
}
|
||||
else if (event==B_MARKER_OFFSET) {
|
||||
else if (event == B_MARKER_OFFSET) {
|
||||
float offset[2], delta[2];
|
||||
int i;
|
||||
|
||||
offset[0]= cb->track_offset[0]/width;
|
||||
offset[1]= cb->track_offset[1]/height;
|
||||
offset[0] = cb->track_offset[0] / width;
|
||||
offset[1] = cb->track_offset[1] / height;
|
||||
|
||||
sub_v2_v2v2(delta, offset, cb->track->offset);
|
||||
copy_v2_v2(cb->track->offset, offset);
|
||||
|
||||
for (i=0; i<cb->track->markersnr; i++)
|
||||
for (i = 0; i < cb->track->markersnr; i++)
|
||||
sub_v2_v2(cb->track->markers[i].pos, delta);
|
||||
|
||||
/* to update position of "parented" objects */
|
||||
DAG_id_tag_update(&cb->clip->id, 0);
|
||||
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
ok= 1;
|
||||
ok = TRUE;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
@@ -331,7 +331,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
|
||||
if (!ptr->data)
|
||||
return;
|
||||
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
prop = RNA_struct_find_property(ptr, propname);
|
||||
if (!prop) {
|
||||
printf("%s: property not found: %s.%s\n",
|
||||
__func__, RNA_struct_identifier(ptr->type), propname);
|
||||
@@ -344,30 +344,30 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
|
||||
return;
|
||||
}
|
||||
|
||||
clipptr= RNA_property_pointer_get(ptr, prop);
|
||||
clip= (MovieClip *)clipptr.data;
|
||||
user= userptr->data;
|
||||
track= trackptr->data;
|
||||
clipptr = RNA_property_pointer_get(ptr, prop);
|
||||
clip = (MovieClip *)clipptr.data;
|
||||
user = userptr->data;
|
||||
track = trackptr->data;
|
||||
|
||||
marker= BKE_tracking_get_marker(track, user->framenr);
|
||||
marker = BKE_tracking_get_marker(track, user->framenr);
|
||||
|
||||
cb= MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
|
||||
cb->compact= compact;
|
||||
cb->clip= clip;
|
||||
cb->user= user;
|
||||
cb->track= track;
|
||||
cb->marker_flag= marker->flag;
|
||||
cb->framenr= user->framenr;
|
||||
cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
|
||||
cb->compact = compact;
|
||||
cb->clip = clip;
|
||||
cb->user = user;
|
||||
cb->track = track;
|
||||
cb->marker_flag = marker->flag;
|
||||
cb->framenr = user->framenr;
|
||||
|
||||
if (compact) {
|
||||
block= uiLayoutGetBlock(layout);
|
||||
block = uiLayoutGetBlock(layout);
|
||||
|
||||
if (cb->marker_flag&MARKER_DISABLED)
|
||||
if (cb->marker_flag & MARKER_DISABLED)
|
||||
tip= "Marker is disabled at current frame";
|
||||
else
|
||||
tip= "Marker is enabled at current frame";
|
||||
|
||||
bt= uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, &cb->marker_flag, 0, 0, 1, 0, tip);
|
||||
bt = uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, &cb->marker_flag, 0, 0, 1, 0, tip);
|
||||
uiButSetNFunc(bt, marker_update_cb, cb, NULL);
|
||||
}
|
||||
else {
|
||||
@@ -377,16 +377,16 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
|
||||
|
||||
BKE_movieclip_get_size(clip, user, &width, &height);
|
||||
|
||||
if (track->flag&TRACK_LOCKED) {
|
||||
if (track->flag & TRACK_LOCKED) {
|
||||
uiLayoutSetActive(layout, 0);
|
||||
block= uiLayoutAbsoluteBlock(layout);
|
||||
block = uiLayoutAbsoluteBlock(layout);
|
||||
uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, "");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
step= 100;
|
||||
digits= 2;
|
||||
digits = 2;
|
||||
|
||||
sub_v2_v2v2(pat_dim, track->pat_max, track->pat_min);
|
||||
sub_v2_v2v2(search_dim, track->search_max, track->search_min);
|
||||
@@ -403,13 +403,13 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
|
||||
to_pixel_space(cb->track_search_pos, search_pos, width, height);
|
||||
to_pixel_space(cb->track_offset, track->offset, width, height);
|
||||
|
||||
cb->marker_flag= marker->flag;
|
||||
cb->marker_flag = marker->flag;
|
||||
|
||||
block= uiLayoutAbsoluteBlock(layout);
|
||||
uiBlockSetHandleFunc(block, marker_block_handler, cb);
|
||||
uiBlockSetNFunc(block, marker_update_cb, cb, NULL);
|
||||
|
||||
if (cb->marker_flag&MARKER_DISABLED)
|
||||
if (cb->marker_flag & MARKER_DISABLED)
|
||||
tip= "Marker is disabled at current frame";
|
||||
else
|
||||
tip= "Marker is enabled at current frame";
|
||||
@@ -417,10 +417,10 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
|
||||
uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &cb->marker_flag,
|
||||
0, 0, 0, 0, tip);
|
||||
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiLayoutSetActive(col, (cb->marker_flag&MARKER_DISABLED)==0);
|
||||
|
||||
block= uiLayoutAbsoluteBlock(col);
|
||||
block = uiLayoutAbsoluteBlock(col);
|
||||
uiBlockBeginAlign(block);
|
||||
|
||||
uiDefBut(block, LABEL, 0, "Position:", 0, 190, 300, 19, NULL, 0, 0, 0, 0, "");
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -57,20 +57,20 @@
|
||||
|
||||
int ED_space_clip_poll(bContext *C)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
|
||||
if (sc && sc->clip)
|
||||
return 1;
|
||||
return TRUE;
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip)
|
||||
{
|
||||
sc->clip= clip;
|
||||
sc->clip = clip;
|
||||
|
||||
if (sc->clip && sc->clip->id.us==0)
|
||||
sc->clip->id.us= 1;
|
||||
sc->clip->id.us = 1;
|
||||
|
||||
if (C)
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|NA_SELECTED, sc->clip);
|
||||
@@ -86,7 +86,7 @@ ImBuf *ED_space_clip_get_buffer(SpaceClip *sc)
|
||||
if (sc->clip) {
|
||||
ImBuf *ibuf;
|
||||
|
||||
ibuf= BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag);
|
||||
ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag);
|
||||
|
||||
if (ibuf && (ibuf->rect || ibuf->rect_float))
|
||||
return ibuf;
|
||||
@@ -103,7 +103,7 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale
|
||||
if (sc->clip) {
|
||||
ImBuf *ibuf;
|
||||
|
||||
ibuf= BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag);
|
||||
ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag);
|
||||
|
||||
if (ibuf && (ibuf->rect || ibuf->rect_float))
|
||||
return ibuf;
|
||||
@@ -131,18 +131,18 @@ void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy)
|
||||
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
|
||||
*zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
|
||||
*zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
|
||||
*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
|
||||
*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
|
||||
}
|
||||
|
||||
void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy)
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
|
||||
if (clip)
|
||||
BKE_movieclip_aspect(clip, aspx, aspy);
|
||||
else
|
||||
*aspx= *aspy= 1.0f;
|
||||
*aspx = *aspy = 1.0f;
|
||||
}
|
||||
|
||||
void ED_clip_update_frame(const Main *mainp, int cfra)
|
||||
@@ -151,14 +151,15 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
|
||||
wmWindow *win;
|
||||
|
||||
/* image window, compo node users */
|
||||
for (wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */
|
||||
for (win= wm->windows.first; win; win= win->next) {
|
||||
for (wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
|
||||
for (win = wm->windows.first; win; win = win->next) {
|
||||
ScrArea *sa;
|
||||
for (sa= win->screen->areabase.first; sa; sa= sa->next) {
|
||||
if (sa->spacetype==SPACE_CLIP) {
|
||||
SpaceClip *sc= sa->spacedata.first;
|
||||
|
||||
sc->scopes.ok= 0;
|
||||
for (sa = win->screen->areabase.first; sa; sa = sa->next) {
|
||||
if (sa->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
|
||||
sc->scopes.ok = FALSE;
|
||||
|
||||
BKE_movieclip_user_set_frame(&sc->user, cfra);
|
||||
}
|
||||
@@ -169,44 +170,45 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
|
||||
|
||||
static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTrackingTrack *track;
|
||||
int width, height, ok= 0;
|
||||
int width, height, ok = FALSE;
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
|
||||
|
||||
INIT_MINMAX2(min, max);
|
||||
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
|
||||
track= tracksbase->first;
|
||||
track = tracksbase->first;
|
||||
while (track) {
|
||||
if (TRACK_VIEW_SELECTED(sc, track)) {
|
||||
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr);
|
||||
MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.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;
|
||||
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)
|
||||
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;
|
||||
pos[0] *= width;
|
||||
pos[1] *= height;
|
||||
|
||||
mul_v3_m4v3(pos, sc->stabmat, pos);
|
||||
|
||||
DO_MINMAX2(pos, min, max);
|
||||
|
||||
ok= 1;
|
||||
ok = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
track= track->next;
|
||||
track = track->next;
|
||||
}
|
||||
|
||||
return ok;
|
||||
@@ -219,90 +221,92 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit)
|
||||
|
||||
ED_space_clip_size(sc, &frame_width, &frame_height);
|
||||
|
||||
if (frame_width==0 || frame_height==0) return 0;
|
||||
if (frame_width == 0 || frame_height == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!selected_boundbox(sc, min, max))
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
/* center view */
|
||||
clip_view_center_to_point(sc, (max[0]+min[0])/(2*frame_width), (max[1]+min[1])/(2*frame_height));
|
||||
|
||||
w= max[0]-min[0];
|
||||
h= max[1]-min[1];
|
||||
w = max[0] - min[0];
|
||||
h = max[1] - min[1];
|
||||
|
||||
/* set zoom to see all selection */
|
||||
if (w>0 && h>0) {
|
||||
if (w > 0 && h > 0) {
|
||||
int width, height;
|
||||
float zoomx, zoomy, newzoom, aspx, aspy;
|
||||
|
||||
ED_space_clip_aspect(sc, &aspx, &aspy);
|
||||
|
||||
width= ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
height= ar->winrct.ymax - ar->winrct.ymin + 1;
|
||||
width = ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
height = ar->winrct.ymax - ar->winrct.ymin + 1;
|
||||
|
||||
zoomx= (float)width/w/aspx;
|
||||
zoomy= (float)height/h/aspy;
|
||||
zoomx = (float)width / w / aspx;
|
||||
zoomy = (float)height / h / aspy;
|
||||
|
||||
newzoom= 1.0f/power_of_2(1/MIN2(zoomx, zoomy));
|
||||
newzoom = 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy));
|
||||
|
||||
if (fit || sc->zoom>newzoom)
|
||||
sc->zoom= newzoom;
|
||||
sc->zoom = newzoom;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2])
|
||||
{
|
||||
copy_v2_v2(nco, co);
|
||||
|
||||
if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) {
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
float aspy= 1.0f/clip->tracking.camera.pixel_aspect;
|
||||
if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
float aspy = 1.0f / clip->tracking.camera.pixel_aspect;
|
||||
int width, height;
|
||||
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
|
||||
nco[0]*= width;
|
||||
nco[1]*= height*aspy;
|
||||
nco[0] *= width;
|
||||
nco[1] *= height * aspy;
|
||||
|
||||
BKE_tracking_invert_intrinsics(&clip->tracking, nco, nco);
|
||||
nco[0]/= width;
|
||||
nco[1]/= height*aspy;
|
||||
|
||||
nco[0] /= width;
|
||||
nco[1] /= height * aspy;
|
||||
}
|
||||
}
|
||||
|
||||
void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *yr)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
int sx, sy, width, height;
|
||||
float zoomx, zoomy, pos[3]={0.0f, 0.0f, 0.0f}, imat[4][4];
|
||||
float zoomx, zoomy, pos[3] = {0.0f, 0.0f, 0.0f}, imat[4][4];
|
||||
|
||||
ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
|
||||
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
|
||||
|
||||
pos[0]= (x-sx)/zoomx;
|
||||
pos[1]= (y-sy)/zoomy;
|
||||
pos[0] = (x - sx) / zoomx;
|
||||
pos[1] = (y - sy) / zoomy;
|
||||
|
||||
invert_m4_m4(imat, sc->stabmat);
|
||||
mul_v3_m4v3(pos, imat, pos);
|
||||
|
||||
*xr= pos[0]/width;
|
||||
*yr= pos[1]/height;
|
||||
*xr = pos[0] / width;
|
||||
*yr = pos[1] / height;
|
||||
|
||||
if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) {
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
float aspy= 1.0f/tracking->camera.pixel_aspect;
|
||||
float tmp[2]= {*xr*width, *yr*height*aspy};
|
||||
if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
float aspy = 1.0f / tracking->camera.pixel_aspect;
|
||||
float tmp[2] = {*xr * width, *yr * height * aspy};
|
||||
|
||||
BKE_tracking_apply_intrinsics(tracking, tmp, tmp);
|
||||
|
||||
*xr= tmp[0]/width;
|
||||
*yr= tmp[1]/(height*aspy);
|
||||
*xr = tmp[0] / width;
|
||||
*yr = tmp[1] / (height * aspy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -67,10 +67,10 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float
|
||||
if (displist == 0) {
|
||||
GLUquadricObj *qobj;
|
||||
|
||||
displist= glGenLists(1);
|
||||
displist = glGenLists(1);
|
||||
glNewList(displist, GL_COMPILE);
|
||||
|
||||
qobj= gluNewQuadric();
|
||||
qobj = gluNewQuadric();
|
||||
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
|
||||
gluDisk(qobj, 0, 0.7, 8, 1);
|
||||
gluDeleteQuadric(qobj);
|
||||
@@ -89,21 +89,21 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float
|
||||
|
||||
static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
|
||||
{
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2D *v2d = &ar->v2d;
|
||||
float xscale, yscale;
|
||||
float vec[2];
|
||||
|
||||
/* Draw a light green line to indicate current frame */
|
||||
vec[0]= (float)(sc->user.framenr * scene->r.framelen);
|
||||
vec[0] = (float)(sc->user.framenr * scene->r.framelen);
|
||||
|
||||
UI_ThemeColor(TH_CFRAME);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
vec[1]= v2d->cur.ymin;
|
||||
vec[1] = v2d->cur.ymin;
|
||||
glVertex2fv(vec);
|
||||
|
||||
vec[1]= v2d->cur.ymax;
|
||||
vec[1] = v2d->cur.ymax;
|
||||
glVertex2fv(vec);
|
||||
glEnd();
|
||||
|
||||
@@ -156,11 +156,11 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co
|
||||
copy_v3_v3(col, colors[coord]);
|
||||
|
||||
if (track==userdata) {
|
||||
col[3]= 1.0f;
|
||||
col[3] = 1.0f;
|
||||
glLineWidth(2.0f);
|
||||
}
|
||||
else {
|
||||
col[3]= 0.5f;
|
||||
col[3] = 0.5f;
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
|
||||
@@ -182,15 +182,17 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
|
||||
struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } *data = userdata;
|
||||
int sel= 0, sel_flag;
|
||||
|
||||
if (track!=data->act_track)
|
||||
if (track != data->act_track)
|
||||
return;
|
||||
|
||||
sel_flag= coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y;
|
||||
sel= (marker->flag & sel_flag) ? 1 : 0;
|
||||
sel_flag = coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y;
|
||||
sel = (marker->flag & sel_flag) ? 1 : 0;
|
||||
|
||||
if (sel == data->sel) {
|
||||
if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
|
||||
else UI_ThemeColor(TH_HANDLE_VERTEX);
|
||||
if (sel)
|
||||
UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
|
||||
else
|
||||
UI_ThemeColor(TH_HANDLE_VERTEX);
|
||||
|
||||
draw_curve_knot(marker->framenr, val, data->xscale, data->yscale, data->hsize);
|
||||
}
|
||||
@@ -198,9 +200,9 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
|
||||
|
||||
static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
int width, height;
|
||||
struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } userdata;
|
||||
|
||||
@@ -210,9 +212,9 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
|
||||
return;
|
||||
|
||||
/* non-selected knot handles */
|
||||
userdata.hsize= UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
|
||||
userdata.sel= 0;
|
||||
userdata.act_track= act_track;
|
||||
userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
|
||||
userdata.sel = FALSE;
|
||||
userdata.act_track = act_track;
|
||||
UI_view2d_getscale(v2d, &userdata.xscale, &userdata.yscale);
|
||||
clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL);
|
||||
|
||||
@@ -222,35 +224,35 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* selected knot handles on top of curves */
|
||||
userdata.sel= 1;
|
||||
userdata.sel= TRUE;
|
||||
clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
static void draw_frame_curves(SpaceClip *sc)
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTrackingReconstruction *reconstruction= BKE_tracking_get_reconstruction(tracking);
|
||||
int i, lines= 0, prevfra= 0;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(tracking);
|
||||
int i, lines = 0, prevfra = 0;
|
||||
|
||||
glColor3f(0.0f, 0.0f, 1.0f);
|
||||
|
||||
for (i= 0; i<reconstruction->camnr; i++) {
|
||||
MovieReconstructedCamera *camera= &reconstruction->cameras[i];
|
||||
for (i = 0; i<reconstruction->camnr; i++) {
|
||||
MovieReconstructedCamera *camera = &reconstruction->cameras[i];
|
||||
|
||||
if (lines && camera->framenr!=prevfra+1) {
|
||||
glEnd();
|
||||
lines= 0;
|
||||
lines = 0;
|
||||
}
|
||||
|
||||
if (!lines) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
lines= 1;
|
||||
lines = 1;
|
||||
}
|
||||
|
||||
glVertex2f(camera->framenr, camera->error);
|
||||
|
||||
prevfra= camera->framenr;
|
||||
prevfra = camera->framenr;
|
||||
}
|
||||
|
||||
if (lines)
|
||||
@@ -259,21 +261,21 @@ static void draw_frame_curves(SpaceClip *sc)
|
||||
|
||||
void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
View2D *v2d= &ar->v2d;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
View2D *v2d = &ar->v2d;
|
||||
View2DGrid *grid;
|
||||
short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES;
|
||||
short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES;
|
||||
|
||||
/* grid */
|
||||
grid= UI_view2d_grid_calc(scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
|
||||
grid = UI_view2d_grid_calc(scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
|
||||
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
|
||||
UI_view2d_grid_free(grid);
|
||||
|
||||
if (clip) {
|
||||
if (sc->flag&SC_SHOW_GRAPH_TRACKS)
|
||||
if (sc->flag & SC_SHOW_GRAPH_TRACKS)
|
||||
draw_tracks_curves(v2d, sc);
|
||||
|
||||
if (sc->flag&SC_SHOW_GRAPH_FRAMES)
|
||||
if (sc->flag & SC_SHOW_GRAPH_FRAMES)
|
||||
draw_frame_curves(sc);
|
||||
}
|
||||
|
||||
|
@@ -80,17 +80,17 @@ typedef struct {
|
||||
|
||||
static void toggle_selection_cb(void *userdata, MovieTrackingMarker *marker)
|
||||
{
|
||||
SelectUserData *data= (SelectUserData *)userdata;
|
||||
SelectUserData *data = (SelectUserData *)userdata;
|
||||
|
||||
switch(data->action) {
|
||||
case SEL_SELECT:
|
||||
marker->flag|= MARKER_GRAPH_SEL;
|
||||
marker->flag |= MARKER_GRAPH_SEL;
|
||||
break;
|
||||
case SEL_DESELECT:
|
||||
marker->flag&= ~MARKER_GRAPH_SEL;
|
||||
marker->flag &= ~MARKER_GRAPH_SEL;
|
||||
break;
|
||||
case SEL_INVERT:
|
||||
marker->flag^= MARKER_GRAPH_SEL;
|
||||
marker->flag ^= MARKER_GRAPH_SEL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -111,47 +111,47 @@ typedef struct {
|
||||
} MouseSelectUserData;
|
||||
|
||||
static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack *track,
|
||||
MovieTrackingMarker *marker, int coord, float val)
|
||||
MovieTrackingMarker *marker, int coord, float val)
|
||||
{
|
||||
MouseSelectUserData *data= userdata;
|
||||
float co[2]= {marker->framenr, val};
|
||||
MouseSelectUserData *data = userdata;
|
||||
float co[2] = {marker->framenr, val};
|
||||
|
||||
if (data->has_prev) {
|
||||
float d= dist_to_line_segment_v2(data->mouse_co, data->prev_co, co);
|
||||
float d = dist_to_line_segment_v2(data->mouse_co, data->prev_co, co);
|
||||
|
||||
if (data->track==NULL || d<data->min_dist) {
|
||||
data->track= track;
|
||||
data->min_dist= d;
|
||||
data->coord= coord;
|
||||
if (data->track == NULL || d < data->min_dist) {
|
||||
data->track = track;
|
||||
data->min_dist = d;
|
||||
data->coord = coord;
|
||||
copy_v2_v2(data->min_co, co);
|
||||
}
|
||||
}
|
||||
|
||||
data->has_prev= 1;
|
||||
data->has_prev = TRUE;
|
||||
copy_v2_v2(data->prev_co, co);
|
||||
}
|
||||
|
||||
void find_nearest_tracking_segment_end_cb(void *userdata)
|
||||
{
|
||||
MouseSelectUserData *data= userdata;
|
||||
MouseSelectUserData *data = userdata;
|
||||
|
||||
data->has_prev= 0;
|
||||
data->has_prev = FALSE;
|
||||
}
|
||||
|
||||
static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *track,
|
||||
MovieTrackingMarker *marker, int coord, float val)
|
||||
MovieTrackingMarker *marker, int coord, float val)
|
||||
{
|
||||
MouseSelectUserData *data= userdata;
|
||||
float dx= marker->framenr-data->mouse_co[0], dy= val-data->mouse_co[1];
|
||||
float d= dx*dx+dy*dy;
|
||||
MouseSelectUserData *data = userdata;
|
||||
float dx = marker->framenr - data->mouse_co[0], dy = val - data->mouse_co[1];
|
||||
float d = dx * dx + dy * dy;
|
||||
|
||||
if (data->marker==NULL || d<data->min_dist) {
|
||||
if (data->marker == NULL || d < data->min_dist) {
|
||||
float co[2]= {marker->framenr, val};
|
||||
|
||||
data->track= track;
|
||||
data->marker= marker;
|
||||
data->min_dist= d;
|
||||
data->coord= coord;
|
||||
data->track = track;
|
||||
data->marker = marker;
|
||||
data->min_dist = d;
|
||||
data->coord = coord;
|
||||
copy_v2_v2(data->min_co, co);
|
||||
}
|
||||
|
||||
@@ -160,26 +160,26 @@ static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *tr
|
||||
static void mouse_select_init_data(MouseSelectUserData *userdata, float *co)
|
||||
{
|
||||
memset(userdata, 0, sizeof(MouseSelectUserData));
|
||||
userdata->min_dist= FLT_MAX;
|
||||
userdata->min_dist = FLT_MAX;
|
||||
copy_v2_v2(userdata->mouse_co, co);
|
||||
}
|
||||
|
||||
static int mouse_select_knot(bContext *C, float co[2], int extend)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
View2D *v2d= &ar->v2d;
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
static const int delta= 6;
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View2D *v2d = &ar->v2d;
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
static const int delta = 6;
|
||||
|
||||
if (act_track) {
|
||||
MouseSelectUserData userdata;
|
||||
|
||||
mouse_select_init_data(&userdata, co);
|
||||
clip_graph_tracking_values_iterate_track(sc, act_track,
|
||||
&userdata, find_nearest_tracking_knot_cb, NULL, NULL);
|
||||
clip_graph_tracking_values_iterate_track(sc, act_track, &userdata,
|
||||
find_nearest_tracking_knot_cb, NULL, NULL);
|
||||
|
||||
if (userdata.marker) {
|
||||
int x1, y1, x2, y2;
|
||||
@@ -187,51 +187,53 @@ static int mouse_select_knot(bContext *C, float co[2], int extend)
|
||||
UI_view2d_view_to_region(v2d, co[0], co[1], &x1, &y1);
|
||||
UI_view2d_view_to_region(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2);
|
||||
|
||||
if (abs(x2-x1)<=delta && abs(y2-y1)<=delta) {
|
||||
if (abs(x2 - x1) <= delta && abs(y2 - y1) <= delta) {
|
||||
if (!extend) {
|
||||
SelectUserData selectdata = {SEL_DESELECT};
|
||||
|
||||
clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb);
|
||||
}
|
||||
|
||||
if (userdata.coord==0)
|
||||
userdata.marker->flag|= MARKER_GRAPH_SEL_X;
|
||||
if (userdata.coord == 0)
|
||||
userdata.marker->flag |= MARKER_GRAPH_SEL_X;
|
||||
else
|
||||
userdata.marker->flag|= MARKER_GRAPH_SEL_Y;
|
||||
userdata.marker->flag |= MARKER_GRAPH_SEL_Y;
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int mouse_select_curve(bContext *C, float co[2], int extend)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
MouseSelectUserData userdata;
|
||||
|
||||
mouse_select_init_data(&userdata, co);
|
||||
clip_graph_tracking_values_iterate(sc, &userdata, find_nearest_tracking_segment_cb, NULL, find_nearest_tracking_segment_end_cb);
|
||||
clip_graph_tracking_values_iterate(sc, &userdata, find_nearest_tracking_segment_cb,
|
||||
NULL, find_nearest_tracking_segment_end_cb);
|
||||
|
||||
if (userdata.track) {
|
||||
if (extend) {
|
||||
if (act_track==userdata.track) {
|
||||
if (act_track == userdata.track) {
|
||||
/* currently only single curve can be selected (selected curve represents active track) */
|
||||
act_track= NULL;
|
||||
act_track = NULL;
|
||||
}
|
||||
}
|
||||
else if (act_track!=userdata.track) {
|
||||
else if (act_track != userdata.track) {
|
||||
MovieTrackingMarker *marker;
|
||||
SelectUserData selectdata = {SEL_DESELECT};
|
||||
|
||||
tracking->act_track= userdata.track;
|
||||
tracking->act_track = userdata.track;
|
||||
|
||||
/* make active track be centered to screen */
|
||||
marker= BKE_tracking_get_marker(userdata.track, sc->user.framenr);
|
||||
marker = BKE_tracking_get_marker(userdata.track, sc->user.framenr);
|
||||
|
||||
clip_view_center_to_point(sc, marker->pos[0], marker->pos[1]);
|
||||
|
||||
@@ -239,22 +241,22 @@ static int mouse_select_curve(bContext *C, float co[2], int extend)
|
||||
clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int mouse_select(bContext *C, float co[2], int extend)
|
||||
{
|
||||
int sel= 0;
|
||||
int sel = FALSE;
|
||||
|
||||
/* first try to select knot on selected curves */
|
||||
sel= mouse_select_knot(C, co, extend);
|
||||
sel = mouse_select_knot(C, co, extend);
|
||||
|
||||
if (!sel) {
|
||||
/* if there's no close enough knot to mouse osition, select nearest curve */
|
||||
sel= mouse_select_curve(C, co, extend);
|
||||
sel = mouse_select_curve(C, co, extend);
|
||||
}
|
||||
|
||||
if (sel)
|
||||
@@ -266,7 +268,7 @@ static int mouse_select(bContext *C, float co[2], int extend)
|
||||
static int select_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
float co[2];
|
||||
int extend= RNA_boolean_get(op->ptr, "extend");
|
||||
int extend = RNA_boolean_get(op->ptr, "extend");
|
||||
|
||||
RNA_float_get_array(op->ptr, "location", co);
|
||||
|
||||
@@ -275,7 +277,7 @@ static int select_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
float co[2];
|
||||
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
|
||||
@@ -343,8 +345,8 @@ static int border_select_graph_exec(bContext *C, wmOperator *op)
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
BorderSelectuserData userdata;
|
||||
rcti rect;
|
||||
|
||||
@@ -399,7 +401,7 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op)
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
MovieTrackingMarker *marker;
|
||||
int action = RNA_enum_get(op->ptr, "action");
|
||||
int a;
|
||||
@@ -462,11 +464,11 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot)
|
||||
|
||||
static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(tracking);
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
|
||||
if (act_track)
|
||||
clip_delete_track(C, clip, tracksbase, act_track);
|
||||
@@ -494,17 +496,17 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot)
|
||||
|
||||
static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(tracking);
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
|
||||
if (act_track) {
|
||||
int a= 0;
|
||||
int a = 0;
|
||||
|
||||
while (a<act_track->markersnr) {
|
||||
MovieTrackingMarker *marker= &act_track->markers[a];
|
||||
while (a < act_track->markersnr) {
|
||||
MovieTrackingMarker *marker = &act_track->markers[a];
|
||||
|
||||
if (marker->flag & MARKER_GRAPH_SEL)
|
||||
clip_delete_marker(C, clip, tracksbase, act_track, marker);
|
||||
@@ -540,10 +542,13 @@ typedef struct {
|
||||
static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *UNUSED(marker),
|
||||
int UNUSED(coord), float val)
|
||||
{
|
||||
ViewAllUserData *data = (ViewAllUserData *)userdata;
|
||||
ViewAllUserData *data = (ViewAllUserData *) userdata;
|
||||
|
||||
if (val < data->min) data->min = val;
|
||||
if (val > data->max) data->max = val;
|
||||
if (val < data->min)
|
||||
data->min = val;
|
||||
|
||||
if (val > data->max)
|
||||
data->max = val;
|
||||
}
|
||||
|
||||
static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
@@ -561,8 +566,8 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
clip_graph_tracking_values_iterate(sc, &userdata, view_all_cb, NULL, NULL);
|
||||
|
||||
/* set extents of view to start/end frames */
|
||||
v2d->cur.xmin = (float)SFRA;
|
||||
v2d->cur.xmax = (float)EFRA;
|
||||
v2d->cur.xmin = (float) SFRA;
|
||||
v2d->cur.xmax = (float) EFRA;
|
||||
|
||||
if (userdata.min < userdata.max) {
|
||||
v2d->cur.ymin = userdata.min;
|
||||
@@ -574,11 +579,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
|
||||
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
|
||||
extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
v2d->cur.xmin -= extra;
|
||||
v2d->cur.xmax += extra;
|
||||
|
||||
extra= 0.01f * (v2d->cur.ymax - v2d->cur.ymin);
|
||||
extra = 0.01f * (v2d->cur.ymax - v2d->cur.ymin);
|
||||
v2d->cur.ymin -= extra;
|
||||
v2d->cur.ymax += extra;
|
||||
|
||||
|
@@ -97,7 +97,7 @@ void clip_graph_tracking_values_iterate(struct SpaceClip *sc, void *userdata,
|
||||
void (*segment_end) (void *userdata));
|
||||
|
||||
void clip_graph_tracking_iterate(struct SpaceClip *sc, void *userdata,
|
||||
void (*func) (void *userdata, struct MovieTrackingMarker *marker));
|
||||
void (*func) (void *userdata, struct MovieTrackingMarker *marker));
|
||||
|
||||
void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track);
|
||||
void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker);
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -70,31 +70,31 @@
|
||||
|
||||
static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float location[2])
|
||||
{
|
||||
float oldzoom= sc->zoom;
|
||||
float oldzoom = sc->zoom;
|
||||
int width, height;
|
||||
|
||||
sc->zoom= zoom;
|
||||
sc->zoom = zoom;
|
||||
|
||||
if (sc->zoom < 0.1f || sc->zoom > 4.0f) {
|
||||
/* check zoom limits */
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
|
||||
width*= sc->zoom;
|
||||
height*= sc->zoom;
|
||||
width *= sc->zoom;
|
||||
height *= sc->zoom;
|
||||
|
||||
if ((width < 4) && (height < 4))
|
||||
sc->zoom= oldzoom;
|
||||
sc->zoom = oldzoom;
|
||||
else if ((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom)
|
||||
sc->zoom= oldzoom;
|
||||
sc->zoom = oldzoom;
|
||||
else if ((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom)
|
||||
sc->zoom= oldzoom;
|
||||
sc->zoom = oldzoom;
|
||||
}
|
||||
|
||||
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
|
||||
sc->xof+= ((location[0]-0.5f)*width-sc->xof)*(sc->zoom-oldzoom)/sc->zoom;
|
||||
sc->yof+= ((location[1]-0.5f)*height-sc->yof)*(sc->zoom-oldzoom)/sc->zoom;
|
||||
sc->xof += ((location[0] - 0.5f) * width-sc->xof) * (sc->zoom-oldzoom) / sc->zoom;
|
||||
sc->yof += ((location[1] - 0.5f) * height-sc->yof) * (sc->zoom-oldzoom) / sc->zoom;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ static void sclip_zoom_set_factor(SpaceClip *sc, ARegion *ar, float zoomfac, flo
|
||||
|
||||
static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
float location[2], *mpos = NULL;
|
||||
|
||||
if (event) {
|
||||
@@ -124,6 +124,7 @@ static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor
|
||||
static void clip_filesel(bContext *C, wmOperator *op, const char *path)
|
||||
{
|
||||
RNA_string_set(op->ptr, "filepath", path);
|
||||
|
||||
WM_event_add_fileselect(C, op);
|
||||
}
|
||||
|
||||
@@ -131,32 +132,32 @@ static void open_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
PropertyPointerRNA *pprop;
|
||||
|
||||
op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
|
||||
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
|
||||
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
|
||||
}
|
||||
|
||||
static int open_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata= NULL;
|
||||
op->customdata = NULL;
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int open_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
PropertyPointerRNA *pprop;
|
||||
PointerRNA idptr;
|
||||
MovieClip *clip= NULL;
|
||||
MovieClip *clip = NULL;
|
||||
char str[FILE_MAX];
|
||||
|
||||
RNA_string_get(op->ptr, "filepath", str);
|
||||
/* default to frame 1 if there's no scene in context */
|
||||
|
||||
errno= 0;
|
||||
errno = 0;
|
||||
|
||||
clip= BKE_add_movieclip_file(str);
|
||||
clip = BKE_add_movieclip_file(str);
|
||||
|
||||
if (!clip) {
|
||||
if (op->customdata)
|
||||
@@ -171,7 +172,7 @@ static int open_exec(bContext *C, wmOperator *op)
|
||||
open_init(C, op);
|
||||
|
||||
/* hook into UI */
|
||||
pprop= op->customdata;
|
||||
pprop = op->customdata;
|
||||
|
||||
if (pprop->prop) {
|
||||
/* when creating new ID blocks, use is already 1, but RNA
|
||||
@@ -195,15 +196,15 @@ static int open_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
char *path= U.textudir;
|
||||
MovieClip *clip= NULL;
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
char *path = U.textudir;
|
||||
MovieClip *clip = NULL;
|
||||
|
||||
if (sc)
|
||||
clip= ED_space_clip(sc);
|
||||
clip = ED_space_clip(sc);
|
||||
|
||||
if (clip)
|
||||
path= clip->name;
|
||||
path = clip->name;
|
||||
|
||||
if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
@@ -241,7 +242,7 @@ void CLIP_OT_open(wmOperatorType *ot)
|
||||
|
||||
static int reload_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
MovieClip *clip= CTX_data_edit_movieclip(C);
|
||||
MovieClip *clip = CTX_data_edit_movieclip(C);
|
||||
|
||||
if (!clip)
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -275,17 +276,19 @@ typedef struct ViewPanData {
|
||||
|
||||
static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ViewPanData *vpd;
|
||||
|
||||
op->customdata= vpd= MEM_callocN(sizeof(ViewPanData), "ClipViewPanData");
|
||||
op->customdata = vpd = MEM_callocN(sizeof(ViewPanData), "ClipViewPanData");
|
||||
WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR);
|
||||
|
||||
vpd->x= event->x;
|
||||
vpd->y= event->y;
|
||||
vpd->x = event->x;
|
||||
vpd->y = event->y;
|
||||
|
||||
if (sc->flag&SC_LOCK_SELECTION) vpd->vec= &sc->xlockof;
|
||||
else vpd->vec= &sc->xof;
|
||||
if (sc->flag & SC_LOCK_SELECTION)
|
||||
vpd->vec= &sc->xlockof;
|
||||
else
|
||||
vpd->vec= &sc->xof;
|
||||
|
||||
copy_v2_v2(&vpd->xof, vpd->vec);
|
||||
copy_v2_v2(&vpd->xorig, &vpd->xof);
|
||||
@@ -297,7 +300,7 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
static void view_pan_exit(bContext *C, wmOperator *op, int cancel)
|
||||
{
|
||||
ViewPanData *vpd= op->customdata;
|
||||
ViewPanData *vpd = op->customdata;
|
||||
|
||||
if (cancel) {
|
||||
copy_v2_v2(vpd->vec, &vpd->xorig);
|
||||
@@ -311,18 +314,18 @@ static void view_pan_exit(bContext *C, wmOperator *op, int cancel)
|
||||
|
||||
static int view_pan_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
float offset[2];
|
||||
|
||||
RNA_float_get_array(op->ptr, "offset", offset);
|
||||
|
||||
if (sc->flag&SC_LOCK_SELECTION) {
|
||||
sc->xlockof+= offset[0];
|
||||
sc->ylockof+= offset[1];
|
||||
if (sc->flag & SC_LOCK_SELECTION) {
|
||||
sc->xlockof += offset[0];
|
||||
sc->ylockof += offset[1];
|
||||
}
|
||||
else {
|
||||
sc->xof+= offset[0];
|
||||
sc->yof+= offset[1];
|
||||
sc->xof += offset[0];
|
||||
sc->yof += offset[1];
|
||||
}
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
@@ -332,47 +335,52 @@ static int view_pan_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
if (event->type==MOUSEPAN) {
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
if (event->type == MOUSEPAN) {
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
float offset[2];
|
||||
|
||||
offset[0]= (event->x - event->prevx)/sc->zoom;
|
||||
offset[1]= (event->y - event->prevy)/sc->zoom;
|
||||
offset[0] = (event->x - event->prevx) / sc->zoom;
|
||||
offset[1] = (event->y - event->prevy) / sc->zoom;
|
||||
|
||||
RNA_float_set_array(op->ptr, "offset", offset);
|
||||
|
||||
view_pan_exec(C, op);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
view_pan_init(C, op, event);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ViewPanData *vpd= op->customdata;
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ViewPanData *vpd = op->customdata;
|
||||
float offset[2];
|
||||
|
||||
switch(event->type) {
|
||||
case MOUSEMOVE:
|
||||
copy_v2_v2(vpd->vec, &vpd->xorig);
|
||||
offset[0]= (vpd->x - event->x)/sc->zoom;
|
||||
offset[1]= (vpd->y - event->y)/sc->zoom;
|
||||
offset[0] = (vpd->x - event->x) / sc->zoom;
|
||||
offset[1] = (vpd->y - event->y) / sc->zoom;
|
||||
RNA_float_set_array(op->ptr, "offset", offset);
|
||||
view_pan_exec(C, op);
|
||||
break;
|
||||
case ESCKEY:
|
||||
view_pan_exit(C, op, 1);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
case SPACEKEY:
|
||||
view_pan_exit(C, op, 0);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
default:
|
||||
if (event->type==vpd->event_type && event->val==KM_RELEASE) {
|
||||
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
|
||||
view_pan_exit(C, op, 0);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
break;
|
||||
@@ -420,16 +428,16 @@ typedef struct ViewZoomData {
|
||||
|
||||
static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ViewZoomData *vpd;
|
||||
|
||||
op->customdata= vpd= MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData");
|
||||
WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR);
|
||||
|
||||
vpd->x= event->x;
|
||||
vpd->y= event->y;
|
||||
vpd->zoom= sc->zoom;
|
||||
vpd->event_type= event->type;
|
||||
vpd->x = event->x;
|
||||
vpd->y = event->y;
|
||||
vpd->zoom = sc->zoom;
|
||||
vpd->event_type = event->type;
|
||||
|
||||
ED_clip_mouse_pos(C, event, vpd->location);
|
||||
|
||||
@@ -438,11 +446,11 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
static void view_zoom_exit(bContext *C, wmOperator *op, int cancel)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ViewZoomData *vpd= op->customdata;
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ViewZoomData *vpd = op->customdata;
|
||||
|
||||
if (cancel) {
|
||||
sc->zoom= vpd->zoom;
|
||||
sc->zoom = vpd->zoom;
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
}
|
||||
|
||||
@@ -452,8 +460,8 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel)
|
||||
|
||||
static int view_zoom_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
sclip_zoom_set_factor(sc, ar, RNA_float_get(op->ptr, "factor"), NULL);
|
||||
|
||||
@@ -464,10 +472,10 @@ static int view_zoom_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
if (event->type==MOUSEZOOM) {
|
||||
if (event->type == MOUSEZOOM) {
|
||||
float factor;
|
||||
|
||||
factor= 1.0f + (event->x-event->prevx+event->y-event->prevy)/300.0f;
|
||||
factor = 1.0f + (event->x - event->prevx + event->y - event->prevy) / 300.0f;
|
||||
RNA_float_set(op->ptr, "factor", factor);
|
||||
|
||||
sclip_zoom_set_factor_exec(C, event, factor);
|
||||
@@ -483,21 +491,22 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
ViewZoomData *vpd= op->customdata;
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
ViewZoomData *vpd = op->customdata;
|
||||
float factor;
|
||||
|
||||
switch(event->type) {
|
||||
case MOUSEMOVE:
|
||||
factor= 1.0f + (vpd->x-event->x+vpd->y-event->y)/300.0f;
|
||||
factor = 1.0f + (vpd->x-event->x + vpd->y - event->y) / 300.0f;
|
||||
RNA_float_set(op->ptr, "factor", factor);
|
||||
sclip_zoom_set(sc, ar, vpd->zoom*factor, vpd->location);
|
||||
sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
break;
|
||||
default:
|
||||
if (event->type==vpd->event_type && event->val==KM_RELEASE) {
|
||||
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
|
||||
view_zoom_exit(C, op, 0);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
break;
|
||||
@@ -509,6 +518,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
static int view_zoom_cancel(bContext *C, wmOperator *op)
|
||||
{
|
||||
view_zoom_exit(C, op, 1);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -537,8 +547,8 @@ void CLIP_OT_view_zoom(wmOperatorType *ot)
|
||||
|
||||
static int view_zoom_in_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
float location[2];
|
||||
|
||||
RNA_float_get_array(op->ptr, "location", location);
|
||||
@@ -577,8 +587,8 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot)
|
||||
|
||||
static int view_zoom_out_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
float location[2];
|
||||
|
||||
RNA_float_get_array(op->ptr, "location", location);
|
||||
@@ -619,14 +629,14 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot)
|
||||
|
||||
static int view_zoom_ratio_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
sclip_zoom_set(sc, ar, RNA_float_get(op->ptr, "ratio"), NULL);
|
||||
|
||||
/* ensure pixel exact locations for draw */
|
||||
sc->xof= (int)sc->xof;
|
||||
sc->yof= (int)sc->yof;
|
||||
sc->xof= (int) sc->xof;
|
||||
sc->yof= (int) sc->yof;
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
@@ -660,31 +670,31 @@ static int view_all_exec(bContext *C, wmOperator *op)
|
||||
float zoomx, zoomy;
|
||||
|
||||
/* retrieve state */
|
||||
sc= CTX_wm_space_clip(C);
|
||||
ar= CTX_wm_region(C);
|
||||
sc = CTX_wm_space_clip(C);
|
||||
ar = CTX_wm_region(C);
|
||||
|
||||
ED_space_clip_size(sc, &w, &h);
|
||||
ED_space_clip_aspect(sc, &aspx, &aspy);
|
||||
|
||||
w= w*aspx;
|
||||
h= h*aspy;
|
||||
w = w * aspx;
|
||||
h = h * aspy;
|
||||
|
||||
/* check if the image will fit in the image with zoom==1 */
|
||||
width= ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
height= ar->winrct.ymax - ar->winrct.ymin + 1;
|
||||
width = ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
height = ar->winrct.ymax - ar->winrct.ymin + 1;
|
||||
|
||||
if (fit_view) {
|
||||
const int margin = 5; /* margin from border */
|
||||
|
||||
zoomx= (float)width / (w + 2*margin);
|
||||
zoomy= (float)height / (h + 2*margin);
|
||||
zoomx= (float) width / (w + 2 * margin);
|
||||
zoomy= (float) height / (h + 2 * margin);
|
||||
|
||||
sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL);
|
||||
}
|
||||
else {
|
||||
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
|
||||
zoomx= (float)width/w;
|
||||
zoomy= (float)height/h;
|
||||
zoomx= (float) width / w;
|
||||
zoomy= (float) height / h;
|
||||
|
||||
/* find the zoom value that will fit the image in the image space */
|
||||
sclip_zoom_set(sc, ar, 1.0f/power_of_2(1/MIN2(zoomx, zoomy)), NULL);
|
||||
@@ -693,7 +703,7 @@ static int view_all_exec(bContext *C, wmOperator *op)
|
||||
sclip_zoom_set(sc, ar, 1.0f, NULL);
|
||||
}
|
||||
|
||||
sc->xof= sc->yof= 0.0f;
|
||||
sc->xof = sc->yof = 0.0f;
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
@@ -718,11 +728,11 @@ void CLIP_OT_view_all(wmOperatorType *ot)
|
||||
|
||||
static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
sc->xlockof= 0.0f;
|
||||
sc->ylockof= 0.0f;
|
||||
sc->xlockof = 0.0f;
|
||||
sc->ylockof = 0.0f;
|
||||
|
||||
ED_clip_view_selection(sc, ar, 1);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
@@ -754,10 +764,10 @@ static int change_frame_poll(bContext *C)
|
||||
|
||||
static void change_frame_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* set the new frame number */
|
||||
CFRA= RNA_int_get(op->ptr, "frame");
|
||||
CFRA = RNA_int_get(op->ptr, "frame");
|
||||
FRAMENUMBER_MIN_CLAMP(CFRA);
|
||||
SUBFRA = 0.0f;
|
||||
|
||||
@@ -775,21 +785,21 @@ static int change_frame_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int frame_from_event(bContext *C, wmEvent *event)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int framenr= 0;
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int framenr = 0;
|
||||
|
||||
if (ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1);
|
||||
float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1);
|
||||
|
||||
framenr= sfra+event->mval[0]/framelen;
|
||||
framenr = sfra + event->mval[0] / framelen;
|
||||
}
|
||||
else {
|
||||
float viewx, viewy;
|
||||
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
|
||||
|
||||
framenr= (int)floor(viewx+0.5f);
|
||||
framenr= (int) floor(viewx + 0.5f);
|
||||
}
|
||||
|
||||
return framenr;
|
||||
@@ -797,10 +807,10 @@ static int frame_from_event(bContext *C, wmEvent *event)
|
||||
|
||||
static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
if (ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
if (event->mval[1]>16)
|
||||
if (event->mval[1] > 16)
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
@@ -827,7 +837,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
case LEFTMOUSE:
|
||||
case RIGHTMOUSE:
|
||||
if (event->val==KM_RELEASE)
|
||||
if (event->val == KM_RELEASE)
|
||||
return OPERATOR_FINISHED;
|
||||
break;
|
||||
}
|
||||
@@ -885,10 +895,17 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto
|
||||
MCLIP_PROXY_UNDISTORTED_SIZE_100}};
|
||||
int size_nr = undistort ? 1 : 0;
|
||||
|
||||
if (size_flag & size_flags[size_nr][0]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25;
|
||||
if (size_flag & size_flags[size_nr][1]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50;
|
||||
if (size_flag & size_flags[size_nr][2]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75;
|
||||
if (size_flag & size_flags[size_nr][3]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100;
|
||||
if (size_flag & size_flags[size_nr][0])
|
||||
build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25;
|
||||
|
||||
if (size_flag & size_flags[size_nr][1])
|
||||
build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50;
|
||||
|
||||
if (size_flag & size_flags[size_nr][2])
|
||||
build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75;
|
||||
|
||||
if (size_flag & size_flags[size_nr][3])
|
||||
build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100;
|
||||
|
||||
return build_count;
|
||||
}
|
||||
@@ -896,19 +913,19 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto
|
||||
/* only this runs inside thread */
|
||||
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
|
||||
{
|
||||
ProxyJob *pj= pjv;
|
||||
Scene *scene=pj->scene;
|
||||
MovieClip *clip= pj->clip;
|
||||
struct MovieDistortion *distortion= NULL;
|
||||
ProxyJob *pj = pjv;
|
||||
Scene *scene = pj->scene;
|
||||
MovieClip *clip = pj->clip;
|
||||
struct MovieDistortion *distortion = NULL;
|
||||
short size_flag;
|
||||
int cfra, sfra= SFRA, efra= EFRA;
|
||||
int build_sizes[4], build_count= 0;
|
||||
int build_undistort_sizes[4], build_undistort_count= 0;
|
||||
int cfra, sfra = SFRA, efra = EFRA;
|
||||
int build_sizes[4], build_count = 0;
|
||||
int build_undistort_sizes[4], build_undistort_count = 0;
|
||||
|
||||
size_flag= clip->proxy.build_size_flag;
|
||||
size_flag = clip->proxy.build_size_flag;
|
||||
|
||||
build_count= proxy_bitflag_to_array(size_flag, build_sizes, 0);
|
||||
build_undistort_count= proxy_bitflag_to_array(size_flag, build_undistort_sizes, 1);
|
||||
build_count = proxy_bitflag_to_array(size_flag, build_sizes, 0);
|
||||
build_undistort_count = proxy_bitflag_to_array(size_flag, build_undistort_sizes, 1);
|
||||
|
||||
if (clip->source == MCLIP_SRC_MOVIE) {
|
||||
if (pj->index_context)
|
||||
@@ -921,15 +938,15 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog
|
||||
return;
|
||||
}
|
||||
else {
|
||||
sfra= 1;
|
||||
efra= IMB_anim_get_duration(clip->anim, IMB_TC_NONE);
|
||||
sfra = 1;
|
||||
efra = IMB_anim_get_duration(clip->anim, IMB_TC_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (build_undistort_count)
|
||||
distortion= BKE_tracking_distortion_create();
|
||||
distortion = BKE_tracking_distortion_create();
|
||||
|
||||
for (cfra= sfra; cfra<=efra; cfra++) {
|
||||
for (cfra = sfra; cfra <= efra; cfra++) {
|
||||
if (clip->source != MCLIP_SRC_MOVIE)
|
||||
BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, NULL, cfra, build_sizes, build_count, 0);
|
||||
|
||||
@@ -938,8 +955,8 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog
|
||||
if (*stop || G.afbreek)
|
||||
break;
|
||||
|
||||
*do_update= 1;
|
||||
*progress= ((float)cfra)/(efra-sfra);
|
||||
*do_update = TRUE;
|
||||
*progress= ((float) cfra) / (efra - sfra);
|
||||
}
|
||||
|
||||
if (distortion)
|
||||
@@ -968,21 +985,21 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
wmJob * steve;
|
||||
ProxyJob *pj;
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
|
||||
if ((clip->flag&MCLIP_USE_PROXY)==0)
|
||||
if ((clip->flag & MCLIP_USE_PROXY) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS);
|
||||
steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS);
|
||||
|
||||
pj= MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
|
||||
pj->scene= scene;
|
||||
pj->main= CTX_data_main(C);
|
||||
pj->clip= clip;
|
||||
pj->clip_flag= clip->flag&MCLIP_TIMECODE_FLAGS;
|
||||
pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
|
||||
pj->scene = scene;
|
||||
pj->main = CTX_data_main(C);
|
||||
pj->clip = clip;
|
||||
pj->clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS;
|
||||
|
||||
if (clip->anim) {
|
||||
pj->index_context = IMB_anim_index_rebuild_context(clip->anim, clip->proxy.build_tc_flag,
|
||||
@@ -993,7 +1010,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|ND_DISPLAY, 0);
|
||||
WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob);
|
||||
|
||||
G.afbreek= 0;
|
||||
G.afbreek = 0;
|
||||
WM_jobs_start(CTX_wm_manager(C), steve);
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
@@ -1020,16 +1037,16 @@ void CLIP_OT_rebuild_proxy(wmOperatorType *ot)
|
||||
|
||||
static int mode_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
int mode= RNA_enum_get(op->ptr, "mode");
|
||||
int toggle= RNA_boolean_get(op->ptr, "toggle");
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
int mode = RNA_enum_get(op->ptr, "mode");
|
||||
int toggle = RNA_boolean_get(op->ptr, "toggle");
|
||||
|
||||
if (sc->mode==mode) {
|
||||
if (sc->mode == mode) {
|
||||
if (toggle)
|
||||
sc->mode= SC_MODE_TRACKING;
|
||||
sc->mode = SC_MODE_TRACKING;
|
||||
}
|
||||
else {
|
||||
sc->mode= mode;
|
||||
sc->mode = mode;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CLIP, NULL);
|
||||
|
@@ -60,24 +60,24 @@ static ARegion *clip_has_properties_region(ScrArea *sa)
|
||||
{
|
||||
ARegion *ar, *arnew;
|
||||
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
|
||||
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
|
||||
if (ar)
|
||||
return ar;
|
||||
|
||||
/* add subdiv level; after header */
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
|
||||
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
|
||||
|
||||
/* is error! */
|
||||
if (ar==NULL)
|
||||
if (ar == NULL)
|
||||
return NULL;
|
||||
|
||||
arnew= MEM_callocN(sizeof(ARegion), "clip properties region");
|
||||
arnew = MEM_callocN(sizeof(ARegion), "clip properties region");
|
||||
|
||||
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
|
||||
arnew->regiontype= RGN_TYPE_UI;
|
||||
arnew->alignment= RGN_ALIGN_RIGHT;
|
||||
arnew->regiontype = RGN_TYPE_UI;
|
||||
arnew->alignment = RGN_ALIGN_RIGHT;
|
||||
|
||||
arnew->flag= RGN_FLAG_HIDDEN;
|
||||
arnew->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
return arnew;
|
||||
}
|
||||
@@ -89,8 +89,8 @@ static int properties_poll(bContext *C)
|
||||
|
||||
static int properties_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= clip_has_properties_region(sa);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = clip_has_properties_region(sa);
|
||||
|
||||
if (ar)
|
||||
ED_region_toggle_hidden(C, ar);
|
||||
@@ -114,43 +114,44 @@ void CLIP_OT_properties(wmOperatorType *ot)
|
||||
|
||||
static ARegion *clip_has_tools_region(ScrArea *sa)
|
||||
{
|
||||
ARegion *ar, *artool=NULL, *arprops=NULL, *arhead;
|
||||
ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
|
||||
|
||||
for (ar= sa->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->regiontype==RGN_TYPE_TOOLS)
|
||||
artool= ar;
|
||||
if (ar->regiontype==RGN_TYPE_TOOL_PROPS)
|
||||
arprops= ar;
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->regiontype == RGN_TYPE_TOOLS)
|
||||
artool = ar;
|
||||
|
||||
if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
|
||||
arprops = ar;
|
||||
}
|
||||
|
||||
/* tool region hide/unhide also hides props */
|
||||
if (arprops && artool)
|
||||
return artool;
|
||||
|
||||
if (artool==NULL) {
|
||||
if (artool == NULL) {
|
||||
/* add subdiv level; after header */
|
||||
arhead= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
|
||||
arhead = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
|
||||
|
||||
/* is error! */
|
||||
if (arhead==NULL)
|
||||
if (arhead == NULL)
|
||||
return NULL;
|
||||
|
||||
artool= MEM_callocN(sizeof(ARegion), "clip tools region");
|
||||
artool = MEM_callocN(sizeof(ARegion), "clip tools region");
|
||||
|
||||
BLI_insertlinkafter(&sa->regionbase, arhead, artool);
|
||||
artool->regiontype= RGN_TYPE_TOOLS;
|
||||
artool->alignment= RGN_ALIGN_LEFT;
|
||||
artool->regiontype = RGN_TYPE_TOOLS;
|
||||
artool->alignment = RGN_ALIGN_LEFT;
|
||||
|
||||
artool->flag= RGN_FLAG_HIDDEN;
|
||||
artool->flag = RGN_FLAG_HIDDEN;
|
||||
}
|
||||
|
||||
if (arprops==NULL) {
|
||||
if (arprops == NULL) {
|
||||
/* add extra subdivided region for tool properties */
|
||||
arprops= MEM_callocN(sizeof(ARegion), "tool props for clip");
|
||||
arprops = MEM_callocN(sizeof(ARegion), "tool props for clip");
|
||||
|
||||
BLI_insertlinkafter(&sa->regionbase, artool, arprops);
|
||||
arprops->regiontype= RGN_TYPE_TOOL_PROPS;
|
||||
arprops->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
|
||||
arprops->regiontype = RGN_TYPE_TOOL_PROPS;
|
||||
arprops->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
|
||||
}
|
||||
|
||||
return artool;
|
||||
@@ -163,8 +164,8 @@ static int tools_poll(bContext *C)
|
||||
|
||||
static int tools_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= clip_has_tools_region(sa);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = clip_has_tools_region(sa);
|
||||
|
||||
if (ar)
|
||||
ED_region_toggle_hidden(C, ar);
|
||||
@@ -193,16 +194,18 @@ static void clip_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperat
|
||||
|
||||
static void clip_panel_operator_redo_header(const bContext *C, Panel *pa)
|
||||
{
|
||||
wmOperator *op= WM_operator_last_redo(C);
|
||||
wmOperator *op = WM_operator_last_redo(C);
|
||||
|
||||
if (op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname));
|
||||
else BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname));
|
||||
if (op)
|
||||
BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname));
|
||||
else
|
||||
BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname));
|
||||
}
|
||||
|
||||
static void clip_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOperator *op)
|
||||
{
|
||||
if (op->type->flag & OPTYPE_MACRO) {
|
||||
for (op= op->macro.first; op; op= op->next) {
|
||||
for (op = op->macro.first; op; op = op->next) {
|
||||
uiItemL(pa->layout, op->type->name, ICON_NONE);
|
||||
clip_panel_operator_redo_operator(C, pa, op);
|
||||
}
|
||||
@@ -215,15 +218,16 @@ static void clip_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOp
|
||||
/* TODO de-duplicate redo panel functions - campbell */
|
||||
static void clip_panel_operator_redo(const bContext *C, Panel *pa)
|
||||
{
|
||||
wmOperator *op= WM_operator_last_redo(C);
|
||||
wmOperator *op = WM_operator_last_redo(C);
|
||||
uiBlock *block;
|
||||
|
||||
if (op==NULL)
|
||||
if (op == NULL)
|
||||
return;
|
||||
|
||||
if (WM_operator_poll((bContext*)C, op->type) == 0)
|
||||
return;
|
||||
|
||||
block= uiLayoutGetBlock(pa->layout);
|
||||
block = uiLayoutGetBlock(pa->layout);
|
||||
|
||||
if (!WM_operator_check_ui_enabled(C, op->type->name))
|
||||
uiLayoutSetEnabled(pa->layout, 0);
|
||||
@@ -238,10 +242,10 @@ void ED_clip_tool_props_register(ARegionType *art)
|
||||
{
|
||||
PanelType *pt;
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype clip panel last operator");
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel last operator");
|
||||
strcpy(pt->idname, "CLIP_PT_last_operator");
|
||||
strcpy(pt->label, "Operator");
|
||||
pt->draw_header= clip_panel_operator_redo_header;
|
||||
pt->draw= clip_panel_operator_redo;
|
||||
pt->draw_header = clip_panel_operator_redo_header;
|
||||
pt->draw = clip_panel_operator_redo;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
|
@@ -62,25 +62,25 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack
|
||||
void (*segment_start) (void *userdata, MovieTrackingTrack *track, int coord),
|
||||
void (*segment_end) (void *userdata))
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
int width, height, coord;
|
||||
|
||||
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
|
||||
|
||||
for (coord= 0; coord<2; coord++) {
|
||||
int i, open= 0, prevfra= 0;
|
||||
float prevval= 0.0f;
|
||||
for (coord = 0; coord < 2; coord++) {
|
||||
int i, open = FALSE, prevfra = 0;
|
||||
float prevval = 0.0f;
|
||||
|
||||
for (i= 0; i<track->markersnr; i++) {
|
||||
MovieTrackingMarker *marker= &track->markers[i];
|
||||
for (i = 0; i < track->markersnr; i++) {
|
||||
MovieTrackingMarker *marker = &track->markers[i];
|
||||
float val;
|
||||
|
||||
if (marker->flag&MARKER_DISABLED) {
|
||||
if (marker->flag & MARKER_DISABLED) {
|
||||
if (open) {
|
||||
if (segment_end)
|
||||
segment_end(userdata);
|
||||
|
||||
open= 0;
|
||||
open = FALSE;
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -90,19 +90,19 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack
|
||||
if (segment_start)
|
||||
segment_start(userdata, track, coord);
|
||||
|
||||
open= 1;
|
||||
prevval= marker->pos[coord];
|
||||
open = TRUE;
|
||||
prevval = marker->pos[coord];
|
||||
}
|
||||
|
||||
/* value is a pixels per frame speed */
|
||||
val= (marker->pos[coord] - prevval) * ((coord==0) ? (width) : (height));
|
||||
val/= marker->framenr-prevfra;
|
||||
val = (marker->pos[coord] - prevval) * ((coord == 0) ? (width) : (height));
|
||||
val /= marker->framenr - prevfra;
|
||||
|
||||
if (func)
|
||||
func(userdata, track, marker, coord, val);
|
||||
|
||||
prevval= marker->pos[coord];
|
||||
prevfra= marker->framenr;
|
||||
prevval = marker->pos[coord];
|
||||
prevfra = marker->framenr;
|
||||
}
|
||||
|
||||
if (open) {
|
||||
@@ -117,38 +117,38 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, void *userdata,
|
||||
void (*segment_start) (void *userdata, MovieTrackingTrack *track, int coord),
|
||||
void (*segment_end) (void *userdata))
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(tracking);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
MovieTrackingTrack *track;
|
||||
|
||||
track= tracksbase->first;
|
||||
track = tracksbase->first;
|
||||
while (track) {
|
||||
if (TRACK_VIEW_SELECTED(sc, track)) {
|
||||
clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end);
|
||||
}
|
||||
|
||||
track= track->next;
|
||||
track = track->next;
|
||||
}
|
||||
}
|
||||
|
||||
void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata,
|
||||
void (*func) (void *userdata, MovieTrackingMarker *marker))
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(tracking);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
MovieTrackingTrack *track;
|
||||
|
||||
track= tracksbase->first;
|
||||
track = tracksbase->first;
|
||||
while (track) {
|
||||
if (TRACK_VIEW_SELECTED(sc, track)) {
|
||||
int i;
|
||||
|
||||
for (i= 0; i<track->markersnr; i++) {
|
||||
MovieTrackingMarker *marker= &track->markers[i];
|
||||
for (i = 0; i < track->markersnr; i++) {
|
||||
MovieTrackingMarker *marker = &track->markers[i];
|
||||
|
||||
if (marker->flag&MARKER_DISABLED)
|
||||
if (marker->flag & MARKER_DISABLED)
|
||||
continue;
|
||||
|
||||
if (func)
|
||||
@@ -156,30 +156,30 @@ void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata,
|
||||
}
|
||||
}
|
||||
|
||||
track= track->next;
|
||||
track = track->next;
|
||||
}
|
||||
}
|
||||
|
||||
void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track)
|
||||
{
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTrackingStabilization *stab= &tracking->stabilization;
|
||||
MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingStabilization *stab = &tracking->stabilization;
|
||||
MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking);
|
||||
|
||||
int has_bundle= 0, update_stab= 0;
|
||||
int has_bundle = FALSE, update_stab = FALSE;
|
||||
|
||||
if (track==act_track)
|
||||
tracking->act_track= NULL;
|
||||
tracking->act_track = NULL;
|
||||
|
||||
if (track==stab->rot_track) {
|
||||
stab->rot_track= NULL;
|
||||
if (track == stab->rot_track) {
|
||||
stab->rot_track = NULL;
|
||||
|
||||
update_stab= 1;
|
||||
update_stab = TRUE;
|
||||
}
|
||||
|
||||
/* handle reconstruction display in 3d viewport */
|
||||
if (track->flag&TRACK_HAS_BUNDLE)
|
||||
has_bundle= 1;
|
||||
if (track->flag & TRACK_HAS_BUNDLE)
|
||||
has_bundle = TRUE;
|
||||
|
||||
BKE_tracking_free_track(track);
|
||||
BLI_freelinkN(tracksbase, track);
|
||||
@@ -187,7 +187,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip);
|
||||
|
||||
if (update_stab) {
|
||||
tracking->stabilization.ok= 0;
|
||||
tracking->stabilization.ok = FALSE;
|
||||
|
||||
DAG_id_tag_update(&clip->id, 0);
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip);
|
||||
@@ -199,7 +199,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie
|
||||
|
||||
void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track, MovieTrackingMarker *marker)
|
||||
{
|
||||
if (track->markersnr==1) {
|
||||
if (track->markersnr == 1) {
|
||||
clip_delete_track(C, clip, tracksbase, track);
|
||||
}
|
||||
else {
|
||||
@@ -217,6 +217,6 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y)
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
ED_space_clip_aspect(sc, &aspx, &aspy);
|
||||
|
||||
sc->xof= (x-0.5f)*width*aspx;
|
||||
sc->yof= (y-0.5f)*height*aspy;
|
||||
sc->xof = (x - 0.5f) * width * aspx;
|
||||
sc->yof = (y - 0.5f) * height * aspy;
|
||||
}
|
||||
|
@@ -71,47 +71,47 @@
|
||||
|
||||
static void init_preview_region(const bContext *C, ARegion *ar)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
ar->regiontype= RGN_TYPE_PREVIEW;
|
||||
ar->alignment= RGN_ALIGN_TOP;
|
||||
ar->flag|= RGN_FLAG_HIDDEN;
|
||||
ar->regiontype = RGN_TYPE_PREVIEW;
|
||||
ar->alignment = RGN_ALIGN_TOP;
|
||||
ar->flag |= RGN_FLAG_HIDDEN;
|
||||
|
||||
ar->v2d.tot.xmin = 0.0f;
|
||||
ar->v2d.tot.ymin = -10.0f;
|
||||
ar->v2d.tot.xmax = (float)scene->r.efra;
|
||||
ar->v2d.tot.ymax = 10.0f;
|
||||
|
||||
ar->v2d.cur= ar->v2d.tot;
|
||||
ar->v2d.cur = ar->v2d.tot;
|
||||
|
||||
ar->v2d.min[0]= FLT_MIN;
|
||||
ar->v2d.min[1]= FLT_MIN;
|
||||
ar->v2d.min[0] = FLT_MIN;
|
||||
ar->v2d.min[1] = FLT_MIN;
|
||||
|
||||
ar->v2d.max[0]= MAXFRAMEF;
|
||||
ar->v2d.max[1]= FLT_MAX;
|
||||
ar->v2d.max[0] = MAXFRAMEF;
|
||||
ar->v2d.max[1] = FLT_MAX;
|
||||
|
||||
ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
|
||||
|
||||
ar->v2d.keeptot= 0;
|
||||
ar->v2d.keeptot = 0;
|
||||
}
|
||||
|
||||
static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa)
|
||||
{
|
||||
ARegion *ar, *arnew;
|
||||
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
|
||||
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
|
||||
if (ar)
|
||||
return ar;
|
||||
|
||||
/* add subdiv level; after header */
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
|
||||
/* is error! */
|
||||
if (ar==NULL)
|
||||
if (ar == NULL)
|
||||
return NULL;
|
||||
|
||||
arnew= MEM_callocN(sizeof(ARegion), "clip preview region");
|
||||
arnew = MEM_callocN(sizeof(ARegion), "clip preview region");
|
||||
|
||||
BLI_insertlinkbefore(&sa->regionbase, ar, arnew);
|
||||
init_preview_region(C, arnew);
|
||||
@@ -121,30 +121,30 @@ static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa)
|
||||
|
||||
static void clip_scopes_tag_refresh(ScrArea *sa)
|
||||
{
|
||||
SpaceClip *sc= (SpaceClip *)sa->spacedata.first;
|
||||
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
|
||||
ARegion *ar;
|
||||
|
||||
if (sc->mode!=SC_MODE_TRACKING)
|
||||
if (sc->mode != SC_MODE_TRACKING)
|
||||
return;
|
||||
|
||||
/* only while proeprties are visible */
|
||||
for (ar=sa->regionbase.first; ar; ar=ar->next) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->regiontype == RGN_TYPE_UI && ar->flag & RGN_FLAG_HIDDEN)
|
||||
return;
|
||||
}
|
||||
|
||||
sc->scopes.ok= 0;
|
||||
sc->scopes.ok = FALSE;
|
||||
}
|
||||
|
||||
static void clip_stabilization_tag_refresh(ScrArea *sa)
|
||||
{
|
||||
SpaceClip *sc= (SpaceClip *)sa->spacedata.first;
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
SpaceClip *sc = (SpaceClip *) sa->spacedata.first;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
|
||||
if (clip) {
|
||||
MovieTrackingStabilization *stab= &clip->tracking.stabilization;
|
||||
MovieTrackingStabilization *stab = &clip->tracking.stabilization;
|
||||
|
||||
stab->ok= 0;
|
||||
stab->ok = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,62 +155,62 @@ static SpaceLink *clip_new(const bContext *C)
|
||||
ARegion *ar;
|
||||
SpaceClip *sc;
|
||||
|
||||
sc= MEM_callocN(sizeof(SpaceClip), "initclip");
|
||||
sc->spacetype= SPACE_CLIP;
|
||||
sc->flag= SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES;
|
||||
sc->zoom= 1.0f;
|
||||
sc->path_length= 20;
|
||||
sc->scopes.track_preview_height= 120;
|
||||
sc = MEM_callocN(sizeof(SpaceClip), "initclip");
|
||||
sc->spacetype = SPACE_CLIP;
|
||||
sc->flag = SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES;
|
||||
sc->zoom = 1.0f;
|
||||
sc->path_length = 20;
|
||||
sc->scopes.track_preview_height = 120;
|
||||
|
||||
/* header */
|
||||
ar= MEM_callocN(sizeof(ARegion), "header for clip");
|
||||
ar = MEM_callocN(sizeof(ARegion), "header for clip");
|
||||
|
||||
BLI_addtail(&sc->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_HEADER;
|
||||
ar->alignment= RGN_ALIGN_BOTTOM;
|
||||
ar->regiontype = RGN_TYPE_HEADER;
|
||||
ar->alignment = RGN_ALIGN_BOTTOM;
|
||||
|
||||
/* tools view */
|
||||
ar= MEM_callocN(sizeof(ARegion), "tools for clip");
|
||||
ar = MEM_callocN(sizeof(ARegion), "tools for clip");
|
||||
|
||||
BLI_addtail(&sc->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_TOOLS;
|
||||
ar->alignment= RGN_ALIGN_LEFT;
|
||||
ar->regiontype = RGN_TYPE_TOOLS;
|
||||
ar->alignment = RGN_ALIGN_LEFT;
|
||||
|
||||
/* tool properties */
|
||||
ar= MEM_callocN(sizeof(ARegion), "tool properties for clip");
|
||||
ar = MEM_callocN(sizeof(ARegion), "tool properties for clip");
|
||||
|
||||
BLI_addtail(&sc->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_TOOL_PROPS;
|
||||
ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
|
||||
ar->regiontype = RGN_TYPE_TOOL_PROPS;
|
||||
ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
|
||||
|
||||
/* properties view */
|
||||
ar= MEM_callocN(sizeof(ARegion), "properties for clip");
|
||||
ar = MEM_callocN(sizeof(ARegion), "properties for clip");
|
||||
|
||||
BLI_addtail(&sc->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_UI;
|
||||
ar->alignment= RGN_ALIGN_RIGHT;
|
||||
ar->regiontype = RGN_TYPE_UI;
|
||||
ar->alignment = RGN_ALIGN_RIGHT;
|
||||
|
||||
/* preview view */
|
||||
ar= MEM_callocN(sizeof(ARegion), "preview for clip");
|
||||
ar = MEM_callocN(sizeof(ARegion), "preview for clip");
|
||||
|
||||
BLI_addtail(&sc->regionbase, ar);
|
||||
init_preview_region(C, ar);
|
||||
|
||||
/* main area */
|
||||
ar= MEM_callocN(sizeof(ARegion), "main area for clip");
|
||||
ar = MEM_callocN(sizeof(ARegion), "main area for clip");
|
||||
|
||||
BLI_addtail(&sc->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_WINDOW;
|
||||
ar->regiontype = RGN_TYPE_WINDOW;
|
||||
|
||||
return (SpaceLink *)sc;
|
||||
return (SpaceLink *) sc;
|
||||
}
|
||||
|
||||
/* not spacelink itself */
|
||||
static void clip_free(SpaceLink *sl)
|
||||
{
|
||||
SpaceClip *sc= (SpaceClip*) sl;
|
||||
SpaceClip *sc = (SpaceClip*) sl;
|
||||
|
||||
sc->clip= NULL;
|
||||
sc->clip = NULL;
|
||||
|
||||
if (sc->scopes.track_preview)
|
||||
IMB_freeImBuf(sc->scopes.track_preview);
|
||||
@@ -224,11 +224,11 @@ static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
|
||||
|
||||
static SpaceLink *clip_duplicate(SpaceLink *sl)
|
||||
{
|
||||
SpaceClip *scn= MEM_dupallocN(sl);
|
||||
SpaceClip *scn = MEM_dupallocN(sl);
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
scn->scopes.track_preview= NULL;
|
||||
scn->scopes.ok= 0;
|
||||
scn->scopes.track_preview = NULL;
|
||||
scn->scopes.ok = FALSE;
|
||||
|
||||
return (SpaceLink *)scn;
|
||||
}
|
||||
@@ -278,12 +278,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
}
|
||||
break;
|
||||
case NC_SCREEN:
|
||||
if (wmn->data==ND_ANIMPLAY) {
|
||||
if (wmn->data ==ND_ANIMPLAY) {
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
break;
|
||||
case NC_SPACE:
|
||||
if (wmn->data==ND_SPACE_CLIP) {
|
||||
if (wmn->data ==ND_SPACE_CLIP) {
|
||||
clip_scopes_tag_refresh(sa);
|
||||
clip_stabilization_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
@@ -615,29 +615,29 @@ const char *clip_context_dir[]= {"edit_movieclip", NULL};
|
||||
|
||||
static int clip_context(const bContext *C, const char *member, bContextDataResult *result)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
|
||||
if (CTX_data_dir(member)) {
|
||||
CTX_data_dir_set(result, clip_context_dir);
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
else if (CTX_data_equals(member, "edit_movieclip")) {
|
||||
CTX_data_id_pointer_set(result, &sc->clip->id);
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmWindow *window= CTX_wm_window(C);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *window = CTX_wm_window(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
SpaceClip *sc= (SpaceClip *)sa->spacedata.first;
|
||||
ARegion *ar_main= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
ARegion *ar_preview= clip_has_preview_region(C, sa);
|
||||
int view_changed= 0;
|
||||
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
|
||||
ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
ARegion *ar_preview = clip_has_preview_region(C, sa);
|
||||
int view_changed = FALSE;
|
||||
|
||||
switch (sc->view) {
|
||||
case SC_VIEW_CLIP:
|
||||
@@ -645,11 +645,11 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
ar_preview->flag |= RGN_FLAG_HIDDEN;
|
||||
ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
|
||||
WM_event_remove_handlers((bContext*)C, &ar_preview->handlers);
|
||||
view_changed= 1;
|
||||
view_changed = TRUE;
|
||||
}
|
||||
if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
|
||||
ar_main->alignment= RGN_ALIGN_NONE;
|
||||
view_changed= 1;
|
||||
ar_main->alignment = RGN_ALIGN_NONE;
|
||||
view_changed = TRUE;
|
||||
}
|
||||
if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
|
||||
/* store graph region align */
|
||||
@@ -658,8 +658,8 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
else
|
||||
sc->runtime_flag |= SC_GRAPH_BOTTOM;
|
||||
|
||||
ar_preview->alignment= RGN_ALIGN_NONE;
|
||||
view_changed= 1;
|
||||
ar_preview->alignment = RGN_ALIGN_NONE;
|
||||
view_changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case SC_VIEW_GRAPH:
|
||||
@@ -667,19 +667,19 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
ar_preview->flag &= ~RGN_FLAG_HIDDEN;
|
||||
ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
|
||||
ar_preview->v2d.cur = ar_preview->v2d.tot;
|
||||
view_changed= 1;
|
||||
view_changed = TRUE;
|
||||
}
|
||||
if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
|
||||
ar_main->alignment= RGN_ALIGN_NONE;
|
||||
view_changed= 1;
|
||||
ar_main->alignment = RGN_ALIGN_NONE;
|
||||
view_changed = TRUE;
|
||||
}
|
||||
if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
|
||||
if (sc->runtime_flag & SC_GRAPH_BOTTOM)
|
||||
ar_preview->alignment= RGN_ALIGN_BOTTOM;
|
||||
ar_preview->alignment = RGN_ALIGN_BOTTOM;
|
||||
else
|
||||
ar_preview->alignment= RGN_ALIGN_TOP;
|
||||
ar_preview->alignment = RGN_ALIGN_TOP;
|
||||
|
||||
view_changed= 1;
|
||||
view_changed = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -697,20 +697,20 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
/* sets up the fields of the View2D from zoom and offset */
|
||||
static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
float x1, y1, w, h;
|
||||
int width, height, winx, winy;
|
||||
|
||||
ED_space_clip_size(sc, &width, &height);
|
||||
|
||||
w= width;
|
||||
h= height;
|
||||
w = width;
|
||||
h = height;
|
||||
|
||||
if (clip)
|
||||
h*= clip->aspy/clip->aspx/clip->tracking.camera.pixel_aspect;
|
||||
h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect;
|
||||
|
||||
winx= ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
winy= ar->winrct.ymax - ar->winrct.ymin + 1;
|
||||
winx = ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
winy = ar->winrct.ymax - ar->winrct.ymin + 1;
|
||||
|
||||
ar->v2d.tot.xmin = 0;
|
||||
ar->v2d.tot.ymin = 0;
|
||||
@@ -722,19 +722,19 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
|
||||
ar->v2d.mask.ymax = winy;
|
||||
|
||||
/* which part of the image space do we see? */
|
||||
x1= ar->winrct.xmin+(winx-sc->zoom*w)/2.0f;
|
||||
y1= ar->winrct.ymin+(winy-sc->zoom*h)/2.0f;
|
||||
x1= ar->winrct.xmin + (winx-sc->zoom * w) / 2.0f;
|
||||
y1= ar->winrct.ymin + (winy-sc->zoom * h) / 2.0f;
|
||||
|
||||
x1-= sc->zoom*sc->xof;
|
||||
y1-= sc->zoom*sc->yof;
|
||||
x1-= sc->zoom * sc->xof;
|
||||
y1-= sc->zoom * sc->yof;
|
||||
|
||||
/* relative display right */
|
||||
ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1)/sc->zoom);
|
||||
ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx/sc->zoom);
|
||||
ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / sc->zoom;
|
||||
ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sc->zoom);
|
||||
|
||||
/* relative display left */
|
||||
ar->v2d.cur.ymin = ((ar->winrct.ymin-(float)y1)/sc->zoom);
|
||||
ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy/sc->zoom);
|
||||
ar->v2d.cur.ymin = (ar->winrct.ymin - (float)y1) / sc->zoom;
|
||||
ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sc->zoom);
|
||||
|
||||
/* normalize 0.0..1.0 */
|
||||
ar->v2d.cur.xmin /= w;
|
||||
@@ -761,25 +761,25 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
static void clip_main_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
|
||||
/* if tracking is in progress, we should synchronize framenr from clipuser
|
||||
* so latest tracked frame would be shown */
|
||||
if (clip && clip->tracking_context)
|
||||
BKE_tracking_sync_user(&sc->user, clip->tracking_context);
|
||||
|
||||
if (sc->flag&SC_LOCK_SELECTION) {
|
||||
ImBuf *tmpibuf= NULL;
|
||||
if (sc->flag & SC_LOCK_SELECTION) {
|
||||
ImBuf *tmpibuf = NULL;
|
||||
|
||||
if (clip && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) {
|
||||
tmpibuf= ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL);
|
||||
if (clip && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
|
||||
tmpibuf = ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (ED_clip_view_selection(sc, ar, 0)) {
|
||||
sc->xof+= sc->xlockof;
|
||||
sc->yof+= sc->ylockof;
|
||||
sc->xof += sc->xlockof;
|
||||
sc->yof += sc->ylockof;
|
||||
}
|
||||
|
||||
if (tmpibuf)
|
||||
@@ -810,7 +810,7 @@ static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCREEN:
|
||||
if (wmn->data==ND_GPENCIL)
|
||||
if (wmn->data == ND_GPENCIL)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
@@ -834,11 +834,11 @@ static void clip_preview_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
|
||||
static void clip_preview_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2D *v2d = &ar->v2d;
|
||||
View2DScrollers *scrollers;
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES;
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES;
|
||||
|
||||
if (sc->flag & SC_LOCK_TIMECURSOR)
|
||||
ED_clip_graph_center_current_frame(scene, ar);
|
||||
@@ -856,7 +856,7 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
|
||||
scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
@@ -931,7 +931,7 @@ static void clip_properties_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
|
||||
static void clip_properties_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
|
||||
BKE_movieclip_update_scopes(sc->clip, &sc->user, &sc->scopes);
|
||||
|
||||
@@ -943,11 +943,11 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCREEN:
|
||||
if (wmn->data==ND_GPENCIL)
|
||||
if (wmn->data ==ND_GPENCIL)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
case NC_BRUSH:
|
||||
if (wmn->action==NA_EDITED)
|
||||
if (wmn->action ==NA_EDITED)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
@@ -958,86 +958,86 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* only called once, from space/spacetypes.c */
|
||||
void ED_spacetype_clip(void)
|
||||
{
|
||||
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype clip");
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype clip");
|
||||
ARegionType *art;
|
||||
|
||||
st->spaceid= SPACE_CLIP;
|
||||
st->spaceid = SPACE_CLIP;
|
||||
strncpy(st->name, "Clip", BKE_ST_MAXNAME);
|
||||
|
||||
st->new= clip_new;
|
||||
st->free= clip_free;
|
||||
st->init= clip_init;
|
||||
st->duplicate= clip_duplicate;
|
||||
st->operatortypes= clip_operatortypes;
|
||||
st->keymap= clip_keymap;
|
||||
st->listener= clip_listener;
|
||||
st->context= clip_context;
|
||||
st->refresh= clip_refresh;
|
||||
st->new = clip_new;
|
||||
st->free = clip_free;
|
||||
st->init = clip_init;
|
||||
st->duplicate = clip_duplicate;
|
||||
st->operatortypes = clip_operatortypes;
|
||||
st->keymap = clip_keymap;
|
||||
st->listener = clip_listener;
|
||||
st->context = clip_context;
|
||||
st->refresh = clip_refresh;
|
||||
|
||||
/* regions: main window */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
|
||||
art->regionid= RGN_TYPE_WINDOW;
|
||||
art->init= clip_main_area_init;
|
||||
art->draw= clip_main_area_draw;
|
||||
art->listener= clip_main_area_listener;
|
||||
art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL;
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region");
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->init = clip_main_area_init;
|
||||
art->draw = clip_main_area_draw;
|
||||
art->listener = clip_main_area_listener;
|
||||
art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* preview */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype clip region preview");
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region preview");
|
||||
art->regionid = RGN_TYPE_PREVIEW;
|
||||
art->prefsizey = 240;
|
||||
art->init= clip_preview_area_init;
|
||||
art->draw= clip_preview_area_draw;
|
||||
art->listener= clip_preview_area_listener;
|
||||
art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
||||
art->init = clip_preview_area_init;
|
||||
art->draw = clip_preview_area_draw;
|
||||
art->listener = clip_preview_area_listener;
|
||||
art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: properties */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype clip region properties");
|
||||
art->regionid= RGN_TYPE_UI;
|
||||
art->prefsizex= UI_COMPACT_PANEL_WIDTH;
|
||||
art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
|
||||
art->init= clip_properties_area_init;
|
||||
art->draw= clip_properties_area_draw;
|
||||
art->listener= clip_properties_area_listener;
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region properties");
|
||||
art->regionid = RGN_TYPE_UI;
|
||||
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
|
||||
art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
|
||||
art->init = clip_properties_area_init;
|
||||
art->draw = clip_properties_area_draw;
|
||||
art->listener = clip_properties_area_listener;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
ED_clip_buttons_register(art);
|
||||
|
||||
/* regions: tools */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype clip region tools");
|
||||
art->regionid= RGN_TYPE_TOOLS;
|
||||
art->prefsizex= UI_COMPACT_PANEL_WIDTH;
|
||||
art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
|
||||
art->listener= clip_props_area_listener;
|
||||
art->init= clip_tools_area_init;
|
||||
art->draw= clip_tools_area_draw;
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region tools");
|
||||
art->regionid = RGN_TYPE_TOOLS;
|
||||
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
|
||||
art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
|
||||
art->listener = clip_props_area_listener;
|
||||
art->init = clip_tools_area_init;
|
||||
art->draw = clip_tools_area_draw;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* tool properties */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype clip tool properties region");
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip tool properties region");
|
||||
art->regionid = RGN_TYPE_TOOL_PROPS;
|
||||
art->prefsizex= 0;
|
||||
art->prefsizey= 120;
|
||||
art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
|
||||
art->listener= clip_props_area_listener;
|
||||
art->init= clip_tools_area_init;
|
||||
art->draw= clip_tools_area_draw;
|
||||
art->prefsizex = 0;
|
||||
art->prefsizey = 120;
|
||||
art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
|
||||
art->listener = clip_props_area_listener;
|
||||
art->init = clip_tools_area_init;
|
||||
art->draw = clip_tools_area_draw;
|
||||
ED_clip_tool_props_register(art);
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
|
||||
art->regionid= RGN_TYPE_HEADER;
|
||||
art->prefsizey= HEADERY;
|
||||
art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region");
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->prefsizey = HEADERY;
|
||||
art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
|
||||
|
||||
art->init= clip_header_area_init;
|
||||
art->draw= clip_header_area_draw;
|
||||
art->init = clip_header_area_init;
|
||||
art->draw = clip_header_area_draw;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -163,8 +163,8 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
|
||||
View2D *v2d = t->view;
|
||||
float divx, divy;
|
||||
|
||||
divx= v2d->mask.xmax-v2d->mask.xmin;
|
||||
divy= v2d->mask.ymax-v2d->mask.ymin;
|
||||
divx = v2d->mask.xmax-v2d->mask.xmin;
|
||||
divy = v2d->mask.ymax-v2d->mask.ymin;
|
||||
|
||||
r_vec[0] = (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
|
||||
r_vec[1] = (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
|
||||
@@ -337,8 +337,8 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
|
||||
else ED_area_tag_redraw(t->sa);
|
||||
}
|
||||
else if (t->spacetype==SPACE_CLIP) {
|
||||
SpaceClip *sc= (SpaceClip*)t->sa->spacedata.first;
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
SpaceClip *sc = (SpaceClip*)t->sa->spacedata.first;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
|
||||
/* objects could be parented to tracking data, so send this for viewport refresh */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
|
@@ -4941,8 +4941,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
|
||||
ED_node_link_intersect_test(t->sa, 0);
|
||||
}
|
||||
else if (t->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *sc= t->sa->spacedata.first;
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
SpaceClip *sc = t->sa->spacedata.first;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
|
||||
if (t->scene->nodetree) {
|
||||
/* tracks can be used for stabilization nodes,
|
||||
@@ -5448,10 +5448,10 @@ typedef struct TransDataTracking {
|
||||
short coord;
|
||||
} TransDataTracking;
|
||||
|
||||
static void markerToTransDataInit(TransData *td, TransData2D *td2d,
|
||||
TransDataTracking *tdt, MovieTrackingTrack *track, int area, float *loc, float *rel, float *off)
|
||||
static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTracking *tdt, MovieTrackingTrack *track,
|
||||
int area, float *loc, float *rel, float *off)
|
||||
{
|
||||
int anchor = area==TRACK_AREA_POINT && off;
|
||||
int anchor = area == TRACK_AREA_POINT && off;
|
||||
|
||||
tdt->mode = transDataTracking_ModeTracks;
|
||||
|
||||
@@ -5470,16 +5470,16 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d,
|
||||
}
|
||||
td2d->loc[2] = 0.0f;
|
||||
|
||||
tdt->relative= rel;
|
||||
tdt->area= area;
|
||||
tdt->relative = rel;
|
||||
tdt->area = area;
|
||||
|
||||
tdt->markersnr= track->markersnr;
|
||||
tdt->markers= track->markers;
|
||||
tdt->markersnr = track->markersnr;
|
||||
tdt->markers = track->markers;
|
||||
|
||||
if (rel) {
|
||||
if (!anchor) {
|
||||
td2d->loc[0]+= rel[0];
|
||||
td2d->loc[1]+= rel[1];
|
||||
td2d->loc[0] += rel[0];
|
||||
td2d->loc[1] += rel[1];
|
||||
}
|
||||
|
||||
copy_v2_v2(tdt->srelative, rel);
|
||||
@@ -5496,34 +5496,35 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d,
|
||||
memset(td->axismtx, 0, sizeof(td->axismtx));
|
||||
td->axismtx[2][2] = 1.0f;
|
||||
|
||||
td->ext= NULL; td->val= NULL;
|
||||
td->ext= NULL;
|
||||
td->val= NULL;
|
||||
|
||||
td->flag |= TD_SELECTED;
|
||||
td->dist= 0.0;
|
||||
td->dist = 0.0;
|
||||
|
||||
unit_m3(td->mtx);
|
||||
unit_m3(td->smtx);
|
||||
}
|
||||
|
||||
static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
|
||||
TransDataTracking *tdt, MovieTrackingTrack *track)
|
||||
TransDataTracking *tdt, MovieTrackingTrack *track)
|
||||
{
|
||||
MovieTrackingMarker *marker= BKE_tracking_ensure_marker(track, sc->user.framenr);
|
||||
MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr);
|
||||
|
||||
tdt->flag= marker->flag;
|
||||
marker->flag&= ~(MARKER_DISABLED|MARKER_TRACKED);
|
||||
tdt->flag = marker->flag;
|
||||
marker->flag &= ~(MARKER_DISABLED|MARKER_TRACKED);
|
||||
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, track->offset, marker->pos, track->offset);
|
||||
|
||||
if (track->flag&SELECT)
|
||||
if (track->flag & SELECT)
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, marker->pos, NULL, NULL);
|
||||
|
||||
if (track->pat_flag&SELECT) {
|
||||
if (track->pat_flag & SELECT) {
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_min, marker->pos, NULL);
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_max, marker->pos, NULL);
|
||||
}
|
||||
|
||||
if (track->search_flag&SELECT) {
|
||||
if (track->search_flag & SELECT) {
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_SEARCH, track->search_min, marker->pos, NULL);
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_SEARCH, track->search_max, marker->pos, NULL);
|
||||
}
|
||||
@@ -5531,10 +5532,12 @@ static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
|
||||
|
||||
static void transDataTrackingFree(TransInfo *t)
|
||||
{
|
||||
TransDataTracking *tdt= t->customData;
|
||||
TransDataTracking *tdt = t->customData;
|
||||
|
||||
if (tdt) {
|
||||
if (tdt->smarkers) MEM_freeN(tdt->smarkers);
|
||||
if (tdt->smarkers)
|
||||
MEM_freeN(tdt->smarkers);
|
||||
|
||||
MEM_freeN(tdt);
|
||||
}
|
||||
}
|
||||
@@ -5545,7 +5548,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
|
||||
TransData2D *td2d;
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
MovieTrackingTrack *track;
|
||||
MovieTrackingMarker *marker;
|
||||
TransDataTracking *tdt;
|
||||
@@ -5556,33 +5559,38 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
|
||||
|
||||
track = tracksbase->first;
|
||||
while (track) {
|
||||
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) {
|
||||
marker= BKE_tracking_get_marker(track, framenr);
|
||||
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
|
||||
marker = BKE_tracking_get_marker(track, framenr);
|
||||
|
||||
t->total++; /* offset */
|
||||
|
||||
if (track->flag&SELECT) t->total++;
|
||||
if (track->pat_flag&SELECT) t->total+= 2;
|
||||
if (track->search_flag&SELECT) t->total+= 2;
|
||||
if (track->flag & SELECT)
|
||||
t->total++;
|
||||
|
||||
if (track->pat_flag & SELECT)
|
||||
t->total+= 2;
|
||||
|
||||
if (track->search_flag & SELECT)
|
||||
t->total+= 2;
|
||||
}
|
||||
|
||||
track = track->next;
|
||||
}
|
||||
|
||||
if (t->total==0)
|
||||
if (t->total == 0)
|
||||
return;
|
||||
|
||||
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData");
|
||||
td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransTracking TransData2D");
|
||||
tdt = t->customData = MEM_callocN(t->total*sizeof(TransDataTracking), "TransTracking TransDataTracking");
|
||||
|
||||
t->customFree= transDataTrackingFree;
|
||||
t->customFree = transDataTrackingFree;
|
||||
|
||||
/* create actual data */
|
||||
track = tracksbase->first;
|
||||
while (track) {
|
||||
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) {
|
||||
marker= BKE_tracking_get_marker(track, framenr);
|
||||
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
|
||||
marker = BKE_tracking_get_marker(track, framenr);
|
||||
|
||||
trackToTransData(sc, td, td2d, tdt, track);
|
||||
|
||||
@@ -5591,20 +5599,29 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
|
||||
td2d++;
|
||||
tdt++;
|
||||
|
||||
if ((marker->flag&MARKER_DISABLED)==0) {
|
||||
if (track->flag&SELECT) {td++; td2d++; tdt++;}
|
||||
if (track->pat_flag&SELECT) {td+= 2; td2d+= 2;tdt+=2;}
|
||||
if ((marker->flag & MARKER_DISABLED) == 0) {
|
||||
if (track->flag & SELECT) {
|
||||
td++;
|
||||
td2d++;
|
||||
tdt++;
|
||||
}
|
||||
|
||||
if (track->pat_flag & SELECT) {
|
||||
td += 2;
|
||||
td2d += 2;
|
||||
tdt +=2;
|
||||
}
|
||||
}
|
||||
|
||||
if (track->search_flag&SELECT) {
|
||||
td+= 2;
|
||||
td2d+= 2;
|
||||
tdt+= 2;
|
||||
if (track->search_flag & SELECT) {
|
||||
td += 2;
|
||||
td2d += 2;
|
||||
tdt += 2;
|
||||
|
||||
if (marker->flag&MARKER_DISABLED) {
|
||||
td+= 3;
|
||||
td2d+= 3;
|
||||
tdt+= 3;
|
||||
if (marker->flag & MARKER_DISABLED) {
|
||||
td += 3;
|
||||
td2d += 3;
|
||||
tdt += 3;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5614,7 +5631,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
|
||||
}
|
||||
|
||||
static void markerToTransCurveDataInit(TransData *td, TransData2D *td2d, TransDataTracking *tdt,
|
||||
MovieTrackingMarker *marker, MovieTrackingMarker *prev_marker,
|
||||
MovieTrackingMarker *marker, MovieTrackingMarker *prev_marker,
|
||||
short coord, float size)
|
||||
{
|
||||
float frames_delta = (marker->framenr - prev_marker->framenr);
|
||||
@@ -5642,10 +5659,11 @@ static void markerToTransCurveDataInit(TransData *td, TransData2D *td2d, TransDa
|
||||
memset(td->axismtx, 0, sizeof(td->axismtx));
|
||||
td->axismtx[2][2] = 1.0f;
|
||||
|
||||
td->ext= NULL; td->val= NULL;
|
||||
td->ext= NULL;
|
||||
td->val= NULL;
|
||||
|
||||
td->flag |= TD_SELECTED;
|
||||
td->dist= 0.0;
|
||||
td->dist = 0.0;
|
||||
|
||||
unit_m3(td->mtx);
|
||||
unit_m3(td->smtx);
|
||||
@@ -5689,7 +5707,7 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
|
||||
track = track->next;
|
||||
}
|
||||
|
||||
if (t->total==0)
|
||||
if (t->total == 0)
|
||||
return;
|
||||
|
||||
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData");
|
||||
@@ -5756,9 +5774,9 @@ static void createTransTrackingData(bContext *C, TransInfo *t)
|
||||
static void cancelTransTracking(TransInfo *t)
|
||||
{
|
||||
TransDataTracking *tdt = t->customData;
|
||||
SpaceClip *sc= t->sa->spacedata.first;
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
|
||||
SpaceClip *sc = t->sa->spacedata.first;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
MovieTrackingTrack *track;
|
||||
MovieTrackingMarker *marker;
|
||||
int a, framenr = sc->user.framenr;
|
||||
@@ -5772,9 +5790,14 @@ static void cancelTransTracking(TransInfo *t)
|
||||
|
||||
tdt++;
|
||||
|
||||
if (track->flag&SELECT) tdt++;
|
||||
if (track->pat_flag&SELECT) tdt += 2;
|
||||
if (track->search_flag&SELECT) tdt += 2;
|
||||
if (track->flag & SELECT)
|
||||
tdt++;
|
||||
|
||||
if (track->pat_flag & SELECT)
|
||||
tdt += 2;
|
||||
|
||||
if (track->search_flag & SELECT)
|
||||
tdt += 2;
|
||||
}
|
||||
|
||||
track = track->next;
|
||||
@@ -5817,13 +5840,13 @@ void flushTransTracking(TransInfo *t)
|
||||
/* flush to 2d vector from internally used 3d vector */
|
||||
for (a=0, td= t->data, td2d= t->data2d, tdt= t->customData; a<t->total; a++, td2d++, td++, tdt++) {
|
||||
if (tdt->mode == transDataTracking_ModeTracks) {
|
||||
if (t->flag&T_ALT_TRANSFORM) {
|
||||
if (tdt->area==TRACK_AREA_POINT && tdt->relative) {
|
||||
if (t->flag & T_ALT_TRANSFORM) {
|
||||
if (tdt->area == TRACK_AREA_POINT && tdt->relative) {
|
||||
float d[2], d2[2];
|
||||
|
||||
if (!tdt->smarkers) {
|
||||
tdt->smarkers= MEM_callocN(sizeof(*tdt->smarkers)*tdt->markersnr, "flushTransTracking markers");
|
||||
for (a= 0; a<tdt->markersnr; a++)
|
||||
tdt->smarkers = MEM_callocN(sizeof(*tdt->smarkers)*tdt->markersnr, "flushTransTracking markers");
|
||||
for (a = 0; a < tdt->markersnr; a++)
|
||||
copy_v2_v2(tdt->smarkers[a], tdt->markers[a].pos);
|
||||
}
|
||||
|
||||
|
@@ -637,14 +637,14 @@ static void recalcData_image(TransInfo *t)
|
||||
/* helper for recalcData() - for Movie Clip transforms */
|
||||
static void recalcData_clip(TransInfo *t)
|
||||
{
|
||||
SpaceClip *sc= t->sa->spacedata.first;
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
|
||||
SpaceClip *sc = t->sa->spacedata.first;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
MovieTrackingTrack *track;
|
||||
|
||||
flushTransTracking(t);
|
||||
|
||||
track= tracksbase->first;
|
||||
track = tracksbase->first;
|
||||
while (track) {
|
||||
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
|
||||
if (t->mode == TFM_TRANSLATION) {
|
||||
@@ -661,7 +661,7 @@ static void recalcData_clip(TransInfo *t)
|
||||
}
|
||||
}
|
||||
|
||||
track= track->next;
|
||||
track = track->next;
|
||||
}
|
||||
|
||||
DAG_id_tag_update(&clip->id, 0);
|
||||
|
Reference in New Issue
Block a user