Cleanup: Internal degrees removal.
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 3 Dec 2013 19:09:25 +0000 (20:09 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 3 Dec 2013 19:35:45 +0000 (20:35 +0100)
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

29 files changed:
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/sca.c
source/blender/blenkernel/intern/seqeffects.c
source/blender/blenloader/intern/versioning_260.c
source/blender/collada/DocumentImporter.cpp
source/blender/collada/LightExporter.cpp
source/blender/compositor/nodes/COM_DefocusNode.cpp
source/blender/compositor/operations/COM_BokehImageOperation.cpp
source/blender/compositor/operations/COM_BoxMaskOperation.cpp
source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_view3d/drawobject.c
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_material.c
source/blender/makesrna/intern/rna_actuator.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_sensor.c
source/blender/makesrna/intern/rna_sequencer.c
source/blender/modifiers/intern/MOD_bevel.c
source/blender/modifiers/intern/MOD_edgesplit.c
source/blender/render/intern/source/convertblender.c
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Converter/KX_ConvertSensors.cpp
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_Light.h

index a4a6b60159d8e14c113692d9fcf7bf32050d22c2..989a5991074336a17ca8b904e0fef85de881a6c7 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         269
-#define BLENDER_SUBVERSION      3
+#define BLENDER_SUBVERSION      4
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      262
 #define BLENDER_MINSUBVERSION   0
index ab952fb87cad86a1e4f01d2321be5f64a8bbeb38..aee8ede406218efc0616fc664933850d55542d25 100644 (file)
@@ -227,7 +227,7 @@ void BKE_camera_params_from_object(CameraParams *params, Object *ob)
        else if (ob->type == OB_LAMP) {
                /* lamp object */
                Lamp *la = ob->data;
-               float fac = cosf((float)M_PI * la->spotsize / 360.0f);
+               float fac = cosf(la->spotsize * 0.5f);
                float phi = acos(fac);
 
                params->lens = 16.0f * fac / sinf(phi);
index 2bd521ab04403282aa562143682fb4f83de4aece..904dbec24a4b1f8f210728707a422f94f3e3b66d 100644 (file)
@@ -63,7 +63,7 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
        la->r = la->g = la->b = la->k = 1.0f;
        la->haint = la->energy = 1.0f;
        la->dist = 25.0f;
-       la->spotsize = 45.0f;
+       la->spotsize = DEG2RADF(45.0f);
        la->spotblend = 0.15f;
        la->att2 = 1.0f;
        la->mode = LA_SHAD_BUF;
index 7c374fd5d7825cf59ee402b72b6f9d1b273eeb26..b0b64cac8029469fd9c9e7e9f5e3a57df5b2ee38 100644 (file)
@@ -44,6 +44,7 @@
 #include "DNA_object_types.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_math.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_library.h"
@@ -405,8 +406,8 @@ void init_actuator(bActuator *act)
                sa->sound3D.rolloff_factor = 1.0f;
                sa->sound3D.reference_distance = 1.0f;
                sa->sound3D.max_gain = 1.0f;
-               sa->sound3D.cone_inner_angle = 360.0f;
-               sa->sound3D.cone_outer_angle = 360.0f;
+               sa->sound3D.cone_inner_angle = DEG2RADF(360.0f);
+               sa->sound3D.cone_outer_angle = DEG2RADF(360.0f);
                sa->sound3D.max_distance = FLT_MAX;
                break;
        case ACT_OBJECT:
index 7b3f18c1bd41c8389439af80de2c82aec45acb5f..1507e1742cda1dec789fc5afd18ba5653b380ef9 100644 (file)
@@ -1246,8 +1246,8 @@ typedef struct WipeZone {
 
 static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo)
 {
-       wipezone->flip = (wipe->angle < 0);
-       wipezone->angle = tanf(DEG2RADF(fabsf(wipe->angle)));
+       wipezone->flip = (wipe->angle < 0.0f);
+       wipezone->angle = tanf(fabsf(wipe->angle));
        wipezone->xo = xo;
        wipezone->yo = yo;
        wipezone->width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0f));
index 14eb8ff4ea658b95033e39fc21dd669a68170879..e023e8eed1ddd9c24bc4fbee8432de267a09e9d0 100644 (file)
@@ -2530,7 +2530,88 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       {
+       if (!MAIN_VERSION_ATLEAST(main, 269, 4)) {
+               /* Internal degrees to radians conversions... */
+               {
+                       Scene *scene;
+                       Object *ob;
+                       Lamp *lamp;
+
+                       for (lamp = main->lamp.first; lamp; lamp = lamp->id.next)
+                               lamp->spotsize = DEG2RADF(lamp->spotsize);
+
+                       for (ob = main->object.first; ob; ob = ob->id.next) {
+                               ModifierData *md;
+                               bSensor *bs;
+                               bActuator *ba;
+
+                               for (md = ob->modifiers.first; md; md = md->next) {
+                                       if (md->type == eModifierType_EdgeSplit) {
+                                               EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md;
+                                               emd->split_angle = DEG2RADF(emd->split_angle);
+                                       }
+                                       else if (md->type == eModifierType_Bevel) {
+                                               BevelModifierData *bmd = (BevelModifierData *)md;
+                                               bmd->bevel_angle = DEG2RADF(bmd->bevel_angle);
+                                       }
+                               }
+
+                               for (bs = ob->sensors.first; bs; bs = bs->next) {
+                                       if (bs->type == SENS_RADAR) {
+                                               bRadarSensor *brs = bs->data;
+                                               brs->angle = DEG2RADF(brs->angle);
+                                       }
+                               }
+
+                               for (ba = ob->actuators.first; ba; ba = ba->next) {
+                                       if (ba->type == ACT_CONSTRAINT) {
+                                               bConstraintActuator *bca = ba->data;
+                                               if (bca->type == ACT_CONST_TYPE_ORI) {
+                                                       bca->minloc[0] = DEG2RADF(bca->minloc[0]);
+                                                       bca->maxloc[0] = DEG2RADF(bca->maxloc[0]);
+                                               }
+                                       }
+                                       else if (ba->type == ACT_SOUND) {
+                                               bSoundActuator *bsa = ba->data;
+                                               bsa->sound3D.cone_outer_angle = DEG2RADF(bsa->sound3D.cone_outer_angle);
+                                               bsa->sound3D.cone_inner_angle = DEG2RADF(bsa->sound3D.cone_inner_angle);
+                                       }
+                               }
+                       }
+
+                       for (scene = main->scene.first; scene; scene = scene->id.next) {
+                               Sequence *seq;
+                               SEQ_BEGIN (scene->ed, seq)
+                               {
+                                       if (seq->type == SEQ_TYPE_WIPE) {
+                                               WipeVars *wv = seq->effectdata;
+                                               wv->angle = DEG2RADF(wv->angle);
+                                       }
+                               }
+                               SEQ_END
+                       }
+
+                       FOREACH_NODETREE(main, ntree, id) {
+                               if (ntree->type == NTREE_COMPOSIT) {
+                                       bNode *node;
+                                       for (node = ntree->nodes.first; node; node = node->next) {
+                                               if (node->type == CMP_NODE_BOKEHIMAGE) {
+                                                       NodeBokehImage *n = node->storage;
+                                                       n->angle = DEG2RADF(n->angle);
+                                               }
+                                               if (node->type == CMP_NODE_MASK_BOX) {
+                                                       NodeBoxMask *n = node->storage;
+                                                       n->rotation = DEG2RADF(n->rotation);
+                                               }
+                                               if (node->type == CMP_NODE_MASK_ELLIPSE) {
+                                                       NodeEllipseMask *n = node->storage;
+                                                       n->rotation = DEG2RADF(n->rotation);
+                                               }
+                                       }
+                               }
+                       } FOREACH_NODETREE_END
+               }
+
                if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) {
                        MovieClip *clip;
                        for (clip = main->movieclip.first; clip; clip = clip->id.next) {
index 9877067544469042411cfe51440290cacba5efb3..144fe75fa702f9deb134e416d5a1c1d750d8a8ac 100644 (file)
@@ -1127,6 +1127,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
                et->setData("energy", &(lamp->energy));
                et->setData("dist", &(lamp->dist));
                et->setData("spotsize", &(lamp->spotsize));
+               lamp->spotsize = DEG2RADF(lamp->spotsize);
                et->setData("spotblend", &(lamp->spotblend));
                et->setData("halo_intensity", &(lamp->haint));
                et->setData("att1", &(lamp->att1));
@@ -1223,7 +1224,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
                                        lamp->falloff_type = LA_FALLOFF_INVSQUARE;
                                if (IS_EQ(att2, 0.0f) && att1 > 0)
                                        lamp->falloff_type = LA_FALLOFF_INVLINEAR;
-                               lamp->spotsize = light->getFallOffAngle().getValue();
+                               lamp->spotsize = DEG2RADF(light->getFallOffAngle().getValue());
                                lamp->spotblend = light->getFallOffExponent().getValue();
                        }
                        break;
index a277963b8834488d2ef215a33dc9db53163237b7..ff50abfedae2b4cf99f8054b93603f3686e31361 100644 (file)
@@ -101,7 +101,7 @@ void LightsExporter::operator()(Object *ob)
        else if (la->type == LA_SPOT) {
                COLLADASW::SpotLight cla(mSW, la_id, la_name);
                cla.setColor(col, false, "color");
-               cla.setFallOffAngle(la->spotsize, false, "fall_off_angle");
+               cla.setFallOffAngle(RAD2DEGF(la->spotsize), false, "fall_off_angle");
                cla.setFallOffExponent(la->spotblend, false, "fall_off_exponent");
                cla.setConstantAttenuation(constatt);
                cla.setLinearAttenuation(linatt);
@@ -147,7 +147,7 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
        cla.addExtraTechniqueParameter("blender", "shadow_b", la->shdwb, "blender_shadow_b");
        cla.addExtraTechniqueParameter("blender", "energy", la->energy, "blender_energy");
        cla.addExtraTechniqueParameter("blender", "dist", la->dist, "blender_dist");
-       cla.addExtraTechniqueParameter("blender", "spotsize", la->spotsize);
+       cla.addExtraTechniqueParameter("blender", "spotsize", RAD2DEGF(la->spotsize));
        cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend);
        cla.addExtraTechniqueParameter("blender", "halo_intensity", la->haint, "blnder_halo_intensity");
        cla.addExtraTechniqueParameter("blender", "att1", la->att1);
index b6dd0e526ae7d1b96ef3b48cbc0613f475e2787d..c2bd899752548603e3ce90d7d58367fd9e76bf2a 100644 (file)
@@ -85,7 +85,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
        
        BokehImageOperation *bokeh = new BokehImageOperation();
        NodeBokehImage *bokehdata = new NodeBokehImage();
-       bokehdata->angle = RAD2DEGF(data->rotation);
+       bokehdata->angle = data->rotation;
        bokehdata->rounding = 0.0f;
        bokehdata->flaps = data->bktype;
        if (data->bktype < 3) {
index 82de750de72124770024f92249521c04ff6d6fe0..6617fc62ab81879ed919b998b906efb2d49b2fe0 100644 (file)
@@ -35,7 +35,7 @@ void BokehImageOperation::initExecution()
        this->m_inverseRounding = 1.0f - this->m_data->rounding;
        this->m_circularDistance = getWidth() / 2;
        this->m_flapRad = (float)(M_PI * 2) / this->m_data->flaps;
-       this->m_flapRadAdd = (this->m_data->angle / 360.0f) * (float)(M_PI * 2.0);
+       this->m_flapRadAdd = this->m_data->angle;
        while (this->m_flapRadAdd < 0.0f) {
                this->m_flapRadAdd += (float)(M_PI * 2.0);
        }
index 4dd92aec4c80a02123df44a9eb5d68c52e7c9999..4e9569053110e98b88fe2605b478f0ef35b35e4d 100644 (file)
@@ -38,7 +38,7 @@ void BoxMaskOperation::initExecution()
 {
        this->m_inputMask = this->getInputSocketReader(0);
        this->m_inputValue = this->getInputSocketReader(1);
-       const double rad = DEG2RAD((double)this->m_data->rotation);
+       const double rad = (double)this->m_data->rotation;
        this->m_cosine = cos(rad);
        this->m_sine = sin(rad);
        this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
index d7cc2ec92724f9ac4a4d0fd126dad73ee548c62d..bc1a6848a5769f32cf1255483c362ee122a194e8 100644 (file)
@@ -38,7 +38,7 @@ void EllipseMaskOperation::initExecution()
 {
        this->m_inputMask = this->getInputSocketReader(0);
        this->m_inputValue = this->getInputSocketReader(1);
-       const double rad = DEG2RAD((double)this->m_data->rotation);
+       const double rad = (double)this->m_data->rotation;
        this->m_cosine = cos(rad);
        this->m_sine = sin(rad);
        this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
index d4af66b7eb90d47112d51987a0c934deb5b062d4..da599f8608d6f1bc5977102e0c190041dc8e5d62 100644 (file)
@@ -2010,7 +2010,7 @@ static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bN
        const float backdropWidth = backdrop->x;
        const float backdropHeight = backdrop->y;
        const float aspect = backdropWidth / backdropHeight;
-       const float rad = DEG2RADF(-boxmask->rotation);
+       const float rad = -boxmask->rotation;
        const float cosine = cosf(rad);
        const float sine = sinf(rad);
        const float halveBoxWidth = backdropWidth * (boxmask->width / 2.0f);
@@ -2048,7 +2048,7 @@ static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop
        const float backdropWidth = backdrop->x;
        const float backdropHeight = backdrop->y;
        const float aspect = backdropWidth / backdropHeight;
-       const float rad = DEG2RADF(-ellipsemask->rotation);
+       const float rad = -ellipsemask->rotation;
        const float cosine = cosf(rad);
        const float sine = sinf(rad);
        const float halveBoxWidth = backdropWidth * (ellipsemask->width / 2.0f);
index 29ee72c39ab45bfc47957711f0eb028effc4098a..b4b8bd247035846157b1ec932e138f46a6746d8a 100644 (file)
@@ -1216,7 +1216,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
                mul_mat3_m4_v3(ob->obmat, vvec);
 
                x = -la->dist;
-               y = cosf(la->spotsize * (float)(M_PI / 360.0));
+               y = cosf(la->spotsize * 0.5f);
                z = x * sqrtf(1.0f - y * y);
 
                spotvolume(lvec, vvec, y);
index 0d25d988df9d0ecc5dffba49866a37d1370e6318..0dba2cd50e83b0664b0d53c2c8a82b62dfdbe9f7 100644 (file)
@@ -1784,7 +1784,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[4][
                                /* spot lamp */
                                negate_v3_v3(direction, base->object->obmat[2]);
                                glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, direction);
-                               glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->spotsize/2.0f);
+                               glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, RAD2DEGF(la->spotsize * 0.5f));
                                glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.0f*la->spotblend);
                        }
                        else
index 8e7194bb4a1d90152a69827a280e29f00fa45868..a3813ef4584d4691c0e4249c7e07bfa45215cbb5 100644 (file)
@@ -1669,8 +1669,8 @@ void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float a
 
 void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend)
 {
-       lamp->spotsi= cosf((float)M_PI * spotsize / 360.0f);
-       lamp->spotbl= (1.0f - lamp->spotsi) * spotblend;
+       lamp->spotsi = cosf(spotsize * 0.5f);
+       lamp->spotbl = (1.0f - lamp->spotsi) * spotblend;
 }
 
 static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
@@ -1695,11 +1695,11 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l
 
        GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat);
 
