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:
Diffstat (limited to 'source/gameengine/Ketsji/KX_Light.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp146
1 files changed, 71 insertions, 75 deletions
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index a2e93ecdd36..713838c88ec 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -57,6 +57,7 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
{
m_lightobj = lightobj;
m_lightobj.m_worldmatrix = GetOpenGLMatrixPtr();
+ m_lightobj.m_scene = sgReplicationInfo;
m_rendertools->AddLight(&m_lightobj);
m_glsl = glsl;
m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene();
@@ -158,7 +159,7 @@ void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_T
cam->NodeSetLocalPosition(camtrans.getOrigin());
cam->NodeSetLocalOrientation(camtrans.getBasis());
- cam->NodeUpdateGS(0,true);
+ cam->NodeUpdateGS(0);
/* setup rasterizer transformations */
ras->SetProjectionMatrix(projectionmat);
@@ -172,109 +173,114 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
GPU_lamp_shadow_buffer_unbind(lamp);
}
-PyObject* KX_LightObject::_getattr(const char *attr)
+PyObject* KX_LightObject::py_getattro(PyObject *attr)
{
- if (!strcmp(attr, "layer"))
+ char *attr_str= PyString_AsString(attr);
+
+ if (!strcmp(attr_str, "layer"))
return PyInt_FromLong(m_lightobj.m_layer);
- if (!strcmp(attr, "energy"))
+ if (!strcmp(attr_str, "energy"))
return PyFloat_FromDouble(m_lightobj.m_energy);
- if (!strcmp(attr, "distance"))
+ if (!strcmp(attr_str, "distance"))
return PyFloat_FromDouble(m_lightobj.m_distance);
- if (!strcmp(attr, "colour") || !strcmp(attr, "color"))
+ if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
return Py_BuildValue("[fff]", m_lightobj.m_red, m_lightobj.m_green, m_lightobj.m_blue);
- if (!strcmp(attr, "lin_attenuation"))
+ if (!strcmp(attr_str, "lin_attenuation"))
return PyFloat_FromDouble(m_lightobj.m_att1);
- if (!strcmp(attr, "quad_attenuation"))
+ if (!strcmp(attr_str, "quad_attenuation"))
return PyFloat_FromDouble(m_lightobj.m_att2);
- if (!strcmp(attr, "spotsize"))
+ if (!strcmp(attr_str, "spotsize"))
return PyFloat_FromDouble(m_lightobj.m_spotsize);
- if (!strcmp(attr, "spotblend"))
+ if (!strcmp(attr_str, "spotblend"))
return PyFloat_FromDouble(m_lightobj.m_spotblend);
- if (!strcmp(attr, "SPOT"))
+ if (!strcmp(attr_str, "SPOT"))
return PyInt_FromLong(RAS_LightObject::LIGHT_SPOT);
- if (!strcmp(attr, "SUN"))
+ if (!strcmp(attr_str, "SUN"))
return PyInt_FromLong(RAS_LightObject::LIGHT_SUN);
- if (!strcmp(attr, "NORMAL"))
+ if (!strcmp(attr_str, "NORMAL"))
return PyInt_FromLong(RAS_LightObject::LIGHT_NORMAL);
- if (!strcmp(attr, "type"))
+ if (!strcmp(attr_str, "type"))
return PyInt_FromLong(m_lightobj.m_type);
- _getattr_up(KX_GameObject);
+ py_getattro_up(KX_GameObject);
}
-int KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
-{
+
+int KX_LightObject::py_setattro(PyObject *attr, PyObject *pyvalue)
+{
+ char *attr_str= PyString_AsString(attr);
+
if (PyInt_Check(pyvalue))
{
int value = PyInt_AsLong(pyvalue);
- if (!strcmp(attr, "layer"))
+ if (!strcmp(attr_str, "layer"))
{
m_lightobj.m_layer = value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
- if (!strcmp(attr, "type"))
+ if (!strcmp(attr_str, "type"))
{
if (value >= RAS_LightObject::LIGHT_SPOT && value <= RAS_LightObject::LIGHT_NORMAL)
m_lightobj.m_type = (RAS_LightObject::LightType) value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
}
- if (PyFloat_Check(pyvalue))
+ if (PyFloat_Check(pyvalue) || PyInt_Check(pyvalue))
{
float value = PyFloat_AsDouble(pyvalue);
- if (!strcmp(attr, "energy"))
+ if (!strcmp(attr_str, "energy"))
{
m_lightobj.m_energy = value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
- if (!strcmp(attr, "distance"))
+ if (!strcmp(attr_str, "distance"))
{
m_lightobj.m_distance = value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
- if (!strcmp(attr, "lin_attenuation"))
+ if (!strcmp(attr_str, "lin_attenuation"))
{
m_lightobj.m_att1 = value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
- if (!strcmp(attr, "quad_attenuation"))
+ if (!strcmp(attr_str, "quad_attenuation"))
{
m_lightobj.m_att2 = value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
- if (!strcmp(attr, "spotsize"))
+ if (!strcmp(attr_str, "spotsize"))
{
m_lightobj.m_spotsize = value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
- if (!strcmp(attr, "spotblend"))
+ if (!strcmp(attr_str, "spotblend"))
{
m_lightobj.m_spotblend = value;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
}
if (PySequence_Check(pyvalue))
{
- if (!strcmp(attr, "colour") || !strcmp(attr, "color"))
+ if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
{
MT_Vector3 color;
if (PyVecTo(pyvalue, color))
@@ -282,19 +288,19 @@ int KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
m_lightobj.m_red = color[0];
m_lightobj.m_green = color[1];
m_lightobj.m_blue = color[2];
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
- return 1;
+ return PY_SET_ATTR_FAIL;
}
}
- if (!strcmp(attr, "SPOT") || !strcmp(attr, "SUN") || !strcmp(attr, "NORMAL"))
+ if (!strcmp(attr_str, "SPOT") || !strcmp(attr_str, "SUN") || !strcmp(attr_str, "NORMAL"))
{
- PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr);
- return 1;
+ PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr_str);
+ return PY_SET_ATTR_FAIL;
}
- return KX_GameObject::_setattr(attr, pyvalue);
+ return KX_GameObject::py_setattro(attr, pyvalue);
}
PyMethodDef KX_LightObject::Methods[] = {
@@ -302,51 +308,41 @@ PyMethodDef KX_LightObject::Methods[] = {
};
PyAttributeDef KX_LightObject::Attributes[] = {
+ KX_PYATTRIBUTE_DUMMY("layer"),
+ KX_PYATTRIBUTE_DUMMY("energy"),
+ KX_PYATTRIBUTE_DUMMY("distance"),
+ KX_PYATTRIBUTE_DUMMY("colour"),
+ KX_PYATTRIBUTE_DUMMY("color"),
+ KX_PYATTRIBUTE_DUMMY("lin_attenuation"),
+ KX_PYATTRIBUTE_DUMMY("quad_attenuation"),
+ KX_PYATTRIBUTE_DUMMY("spotsize"),
+ KX_PYATTRIBUTE_DUMMY("spotblend"),
+ KX_PYATTRIBUTE_DUMMY("SPOT"),
+ KX_PYATTRIBUTE_DUMMY("SUN"),
+ KX_PYATTRIBUTE_DUMMY("NORMAL"),
+ KX_PYATTRIBUTE_DUMMY("type"),
{ NULL } //Sentinel
};
-char KX_LightObject::doc[] = "Module KX_LightObject\n\n"
-"Constants:\n"
-"\tSPOT\n"
-"\tSUN\n"
-"\tNORMAL\n"
-"Attributes:\n"
-"\ttype -> SPOT, SUN or NORMAL\n"
-"\t\tThe type of light.\n"
-"\tlayer -> integer bit field.\n"
-"\t\tThe layers this light applies to.\n"
-"\tenergy -> float.\n"
-"\t\tThe brightness of the light.\n"
-"\tdistance -> float.\n"
-"\t\tThe effect radius of the light.\n"
-"\tcolour -> list [r, g, b].\n"
-"\tcolor -> list [r, g, b].\n"
-"\t\tThe color of the light.\n"
-"\tlin_attenuation -> float.\n"
-"\t\tThe attenuation factor for the light.\n"
-"\tspotsize -> float.\n"
-"\t\tThe size of the spot.\n"
-"\tspotblend -> float.\n"
-"\t\tThe blend? of the spot.\n";
-
PyTypeObject KX_LightObject::Type = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(NULL)
0,
"KX_LightObject",
- sizeof(KX_LightObject),
+ sizeof(PyObjectPlus_Proxy),
0,
- PyDestructor,
+ py_base_dealloc,
0,
- __getattr,
- __setattr,
- 0, //&MyPyCompare,
- __repr,
- 0, //&cvalue_as_number,
0,
0,
0,
- 0, 0, 0, 0, 0, 0,
- doc
+ py_base_repr,
+ 0,0,
+ &KX_GameObject::Mapping,
+ 0,0,0,
+ py_base_getattro,
+ py_base_setattro,
+ 0,0,0,0,0,0,0,0,0,
+ Methods
};
PyParentObject KX_LightObject::Parents[] = {