[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38706] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Mon Jul 25 20:11:22 CEST 2011
Revision: 38706
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38706
Author: nazgul
Date: 2011-07-25 18:11:22 +0000 (Mon, 25 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Split clip hotkeys into two categories:
* Global
* Editing
This allows to re-use such hotkeys as track markers
from properties region without worrying about conflicts.
- Anchor point could now be offseted from marker position.
- Pattern can now be symmetrical relative to marker position only.
- Changes to mouse sliding:
* Left top rectangle used for marker position and now
it's half inside and half outside of marker.
* Right bottom corners are for size.
* Anchor point can be slided with mouse to adjust offset.
- Resolved conflict caused by left-mouse selection option.
Now it works perfectly with sliding -- no more "sticky" keys or so.
- Fixed some typos.
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py
branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py 2011-07-25 18:11:00 UTC (rev 38705)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py 2011-07-25 18:11:22 UTC (rev 38706)
@@ -95,7 +95,9 @@
('Script', 'SCRIPTS_WINDOW', 'WINDOW', []),
('Text', 'TEXT_EDITOR', 'WINDOW', []),
('Console', 'CONSOLE', 'WINDOW', []),
- ('Clip', 'CLIP_EDITOR', 'WINDOW', []),
+ ('Console', 'CONSOLE', 'WINDOW', []),
+ ('Clip Editor', 'CLIP_EDITOR', 'WINDOW', []),
+ ('Clip Globals', 'CLIP_EDITOR', 'WINDOW', []),
('View3D Gesture Circle', 'EMPTY', 'WINDOW', []),
('Gesture Border', 'EMPTY', 'WINDOW', []),
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c 2011-07-25 18:11:00 UTC (rev 38705)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c 2011-07-25 18:11:22 UTC (rev 38706)
@@ -4010,9 +4010,14 @@
len= len_v3(disp);
if(len>FLT_EPSILON) {
- float rmat[4][4];
+ float pos[2], rmat[4][4];
int is_ortho= 0;
+ user.framenr= scene->r.cfra;
+ marker= BKE_tracking_get_marker(track, user.framenr);
+
+ add_v2_v2v2(pos, marker->pos, track->offset);
+
/* calculate lens and sensor size depends on object type */
if(camob->type==OB_CAMERA) {
Camera *camera= (Camera *)camob->data;
@@ -4035,12 +4040,9 @@
ortho_scale= 0.f;
}
- user.framenr= scene->r.cfra;
- marker= BKE_tracking_get_marker(track, user.framenr);
-
if(is_ortho) {
- vec[0]= ortho_scale * (marker->pos[0]-0.5f);
- vec[1]= ortho_scale * (marker->pos[1]-0.5f);
+ vec[0]= ortho_scale * (pos[0]-0.5f);
+ vec[1]= ortho_scale * (pos[1]-0.5f);
vec[2]= -len;
if(aspect>1.f) vec[1]/= aspect;
@@ -4057,8 +4059,8 @@
else {
d= (len*sensor_x) / (2.f*lens);
- vec[0]= d*(2.f*marker->pos[0]-1.f);
- vec[1]= d*(2.f*marker->pos[1]-1.f);
+ vec[0]= d*(2.f*pos[0]-1.f);
+ vec[1]= d*(2.f*pos[1]-1.f);
vec[2]= -len;
if(aspect>1.f) vec[1]/= aspect;
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-07-25 18:11:00 UTC (rev 38705)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-07-25 18:11:22 UTC (rev 38706)
@@ -120,20 +120,14 @@
}
}
- /* marker's center should be inside pattern */
+ /* marker's center should be in center of pattern */
if(event==CLAMP_PAT_DIM || event==CLAMP_PAT_POS) {
float dim[2];
sub_v2_v2v2(dim, track->pat_max, track->pat_min);
for(a= 0; a<2; a++) {
- if(track->pat_min[a] > 0.0f) {
- track->pat_min[a]= 0.0f;
- track->pat_max[a]= dim[a];
- }
- if(track->pat_max[a] < 0.0f) {
- track->pat_max[a]= 0.0f;
- track->pat_min[a]= -dim[a];
- }
+ track->pat_min[a]= -dim[a]/2.f;
+ track->pat_max[a]= dim[a]/2.f;
}
}
}
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c 2011-07-25 18:11:00 UTC (rev 38705)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c 2011-07-25 18:11:22 UTC (rev 38706)
@@ -62,7 +62,7 @@
#include "clip_intern.h" // own include
#define B_MARKER_POS 3
-#define B_MARKER_PAT_POS 4
+#define B_MARKER_OFFSET 4
#define B_MARKER_PAT_DIM 5
#define B_MARKER_SEARCH_POS 6
#define B_MARKER_SEARCH_DIM 7
@@ -105,9 +105,9 @@
to_pixel_space(sc->marker_pos, marker->pos, width, height);
to_pixel_space(sc->track_pat, pat_dim, width, height);
- to_pixel_space(sc->track_pat_pos, pat_pos, width, height);
to_pixel_space(sc->track_search, search_dim, width, height);
to_pixel_space(sc->track_search_pos, search_pos, width, height);
+ to_pixel_space(sc->track_offset, track->offset, width, height);
sc->marker_flag= marker->flag;
@@ -122,17 +122,19 @@
block= uiLayoutAbsoluteBlock(col);
uiBlockBeginAlign(block);
- uiDefBut(block, LABEL, 0, "Position:", 0, 171, 300, 19, NULL, 0, 0, 0, 0, "");
- uiDefButF(block, NUM, B_MARKER_POS, "X:", 10, 152, 145, 19, &sc->marker_pos[0],
+ uiDefBut(block, LABEL, 0, "Position:", 0, 190, 300, 19, NULL, 0, 0, 0, 0, "");
+ uiDefButF(block, NUM, B_MARKER_POS, "X:", 10, 171, 145, 19, &sc->marker_pos[0],
-10*width, 10.0*width, step, digits, "X-position of marker at frame in screen coordinates.");
- uiDefButF(block, NUM, B_MARKER_POS, "Y:", 165, 152, 145, 19, &sc->marker_pos[1],
+ uiDefButF(block, NUM, B_MARKER_POS, "Y:", 165, 171, 145, 19, &sc->marker_pos[1],
-10*height, 10.0*height, step, digits, "Y-position of marker at frame in screen coordinates.");
- uiDefBut(block, LABEL, 0, "Pattern Area:", 0, 133, 300, 19, NULL, 0, 0, 0, 0, "");
- uiDefButF(block, NUM, B_MARKER_PAT_POS, "X:", 10, 114, 145, 19, &sc->track_pat_pos[0],
- -width, width, step, digits, "X-position of pattern at frame in screen coordinates relative to marker's position.");
- uiDefButF(block, NUM, B_MARKER_PAT_POS, "Y:", 165, 114, 145, 19, &sc->track_pat_pos[1],
- -height, height, step, digits, "Y-position of pattern at frame in screen coordinates relative to marker's position.");
+ uiDefBut(block, LABEL, 0, "Offset:", 0, 152, 300, 19, NULL, 0, 0, 0, 0, "");
+ uiDefButF(block, NUM, B_MARKER_OFFSET, "X:", 10, 133, 145, 19, &sc->track_offset[0],
+ -10*width, 10.0*width, step, digits, "X-offset to parenting point.");
+ uiDefButF(block, NUM, B_MARKER_OFFSET, "Y:", 165, 133, 145, 19, &sc->track_offset[1],
+ -10*height, 10.0*height, step, digits, "Y-offset to parenting point.");
+
+ uiDefBut(block, LABEL, 0, "Pattern Area:", 0, 114, 300, 19, NULL, 0, 0, 0, 0, "");
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Width:", 10, 95, 300, 19, &sc->track_pat[0], 3.0f,
10.0*width, step, digits, "Width of marker's pattern in screen soordinates.");
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Height:", 10, 76, 300, 19, &sc->track_pat[1], 3.0f,
@@ -171,31 +173,23 @@
ok= 1;
}
- else if(event==B_MARKER_PAT_POS) {
- float delta[2], side[2];
+ else if(event==B_MARKER_PAT_DIM) {
+ float dim[2], pat_dim[2];
- sub_v2_v2v2(side, track->pat_max, track->pat_min);
- mul_v2_fl(side, 0.5f);
+ sub_v2_v2v2(pat_dim, track->pat_max, track->pat_min);
- delta[0]= sc->track_pat_pos[0]/width;
- delta[1]= sc->track_pat_pos[1]/height;
+ dim[0]= sc->track_pat[0]/width;
+ dim[1]= sc->track_pat[1]/height;
- sub_v2_v2v2(track->pat_min, delta, side);
- add_v2_v2v2(track->pat_max, delta, side);
+ sub_v2_v2(dim, pat_dim);
+ mul_v2_fl(dim, 0.5f);
- BKE_tracking_clamp_track(track, CLAMP_PAT_POS);
+ track->pat_min[0]-= dim[0];
+ track->pat_min[1]-= dim[1];
- ok= 1;
- }
- else if(event==B_MARKER_PAT_DIM) {
- float dim[2];
+ track->pat_max[0]+= dim[0];
+ track->pat_max[1]+= dim[1];
- dim[0]= sc->track_pat[0]/width;
- dim[1]= sc->track_pat[1]/height;
-
- mul_v2_v2fl(track->pat_min, dim, -0.5);
- mul_v2_v2fl(track->pat_max, dim, 0.5);
-
BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
ok= 1;
@@ -217,14 +211,22 @@
ok= 1;
}
else if(event==B_MARKER_SEARCH_DIM) {
- float dim[2];
+ float dim[2], search_dim[2];
+ sub_v2_v2v2(search_dim, track->search_max, track->search_min);
+
dim[0]= sc->track_search[0]/width;
dim[1]= sc->track_search[1]/height;
- mul_v2_v2fl(track->search_min, dim, -0.5);
- mul_v2_v2fl(track->search_max, dim, 0.5);
+ sub_v2_v2(dim, search_dim);
+ mul_v2_fl(dim, 0.5f);
+ track->search_min[0]-= dim[0];
+ track->search_min[1]-= dim[1];
+
+ track->search_max[0]+= dim[0];
+ track->search_max[1]+= dim[1];
+
BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
ok= 1;
@@ -232,6 +234,11 @@
marker->flag= sc->marker_flag;
ok= 1;
+ } else if(event==B_MARKER_OFFSET) {
+ track->offset[0]= sc->track_offset[0]/width;
+ track->offset[1]= sc->track_offset[1]/height;
+
+ ok= 1;
}
if(ok)
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-07-25 18:11:00 UTC (rev 38705)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-07-25 18:11:22 UTC (rev 38706)
@@ -47,6 +47,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_rect.h"
#include "ED_screen.h"
#include "ED_clip.h"
@@ -275,20 +276,48 @@
glPointSize(1.0f);
}
-static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker)
+static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int width, int height)
{
int tiny= sc->flag&SC_SHOW_TINY_MARKER;
int show_pat= 0;
+ float px[2];
UI_ThemeColor(TH_MARKER_OUTLINE);
+ px[0]= 1.0f/width/sc->zoom;
+ px[1]= 1.0f/height/sc->zoom;
+
if((marker->flag&MARKER_DISABLED)==0) {
- if(tiny) glPointSize(3.0f);
- else glPointSize(4.0f);
- glBegin(GL_POINTS);
- glVertex2f(marker->pos[0], marker->pos[1]);
- glEnd();
- glPointSize(1.0f);
+ float pos[2];
+ rctf r;
+
+ BLI_init_rctf(&r, track->pat_min[0], track->pat_max[0], track->pat_min[1], track->pat_max[1]);
+ add_v2_v2v2(pos, marker->pos, track->offset);
+
+ if(BLI_in_rctf(&r, pos[0]-marker->pos[0], pos[1]-marker->pos[1])) {
+ if(tiny) glPointSize(3.0f);
+ else glPointSize(4.0f);
+ glBegin(GL_POINTS);
+ glVertex2f(pos[0], pos[1]);
+ glEnd();
+ glPointSize(1.0f);
+ } else {
+ if(!tiny) glLineWidth(3.0f);
+ glBegin(GL_LINES);
+ glVertex2f(pos[0] + px[0]*2, pos[1]);
+ glVertex2f(pos[0] + px[0]*8, pos[1]);
+
+ glVertex2f(pos[0] - px[0]*2, pos[1]);
+ glVertex2f(pos[0] - px[0]*8, pos[1]);
+
+ glVertex2f(pos[0], pos[1] - px[1]*2);
+ glVertex2f(pos[0], pos[1] - px[1]*8);
+
+ glVertex2f(pos[0], pos[1] + px[1]*2);
+ glVertex2f(pos[0], pos[1] + px[1]*8);
+ glEnd();
+ if(!tiny) glLineWidth(1.0f);
+ }
}
/* pattern and search outline */
@@ -335,29 +364,57 @@
}
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list