Fix T60558: Cycles viewport render mismatch when the camera is a light.

This commit is contained in:
2019-01-17 16:28:43 +01:00
parent 1a3abc7f79
commit 260b786d07
2 changed files with 11 additions and 9 deletions

View File

@@ -228,12 +228,17 @@ static void blender_camera_from_object(BlenderCamera *bcam,
bcam->sensor_fit = BlenderCamera::HORIZONTAL;
else
bcam->sensor_fit = BlenderCamera::VERTICAL;
}
else if(b_ob_data.is_a(&RNA_Light)) {
/* Can also look through spot light. */
BL::SpotLight b_light(b_ob_data);
float lens = 16.0f / tanf(b_light.spot_size() * 0.5f);
if (lens > 0.0f) {
bcam->lens = lens;
}
}
bcam->motion_steps = object_motion_steps(b_ob, b_ob);
}
else {
/* from light not implemented yet */
}
bcam->motion_steps = object_motion_steps(b_ob, b_ob);
}
static Transform blender_camera_matrix(const Transform& tfm,

View File

@@ -213,10 +213,7 @@ void BKE_camera_params_from_object(CameraParams *params, const Object *ob)
else if (ob->type == OB_LAMP) {
/* lamp object */
Lamp *la = ob->data;
float fac = cosf(la->spotsize * 0.5f);
float phi = acosf(fac);
params->lens = 16.0f * fac / sinf(phi);
params->lens = 16.0f / tanf(la->spotsize * 0.5f);
if (params->lens == 0.0f)
params->lens = 35.0f;