* Added proper update/conversions for changing between degrees and "mm" in camera

This commit is contained in:
Matt Ebb
2009-10-01 04:14:43 +00:00
parent bf3374426a
commit 0901eafa8f

View File

@@ -22,7 +22,9 @@
* ***** END GPL LICENSE BLOCK *****
*/
#define _USE_MATH_DEFINES
#include <stdlib.h>
#include <math.h>
#include "RNA_define.h"
#include "RNA_types.h"
@@ -35,6 +37,19 @@
#ifdef RNA_RUNTIME
static void rna_Camera_angle_update(bContext *C, PointerRNA *ptr)
{
Camera *cam= (Camera*)ptr->id.data;
cam->lens = 16.0f / tan(M_PI*cam->angle/360.0f);
}
static void rna_Camera_lens_update(bContext *C, PointerRNA *ptr)
{
Camera *cam= (Camera*)ptr->id.data;
cam->angle= 360.0f * atan(16.0f/cam->lens) / M_PI;
}
#else
void RNA_def_camera(BlenderRNA *brna)
@@ -72,7 +87,7 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "angle");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Angle", "Perspective Camera lend field of view in degrees.");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_angle_update");
prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "clipsta");
@@ -90,7 +105,7 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "lens");
RNA_def_property_range(prop, 1.0f, 250.0f);
RNA_def_property_ui_text(prop, "Lens", "Perspective Camera lens value in mm.");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_lens_update");
prop= RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ortho_scale");