py api cleanup, replace use...
[blender.git] / source / gameengine / Ketsji / KX_VertexProxy.cpp
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file gameengine/Ketsji/KX_VertexProxy.cpp
29  *  \ingroup ketsji
30  */
31
32
33 #ifdef WITH_PYTHON
34
35 #include "KX_VertexProxy.h"
36 #include "KX_MeshProxy.h"
37 #include "RAS_TexVert.h"
38
39 #include "KX_PyMath.h"
40
41 PyTypeObject KX_VertexProxy::Type = {
42         PyVarObject_HEAD_INIT(NULL, 0)
43         "KX_VertexProxy",
44         sizeof(PyObjectPlus_Proxy),
45         0,
46         py_base_dealloc,
47         0,
48         0,
49         0,
50         0,
51         py_base_repr,
52         0,0,0,0,0,0,0,0,0,
53         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
54         0,0,0,0,0,0,0,
55         Methods,
56         0,
57         0,
58         &CValue::Type,
59         0,0,0,0,0,0,
60         py_base_new
61 };
62
63 PyMethodDef KX_VertexProxy::Methods[] = {
64         {"getXYZ", (PyCFunction)KX_VertexProxy::sPyGetXYZ,METH_NOARGS},
65         {"setXYZ", (PyCFunction)KX_VertexProxy::sPySetXYZ,METH_O},
66         {"getUV", (PyCFunction)KX_VertexProxy::sPyGetUV1, METH_NOARGS},
67         {"setUV", (PyCFunction)KX_VertexProxy::sPySetUV1, METH_O},
68
69         {"getUV2", (PyCFunction)KX_VertexProxy::sPyGetUV2,METH_NOARGS},
70         {"setUV2", (PyCFunction)KX_VertexProxy::sPySetUV2,METH_VARARGS},
71
72         {"getRGBA", (PyCFunction)KX_VertexProxy::sPyGetRGBA,METH_NOARGS},
73         {"setRGBA", (PyCFunction)KX_VertexProxy::sPySetRGBA,METH_O},
74         {"getNormal", (PyCFunction)KX_VertexProxy::sPyGetNormal,METH_NOARGS},
75         {"setNormal", (PyCFunction)KX_VertexProxy::sPySetNormal,METH_O},
76         {NULL,NULL} //Sentinel
77 };
78
79 PyAttributeDef KX_VertexProxy::Attributes[] = {
80         KX_PYATTRIBUTE_RW_FUNCTION("x", KX_VertexProxy, pyattr_get_x, pyattr_set_x),
81         KX_PYATTRIBUTE_RW_FUNCTION("y", KX_VertexProxy, pyattr_get_y, pyattr_set_y),
82         KX_PYATTRIBUTE_RW_FUNCTION("z", KX_VertexProxy, pyattr_get_z, pyattr_set_z),
83
84         KX_PYATTRIBUTE_RW_FUNCTION("r", KX_VertexProxy, pyattr_get_r, pyattr_set_r),
85         KX_PYATTRIBUTE_RW_FUNCTION("g", KX_VertexProxy, pyattr_get_g, pyattr_set_g),
86         KX_PYATTRIBUTE_RW_FUNCTION("b", KX_VertexProxy, pyattr_get_b, pyattr_set_b),
87         KX_PYATTRIBUTE_RW_FUNCTION("a", KX_VertexProxy, pyattr_get_a, pyattr_set_a),
88
89         KX_PYATTRIBUTE_RW_FUNCTION("u", KX_VertexProxy, pyattr_get_u, pyattr_set_u),
90         KX_PYATTRIBUTE_RW_FUNCTION("v", KX_VertexProxy, pyattr_get_v, pyattr_set_v),
91
92         KX_PYATTRIBUTE_RW_FUNCTION("u2", KX_VertexProxy, pyattr_get_u2, pyattr_set_u2),
93         KX_PYATTRIBUTE_RW_FUNCTION("v2", KX_VertexProxy, pyattr_get_v2, pyattr_set_v2),
94
95         KX_PYATTRIBUTE_RW_FUNCTION("XYZ", KX_VertexProxy, pyattr_get_XYZ, pyattr_set_XYZ),
96         KX_PYATTRIBUTE_RW_FUNCTION("UV", KX_VertexProxy, pyattr_get_UV, pyattr_set_UV),
97
98         KX_PYATTRIBUTE_RW_FUNCTION("color", KX_VertexProxy, pyattr_get_color, pyattr_set_color),
99         KX_PYATTRIBUTE_RW_FUNCTION("normal", KX_VertexProxy, pyattr_get_normal, pyattr_set_normal),
100
101         { NULL }        //Sentinel
102 };
103
104 PyObject *KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
105 {
106         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
107         return PyFloat_FromDouble(self->m_vertex->getXYZ()[0]);
108 }
109
110 PyObject *KX_VertexProxy::pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
111 {
112         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
113         return PyFloat_FromDouble(self->m_vertex->getXYZ()[1]);
114 }
115
116 PyObject *KX_VertexProxy::pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
117 {
118         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
119         return PyFloat_FromDouble(self->m_vertex->getXYZ()[2]);
120 }
121
122 PyObject *KX_VertexProxy::pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
123 {
124         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
125         return PyFloat_FromDouble(self->m_vertex->getRGBA()[0]/255.0);
126 }
127
128 PyObject *KX_VertexProxy::pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
129 {
130         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
131         return PyFloat_FromDouble(self->m_vertex->getRGBA()[1]/255.0);
132 }
133
134 PyObject *KX_VertexProxy::pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
135 {
136         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
137         return PyFloat_FromDouble(self->m_vertex->getRGBA()[2]/255.0);
138 }
139
140 PyObject *KX_VertexProxy::pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
141 {
142         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
143         return PyFloat_FromDouble(self->m_vertex->getRGBA()[3]/255.0);
144 }
145
146 PyObject *KX_VertexProxy::pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
147 {
148         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
149         return PyFloat_FromDouble(self->m_vertex->getUV1()[0]);
150 }
151
152 PyObject *KX_VertexProxy::pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
153 {
154         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
155         return PyFloat_FromDouble(self->m_vertex->getUV1()[1]);
156 }
157
158 PyObject *KX_VertexProxy::pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
159 {
160         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
161         return PyFloat_FromDouble(self->m_vertex->getUV2()[0]);
162 }
163
164 PyObject *KX_VertexProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
165 {
166         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
167         return PyFloat_FromDouble(self->m_vertex->getUV2()[1]);
168 }
169
170 PyObject *KX_VertexProxy::pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
171 {
172         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
173         return PyObjectFrom(MT_Vector3(self->m_vertex->getXYZ()));
174 }
175
176 PyObject *KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
177 {
178         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
179         return PyObjectFrom(MT_Point2(self->m_vertex->getUV1()));
180 }
181
182 PyObject *KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
183 {
184         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
185         const unsigned char *colp = self->m_vertex->getRGBA();
186         MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]);
187         color /= 255.0;
188         return PyObjectFrom(color);
189 }
190
191 PyObject *KX_VertexProxy::pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
192 {
193         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
194         return PyObjectFrom(MT_Vector3(self->m_vertex->getNormal()));
195 }
196
197 int KX_VertexProxy::pyattr_set_x(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
198 {
199         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
200         if (PyFloat_Check(value))
201         {
202                 float val = PyFloat_AsDouble(value);
203                 MT_Point3 pos(self->m_vertex->getXYZ());
204                 pos.x() = val;
205                 self->m_vertex->SetXYZ(pos);
206                 self->m_mesh->SetMeshModified(true);
207                 return PY_SET_ATTR_SUCCESS;
208         }
209         return PY_SET_ATTR_FAIL;
210 }
211
212 int KX_VertexProxy::pyattr_set_y(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
213 {
214         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
215         if (PyFloat_Check(value))
216         {
217                 float val = PyFloat_AsDouble(value);
218                 MT_Point3 pos(self->m_vertex->getXYZ());
219                 pos.y() = val;
220                 self->m_vertex->SetXYZ(pos);
221                 self->m_mesh->SetMeshModified(true);
222                 return PY_SET_ATTR_SUCCESS;
223         }
224         return PY_SET_ATTR_FAIL;
225 }
226
227 int KX_VertexProxy::pyattr_set_z(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
228 {
229         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
230         if (PyFloat_Check(value))
231         {
232                 float val = PyFloat_AsDouble(value);
233                 MT_Point3 pos(self->m_vertex->getXYZ());
234                 pos.z() = val;
235                 self->m_vertex->SetXYZ(pos);
236                 self->m_mesh->SetMeshModified(true);
237                 return PY_SET_ATTR_SUCCESS;
238         }
239         return PY_SET_ATTR_FAIL;
240 }
241
242 int KX_VertexProxy::pyattr_set_u(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
243 {
244         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
245         if (PyFloat_Check(value))
246         {
247                 float val = PyFloat_AsDouble(value);
248                 MT_Point2 uv = self->m_vertex->getUV1();
249                 uv[0] = val;
250                 self->m_vertex->SetUV1(uv);
251                 self->m_mesh->SetMeshModified(true);
252                 return PY_SET_ATTR_SUCCESS;
253         }
254         return PY_SET_ATTR_FAIL;
255 }
256
257 int KX_VertexProxy::pyattr_set_v(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
258 {
259         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
260         if (PyFloat_Check(value))
261         {
262                 float val = PyFloat_AsDouble(value);
263                 MT_Point2 uv = self->m_vertex->getUV1();
264                 uv[1] = val;
265                 self->m_vertex->SetUV1(uv);
266                 self->m_mesh->SetMeshModified(true);
267                 return PY_SET_ATTR_SUCCESS;
268         }
269         return PY_SET_ATTR_FAIL;
270 }
271
272 int KX_VertexProxy::pyattr_set_u2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
273 {
274         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
275         if (PyFloat_Check(value))
276         {
277                 float val = PyFloat_AsDouble(value);
278                 MT_Point2 uv = self->m_vertex->getUV2();
279                 uv[0] = val;
280                 self->m_vertex->SetUV2(uv);
281                 self->m_mesh->SetMeshModified(true);
282                 return PY_SET_ATTR_SUCCESS;
283         }
284         return PY_SET_ATTR_FAIL;
285 }
286
287 int KX_VertexProxy::pyattr_set_v2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
288 {
289         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
290         if (PyFloat_Check(value))
291         {
292                 float val = PyFloat_AsDouble(value);
293                 MT_Point2 uv = self->m_vertex->getUV2();
294                 uv[1] = val;
295                 self->m_vertex->SetUV2(uv);
296                 self->m_mesh->SetMeshModified(true);
297                 return PY_SET_ATTR_SUCCESS;
298         }
299         return PY_SET_ATTR_FAIL;
300 }
301
302 int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
303 {
304         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
305         if (PyFloat_Check(value))
306         {
307                 float val = PyFloat_AsDouble(value);
308                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
309                 unsigned char *cp = (unsigned char*) &icol;
310                 val *= 255.0;
311                 cp[0] = (unsigned char) val;
312                 self->m_vertex->SetRGBA(icol);
313                 self->m_mesh->SetMeshModified(true);
314                 return PY_SET_ATTR_SUCCESS;
315         }
316         return PY_SET_ATTR_FAIL;
317 }
318
319 int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
320 {
321         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
322         if (PyFloat_Check(value))
323         {
324                 float val = PyFloat_AsDouble(value);
325                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
326                 unsigned char *cp = (unsigned char*) &icol;
327                 val *= 255.0;
328                 cp[1] = (unsigned char) val;
329                 self->m_vertex->SetRGBA(icol);
330                 self->m_mesh->SetMeshModified(true);
331                 return PY_SET_ATTR_SUCCESS;
332         }
333         return PY_SET_ATTR_FAIL;
334 }
335
336 int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
337 {
338         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
339         if (PyFloat_Check(value))
340         {
341                 float val = PyFloat_AsDouble(value);
342                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
343                 unsigned char *cp = (unsigned char*) &icol;
344                 val *= 255.0;
345                 cp[2] = (unsigned char) val;
346                 self->m_vertex->SetRGBA(icol);
347                 self->m_mesh->SetMeshModified(true);
348                 return PY_SET_ATTR_SUCCESS;
349         }
350         return PY_SET_ATTR_FAIL;
351 }
352
353 int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
354 {
355         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
356         if (PyFloat_Check(value))
357         {
358                 float val = PyFloat_AsDouble(value);
359                 unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
360                 unsigned char *cp = (unsigned char*) &icol;
361                 val *= 255.0;
362                 cp[3] = (unsigned char) val;
363                 self->m_vertex->SetRGBA(icol);
364                 self->m_mesh->SetMeshModified(true);
365                 return PY_SET_ATTR_SUCCESS;
366         }
367         return PY_SET_ATTR_FAIL;
368 }
369
370 int KX_VertexProxy::pyattr_set_XYZ(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
371 {
372         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
373         if (PySequence_Check(value))
374         {
375                 MT_Point3 vec;
376                 if (PyVecTo(value, vec))
377                 {
378                         self->m_vertex->SetXYZ(vec);
379                         self->m_mesh->SetMeshModified(true);
380                         return PY_SET_ATTR_SUCCESS;
381                 }
382         }
383         return PY_SET_ATTR_FAIL;
384 }
385
386 int KX_VertexProxy::pyattr_set_UV(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
387 {
388         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
389         if (PySequence_Check(value))
390         {
391                 MT_Point2 vec;
392                 if (PyVecTo(value, vec)) {
393                         self->m_vertex->SetUV1(vec);
394                         self->m_mesh->SetMeshModified(true);
395                         return PY_SET_ATTR_SUCCESS;
396                 }
397         }
398         return PY_SET_ATTR_FAIL;
399 }
400
401 int KX_VertexProxy::pyattr_set_color(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
402 {
403         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
404         if (PySequence_Check(value))
405         {
406                 MT_Vector4 vec;
407                 if (PyVecTo(value, vec))
408                 {
409                         self->m_vertex->SetRGBA(vec);
410                         self->m_mesh->SetMeshModified(true);
411                         return PY_SET_ATTR_SUCCESS;
412                 }
413         }
414         return PY_SET_ATTR_FAIL;
415 }
416
417 int KX_VertexProxy::pyattr_set_normal(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
418 {
419         KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
420         if (PySequence_Check(value))
421         {
422                 MT_Vector3 vec;
423                 if (PyVecTo(value, vec))
424                 {
425                         self->m_vertex->SetNormal(vec);
426                         self->m_mesh->SetMeshModified(true);
427                         return PY_SET_ATTR_SUCCESS;
428                 }
429         }
430         return PY_SET_ATTR_FAIL;
431 }
432
433 KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
434 :       m_vertex(vertex),
435         m_mesh(mesh)
436 {
437         /* see bug [#27071] */
438         Py_INCREF(m_mesh->GetProxy());
439 }
440
441 KX_VertexProxy::~KX_VertexProxy()
442 {
443         /* see bug [#27071] */
444         Py_DECREF(m_mesh->GetProxy());
445 }
446
447
448
449 // stuff for cvalue related things
450 CValue*         KX_VertexProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
451 CValue*         KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
452 STR_String      sVertexName="vertex";
453 const STR_String &      KX_VertexProxy::GetText() {return sVertexName;};
454 double          KX_VertexProxy::GetNumber() { return -1;}
455 STR_String&     KX_VertexProxy::GetName() { return sVertexName;}
456 void            KX_VertexProxy::SetName(const char *) { };
457 CValue*         KX_VertexProxy::GetReplica() { return NULL;}
458
459 // stuff for python integration
460
461 PyObject *KX_VertexProxy::PyGetXYZ()
462 {
463         return PyObjectFrom(MT_Point3(m_vertex->getXYZ()));
464 }
465
466 PyObject *KX_VertexProxy::PySetXYZ(PyObject *value)
467 {
468         MT_Point3 vec;
469         if (!PyVecTo(value, vec))
470                 return NULL;
471
472         m_vertex->SetXYZ(vec);
473         m_mesh->SetMeshModified(true);
474         Py_RETURN_NONE;
475 }
476
477 PyObject *KX_VertexProxy::PyGetNormal()
478 {
479         return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
480 }
481
482 PyObject *KX_VertexProxy::PySetNormal(PyObject *value)
483 {
484         MT_Vector3 vec;
485         if (!PyVecTo(value, vec))
486                 return NULL;
487
488         m_vertex->SetNormal(vec);
489         m_mesh->SetMeshModified(true);
490         Py_RETURN_NONE;
491 }
492
493
494 PyObject *KX_VertexProxy::PyGetRGBA()
495 {
496         int *rgba = (int *) m_vertex->getRGBA();
497         return PyLong_FromLong(*rgba);
498 }
499
500 PyObject *KX_VertexProxy::PySetRGBA(PyObject *value)
501 {
502         if (PyLong_Check(value)) {
503                 int rgba = PyLong_AsLong(value);
504                 m_vertex->SetRGBA(rgba);
505                 m_mesh->SetMeshModified(true);
506                 Py_RETURN_NONE;
507         }
508         else {
509                 MT_Vector4 vec;
510                 if (PyVecTo(value, vec))
511                 {
512                         m_vertex->SetRGBA(vec);
513                         m_mesh->SetMeshModified(true);
514                         Py_RETURN_NONE;
515                 }
516         }
517
518         PyErr_SetString(PyExc_TypeError, "vert.setRGBA(value): KX_VertexProxy, expected a 4D vector or an int");
519         return NULL;
520 }
521
522
523 PyObject *KX_VertexProxy::PyGetUV1()
524 {
525         return PyObjectFrom(MT_Vector2(m_vertex->getUV1()));
526 }
527
528 PyObject *KX_VertexProxy::PySetUV1(PyObject *value)
529 {
530         MT_Point2 vec;
531         if (!PyVecTo(value, vec))
532                 return NULL;
533
534         m_vertex->SetUV1(vec);
535         m_mesh->SetMeshModified(true);
536         Py_RETURN_NONE;
537 }
538
539 PyObject *KX_VertexProxy::PyGetUV2()
540 {
541         return PyObjectFrom(MT_Vector2(m_vertex->getUV2()));
542 }
543
544 PyObject *KX_VertexProxy::PySetUV2(PyObject *args)
545 {
546         MT_Point2 vec;
547         unsigned int unit= RAS_TexVert::SECOND_UV;
548
549         PyObject *list = NULL;
550         if (!PyArg_ParseTuple(args, "O|i:setUV2", &list, &unit))
551                 return NULL;
552
553         if (!PyVecTo(list, vec))
554                 return NULL;
555
556         m_vertex->SetFlag((m_vertex->getFlag()|RAS_TexVert::SECOND_UV));
557         m_vertex->SetUnit(unit);
558         m_vertex->SetUV2(vec);
559         m_mesh->SetMeshModified(true);
560         Py_RETURN_NONE;
561 }
562
563 #endif // WITH_PYTHON