Fix T55165: Driving camera lens with property behaves unexpectedly
Differential Revision: https://developer.blender.org/D3438
This commit is contained in:
parent
8a78a53e3b
commit
fbc65c6b28
|
@ -129,9 +129,9 @@ bool BKE_camera_view_frame_fit_to_scene(
|
||||||
struct Scene *scene, struct ViewLayer *view_layer, struct Object *camera_ob,
|
struct Scene *scene, struct ViewLayer *view_layer, struct Object *camera_ob,
|
||||||
float r_co[3], float *r_scale);
|
float r_co[3], float *r_scale);
|
||||||
bool BKE_camera_view_frame_fit_to_coords(
|
bool BKE_camera_view_frame_fit_to_coords(
|
||||||
const struct Scene *scene,
|
const struct Depsgraph *depsgraph,
|
||||||
const float (*cos)[3], int num_cos,
|
const float (*cos)[3], int num_cos,
|
||||||
const struct Object *camera_ob,
|
struct Object *camera_ob,
|
||||||
float r_co[3], float *r_scale);
|
float r_co[3], float *r_scale);
|
||||||
|
|
||||||
void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings);
|
void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings);
|
||||||
|
@ -139,11 +139,11 @@ void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_set
|
||||||
/* Camera multi-view API */
|
/* Camera multi-view API */
|
||||||
|
|
||||||
struct Object *BKE_camera_multiview_render(struct Scene *scene, struct Object *camera, const char *viewname);
|
struct Object *BKE_camera_multiview_render(struct Scene *scene, struct Object *camera, const char *viewname);
|
||||||
void BKE_camera_multiview_view_matrix(struct RenderData *rd, struct Object *camera, const bool is_left, float r_viewmat[4][4]);
|
void BKE_camera_multiview_view_matrix(struct RenderData *rd, const struct Object *camera, const bool is_left, float r_viewmat[4][4]);
|
||||||
void BKE_camera_multiview_model_matrix(struct RenderData *rd, struct Object *camera, const char *viewname, float r_modelmat[4][4]);
|
void BKE_camera_multiview_model_matrix(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4]);
|
||||||
float BKE_camera_multiview_shift_x(struct RenderData *rd, struct Object *camera, const char *viewname);
|
float BKE_camera_multiview_shift_x(struct RenderData *rd, const struct Object *camera, const char *viewname);
|
||||||
void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, struct Object *camera, const char *viewname);
|
void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, const struct Object *camera, const char *viewname);
|
||||||
bool BKE_camera_multiview_spherical_stereo(struct RenderData *rd, struct Object *camera);
|
bool BKE_camera_multiview_spherical_stereo(struct RenderData *rd, const struct Object *camera);
|
||||||
|
|
||||||
/* Camera background image API */
|
/* Camera background image API */
|
||||||
struct CameraBGImage *BKE_camera_background_image_new(struct Camera *cam);
|
struct CameraBGImage *BKE_camera_background_image_new(struct Camera *cam);
|
||||||
|
|
|
@ -49,6 +49,7 @@ extern "C" {
|
||||||
|
|
||||||
/* special struct for use in constraint evaluation */
|
/* special struct for use in constraint evaluation */
|
||||||
typedef struct bConstraintOb {
|
typedef struct bConstraintOb {
|
||||||
|
struct Depsgraph *depsgraph;/* to get evaluated armature. */
|
||||||
struct Scene *scene; /* for system time, part of deglobalization, code nicer later with local time (ton) */
|
struct Scene *scene; /* for system time, part of deglobalization, code nicer later with local time (ton) */
|
||||||
struct Object *ob; /* if pchan, then armature that it comes from, otherwise constraint owner */
|
struct Object *ob; /* if pchan, then armature that it comes from, otherwise constraint owner */
|
||||||
struct bPoseChannel *pchan; /* pose channel that owns the constraints being evaluated */
|
struct bPoseChannel *pchan; /* pose channel that owns the constraints being evaluated */
|
||||||
|
@ -144,7 +145,7 @@ void BKE_constraints_proxylocal_extract(struct ListBase *dst, struct ListBase *s
|
||||||
bool BKE_constraints_proxylocked_owner(struct Object *ob, struct bPoseChannel *pchan);
|
bool BKE_constraints_proxylocked_owner(struct Object *ob, struct bPoseChannel *pchan);
|
||||||
|
|
||||||
/* Constraint Evaluation function prototypes */
|
/* Constraint Evaluation function prototypes */
|
||||||
struct bConstraintOb *BKE_constraints_make_evalob(struct Scene *scene, struct Object *ob, void *subdata, short datatype);
|
struct bConstraintOb *BKE_constraints_make_evalob(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, void *subdata, short datatype);
|
||||||
void BKE_constraints_clear_evalob(struct bConstraintOb *cob);
|
void BKE_constraints_clear_evalob(struct bConstraintOb *cob);
|
||||||
|
|
||||||
void BKE_constraint_mat_convertspace(
|
void BKE_constraint_mat_convertspace(
|
||||||
|
|
|
@ -2239,7 +2239,7 @@ void BKE_pose_where_is_bone(
|
||||||
/* prepare PoseChannel for Constraint solving
|
/* prepare PoseChannel for Constraint solving
|
||||||
* - makes a copy of matrix, and creates temporary struct to use
|
* - makes a copy of matrix, and creates temporary struct to use
|
||||||
*/
|
*/
|
||||||
cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
|
cob = BKE_constraints_make_evalob(depsgraph, scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
|
||||||
|
|
||||||
/* Solve PoseChannel's Constraints */
|
/* Solve PoseChannel's Constraints */
|
||||||
BKE_constraints_solve(depsgraph, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
|
BKE_constraints_solve(depsgraph, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
|
||||||
|
|
|
@ -268,7 +268,7 @@ void BKE_camera_params_from_view3d(CameraParams *params, Depsgraph *depsgraph, c
|
||||||
|
|
||||||
if (rv3d->persp == RV3D_CAMOB) {
|
if (rv3d->persp == RV3D_CAMOB) {
|
||||||
/* camera view */
|
/* camera view */
|
||||||
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
|
const Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
|
||||||
BKE_camera_params_from_object(params, ob_camera_eval);
|
BKE_camera_params_from_object(params, ob_camera_eval);
|
||||||
|
|
||||||
params->zoom = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
|
params->zoom = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
|
||||||
|
@ -666,16 +666,18 @@ bool BKE_camera_view_frame_fit_to_scene(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BKE_camera_view_frame_fit_to_coords(
|
bool BKE_camera_view_frame_fit_to_coords(
|
||||||
const Scene *scene, const float (*cos)[3], int num_cos, const Object *camera_ob,
|
const Depsgraph *depsgraph, const float (*cos)[3], int num_cos, Object *camera_ob,
|
||||||
float r_co[3], float *r_scale)
|
float r_co[3], float *r_scale)
|
||||||
{
|
{
|
||||||
|
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
|
||||||
|
Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob);
|
||||||
CameraParams params;
|
CameraParams params;
|
||||||
CameraViewFrameData data_cb;
|
CameraViewFrameData data_cb;
|
||||||
|
|
||||||
/* just in case */
|
/* just in case */
|
||||||
*r_scale = 1.0f;
|
*r_scale = 1.0f;
|
||||||
|
|
||||||
camera_frame_fit_data_init(scene, camera_ob, ¶ms, &data_cb);
|
camera_frame_fit_data_init(scene_eval, camera_ob_eval, ¶ms, &data_cb);
|
||||||
|
|
||||||
/* run callback on all given coordinates */
|
/* run callback on all given coordinates */
|
||||||
while (num_cos--) {
|
while (num_cos--) {
|
||||||
|
@ -687,12 +689,12 @@ bool BKE_camera_view_frame_fit_to_coords(
|
||||||
|
|
||||||
/******************* multiview matrix functions ***********************/
|
/******************* multiview matrix functions ***********************/
|
||||||
|
|
||||||
static void camera_model_matrix(Object *camera, float r_modelmat[4][4])
|
static void camera_model_matrix(const Object *camera, float r_modelmat[4][4])
|
||||||
{
|
{
|
||||||
copy_m4_m4(r_modelmat, camera->obmat);
|
copy_m4_m4(r_modelmat, camera->obmat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void camera_stereo3d_model_matrix(Object *camera, const bool is_left, float r_modelmat[4][4])
|
static void camera_stereo3d_model_matrix(const Object *camera, const bool is_left, float r_modelmat[4][4])
|
||||||
{
|
{
|
||||||
Camera *data = (Camera *)camera->data;
|
Camera *data = (Camera *)camera->data;
|
||||||
float interocular_distance, convergence_distance;
|
float interocular_distance, convergence_distance;
|
||||||
|
@ -790,7 +792,7 @@ static void camera_stereo3d_model_matrix(Object *camera, const bool is_left, flo
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the view matrix is used by the viewport drawing, it is basically the inverted model matrix */
|
/* the view matrix is used by the viewport drawing, it is basically the inverted model matrix */
|
||||||
void BKE_camera_multiview_view_matrix(RenderData *rd, Object *camera, const bool is_left, float r_viewmat[4][4])
|
void BKE_camera_multiview_view_matrix(RenderData *rd, const Object *camera, const bool is_left, float r_viewmat[4][4])
|
||||||
{
|
{
|
||||||
BKE_camera_multiview_model_matrix(rd, camera, is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME, r_viewmat);
|
BKE_camera_multiview_model_matrix(rd, camera, is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME, r_viewmat);
|
||||||
invert_m4(r_viewmat);
|
invert_m4(r_viewmat);
|
||||||
|
@ -805,7 +807,7 @@ static bool camera_is_left(const char *viewname)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_camera_multiview_model_matrix(RenderData *rd, Object *camera, const char *viewname, float r_modelmat[4][4])
|
void BKE_camera_multiview_model_matrix(RenderData *rd, const Object *camera, const char *viewname, float r_modelmat[4][4])
|
||||||
{
|
{
|
||||||
const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0;
|
const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0;
|
||||||
|
|
||||||
|
@ -822,7 +824,7 @@ void BKE_camera_multiview_model_matrix(RenderData *rd, Object *camera, const cha
|
||||||
normalize_m4(r_modelmat);
|
normalize_m4(r_modelmat);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BKE_camera_multiview_spherical_stereo(RenderData *rd, Object *camera)
|
bool BKE_camera_multiview_spherical_stereo(RenderData *rd, const Object *camera)
|
||||||
{
|
{
|
||||||
Camera *cam;
|
Camera *cam;
|
||||||
const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0;
|
const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0;
|
||||||
|
@ -895,7 +897,7 @@ Object *BKE_camera_multiview_render(Scene *scene, Object *camera, const char *vi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float camera_stereo3d_shift_x(Object *camera, const char *viewname)
|
static float camera_stereo3d_shift_x(const Object *camera, const char *viewname)
|
||||||
{
|
{
|
||||||
Camera *data = camera->data;
|
Camera *data = camera->data;
|
||||||
float shift = data->shiftx;
|
float shift = data->shiftx;
|
||||||
|
@ -933,7 +935,7 @@ static float camera_stereo3d_shift_x(Object *camera, const char *viewname)
|
||||||
return shift;
|
return shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
float BKE_camera_multiview_shift_x(RenderData *rd, Object *camera, const char *viewname)
|
float BKE_camera_multiview_shift_x(RenderData *rd, const Object *camera, const char *viewname)
|
||||||
{
|
{
|
||||||
const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0;
|
const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0;
|
||||||
Camera *data = camera->data;
|
Camera *data = camera->data;
|
||||||
|
@ -951,7 +953,7 @@ float BKE_camera_multiview_shift_x(RenderData *rd, Object *camera, const char *v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_camera_multiview_params(RenderData *rd, CameraParams *params, Object *camera, const char *viewname)
|
void BKE_camera_multiview_params(RenderData *rd, CameraParams *params, const Object *camera, const char *viewname)
|
||||||
{
|
{
|
||||||
if (camera->type == OB_CAMERA) {
|
if (camera->type == OB_CAMERA) {
|
||||||
params->shiftx = BKE_camera_multiview_shift_x(rd, camera, viewname);
|
params->shiftx = BKE_camera_multiview_shift_x(rd, camera, viewname);
|
||||||
|
|
|
@ -84,6 +84,9 @@
|
||||||
|
|
||||||
#include "BIK_api.h"
|
#include "BIK_api.h"
|
||||||
|
|
||||||
|
#include "DEG_depsgraph.h"
|
||||||
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
# include "BPY_extern.h"
|
# include "BPY_extern.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -116,7 +119,7 @@ void BKE_constraint_unique_name(bConstraint *con, ListBase *list)
|
||||||
|
|
||||||
/* package an object/bone for use in constraint evaluation */
|
/* package an object/bone for use in constraint evaluation */
|
||||||
/* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */
|
/* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */
|
||||||
bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subdata, short datatype)
|
bConstraintOb *BKE_constraints_make_evalob(Depsgraph *depsgraph, Scene *scene, Object *ob, void *subdata, short datatype)
|
||||||
{
|
{
|
||||||
bConstraintOb *cob;
|
bConstraintOb *cob;
|
||||||
|
|
||||||
|
@ -125,6 +128,7 @@ bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subda
|
||||||
|
|
||||||
/* for system time, part of deglobalization, code nicer later with local time (ton) */
|
/* for system time, part of deglobalization, code nicer later with local time (ton) */
|
||||||
cob->scene = scene;
|
cob->scene = scene;
|
||||||
|
cob->depsgraph = depsgraph;
|
||||||
|
|
||||||
/* based on type of available data */
|
/* based on type of available data */
|
||||||
switch (datatype) {
|
switch (datatype) {
|
||||||
|
@ -3903,20 +3907,25 @@ static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void
|
||||||
|
|
||||||
static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
||||||
{
|
{
|
||||||
|
Depsgraph *depsgraph = cob->depsgraph;
|
||||||
Scene *scene = cob->scene;
|
Scene *scene = cob->scene;
|
||||||
bFollowTrackConstraint *data = con->data;
|
bFollowTrackConstraint *data = con->data;
|
||||||
MovieClip *clip = data->clip;
|
MovieClip *clip = data->clip;
|
||||||
MovieTracking *tracking;
|
MovieTracking *tracking;
|
||||||
MovieTrackingTrack *track;
|
MovieTrackingTrack *track;
|
||||||
MovieTrackingObject *tracking_object;
|
MovieTrackingObject *tracking_object;
|
||||||
Object *camob = data->camera ? data->camera : scene->camera;
|
|
||||||
|
Object *camob_eval = DEG_get_evaluated_object(
|
||||||
|
depsgraph,
|
||||||
|
data->camera ? data->camera : scene->camera);
|
||||||
|
|
||||||
float ctime = BKE_scene_frame_get(scene);
|
float ctime = BKE_scene_frame_get(scene);
|
||||||
float framenr;
|
float framenr;
|
||||||
|
|
||||||
if (data->flag & FOLLOWTRACK_ACTIVECLIP)
|
if (data->flag & FOLLOWTRACK_ACTIVECLIP)
|
||||||
clip = scene->clip;
|
clip = scene->clip;
|
||||||
|
|
||||||
if (!clip || !data->track[0] || !camob)
|
if (!clip || !data->track[0] || !camob_eval)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tracking = &clip->tracking;
|
tracking = &clip->tracking;
|
||||||
|
@ -3945,7 +3954,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||||
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) {
|
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) {
|
||||||
float imat[4][4];
|
float imat[4][4];
|
||||||
|
|
||||||
copy_m4_m4(mat, camob->obmat);
|
copy_m4_m4(mat, camob_eval->obmat);
|
||||||
|
|
||||||
BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, imat);
|
BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, imat);
|
||||||
invert_m4(imat);
|
invert_m4(imat);
|
||||||
|
@ -3954,7 +3963,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||||
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
|
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BKE_tracking_get_camera_object_matrix(cob->scene, camob, mat);
|
BKE_tracking_get_camera_object_matrix(cob->scene, camob_eval, mat);
|
||||||
|
|
||||||
mul_m4_m4m4(cob->matrix, obmat, mat);
|
mul_m4_m4m4(cob->matrix, obmat, mat);
|
||||||
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
|
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
|
||||||
|
@ -3966,7 +3975,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||||
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;
|
float len, d;
|
||||||
|
|
||||||
BKE_object_where_is_calc_mat4(scene, camob, mat);
|
BKE_object_where_is_calc_mat4(scene, camob_eval, mat);
|
||||||
|
|
||||||
/* camera axis */
|
/* camera axis */
|
||||||
vec[0] = 0.0f;
|
vec[0] = 0.0f;
|
||||||
|
@ -4034,7 +4043,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||||
}
|
}
|
||||||
|
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
BKE_camera_params_from_object(¶ms, camob);
|
BKE_camera_params_from_object(¶ms, camob_eval);
|
||||||
|
|
||||||
if (params.is_ortho) {
|
if (params.is_ortho) {
|
||||||
vec[0] = params.ortho_scale * (pos[0] - 0.5f + params.shiftx);
|
vec[0] = params.ortho_scale * (pos[0] - 0.5f + params.shiftx);
|
||||||
|
@ -4046,9 +4055,9 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||||
else
|
else
|
||||||
vec[0] *= aspect;
|
vec[0] *= aspect;
|
||||||
|
|
||||||
mul_v3_m4v3(disp, camob->obmat, vec);
|
mul_v3_m4v3(disp, camob_eval->obmat, vec);
|
||||||
|
|
||||||
copy_m4_m4(rmat, camob->obmat);
|
copy_m4_m4(rmat, camob_eval->obmat);
|
||||||
zero_v3(rmat[3]);
|
zero_v3(rmat[3]);
|
||||||
mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
|
mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
|
||||||
|
|
||||||
|
@ -4066,10 +4075,10 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||||
else
|
else
|
||||||
vec[0] *= aspect;
|
vec[0] *= aspect;
|
||||||
|
|
||||||
mul_v3_m4v3(disp, camob->obmat, vec);
|
mul_v3_m4v3(disp, camob_eval->obmat, vec);
|
||||||
|
|
||||||
/* apply camera rotation so Z-axis would be co-linear */
|
/* apply camera rotation so Z-axis would be co-linear */
|
||||||
copy_m4_m4(rmat, camob->obmat);
|
copy_m4_m4(rmat, camob_eval->obmat);
|
||||||
zero_v3(rmat[3]);
|
zero_v3(rmat[3]);
|
||||||
mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
|
mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
|
||||||
|
|
||||||
|
@ -4088,7 +4097,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
|
||||||
|
|
||||||
invert_m4_m4(imat, depth_ob->obmat);
|
invert_m4_m4(imat, depth_ob->obmat);
|
||||||
|
|
||||||
mul_v3_m4v3(ray_start, imat, camob->obmat[3]);
|
mul_v3_m4v3(ray_start, imat, camob_eval->obmat[3]);
|
||||||
mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
|
mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
|
||||||
|
|
||||||
sub_v3_v3v3(ray_nor, ray_end, ray_start);
|
sub_v3_v3v3(ray_nor, ray_end, ray_start);
|
||||||
|
@ -4811,6 +4820,7 @@ void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph, Scene *scene,
|
||||||
cob = MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb");
|
cob = MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb");
|
||||||
cob->type = ownertype;
|
cob->type = ownertype;
|
||||||
cob->scene = scene;
|
cob->scene = scene;
|
||||||
|
cob->depsgraph = depsgraph;
|
||||||
switch (ownertype) {
|
switch (ownertype) {
|
||||||
case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */
|
case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */
|
||||||
{
|
{
|
||||||
|
|
|
@ -2132,7 +2132,7 @@ void BKE_object_where_is_calc_time_ex(
|
||||||
/* solve constraints */
|
/* solve constraints */
|
||||||
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
|
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
|
||||||
bConstraintOb *cob;
|
bConstraintOb *cob;
|
||||||
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
cob = BKE_constraints_make_evalob(depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
||||||
BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime);
|
BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime);
|
||||||
BKE_constraints_clear_evalob(cob);
|
BKE_constraints_clear_evalob(cob);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ void BKE_object_eval_constraints(Depsgraph *depsgraph,
|
||||||
* Not sure why, this is from Joshua - sergey
|
* Not sure why, this is from Joshua - sergey
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
cob = BKE_constraints_make_evalob(depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
||||||
BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime);
|
BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime);
|
||||||
BKE_constraints_clear_evalob(cob);
|
BKE_constraints_clear_evalob(cob);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,9 +106,11 @@ void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]);
|
||||||
struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d);
|
struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d);
|
||||||
|
|
||||||
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist);
|
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist);
|
||||||
void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist);
|
void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist);
|
||||||
|
|
||||||
void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens);
|
void ED_view3d_from_object(
|
||||||
|
const struct Object *ob,
|
||||||
|
float ofs[3], float quat[4], float *dist, float *lens);
|
||||||
void ED_view3d_to_object(
|
void ED_view3d_to_object(
|
||||||
const struct Depsgraph *depsgraph, struct Object *ob,
|
const struct Depsgraph *depsgraph, struct Object *ob,
|
||||||
const float ofs[3], const float quat[4], const float dist);
|
const float ofs[3], const float quat[4], const float dist);
|
||||||
|
@ -305,6 +307,7 @@ float ED_view3d_radius_to_dist_persp(const float angle, const float radius);
|
||||||
float ED_view3d_radius_to_dist_ortho(const float lens, const float radius);
|
float ED_view3d_radius_to_dist_ortho(const float lens, const float radius);
|
||||||
float ED_view3d_radius_to_dist(
|
float ED_view3d_radius_to_dist(
|
||||||
const struct View3D *v3d, const struct ARegion *ar,
|
const struct View3D *v3d, const struct ARegion *ar,
|
||||||
|
const struct Depsgraph *depsgraph,
|
||||||
const char persp, const bool use_aspect,
|
const char persp, const bool use_aspect,
|
||||||
const float radius);
|
const float radius);
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
#include "BKE_texture.h"
|
#include "BKE_texture.h"
|
||||||
|
|
||||||
#include "DEG_depsgraph.h"
|
#include "DEG_depsgraph.h"
|
||||||
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
|
|
||||||
|
@ -3083,7 +3084,7 @@ static void proj_paint_state_non_cddm_init(ProjPaintState *ps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void proj_paint_state_viewport_init(
|
static void proj_paint_state_viewport_init(
|
||||||
ProjPaintState *ps, const char symmetry_flag)
|
ProjPaintState *ps, const Depsgraph *depsgraph, const char symmetry_flag)
|
||||||
{
|
{
|
||||||
float mat[3][3];
|
float mat[3][3];
|
||||||
float viewmat[4][4];
|
float viewmat[4][4];
|
||||||
|
@ -3144,17 +3145,17 @@ static void proj_paint_state_viewport_init(
|
||||||
invert_m4_m4(viewinv, viewmat);
|
invert_m4_m4(viewinv, viewmat);
|
||||||
}
|
}
|
||||||
else if (ps->source == PROJ_SRC_IMAGE_CAM) {
|
else if (ps->source == PROJ_SRC_IMAGE_CAM) {
|
||||||
Object *cam_ob = ps->scene->camera;
|
Object *cam_ob_eval = DEG_get_evaluated_object(depsgraph, ps->scene->camera);
|
||||||
CameraParams params;
|
CameraParams params;
|
||||||
|
|
||||||
/* viewmat & viewinv */
|
/* viewmat & viewinv */
|
||||||
copy_m4_m4(viewinv, cam_ob->obmat);
|
copy_m4_m4(viewinv, cam_ob_eval->obmat);
|
||||||
normalize_m4(viewinv);
|
normalize_m4(viewinv);
|
||||||
invert_m4_m4(viewmat, viewinv);
|
invert_m4_m4(viewmat, viewinv);
|
||||||
|
|
||||||
/* window matrix, clipping and ortho */
|
/* window matrix, clipping and ortho */
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
BKE_camera_params_from_object(¶ms, cam_ob);
|
BKE_camera_params_from_object(¶ms, cam_ob_eval);
|
||||||
BKE_camera_params_compute_viewplane(¶ms, ps->winx, ps->winy, 1.0f, 1.0f);
|
BKE_camera_params_compute_viewplane(¶ms, ps->winx, ps->winy, 1.0f, 1.0f);
|
||||||
BKE_camera_params_compute_matrix(¶ms);
|
BKE_camera_params_compute_matrix(¶ms);
|
||||||
|
|
||||||
|
@ -3858,7 +3859,7 @@ static void project_paint_begin(
|
||||||
proj_paint_state_cavity_init(ps);
|
proj_paint_state_cavity_init(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
proj_paint_state_viewport_init(ps, symmetry_flag);
|
proj_paint_state_viewport_init(ps, CTX_data_depsgraph(C), symmetry_flag);
|
||||||
|
|
||||||
/* calculate vert screen coords
|
/* calculate vert screen coords
|
||||||
* run this early so we can calculate the x/y resolution of our bucket rect */
|
* run this early so we can calculate the x/y resolution of our bucket rect */
|
||||||
|
|
|
@ -302,6 +302,7 @@ static void view3d_camera_border(
|
||||||
{
|
{
|
||||||
CameraParams params;
|
CameraParams params;
|
||||||
rctf rect_view, rect_camera;
|
rctf rect_view, rect_camera;
|
||||||
|
Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
|
||||||
|
|
||||||
/* get viewport viewplane */
|
/* get viewport viewplane */
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
|
@ -316,7 +317,7 @@ static void view3d_camera_border(
|
||||||
/* fallback for non camera objects */
|
/* fallback for non camera objects */
|
||||||
params.clipsta = v3d->near;
|
params.clipsta = v3d->near;
|
||||||
params.clipend = v3d->far;
|
params.clipend = v3d->far;
|
||||||
BKE_camera_params_from_object(¶ms, v3d->camera);
|
BKE_camera_params_from_object(¶ms, camera_eval);
|
||||||
if (no_shift) {
|
if (no_shift) {
|
||||||
params.shiftx = 0.0f;
|
params.shiftx = 0.0f;
|
||||||
params.shifty = 0.0f;
|
params.shifty = 0.0f;
|
||||||
|
@ -1417,13 +1418,16 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
|
||||||
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
|
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
|
||||||
CameraParams params;
|
CameraParams params;
|
||||||
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
|
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
|
||||||
|
const Object *camera_eval = DEG_get_evaluated_object(
|
||||||
|
depsgraph,
|
||||||
|
camera);
|
||||||
|
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
/* fallback for non camera objects */
|
/* fallback for non camera objects */
|
||||||
params.clipsta = v3d->near;
|
params.clipsta = v3d->near;
|
||||||
params.clipend = v3d->far;
|
params.clipend = v3d->far;
|
||||||
BKE_camera_params_from_object(¶ms, camera);
|
BKE_camera_params_from_object(¶ms, camera_eval);
|
||||||
BKE_camera_multiview_params(&scene->r, ¶ms, camera, viewname);
|
BKE_camera_multiview_params(&scene->r, ¶ms, camera_eval, viewname);
|
||||||
BKE_camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp);
|
BKE_camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp);
|
||||||
BKE_camera_params_compute_matrix(¶ms);
|
BKE_camera_params_compute_matrix(¶ms);
|
||||||
|
|
||||||
|
@ -1597,11 +1601,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
|
||||||
|
|
||||||
{
|
{
|
||||||
CameraParams params;
|
CameraParams params;
|
||||||
Object *view_camera = BKE_camera_multiview_render(scene, v3d.camera, viewname);
|
const Object *view_camera_eval = DEG_get_evaluated_object(
|
||||||
|
depsgraph,
|
||||||
|
BKE_camera_multiview_render(scene, v3d.camera, viewname));
|
||||||
|
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
BKE_camera_params_from_object(¶ms, view_camera);
|
BKE_camera_params_from_object(¶ms, view_camera_eval);
|
||||||
BKE_camera_multiview_params(&scene->r, ¶ms, view_camera, viewname);
|
BKE_camera_multiview_params(&scene->r, ¶ms, view_camera_eval, viewname);
|
||||||
BKE_camera_params_compute_viewplane(¶ms, width, height, scene->r.xasp, scene->r.yasp);
|
BKE_camera_params_compute_viewplane(¶ms, width, height, scene->r.xasp, scene->r.yasp);
|
||||||
BKE_camera_params_compute_matrix(¶ms);
|
BKE_camera_params_compute_matrix(¶ms);
|
||||||
|
|
||||||
|
|
|
@ -2654,7 +2654,7 @@ static void view3d_from_minmax(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok_dist) {
|
if (ok_dist) {
|
||||||
new_dist = ED_view3d_radius_to_dist(v3d, ar, persp, true, (size / 2) * VIEW3D_MARGIN);
|
new_dist = ED_view3d_radius_to_dist(v3d, ar, CTX_data_depsgraph(C), persp, true, (size / 2) * VIEW3D_MARGIN);
|
||||||
if (rv3d->is_persp) {
|
if (rv3d->is_persp) {
|
||||||
/* don't zoom closer than the near clipping plane */
|
/* don't zoom closer than the near clipping plane */
|
||||||
new_dist = max_ff(new_dist, v3d->near * 1.5f);
|
new_dist = max_ff(new_dist, v3d->near * 1.5f);
|
||||||
|
@ -3678,7 +3678,8 @@ static void axis_set_view(
|
||||||
dist = rv3d->dist;
|
dist = rv3d->dist;
|
||||||
|
|
||||||
/* so we animate _from_ the camera location */
|
/* so we animate _from_ the camera location */
|
||||||
ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, &rv3d->dist, NULL);
|
Object *camera_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), v3d->camera);
|
||||||
|
ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL);
|
||||||
|
|
||||||
ED_view3d_smooth_view(
|
ED_view3d_smooth_view(
|
||||||
C, v3d, ar, smooth_viewtx,
|
C, v3d, ar, smooth_viewtx,
|
||||||
|
|
|
@ -1067,6 +1067,7 @@ float ED_view3d_radius_to_dist_ortho(const float lens, const float radius)
|
||||||
*/
|
*/
|
||||||
float ED_view3d_radius_to_dist(
|
float ED_view3d_radius_to_dist(
|
||||||
const View3D *v3d, const ARegion *ar,
|
const View3D *v3d, const ARegion *ar,
|
||||||
|
const struct Depsgraph *depsgraph,
|
||||||
const char persp, const bool use_aspect,
|
const char persp, const bool use_aspect,
|
||||||
const float radius)
|
const float radius)
|
||||||
{
|
{
|
||||||
|
@ -1087,7 +1088,8 @@ float ED_view3d_radius_to_dist(
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
params.clipsta = v3d->near;
|
params.clipsta = v3d->near;
|
||||||
params.clipend = v3d->far;
|
params.clipend = v3d->far;
|
||||||
BKE_camera_params_from_object(¶ms, v3d->camera);
|
Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
|
||||||
|
BKE_camera_params_from_object(¶ms, camera_eval);
|
||||||
|
|
||||||
lens = params.lens;
|
lens = params.lens;
|
||||||
sensor_size = BKE_camera_sensor_size(params.sensor_fit, params.sensor_x, params.sensor_y);
|
sensor_size = BKE_camera_sensor_size(params.sensor_fit, params.sensor_x, params.sensor_y);
|
||||||
|
@ -1277,7 +1279,7 @@ bool ED_view3d_lock(RegionView3D *rv3d)
|
||||||
* \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
|
* \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
|
||||||
* \param dist The view distance from ofs, normally from RegionView3D.dist.
|
* \param dist The view distance from ofs, normally from RegionView3D.dist.
|
||||||
*/
|
*/
|
||||||
void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist)
|
void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist)
|
||||||
{
|
{
|
||||||
float nmat[3][3];
|
float nmat[3][3];
|
||||||
|
|
||||||
|
@ -1322,13 +1324,14 @@ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], c
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the RegionView3D members from an objects transformation and optionally lens.
|
* Set the RegionView3D members from an objects transformation and optionally lens.
|
||||||
|
* \param depsgraph The depsgraph to get the evaluated object for the lens calculation.
|
||||||
* \param ob The object to set the view to.
|
* \param ob The object to set the view to.
|
||||||
* \param ofs The view offset to be set, normally from RegionView3D.ofs.
|
* \param ofs The view offset to be set, normally from RegionView3D.ofs.
|
||||||
* \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat.
|
* \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat.
|
||||||
* \param dist The view distance from ofs to be set, normally from RegionView3D.dist.
|
* \param dist The view distance from ofs to be set, normally from RegionView3D.dist.
|
||||||
* \param lens The view lens angle set for cameras and lamps, normally from View3D.lens.
|
* \param lens The view lens angle set for cameras and lamps, normally from View3D.lens.
|
||||||
*/
|
*/
|
||||||
void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
|
void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
|
||||||
{
|
{
|
||||||
ED_view3d_from_m4(ob->obmat, ofs, quat, dist);
|
ED_view3d_from_m4(ob->obmat, ofs, quat, dist);
|
||||||
|
|
||||||
|
@ -1343,6 +1346,7 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the object transformation from RegionView3D members.
|
* Set the object transformation from RegionView3D members.
|
||||||
|
* \param depsgraph The depsgraph to get the evaluated object parent for the transformation calculation.
|
||||||
* \param ob The object which has the transformation assigned.
|
* \param ob The object which has the transformation assigned.
|
||||||
* \param ofs The view offset, normally from RegionView3D.ofs.
|
* \param ofs The view offset, normally from RegionView3D.ofs.
|
||||||
* \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
|
* \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "BKE_scene.h"
|
#include "BKE_scene.h"
|
||||||
|
|
||||||
#include "DEG_depsgraph.h"
|
#include "DEG_depsgraph.h"
|
||||||
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
|
|
||||||
|
@ -513,25 +514,26 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
|
||||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||||
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
|
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
|
||||||
Object *camera_ob = v3d ? v3d->camera : scene->camera;
|
Object *camera_ob = v3d ? v3d->camera : scene->camera;
|
||||||
|
Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob);
|
||||||
|
|
||||||
float r_co[3]; /* the new location to apply */
|
float r_co[3]; /* the new location to apply */
|
||||||
float r_scale; /* only for ortho cameras */
|
float r_scale; /* only for ortho cameras */
|
||||||
|
|
||||||
if (camera_ob == NULL) {
|
if (camera_ob_eval == NULL) {
|
||||||
BKE_report(op->reports, RPT_ERROR, "No active camera");
|
BKE_report(op->reports, RPT_ERROR, "No active camera");
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function does all the important stuff */
|
/* this function does all the important stuff */
|
||||||
if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob, r_co, &r_scale)) {
|
if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob_eval, r_co, &r_scale)) {
|
||||||
ObjectTfmProtectedChannels obtfm;
|
ObjectTfmProtectedChannels obtfm;
|
||||||
float obmat_new[4][4];
|
float obmat_new[4][4];
|
||||||
|
|
||||||
if ((camera_ob->type == OB_CAMERA) && (((Camera *)camera_ob->data)->type == CAM_ORTHO)) {
|
if ((camera_ob_eval->type == OB_CAMERA) && (((Camera *)camera_ob_eval->data)->type == CAM_ORTHO)) {
|
||||||
((Camera *)camera_ob->data)->ortho_scale = r_scale;
|
((Camera *)camera_ob->data)->ortho_scale = r_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_m4_m4(obmat_new, camera_ob->obmat);
|
copy_m4_m4(obmat_new, camera_ob_eval->obmat);
|
||||||
copy_v3_v3(obmat_new[3], r_co);
|
copy_v3_v3(obmat_new[3], r_co);
|
||||||
|
|
||||||
/* only touch location */
|
/* only touch location */
|
||||||
|
|
|
@ -89,6 +89,8 @@ static const EnumPropertyItem space_items[] = {
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
|
|
||||||
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
static void rna_Object_select_set(Object *ob, bContext *C, ReportList *reports, int action)
|
static void rna_Object_select_set(Object *ob, bContext *C, ReportList *reports, int action)
|
||||||
|
@ -173,13 +175,14 @@ static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseC
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_Object_calc_matrix_camera(
|
static void rna_Object_calc_matrix_camera(
|
||||||
Object *ob, float mat_ret[16], int width, int height, float scalex, float scaley)
|
Object *ob, Depsgraph *depsgraph, float mat_ret[16], int width, int height, float scalex, float scaley)
|
||||||
{
|
{
|
||||||
|
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||||
CameraParams params;
|
CameraParams params;
|
||||||
|
|
||||||
/* setup parameters */
|
/* setup parameters */
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
BKE_camera_params_from_object(¶ms, ob);
|
BKE_camera_params_from_object(¶ms, ob_eval);
|
||||||
|
|
||||||
/* compute matrix, viewplane, .. */
|
/* compute matrix, viewplane, .. */
|
||||||
BKE_camera_params_compute_viewplane(¶ms, width, height, scalex, scaley);
|
BKE_camera_params_compute_viewplane(¶ms, width, height, scalex, scaley);
|
||||||
|
@ -189,9 +192,9 @@ static void rna_Object_calc_matrix_camera(
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_Object_camera_fit_coords(
|
static void rna_Object_camera_fit_coords(
|
||||||
Object *ob, Scene *scene, int num_cos, float *cos, float co_ret[3], float *scale_ret)
|
Object *ob, Depsgraph *depsgraph, int num_cos, float *cos, float co_ret[3], float *scale_ret)
|
||||||
{
|
{
|
||||||
BKE_camera_view_frame_fit_to_coords(scene, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret);
|
BKE_camera_view_frame_fit_to_coords(depsgraph, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copied from Mesh_getFromObject and adapted to RNA interface */
|
/* copied from Mesh_getFromObject and adapted to RNA interface */
|
||||||
|
@ -518,6 +521,9 @@ void RNA_api_object(StructRNA *srna)
|
||||||
func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera");
|
func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera");
|
||||||
RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object "
|
RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object "
|
||||||
"(mostly useful for Camera and Lamp types)");
|
"(mostly useful for Camera and Lamp types)");
|
||||||
|
parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "",
|
||||||
|
"Depsgraph to get evaluated data from");
|
||||||
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||||
parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX);
|
parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX);
|
||||||
RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
|
RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
|
||||||
RNA_def_property_ui_text(parm, "", "The camera projection matrix");
|
RNA_def_property_ui_text(parm, "", "The camera projection matrix");
|
||||||
|
@ -530,7 +536,8 @@ void RNA_api_object(StructRNA *srna)
|
||||||
func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords");
|
func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords");
|
||||||
RNA_def_function_ui_description(func, "Compute the coordinate (and scale for ortho cameras) "
|
RNA_def_function_ui_description(func, "Compute the coordinate (and scale for ortho cameras) "
|
||||||
"given object should be to 'see' all given coordinates");
|
"given object should be to 'see' all given coordinates");
|
||||||
parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to get render size information from, if available");
|
parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "",
|
||||||
|
"Depsgraph to get evaluated data from");
|
||||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||||
parm = RNA_def_float_array(func, "coordinates", 1, NULL, -FLT_MAX, FLT_MAX, "", "Coordinates to fit in",
|
parm = RNA_def_float_array(func, "coordinates", 1, NULL, -FLT_MAX, FLT_MAX, "", "Coordinates to fit in",
|
||||||
-FLT_MAX, FLT_MAX);
|
-FLT_MAX, FLT_MAX);
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "DEG_depsgraph.h"
|
||||||
#include "DEG_depsgraph_build.h"
|
#include "DEG_depsgraph_build.h"
|
||||||
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
static void initData(ModifierData *md)
|
static void initData(ModifierData *md)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +113,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct Projector {
|
typedef struct Projector {
|
||||||
Object *ob; /* object this projector is derived from */
|
Object *ob_eval; /* object this projector is derived from */
|
||||||
float projmat[4][4]; /* projection matrix */
|
float projmat[4][4]; /* projection matrix */
|
||||||
float normal[3]; /* projector normal in world space */
|
float normal[3]; /* projector normal in world space */
|
||||||
void *uci; /* optional uv-project info (panorama projection) */
|
void *uci; /* optional uv-project info (panorama projection) */
|
||||||
|
@ -119,6 +121,7 @@ typedef struct Projector {
|
||||||
|
|
||||||
static Mesh *uvprojectModifier_do(
|
static Mesh *uvprojectModifier_do(
|
||||||
UVProjectModifierData *umd,
|
UVProjectModifierData *umd,
|
||||||
|
Depsgraph *depsgraph,
|
||||||
Object *ob, Mesh *mesh)
|
Object *ob, Mesh *mesh)
|
||||||
{
|
{
|
||||||
float (*coords)[3], (*co)[3];
|
float (*coords)[3], (*co)[3];
|
||||||
|
@ -137,7 +140,7 @@ static Mesh *uvprojectModifier_do(
|
||||||
|
|
||||||
for (i = 0; i < umd->num_projectors; ++i)
|
for (i = 0; i < umd->num_projectors; ++i)
|
||||||
if (umd->projectors[i])
|
if (umd->projectors[i])
|
||||||
projectors[num_projectors++].ob = umd->projectors[i];
|
projectors[num_projectors++].ob_eval = DEG_get_evaluated_object(depsgraph, umd->projectors[i]);
|
||||||
|
|
||||||
if (num_projectors == 0) return mesh;
|
if (num_projectors == 0) return mesh;
|
||||||
|
|
||||||
|
@ -154,15 +157,14 @@ static Mesh *uvprojectModifier_do(
|
||||||
float offsetmat[4][4];
|
float offsetmat[4][4];
|
||||||
Camera *cam = NULL;
|
Camera *cam = NULL;
|
||||||
/* calculate projection matrix */
|
/* calculate projection matrix */
|
||||||
invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat);
|
invert_m4_m4(projectors[i].projmat, projectors[i].ob_eval->obmat);
|
||||||
|
|
||||||
projectors[i].uci = NULL;
|
projectors[i].uci = NULL;
|
||||||
|
|
||||||
if (projectors[i].ob->type == OB_CAMERA) {
|
if (projectors[i].ob_eval->type == OB_CAMERA) {
|
||||||
|
cam = (Camera *)projectors[i].ob_eval->data;
|
||||||
cam = (Camera *)projectors[i].ob->data;
|
|
||||||
if (cam->type == CAM_PANO) {
|
if (cam->type == CAM_PANO) {
|
||||||
projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy);
|
projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob_eval, NULL, aspx, aspy);
|
||||||
BLI_uvproject_camera_info_scale(projectors[i].uci, scax, scay);
|
BLI_uvproject_camera_info_scale(projectors[i].uci, scax, scay);
|
||||||
free_uci = 1;
|
free_uci = 1;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +173,7 @@ static Mesh *uvprojectModifier_do(
|
||||||
|
|
||||||
/* setup parameters */
|
/* setup parameters */
|
||||||
BKE_camera_params_init(¶ms);
|
BKE_camera_params_init(¶ms);
|
||||||
BKE_camera_params_from_object(¶ms, projectors[i].ob);
|
BKE_camera_params_from_object(¶ms, projectors[i].ob_eval);
|
||||||
|
|
||||||
/* compute matrix, viewplane, .. */
|
/* compute matrix, viewplane, .. */
|
||||||
BKE_camera_params_compute_viewplane(¶ms, 1, 1, aspx, aspy);
|
BKE_camera_params_compute_viewplane(¶ms, 1, 1, aspx, aspy);
|
||||||
|
@ -200,7 +202,7 @@ static Mesh *uvprojectModifier_do(
|
||||||
projectors[i].normal[0] = 0;
|
projectors[i].normal[0] = 0;
|
||||||
projectors[i].normal[1] = 0;
|
projectors[i].normal[1] = 0;
|
||||||
projectors[i].normal[2] = 1;
|
projectors[i].normal[2] = 1;
|
||||||
mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal);
|
mul_mat3_m4_v3(projectors[i].ob_eval->obmat, projectors[i].normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
numPolys = mesh->totpoly;
|
numPolys = mesh->totpoly;
|
||||||
|
@ -312,7 +314,7 @@ static Mesh *applyModifier(
|
||||||
Mesh *result;
|
Mesh *result;
|
||||||
UVProjectModifierData *umd = (UVProjectModifierData *) md;
|
UVProjectModifierData *umd = (UVProjectModifierData *) md;
|
||||||
|
|
||||||
result = uvprojectModifier_do(umd, ctx->object, mesh);
|
result = uvprojectModifier_do(umd, ctx->depsgraph, ctx->object, mesh);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue