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:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-05-06 23:55:46 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-05-06 23:55:46 +0300
commitfb0dd596e9a58f095730359a11759c40ea46be44 (patch)
tree1ac9e049b1b87e60964c75a556fd99e4e1d3913d /source/gameengine
parentde180aba35ea0bc203abb4995b9fbcaa2d97aaa2 (diff)
BGE : KX_VertexProxy support for more than 2 UV channel.
I have added an optional named "index" argument for methode get/setUV, I have also modified the and set to deprecated methodes setUV2 and getUV2 : the doc was wrong and the methode can't be called anyway because it declared as VARARG in the .h and convert directly the args value to a vector in the .cpp. Reviewers: sybren, lordloki, hg1 Reviewed By: lordloki, hg1 Subscribers: agoose77 Differential Revision: https://developer.blender.org/D1240
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.cpp41
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.h6
2 files changed, 34 insertions, 13 deletions
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp
index cd1c9eed91b..163416526f3 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.cpp
+++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp
@@ -63,11 +63,11 @@ PyTypeObject KX_VertexProxy::Type = {
PyMethodDef KX_VertexProxy::Methods[] = {
{"getXYZ", (PyCFunction)KX_VertexProxy::sPyGetXYZ,METH_NOARGS},
{"setXYZ", (PyCFunction)KX_VertexProxy::sPySetXYZ,METH_O},
- {"getUV", (PyCFunction)KX_VertexProxy::sPyGetUV1, METH_NOARGS},
- {"setUV", (PyCFunction)KX_VertexProxy::sPySetUV1, METH_O},
+ {"getUV", (PyCFunction)KX_VertexProxy::sPyGetUV, METH_VARARGS},
+ {"setUV", (PyCFunction)KX_VertexProxy::sPySetUV, METH_VARARGS},
{"getUV2", (PyCFunction)KX_VertexProxy::sPyGetUV2,METH_NOARGS},
- {"setUV2", (PyCFunction)KX_VertexProxy::sPySetUV2,METH_VARARGS},
+ {"setUV2", (PyCFunction)KX_VertexProxy::sPySetUV2, METH_O},
{"getRGBA", (PyCFunction)KX_VertexProxy::sPyGetRGBA,METH_NOARGS},
{"setRGBA", (PyCFunction)KX_VertexProxy::sPySetRGBA,METH_O},
@@ -423,7 +423,6 @@ int KX_VertexProxy::pyattr_set_uvs(void *self_v, const struct KX_PYATTRIBUTE_DEF
if (PyVecTo(PySequence_GetItem(value, i), vec))
{
self->m_vertex->SetUV(i, vec);
- self->m_mesh->SetMeshModified(true);
}
else
{
@@ -559,25 +558,45 @@ PyObject *KX_VertexProxy::PySetRGBA(PyObject *value)
return NULL;
}
-
-PyObject *KX_VertexProxy::PyGetUV1()
+PyObject *KX_VertexProxy::PyGetUV(PyObject *args)
{
- return PyObjectFrom(MT_Vector2(m_vertex->getUV(0)));
+ int index = 0;
+ if (!PyArg_ParseTuple(args, "|i:getUV", &index))
+ return NULL;
+
+ if (index < 0 || index > (RAS_TexVert::MAX_UNIT - 1)) {
+ PyErr_Format(PyExc_TypeError, "vert.getUV(index): KX_VertexProxy, expected an int between 0 and %i", (RAS_TexVert::MAX_UNIT - 1));
+ return NULL;
+ }
+
+ return PyObjectFrom(MT_Vector2(m_vertex->getUV(index)));
}
-PyObject *KX_VertexProxy::PySetUV1(PyObject *value)
+PyObject *KX_VertexProxy::PySetUV(PyObject *args)
{
+ PyObject *pyvect;
+ int index = 0;
+ if (!PyArg_ParseTuple(args, "O|i:setUV", &pyvect, &index))
+ return NULL;
+
+ if (index < 0 || index > (RAS_TexVert::MAX_UNIT - 1)) {
+ PyErr_Format(PyExc_TypeError, "vert.setUV(uv, index): KX_VertexProxy, expected an int between 0 and %i", (RAS_TexVert::MAX_UNIT - 1));
+ return NULL;
+ }
+
MT_Point2 vec;
- if (!PyVecTo(value, vec))
+ if (!PyVecTo(pyvect, vec))
return NULL;
- m_vertex->SetUV(0, vec);
+ m_vertex->SetUV(index, vec);
m_mesh->SetMeshModified(true);
Py_RETURN_NONE;
}
PyObject *KX_VertexProxy::PyGetUV2()
{
+ ShowDeprecationWarning("getUV2()", "getUV(1)");
+
return PyObjectFrom(MT_Vector2(m_vertex->getUV(1)));
}
@@ -587,6 +606,8 @@ PyObject *KX_VertexProxy::PySetUV2(PyObject *args)
if (!PyVecTo(args, vec))
return NULL;
+ ShowDeprecationWarning("setUV2(uv)", "setUV(uv, 1)");
+
m_vertex->SetUV(1, vec);
m_mesh->SetMeshModified(true);
Py_RETURN_NONE;
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h
index 8070825ad11..91cf29deca1 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.h
+++ b/source/gameengine/Ketsji/KX_VertexProxy.h
@@ -94,11 +94,11 @@ public:
KX_PYMETHOD_NOARGS(KX_VertexProxy,GetXYZ);
KX_PYMETHOD_O(KX_VertexProxy,SetXYZ);
- KX_PYMETHOD_NOARGS(KX_VertexProxy,GetUV1);
- KX_PYMETHOD_O(KX_VertexProxy,SetUV1);
+ KX_PYMETHOD_VARARGS(KX_VertexProxy, GetUV);
+ KX_PYMETHOD_VARARGS(KX_VertexProxy, SetUV);
KX_PYMETHOD_NOARGS(KX_VertexProxy,GetUV2);
- KX_PYMETHOD_VARARGS(KX_VertexProxy,SetUV2);
+ KX_PYMETHOD_O(KX_VertexProxy, SetUV2);
KX_PYMETHOD_NOARGS(KX_VertexProxy,GetRGBA);
KX_PYMETHOD_O(KX_VertexProxy,SetRGBA);