-       lamp->spotsi= la->spotsize;
+       lamp->spotsi = la->spotsize;
        if (lamp->mode & LA_HALO)
-               if (lamp->spotsi > 170.0f)
-                       lamp->spotsi = 170.0f;
-       lamp->spotsi= cosf((float)M_PI*lamp->spotsi/360.0f);
+               if (lamp->spotsi > DEG2RADF(170.0f))
+                       lamp->spotsi = DEG2RADF(170.0f);
+       lamp->spotsi = cosf(lamp->spotsi * 0.5f);
        lamp->spotbl= (1.0f - lamp->spotsi)*la->spotblend;
        lamp->k= la->k;
 
index a07a000dacb6764810bae6a19ff5712752cc3d81..ce5049c1a6e6ca86772af164f4646849e7b49e0a 100644 (file)
@@ -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);
 
index 63fc5dbdbbd5e002a2f5fc1925451c6dcf626fd2..2455141972b06b4c89ae74dd8f1f3bf8aefb366d 100644 (file)
@@ -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);
index 667e7bd64082d4ad660dc0ada3a8fde44d415888..c6f97e11156bb2abe981804cfb2c1af9f4cf6d4b 100644 (file)
@@ -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");
 
index ad327cc2c00b8d8a948e8f8911f2c6b5f8e9ddc2..44334ce9aec47761849365b3e3f785edbd604c6f 100644 (file)
@@ -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");
 
