diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-12-03 23:09:25 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-12-03 23:35:45 +0400 |
commit | 46eef60d93fd0d52ed4b94750f7a3248db5594ee (patch) | |
tree | 234bd4dba7f241afec6e8c1a4057fb886b37878c /source/blender/makesrna/intern | |
parent | 462751688449108899a821f500cffc03658d6e3d (diff) |
Cleanup: Internal degrees removal.
This patch changes most of the reamining degrees usage in internal code into radians.
I let a few which I know off asside, for reasons explained below - and I'm not sure to have found out all of them.
WARNING: this introduces forward incompatibility, which means files saved from this version won't open 100% correctly
in previous versions (a few angle properties would use radians values as degrees...).
Details:
- Data:
-- Lamp.spotsize: Game engine exposed this setting in degrees, to not break the API here I kept it as such
(using getter/setter functions), still using radians internally.
-- Mesh.smoothresh: Didn't touch to this one, as we will hopefully replace it completely by loop normals currently in dev.
- Modifiers:
-- EdgeSplitModifierData.split_angle, BevelModifierData.bevel_angle: Done.
- Postprocessing:
-- WipeVars.angle (sequencer's effect), NodeBokehImage.angle, NodeBoxMask.rotation, NodeEllipseMask.rotation: Done.
- BGE:
-- bConstraintActuator: Orientation type done (the minloc[0] & maxloc[0] cases). Did not touch to 'limit location' type,
it can also limit rotation, but it exposes through RNA the same limit_min/limit_max, which hence
can be either distance or angle values, depending on the mode. Will leave this to BGE team.
-- bSoundActuator.cone_outer_angle_3d, bSoundActuator.cone_inner_angle_3d: Done (note I kept degrees in BGE itself,
as it seems this is the expected value here...).
-- bRadarSensor.angle: Done.
Reviewers: brecht, campbellbarton, sergey, gaiaclary, dfelinto, moguri, jbakker, lukastoenne, howardt
Reviewed By: brecht, campbellbarton, sergey, gaiaclary, moguri, jbakker, lukastoenne, howardt
Thanks to all!
Differential Revision: http://developer.blender.org/D59
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_actuator.c | 23 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_lamp.c | 19 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 47 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 23 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sensor.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 27 |
6 files changed, 35 insertions, 112 deletions
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index a07a000dacb..ce5049c1a6e 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -33,6 +33,7 @@ #include "DNA_scene_types.h" /* for MAXFRAME */ #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BLF_translation.h" @@ -1051,15 +1052,15 @@ static void rna_def_sound_actuator(BlenderRNA *brna) "between this value and the normal gain in the inner cone)"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop = RNA_def_property(srna, "cone_outer_angle_3d", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "cone_outer_angle_3d", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_outer_angle"); - RNA_def_property_ui_range(prop, 0.0, 360.0, 1, 2); + RNA_def_property_ui_range(prop, 0.0, DEG2RADF(360.0f), 1, 2); RNA_def_property_ui_text(prop, "Cone Outer Angle", "The angle of the outer cone"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop = RNA_def_property(srna, "cone_inner_angle_3d", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "cone_inner_angle_3d", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_inner_angle"); - RNA_def_property_ui_range(prop, 0.0, 360.0, 1, 2); + RNA_def_property_ui_range(prop, 0.0, DEG2RADF(360.0f), 1, 2); RNA_def_property_ui_text(prop, "Cone Inner Angle", "The angle of the inner cone"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -1259,21 +1260,19 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Reference Direction", "Reference Direction"); RNA_def_property_update(prop, NC_LOGIC, NULL); - /*XXX TODO - use radians internally then change to PROP_ANGLE */ - prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); - RNA_def_property_range(prop, 0.0, 180.0); + RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); RNA_def_property_ui_text(prop, "Min Angle", - "Minimum angle (in degree) to maintain with target direction " + "Minimum angle to maintain with target direction " "(no correction is done if angle with target direction is between min and max)"); RNA_def_property_update(prop, NC_LOGIC, NULL); - /*XXX TODO - use radians internally then change to PROP_ANGLE */ - prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); - RNA_def_property_range(prop, 0.0, 180.0); + RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); RNA_def_property_ui_text(prop, "Max Angle", - "Maximum angle (in degree) allowed with target direction " + "Maximum angle allowed with target direction " "(no correction is done if angle with target direction is between min and max)"); RNA_def_property_update(prop, NC_LOGIC, NULL); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 63fc5dbdbbd..2455141972b 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -156,19 +156,6 @@ static void rna_Lamp_sky_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point WM_main_add_notifier(NC_LAMP | ND_SKY, la); } -/* only for rad/deg conversion! can remove later */ -static float rna_Lamp_spot_size_get(PointerRNA *ptr) -{ - Lamp *la = ptr->id.data; - return DEG2RADF(la->spotsize); -} - -static void rna_Lamp_spot_size_set(PointerRNA *ptr, float value) -{ - Lamp *la = ptr->id.data; - la->spotsize = RAD2DEGF(value); -} - static void rna_Lamp_use_nodes_update(bContext *C, PointerRNA *ptr) { Lamp *la = (Lamp *)ptr->data; @@ -800,11 +787,9 @@ static void rna_def_spot_lamp(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); prop = RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE); - /* RNA_def_property_float_sdna(prop, NULL, "spotsize"); */ - RNA_def_property_range(prop, M_PI / 180.0, M_PI); + RNA_def_property_float_sdna(prop, NULL, "spotsize"); + RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f)); RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam"); - /* only for deg/rad conversion */ - RNA_def_property_float_funcs(prop, "rna_Lamp_spot_size_get", "rna_Lamp_spot_size_set", NULL); RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); prop = RNA_def_property(srna, "show_cone", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 667e7bd6408..c6f97e11156 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -743,34 +743,6 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value) } } -static float rna_EdgeSplitModifier_split_angle_get(PointerRNA *ptr) -{ - EdgeSplitModifierData *md = (EdgeSplitModifierData *)ptr->data; - return DEG2RADF(md->split_angle); -} - -static void rna_EdgeSplitModifier_split_angle_set(PointerRNA *ptr, float value) -{ - EdgeSplitModifierData *md = (EdgeSplitModifierData *)ptr->data; - value = RAD2DEGF(value); - CLAMP(value, 0.0f, 180.0f); - md->split_angle = (int)value; -} - -static float rna_BevelModifier_angle_limit_get(PointerRNA *ptr) -{ - BevelModifierData *md = (BevelModifierData *)ptr->data; - return DEG2RADF(md->bevel_angle); -} - -static void rna_BevelModifier_angle_limit_set(PointerRNA *ptr, float value) -{ - BevelModifierData *md = (BevelModifierData *)ptr->data; - value = RAD2DEGF(value); - CLAMP(value, 0.0f, 180.0f); - md->bevel_angle = (int)value; -} - static void rna_BevelModifier_defgrp_name_set(PointerRNA *ptr, const char *value) { BevelModifierData *md = (BevelModifierData *)ptr->data; @@ -1668,17 +1640,9 @@ static void rna_def_modifier_edgesplit(BlenderRNA *brna) RNA_def_struct_sdna(srna, "EdgeSplitModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_EDGESPLIT); -#if 1 /* expose as radians */ prop = RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_funcs(prop, "rna_EdgeSplitModifier_split_angle_get", - "rna_EdgeSplitModifier_split_angle_set", NULL); - RNA_def_property_range(prop, 0, DEG2RAD(180)); - RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 100, 2); -#else - prop = RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0, 180); - RNA_def_property_ui_range(prop, 0, 180, 100, 2); -#endif + RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); + RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 100, 2); RNA_def_property_ui_text(prop, "Split Angle", "Angle above which to split edges"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2394,10 +2358,9 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_funcs(prop, "rna_BevelModifier_angle_limit_get", - "rna_BevelModifier_angle_limit_set", NULL); - RNA_def_property_range(prop, 0, DEG2RAD(180)); - RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 100, 2); + RNA_def_property_float_sdna(prop, NULL, "bevel_angle"); + RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); + RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 100, 2); RNA_def_property_ui_text(prop, "Angle", "Angle above which to bevel edges"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index ad327cc2c00..44334ce9aec 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4846,7 +4846,6 @@ static void def_cmp_defocus(StructRNA *srna) RNA_def_property_ui_text(prop, "Bokeh Type", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - /* TODO: angle in degrees */ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "rotation"); RNA_def_property_range(prop, 0.0f, DEG2RADF(90.0f)); @@ -5549,10 +5548,10 @@ static void def_cmp_boxmask(StructRNA *srna) RNA_def_property_ui_text(prop, "Height", "Height of the box"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "rotation"); RNA_def_property_float_default(prop, 0.0f); - RNA_def_property_range(prop, -1000.0f, 1000.0f); + RNA_def_property_range(prop, DEG2RADF(-1800.0f), DEG2RADF(1800.0f)); RNA_def_property_ui_text(prop, "Rotation", "Rotation angle of the box"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -5572,35 +5571,35 @@ static void def_cmp_ellipsemask(StructRNA *srna) RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, -1.0f, 2.0f); - RNA_def_property_ui_text(prop, "X", "X position of the middle of the box"); + RNA_def_property_ui_text(prop, "X", "X position of the middle of the ellipse"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "y"); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, -1.0f, 2.0f); - RNA_def_property_ui_text(prop, "Y", "Y position of the middle of the box"); + RNA_def_property_ui_text(prop, "Y", "Y position of the middle of the ellipse"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "width"); RNA_def_property_float_default(prop, 0.3f); RNA_def_property_range(prop, 0.0f, 2.0f); - RNA_def_property_ui_text(prop, "Width", "Width of the box"); + RNA_def_property_ui_text(prop, "Width", "Width of the ellipse"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "height"); RNA_def_property_float_default(prop, 0.2f); RNA_def_property_range(prop, 0.0f, 2.0f); - RNA_def_property_ui_text(prop, "Height", "Height of the box"); + RNA_def_property_ui_text(prop, "Height", "Height of the ellipse"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "rotation"); RNA_def_property_float_default(prop, 0.0f); - RNA_def_property_range(prop, -1000.0f, 1000.0f); - RNA_def_property_ui_text(prop, "Rotation", "Rotation angle of the box"); + RNA_def_property_range(prop, DEG2RADF(-1800.0f), DEG2RADF(1800.0f)); + RNA_def_property_ui_text(prop, "Rotation", "Rotation angle of the ellipse"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -5639,10 +5638,10 @@ static void def_cmp_bokehimage(StructRNA *srna) RNA_def_struct_sdna_from(srna, "NodeBokehImage", "storage"); - prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "angle"); RNA_def_property_float_default(prop, 0.0f); - RNA_def_property_range(prop, -720.0f, 720.0f); + RNA_def_property_range(prop, DEG2RADF(-720.0f), DEG2RADF(720.0f)); RNA_def_property_ui_text(prop, "Angle", "Angle of the bokeh"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 71546c7fad4..4458cac3e3d 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -31,6 +31,7 @@ #include "DNA_sensor_types.h" #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BLF_translation.h" @@ -663,10 +664,9 @@ static void rna_def_radar_sensor(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Axis", "Along which axis the radar cone is cast"); RNA_def_property_update(prop, NC_LOGIC, NULL); - /*XXX TODO - use radians internally then change to PROP_ANGLE */ - prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0, 179.9); - RNA_def_property_ui_text(prop, "Angle", "Opening angle of the radar cone (in degrees)"); + prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_range(prop, 0.0, DEG2RADF(179.9f)); + RNA_def_property_ui_text(prop, "Angle", "Opening angle of the radar cone"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 342d94c7667..a73a7f41d7e 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -884,22 +884,6 @@ static void rna_SequenceEditor_overlay_frame_set(PointerRNA *ptr, int value) ed->over_ofs = value; } - -static void rna_WipeSequence_angle_set(PointerRNA *ptr, float value) -{ - Sequence *seq = (Sequence *)(ptr->data); - value = RAD2DEGF(value); - CLAMP(value, -90.0f, 90.0f); - ((WipeVars *)seq->effectdata)->angle = value; -} - -static float rna_WipeSequence_angle_get(PointerRNA *ptr) -{ - Sequence *seq = (Sequence *)(ptr->data); - - return DEG2RADF(((WipeVars *)seq->effectdata)->angle); -} - static int modifier_seq_cmp_cb(Sequence *seq, void *arg_pt) { SequenceSearchData *data = arg_pt; @@ -2042,18 +2026,11 @@ static void rna_def_wipe(StructRNA *srna) "Width of the blur edge, in percentage relative to the image size"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); -#if 1 /* expose as radians */ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_funcs(prop, "rna_WipeSequence_angle_get", "rna_WipeSequence_angle_set", NULL); - RNA_def_property_range(prop, DEG2RAD(-90.0), DEG2RAD(90.0)); -#else - prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "angle"); - RNA_def_property_range(prop, -90.0f, 90.0f); -#endif + RNA_def_property_range(prop, DEG2RADF(-90.0f), DEG2RADF(90.0f)); RNA_def_property_ui_text(prop, "Angle", "Edge angle"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); - + prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "forward"); RNA_def_property_enum_items(prop, wipe_direction_items); |