diff --git a/Sources/Plasma/FeatureLib/pfPython/Pch.h b/Sources/Plasma/FeatureLib/pfPython/Pch.h index bf347db6..ac5a80ac 100644 --- a/Sources/Plasma/FeatureLib/pfPython/Pch.h +++ b/Sources/Plasma/FeatureLib/pfPython/Pch.h @@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // Standard Library Includes #include +#include #include #include #include diff --git a/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.cpp b/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.cpp index dd78ae65..4ad9594c 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.cpp @@ -132,9 +132,9 @@ PyObject* pyMatrix44::GetRightAxis() const return pyVector3::New(fMatrix.GetAxis(hsMatrix44::kRight)); } -float* pyMatrix44::GetData() const +mat44_t pyMatrix44::GetData() const { - float *res = new float[4*4]; + mat44_t res; res[0] = fMatrix.fMap[0][0]; res[1] = fMatrix.fMap[0][1]; res[2] = fMatrix.fMap[0][2]; res[3] = fMatrix.fMap[0][3]; res[4] = fMatrix.fMap[1][0]; res[5] = fMatrix.fMap[1][1]; res[6] = fMatrix.fMap[1][2]; res[7] = fMatrix.fMap[1][3]; res[8] = fMatrix.fMap[2][0]; res[9] = fMatrix.fMap[2][1]; res[10] = fMatrix.fMap[2][2]; res[11] = fMatrix.fMap[2][3]; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.h b/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.h index a7ff96f2..fd2dbdce 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyMatrix44.h @@ -42,12 +42,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #ifndef pyMatrix44_h_inc #define pyMatrix44_h_inc +#include #include "hsMatrix44.h" #include "pyGlueHelpers.h" class pyPoint3; class pyVector3; +typedef std::array mat44_t; class pyMatrix44 { @@ -93,7 +95,8 @@ public: PyObject* GetUpAxis() const; // returns pyVector3 PyObject* GetRightAxis() const; // returns pyVector3 - float* GetData() const; + /** Returns a copy of the 4x4 matrix data */ + mat44_t GetData() const; void SetData(const float mat[]); }; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyMatrix44Glue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyMatrix44Glue.cpp index b003b812..2b13e8ec 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyMatrix44Glue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyMatrix44Glue.cpp @@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include + #include "pyGeometry3.h" #include "pyMatrix44.h" #pragma hdrstop @@ -302,21 +303,19 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptMatrix44, right) PYTHON_METHOD_DEFINITION_NOARGS(ptMatrix44, getData) { - float *mat = self->fThis->GetData(); + mat44_t mat = self->fThis->GetData(); - PyObject *retVal = Py_BuildValue("(ffff)(ffff)(ffff)(ffff)", + PyObject* retVal = Py_BuildValue("(ffff)(ffff)(ffff)(ffff)", mat[0], mat[1], mat[2], mat[3], mat[4], mat[5], mat[6], mat[7], mat[8], mat[9], mat[10], mat[11], mat[12], mat[13], mat[14], mat[15]); - if (retVal == NULL) - { + if (!retVal) { PyErr_SetString(PyExc_TypeError, "setData expects a 4x4 tuple of floats"); PYTHON_RETURN_ERROR; } - delete mat; return retVal; }