index 71546c7fad4582334b9a62bc8596199e98ff44f8..4458cac3e3d3d103102ebfadc2b47759856d6e90 100644 (file)
@@ -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);
index 342d94c766735dbfefb97630c9c7b0d293b38b42..a73a7f41d7eafb0ef4bfa8523bee0c4334ad7b33 100644 (file)
@@ -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);
index 6a1de92f9b27bcad22468385b63a9948e54968b4..3ba06a73c8b8b04fd5552d5c0ebf106f81e4e5b5 100644 (file)
@@ -61,7 +61,7 @@ static void initData(ModifierData *md)
        bmd->val_flags = 0;
        bmd->lim_flags = 0;
        bmd->e_flags = 0;
-       bmd->bevel_angle = 30;
+       bmd->bevel_angle = DEG2RADF(30.0f);
        bmd->defgrp_name[0] = '\0';
 }
 
@@ -107,7 +107,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
        int vgroup = -1;
        MDeformVert *dvert = NULL;
        BevelModifierData *bmd = (BevelModifierData *) md;
-       const float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f);
+       const float threshold = cosf(bmd->bevel_angle + 0.000000175f);
        const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0;
        const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK);
 
index d55ebdad9396a9ef1c026ceaa87bb160e8d617e8..a17858d58f5b54b2026f4eb8bcff5c670c513a66 100644 (file)
@@ -55,7 +55,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
        BMesh *bm;
        BMIter iter;
        BMEdge *e;
