diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-12-03 23:09:25 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-12-03 23:35:45 +0400 |
commit | 46eef60d93fd0d52ed4b94750f7a3248db5594ee (patch) | |
tree | 234bd4dba7f241afec6e8c1a4057fb886b37878c /source/gameengine/Ketsji/KX_Light.cpp | |
parent | 462751688449108899a821f500cffc03658d6e3d (diff) |
Cleanup: Internal degrees removal.
This patch changes most of the reamining degrees usage in internal code into radians.
I let a few which I know off asside, for reasons explained below - and I'm not sure to have found out all of them.
WARNING: this introduces forward incompatibility, which means files saved from this version won't open 100% correctly
in previous versions (a few angle properties would use radians values as degrees...).
Details:
- Data:
-- Lamp.spotsize: Game engine exposed this setting in degrees, to not break the API here I kept it as such
(using getter/setter functions), still using radians internally.
-- Mesh.smoothresh: Didn't touch to this one, as we will hopefully replace it completely by loop normals currently in dev.
- Modifiers:
-- EdgeSplitModifierData.split_angle, BevelModifierData.bevel_angle: Done.
- Postprocessing:
-- WipeVars.angle (sequencer's effect), NodeBokehImage.angle, NodeBoxMask.rotation, NodeEllipseMask.rotation: Done.
- BGE:
-- bConstraintActuator: Orientation type done (the minloc[0] & maxloc[0] cases). Did not touch to 'limit location' type,
it can also limit rotation, but it exposes through RNA the same limit_min/limit_max, which hence
can be either distance or angle values, depending on the mode. Will leave this to BGE team.
-- bSoundActuator.cone_outer_angle_3d, bSoundActuator.cone_inner_angle_3d: Done (note I kept degrees in BGE itself,
as it seems this is the expected value here...).
-- bRadarSensor.angle: Done.
Reviewers: brecht, campbellbarton, sergey, gaiaclary, dfelinto, moguri, jbakker, lukastoenne, howardt
Reviewed By: brecht, campbellbarton, sergey, gaiaclary, moguri, jbakker, lukastoenne, howardt
Thanks to all!
Differential Revision: http://developer.blender.org/D59
Diffstat (limited to 'source/gameengine/Ketsji/KX_Light.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_Light.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
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; |