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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-02-25 09:43:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-02-25 09:43:03 +0300
commitc77af311665d230ed933138cd20962d021ad5c2b (patch)
tree5c2f89032fb773a046aab0a7a6c9a17162260b99 /source
parent2eb85c01f3e0ea2ba9dd129ae70e8b370953d7b5 (diff)
Minor speedups for the BGE
* Where possible use vec.setValue(x,y,z) to assign values to a vector instead of vec= MT_Vector3(x,y,z), for MT_Point and MT_Matrix types too. * Comparing TexVerts was creating 10 MT_Vector types - instead compare as floats. * Added SG_Spatial::SetWorldFromLocalTransform() since the local transform is use for world transform in some cases. * removed some unneeded vars from UpdateChildCoordinates functions * Py API - Mouse, Ray, Radar sensors - use PyObjectFrom(vec) rather then filling the lists in each function. Use METH_NOARGS for get*() functions.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Mathutils.c10
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp69
-rw-r--r--source/gameengine/Converter/BL_MeshDeformer.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp28
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp89
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.h12
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp35
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.h6
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp64
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.h8
-rw-r--r--source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp19
-rw-r--r--source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp80
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp6
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.cpp26
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.h1
-rw-r--r--source/gameengine/SceneGraph/SG_BBox.cpp4
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.cpp19
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.h2
18 files changed, 164 insertions, 318 deletions
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c
index f0b51285376..b370aa0e1e8 100644
--- a/source/blender/python/api2_2x/Mathutils.c
+++ b/source/blender/python/api2_2x/Mathutils.c
@@ -350,7 +350,7 @@ PyObject *quat_rotation(PyObject *arg1, PyObject *arg2)
PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args)
{
float high, low, range;
- double rand;
+ double drand;
//initializers
high = 1.0;
low = 0.0;
@@ -364,14 +364,14 @@ PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args)
"Mathutils.Rand(): high value should be larger than low value\n"));
//get the random number 0 - 1
- rand = BLI_drand();
+ drand = BLI_drand();
//set it to range
range = high - low;
- rand = rand * range;
- rand = rand + low;
+ drand = drand * range;
+ drand = drand + low;
- return PyFloat_FromDouble(rand);
+ return PyFloat_FromDouble(drand);
}
//----------------------------------VECTOR FUNCTIONS---------------------
//----------------------------------Mathutils.Vector() ------------------
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 3293d37af3a..3a0302562e6 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -593,7 +593,7 @@ BL_Material* ConvertMaterial(
MT_Point2 uv2[4];
const char *uvName = "", *uv2Name = "";
- uv[0]= uv[1]= uv[2]= uv[3]= MT_Point2(0.0f, 0.0f);
+
uv2[0]= uv2[1]= uv2[2]= uv2[3]= MT_Point2(0.0f, 0.0f);
if( validface ) {
@@ -607,12 +607,12 @@ BL_Material* ConvertMaterial(
material->tile = tface->tile;
material->mode = tface->mode;
- uv[0] = MT_Point2(tface->uv[0]);
- uv[1] = MT_Point2(tface->uv[1]);
- uv[2] = MT_Point2(tface->uv[2]);
+ uv[0].setValue(tface->uv[0]);
+ uv[1].setValue(tface->uv[1]);
+ uv[2].setValue(tface->uv[2]);
if (mface->v4)
- uv[3] = MT_Point2(tface->uv[3]);
+ uv[3].setValue(tface->uv[3]);
uvName = tfaceName;
}
@@ -622,6 +622,8 @@ BL_Material* ConvertMaterial(
material->mode = default_face_mode;
material->transp = TF_SOLID;
material->tile = 0;
+
+ uv[0]= uv[1]= uv[2]= uv[3]= MT_Point2(0.0f, 0.0f);
}
// with ztransp enabled, enforce alpha blending mode
@@ -665,14 +667,14 @@ BL_Material* ConvertMaterial(
{
MT_Point2 uvSet[4];
- uvSet[0] = MT_Point2(layer.face->uv[0]);
- uvSet[1] = MT_Point2(layer.face->uv[1]);
- uvSet[2] = MT_Point2(layer.face->uv[2]);
+ uvSet[0].setValue(layer.face->uv[0]);
+ uvSet[1].setValue(layer.face->uv[1]);
+ uvSet[2].setValue(layer.face->uv[2]);
if (mface->v4)
- uvSet[3] = MT_Point2(layer.face->uv[3]);
+ uvSet[3].setValue(layer.face->uv[3]);
else
- uvSet[3] = MT_Point2(0.0f, 0.0f);
+ uvSet[3].setValue(0.0f, 0.0f);
if (isFirstSet)
{
@@ -790,10 +792,10 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
MT_Vector4 tan0(0,0,0,0), tan1(0,0,0,0), tan2(0,0,0,0), tan3(0,0,0,0);
/* get coordinates, normals and tangents */
- pt0 = MT_Point3(mvert[mface->v1].co);
- pt1 = MT_Point3(mvert[mface->v2].co);
- pt2 = MT_Point3(mvert[mface->v3].co);
- pt3 = (mface->v4)? MT_Point3(mvert[mface->v4].co): MT_Point3(0.0, 0.0, 0.0);
+ pt0.setValue(mvert[mface->v1].co);
+ pt1.setValue(mvert[mface->v2].co);
+ pt2.setValue(mvert[mface->v3].co);
+ if (mface->v4) pt3.setValue(mvert[mface->v4].co);
if(mface->flag & ME_SMOOTH) {
float n0[3], n1[3], n2[3], n3[3];
@@ -894,12 +896,12 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
visible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE));
- uv0 = MT_Point2(tface->uv[0]);
- uv1 = MT_Point2(tface->uv[1]);
- uv2 = MT_Point2(tface->uv[2]);
+ uv0.setValue(tface->uv[0]);
+ uv1.setValue(tface->uv[1]);
+ uv2.setValue(tface->uv[2]);
if (mface->v4)
- uv3 = MT_Point2(tface->uv[3]);
+ uv3.setValue(tface->uv[3]);
}
else {
/* no texfaces, set COLLSION true and everything else FALSE */
@@ -960,7 +962,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
polymat->m_diffuse = MT_Vector3(ma->r, ma->g, ma->b)*(ma->emit + ma->ref);
}
else {
- polymat->m_specular = MT_Vector3(0.0f,0.0f,0.0f);
+ polymat->m_specular.setValue(0.0f,0.0f,0.0f);
polymat->m_shininess = 35.0;
}
}
@@ -1911,21 +1913,14 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
MT_Matrix3x3 angor;
if (converter->addInitFromFrame) blenderscene->r.cfra=blenderscene->r.sfra;
- MT_Point3 pos = MT_Point3(
+ MT_Point3 pos;
+ pos.setValue(
blenderobject->loc[0]+blenderobject->dloc[0],
blenderobject->loc[1]+blenderobject->dloc[1],
blenderobject->loc[2]+blenderobject->dloc[2]
);
- MT_Vector3 eulxyz = MT_Vector3(
- blenderobject->rot[0],
- blenderobject->rot[1],
- blenderobject->rot[2]
- );
- MT_Vector3 scale = MT_Vector3(
- blenderobject->size[0],
- blenderobject->size[1],
- blenderobject->size[2]
- );
+ MT_Vector3 eulxyz(blenderobject->rot);
+ MT_Vector3 scale(blenderobject->size);
if (converter->addInitFromFrame){//rcruiz
float eulxyzPrev[3];
blenderscene->r.cfra=blenderscene->r.sfra-1;
@@ -2113,21 +2108,13 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
if (converter->addInitFromFrame)
blenderscene->r.cfra=blenderscene->r.sfra;
- MT_Point3 pos = MT_Point3(
+ MT_Point3 pos(
blenderobject->loc[0]+blenderobject->dloc[0],
blenderobject->loc[1]+blenderobject->dloc[1],
blenderobject->loc[2]+blenderobject->dloc[2]
);
- MT_Vector3 eulxyz = MT_Vector3(
- blenderobject->rot[0],
- blenderobject->rot[1],
- blenderobject->rot[2]
- );
- MT_Vector3 scale = MT_Vector3(
- blenderobject->size[0],
- blenderobject->size[1],
- blenderobject->size[2]
- );
+ MT_Vector3 eulxyz(blenderobject->rot);
+ MT_Vector3 scale(blenderobject->size);
if (converter->addInitFromFrame){//rcruiz
float eulxyzPrev[3];
blenderscene->r.cfra=blenderscene->r.sfra-1;
diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp
index fa3b8185fe2..80112346c72 100644
--- a/source/gameengine/Converter/BL_MeshDeformer.cpp
+++ b/source/gameengine/Converter/BL_MeshDeformer.cpp
@@ -51,7 +51,6 @@
bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*)
{
size_t i;
- float *co;
// only apply once per frame if the mesh is actually modified
if(m_pMeshObject->MeshModified() &&
@@ -70,8 +69,7 @@ bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*)
// For each vertex
for(i=it.startvertex; i<it.endvertex; i++) {
RAS_TexVert& v = it.vertex[i];
- co = m_bmesh->mvert[v.getOrigIndex()].co;
- v.SetXYZ(MT_Point3(co));
+ v.SetXYZ(m_bmesh->mvert[v.getOrigIndex()].co);
}
}
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 60512991cf4..5e013a1c647 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -690,9 +690,9 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
switch (axis)
{
case 0: //x axis
- ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis
+ ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis
if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector paralell to the pivot?
- ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot!
+ ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot!
if (fac == 1.0) {
x = vect;
} else {
@@ -705,9 +705,9 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
z = x.cross(y);
break;
case 1: //y axis
- ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
+ ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]);
if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
- ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]);
+ ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]);
if (fac == 1.0) {
y = vect;
} else {
@@ -720,9 +720,9 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
x = y.cross(z);
break;
case 2: //z axis
- ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]);
+ ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]);
if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
- ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
+ ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]);
if (fac == 1.0) {
z = vect;
} else {
@@ -741,9 +741,9 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
x.normalize(); //normalize the vectors
y.normalize();
z.normalize();
- orimat = MT_Matrix3x3( x[0],y[0],z[0],
- x[1],y[1],z[1],
- x[2],y[2],z[2]);
+ orimat.setValue( x[0],y[0],z[0],
+ x[1],y[1],z[1],
+ x[2],y[2],z[2]);
if (GetSGNode()->GetSGParent() != NULL)
{
// the object is a child, adapt its local orientation so that
@@ -945,13 +945,11 @@ const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
{
- static MT_Point3 defaultPosition = MT_Point3(0.0, 0.0, 0.0);
-
// check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return defaultPosition;
-
- return GetSGNode()->GetWorldPosition();
+ if (GetSGNode())
+ return GetSGNode()->GetWorldPosition();
+ else
+ return MT_Point3(0.0, 0.0, 0.0);
}
/* Suspend/ resume: for the dynamic behaviour, there is a simple
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index bd15d3cffbe..afe4cd1e2a4 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -42,6 +42,7 @@
#include "KX_Scene.h"
#include "KX_Camera.h"
#include "KX_MouseFocusSensor.h"
+#include "KX_PyMath.h"
#include "KX_RayCast.h"
#include "KX_IPhysicsController.h"
@@ -320,12 +321,12 @@ PyParentObject KX_MouseFocusSensor::Parents[] = {
};
PyMethodDef KX_MouseFocusSensor::Methods[] = {
- {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, METH_VARARGS, (PY_METHODCHAR)GetRayTarget_doc},
- {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, METH_VARARGS, (PY_METHODCHAR)GetRaySource_doc},
- {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc},
- {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_VARARGS, (PY_METHODCHAR)GetHitPosition_doc},
- {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_VARARGS, (PY_METHODCHAR)GetHitNormal_doc},
- {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_VARARGS, (PY_METHODCHAR)GetRayDirection_doc},
+ {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, METH_NOARGS, (PY_METHODCHAR)GetRayTarget_doc},
+ {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, METH_NOARGS, (PY_METHODCHAR)GetRaySource_doc},
+ {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_NOARGS, (PY_METHODCHAR)GetHitObject_doc},
+ {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_NOARGS, (PY_METHODCHAR)GetHitPosition_doc},
+ {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_NOARGS, (PY_METHODCHAR)GetHitNormal_doc},
+ {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_NOARGS, (PY_METHODCHAR)GetRayDirection_doc},
{NULL,NULL} //Sentinel
@@ -339,14 +340,11 @@ PyObject* KX_MouseFocusSensor::_getattr(const char *attr) {
const char KX_MouseFocusSensor::GetHitObject_doc[] =
"getHitObject()\n"
"\tReturns the name of the object that was hit by this ray.\n";
-PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self)
{
if (m_hitObject)
- {
return m_hitObject->AddRef();
- }
+
Py_RETURN_NONE;
}
@@ -354,61 +352,28 @@ PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self,
const char KX_MouseFocusSensor::GetHitPosition_doc[] =
"getHitPosition()\n"
"\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n";
-PyObject* KX_MouseFocusSensor::PyGetHitPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_MouseFocusSensor::PyGetHitPosition(PyObject* self)
{
-
- MT_Point3 pos = m_hitPosition;
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
- {
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(pos[index]));
- }
- return resultlist;
-
+ return PyObjectFrom(m_hitPosition);
}
const char KX_MouseFocusSensor::GetRayDirection_doc[] =
"getRayDirection()\n"
"\tReturns the direction from the ray (in worldcoordinates) .\n";
-PyObject* KX_MouseFocusSensor::PyGetRayDirection(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_MouseFocusSensor::PyGetRayDirection(PyObject* self)
{
MT_Vector3 dir = m_prevTargetPoint - m_prevSourcePoint;
dir.normalize();
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
- {
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(dir[index]));
- }
- return resultlist;
-
+ return PyObjectFrom(dir);
}
const char KX_MouseFocusSensor::GetHitNormal_doc[] =
"getHitNormal()\n"
"\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n";
-PyObject* KX_MouseFocusSensor::PyGetHitNormal(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_MouseFocusSensor::PyGetHitNormal(PyObject* self)
{
- MT_Vector3 pos = m_hitNormal;
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
- {
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(pos[index]));
- }
- return resultlist;
-
+ return PyObjectFrom(m_hitNormal);
}
@@ -417,16 +382,8 @@ const char KX_MouseFocusSensor::GetRayTarget_doc[] =
"getRayTarget()\n"
"\tReturns the target of the ray that seeks the focus object,\n"
"\tin worldcoordinates.";
-PyObject* KX_MouseFocusSensor::PyGetRayTarget(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- PyObject *retVal = PyList_New(3);
-
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_prevTargetPoint[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_prevTargetPoint[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_prevTargetPoint[2]));
-
- return retVal;
+PyObject* KX_MouseFocusSensor::PyGetRayTarget(PyObject* self) {
+ return PyObjectFrom(m_prevTargetPoint);
}
/* getRayTarget */
@@ -434,16 +391,8 @@ const char KX_MouseFocusSensor::GetRaySource_doc[] =
"getRaySource()\n"
"\tReturns the source of the ray that seeks the focus object,\n"
"\tin worldcoordinates.";
-PyObject* KX_MouseFocusSensor::PyGetRaySource(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- PyObject *retVal = PyList_New(3);
-
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_prevSourcePoint[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_prevSourcePoint[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_prevSourcePoint[2]));
-
- return retVal;
+PyObject* KX_MouseFocusSensor::PyGetRaySource(PyObject* self) {
+ return PyObjectFrom(m_prevSourcePoint);
}
/* eof */
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
index 704198ce5a3..4979783032c 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
@@ -89,13 +89,13 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const char *attr);
- KX_PYMETHOD_DOC(KX_MouseFocusSensor,GetRayTarget);
- KX_PYMETHOD_DOC(KX_MouseFocusSensor,GetRaySource);
+ KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayTarget);
+ KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRaySource);
- KX_PYMETHOD_DOC(KX_MouseFocusSensor,GetHitObject);
- KX_PYMETHOD_DOC(KX_MouseFocusSensor,GetHitPosition);
- KX_PYMETHOD_DOC(KX_MouseFocusSensor,GetHitNormal);
- KX_PYMETHOD_DOC(KX_MouseFocusSensor,GetRayDirection);
+ KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetHitObject);
+ KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetHitPosition);
+ KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetHitNormal);
+ KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayDirection);
/* --------------------------------------------------------------------- */
SCA_IObject* m_hitObject;
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 1321b862463..2ba1126a633 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -28,6 +28,7 @@
#include "KX_RadarSensor.h"
#include "KX_GameObject.h"
+#include "KX_PyMath.h"
#include "PHY_IPhysicsController.h"
#ifdef HAVE_CONFIG_H
@@ -221,11 +222,11 @@ PyParentObject KX_RadarSensor::Parents[] = {
PyMethodDef KX_RadarSensor::Methods[] = {
{"getConeOrigin", (PyCFunction) KX_RadarSensor::sPyGetConeOrigin,
- METH_VARARGS, (PY_METHODCHAR)GetConeOrigin_doc},
+ METH_NOARGS, (PY_METHODCHAR)GetConeOrigin_doc},
{"getConeTarget", (PyCFunction) KX_RadarSensor::sPyGetConeTarget,
- METH_VARARGS, (PY_METHODCHAR)GetConeTarget_doc},
+ METH_NOARGS, (PY_METHODCHAR)GetConeTarget_doc},
{"getConeHeight", (PyCFunction) KX_RadarSensor::sPyGetConeHeight,
- METH_VARARGS, (PY_METHODCHAR)GetConeHeight_doc},
+ METH_NOARGS, (PY_METHODCHAR)GetConeHeight_doc},
{NULL,NULL,NULL,NULL} //Sentinel
};
@@ -238,41 +239,23 @@ const char KX_RadarSensor::GetConeOrigin_doc[] =
"getConeOrigin()\n"
"\tReturns the origin of the cone with which to test. The origin\n"
"\tis in the middle of the cone.";
-PyObject* KX_RadarSensor::PyGetConeOrigin(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- PyObject *retVal = PyList_New(3);
-
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_cone_origin[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_cone_origin[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_cone_origin[2]));
-
- return retVal;
+PyObject* KX_RadarSensor::PyGetConeOrigin(PyObject* self) {
+ return PyObjectFrom(m_cone_origin);
}
/* getConeOrigin */
const char KX_RadarSensor::GetConeTarget_doc[] =
"getConeTarget()\n"
"\tReturns the center of the bottom face of the cone with which to test.\n";
-PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- PyObject *retVal = PyList_New(3);
-
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_cone_target[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_cone_target[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_cone_target[2]));
-
- return retVal;
+PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self) {
+ return PyObjectFrom(m_cone_target);
}
/* getConeOrigin */
const char KX_RadarSensor::GetConeHeight_doc[] =
"getConeHeight()\n"
"\tReturns the height of the cone with which to test.\n";
-PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self) {
return PyFloat_FromDouble(m_coneheight);
}
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h
index f8f80725145..e4c6d73f22d 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.h
+++ b/source/gameengine/Ketsji/KX_RadarSensor.h
@@ -83,9 +83,9 @@ public:
virtual PyObject* _getattr(const char *attr);
- KX_PYMETHOD_DOC(KX_RadarSensor,GetConeOrigin);
- KX_PYMETHOD_DOC(KX_RadarSensor,GetConeTarget);
- KX_PYMETHOD_DOC(KX_RadarSensor,GetConeHeight);
+ KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeOrigin);
+ KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeTarget);
+ KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeHeight);
};
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index b8ebce28814..c7cb53f64ed 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -38,6 +38,7 @@
#include "KX_GameObject.h"
#include "KX_Scene.h"
#include "KX_RayCast.h"
+#include "KX_PyMath.h"
#include "PHY_IPhysicsEnvironment.h"
#include "KX_IPhysicsController.h"
#include "PHY_IPhysicsController.h"
@@ -179,8 +180,8 @@ bool KX_RaySensor::Evaluate(CValue* event)
bool reset = m_reset && m_level;
m_rayHit = false;
m_hitObject = NULL;
- m_hitPosition = MT_Vector3(0,0,0);
- m_hitNormal = MT_Vector3(1,0,0);
+ m_hitPosition.setValue(0,0,0);
+ m_hitNormal.setValue(1,0,0);
KX_GameObject* obj = (KX_GameObject*)GetParent();
MT_Point3 frompoint = obj->NodeGetWorldPosition();
@@ -335,19 +336,17 @@ PyParentObject KX_RaySensor::Parents[] = {
};
PyMethodDef KX_RaySensor::Methods[] = {
- {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc},
- {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_VARARGS, (PY_METHODCHAR)GetHitPosition_doc},
- {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_VARARGS, (PY_METHODCHAR)GetHitNormal_doc},
- {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_VARARGS, (PY_METHODCHAR)GetRayDirection_doc},
+ {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_NOARGS, (PY_METHODCHAR)GetHitObject_doc},
+ {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_NOARGS, (PY_METHODCHAR)GetHitPosition_doc},
+ {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_NOARGS, (PY_METHODCHAR)GetHitNormal_doc},
+ {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_NOARGS, (PY_METHODCHAR)GetRayDirection_doc},
{NULL,NULL} //Sentinel
};
const char KX_RaySensor::GetHitObject_doc[] =
"getHitObject()\n"
"\tReturns the name of the object that was hit by this ray.\n";
-PyObject* KX_RaySensor::PyGetHitObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_RaySensor::PyGetHitObject(PyObject* self)
{
if (m_hitObject)
{
@@ -360,60 +359,25 @@ PyObject* KX_RaySensor::PyGetHitObject(PyObject* self,
const char KX_RaySensor::GetHitPosition_doc[] =
"getHitPosition()\n"
"\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n";
-PyObject* KX_RaySensor::PyGetHitPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_RaySensor::PyGetHitPosition(PyObject* self)
{
-
- MT_Point3 pos = m_hitPosition;
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
- {
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(pos[index]));
- }
- return resultlist;
-
+ return PyObjectFrom(m_hitPosition);
}
const char KX_RaySensor::GetRayDirection_doc[] =
"getRayDirection()\n"
"\tReturns the direction from the ray (in worldcoordinates) .\n";
-PyObject* KX_RaySensor::PyGetRayDirection(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_RaySensor::PyGetRayDirection(PyObject* self)
{
-
- MT_Vector3 dir = m_rayDirection;
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
- {
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(dir[index]));
- }
- return resultlist;
-
+ return PyObjectFrom(m_rayDirection);
}
const char KX_RaySensor::GetHitNormal_doc[] =
"getHitNormal()\n"
"\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n";
-PyObject* KX_RaySensor::PyGetHitNormal(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_RaySensor::PyGetHitNormal(PyObject* self)
{
- MT_Vector3 pos = m_hitNormal;
-
- PyObject* resultlist = PyList_New(3);
- int index;
- for (index=0;index<3;index++)
- {
- PyList_SetItem(resultlist,index,PyFloat_FromDouble(pos[index]));
- }
- return resultlist;
-
+ return PyObjectFrom(m_hitNormal);
}
diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h
index 2baec12f74e..09d8bc1369a 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.h
+++ b/source/gameengine/Ketsji/KX_RaySensor.h
@@ -74,10 +74,10 @@ public:
bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
bool NeedRayCast(KX_ClientObjectInfo* client);
- KX_PYMETHOD_DOC(KX_RaySensor,GetHitObject);
- KX_PYMETHOD_DOC(KX_RaySensor,GetHitPosition);
- KX_PYMETHOD_DOC(KX_RaySensor,GetHitNormal);
- KX_PYMETHOD_DOC(KX_RaySensor,GetRayDirection);
+ KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitObject);
+ KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitPosition);
+ KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitNormal);
+ KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetRayDirection);
virtual PyObject* _getattr(const char *attr);
diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
index d651373869a..151270cbd68 100644
--- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
+++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
@@ -97,11 +97,11 @@ UpdateChildCoordinates(
child_transform = parent_matrix * child_transform;
// Recompute the child transform components from the transform.
- child_w_scale = MT_Vector3(
+ child_w_scale.setValue(
MT_Vector3(child_transform[0][0], child_transform[0][1], child_transform[0][2]).length(),
MT_Vector3(child_transform[1][0], child_transform[1][1], child_transform[1][2]).length(),
MT_Vector3(child_transform[2][0], child_transform[2][1], child_transform[2][2]).length());
- child_w_rotation = MT_Matrix3x3(child_transform[0][0], child_transform[0][1], child_transform[0][2],
+ child_w_rotation.setValue(child_transform[0][0], child_transform[0][1], child_transform[0][2],
child_transform[1][0], child_transform[1][1], child_transform[1][2],
child_transform[2][0], child_transform[2][1], child_transform[2][2]);
child_w_rotation.scale(1.0/child_w_scale[0], 1.0/child_w_scale[1], 1.0/child_w_scale[2]);
@@ -113,16 +113,15 @@ UpdateChildCoordinates(
}
}
- if (!valid_parent_transform)
+ if (valid_parent_transform)
{
- child_w_scale = child_scale;
- child_w_pos = child_pos;
- child_w_rotation = child_rotation;
+ child->SetWorldScale(child_w_scale);
+ child->SetWorldPosition(child_w_pos);
+ child->SetWorldOrientation(child_w_rotation);
+ }
+ else {
+ child->SetWorldFromLocalTransform();
}
-
- child->SetWorldScale(child_w_scale);
- child->SetWorldPosition(child_w_pos);
- child->SetWorldOrientation(child_w_rotation);
return valid_parent_transform;
}
diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
index 0c8e7e28771..0729ec8a902 100644
--- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
+++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
@@ -55,43 +55,21 @@ UpdateChildCoordinates(
){
MT_assert(child != NULL);
- // This way of accessing child coordinates is a bit cumbersome
- // be nice to have non constant reference access to these values.
-
- const MT_Vector3 & child_scale = child->GetLocalScale();
- const MT_Point3 & child_pos = child->GetLocalPosition();
- const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
-
- // the childs world locations which we will update.
-
- MT_Vector3 child_w_scale;
- MT_Point3 child_w_pos;
- MT_Matrix3x3 child_w_rotation;
-
- if (parent) {
-
+ if (parent==NULL) { /* Simple case */
+ child->SetWorldFromLocalTransform();
+ return false;
+ }
+ else {
+ // the childs world locations which we will update.
const MT_Vector3 & p_world_scale = parent->GetWorldScaling();
const MT_Point3 & p_world_pos = parent->GetWorldPosition();
const MT_Matrix3x3 & p_world_rotation = parent->GetWorldOrientation();
- child_w_scale = p_world_scale * child_scale;
- child_w_rotation = p_world_rotation * child_rotation;
-
- child_w_pos = p_world_pos + p_world_scale *
- (p_world_rotation * child_pos);
-
- } else {
-
- child_w_scale = child_scale;
- child_w_pos = child_pos;
- child_w_rotation = child_rotation;
+ child->SetWorldScale(p_world_scale * child->GetLocalScale());
+ child->SetWorldOrientation(p_world_rotation * child->GetLocalOrientation());
+ child->SetWorldPosition(p_world_pos + p_world_scale * (p_world_rotation * child->GetLocalPosition()));
+ return true;
}
-
- child->SetWorldScale(child_w_scale);
- child->SetWorldPosition(child_w_pos);
- child->SetWorldOrientation(child_w_rotation);
-
- return parent != NULL;
}
SG_ParentRelation *
@@ -138,40 +116,14 @@ UpdateChildCoordinates(
){
MT_assert(child != NULL);
-
- const MT_Vector3 & child_scale = child->GetLocalScale();
- const MT_Point3 & child_pos = child->GetLocalPosition();
- const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
-
- // the childs world locations which we will update.
+ child->SetWorldScale(child->GetLocalScale());
- MT_Vector3 child_w_scale;
- MT_Point3 child_w_pos;
- MT_Matrix3x3 child_w_rotation;
-
- if (parent) {
-
- // This is a vertex parent so we do not inherit orientation
- // information.
-
- // const MT_Vector3 & p_world_scale = parent->GetWorldScaling(); /*unused*/
- const MT_Point3 & p_world_pos = parent->GetWorldPosition();
- // const MT_Matrix3x3 & p_world_rotation = parent->GetWorldOrientation(); /*unused*/
-
- child_w_scale = child_scale;
- child_w_rotation = child_rotation;
- child_w_pos = p_world_pos + child_pos;
- } else {
-
- child_w_scale = child_scale;
- child_w_pos = child_pos;
- child_w_rotation = child_rotation;
- }
-
- child->SetWorldScale(child_w_scale);
- child->SetWorldPosition(child_w_pos);
- child->SetWorldOrientation(child_w_rotation);
+ if (parent)
+ child->SetWorldPosition(child->GetLocalPosition()+parent->GetWorldPosition());
+ else
+ child->SetWorldPosition(child->GetLocalPosition());
+ child->SetWorldOrientation(child->GetLocalOrientation());
return parent != NULL;
}
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index 89dfc8e57ad..9d4fa14ad8e 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -258,18 +258,18 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
{
case 0:
{
- up = MT_Vector3(1.0,0,0);
+ up.setValue(1.0,0,0);
break;
}
case 1:
{
- up = MT_Vector3(0,1.0,0);
+ up.setValue(0,1.0,0);
break;
}
case 2:
default:
{
- up = MT_Vector3(0,0,1.0);
+ up.setValue(0,0,1.0);
}
}
#endif
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp
index b92965ed1cc..210addfb927 100644
--- a/source/gameengine/Rasterizer/RAS_TexVert.cpp
+++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp
@@ -59,10 +59,10 @@ const MT_Point3& RAS_TexVert::xyz()
void RAS_TexVert::SetRGBA(const MT_Vector4& rgba)
{
unsigned char *colp = (unsigned char*) &m_rgba;
- colp[0] = (unsigned char) (rgba[0]*255.0);
- colp[1] = (unsigned char) (rgba[1]*255.0);
- colp[2] = (unsigned char) (rgba[2]*255.0);
- colp[3] = (unsigned char) (rgba[3]*255.0);
+ colp[0] = (unsigned char) (rgba[0]*255.0f);
+ colp[1] = (unsigned char) (rgba[1]*255.0f);
+ colp[2] = (unsigned char) (rgba[2]*255.0f);
+ colp[3] = (unsigned char) (rgba[3]*255.0f);
}
@@ -71,7 +71,10 @@ void RAS_TexVert::SetXYZ(const MT_Point3& xyz)
xyz.getValue(m_localxyz);
}
-
+void RAS_TexVert::SetXYZ(const float *xyz)
+{
+ m_localxyz[0]= xyz[0]; m_localxyz[1]= xyz[1]; m_localxyz[2]= xyz[2];
+}
void RAS_TexVert::SetUV(const MT_Point2& uv)
{
@@ -111,15 +114,18 @@ void RAS_TexVert::SetTangent(const MT_Vector3& tangent)
}
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
+#define _VEC_EQUAL3(_v1, _v2) (_v1[0]==_v2[0] && _v1[1]==_v2[1] && _v1[2]==_v2[2])
+#define _VEC_EQUAL2(_v1, _v2) (_v1[0]==_v2[0] && _v1[1]==_v2[1])
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
{
return (m_flag == other->m_flag &&
m_rgba == other->m_rgba &&
- MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) &&
- MT_fuzzyEqual(MT_Vector3(m_tangent), MT_Vector3(other->m_tangent)) &&
- MT_fuzzyEqual(MT_Vector2(m_uv1), MT_Vector2(other->m_uv1)) &&
- MT_fuzzyEqual(MT_Vector2(m_uv2), MT_Vector2(other->m_uv2)) && // p --
- MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))) ;
+ _VEC_EQUAL3(m_normal, other->m_normal) &&
+ _VEC_EQUAL3(m_tangent, other->m_tangent) &&
+ _VEC_EQUAL2(m_uv1, other->m_uv1) &&
+ _VEC_EQUAL2(m_uv2, other->m_uv2) // p --
+ /* we know the verts must be shared so dont need to check this */
+ /*&& FAST_MT_fuzzyEqual3(m_localxyz, other->m_localxyz)*/) ;
}
short RAS_TexVert::getFlag() const
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h
index 157a6ce3d51..811867f3579 100644
--- a/source/gameengine/Rasterizer/RAS_TexVert.h
+++ b/source/gameengine/Rasterizer/RAS_TexVert.h
@@ -115,6 +115,7 @@ public:
}
void SetXYZ(const MT_Point3& xyz);
+ void SetXYZ(const float *xyz);
void SetUV(const MT_Point2& uv);
void SetUV2(const MT_Point2& uv);
diff --git a/source/gameengine/SceneGraph/SG_BBox.cpp b/source/gameengine/SceneGraph/SG_BBox.cpp
index 4bd2805978e..a44262d04f7 100644
--- a/source/gameengine/SceneGraph/SG_BBox.cpp
+++ b/source/gameengine/SceneGraph/SG_BBox.cpp
@@ -34,8 +34,8 @@
#include "SG_Node.h"
SG_BBox::SG_BBox() :
- m_min(MT_Point3(0., 0., 0.)),
- m_max(MT_Point3(0., 0., 0.))
+ m_min(0., 0., 0.),
+ m_max(0., 0., 0.)
{
}
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp
index 5ba116e59db..99aeb3e72ee 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.cpp
+++ b/source/gameengine/SceneGraph/SG_Spatial.cpp
@@ -44,13 +44,13 @@ SG_Spatial(
):
SG_IObject(clientobj,clientinfo,callbacks),
- m_localPosition(MT_Point3(0.0,0.0,0.0)),
- m_localRotation(MT_Matrix3x3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)),
- m_localScaling(MT_Vector3(1.f,1.f,1.f)),
+ m_localPosition(0.0,0.0,0.0),
+ m_localRotation(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0),
+ m_localScaling(1.f,1.f,1.f),
- m_worldPosition(MT_Point3(0.0,0.0,0.0)),
- m_worldRotation(MT_Matrix3x3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)),
- m_worldScaling(MT_Vector3(1.f,1.f,1.f)),
+ m_worldPosition(0.0,0.0,0.0),
+ m_worldRotation(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0),
+ m_worldScaling(1.f,1.f,1.f),
m_parent_relation (NULL),
@@ -297,6 +297,13 @@ GetWorldScaling(
return m_worldScaling;
}
+void SG_Spatial::SetWorldFromLocalTransform()
+{
+ m_worldPosition= m_localPosition;
+ m_worldScaling= m_localScaling;
+ m_worldRotation= m_localRotation;
+}
+
SG_BBox& SG_Spatial::BBox()
{
return m_bbox;
diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h
index 28848b0f933..6ccec2aa9c1 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.h
+++ b/source/gameengine/SceneGraph/SG_Spatial.h
@@ -176,6 +176,8 @@ public:
GetWorldScaling(
) const ;
+ void SetWorldFromLocalTransform();
+
MT_Transform GetWorldTransform() const;
bool ComputeWorldTransforms( const SG_Spatial *parent);