Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2013-12-03 23:09:25 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-12-03 23:35:45 +0400
commit46eef60d93fd0d52ed4b94750f7a3248db5594ee (patch)
tree234bd4dba7f241afec6e8c1a4057fb886b37878c
parent462751688449108899a821f500cffc03658d6e3d (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
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/intern/camera.c2
-rw-r--r--source/blender/blenkernel/intern/lamp.c2
-rw-r--r--source/blender/blenkernel/intern/sca.c5
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c4
-rw-r--r--source/blender/blenloader/intern/versioning_260.c83
-rw-r--r--source/blender/collada/DocumentImporter.cpp3
-rw-r--r--source/blender/collada/LightExporter.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp2
-rw-r--r--source/blender/editors/space_node/drawnode.c4
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
-rw-r--r--source/blender/gpu/intern/gpu_draw.c2
-rw-r--r--source/blender/gpu/intern/gpu_material.c12
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c23
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c19
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c47
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c23
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c8
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c27
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c4
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c4
-rw-r--r--source/blender/render/intern/source/convertblender.c4
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp10
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp30
-rw-r--r--source/gameengine/Ketsji/KX_Light.h2
29 files changed, 184 insertions, 152 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index a4a6b60159d..989a5991074 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -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
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index ab952fb87ca..aee8ede4062 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -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);
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 2bd521ab044..904dbec24a4 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -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;
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 7c374fd5d78..b0b64cac802 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -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:
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 7b3f18c1bd4..1507e1742cd 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -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));
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 14eb8ff4ea6..e023e8eed1d 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -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) {
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 98770675444..144fe75fa70 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -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;
diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
index a277963b883..ff50abfedae 100644
--- a/source/blender/collada/LightExporter.cpp
+++ b/source/blender/collada/LightExporter.cpp
@@ -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);
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index b6dd0e526ae..c2bd8997525 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -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) {
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index 82de750de72..6617fc62ab8 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -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);
}
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index 4dd92aec4c8..4e956905311 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -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();
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
index d7cc2ec9272..bc1a6848a57 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -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();
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index d4af66b7eb9..da599f8608d 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -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);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 29ee72c39ab..b4b8bd24703 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -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);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 0d25d988df9..0dba2cd50e8 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -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
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 8e7194bb4a1..a3813ef4584 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -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;
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);
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 6a1de92f9b2..3ba06a73c8b 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -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);
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index d55ebdad939..a17858d58f5 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -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;
}
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 0dc0f7d74f3..52030fb2d86 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -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 *));
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index e9461a15578..26401fcd868 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -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;
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index b9bd9aabc54..860dd5c06fb 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -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;
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 4567c17cc3e..3a8821e8a86 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -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;
diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h
index 4f11c535cf0..d6892875042 100644
--- a/source/gameengine/Ketsji/KX_Light.h
+++ b/source/gameengine/Ketsji/KX_Light.h
@@ -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);