-       float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f);
+       float threshold = cosf(emd->split_angle + 0.000000175f);
        const bool calc_face_normals = (emd->flags & MOD_EDGESPLIT_FROMANGLE) != 0;
 
        bm = DM_to_bmesh(dm, calc_face_normals);
@@ -107,7 +107,7 @@ static void initData(ModifierData *md)
        EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md;
 
        /* default to 30-degree split angle, sharpness from both angle & flag */
-       emd->split_angle = 30;
+       emd->split_angle = DEG2RADF(30.0f);
        emd->flags = MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG;
 }
 
index 0dc0f7d74f374e8811aad71ce7c80bbe91bdb964..52030fb2d86bd0932274b33854f7005658867df4 100644 (file)
@@ -3793,9 +3793,9 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
        
        lar->spotsi= la->spotsize;
        if (lar->mode & LA_HALO) {
-               if (lar->spotsi>170.0f) lar->spotsi= 170.0f;
+               if (lar->spotsi > DEG2RADF(170.0f)) lar->spotsi = DEG2RADF(170.0f);
        }
-       lar->spotsi= cosf( (float)M_PI*lar->spotsi/360.0f );
+       lar->spotsi= cosf(lar->spotsi * 0.5f);
        lar->spotbl= (1.0f-lar->spotsi)*la->spotblend;
 
        memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *));
