Revision: 23578 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23578 Author: broken Date: 2009-10-01 06:14:43 +0200 (Thu, 01 Oct 2009)
Log Message: ----------- * Added proper update/conversions for changing between degrees and "mm" in camera Modified Paths: -------------- trunk/blender/source/blender/makesrna/intern/rna_camera.c Modified: trunk/blender/source/blender/makesrna/intern/rna_camera.c =================================================================== --- trunk/blender/source/blender/makesrna/intern/rna_camera.c 2009-09-30 23:31:10 UTC (rev 23577) +++ trunk/blender/source/blender/makesrna/intern/rna_camera.c 2009-10-01 04:14:43 UTC (rev 23578) @@ -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 @@ 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 @@ 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"); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs