Camera tracking integration
=========================== - Track preview widget is now resizeable. - Marker position could now be adjusted from track preview widget.
This commit is contained in:
@@ -213,8 +213,7 @@ class CLIP_PT_track(bpy.types.Panel):
|
||||
|
||||
layout.prop(act_track, "name")
|
||||
|
||||
layout.template_track(clip.tracking, "active_track", \
|
||||
sc.clip_user, clip)
|
||||
layout.template_track(sc, "scopes")
|
||||
|
||||
if act_track:
|
||||
row = layout.row()
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
struct ImBuf;
|
||||
struct Main;
|
||||
struct MovieClip;
|
||||
struct MovieClipScopes;
|
||||
struct MovieClipUser;
|
||||
struct MovieTrackingTrack;
|
||||
|
||||
@@ -56,6 +57,8 @@ void BKE_movieclip_deselect_track(struct MovieClip *clip, struct MovieTrackingTr
|
||||
void BKE_movieclip_set_selection(struct MovieClip *clip, int type, void *sel);
|
||||
void BKE_movieclip_last_selection(struct MovieClip *clip, int *type, void **sel);
|
||||
|
||||
void BKE_movieclip_update_scopes(struct MovieClip *clip, struct MovieClipUser *user, struct MovieClipScopes *scopes);
|
||||
|
||||
void BKE_movieclip_get_cache_segments(struct MovieClip *clip, int *totseg_r, int **points_r);
|
||||
|
||||
#define TRACK_CLEAR_UPTO 0
|
||||
|
||||
@@ -441,6 +441,61 @@ void BKE_movieclip_last_selection(MovieClip *clip, int *type, void **sel)
|
||||
else *sel= clip->last_sel;
|
||||
}
|
||||
|
||||
void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)
|
||||
{
|
||||
void *sel;
|
||||
int sel_type;
|
||||
|
||||
if(scopes->ok) return;
|
||||
|
||||
if(scopes->track_preview) {
|
||||
IMB_freeImBuf(scopes->track_preview);
|
||||
scopes->track_preview= NULL;
|
||||
}
|
||||
|
||||
scopes->marker_pos= NULL;
|
||||
|
||||
if(clip) {
|
||||
BKE_movieclip_last_selection(clip, &sel_type, &sel);
|
||||
|
||||
if(sel_type==MCLIP_SEL_TRACK) {
|
||||
MovieTrackingTrack *track= (MovieTrackingTrack*)sel;
|
||||
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr);
|
||||
|
||||
if(marker->flag&MARKER_DISABLED) {
|
||||
scopes->track_disabled= 1;
|
||||
} else {
|
||||
ImBuf *ibuf= BKE_movieclip_acquire_ibuf(clip, user);
|
||||
|
||||
scopes->track_disabled= 0;
|
||||
|
||||
if(ibuf && ibuf->rect) {
|
||||
ImBuf *tmpibuf;
|
||||
|
||||
tmpibuf= BKE_tracking_acquire_pattern_imbuf(ibuf, track, marker, 1, &scopes->track_pos, NULL);
|
||||
|
||||
if(tmpibuf->rect_float)
|
||||
IMB_rect_from_float(tmpibuf);
|
||||
|
||||
if(tmpibuf->rect)
|
||||
scopes->track_preview= tmpibuf;
|
||||
else
|
||||
IMB_freeImBuf(tmpibuf);
|
||||
|
||||
scopes->marker_pos= marker->pos;
|
||||
scopes->slide_scale[0]= track->pat_max[0]-track->pat_min[0];
|
||||
scopes->slide_scale[1]= track->pat_max[1]-track->pat_min[1];
|
||||
}
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scopes->ok= 1;
|
||||
}
|
||||
|
||||
void free_movieclip(MovieClip *clip)
|
||||
{
|
||||
free_buffers(clip);
|
||||
|
||||
@@ -5012,6 +5012,9 @@ static void lib_link_screen(FileData *fd, Main *main)
|
||||
SpaceClip *sclip= (SpaceClip *)sl;
|
||||
|
||||
sclip->clip= newlibadr_us(fd, sc->id.lib, sclip->clip);
|
||||
|
||||
sclip->scopes.track_preview = NULL;
|
||||
sclip->scopes.ok = 0;
|
||||
}
|
||||
}
|
||||
sa= sa->next;
|
||||
@@ -5244,6 +5247,9 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
|
||||
SpaceClip *sclip= (SpaceClip *)sl;
|
||||
|
||||
sclip->clip= restore_pointer_by_name(newmain, (ID *)sclip->clip, 1);
|
||||
|
||||
sclip->scopes.track_preview = NULL;
|
||||
sclip->scopes.ok = 0;
|
||||
}
|
||||
}
|
||||
sa= sa->next;
|
||||
@@ -11811,6 +11817,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
{
|
||||
bScreen *sc;
|
||||
Camera *cam;
|
||||
|
||||
for (sc= main->screen.first; sc; sc= sc->id.next) {
|
||||
ScrArea *sa;
|
||||
@@ -11824,17 +11831,19 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
|
||||
}
|
||||
}
|
||||
else if(sl->spacetype==SPACE_CLIP) {
|
||||
SpaceClip *sc= (SpaceClip *)sl;
|
||||
if(sc->scopes.track_preview_height==0)
|
||||
sc->scopes.track_preview_height= 120;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Camera *cam;
|
||||
for(cam= main->camera.first; cam; cam= cam->id.next) {
|
||||
if (cam->sensor_x < 0.01) {
|
||||
cam->sensor_x = 32.f;
|
||||
cam->sensor_y = 18.f;
|
||||
|
||||
for(cam= main->camera.first; cam; cam= cam->id.next) {
|
||||
if (cam->sensor_x < 0.01) {
|
||||
cam->sensor_x = 32.f;
|
||||
cam->sensor_y = 18.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +232,7 @@ typedef struct uiLayout uiLayout;
|
||||
#define WAVEFORM (48<<9)
|
||||
#define VECTORSCOPE (49<<9)
|
||||
#define PROGRESSBAR (50<<9)
|
||||
#define TRACKPREVIEW (51<<9)
|
||||
|
||||
#define BUTTYPE (63<<9)
|
||||
|
||||
@@ -726,7 +727,7 @@ void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, int rows, int maxrows, int type);
|
||||
|
||||
void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
|
||||
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, struct PointerRNA *clipptr);
|
||||
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
|
||||
|
||||
/* items */
|
||||
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_movieclip_types.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_rect.h"
|
||||
@@ -725,7 +726,7 @@ static void draw_scope_end(rctf *rect, GLint *scissor)
|
||||
/* outline */
|
||||
glColor4f(0.f, 0.f, 0.f, 0.5f);
|
||||
uiSetRoundBox(15);
|
||||
uiDrawBox(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f);
|
||||
uiDrawBox(GL_LINE_LOOP, rect->xmin-1, rect->ymin-1, rect->xmax+1, rect->ymax+1, 3.0f);
|
||||
}
|
||||
|
||||
static void histogram_draw_one(float r, float g, float b, float alpha, float x, float y, float w, float h, float *data, int res)
|
||||
@@ -1530,6 +1531,114 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
|
||||
fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
||||
}
|
||||
|
||||
static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float zoomx, float zoomy)
|
||||
{
|
||||
ImBuf *scaleibuf;
|
||||
int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy;
|
||||
scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect);
|
||||
|
||||
for(y= 0; y<scaleibuf->y; y++) {
|
||||
for (x= 0; x<scaleibuf->x; x++) {
|
||||
int pixel= scaleibuf->x*y + x;
|
||||
int orig_pixel= ibuf->x*(int)(((float)y)/zoomy) + (int)(((float)x)/zoomx);
|
||||
char *rrgb= (char*)scaleibuf->rect + pixel*4;
|
||||
char *orig_rrgb= (char*)ibuf->rect + orig_pixel*4;
|
||||
rrgb[0]= orig_rrgb[0];
|
||||
rrgb[1]= orig_rrgb[1];
|
||||
rrgb[2]= orig_rrgb[2];
|
||||
rrgb[3]= orig_rrgb[3];
|
||||
}
|
||||
}
|
||||
|
||||
return scaleibuf;
|
||||
}
|
||||
|
||||
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
|
||||
{
|
||||
rctf rect;
|
||||
int ok= 0;
|
||||
GLint scissor[4];
|
||||
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
|
||||
|
||||
rect.xmin = (float)recti->xmin+1;
|
||||
rect.xmax = (float)recti->xmax-1;
|
||||
rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2;
|
||||
rect.ymax = (float)recti->ymax-1;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
/* need scissor test, preview image can draw outside of boundary */
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1));
|
||||
|
||||
if(scopes->track_disabled) {
|
||||
glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
|
||||
uiSetRoundBox(15);
|
||||
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
else if(scopes->track_preview) {
|
||||
int a, off_x, off_y;
|
||||
float zoomx, zoomy;
|
||||
ImBuf *drawibuf;
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
/* draw content of pattern area */
|
||||
glScissor(ar->winrct.xmin+rect.xmin, ar->winrct.ymin+rect.ymin, scissor[2], scissor[3]);
|
||||
|
||||
zoomx= (rect.xmax-rect.xmin) / (scopes->track_preview->x-2.f);
|
||||
zoomy= (rect.ymax-rect.ymin) / (scopes->track_preview->y-2.f);
|
||||
|
||||
off_x= ((int)scopes->track_pos[0]-scopes->track_pos[0]-0.5)*zoomx;
|
||||
off_y= ((int)scopes->track_pos[1]-scopes->track_pos[1]-0.5)*zoomy;
|
||||
|
||||
drawibuf= scale_trackpreview_ibuf(scopes->track_preview, zoomx, zoomy);
|
||||
glaDrawPixelsSafe(off_x+rect.xmin, off_y+rect.ymin, rect.xmax-rect.xmin+1.f-off_x, rect.ymax-rect.ymin+1.f-off_y, drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
|
||||
|
||||
IMB_freeImBuf(drawibuf);
|
||||
|
||||
/* draw cross for pizel position */
|
||||
glTranslatef(off_x+rect.xmin+scopes->track_pos[0]*zoomx, off_y+rect.ymin+scopes->track_pos[1]*zoomy, 0.f);
|
||||
glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin+rect.ymin, rect.xmax-rect.xmin, rect.ymax-rect.ymin);
|
||||
|
||||
for(a= 0; a< 2; a++) {
|
||||
if(a==1) {
|
||||
glLineStipple(3, 0xaaaa);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
UI_ThemeColor(TH_SEL_MARKER);
|
||||
}
|
||||
else {
|
||||
UI_ThemeColor(TH_MARKER_OUTLINE);
|
||||
}
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-10.0f, 0.0f);
|
||||
glVertex2f(10.0f, 0.0f);
|
||||
glVertex2f(0.0f, -10.0f);
|
||||
glVertex2f(0.0f, 10.0f);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
glPopMatrix();
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
|
||||
if(!ok) {
|
||||
glColor4f(0.f, 0.f, 0.f, 0.3f);
|
||||
uiSetRoundBox(15);
|
||||
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
|
||||
}
|
||||
|
||||
/* outline, scale gripper */
|
||||
draw_scope_end(&rect, scissor);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* ****************************************************** */
|
||||
|
||||
|
||||
@@ -4057,6 +4057,78 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
static int ui_numedit_but_TRACKPREVIEW(uiBut *but, uiHandleButtonData *data, int mx, int my)
|
||||
{
|
||||
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
|
||||
/* rcti rect; */
|
||||
int changed= 1;
|
||||
float dx, dy, yfac=1.f;
|
||||
|
||||
dx = mx - data->draglastx;
|
||||
dy = my - data->draglasty;
|
||||
|
||||
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
|
||||
/* resize preview widget itself */
|
||||
scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my);
|
||||
} else {
|
||||
if(scopes->marker_pos) {
|
||||
scopes->marker_pos[0]+= -dx*scopes->slide_scale[0] / (but->block->maxx-but->block->minx);
|
||||
scopes->marker_pos[1]+= -dy*scopes->slide_scale[1] / (but->block->maxy-but->block->miny);
|
||||
}
|
||||
|
||||
scopes->ok= 0;
|
||||
}
|
||||
|
||||
data->draglastx= mx;
|
||||
data->draglasty= my;
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
|
||||
{
|
||||
int mx, my;
|
||||
|
||||
mx= event->x;
|
||||
my= event->y;
|
||||
ui_window_to_block(data->region, block, &mx, &my);
|
||||
|
||||
if(data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
|
||||
data->dragstartx= mx;
|
||||
data->dragstarty= my;
|
||||
data->draglastx= mx;
|
||||
data->draglasty= my;
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
|
||||
/* also do drag the first time */
|
||||
if(ui_numedit_but_TRACKPREVIEW(but, data, mx, my))
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
else if(data->state == BUTTON_STATE_NUM_EDITING) {
|
||||
if(event->type == ESCKEY) {
|
||||
data->cancel= 1;
|
||||
data->escapecancel= 1;
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
else if(event->type == MOUSEMOVE) {
|
||||
if(mx!=data->draglastx || my!=data->draglasty) {
|
||||
if(ui_numedit_but_TRACKPREVIEW(but, data, mx, my))
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
}
|
||||
}
|
||||
else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
|
||||
{
|
||||
uiBut *but = (uiBut *)arg1;
|
||||
@@ -4581,6 +4653,9 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
case INLINK:
|
||||
retval= ui_do_but_LINK(C, but, data, event);
|
||||
break;
|
||||
case TRACKPREVIEW:
|
||||
retval= ui_do_but_TRACKPREVIEW(C, block, but, data, event);
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
@@ -465,6 +465,7 @@ void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
|
||||
void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
|
||||
void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
|
||||
void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
|
||||
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
|
||||
|
||||
/* interface_handlers.c */
|
||||
extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);
|
||||
|
||||
@@ -3049,6 +3049,10 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
wt= widget_type(UI_WTYPE_SCROLL);
|
||||
break;
|
||||
|
||||
case TRACKPREVIEW:
|
||||
ui_draw_but_TRACKPREVIEW(ar, but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
default:
|
||||
wt= widget_type(UI_WTYPE_REGULAR);
|
||||
}
|
||||
|
||||
@@ -336,16 +336,14 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
|
||||
|
||||
/********************* Marker Template ************************/
|
||||
|
||||
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *clipptr)
|
||||
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
PointerRNA trackptr;
|
||||
PointerRNA scopesptr;
|
||||
uiBlock *block;
|
||||
uiBut *bt;
|
||||
rctf rect;
|
||||
MovieTrackingTrack *track;
|
||||
|
||||
(void)userptr;
|
||||
MovieClipScopes *scopes;
|
||||
|
||||
if(!ptr->data)
|
||||
return;
|
||||
@@ -361,16 +359,15 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname, Po
|
||||
return;
|
||||
}
|
||||
|
||||
trackptr= RNA_property_pointer_get(ptr, prop);
|
||||
track= trackptr.data;
|
||||
scopesptr= RNA_property_pointer_get(ptr, prop);
|
||||
scopes= (MovieClipScopes *)scopesptr.data;
|
||||
|
||||
rect.xmin= 0; rect.xmax= 200;
|
||||
rect.ymin= 0; rect.ymax= 120;
|
||||
|
||||
uiLayoutSetContextPointer(layout, "edit_movieclip", clipptr);
|
||||
|
||||
block= uiLayoutAbsoluteBlock(layout);
|
||||
|
||||
bt= uiDefBut(block, BUT_EXTRA, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, rect.ymax-rect.ymin, track, 0, 0, 0, 0, "");
|
||||
uiBlockSetDrawExtraFunc(block, draw_clip_track_widget, userptr->data, clipptr->data);
|
||||
scopes->track_preview_height= (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height;
|
||||
|
||||
bt= uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->track_preview_height, scopes, 0, 0, 0, 0, "");
|
||||
}
|
||||
|
||||
@@ -656,126 +656,3 @@ void draw_clip_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
||||
|
||||
draw_movieclip_cache(sc, ar, clip, scene);
|
||||
}
|
||||
|
||||
static ImBuf *scale_ibuf(ImBuf *ibuf, float zoomx, float zoomy)
|
||||
{
|
||||
ImBuf *scaleibuf;
|
||||
int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy;
|
||||
scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect);
|
||||
|
||||
for(y= 0; y<scaleibuf->y; y++) {
|
||||
for (x= 0; x<scaleibuf->x; x++) {
|
||||
int pixel= scaleibuf->x*y + x;
|
||||
int orig_pixel= ibuf->x*(int)(((float)y)/zoomy) + (int)(((float)x)/zoomx);
|
||||
char *rrgb= (char*)scaleibuf->rect + pixel*4;
|
||||
char *orig_rrgb= (char*)ibuf->rect + orig_pixel*4;
|
||||
rrgb[0]= orig_rrgb[0];
|
||||
rrgb[1]= orig_rrgb[1];
|
||||
rrgb[2]= orig_rrgb[2];
|
||||
rrgb[3]= orig_rrgb[3];
|
||||
}
|
||||
}
|
||||
|
||||
return scaleibuf;
|
||||
}
|
||||
|
||||
void draw_clip_track_widget(const bContext *C, void *trackp, void *userp, void *clipp, rcti *rect)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
MovieClipUser *user= (MovieClipUser *)userp;
|
||||
MovieClip *clip= (MovieClip *)clipp;
|
||||
MovieTrackingTrack *track= (MovieTrackingTrack *)trackp;
|
||||
int ok= 0;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if(track) {
|
||||
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr);
|
||||
|
||||
if(marker->flag&MARKER_DISABLED) {
|
||||
glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
|
||||
uiSetRoundBox(15);
|
||||
uiDrawBox(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 3.0f);
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
else {
|
||||
ImBuf* ibuf= BKE_movieclip_acquire_ibuf(clip, user);
|
||||
|
||||
if(ibuf && ibuf->rect) {
|
||||
float pos[2];
|
||||
ImBuf *tmpibuf;
|
||||
|
||||
tmpibuf= BKE_tracking_acquire_pattern_imbuf(ibuf, track, marker, 1, pos, NULL);
|
||||
|
||||
if(tmpibuf->rect_float)
|
||||
IMB_rect_from_float(tmpibuf);
|
||||
|
||||
if(tmpibuf->rect) {
|
||||
int a;
|
||||
float zoomx, zoomy, off_x, off_y;
|
||||
GLint scissor[4];
|
||||
ImBuf *drawibuf;
|
||||
|
||||
zoomx= ((float)rect->xmax-rect->xmin) / (tmpibuf->x-2);
|
||||
zoomy= ((float)rect->ymax-rect->ymin) / (tmpibuf->y-2);
|
||||
|
||||
off_x= ((int)pos[0]-pos[0]-0.5)*zoomx;
|
||||
off_y= ((int)pos[1]-pos[1]-0.5)*zoomy;
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
|
||||
/* draw content of pattern area */
|
||||
glScissor(ar->winrct.xmin+rect->xmin, ar->winrct.ymin+rect->ymin, scissor[2], scissor[3]);
|
||||
|
||||
drawibuf= scale_ibuf(tmpibuf, zoomx, zoomy);
|
||||
glaDrawPixelsSafe(off_x+rect->xmin, off_y+rect->ymin, rect->xmax-rect->xmin-off_x, rect->ymax-rect->ymin-off_y, drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
|
||||
|
||||
/* draw cross for pizel position */
|
||||
glTranslatef(off_x+rect->xmin+pos[0]*zoomx, off_y+rect->ymin+pos[1]*zoomy, 0.f);
|
||||
glScissor(ar->winrct.xmin + (rect->xmin-1), ar->winrct.ymin+(rect->ymin-1), (rect->xmax+1)-(rect->xmin-1), (rect->ymax+1)-(rect->ymin-1));
|
||||
|
||||
for(a= 0; a< 2; a++) {
|
||||
if(a==1) {
|
||||
glLineStipple(3, 0xaaaa);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
UI_ThemeColor(TH_SEL_MARKER);
|
||||
}
|
||||
else {
|
||||
UI_ThemeColor(TH_MARKER_OUTLINE);
|
||||
}
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-10.0f, 0.0f);
|
||||
glVertex2f(10.0f, 0.0f);
|
||||
glVertex2f(0.0f, -10.0f);
|
||||
glVertex2f(0.0f, 10.0f);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
||||
|
||||
IMB_freeImBuf(drawibuf);
|
||||
}
|
||||
|
||||
IMB_freeImBuf(tmpibuf);
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!ok) {
|
||||
glColor4f(0.f, 0.f, 0.f, 0.3f);
|
||||
uiSetRoundBox(15);
|
||||
uiDrawBox(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
|
||||
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_CLIP) {
|
||||
SpaceClip *sc= sa->spacedata.first;
|
||||
sc->scopes.ok= 0;
|
||||
BKE_movieclip_user_set_frame(&sc->user, cfra);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ void CLIP_OT_detect_features(struct wmOperatorType *ot);
|
||||
|
||||
/* clip_draw.c */
|
||||
void draw_clip_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
|
||||
void draw_clip_track_widget(const struct bContext *C, void *trackp, void *userp, void *clipp, rcti *rect);
|
||||
void draw_clip_track_widget(const bContext *C, void *poin, void *arg1, void *arg2, rcti *rect);
|
||||
|
||||
/* clip_buttons.c */
|
||||
void ED_clip_buttons_register(struct ARegionType *art);
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
#include "ED_clip.h"
|
||||
#include "ED_transform.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
@@ -68,6 +70,20 @@
|
||||
|
||||
#include "clip_intern.h" // own include
|
||||
|
||||
static void clip_scopes_tag_refresh(ScrArea *sa)
|
||||
{
|
||||
SpaceClip *sc= (SpaceClip *)sa->spacedata.first;
|
||||
ARegion *ar;
|
||||
|
||||
/* only while proeprties are visible */
|
||||
for (ar=sa->regionbase.first; ar; ar=ar->next) {
|
||||
if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN)
|
||||
return;
|
||||
}
|
||||
|
||||
sc->scopes.ok=0;
|
||||
}
|
||||
|
||||
/* ******************** default callbacks for clip space ***************** */
|
||||
|
||||
static SpaceLink *clip_new(const bContext *UNUSED(C))
|
||||
@@ -114,9 +130,12 @@ static SpaceLink *clip_new(const bContext *UNUSED(C))
|
||||
/* not spacelink itself */
|
||||
static void clip_free(SpaceLink *sl)
|
||||
{
|
||||
SpaceClip *sclip= (SpaceClip*) sl;
|
||||
SpaceClip *sc= (SpaceClip*) sl;
|
||||
|
||||
sclip->clip= NULL;
|
||||
sc->clip= NULL;
|
||||
|
||||
if(sc->scopes.track_preview)
|
||||
IMB_freeImBuf(sc->scopes.track_preview);
|
||||
}
|
||||
|
||||
/* spacetype; init callback */
|
||||
@@ -145,6 +164,9 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
case NC_SCENE:
|
||||
switch(wmn->data) {
|
||||
case ND_FRAME:
|
||||
clip_scopes_tag_refresh(sa);
|
||||
/* no break! */
|
||||
|
||||
case ND_FRAME_RANGE:
|
||||
ED_area_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
@@ -155,6 +177,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
switch(wmn->data) {
|
||||
case ND_DISPLAY:
|
||||
case ND_SELECT:
|
||||
clip_scopes_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
}
|
||||
@@ -163,6 +186,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
case NA_SELECTED:
|
||||
case NA_EDITED:
|
||||
case NA_EVALUATED:
|
||||
clip_scopes_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
}
|
||||
@@ -171,12 +195,15 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
switch(wmn->data) {
|
||||
case ND_SELECT:
|
||||
ED_area_tag_redraw(sa);
|
||||
clip_scopes_tag_refresh(sa);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_SPACE:
|
||||
if(wmn->data==ND_SPACE_CLIP)
|
||||
if(wmn->data==ND_SPACE_CLIP) {
|
||||
clip_scopes_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -459,6 +486,10 @@ 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);
|
||||
|
||||
BKE_movieclip_update_scopes(sc->clip, &sc->user, &sc->scopes);
|
||||
|
||||
ED_region_panels(C, ar, 1, NULL, -1);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "DNA_tracking_types.h"
|
||||
|
||||
struct anim;
|
||||
struct ImBuf;
|
||||
|
||||
typedef struct MovieClipUser {
|
||||
int framenr; /* current frame number */
|
||||
@@ -69,6 +70,17 @@ typedef struct MovieClip {
|
||||
void *last_sel;
|
||||
} MovieClip;
|
||||
|
||||
typedef struct MovieClipScopes {
|
||||
int ok; /* 1 means scopes are ok and re-calculaito is unneeded */
|
||||
int track_preview_height; /* height of track preview widget */
|
||||
struct ImBuf *track_preview; /* ImBuf displayed in track preview */
|
||||
float track_pos[2]; /* sub-pizel position of marker in track ImBuf */
|
||||
short track_disabled; /* active track is disabled, special notifier should be drawn */
|
||||
char pad[6];
|
||||
float *marker_pos; /* original marker position. used for sliding from preview */
|
||||
float slide_scale[2]; /* scale used for sliding from previewe area */
|
||||
} MovieClipScopes;
|
||||
|
||||
/* MovieClip->source */
|
||||
#define MCLIP_SRC_SEQUENCE 1
|
||||
#define MCLIP_SRC_MOVIE 2
|
||||
|
||||
@@ -66,6 +66,7 @@ struct Scene;
|
||||
struct wmOperator;
|
||||
struct wmTimer;
|
||||
struct MovieClip;
|
||||
struct MovieClipScopes;
|
||||
|
||||
/**
|
||||
* The base structure all the other spaces
|
||||
@@ -572,8 +573,9 @@ typedef struct SpaceClip {
|
||||
float xof, yof; /* user defined offset, image is centered */
|
||||
float zoom; /* user defined zoom level */
|
||||
|
||||
struct MovieClipUser user; /* user of clip */
|
||||
struct MovieClip *clip; /* clip data */
|
||||
struct MovieClipUser user; /* user of clip */
|
||||
struct MovieClip *clip; /* clip data */
|
||||
struct MovieClipScopes scopes; /* different scoped displayed in space panels */
|
||||
|
||||
int flag; /* flags */
|
||||
int pad;
|
||||
|
||||
@@ -102,6 +102,15 @@ static void rna_def_moviecliUuser(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Current Frame", "Get frame number user is points to in clip");
|
||||
}
|
||||
|
||||
static void rna_def_movieClipScopes(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
||||
srna= RNA_def_struct(brna, "MovieClipScopes", NULL);
|
||||
RNA_def_struct_ui_text(srna, "MovieClipScopes", "Scopes for statistical view of a movie clip");
|
||||
}
|
||||
|
||||
|
||||
static void rna_def_movieclip(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
@@ -132,6 +141,7 @@ void RNA_def_movieclip(BlenderRNA *brna)
|
||||
{
|
||||
rna_def_movieclip(brna);
|
||||
rna_def_moviecliUuser(brna);
|
||||
rna_def_movieClipScopes(brna);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2694,8 +2694,15 @@ static void rna_def_space_clip(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Show Disabled", "Show disabled tracks from the footage");
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SC_HIDE_DISABLED);
|
||||
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
|
||||
|
||||
/* scopes */
|
||||
prop= RNA_def_property(srna, "scopes", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "scopes");
|
||||
RNA_def_property_struct_type(prop, "MovieClipScopes");
|
||||
RNA_def_property_ui_text(prop, "Scopes", "Scopes to visualize movie clip statistics.");
|
||||
}
|
||||
|
||||
|
||||
void RNA_def_space(BlenderRNA *brna)
|
||||
{
|
||||
rna_def_space(brna);
|
||||
|
||||
@@ -401,12 +401,8 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
RNA_def_boolean(func, "compact", 0, "", "Use more compact layout.");
|
||||
|
||||
func= RNA_def_function(srna, "template_track", "uiTemplateTrack");
|
||||
RNA_def_function_ui_description(func, "Item. A tarck widget to analyze imaga marker is pointed to.");
|
||||
RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data.");
|
||||
api_ui_item_rna_common(func);
|
||||
parm= RNA_def_pointer(func, "clip", "MovieClip", "", "");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
|
||||
parm= RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
|
||||
|
||||
func= RNA_def_function(srna, "template_list", "uiTemplateList");
|
||||
RNA_def_function_ui_description(func, "Item. A list widget to display data. e.g. vertexgroups.");
|
||||
|
||||
@@ -366,7 +366,7 @@ void uiTemplateReportsBanner(struct uiLayout *layout, struct bContext *C, struct
|
||||
void uiTemplateWaveform(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand){}
|
||||
void uiTemplateVectorscope(struct uiLayout *_self, struct PointerRNA *data, char* property, int expand){}
|
||||
void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact){}
|
||||
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, struct PointerRNA *clipptr){}
|
||||
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname){}
|
||||
|
||||
/* rna render */
|
||||
struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h){return (struct RenderResult *) NULL;}
|
||||
|
||||
Reference in New Issue
Block a user