Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(48)

Unified Diff: source/blender/blenkernel/intern/object.c

Issue 5285047: Camera tracking integration Base URL: https://svn.blender.org/svnroot/bf-blender/trunk/blender/
Patch Set: Updated to tomato rev41255 Created 12 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: source/blender/blenkernel/intern/object.c
===================================================================
--- source/blender/blenkernel/intern/object.c (revision 41254)
+++ source/blender/blenkernel/intern/object.c (working copy)
@@ -47,6 +47,7 @@
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
@@ -2115,11 +2116,30 @@
no_parent_ipo= val;
}
+static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[4][4])
+{
+ float *fp1, *fp2;
+ float fac1, fac2;
+ int a;
+
+ // include framerate
+ fac1= ( 1.0f / (1.0f + (float)fabs(give_timeoffset(ob))) );
+ if(fac1 >= 1.0f) return 0;
+ fac2= 1.0f-fac1;
+
+ fp1= obmat[0];
+ fp2= slowmat[0];
+ for(a=0; a<16; a++, fp1++, fp2++) {
+ fp1[0]= fac1*fp1[0] + fac2*fp2[0];
+ }
+
+ return 1;
+}
+
void where_is_object_time(Scene *scene, Object *ob, float ctime)
{
- float *fp1, *fp2, slowmat[4][4] = MAT4_UNITY;
- float stime=ctime, fac1, fac2;
- int a;
+ float slowmat[4][4] = MAT4_UNITY;
+ float stime=ctime;
/* new version: correct parent+vertexparent and track+parent */
/* this one only calculates direct attached parent and track */
@@ -2153,16 +2173,8 @@
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
if(ob->partype & PARSLOW) {
- // include framerate
- fac1= ( 1.0f / (1.0f + (float)fabs(give_timeoffset(ob))) );
- if(fac1 >= 1.0f) return;
- fac2= 1.0f-fac1;
-
- fp1= ob->obmat[0];
- fp2= slowmat[0];
- for(a=0; a<16; a++, fp1++, fp2++) {
- fp1[0]= fac1*fp1[0] + fac2*fp2[0];
- }
+ if(!where_is_object_parslow(ob, ob->obmat, slowmat))
+ return;
}
}
else {
@@ -2186,6 +2198,27 @@
else ob->transflag &= ~OB_NEG_SCALE;
}
+/* get object transformation matrix without recalculating dependencies and
+ constraints -- assume dependencies are already solved by depsgraph.
+ no changes to object and it's parent would be done.
+ used for bundles orientation in 3d space relative to parented blender camera */
+void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4])
+{
+ float slowmat[4][4] = MAT4_UNITY;
+
+ if(ob->parent) {
+ Object *par= ob->parent;
+
+ solve_parenting(scene, ob, par, obmat, slowmat, 1);
+
+ if(ob->partype & PARSLOW)
+ where_is_object_parslow(ob, obmat, slowmat);
+ }
+ else {
+ object_to_mat4(ob, obmat);
+ }
+}
+
static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul)
{
float totmat[4][4];
@@ -2942,27 +2975,19 @@
}
}
-/* 'lens' may be set for envmap only */
-void object_camera_matrix(
- RenderData *rd, Object *camera, int winx, int winy, short field_second,
- float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor,
- float *viewdx, float *viewdy
-) {
- Camera *cam=NULL;
- float pixsize;
- float shiftx=0.0, shifty=0.0, winside, viewfac;
- short is_ortho= FALSE;
+void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, float *shiftx, float *shifty,
+ float *clipsta, float *clipend, float *lens, float *sensor_x)
+{
+ Camera *cam= NULL;
- /* question mark */
- (*ycor)= rd->yasp / rd->xasp;
- if(rd->mode & R_FIELDS)
- (*ycor) *= 2.0f;
+ (*shiftx)= 0.0f;
+ (*shifty)= 0.0f;
if(camera->type==OB_CAMERA) {
cam= camera->data;
if(cam->type == CAM_ORTHO) {
- is_ortho= TRUE;
+ *is_ortho= TRUE;
}
/* solve this too... all time depending stuff is in convertblender.c?
@@ -2975,8 +3000,8 @@
execute_ipo(&cam->id, cam->ipo);
}
#endif // XXX old animation system
- shiftx=cam->shiftx;
- shifty=cam->shifty;
+ (*shiftx)=cam->shiftx;
+ (*shifty)=cam->shifty;
(*lens)= cam->lens;
(*clipsta)= cam->clipsta;
(*clipend)= cam->clipend;
@@ -3002,6 +3027,27 @@
}
}
+ (*cam_r)= cam;
+}
+
+/* 'lens' may be set for envmap only */
+void object_camera_matrix(
+ RenderData *rd, Object *camera, int winx, int winy, short field_second,
+ float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, float *sensor_x, float *ycor,
+ float *viewdx, float *viewdy
+) {
+ Camera *cam=NULL;
+ float pixsize;
+ float shiftx=0.0, shifty=0.0, winside, viewfac;
+ short is_ortho= FALSE;
+
+ /* question mark */
+ (*ycor)= rd->yasp / rd->xasp;
+ if(rd->mode & R_FIELDS)
+ (*ycor) *= 2.0f;
+
+ object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, clipsta, clipend, lens, sensor_x);
+
/* ortho only with camera available */
if(cam && is_ortho) {
if(rd->xasp*winx >= rd->yasp*winy) {
@@ -3322,3 +3368,28 @@
ID_NEW(ob->proxy);
ID_NEW(ob->proxy_group);
}
+
+MovieClip *object_get_movieclip(Scene *scene, Object *ob, int use_default)
+{
+ MovieClip *clip= use_default ? scene->clip : NULL;
+ bConstraint *con= ob->constraints.first, *scon= NULL;
+
+ while(con){
+ if(con->type==CONSTRAINT_TYPE_CAMERASOLVER){
+ if(scon==NULL || (scon->flag&CONSTRAINT_OFF))
+ scon= con;
+ }
+
+ con= con->next;
+ }
+
+ if(scon) {
+ bCameraSolverConstraint *solver= scon->data;
+ if((solver->flag&CAMERASOLVER_ACTIVECLIP)==0)
+ clip= solver->clip;
+ else
+ clip= scene->clip;
+ }
+
+ return clip;
+}

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b