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:
authorThomas Szepe <HG1_public@gmx.net>2015-03-23 23:36:08 +0300
committerThomas Szepe <HG1_public@gmx.net>2015-03-23 23:36:08 +0300
commit2affbb437bd3cbf3e1a502bd65a5eefb64a92b9b (patch)
tree2403ce2b95eb97249251d24ca035d389864c307f /source/gameengine/Ketsji/KX_PythonInit.cpp
parent38321faa8d111ec51ebdeb7f2e939062d5e080a1 (diff)
BGE: Multitexture world (mist, ambient) fix
This patch fix the existing word API for mist and global ambient lighting. Add deprecated message to disableMist() Add setUseMist(enable). Reviewers: dfelinto, campbellbarton, moguri Reviewed By: moguri Subscribers: solarlune, jta, brecht Projects: #bf_blender:_next Differential Revision: https://developer.blender.org/D148
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp113
1 files changed, 62 insertions, 51 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index d7dd3fe5253..e0af3283f44 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1029,108 +1029,118 @@ static PyObject *gPyGetStereoEye(PyObject *, PyObject *, PyObject *)
static PyObject *gPySetBackgroundColor(PyObject *, PyObject *value)
{
-
MT_Vector4 vec;
if (!PyVecTo(value, vec))
return NULL;
-
- if (gp_Canvas)
- {
- gp_Rasterizer->SetBackColor((float)vec[0], (float)vec[1], (float)vec[2], (float)vec[3]);
- }
KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
- if (wi->hasWorld())
- wi->setBackColor((float)vec[0], (float)vec[1], (float)vec[2]);
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.SetBackgroundColor(color), World not available");
+ return NULL;
+ }
+
+ wi->setBackColor((float)vec[0], (float)vec[1], (float)vec[2]);
Py_RETURN_NONE;
}
-
-
static PyObject *gPySetMistColor(PyObject *, PyObject *value)
{
-
MT_Vector3 vec;
if (!PyVecTo(value, vec))
return NULL;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistColor(color), Rasterizer not available");
+
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistColor(color), World not available");
return NULL;
}
- gp_Rasterizer->SetFogColor((float)vec[0], (float)vec[1], (float)vec[2]);
-
+
+ wi->setMistColor((float)vec[0], (float)vec[1], (float)vec[2]);
+
Py_RETURN_NONE;
}
static PyObject *gPyDisableMist(PyObject *)
{
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistColor(color), Rasterizer not available");
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.DisableMist(), World not available");
return NULL;
}
- gp_Rasterizer->DisableFog();
-
+ ShowDeprecationWarning("DisableMist()", "setUseMist(false)");
+ wi->setUseMist(false);
+
Py_RETURN_NONE;
}
-static PyObject *gPySetMistStart(PyObject *, PyObject *args)
+static PyObject *gPySetUseMist(PyObject *, PyObject *args)
{
+ int enable;
+ if (!PyArg_ParseTuple(args,"i:setUseMist",&enable))
+ return NULL;
+
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.setUseMist(enable), World not available");
+ return NULL;
+ }
+
+ wi->setUseMist(enable);
+
+ Py_RETURN_NONE;
+}
+static PyObject *gPySetMistStart(PyObject *, PyObject *args)
+{
float miststart;
if (!PyArg_ParseTuple(args,"f:setMistStart",&miststart))
return NULL;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistStart(float), Rasterizer not available");
+
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistStart(float), World not available");
return NULL;
}
-
- gp_Rasterizer->SetFogStart(miststart);
-
- Py_RETURN_NONE;
-}
+ wi->setMistStart(miststart);
+ Py_RETURN_NONE;
+}
static PyObject *gPySetMistEnd(PyObject *, PyObject *args)
{
-
- float mistend;
- if (!PyArg_ParseTuple(args,"f:setMistEnd",&mistend))
+ float mistdist;
+ if (!PyArg_ParseTuple(args,"f:setMistEnd",&mistdist))
return NULL;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistEnd(float), Rasterizer not available");
+
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistEnd(float), World not available");
return NULL;
}
-
- gp_Rasterizer->SetFogEnd(mistend);
-
+
+ wi->setMistDistance(mistdist);
+
Py_RETURN_NONE;
}
-
static PyObject *gPySetAmbientColor(PyObject *, PyObject *value)
{
-
MT_Vector3 vec;
if (!PyVecTo(value, vec))
return NULL;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setAmbientColor(color), Rasterizer not available");
+
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.setAmbientColor(color), World not available");
return NULL;
}
- gp_Rasterizer->SetAmbientColor((float)vec[0], (float)vec[1], (float)vec[2]);
-
- Py_RETURN_NONE;
-}
-
+ wi->setAmbientColor((float)vec[0], (float)vec[1], (float)vec[2]);
+ Py_RETURN_NONE;
+}
static PyObject *gPyMakeScreenshot(PyObject *, PyObject *args)
{
@@ -1510,9 +1520,10 @@ static struct PyMethodDef rasterizer_methods[] = {
{"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_O,"set Background Color (rgb)"},
{"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_O,"set Ambient Color (rgb)"},
{"disableMist",(PyCFunction)gPyDisableMist,METH_NOARGS,"turn off mist"},
+ {"setUseMist",(PyCFunction)gPySetUseMist,METH_VARARGS,"enable or disable mist"},
{"setMistColor",(PyCFunction)gPySetMistColor,METH_O,"set Mist Color (rgb)"},
- {"setMistStart",(PyCFunction)gPySetMistStart,METH_VARARGS,"set Mist Start(rgb)"},
- {"setMistEnd",(PyCFunction)gPySetMistEnd,METH_VARARGS,"set Mist End(rgb)"},
+ {"setMistStart",(PyCFunction)gPySetMistStart,METH_VARARGS,"set Mist Start"},
+ {"setMistEnd",(PyCFunction)gPySetMistEnd,METH_VARARGS,"set Mist End"},
{"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"},
{"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_NOARGS,"disable motion blur"},