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:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-07-17 09:28:23 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-07-17 09:28:23 +0400
commitbaa2f99f079920d404af65798a8df3e82bcc6a48 (patch)
tree2e8fb2bad0c3824e87e12cc0ebf3d4933eeb56f3 /source/gameengine/Ketsji
parent90fb63152628927d5d13b0101f4f2dcec025d2f7 (diff)
Port Python updates from Tuhopuu2:
getType/setType to action/sound actuator (sgefant) Use a more generic python -> math conversion.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp56
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp142
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp6
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.h1
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp330
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.h117
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp139
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp22
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp141
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h4
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.cpp11
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp27
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp21
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.cpp200
-rw-r--r--source/gameengine/Ketsji/Makefile6
18 files changed, 534 insertions, 714 deletions
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index 5d455a70ed1..d32ea269d3a 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -435,13 +435,13 @@ PyObject* KX_Camera::_getattr(const STR_String& attr)
if (attr == "frustum_culling")
return PyInt_FromLong(m_frustum_culling); /* new ref */
if (attr == "projection_matrix")
- return PyObjectFromMT_Matrix4x4(GetProjectionMatrix()); /* new ref */
+ return PyObjectFrom(GetProjectionMatrix()); /* new ref */
if (attr == "modelview_matrix")
- return PyObjectFromMT_Matrix4x4(GetModelviewMatrix()); /* new ref */
+ return PyObjectFrom(GetModelviewMatrix()); /* new ref */
if (attr == "camera_to_world")
- return PyObjectFromMT_Matrix4x4(GetCameraToWorld()); /* new ref */
+ return PyObjectFrom(GetCameraToWorld()); /* new ref */
if (attr == "world_to_camera")
- return PyObjectFromMT_Matrix4x4(GetWorldToCamera()); /* new ref */
+ return PyObjectFrom(GetWorldToCamera()); /* new ref */
_getattr_up(KX_GameObject);
}
@@ -483,8 +483,13 @@ int KX_Camera::_setattr(const STR_String &attr, PyObject *pyvalue)
{
if (attr == "projection_matrix")
{
- SetProjectionMatrix(MT_Matrix4x4FromPyObject(pyvalue));
- return 0;
+ MT_Matrix4x4 mat;
+ if (PyMatTo(pyvalue, mat))
+ {
+ SetProjectionMatrix(mat);
+ return 0;
+ }
+ return 1;
}
}
return KX_GameObject::_setattr(attr, pyvalue);
@@ -512,14 +517,11 @@ KX_PYMETHODDEF_DOC(KX_Camera, sphereInsideFrustum,
float radius;
if (PyArg_ParseTuple(args, "Of", &pycentre, &radius))
{
- MT_Point3 centre = MT_Point3FromPyList(pycentre);
- if (PyErr_Occurred())
+ MT_Point3 centre;
+ if (PyVecTo(pycentre, centre))
{
- PyErr_SetString(PyExc_TypeError, "sphereInsideFrustum: Expected list for argument centre.");
- Py_Return;
+ return PyInt_FromLong(SphereInsideFrustum(centre, radius)); /* new ref */
}
-
- return PyInt_FromLong(SphereInsideFrustum(centre, radius)); /* new ref */
}
PyErr_SetString(PyExc_TypeError, "sphereInsideFrustum: Expected arguments: (centre, radius)");
@@ -566,9 +568,9 @@ KX_PYMETHODDEF_DOC(KX_Camera, boxInsideFrustum,
for (unsigned int p = 0; p < 8 ; p++)
{
PyObject *item = PySequence_GetItem(pybox, p); /* new ref */
- box[p] = MT_Point3FromPyList(item);
+ bool error = !PyVecTo(item, box[p]);
Py_DECREF(item);
- if (PyErr_Occurred())
+ if (error)
return NULL;
}
@@ -595,13 +597,9 @@ KX_PYMETHODDEF_DOC(KX_Camera, pointInsideFrustum,
"\t\t# Box is outside the frustum !\n"
)
{
- PyObject *pypoint;
- if (PyArg_ParseTuple(args, "O", &pypoint))
+ MT_Point3 point;
+ if (PyVecArgTo(args, point))
{
- MT_Point3 point = MT_Point3FromPyList(pypoint);
- if (PyErr_Occurred())
- return NULL;
-
return PyInt_FromLong(PointInsideFrustum(point)); /* new ref */
}
@@ -615,7 +613,7 @@ KX_PYMETHODDEF_DOC(KX_Camera, getCameraToWorld,
"\tie: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])\n"
)
{
- return PyObjectFromMT_Matrix4x4(GetCameraToWorld()); /* new ref */
+ return PyObjectFrom(GetCameraToWorld()); /* new ref */
}
KX_PYMETHODDEF_DOC(KX_Camera, getWorldToCamera,
@@ -624,7 +622,7 @@ KX_PYMETHODDEF_DOC(KX_Camera, getWorldToCamera,
"\tie: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])\n"
)
{
- return PyObjectFromMT_Matrix4x4(GetWorldToCamera()); /* new ref */
+ return PyObjectFrom(GetWorldToCamera()); /* new ref */
}
KX_PYMETHODDEF_DOC(KX_Camera, getProjectionMatrix,
@@ -633,7 +631,7 @@ KX_PYMETHODDEF_DOC(KX_Camera, getProjectionMatrix,
"\tie: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])\n"
)
{
- return PyObjectFromMT_Matrix4x4(GetProjectionMatrix()); /* new ref */
+ return PyObjectFrom(GetProjectionMatrix()); /* new ref */
}
KX_PYMETHODDEF_DOC(KX_Camera, setProjectionMatrix,
@@ -681,12 +679,12 @@ KX_PYMETHODDEF_DOC(KX_Camera, setProjectionMatrix,
PyObject *pymat;
if (PyArg_ParseTuple(args, "O", &pymat))
{
- MT_Matrix4x4 mat = MT_Matrix4x4FromPyObject(pymat);
- if (PyErr_Occurred())
- return NULL;
-
- SetProjectionMatrix(mat);
- Py_Return;
+ MT_Matrix4x4 mat;
+ if (PyMatTo(pymat, mat))
+ {
+ SetProjectionMatrix(mat);
+ Py_Return;
+ }
}
PyErr_SetString(PyExc_TypeError, "setProjectionMatrix: Expected 4x4 list as matrix argument.");
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 6a35dfc0484..3061ceb252a 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -628,7 +628,7 @@ PyMethodDef KX_GameObject::Methods[] = {
-
+/*
bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args,
MT_Vector3& pos,
MT_Vector3& pos2)
@@ -642,7 +642,7 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args,
return error;
}
-
+*/
PyObject* KX_GameObject::sPySetPosition(PyObject* self,
@@ -658,7 +658,7 @@ PyObject* KX_GameObject::PyGetPosition(PyObject* self,
PyObject* args,
PyObject* kwds)
{
- return PyObjectFromMT_Point3(NodeGetWorldPosition());
+ return PyObjectFrom(NodeGetWorldPosition());
}
@@ -706,21 +706,27 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr)
{
KX_GameObject* parent = GetParent();
if (parent)
+ {
+ parent->AddRef();
return parent;
+ }
Py_Return;
}
-
+
if (attr == "visible")
return PyInt_FromLong(m_bVisible);
if (attr == "position")
- return PyObjectFromMT_Point3(NodeGetWorldPosition());
+ return PyObjectFrom(NodeGetWorldPosition());
if (attr == "orientation")
- return PyObjectFromMT_Matrix3x3(NodeGetWorldOrientation());
+ return PyObjectFrom(NodeGetWorldOrientation());
if (attr == "scaling")
- return PyObjectFromMT_Vector3(NodeGetWorldScaling());
+ return PyObjectFrom(NodeGetWorldScaling());
+
+ if (attr == "name")
+ return PyString_FromString(m_name.ReadPtr());
_getattr_up(SCA_IObject);
}
@@ -750,25 +756,36 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
MT_Matrix3x3 rot;
if (PyObject_IsMT_Matrix(value, 3))
{
- rot = MT_Matrix3x3FromPyObject(value);
- NodeSetLocalOrientation(rot);
- return 0;
+ if (PyMatTo(value, rot))
+ {
+ NodeSetLocalOrientation(rot);
+ return 0;
+ }
+ return 1;
}
if (PySequence_Size(value) == 4)
{
- MT_Quaternion qrot = MT_QuaternionFromPyList(value);
- rot.setRotation(qrot);
- NodeSetLocalOrientation(rot);
- return 0;
+ MT_Quaternion qrot;
+ if (PyVecTo(value, qrot))
+ {
+ rot.setRotation(qrot);
+ NodeSetLocalOrientation(rot);
+ return 0;
+ }
+ return 1;
}
if (PySequence_Size(value) == 3)
{
- MT_Vector3 erot = MT_Vector3FromPyList(value);
- rot.setEuler(erot);
- NodeSetLocalOrientation(rot);
- return 0;
+ MT_Vector3 erot;
+ if (PyVecTo(value, erot))
+ {
+ rot.setEuler(erot);
+ NodeSetLocalOrientation(rot);
+ return 0;
+ }
+ return 1;
}
return 1;
@@ -776,15 +793,32 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
if (attr == "position")
{
- MT_Point3 pos(MT_Point3FromPyList(value));
- NodeSetLocalPosition(pos);
- return 0;
+ MT_Point3 pos;
+ if (PyVecTo(value, pos))
+ {
+ NodeSetLocalPosition(pos);
+ return 0;
+ }
+ return 1;
}
if (attr == "scaling")
{
- MT_Vector3 scale(MT_Vector3FromPyList(value));
- NodeSetLocalScale(scale);
+ MT_Vector3 scale;
+ if (PyVecTo(value, scale))
+ {
+ NodeSetLocalScale(scale);
+ return 0;
+ }
+ return 1;
+ }
+ }
+
+ if (PyString_Check(value))
+ {
+ if (attr == "name")
+ {
+ m_name = PyString_AsString(value);
return 0;
}
}
@@ -798,7 +832,7 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self,
PyObject* kwds)
{
// only can get the velocity if we have a physics object connected to us...
- return PyObjectFromMT_Vector3( GetLinearVelocity());
+ return PyObjectFrom(GetLinearVelocity());
}
@@ -837,7 +871,7 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self,
if (PyArg_ParseTuple(args, "|O", &pypos))
{
if (pypos)
- point = MT_Point3FromPyList(pypos);
+ PyVecTo(pypos, point);
}
if (m_pPhysicsController1)
@@ -845,7 +879,7 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self,
velocity = m_pPhysicsController1->GetVelocity(point);
}
- return PyObjectFromMT_Vector3(velocity);
+ return PyObjectFrom(velocity);
}
@@ -872,7 +906,7 @@ PyObject* KX_GameObject::PyGetReactionForce(PyObject* self,
PyObject* kwds)
{
// only can get the velocity if we have a physics object connected to us...
- return PyObjectFromMT_Vector3(GetPhysicsController()->getReactionForce());
+ return PyObjectFrom(GetPhysicsController()->getReactionForce());
}
@@ -906,7 +940,10 @@ PyObject* KX_GameObject::PyGetParent(PyObject* self,
{
KX_GameObject* parent = this->GetParent();
if (parent)
+ {
+ parent->AddRef();
return parent;
+ }
Py_Return;
}
@@ -942,17 +979,18 @@ PyObject* KX_GameObject::PyApplyImpulse(PyObject* self,
if (PyArg_ParseTuple(args, "OO", &pyattach, &pyimpulse))
{
- MT_Point3 attach(MT_Point3FromPyList(pyattach));
- MT_Vector3 impulse(MT_Vector3FromPyList(pyimpulse));
+ MT_Point3 attach;
+ MT_Vector3 impulse;
- if (m_pPhysicsController1)
+ if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse) && m_pPhysicsController1)
{
m_pPhysicsController1->applyImpulse(attach, impulse);
+ Py_Return;
}
}
- Py_Return;
+ return NULL;
}
@@ -1002,8 +1040,7 @@ PyObject* KX_GameObject::PyGetOrientation(PyObject* self,
PyObject* args,
PyObject* kwds) //keywords
{
- const MT_Matrix3x3& orient = NodeGetWorldOrientation();
- return PyObjectFromMT_Matrix3x3(orient);
+ return PyObjectFrom(NodeGetWorldOrientation());
}
@@ -1016,29 +1053,24 @@ PyObject* KX_GameObject::PySetOrientation(PyObject* self,
bool error = false;
int row,col;
- PyArg_ParseTuple(args,"O",&pylist);
-
- MT_Matrix3x3 matrix;
- if (PyObject_IsMT_Matrix(pylist, 3))
+ if (PyArg_ParseTuple(args,"O",&pylist))
{
- matrix = MT_Matrix3x3FromPyObject(pylist);
-
- if (!PyErr_Occurred())
+ MT_Matrix3x3 matrix;
+ if (PyObject_IsMT_Matrix(pylist, 3) && PyMatTo(pylist, matrix))
{
NodeSetLocalOrientation(matrix);
+ Py_Return;
}
-
- Py_Return;
- }
- MT_Quaternion quat = MT_QuaternionFromPyList(pylist);
- if (!PyErr_Occurred())
- {
- matrix.setRotation(quat);
- NodeSetLocalOrientation(matrix);
+ MT_Quaternion quat;
+ if (PyVecTo(pylist, quat))
+ {
+ matrix.setRotation(quat);
+ NodeSetLocalOrientation(matrix);
+ Py_Return;
+ }
}
-
- Py_Return;
+ return NULL;
}
@@ -1047,14 +1079,14 @@ PyObject* KX_GameObject::PySetPosition(PyObject* self,
PyObject* args,
PyObject* kwds)
{
- // make a general function for this, it's needed many times
- PyObject *pypos;
- if (PyArg_ParseTuple(args, "O", &pypos))
+ MT_Point3 pos;
+ if (PyVecArgTo(args, pos))
{
- MT_Point3 pos = MT_Point3FromPyList(pypos);
NodeSetLocalPosition(pos);
+ Py_Return;
}
- Py_Return;
+
+ return NULL;
}
PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self,
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index f5ec21ee1b8..06a52c07b3f 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -191,11 +191,15 @@ int KX_LightObject::_setattr(const STR_String& attr, PyObject *pyvalue)
{
if (attr == "colour" || attr == "color")
{
- MT_Vector3 colour(MT_Vector3FromPyList(pyvalue));
- m_lightobj.m_red = colour[0];
- m_lightobj.m_green = colour[1];
- m_lightobj.m_blue = colour[2];
- return 0;
+ MT_Vector3 colour;
+ if (PyVecTo(pyvalue, colour))
+ {
+ m_lightobj.m_red = colour[0];
+ m_lightobj.m_green = colour[1];
+ m_lightobj.m_blue = colour[2];
+ return 0;
+ }
+ return 1;
}
}
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index 4cde3ea9025..ec0ddddafed 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -29,14 +29,15 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "KX_MeshProxy.h"
#include "RAS_IPolygonMaterial.h"
#include "RAS_MeshObject.h"
-#include "KX_VertexProxy.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "KX_VertexProxy.h"
PyTypeObject KX_MeshProxy::Type = {
PyObject_HEAD_INIT(&PyType_Type)
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
index 3c6a5b9ba5e..3bb6bad5029 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -143,10 +143,12 @@ KX_NearSensor::~KX_NearSensor()
{
// for nearsensor, the sensor is the 'owner' of sumoobj
// for touchsensor, it's the parent
- static_cast<KX_TouchEventManager*>(m_eventmgr)->GetSumoScene()->remove(*m_sumoObj);
-
if (m_sumoObj)
+ {
+ static_cast<KX_TouchEventManager*>(m_eventmgr)->GetSumoScene()->remove(*m_sumoObj);
delete m_sumoObj;
+ m_sumoObj = NULL;
+ }
if (m_client_info)
delete m_client_info;
diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h
index d1126510728..080df58639e 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.h
+++ b/source/gameengine/Ketsji/KX_NearSensor.h
@@ -39,7 +39,6 @@
#include "KX_ClientObjectInfo.h"
class KX_Scene;
-class KX_ClientObjectInfo;
class KX_NearSensor : public KX_TouchSensor
{
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
index ba687744dfc..47984aa22ec 100644
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ b/source/gameengine/Ketsji/KX_PyMath.cpp
@@ -48,272 +48,13 @@
#include "KX_Python.h"
-MT_Vector3 MT_Vector3FromPyList(PyObject* pylist)
-{
- MT_Vector3 vec(0., 0., 0.);
- bool error=false;
- if (pylist->ob_type == &CListValue::Type)
- {
- CListValue* listval = (CListValue*) pylist;
- unsigned int numitems = listval->GetCount();
- if (numitems <= 3)
- {
- for (unsigned int index=0;index<numitems;index++)
- {
- vec[index] = listval->GetValue(index)->GetNumber();
- }
- } else
- {
- error = true;
- }
-
- } else
- {
- // assert the list is long enough...
- unsigned int numitems = PySequence_Size(pylist);
- if (numitems <= 3)
- {
- for (unsigned int index=0;index<numitems;index++)
- {
- PyObject *item = PySequence_GetItem(pylist,index); /* new ref */
- vec[index] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
- }
- else
- {
- error = true;
- }
-
- }
- if (error)
- PyErr_SetString(PyExc_TypeError, "Expected list of three items for vector argument.");
-
- return vec;
-}
-
-MT_Point3 MT_Point3FromPyList(PyObject* pylist)
-{
- MT_Point3 point(0., 0., 0.);
- bool error=false;
- if (pylist->ob_type == &CListValue::Type)
- {
- CListValue* listval = (CListValue*) pylist;
- unsigned int numitems = listval->GetCount();
- if (numitems <= 3)
- {
- for (unsigned int index=0;index<numitems;index++)
- {
- point[index] = listval->GetValue(index)->GetNumber();
- }
- } else
- {
- error = true;
- }
-
- } else
- {
- // assert the list is long enough...
- unsigned int numitems = PySequence_Size(pylist);
- if (numitems <= 3)
- {
- for (unsigned int index=0;index<numitems;index++)
- {
- PyObject *item = PySequence_GetItem(pylist,index); /* new ref */
- point[index] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
- }
- else
- {
- error = true;
- }
-
- }
- if (error)
- PyErr_SetString(PyExc_TypeError, "Expected list of three items for point argument.");
-
- return point;
-}
-
-MT_Point2 MT_Point2FromPyList(PyObject* pylist)
-{
- MT_Point2 point(0., 0.);
- bool error=false;
- if (pylist->ob_type == &CListValue::Type)
- {
- CListValue* listval = (CListValue*) pylist;
- unsigned int numitems = listval->GetCount();
- if (numitems <= 2)
- {
- for (unsigned int index=0;index<numitems;index++)
- {
- point[index] = listval->GetValue(index)->GetNumber();
- }
- } else
- {
- error = true;
- }
-
- } else
- {
- // assert the list is long enough...
- unsigned int numitems = PySequence_Size(pylist);
- if (numitems <= 2)
- {
- for (unsigned int index=0;index<numitems;index++)
- {
- PyObject *item = PySequence_GetItem(pylist,index); /* new ref */
- point[index] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
- }
- else
- {
- error = true;
- }
-
- }
- if (error)
- PyErr_SetString(PyExc_TypeError, "Expected list of twos items for point argument.");
-
- return point;
-}
-
-MT_Vector4 MT_Vector4FromPyList(PyObject* pylist)
-{
- MT_Vector4 vec(0., 0., 0., 1.);
- bool error=false;
- if (pylist->ob_type == &CListValue::Type)
- {
- CListValue* listval = (CListValue*) pylist;
- unsigned int numitems = listval->GetCount();
- if (numitems <= 4)
- {
- for (unsigned index=0;index<numitems;index++)
- {
- vec[index] = listval->GetValue(index)->GetNumber();
- }
- } else
- {
- error = true;
- }
-
- } else
- {
- // assert the list is long enough...
- unsigned int numitems = PySequence_Size(pylist);
- if (numitems <= 4)
- {
- for (unsigned index=0;index<numitems;index++)
- {
- PyObject *item = PySequence_GetItem(pylist,index); /* new ref */
- vec[index] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
- }
- else
- {
- error = true;
- }
- }
- if (error)
- PyErr_SetString(PyExc_TypeError, "Expected list of four items for Vector argument.");
- return vec;
-}
-
-MT_Quaternion MT_QuaternionFromPyList(PyObject* pylist)
-{
- MT_Quaternion vec(0., 0., 0., 1.);
- bool error=false;
- if (pylist->ob_type == &CListValue::Type)
- {
- CListValue* listval = (CListValue*) pylist;
- unsigned int numitems = listval->GetCount();
- if (numitems <= 4)
- {
- for (unsigned index=0;index<numitems;index++)
- {
- vec[index] = listval->GetValue(index)->GetNumber();
- }
- } else
- {
- error = true;
- }
-
- } else
- {
- // assert the list is long enough...
- unsigned int numitems = PySequence_Size(pylist);
- if (numitems <= 4)
- {
- for (unsigned index=0;index<numitems;index++)
- {
- PyObject *item = PySequence_GetItem(pylist,index); /* new ref */
- vec[index] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
- }
- else
- {
- error = true;
- }
- }
- if (error)
- PyErr_SetString(PyExc_TypeError, "Expected list of four items for Quaternion argument.");
- return vec;
-}
-
-
-MT_Matrix4x4 MT_Matrix4x4FromPyObject(PyObject *pymat)
-{
- MT_Matrix4x4 mat;
- bool error = false;
- mat.setIdentity();
- if (PySequence_Check(pymat))
- {
- unsigned int rows = PySequence_Size(pymat);
- for (unsigned int y = 0; y < rows && y < 4; y++)
- {
- PyObject *pyrow = PySequence_GetItem(pymat, y); /* new ref */
- if (PySequence_Check(pyrow))
- {
- unsigned int cols = PySequence_Size(pyrow);
- for( unsigned int x = 0; x < cols && x < 4; x++)
- {
- PyObject *item = PySequence_GetItem(pyrow, x); /* new ref */
- mat[y][x] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
- }
- Py_DECREF(pyrow);
- }
- }
-
- return mat;
-}
-
bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
{
if (!pymat)
return false;
unsigned int x, y;
- if (pymat->ob_type == &CListValue::Type)
- {
- CListValue* listval = (CListValue*) pymat;
- if (listval->GetCount() == rank)
- {
- for (y = 0; y < rank; y++)
- {
- CListValue* vecval = (CListValue*)listval->GetValue(y);
- if (vecval->GetCount() != rank)
- return false;
- }
- return true;
- }
- return false;
- } else if (PySequence_Check(pymat))
+ if (PySequence_Check(pymat))
{
unsigned int rows = PySequence_Size(pymat);
if (rows != rank)
@@ -337,58 +78,8 @@ bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
return false;
}
-MT_Matrix3x3 MT_Matrix3x3FromPyObject(PyObject *pymat)
-{
- MT_Matrix3x3 mat;
- bool error = false;
- mat.setIdentity();
- if (pymat->ob_type == &CListValue::Type)
- {
- unsigned int row, col;
- CListValue* listval = (CListValue*) pymat;
- if (listval->GetCount() == 3)
- {
- for (row=0;row<3;row++) // each row has a 3-vector [x,y,z]
- {
- CListValue* vecval = (CListValue*)listval->GetValue(row);
- for (col=0;col<3 && col < vecval->GetCount();col++)
- {
- mat[row][col] = vecval->GetValue(col)->GetNumber();
-
- }
- }
- }
- else
- {
- error = true;
- if (error)
- PyErr_SetString(PyExc_TypeError, "Expected list of three items for 3x3 matrix argument.");
- }
- } else if (PySequence_Check(pymat))
- {
- unsigned int rows = PySequence_Size(pymat);
- for (unsigned int y = 0; y < rows && y < 3; y++)
- {
- PyObject *pyrow = PySequence_GetItem(pymat, y); /* new ref */
- if (PySequence_Check(pyrow))
- {
- unsigned int cols = PySequence_Size(pyrow);
- for( unsigned int x = 0; x < cols && x < 3; x++)
- {
- PyObject *pyitem = PySequence_GetItem(pyrow, x); /* new ref */
- mat[y][x] = PyFloat_AsDouble(pyitem);
- Py_DECREF(pyitem);
- }
- }
- Py_DECREF(pyrow);
- }
- }
-
- return mat;
-}
-
-PyObject* PyObjectFromMT_Matrix4x4(const MT_Matrix4x4 &mat)
+PyObject* PyObjectFrom(const MT_Matrix4x4 &mat)
{
return Py_BuildValue("[[ffff][ffff][ffff][ffff]]",
mat[0][0], mat[0][1], mat[0][2], mat[0][3],
@@ -397,7 +88,7 @@ PyObject* PyObjectFromMT_Matrix4x4(const MT_Matrix4x4 &mat)
mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
}
-PyObject* PyObjectFromMT_Matrix3x3(const MT_Matrix3x3 &mat)
+PyObject* PyObjectFrom(const MT_Matrix3x3 &mat)
{
return Py_BuildValue("[[fff][fff][fff]]",
mat[0][0], mat[0][1], mat[0][2],
@@ -405,25 +96,20 @@ PyObject* PyObjectFromMT_Matrix3x3(const MT_Matrix3x3 &mat)
mat[2][0], mat[2][1], mat[2][2]);
}
-PyObject* PyObjectFromMT_Vector4(const MT_Vector4 &vec)
+PyObject* PyObjectFrom(const MT_Tuple4 &vec)
{
return Py_BuildValue("[ffff]",
vec[0], vec[1], vec[2], vec[3]);
}
-PyObject* PyObjectFromMT_Vector3(const MT_Vector3 &vec)
+PyObject* PyObjectFrom(const MT_Tuple3 &vec)
{
return Py_BuildValue("[fff]",
vec[0], vec[1], vec[2]);
}
-PyObject* PyObjectFromMT_Point3(const MT_Point3 &pos)
-{
- return Py_BuildValue("[fff]",
- pos[0], pos[1], pos[2]);
-}
-
-PyObject* PyObjectFromMT_Point2(const MT_Point2 &pos)
+PyObject* PyObjectFrom(const MT_Tuple2 &vec)
{
- return Py_BuildValue("[ff]", pos[0], pos[1]);
+ return Py_BuildValue("[ff]",
+ vec[0], vec[1]);
}
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h
index 72793a6cbae..322a9d32a7d 100644
--- a/source/gameengine/Ketsji/KX_PyMath.h
+++ b/source/gameengine/Ketsji/KX_PyMath.h
@@ -36,6 +36,7 @@
#include "MT_Point2.h"
#include "MT_Point3.h"
+#include "MT_Vector2.h"
#include "MT_Vector3.h"
#include "MT_Vector4.h"
#include "MT_Matrix3x3.h"
@@ -43,77 +44,107 @@
#include "KX_Python.h"
-/**
- * Converts a python list to an MT_Vector3
- */
-MT_Vector3 MT_Vector3FromPyList(PyObject* pylist);
-
-/**
- * Converts a python list to an MT_Point3
- */
-MT_Point3 MT_Point3FromPyList(PyObject* pylist);
-
-/**
- * Converts a python list to an MT_Vector4
- */
-MT_Vector4 MT_Vector4FromPyList(PyObject* pylist);
+static unsigned int Size(const MT_Matrix4x4&) { return 4; }
+static unsigned int Size(const MT_Matrix3x3&) { return 3; }
+static unsigned int Size(const MT_Tuple2&) { return 2; }
+static unsigned int Size(const MT_Tuple3&) { return 3; }
+static unsigned int Size(const MT_Tuple4&) { return 4; }
/**
- * Converts a python list to an MT_Vector2
+ * Converts the given python matrix to an MT class.
*/
-MT_Point2 MT_Point2FromPyList(PyObject* pylist);
+template<class T>
+bool PyMatTo(PyObject* pymat, T& mat)
+{
+ bool noerror = true;
+ mat.setIdentity();
+ if (PySequence_Check(pymat))
+ {
+ unsigned int rows = PySequence_Size(pymat);
+ for (unsigned int y = 0; y < rows && y < Size(mat); y++)
+ {
+ PyObject *pyrow = PySequence_GetItem(pymat, y); /* new ref */
+ if (PySequence_Check(pyrow))
+ {
+ unsigned int cols = PySequence_Size(pyrow);
+ for( unsigned int x = 0; x < cols && x < Size(mat); x++)
+ {
+ PyObject *item = PySequence_GetItem(pyrow, x); /* new ref */
+ mat[y][x] = PyFloat_AsDouble(item);
+ Py_DECREF(item);
+ }
+ } else
+ noerror = false;
+ Py_DECREF(pyrow);
+ }
+ } else
+ noerror = false;
+
+ return noerror;
+}
/**
- * Converts a python list to an MT_Quaternion
+ * Converts a python list to a MT class.
*/
-MT_Quaternion MT_QuaternionFromPyList(PyObject* pylist);
+template<class T>
+bool PyVecTo(PyObject* pyval, T& vec)
+{
+ if (PySequence_Check(pyval))
+ {
+ unsigned int numitems = PySequence_Size(pyval);
+ for (unsigned int x = 0; x < numitems && x < Size(vec); x++)
+ {
+ PyObject *item = PySequence_GetItem(pyval, x); /* new ref */
+ vec[x] = PyFloat_AsDouble(item);
+ Py_DECREF(item);
+ }
+
+ return true;
+ }
+
+ return false;
+}
/**
- * Converts a python list of lists to an MT_Matrix4x4.
- * Any object that supports the sequence protocol will work.
- * Only the first four rows and first four columns in each row will be converted.
- * @example The python object [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]
- */
-MT_Matrix4x4 MT_Matrix4x4FromPyObject(PyObject *pymat);
-/**
- * Converts a python list of lists to an MT_Matrix3x3
- * Any object that supports the sequence protocol will work.
- * Only the first three rows and first three columns in each row will be converted.
- * @example The python object [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
+ * Converts a python argument to an MT class.
+ * This paramater expects arguments as passed to a python method.
*/
-MT_Matrix3x3 MT_Matrix3x3FromPyObject(PyObject *pymat);
+template<class T>
+bool PyVecArgTo(PyObject* args, T& vec)
+{
+ PyObject* pylist;
+ if (PyArg_ParseTuple(args,"O",&pylist))
+ return PyVecTo(pylist, vec);
+
+ return false;
+}
/**
* Converts an MT_Matrix4x4 to a python object.
*/
-PyObject* PyObjectFromMT_Matrix4x4(const MT_Matrix4x4 &mat);
+PyObject* PyObjectFrom(const MT_Matrix4x4 &mat);
/**
* Converts an MT_Matrix3x3 to a python object.
*/
-PyObject* PyObjectFromMT_Matrix3x3(const MT_Matrix3x3 &mat);
+PyObject* PyObjectFrom(const MT_Matrix3x3 &mat);
/**
- * Converts an MT_Vector3 to a python object.
+ * Converts an MT_Tuple2 to a python object.
*/
-PyObject* PyObjectFromMT_Vector3(const MT_Vector3 &vec);
+PyObject* PyObjectFrom(const MT_Tuple2 &vec);
/**
- * Converts an MT_Vector4 to a python object
+ * Converts an MT_Tuple3 to a python object
*/
-PyObject* PyObjectFromMT_Vector4(const MT_Vector4 &vec);
+PyObject* PyObjectFrom(const MT_Tuple3 &vec);
/**
- * Converts an MT_Vector3 to a python object.
+ * Converts an MT_Tuple4 to a python object.
*/
-PyObject* PyObjectFromMT_Point3(const MT_Point3 &pos);
+PyObject* PyObjectFrom(const MT_Tuple4 &pos);
/**
- * Converts an MT_Point2 to a python object.
- */
-PyObject* PyObjectFromMT_Point2(const MT_Point2 &vec);
-
-/**
* True if the given PyObject can be converted to an MT_Matrix
* @param rank = 3 (for MT_Matrix3x3) or 4 (for MT_Matrix4x4)
*/
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 1b6d55f68e9..3d6995ab4e0 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -46,6 +46,8 @@
#include "SCA_RandomActuator.h"
#include "KX_ConstraintActuator.h"
#include "KX_IpoActuator.h"
+#include "KX_SoundActuator.h"
+#include "BL_ActionActuator.h"
#include "RAS_IRasterizer.h"
#include "RAS_ICanvas.h"
#include "MT_Vector3.h"
@@ -86,54 +88,36 @@ static RAS_IRasterizer* gp_Rasterizer = NULL;
static PyObject* ErrorObject;
STR_String gPyGetRandomFloat_doc="getRandomFloat returns a random floating point value in the range [0..1)";
-static PyObject* gPyGetRandomFloat(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+static PyObject* gPyGetRandomFloat(PyObject*,
+ PyObject*,
+ PyObject*)
{
return PyFloat_FromDouble(MT_random());
}
-
-
-
-
-void GlobalConvertPythonVectorArg(PyObject* args, MT_Vector3 &pos)
-{
- PyObject* pylist;
- PyArg_ParseTuple(args,"O",&pylist);
-
- pos = MT_Vector3FromPyList(pylist);
-}
-
-void GlobalConvertPythonVectorArg(PyObject* args, MT_Vector4 &vec)
-{
- PyObject* pylist;
- PyArg_ParseTuple(args,"O",&pylist);
-
- vec = MT_Vector4FromPyList(pylist);
-}
-
-
-static PyObject* gPySetGravity(PyObject* self,
+static PyObject* gPySetGravity(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
- GlobalConvertPythonVectorArg(args, vec);
-
- if (gp_KetsjiScene)
- gp_KetsjiScene->SetGravity(vec);
+ if (PyVecArgTo(args, vec))
+ {
+ if (gp_KetsjiScene)
+ gp_KetsjiScene->SetGravity(vec);
+
+ Py_Return;
+ }
- Py_Return;
+ return NULL;
}
static bool usedsp = false;
// this gets a pointer to an array filled with floats
-static PyObject* gPyGetSpectrum(PyObject* self,
+static PyObject* gPyGetSpectrum(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
@@ -160,9 +144,9 @@ static PyObject* gPyGetSpectrum(PyObject* self,
-static PyObject* gPyStartDSP(PyObject* self,
+static PyObject* gPyStartDSP(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
@@ -180,9 +164,9 @@ static PyObject* gPyStartDSP(PyObject* self,
-static PyObject* gPyStopDSP(PyObject* self,
+static PyObject* gPyStopDSP(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
@@ -229,9 +213,9 @@ static struct PyMethodDef game_methods[] = {
};
-static PyObject* gPyGetWindowHeight(PyObject* self,
+static PyObject* gPyGetWindowHeight(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
int height = (gp_Canvas ? gp_Canvas->GetHeight() : 0);
@@ -241,9 +225,9 @@ static PyObject* gPyGetWindowHeight(PyObject* self,
-static PyObject* gPyGetWindowWidth(PyObject* self,
+static PyObject* gPyGetWindowWidth(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
@@ -258,9 +242,9 @@ static PyObject* gPyGetWindowWidth(PyObject* self,
// temporarility visibility thing, will be moved to rasterizer/renderer later
bool gUseVisibilityTemp = false;
-static PyObject* gPyEnableVisibility(PyObject* self,
+static PyObject* gPyEnableVisibility(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
int visible;
if (PyArg_ParseTuple(args,"i",&visible))
@@ -276,9 +260,9 @@ static PyObject* gPyEnableVisibility(PyObject* self,
-static PyObject* gPyShowMouse(PyObject* self,
+static PyObject* gPyShowMouse(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
int visible;
if (PyArg_ParseTuple(args,"i",&visible))
@@ -299,9 +283,9 @@ static PyObject* gPyShowMouse(PyObject* self,
-static PyObject* gPySetMousePosition(PyObject* self,
+static PyObject* gPySetMousePosition(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
int x,y;
if (PyArg_ParseTuple(args,"ii",&x,&y))
@@ -315,43 +299,49 @@ static PyObject* gPySetMousePosition(PyObject* self,
-static PyObject* gPySetBackgroundColor(PyObject* self,
+static PyObject* gPySetBackgroundColor(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.);
- GlobalConvertPythonVectorArg(args, vec);
-
- if (gp_Canvas)
+ if (PyVecArgTo(args, vec))
{
- gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]);
+ if (gp_Canvas)
+ {
+ gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]);
+ }
+ Py_Return;
}
- Py_Return;
+
+ return NULL;
}
-static PyObject* gPySetMistColor(PyObject* self,
+static PyObject* gPySetMistColor(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
- GlobalConvertPythonVectorArg(args, vec);
-
- if (gp_Rasterizer)
+ if (PyVecArgTo(args, vec))
{
- gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]);
+ if (gp_Rasterizer)
+ {
+ gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]);
+ }
+ Py_Return;
}
- Py_Return;
+
+ return NULL;
}
-static PyObject* gPySetMistStart(PyObject* self,
+static PyObject* gPySetMistStart(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
float miststart;
@@ -367,9 +357,9 @@ static PyObject* gPySetMistStart(PyObject* self,
-static PyObject* gPySetMistEnd(PyObject* self,
+static PyObject* gPySetMistEnd(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
float mistend;
@@ -385,9 +375,9 @@ static PyObject* gPySetMistEnd(PyObject* self,
-static PyObject* gPyMakeScreenshot(PyObject* self,
+static PyObject* gPyMakeScreenshot(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
char* filename;
if (PyArg_ParseTuple(args,"s",&filename))
@@ -506,6 +496,21 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_NORMAL, SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL);
KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL, SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL);
+ /* 6. Sound actuator */
+ KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYSTOP, KX_SoundActuator::KX_SOUNDACT_PLAYSTOP);
+ KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYEND, KX_SoundActuator::KX_SOUNDACT_PLAYEND);
+ KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPSTOP, KX_SoundActuator::KX_SOUNDACT_LOOPSTOP);
+ KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPEND, KX_SoundActuator::KX_SOUNDACT_LOOPEND);
+ KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL);
+ KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP);
+
+ /* 7. Action actuator */
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PLAY, BL_ActionActuator::KX_ACT_ACTION_PLAY);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_FLIPPER, BL_ActionActuator::KX_ACT_ACTION_FLIPPER);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPSTOP, BL_ActionActuator::KX_ACT_ACTION_LOOPSTOP);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND, BL_ActionActuator::KX_ACT_ACTION_LOOPEND);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PROPERTY, BL_ActionActuator::KX_ACT_ACTION_PROPERTY);
+
// Check for errors
if (PyErr_Occurred())
{
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index 37d772b9674..cfa0ad4a986 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -192,16 +192,22 @@ PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self,
PyObject* args,
PyObject* kwds)
{
- char* objectname;
-
- if (!PyArg_ParseTuple(args, "s", &objectname))
- return NULL;
-
- CValue* gameobj = SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));
+ PyObject* gameobj;
+ if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
+ {
+ m_OriginalObject = (CValue*)gameobj;
+ Py_Return;
+ }
- m_OriginalObject= (CValue*)gameobj;
+ char* objectname;
+ if (PyArg_ParseTuple(args, "s", &objectname))
+ {
+ m_OriginalObject= (CValue*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));;
+
+ Py_Return;
+ }
- Py_Return;
+ return NULL;
}
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index c274f05558d..c44c9413538 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -772,7 +772,6 @@ void KX_Scene::AddCamera(KX_Camera* cam)
m_cameras.insert(cam);
}
-
KX_Camera* KX_Scene::GetActiveCamera()
{
// NULL if not defined
@@ -808,14 +807,15 @@ void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty)
{
int intersect = KX_Camera::INTERSECT;
KX_GameObject *gameobj = node->Client()?(KX_GameObject*) node->Client()->GetSGClientObject():NULL;
+ bool dotest = (gameobj && gameobj->GetVisible()) || node->Left() || node->Right();
/* If the camera is inside the box, assume intersect. */
- if (!node->inside(GetActiveCamera()->NodeGetWorldPosition()))
+ if (dotest && !node->inside(GetActiveCamera()->NodeGetWorldPosition()))
{
MT_Scalar radius = node->Radius();
MT_Point3 centre = node->Centre();
- intersect = GetActiveCamera()->SphereInsideFrustum(centre, radius);
+ intersect = GetActiveCamera()->SphereInsideFrustum(centre, radius);
if (intersect == KX_Camera::INTERSECT)
{
@@ -832,17 +832,7 @@ void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty)
break;
case KX_Camera::INTERSECT:
if (gameobj)
- {
- int nummeshes = gameobj->GetMeshCount();
- MT_Transform t(GetActiveCamera()->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform());
-
- for (int m=0;m<nummeshes;m++)
- {
- // this adds the vertices to the display list
- (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode(),rasty);
- }
- gameobj->MarkVisible();
- }
+ MarkVisible(rasty, gameobj);
if (node->Left())
MarkVisible(node->Left(), rasty);
if (node->Right())
@@ -859,19 +849,22 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi
if (node->Client())
{
KX_GameObject *gameobj = (KX_GameObject*) node->Client()->GetSGClientObject();
- if (visible)
+ if (gameobj->GetVisible())
{
- int nummeshes = gameobj->GetMeshCount();
- MT_Transform t( GetActiveCamera()->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform());
-
-
- for (int m=0;m<nummeshes;m++)
+ if (visible)
{
- // this adds the vertices to the display list
- (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode(),rasty);
+ int nummeshes = gameobj->GetMeshCount();
+ MT_Transform t( GetActiveCamera()->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform());
+
+
+ for (int m=0;m<nummeshes;m++)
+ {
+ // this adds the vertices to the display list
+ (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode(),rasty);
+ }
}
+ gameobj->MarkVisible(visible);
}
- gameobj->MarkVisible(visible && gameobj->GetVisible());
}
if (node->Left())
MarkSubTreeVisible(node->Left(), rasty, visible);
@@ -879,62 +872,68 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi
MarkSubTreeVisible(node->Right(), rasty, visible);
}
-
-void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty)
+void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj)
{
-// FIXME: When tree is operational
-#if 1
- // do this incrementally in the future
- for (int i = 0; i < m_objectlist->GetCount(); i++)
+ // User (Python/Actuator) has forced object invisible...
+ if (!gameobj->GetVisible())
+ return;
+ // If Frustum culling is off, the object is always visible.
+ bool vis = !GetActiveCamera()->GetFrustumCulling();
+
+ // If the camera is inside this node, then the object is visible.
+ if (!vis)
{
- KX_GameObject* gameobj = (KX_GameObject*)m_objectlist->GetValue(i);
- // If Frustum culling is off, the object is always visible.
- bool vis = !GetActiveCamera()->GetFrustumCulling();
+ vis = gameobj->GetSGNode()->inside( GetActiveCamera()->GetCameraLocation() );
+ }
- // If the camera is inside this node, then the object is visible.
- if (!vis)
- {
- vis = gameobj->GetSGNode()->inside( GetActiveCamera()->GetCameraLocation() );
- }
-
- // Test the object's bound sphere against the view frustum.
- if (!vis)
+ // Test the object's bound sphere against the view frustum.
+ if (!vis)
+ {
+ MT_Vector3 scale = gameobj->GetSGNode()->GetWorldScaling();
+ MT_Scalar radius = fabs(scale[scale.closestAxis()] * gameobj->GetSGNode()->Radius());
+ switch (GetActiveCamera()->SphereInsideFrustum(gameobj->NodeGetWorldPosition(), radius))
{
- MT_Vector3 scale = gameobj->GetSGNode()->GetWorldScaling();
- MT_Scalar radius = fabs(scale[scale.closestAxis()] * gameobj->GetSGNode()->Radius());
- switch (GetActiveCamera()->SphereInsideFrustum(gameobj->NodeGetWorldPosition(), radius))
- {
- case KX_Camera::INSIDE:
- vis = true;
- break;
- case KX_Camera::OUTSIDE:
- vis = false;
- break;
- case KX_Camera::INTERSECT:
- // Test the object's bound box against the view frustum.
- MT_Point3 box[8];
- gameobj->GetSGNode()->getBBox(box);
- vis = GetActiveCamera()->BoxInsideFrustum(box) != KX_Camera::OUTSIDE;
- break;
- }
+ case KX_Camera::INSIDE:
+ vis = true;
+ break;
+ case KX_Camera::OUTSIDE:
+ vis = false;
+ break;
+ case KX_Camera::INTERSECT:
+ // Test the object's bound box against the view frustum.
+ MT_Point3 box[8];
+ gameobj->GetSGNode()->getBBox(box);
+ vis = GetActiveCamera()->BoxInsideFrustum(box) != KX_Camera::OUTSIDE;
+ break;
}
+ }
+
+ if (vis)
+ {
+ int nummeshes = gameobj->GetMeshCount();
+ MT_Transform t(GetActiveCamera()->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform());
- if (vis)
+ for (int m=0;m<nummeshes;m++)
{
- int nummeshes = gameobj->GetMeshCount();
- MT_Transform t(GetActiveCamera()->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform());
-
- for (int m=0;m<nummeshes;m++)
- {
- // this adds the vertices to the display list
- (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode(),rasty);
- }
- // Visibility/ non-visibility are marked
- // elsewhere now.
- gameobj->MarkVisible();
- } else {
- gameobj->MarkVisible(false);
+ // this adds the vertices to the display list
+ (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode(),rasty);
}
+ // Visibility/ non-visibility are marked
+ // elsewhere now.
+ gameobj->MarkVisible();
+ } else {
+ gameobj->MarkVisible(false);
+ }
+}
+
+void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty)
+{
+// FIXME: When tree is operational
+#if 1
+ // do this incrementally in the future
+ for (int i = 0; i < m_objectlist->GetCount(); i++)
+ {
+ MarkVisible(rasty, static_cast<KX_GameObject*>(m_objectlist->GetValue(i)));
}
#else
if (GetActiveCamera()->GetFrustumCulling())
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index 1df126ce1b0..9e6909168cb 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -245,8 +245,12 @@ protected:
*/
RAS_Rect m_viewport;
+ /**
+ * Visibility testing functions.
+ */
void MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty);
void MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible);
+ void MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj);
/**
* This stores anything from python
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp
index 721d01a3da3..9ccb4068cc0 100644
--- a/source/gameengine/Ketsji/KX_SceneActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp
@@ -314,16 +314,21 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self,
PyObject* args,
PyObject* kwds)
{
+ PyObject *cam;
+ if (PyArg_ParseTuple(args, "O!", &KX_Camera::Type, &cam))
+ {
+ m_camera = (KX_Camera*) cam;
+ Py_Return;
+ }
+
/* one argument: a scene, ignore the rest */
char *camName;
- KX_Camera *camOb;
-
if(!PyArg_ParseTuple(args, "s", &camName))
{
return NULL;
}
- camOb = FindCamera(camName);
+ KX_Camera *camOb = FindCamera(camName);
if (camOb) m_camera = camOb;
Py_Return;
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index 6f959f0273b..e71902519f3 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -256,7 +256,9 @@ PyMethodDef KX_SoundActuator::Methods[] = {
{"getLooping",(PyCFunction) KX_SoundActuator::sPyGetLooping,METH_VARARGS,NULL},
{"setPosition",(PyCFunction) KX_SoundActuator::sPySetPosition,METH_VARARGS,NULL},
{"setVelocity",(PyCFunction) KX_SoundActuator::sPySetVelocity,METH_VARARGS,NULL},
- {"setOrientation",(PyCFunction) KX_SoundActuator::sPySetOrientation,METH_VARARGS,NULL},
+ {"setOrientation",(PyCFunction) KX_SoundActuator::sPySetOrientation,METH_VARARGS,NULL},
+ {"setType",(PyCFunction) KX_SoundActuator::sPySetType,METH_VARARGS,NULL},
+ {"getType",(PyCFunction) KX_SoundActuator::sPyGetType,METH_VARARGS,NULL},
{NULL,NULL,NULL,NULL} //Sentinel
};
@@ -464,7 +466,28 @@ PyObject* KX_SoundActuator::PySetOrientation(PyObject* self, PyObject* args, PyO
m_soundObject->SetOrientation(ori);
Py_Return;
-}
+}
+
+PyObject* KX_SoundActuator::PySetType(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ int typeArg;
+
+ if (!PyArg_ParseTuple(args, "i", &typeArg)) {
+ return NULL;
+ }
+
+ if ( (typeArg > KX_SOUNDACT_NODEF)
+ && (typeArg < KX_SOUNDACT_MAX) ) {
+ m_type = (KX_SOUNDACT_TYPE) typeArg;
+ }
+
+ Py_Return;
+}
+
+PyObject* KX_SoundActuator::PyGetType(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ return PyInt_FromLong(m_type);
+}
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h
index 7cdf6013180..dcb46f1b5d0 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.h
+++ b/source/gameengine/Ketsji/KX_SoundActuator.h
@@ -101,6 +101,8 @@ public:
KX_PYMETHOD(KX_SoundActuator,SetPosition);
KX_PYMETHOD(KX_SoundActuator,SetVelocity);
KX_PYMETHOD(KX_SoundActuator,SetOrientation);
+ KX_PYMETHOD(KX_SoundActuator,SetType);
+ KX_PYMETHOD(KX_SoundActuator,GetType);
};
#endif //__KX_SOUNDACTUATOR
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index c02cdbc17be..becc4c58758 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -399,16 +399,23 @@ char KX_TrackToActuator::SetObject_doc[] =
"\t- object: string\n"
"\tSet the object to track with the parent of this actuator.\n";
PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* args, PyObject* kwds) {
- char* nameArg;
-
- if (!PyArg_ParseTuple(args, "s", &nameArg)) {
- return NULL;
+ PyObject* gameobj;
+ if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
+ {
+ m_object = (SCA_IObject*)gameobj;
+
+ Py_Return;
}
- CValue* gameobj = SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(nameArg));
- m_object= (SCA_IObject*)gameobj;
+ char* objectname;
+ if (PyArg_ParseTuple(args, "s", &objectname))
+ {
+ m_object= static_cast<SCA_IObject*>(SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)));
+
+ Py_Return;
+ }
- Py_Return;
+ return NULL;
}
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp
index ae8a5555843..3afea847405 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.cpp
+++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp
@@ -29,13 +29,14 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-#include "KX_VertexProxy.h"
-#include "RAS_TexVert.h"
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include "KX_VertexProxy.h"
+#include "KX_MeshProxy.h"
+#include "RAS_TexVert.h"
+
#include "KX_PyMath.h"
PyTypeObject KX_VertexProxy::Type = {
@@ -80,23 +81,22 @@ PyObject*
KX_VertexProxy::_getattr(const STR_String& attr)
{
if (attr == "XYZ")
- return PyObjectFromMT_Vector3(m_vertex->getLocalXYZ());
+ return PyObjectFrom(MT_Vector3(m_vertex->getLocalXYZ()));
if (attr == "UV")
- return PyObjectFromMT_Point2(MT_Point2(m_vertex->getUV1()));
+ return PyObjectFrom(MT_Point2(m_vertex->getUV1()));
if (attr == "colour" || attr == "color")
{
- unsigned int icol = m_vertex->getRGBA();
- unsigned char *colp = (unsigned char *) &icol;
+ const unsigned char *colp = m_vertex->getRGBA();
MT_Vector4 colour(colp[0], colp[1], colp[2], colp[3]);
colour /= 255.0;
- return PyObjectFromMT_Vector4(colour);
+ return PyObjectFrom(colour);
}
if (attr == "normal")
{
- return PyObjectFromMT_Vector3(m_vertex->getNormal());
+ return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
}
// pos
@@ -109,13 +109,13 @@ KX_VertexProxy::_getattr(const STR_String& attr)
// Col
if (attr == "r")
- return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[0]/255.0);
+ return PyFloat_FromDouble(m_vertex->getRGBA()[0]/255.0);
if (attr == "g")
- return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[1]/255.0);
+ return PyFloat_FromDouble(m_vertex->getRGBA()[1]/255.0);
if (attr == "b")
- return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[2]/255.0);
+ return PyFloat_FromDouble(m_vertex->getRGBA()[2]/255.0);
if (attr == "a")
- return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[3]/255.0);
+ return PyFloat_FromDouble(m_vertex->getRGBA()[3]/255.0);
// UV
if (attr == "u")
@@ -132,26 +132,46 @@ int KX_VertexProxy::_setattr(const STR_String& attr, PyObject *pyvalue)
{
if (attr == "XYZ")
{
- m_vertex->SetXYZ(MT_Point3FromPyList(pyvalue));
- return 0;
+ MT_Point3 vec;
+ if (PyVecTo(pyvalue, vec))
+ {
+ m_vertex->SetXYZ(vec);
+ return 0;
+ }
+ return 1;
}
if (attr == "UV")
{
- m_vertex->SetUV(MT_Point2FromPyList(pyvalue));
- return 0;
+ MT_Point2 vec;
+ if (PyVecTo(pyvalue, vec))
+ {
+ m_vertex->SetUV(vec);
+ return 0;
+ }
+ return 1;
}
if (attr == "colour" || attr == "color")
{
- m_vertex->SetRGBA(MT_Vector4FromPyList(pyvalue));
- return 0;
+ MT_Vector4 vec;
+ if (PyVecTo(pyvalue, vec))
+ {
+ m_vertex->SetRGBA(vec);
+ return 0;
+ }
+ return 1;
}
if (attr == "normal")
{
- m_vertex->SetNormal(MT_Vector3FromPyList(pyvalue));
- return 0;
+ MT_Vector3 vec;
+ if (PyVecTo(pyvalue, vec))
+ {
+ m_vertex->SetNormal(vec);
+ return 0;
+ }
+ return 1;
}
}
@@ -198,7 +218,7 @@ int KX_VertexProxy::_setattr(const STR_String& attr, PyObject *pyvalue)
}
// col
- unsigned int icol = m_vertex->getRGBA();
+ unsigned int icol = *((const unsigned int *)m_vertex->getRGBA());
unsigned char *cp = (unsigned char*) &icol;
val *= 255.0;
if (attr == "r")
@@ -233,132 +253,122 @@ int KX_VertexProxy::_setattr(const STR_String& attr, PyObject *pyvalue)
KX_VertexProxy::KX_VertexProxy(RAS_TexVert* vertex)
:m_vertex(vertex)
{
-
}
KX_VertexProxy::~KX_VertexProxy()
{
-
}
// stuff for cvalue related things
-CValue* KX_VertexProxy::Calc(VALUE_OPERATOR op, CValue *val) { return NULL;}
-CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val) { return NULL;}
+CValue* KX_VertexProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
+CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
STR_String sVertexName="vertex";
const STR_String & KX_VertexProxy::GetText() {return sVertexName;};
float KX_VertexProxy::GetNumber() { return -1;}
STR_String KX_VertexProxy::GetName() { return sVertexName;}
-void KX_VertexProxy::SetName(STR_String name) { };
+void KX_VertexProxy::SetName(STR_String) { };
CValue* KX_VertexProxy::GetReplica() { return NULL;}
-void KX_VertexProxy::ReplicaSetName(STR_String name) {};
+void KX_VertexProxy::ReplicaSetName(STR_String) {};
// stuff for python integration
-PyObject* KX_VertexProxy::PyGetXYZ(PyObject* self,
+PyObject* KX_VertexProxy::PyGetXYZ(PyObject*,
+ PyObject*,
+ PyObject*)
+{
+ return PyObjectFrom(MT_Point3(m_vertex->getLocalXYZ()));
+}
+
+PyObject* KX_VertexProxy::PySetXYZ(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
-
- MT_Point3 pos = m_vertex->getLocalXYZ();
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
+ MT_Point3 vec;
+ if (PyVecArgTo(args, vec))
{
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(pos[index]));
+ m_vertex->SetXYZ(vec);
+
+ Py_Return;
}
-
- return resultlist;
-
+
+ return NULL;
}
-PyObject* KX_VertexProxy::PySetXYZ(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_VertexProxy::PyGetNormal(PyObject*,
+ PyObject*,
+ PyObject*)
{
-
- MT_Point3 pos = ConvertPythonVectorArg(args);
- m_vertex->SetXYZ(pos);
-
-
- Py_Return;
+ return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
}
-PyObject* KX_VertexProxy::PyGetNormal(PyObject* self,
+PyObject* KX_VertexProxy::PySetNormal(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
-
- MT_Vector3 normal(m_vertex->getNormal());
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
+ MT_Vector3 vec;
+ if (PyVecArgTo(args, vec))
{
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(normal[index]));
+ m_vertex->SetNormal(vec);
+
+ Py_Return;
}
-
- return resultlist;
-
-}
-
-PyObject* KX_VertexProxy::PySetNormal(PyObject* self,
- PyObject* args,
- PyObject* kwds)
-{
- MT_Point3 normal = ConvertPythonVectorArg(args);
- m_vertex->SetNormal(normal);
- Py_Return;
+
+ return NULL;
}
-PyObject* KX_VertexProxy::PyGetRGBA(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_VertexProxy::PyGetRGBA(PyObject*,
+ PyObject*,
+ PyObject*)
{
- int rgba = m_vertex->getRGBA();
- return PyInt_FromLong(rgba);
+ int *rgba = (int *) m_vertex->getRGBA();
+ return PyInt_FromLong(*rgba);
}
-PyObject* KX_VertexProxy::PySetRGBA(PyObject* self,
+PyObject* KX_VertexProxy::PySetRGBA(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
+ float r, g, b, a;
+ if (PyArg_ParseTuple(args, "(ffff)", &r, &g, &b, &a))
+ {
+ m_vertex->SetRGBA(MT_Vector4(r, g, b, a));
+ Py_Return;
+ }
+
int rgba;
if (PyArg_ParseTuple(args,"i",&rgba))
{
m_vertex->SetRGBA(rgba);
+ Py_Return;
}
Py_Return;
}
-PyObject* KX_VertexProxy::PyGetUV(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_VertexProxy::PyGetUV(PyObject*,
+ PyObject*,
+ PyObject*)
{
- MT_Vector2 uv = m_vertex->getUV1();
- PyObject* resultlist = PyList_New(2);
- int index;
- for (index=0;index<2;index++)
- {
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(uv[index]));
- }
-
- return resultlist;
-
+ return PyObjectFrom(MT_Vector2(m_vertex->getUV1()));
}
-PyObject* KX_VertexProxy::PySetUV(PyObject* self,
+PyObject* KX_VertexProxy::PySetUV(PyObject*,
PyObject* args,
- PyObject* kwds)
+ PyObject*)
{
- MT_Point3 uv = ConvertPythonVectorArg(args);
- m_vertex->SetUV(MT_Point2(uv[0],uv[1]));
- Py_Return;
+ MT_Point2 vec;
+ if (PyVecArgTo(args, vec))
+ {
+ m_vertex->SetUV(vec);
+
+ Py_Return;
+ }
+
+ return NULL;
}
diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile
index d5dee041e3e..18a931eed65 100644
--- a/source/gameengine/Ketsji/Makefile
+++ b/source/gameengine/Ketsji/Makefile
@@ -53,6 +53,12 @@ CPPFLAGS += -I../Physics/Dummy
CPPFLAGS += -I../Physics/Sumo
CPPFLAGS += -I../Physics/BlOde
CPPFLAGS += -I.
+CPPFLAGS += -I../Converter
+CPPFLAGS += -I../../blender/blenkernel
+CPPFLAGS += -I../../blender/include
+CPPFLAGS += -I../../blender/makesdna
+CPPFLAGS += -I../../blender/imbuf
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
###########################