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 /source/gameengine
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
Diffstat (limited to 'source/gameengine')
-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
4 files changed, 35 insertions, 9 deletions
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);