index e9461a1557888c46ff067866d9a7264a901c8429..26401fcd868a587011a0333149da5867a5fefefb 100644 (file)
@@ -80,7 +80,7 @@
 /* This little block needed for linking to Blender... */
 #include "BKE_text.h"
 #include "BLI_blenlib.h"
-#include "BLI_math_base.h"
+#include "BLI_math.h"
 #include "BLI_path_util.h"
 
 #include "KX_NetworkMessageActuator.h"
@@ -386,8 +386,8 @@ void BL_ConvertActuators(const char* maggiename,
                                        bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
                                        boost::shared_ptr<AUD_IFactory> snd_sound;
                                        KX_3DSoundSettings settings;
-                                       settings.cone_inner_angle = soundact->sound3D.cone_inner_angle;
-                                       settings.cone_outer_angle = soundact->sound3D.cone_outer_angle;
+                                       settings.cone_inner_angle = RAD2DEGF(soundact->sound3D.cone_inner_angle);
+                                       settings.cone_outer_angle = RAD2DEGF(soundact->sound3D.cone_outer_angle);
                                        settings.cone_outer_gain = soundact->sound3D.cone_outer_gain;
                                        settings.max_distance = soundact->sound3D.max_distance;
                                        settings.max_gain = soundact->sound3D.max_gain;
@@ -571,8 +571,8 @@ void BL_ConvertActuators(const char* maggiename,
                                /* convert settings... degrees in the ui become radians  */ 
                                /* internally                                            */ 
                                if (conact->type == ACT_CONST_TYPE_ORI) {
-                                       min = (float)(((float)MT_2_PI * conact->minloc[0]) / 360.0f);
-                                       max = (float)(((float)MT_2_PI * conact->maxloc[0]) / 360.0f);
+                                       min = conact->minloc[0];
+                                       max = conact->maxloc[0];
                                        switch (conact->mode) {
                                        case ACT_CONST_DIRPX:
                                                locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX;
index b9bd9aabc54cae64a8b18058032679c0a03fbe59..860dd5c06fbf2ca08dab262039bbdeb5816ce761 100644 (file)
@@ -431,7 +431,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
                                        // or the blenderradarsensor->angle?
                                        // nzc: the angle is the opening angle. We need to init with 
                                        // the axis-hull angle,so /2.0.
-                                       MT_Scalar factor = tan(MT_radians((blenderradarsensor->angle) / 2.0f));
+                                       MT_Scalar factor = tan(blenderradarsensor->angle * 0.5f);
                                        //MT_Scalar coneradius = coneheight * (factor / 2);
                                        MT_Scalar coneradius = coneheight * factor;
                                        
index 4567c17cc3e7177ff064db558464c30c119ffc30..3a8821e8a86feaa67638b3e97a20e8b7460b2a6c 100644 (file)
@@ -51,7 +51,9 @@
 
 #include "BKE_scene.h"
 #include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
 KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
                                RAS_IRasterizer* rasterizer,
                                const RAS_LightObject&  lightobj,
@@ -158,7 +160,7 @@ bool KX_LightObject::ApplyLight(KX_Scene *kxscene, int oblayer, int slot)
                        //vec[1] = -base->object->obmat[2][1];
                        //vec[2] = -base->object->obmat[2][2];
                        glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPOT_DIRECTION, vec);
-                       glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, m_lightobj.m_spotsize / 2.0f);
+                       glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, RAD2DEGF(m_lightobj.m_spotsize * 0.5f));
                        glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_EXPONENT, 128.0f * m_lightobj.m_spotblend);
                }
                else {
@@ -360,7 +362,7 @@ PyAttributeDef KX_LightObject::Attributes[] = {
        KX_PYATTRIBUTE_RW_FUNCTION("color", KX_LightObject, pyattr_get_color, pyattr_set_color),
        KX_PYATTRIBUTE_FLOAT_RW("lin_attenuation", 0, 1, KX_LightObject, m_lightobj.m_att1),
        KX_PYATTRIBUTE_FLOAT_RW("quad_attenuation", 0, 1, KX_LightObject, m_lightobj.m_att2),
-       KX_PYATTRIBUTE_FLOAT_RW("spotsize", 1, 180, KX_LightObject, m_lightobj.m_spotsize),
+       KX_PYATTRIBUTE_RW_FUNCTION("spotsize", KX_LightObject, pyattr_get_spotsize, pyattr_set_spotsize),
        KX_PYATTRIBUTE_FLOAT_RW("spotblend", 0, 1, KX_LightObject, m_lightobj.m_spotblend),
        KX_PYATTRIBUTE_RO_FUNCTION("SPOT", KX_LightObject, pyattr_get_typeconst),
        KX_PYATTRIBUTE_RO_FUNCTION("SUN", KX_LightObject, pyattr_get_typeconst),
@@ -390,6 +392,28 @@ int KX_LightObject::pyattr_set_color(void *self_v, const KX_PYATTRIBUTE_DEF *att
        return PY_SET_ATTR_FAIL;
 }
 
+PyObject *KX_LightObject::pyattr_get_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
+       return Py_BuildValue("f", RAD2DEGF(self->m_lightobj.m_spotsize));
+}
+
+int KX_LightObject::pyattr_set_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+       KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
+
+       float spotsize = (float)PyFloat_AsDouble(value);
+       if (PyErr_Occurred())
+               return PY_SET_ATTR_FAIL;
+
+       if (spotsize < 1.0f)
+               spotsize = 1.0f;
+       else if (spotsize > 180.0f)
+               spotsize = 180.0f;
+       self->m_lightobj.m_spotsize = DEG2RADF(spotsize);
+       return PY_SET_ATTR_SUCCESS;
+}
+
 PyObject *KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        PyObject *retvalue;
index 4f11c535cf049f0230f38c0a6d65fe2a6e9298ee..d689287504246e5af587427c13f7149e7d9032a2 100644 (file)
@@ -78,6 +78,8 @@ public:
        /* attributes */
        static PyObject*        pyattr_get_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        static int                      pyattr_set_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+       static PyObject*        pyattr_get_spotsize(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+       static int                      pyattr_set_spotsize(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
        static PyObject*        pyattr_get_typeconst(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        static PyObject*        pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        static int                      pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);