From 509ca83ef1d10fab4903981714cfab3719280e04 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 14 Jan 2009 22:33:39 +0000 Subject: BGE patch 18065: gameobj mass writeable + setmass actuator. This patch allows to change the mass of a dynamic or rigid body object during the game. Two methods are available: in a Python script by setting the mass attribute of the game object; by logic brick with the Edit Object->Dynamics->Set Mass actuator. The mass can only be set on dynamic objects and must be a positive floating point value. --- source/gameengine/Converter/KX_ConvertActuators.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 4f152acc918..3a6122e6608 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -661,7 +661,8 @@ void BL_ConvertActuators(char* maggiename, { KX_SCA_DynamicActuator* tmpdynact = new KX_SCA_DynamicActuator(gameobj, - editobact->dyn_operation + editobact->dyn_operation, + editobact->mass ); baseact = tmpdynact; } -- cgit v1.2.3 From 8bd7aa0a01ee53172bb4fd1bd2de1b318c4ea80c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 21 Jan 2009 13:54:53 +0000 Subject: BGE API cleanup: action actuator. --- source/gameengine/Converter/BL_ActionActuator.cpp | 339 ++++++++++++++-------- source/gameengine/Converter/BL_ActionActuator.h | 48 ++- 2 files changed, 266 insertions(+), 121 deletions(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 4d748948c27..c05f763cacb 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -52,6 +52,8 @@ #include "FloatValue.h" #include "PyObjectPlus.h" +#include "blendef.h" + #ifdef HAVE_CONFIG_H #include #endif @@ -418,67 +420,6 @@ bool BL_ActionActuator::Update(double curtime, bool frame) /* Python functions */ /* ------------------------------------------------------------------------- */ -/* Integration hooks ------------------------------------------------------- */ - -PyTypeObject BL_ActionActuator::Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "BL_ActionActuator", - sizeof(BL_ActionActuator), - 0, - PyDestructor, - 0, - __getattr, - __setattr, - 0, //&MyPyCompare, - __repr, - 0, //&cvalue_as_number, - 0, - 0, - 0, - 0 -}; - -PyParentObject BL_ActionActuator::Parents[] = { - &BL_ActionActuator::Type, - &SCA_IActuator::Type, - &SCA_ILogicBrick::Type, - &CValue::Type, - NULL -}; - -PyMethodDef BL_ActionActuator::Methods[] = { - {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc}, - {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, - {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, - {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc}, - {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc}, - {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc}, - {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc}, - {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc}, - - {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc}, - {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc}, - {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc}, - {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc}, - {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc}, - {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc}, - {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, - {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc}, - {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, (PY_METHODCHAR)SetChannel_doc}, -// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS}, - {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc}, - {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, - {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0}, - {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0}, - {NULL,NULL} //Sentinel -}; - -PyObject* BL_ActionActuator::_getattr(const STR_String& attr) { - _getattr_up(SCA_IActuator); -} - /* setStart */ const char BL_ActionActuator::GetAction_doc[] = "getAction()\n" @@ -487,6 +428,8 @@ const char BL_ActionActuator::GetAction_doc[] = PyObject* BL_ActionActuator::PyGetAction(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getAction()", "the action property"); + if (m_action){ return PyString_FromString(m_action->id.name+2); } @@ -501,6 +444,8 @@ const char BL_ActionActuator::GetProperty_doc[] = PyObject* BL_ActionActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getProperty()", "the property property"); + PyObject *result; result = Py_BuildValue("s", (const char *)m_propname); @@ -516,6 +461,8 @@ const char BL_ActionActuator::GetFrameProperty_doc[] = PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getFrameProperty()", "the frameProperty property"); + PyObject *result; result = Py_BuildValue("s", (const char *)m_framepropname); @@ -531,6 +478,8 @@ const char BL_ActionActuator::GetFrame_doc[] = PyObject* BL_ActionActuator::PyGetFrame(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getFrame()", "the frame property"); + PyObject *result; result = Py_BuildValue("f", m_localtime); @@ -546,6 +495,8 @@ const char BL_ActionActuator::GetEnd_doc[] = PyObject* BL_ActionActuator::PyGetEnd(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getEnd()", "the end property"); + PyObject *result; result = Py_BuildValue("f", m_endframe); @@ -561,6 +512,8 @@ const char BL_ActionActuator::GetStart_doc[] = PyObject* BL_ActionActuator::PyGetStart(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getStart()", "the start property"); + PyObject *result; result = Py_BuildValue("f", m_startframe); @@ -577,6 +530,8 @@ const char BL_ActionActuator::GetBlendin_doc[] = PyObject* BL_ActionActuator::PyGetBlendin(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getBlendin()", "the blendin property"); + PyObject *result; result = Py_BuildValue("f", m_blendin); @@ -593,6 +548,8 @@ const char BL_ActionActuator::GetPriority_doc[] = PyObject* BL_ActionActuator::PyGetPriority(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("getPriority()", "the priority property"); + PyObject *result; result = Py_BuildValue("i", m_priority); @@ -613,6 +570,8 @@ const char BL_ActionActuator::SetAction_doc[] = PyObject* BL_ActionActuator::PySetAction(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setAction()", "the action property"); + char *string; int reset = 1; @@ -647,6 +606,8 @@ const char BL_ActionActuator::SetStart_doc[] = PyObject* BL_ActionActuator::PySetStart(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setStart()", "the start property"); + float start; if (PyArg_ParseTuple(args,"f",&start)) @@ -668,6 +629,8 @@ const char BL_ActionActuator::SetEnd_doc[] = PyObject* BL_ActionActuator::PySetEnd(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setEnd()", "the end property"); + float end; if (PyArg_ParseTuple(args,"f",&end)) @@ -690,6 +653,8 @@ const char BL_ActionActuator::SetBlendin_doc[] = PyObject* BL_ActionActuator::PySetBlendin(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setBlendin()", "the blendin property"); + float blendin; if (PyArg_ParseTuple(args,"f",&blendin)) @@ -713,6 +678,8 @@ const char BL_ActionActuator::SetBlendtime_doc[] = PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setBlendtime()", "the blendtime property"); + float blendframe; if (PyArg_ParseTuple(args,"f",&blendframe)) @@ -740,6 +707,8 @@ const char BL_ActionActuator::SetPriority_doc[] = PyObject* BL_ActionActuator::PySetPriority(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setPriority()", "the priority property"); + int priority; if (PyArg_ParseTuple(args,"i",&priority)) @@ -761,6 +730,8 @@ const char BL_ActionActuator::SetFrame_doc[] = PyObject* BL_ActionActuator::PySetFrame(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setFrame()", "the frame property"); + float frame; if (PyArg_ParseTuple(args,"f",&frame)) @@ -787,6 +758,8 @@ const char BL_ActionActuator::SetProperty_doc[] = PyObject* BL_ActionActuator::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setProperty()", "the property property"); + char *string; if (PyArg_ParseTuple(args,"s",&string)) @@ -808,6 +781,8 @@ const char BL_ActionActuator::SetFrameProperty_doc[] = PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setFrameProperty()", "the frameProperty property"); + char *string; if (PyArg_ParseTuple(args,"s",&string)) @@ -839,16 +814,80 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self, } */ -/* setChannel */ -const char BL_ActionActuator::SetChannel_doc[] = +/* getType */ +const char BL_ActionActuator::GetType_doc[] = +"getType()\n" +"\tReturns the operation mode of the actuator.\n"; +PyObject* BL_ActionActuator::PyGetType(PyObject* self, + PyObject* args, + PyObject* kwds) { + ShowDeprecationWarning("getType()", "the type property"); + + return Py_BuildValue("h", m_playtype); +} + +/* setType */ +const char BL_ActionActuator::SetType_doc[] = +"setType(mode)\n" +"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n" +"\tSet the operation mode of the actuator.\n"; +PyObject* BL_ActionActuator::PySetType(PyObject* self, + PyObject* args, + PyObject* kwds) { + ShowDeprecationWarning("setType()", "the type property"); + + short typeArg; + + if (!PyArg_ParseTuple(args, "h", &typeArg)) { + return NULL; + } + + switch (typeArg) { + case KX_ACT_ACTION_PLAY: + case KX_ACT_ACTION_FLIPPER: + case KX_ACT_ACTION_LOOPSTOP: + case KX_ACT_ACTION_LOOPEND: + case KX_ACT_ACTION_PROPERTY: + m_playtype = typeArg; + break; + default: + printf("Invalid type for action actuator: %d\n", typeArg); /* error */ + } + Py_RETURN_NONE; +} + +PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) { + ShowDeprecationWarning("getContinue()", "the continue property"); + + return PyInt_FromLong((long)(m_end_reset==0)); +} + +PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) { + ShowDeprecationWarning("setContinue()", "the continue property"); + + int param = PyObject_IsTrue( value ); + + if( param == -1 ) { + PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" ); + return NULL; + } + + if (param) { + m_end_reset = 0; + } else { + m_end_reset = 1; + } + Py_RETURN_NONE; +} + +//<-----Deprecated + +/* setChannel */ +KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, "setChannel(channel, matrix)\n" "\t - channel : A string specifying the name of the bone channel.\n" "\t - matrix : A 4x4 matrix specifying the overriding transformation\n" -"\t as an offset from the bone's rest position.\n"; - -PyObject* BL_ActionActuator::PySetChannel(PyObject* self, - PyObject* args, - PyObject* kwds) +"\t as an offset from the bone's rest position.\n") { float matrix[4][4]; char *string; @@ -923,61 +962,123 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self, Py_RETURN_NONE; } -/* getType */ -const char BL_ActionActuator::GetType_doc[] = -"getType()\n" -"\tReturns the operation mode of the actuator.\n"; -PyObject* BL_ActionActuator::PyGetType(PyObject* self, - PyObject* args, - PyObject* kwds) { - return Py_BuildValue("h", m_playtype); -} +/* ------------------------------------------------------------------------- */ +/* Python Integration Hooks */ +/* ------------------------------------------------------------------------- */ -/* setType */ -const char BL_ActionActuator::SetType_doc[] = -"setType(mode)\n" -"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n" -"\tSet the operation mode of the actuator.\n"; -PyObject* BL_ActionActuator::PySetType(PyObject* self, - PyObject* args, - PyObject* kwds) { - short typeArg; - - if (!PyArg_ParseTuple(args, "h", &typeArg)) { - return NULL; - } +PyTypeObject BL_ActionActuator::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "BL_ActionActuator", + sizeof(BL_ActionActuator), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; - switch (typeArg) { - case KX_ACT_ACTION_PLAY: - case KX_ACT_ACTION_FLIPPER: - case KX_ACT_ACTION_LOOPSTOP: - case KX_ACT_ACTION_LOOPEND: - case KX_ACT_ACTION_PROPERTY: - m_playtype = typeArg; - break; - default: - printf("Invalid type for action actuator: %d\n", typeArg); /* error */ - } - Py_RETURN_NONE; -} +PyParentObject BL_ActionActuator::Parents[] = { + &BL_ActionActuator::Type, + &SCA_IActuator::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; -PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) { - return PyInt_FromLong((long)(m_end_reset==0)); -} +PyMethodDef BL_ActionActuator::Methods[] = { + //Deprecated -----> + {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc}, + {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, + {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc}, -PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) { - int param = PyObject_IsTrue( value ); - - if( param == -1 ) { - PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" ); - return NULL; - } + {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc}, + {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc}, + {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc}, +// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS}, + {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc}, + {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, + {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0}, + {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0}, + //<------ + KX_PYMETHODTABLE(BL_ActionActuator, setChannel), + {NULL,NULL} //Sentinel +}; - if (param) { - m_end_reset = 0; - } else { - m_end_reset = 1; - } - Py_RETURN_NONE; +PyAttributeDef BL_ActionActuator::Attributes[] = { + KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ActionActuator, m_startframe), + KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ActionActuator, m_endframe), + KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ActionActuator, m_blendin), + KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority), + KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ActionActuator, m_localtime, CheckFrame), + KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ActionActuator, m_propname), + KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ActionActuator, m_framepropname), + KX_PYATTRIBUTE_BOOL_RW("continue", BL_ActionActuator, m_end_reset), + KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime), + KX_PYATTRIBUTE_ENUM_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType), + { NULL } //Sentinel +}; + +PyObject* BL_ActionActuator::_getattr(const STR_String& attr) { + if (attr == "action") + return PyString_FromString(m_action->id.name+2); + PyObject* object = _getattr_self(Attributes, this, attr); + if (object != NULL) + return object; + _getattr_up(SCA_IActuator); } +int BL_ActionActuator::_setattr(const STR_String& attr, PyObject* value) { + if (attr == "action") + { + if (!PyString_Check(value)) + { + PyErr_SetString(PyExc_ValueError, "expected a string"); + return 1; + } + + STR_String val = PyString_AsString(value); + + if (val == "") + { + m_action = NULL; + return 0; + } + + bAction *action; + + action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val); + + + if (!action) + { + PyErr_SetString(PyExc_ValueError, "action not found!"); + return 1; + } + + m_action = action; + return 0; + } + int ret = _setattr_self(Attributes, this, attr, value); + if (ret >= 0) + return ret; + return SCA_IActuator::_setattr(attr, value); +} \ No newline at end of file diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index a67b6d29b74..04bd9c803c5 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -81,6 +81,7 @@ public: void SetBlendTime (float newtime); + //Deprecated -----> KX_PYMETHOD_DOC(BL_ActionActuator,SetAction); KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendin); KX_PYMETHOD_DOC(BL_ActionActuator,SetPriority); @@ -90,7 +91,6 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,SetProperty); KX_PYMETHOD_DOC(BL_ActionActuator,SetFrameProperty); KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendtime); - KX_PYMETHOD_DOC(BL_ActionActuator,SetChannel); KX_PYMETHOD_DOC(BL_ActionActuator,GetAction); KX_PYMETHOD_DOC(BL_ActionActuator,GetBlendin); @@ -105,8 +105,12 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,SetType); KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue); KX_PYMETHOD_O(BL_ActionActuator,SetContinue); + //<----- + + KX_PYMETHOD_DOC(BL_ActionActuator,setChannel); virtual PyObject* _getattr(const STR_String& attr); + virtual int _setattr(const STR_String& attr, PyObject* value); enum ActionActType { @@ -117,6 +121,46 @@ public: KX_ACT_ACTION_PROPERTY = 6 }; + /* attribute check */ + static int CheckFrame(void *self, const PyAttributeDef*) + { + BL_ActionActuator* act = reinterpret_cast(self); + + if (act->m_localtime < act->m_startframe) + act->m_localtime = act->m_startframe; + else if (act->m_localtime > act->m_endframe) + act->m_localtime = act->m_endframe; + + return 0; + } + + static int CheckBlendTime(void *self, const PyAttributeDef*) + { + BL_ActionActuator* act = reinterpret_cast(self); + + if (act->m_blendframe < act->m_blendin) + act->m_blendframe = act->m_blendin; + + return 0; + } + + static int CheckType(void *self, const PyAttributeDef*) + { + BL_ActionActuator* act = reinterpret_cast(self); + + switch (act->m_playtype) { + case KX_ACT_ACTION_PLAY: + case KX_ACT_ACTION_FLIPPER: + case KX_ACT_ACTION_LOOPSTOP: + case KX_ACT_ACTION_LOOPEND: + case KX_ACT_ACTION_PROPERTY: + return 0; + default: + PyErr_SetString(PyExc_ValueError, "invalid type supplied"); + return 1; + } + + } protected: void SetStartTime(float curtime); @@ -141,7 +185,7 @@ protected: float m_stridelength; short m_playtype; short m_priority; - short m_end_reset; + bool m_end_reset; struct bPose* m_pose; struct bPose* m_blendpose; struct bPose* m_userpose; -- cgit v1.2.3 From 8a95c67a50918a928f45fffd53e084428fcff9d8 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 22 Jan 2009 17:40:47 +0000 Subject: BGE API cleanup: shape action actuator. --- source/gameengine/Converter/BL_ActionActuator.cpp | 16 ++--- source/gameengine/Converter/BL_ActionActuator.h | 22 ++---- .../Converter/BL_ShapeActionActuator.cpp | 80 +++++++++++++++++++++- .../gameengine/Converter/BL_ShapeActionActuator.h | 40 +++++++++++ 4 files changed, 131 insertions(+), 27 deletions(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index c05f763cacb..65d6892fa6d 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -39,10 +39,9 @@ #include "BL_SkinDeformer.h" #include "KX_GameObject.h" #include "STR_HashedString.h" -#include "DNA_action_types.h" #include "DNA_nla_types.h" -#include "DNA_actuator_types.h" #include "BKE_action.h" +#include "DNA_action_types.h" #include "DNA_armature_types.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" @@ -51,7 +50,6 @@ #include "BKE_utildefines.h" #include "FloatValue.h" #include "PyObjectPlus.h" - #include "blendef.h" #ifdef HAVE_CONFIG_H @@ -843,11 +841,11 @@ PyObject* BL_ActionActuator::PySetType(PyObject* self, } switch (typeArg) { - case KX_ACT_ACTION_PLAY: - case KX_ACT_ACTION_FLIPPER: - case KX_ACT_ACTION_LOOPSTOP: - case KX_ACT_ACTION_LOOPEND: - case KX_ACT_ACTION_PROPERTY: + case ACT_ACTION_PLAY: + case ACT_ACTION_FLIPPER: + case ACT_ACTION_LOOP_STOP: + case ACT_ACTION_LOOP_END: + case ACT_ACTION_FROM_PROP: m_playtype = typeArg; break; default: @@ -1033,7 +1031,7 @@ PyAttributeDef BL_ActionActuator::Attributes[] = { KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ActionActuator, m_framepropname), KX_PYATTRIBUTE_BOOL_RW("continue", BL_ActionActuator, m_end_reset), KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime), - KX_PYATTRIBUTE_ENUM_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType), + KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType), { NULL } //Sentinel }; diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 04bd9c803c5..6e291106553 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -32,6 +32,7 @@ #include "GEN_HashedPtr.h" #include "SCA_IActuator.h" +#include "DNA_actuator_types.h" #include "MT_Point3.h" class BL_ActionActuator : public SCA_IActuator @@ -112,15 +113,6 @@ public: virtual PyObject* _getattr(const STR_String& attr); virtual int _setattr(const STR_String& attr, PyObject* value); - enum ActionActType - { - KX_ACT_ACTION_PLAY = 0, - KX_ACT_ACTION_FLIPPER = 2, - KX_ACT_ACTION_LOOPSTOP, - KX_ACT_ACTION_LOOPEND, - KX_ACT_ACTION_PROPERTY = 6 - }; - /* attribute check */ static int CheckFrame(void *self, const PyAttributeDef*) { @@ -138,7 +130,7 @@ public: { BL_ActionActuator* act = reinterpret_cast(self); - if (act->m_blendframe < act->m_blendin) + if (act->m_blendframe > act->m_blendin) act->m_blendframe = act->m_blendin; return 0; @@ -149,11 +141,11 @@ public: BL_ActionActuator* act = reinterpret_cast(self); switch (act->m_playtype) { - case KX_ACT_ACTION_PLAY: - case KX_ACT_ACTION_FLIPPER: - case KX_ACT_ACTION_LOOPSTOP: - case KX_ACT_ACTION_LOOPEND: - case KX_ACT_ACTION_PROPERTY: + case ACT_ACTION_PLAY: + case ACT_ACTION_FLIPPER: + case ACT_ACTION_LOOP_STOP: + case ACT_ACTION_LOOP_END: + case ACT_ACTION_FROM_PROP: return 0; default: PyErr_SetString(PyExc_ValueError, "invalid type supplied"); diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 46f3141be29..df0a8c4f25e 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -35,13 +35,11 @@ #include "SCA_LogicManager.h" #include "BL_ShapeActionActuator.h" -#include "BL_ActionActuator.h" #include "BL_ShapeDeformer.h" #include "KX_GameObject.h" #include "STR_HashedString.h" -#include "DNA_action_types.h" #include "DNA_nla_types.h" -#include "DNA_actuator_types.h" +#include "DNA_action_types.h" #include "BKE_action.h" #include "DNA_armature_types.h" #include "MEM_guardedalloc.h" @@ -51,6 +49,7 @@ #include "BKE_utildefines.h" #include "FloatValue.h" #include "PyObjectPlus.h" +#include "blendef.h" #ifdef HAVE_CONFIG_H #include @@ -471,16 +470,73 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = { {NULL,NULL} //Sentinel }; +PyAttributeDef BL_ShapeActionActuator::Attributes[] = { + KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ShapeActionActuator, m_startframe), + KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ShapeActionActuator, m_endframe), + KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendin), + KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ShapeActionActuator, m_priority), + KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ShapeActionActuator, m_localtime, CheckFrame), + KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ShapeActionActuator, m_propname), + KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ShapeActionActuator, m_framepropname), + KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendframe, CheckBlendTime), + KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ShapeActionActuator,m_playtype,CheckType), + { NULL } //Sentinel +}; + + PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) { + if (attr == "action") + return PyString_FromString(m_action->id.name+2); + PyObject* object = _getattr_self(Attributes, this, attr); + if (object != NULL) + return object; _getattr_up(SCA_IActuator); } +int BL_ShapeActionActuator::_setattr(const STR_String& attr, PyObject* value) { + if (attr == "action") + { + if (!PyString_Check(value)) + { + PyErr_SetString(PyExc_ValueError, "expected a string"); + return 1; + } + + STR_String val = PyString_AsString(value); + + if (val == "") + { + m_action = NULL; + return 0; + } + + bAction *action; + + action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val); + + + if (!action) + { + PyErr_SetString(PyExc_ValueError, "action not found!"); + return 1; + } + + m_action = action; + return 0; + } + int ret = _setattr_self(Attributes, this, attr, value); + if (ret >= 0) + return ret; + return SCA_IActuator::_setattr(attr, value); +} + /* setStart */ const char BL_ShapeActionActuator::GetAction_doc[] = "getAction()\n" "\tReturns a string containing the name of the current action.\n"; PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) { + ShowDeprecationWarning("getAction()", "the action property"); if (m_action){ return PyString_FromString(m_action->id.name+2); } @@ -493,6 +549,7 @@ const char BL_ShapeActionActuator::GetProperty_doc[] = "\tReturns the name of the property to be used in FromProp mode.\n"; PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self) { + ShowDeprecationWarning("getProperty()", "the property property"); PyObject *result; result = Py_BuildValue("s", (const char *)m_propname); @@ -506,6 +563,7 @@ const char BL_ShapeActionActuator::GetFrame_doc[] = "\tReturns the current frame number.\n"; PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self) { + ShowDeprecationWarning("getFrame()", "the frame property"); PyObject *result; result = Py_BuildValue("f", m_localtime); @@ -519,6 +577,7 @@ const char BL_ShapeActionActuator::GetEnd_doc[] = "\tReturns the last frame of the action.\n"; PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self) { + ShowDeprecationWarning("getEnd()", "the end property"); PyObject *result; result = Py_BuildValue("f", m_endframe); @@ -532,6 +591,7 @@ const char BL_ShapeActionActuator::GetStart_doc[] = "\tReturns the starting frame of the action.\n"; PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self) { + ShowDeprecationWarning("getStart()", "the start property"); PyObject *result; result = Py_BuildValue("f", m_startframe); @@ -546,6 +606,7 @@ const char BL_ShapeActionActuator::GetBlendin_doc[] = "\tgenerated when this actuator is triggered.\n"; PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self) { + ShowDeprecationWarning("getBlendin()", "the blendin property"); PyObject *result; result = Py_BuildValue("f", m_blendin); @@ -560,6 +621,7 @@ const char BL_ShapeActionActuator::GetPriority_doc[] = "\tPriority numbers will override actuators with higher numbers.\n"; PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self) { + ShowDeprecationWarning("getPriority()", "the priority property"); PyObject *result; result = Py_BuildValue("i", m_priority); @@ -581,6 +643,7 @@ const char BL_ShapeActionActuator::SetAction_doc[] = PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setAction()", "the action property"); char *string; int reset = 1; @@ -615,6 +678,7 @@ const char BL_ShapeActionActuator::SetStart_doc[] = PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setStart()", "the start property"); float start; if (PyArg_ParseTuple(args,"f",&start)) @@ -636,6 +700,7 @@ const char BL_ShapeActionActuator::SetEnd_doc[] = PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setEnd()", "the end property"); float end; if (PyArg_ParseTuple(args,"f",&end)) @@ -658,6 +723,7 @@ const char BL_ShapeActionActuator::SetBlendin_doc[] = PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setBlendin()", "the blendin property"); float blendin; if (PyArg_ParseTuple(args,"f",&blendin)) @@ -681,6 +747,7 @@ const char BL_ShapeActionActuator::SetBlendtime_doc[] = PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setBlendtime()", "the blendTime property"); float blendframe; if (PyArg_ParseTuple(args,"f",&blendframe)) @@ -708,6 +775,7 @@ const char BL_ShapeActionActuator::SetPriority_doc[] = PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setPriority()", "the priority property"); int priority; if (PyArg_ParseTuple(args,"i",&priority)) @@ -727,6 +795,7 @@ const char BL_ShapeActionActuator::GetFrameProperty_doc[] = "\tReturns the name of the property, that is set to the current frame number.\n"; PyObject* BL_ShapeActionActuator::PyGetFrameProperty(PyObject* self) { + ShowDeprecationWarning("getFrameProperty()", "the frameProperty property"); PyObject *result; result = Py_BuildValue("s", (const char *)m_framepropname); @@ -743,6 +812,7 @@ const char BL_ShapeActionActuator::SetFrame_doc[] = PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setFrame()", "the frame property"); float frame; if (PyArg_ParseTuple(args,"f",&frame)) @@ -769,6 +839,7 @@ const char BL_ShapeActionActuator::SetProperty_doc[] = PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setProperty()", "the property property"); char *string; if (PyArg_ParseTuple(args,"s",&string)) @@ -790,6 +861,7 @@ const char BL_ShapeActionActuator::SetFrameProperty_doc[] = PyObject* BL_ShapeActionActuator::PySetFrameProperty(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setFrameProperty()", "the frameProperty property"); char *string; if (PyArg_ParseTuple(args,"s",&string)) @@ -808,6 +880,7 @@ const char BL_ShapeActionActuator::GetType_doc[] = "getType()\n" "\tReturns the operation mode of the actuator.\n"; PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self) { + ShowDeprecationWarning("getType()", "the type property"); return Py_BuildValue("h", m_playtype); } @@ -819,6 +892,7 @@ const char BL_ShapeActionActuator::SetType_doc[] = PyObject* BL_ShapeActionActuator::PySetType(PyObject* self, PyObject* args, PyObject* kwds) { + ShowDeprecationWarning("setType()", "the type property"); short typeArg; if (!PyArg_ParseTuple(args, "h", &typeArg)) { diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 30b2d41fc67..b521c0d98a6 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -32,6 +32,7 @@ #include "GEN_HashedPtr.h" #include "SCA_IActuator.h" +#include "BL_ActionActuator.h" #include "MT_Point3.h" #include @@ -103,6 +104,45 @@ public: KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType); virtual PyObject* _getattr(const STR_String& attr); + virtual int _setattr(const STR_String& attr, PyObject* value); + + static int CheckBlendTime(void *self, const PyAttributeDef*) + { + BL_ShapeActionActuator* act = reinterpret_cast(self); + + if (act->m_blendframe > act->m_blendin) + act->m_blendframe = act->m_blendin; + + return 0; + } + static int CheckFrame(void *self, const PyAttributeDef*) + { + BL_ShapeActionActuator* act = reinterpret_cast(self); + + if (act->m_localtime < act->m_startframe) + act->m_localtime = act->m_startframe; + else if (act->m_localtime > act->m_endframe) + act->m_localtime = act->m_endframe; + + return 0; + } + static int CheckType(void *self, const PyAttributeDef*) + { + BL_ShapeActionActuator* act = reinterpret_cast(self); + + switch (act->m_playtype) { + case ACT_ACTION_PLAY: + case ACT_ACTION_FLIPPER: + case ACT_ACTION_LOOP_STOP: + case ACT_ACTION_LOOP_END: + case ACT_ACTION_FROM_PROP: + return 0; + default: + PyErr_SetString(PyExc_ValueError, "invalid type supplied"); + return 1; + } + + } protected: -- cgit v1.2.3 From c597863783e1001dca599e6dcbc28048f0ef4ce1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 19 Feb 2009 10:34:51 +0000 Subject: "object" and "objectLastCreated" attribute for actuators, deprecates getObject/setObject() & getLastCreatedObject() also removed some warnings --- source/gameengine/Converter/BL_ShapeActionActuator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index b521c0d98a6..47ceb9aa995 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -169,8 +169,8 @@ protected: short m_playtype; short m_priority; struct bAction *m_action; - STR_String m_propname; STR_String m_framepropname; + STR_String m_propname; vector m_blendshape; }; -- cgit v1.2.3 From cdec2b3d15ab0448e4df70496285ed95681e5972 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 19 Feb 2009 13:42:07 +0000 Subject: BGE Python API Use 'const char *' rather then the C++ 'STR_String' type for the attribute identifier of python attributes. Each attribute and method access from python was allocating and freeing the string. A simple test with getting an attribute a loop shows this speeds up attribute lookups a bit over 2x. --- source/gameengine/Converter/BL_ActionActuator.cpp | 8 ++++---- source/gameengine/Converter/BL_ActionActuator.h | 4 ++-- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 +- source/gameengine/Converter/BL_ShapeActionActuator.cpp | 8 ++++---- source/gameengine/Converter/BL_ShapeActionActuator.h | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 65d6892fa6d..22c6c95b158 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -1035,8 +1035,8 @@ PyAttributeDef BL_ActionActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* BL_ActionActuator::_getattr(const STR_String& attr) { - if (attr == "action") +PyObject* BL_ActionActuator::_getattr(const char *attr) { + if (!strcmp(attr, "action")) return PyString_FromString(m_action->id.name+2); PyObject* object = _getattr_self(Attributes, this, attr); if (object != NULL) @@ -1044,8 +1044,8 @@ PyObject* BL_ActionActuator::_getattr(const STR_String& attr) { _getattr_up(SCA_IActuator); } -int BL_ActionActuator::_setattr(const STR_String& attr, PyObject* value) { - if (attr == "action") +int BL_ActionActuator::_setattr(const char *attr, PyObject* value) { + if (!strcmp(attr, "action")) { if (!PyString_Check(value)) { diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 6e291106553..6161048afb8 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -110,8 +110,8 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,setChannel); - virtual PyObject* _getattr(const STR_String& attr); - virtual int _setattr(const STR_String& attr, PyObject* value); + virtual PyObject* _getattr(const char *attr); + virtual int _setattr(const char *attr, PyObject* value); /* attribute check */ static int CheckFrame(void *self, const PyAttributeDef*) diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 9c699b67b28..2fa3e192179 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -361,7 +361,7 @@ BL_Material* ConvertMaterial( facetex = true; if(validface && mat->mtex[0]) { MTex *tmp = mat->mtex[0]; - if(!tmp->tex || tmp->tex && !tmp->tex->ima ) + if(!tmp->tex || (tmp->tex && !tmp->tex->ima)) facetex = true; } numchan = numchan>MAXTEX?MAXTEX:numchan; diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index df0a8c4f25e..7cba6b01e1a 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -484,8 +484,8 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = { }; -PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) { - if (attr == "action") +PyObject* BL_ShapeActionActuator::_getattr(const char *attr) { + if (!strcmp(attr, "action")) return PyString_FromString(m_action->id.name+2); PyObject* object = _getattr_self(Attributes, this, attr); if (object != NULL) @@ -493,8 +493,8 @@ PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) { _getattr_up(SCA_IActuator); } -int BL_ShapeActionActuator::_setattr(const STR_String& attr, PyObject* value) { - if (attr == "action") +int BL_ShapeActionActuator::_setattr(const char *attr, PyObject* value) { + if (!strcmp(attr, "action")) { if (!PyString_Check(value)) { diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 47ceb9aa995..7f2431bcfa5 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -103,8 +103,8 @@ public: KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType); - virtual PyObject* _getattr(const STR_String& attr); - virtual int _setattr(const STR_String& attr, PyObject* value); + virtual PyObject* _getattr(const char *attr); + virtual int _setattr(const char *attr, PyObject* value); static int CheckBlendTime(void *self, const PyAttributeDef*) { -- cgit v1.2.3 From 9d5c2af1d1e11d40fec6c0da96cb37de1684f13c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Feb 2009 12:43:24 +0000 Subject: * removed typedefs that were not used (from anonymous enums and structs) * Missed some cases of using a 'char *' as an attribute * replace BGE's Py_Return macro with Pythons Py_RETURN_NONE * other minor warnings removed --- source/gameengine/Converter/BL_ShapeActionActuator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 7cba6b01e1a..2e02ee9b941 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -911,6 +911,6 @@ PyObject* BL_ShapeActionActuator::PySetType(PyObject* self, printf("Invalid type for action actuator: %d\n", typeArg); /* error */ } - Py_Return; + Py_RETURN_NONE; } -- cgit v1.2.3 From 394d893e13257cb0fc5bec815e2111c12d5ed4ec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Feb 2009 03:29:31 +0000 Subject: compile scripts when converting controllers to give more predictable performance and print syntax errors early on rather then when the script is first executed. --- source/gameengine/Converter/KX_ConvertControllers.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index da490b4ee85..fb100b0a68b 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -200,6 +200,13 @@ void BL_ConvertControllers( gameobj->AddController(gamecontroller); converter->RegisterGameController(gamecontroller, bcontr); + + if (bcontr->type==CONT_PYTHON) { + /* not strictly needed but gives syntax errors early on and + * gives more pradictable performance for larger scripts */ + (static_cast(gamecontroller))->Compile(); + } + //done with gamecontroller gamecontroller->Release(); } -- cgit v1.2.3 From 2eb85c01f3e0ea2ba9dd129ae70e8b370953d7b5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Feb 2009 03:26:02 +0000 Subject: remove warnings for the BGE - variables that shadow vers declared earlier - Py_Fatal print an error to the stderr - gcc was complaining about the order of initialized vars (for classes) - const return values for ints and bools didnt do anything. - braces for ambiguous if statements --- .../Converter/BL_BlenderDataConversion.cpp | 32 +++++++------- source/gameengine/Converter/KX_IpoConvert.cpp | 50 +++++++++++----------- 2 files changed, 41 insertions(+), 41 deletions(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 2fa3e192179..3293d37af3a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1997,18 +1997,18 @@ void BL_ConvertBlenderObjects(struct Main* maggie, MT_Vector3 x(ori.getColumn(0)); MT_Vector3 y(ori.getColumn(1)); MT_Vector3 z(ori.getColumn(2)); - MT_Vector3 scale(x.length(), y.length(), z.length()); - if (!MT_fuzzyZero(scale[0])) - x /= scale[0]; - if (!MT_fuzzyZero(scale[1])) - y /= scale[1]; - if (!MT_fuzzyZero(scale[2])) - z /= scale[2]; + MT_Vector3 parscale(x.length(), y.length(), z.length()); + if (!MT_fuzzyZero(parscale[0])) + x /= parscale[0]; + if (!MT_fuzzyZero(parscale[1])) + y /= parscale[1]; + if (!MT_fuzzyZero(parscale[2])) + z /= parscale[2]; ori.setColumn(0, x); ori.setColumn(1, y); ori.setColumn(2, z); parentinversenode->SetLocalOrientation(ori); - parentinversenode->SetLocalScale(scale); + parentinversenode->SetLocalScale(parscale); parentinversenode->AddChild(gameobj->GetSGNode()); } @@ -2194,18 +2194,18 @@ void BL_ConvertBlenderObjects(struct Main* maggie, MT_Vector3 x(ori.getColumn(0)); MT_Vector3 y(ori.getColumn(1)); MT_Vector3 z(ori.getColumn(2)); - MT_Vector3 scale(x.length(), y.length(), z.length()); - if (!MT_fuzzyZero(scale[0])) - x /= scale[0]; - if (!MT_fuzzyZero(scale[1])) - y /= scale[1]; - if (!MT_fuzzyZero(scale[2])) - z /= scale[2]; + MT_Vector3 localscale(x.length(), y.length(), z.length()); + if (!MT_fuzzyZero(localscale[0])) + x /= localscale[0]; + if (!MT_fuzzyZero(localscale[1])) + y /= localscale[1]; + if (!MT_fuzzyZero(localscale[2])) + z /= localscale[2]; ori.setColumn(0, x); ori.setColumn(1, y); ori.setColumn(2, z); parentinversenode->SetLocalOrientation(ori); - parentinversenode->SetLocalScale(scale); + parentinversenode->SetLocalScale(localscale); parentinversenode->AddChild(gameobj->GetSGNode()); } diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index ce004fa0504..f19390db8a9 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -311,67 +311,67 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend } { - KX_ObColorIpoSGController* ipocontr=NULL; + KX_ObColorIpoSGController* ipocontr_obcol=NULL; ipo = ipoList->GetScalarInterpolator(OB_COL_R); if (ipo) { - if (!ipocontr) + if (!ipocontr_obcol) { - ipocontr = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + ipocontr_obcol = new KX_ObColorIpoSGController(); + gameobj->GetSGNode()->AddSGController(ipocontr_obcol); + ipocontr_obcol->SetObject(gameobj->GetSGNode()); } KX_IInterpolator *interpolator = new KX_ScalarInterpolator( - &ipocontr->m_rgba[0], + &ipocontr_obcol->m_rgba[0], ipo); - ipocontr->AddInterpolator(interpolator); + ipocontr_obcol->AddInterpolator(interpolator); } ipo = ipoList->GetScalarInterpolator(OB_COL_G); if (ipo) { - if (!ipocontr) + if (!ipocontr_obcol) { - ipocontr = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + ipocontr_obcol = new KX_ObColorIpoSGController(); + gameobj->GetSGNode()->AddSGController(ipocontr_obcol); + ipocontr_obcol->SetObject(gameobj->GetSGNode()); } KX_IInterpolator *interpolator = new KX_ScalarInterpolator( - &ipocontr->m_rgba[1], + &ipocontr_obcol->m_rgba[1], ipo); - ipocontr->AddInterpolator(interpolator); + ipocontr_obcol->AddInterpolator(interpolator); } ipo = ipoList->GetScalarInterpolator(OB_COL_B); if (ipo) { - if (!ipocontr) + if (!ipocontr_obcol) { - ipocontr = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + ipocontr_obcol = new KX_ObColorIpoSGController(); + gameobj->GetSGNode()->AddSGController(ipocontr_obcol); + ipocontr_obcol->SetObject(gameobj->GetSGNode()); } KX_IInterpolator *interpolator = new KX_ScalarInterpolator( - &ipocontr->m_rgba[2], + &ipocontr_obcol->m_rgba[2], ipo); - ipocontr->AddInterpolator(interpolator); + ipocontr_obcol->AddInterpolator(interpolator); } ipo = ipoList->GetScalarInterpolator(OB_COL_A); if (ipo) { - if (!ipocontr) + if (!ipocontr_obcol) { - ipocontr = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + ipocontr_obcol = new KX_ObColorIpoSGController(); + gameobj->GetSGNode()->AddSGController(ipocontr_obcol); + ipocontr_obcol->SetObject(gameobj->GetSGNode()); } KX_IInterpolator *interpolator = new KX_ScalarInterpolator( - &ipocontr->m_rgba[3], + &ipocontr_obcol->m_rgba[3], ipo); - ipocontr->AddInterpolator(interpolator); + ipocontr_obcol->AddInterpolator(interpolator); } } -- cgit v1.2.3 From c77af311665d230ed933138cd20962d021ad5c2b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Feb 2009 06:43:03 +0000 Subject: 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. --- .../Converter/BL_BlenderDataConversion.cpp | 69 +++++++++------------- source/gameengine/Converter/BL_MeshDeformer.cpp | 4 +- 2 files changed, 29 insertions(+), 44 deletions(-) (limited to 'source/gameengine/Converter') 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; imvert[v.getOrigIndex()].co; - v.SetXYZ(MT_Point3(co)); + v.SetXYZ(m_bmesh->mvert[v.getOrigIndex()].co); } } } -- cgit v1.2.3 From 7fffb0b6302618049a35e6bacf0aeed70a47d8aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Feb 2009 12:07:51 +0000 Subject: Building the game engine with Solid/Sumo is now optional for scons using WITH_BF_SOLID. Now Sumo is has been deprecated for a while we might want to remove it for 2.5. --- source/gameengine/Converter/SConscript | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index 3be352c568b..361dca58005 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -2,6 +2,7 @@ Import ('env') sources = env.Glob('*.cpp') +defs = [] incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #intern/bmfont' @@ -14,12 +15,16 @@ incs += ' #source/blender/include #source/blender/makesdna #source/gameengine/Ra incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #source/gameengine/GameLogic' incs += ' #source/gameengine/Expressions #source/gameengine/Network #source/gameengine/SceneGraph' incs += ' #source/gameengine/Physics/common #source/gameengine/Physics/Bullet #source/gameengine/Physics/BlOde' -incs += ' #source/gameengine/Physics/Dummy #source/gameengine/Physics/Sumo' -incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork' +incs += ' #source/gameengine/Physics/Dummy' +incs += ' #source/gameengine/Network/LoopBackNetwork' incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu' +if env['WITH_BF_SOLID']: + incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/Fuzzics/include' + incs += ' ' + env['BF_SOLID_INC'] + defs.append('USE_SUMO_SOLID') + incs += ' ' + env['BF_PYTHON_INC'] -incs += ' ' + env['BF_SOLID_INC'] incs += ' ' + env['BF_BULLET_INC'] -env.BlenderLib ( 'bf_converter', sources, Split(incs), [], libtype=['game','player'], priority=[5,70] ) +env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['game','player'], priority=[5,70] ) -- cgit v1.2.3 From a4ad52f1aaa1c8ed0d2f1345cbff99769f353ae9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Feb 2009 17:19:30 +0000 Subject: New Pulse option for the collision sensor (off by default wont change existing logic) Previously only the first collision would trigger an event (no collisions a negative event ofcourse) With the Pulse option enabled, any change to the set of colliding objects will trigger an event. Added this because there was no way to count how many sheep were on a platform in YoFrankie without running a script periodically. Changes in collision are detected by comparing the number of objects colliding with the last event, as well as a hash made from the object pointers. Also changed the touch sensors internal list of colliding objects to only contain objects that match the property or material. - pulse isnt a great name, could change this. --- source/gameengine/Converter/KX_ConvertSensors.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 13b7f43195d..c9b51807767 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -306,12 +306,12 @@ void BL_ConvertSensors(struct Object* blenderobject, { // collision sensor can sense both materials and properties. - bool bFindMaterial = false; + bool bFindMaterial = false, bTouchPulse = false; bCollisionSensor* blendertouchsensor = (bCollisionSensor*)sens->data; - bFindMaterial = (blendertouchsensor->mode - & SENS_COLLISION_MATERIAL); + bFindMaterial = (blendertouchsensor->mode & SENS_COLLISION_MATERIAL); + bTouchPulse = (blendertouchsensor->mode & SENS_COLLISION_PULSE); STR_String touchPropOrMatName = ( bFindMaterial ? @@ -324,6 +324,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gamesensor = new KX_TouchSensor(eventmgr, gameobj, bFindMaterial, + bTouchPulse, touchPropOrMatName); } @@ -349,6 +350,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gamesensor = new KX_TouchSensor(eventmgr, gameobj, bFindMaterial, + false, touchpropertyname); } } -- cgit v1.2.3 From abb338ddf9dea9a26ca1092b3f7fda86b32bbd16 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 9 Mar 2009 04:21:28 +0000 Subject: upgrade to latest Bullet trunk, fix related to vehicle anti-roll, added constraint visualization. This commit doesn't add new functionality, but more updates are planned before Blender 2.49 release. --- source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 7eec93dc402..97a0819147c 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -321,7 +321,7 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename, SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/ int visualizePhysics = SYS_GetCommandLineInt(syshandle,"show_physics",0); if (visualizePhysics) - ccdPhysEnv->setDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText); + ccdPhysEnv->setDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints); //todo: get a button in blender ? //disable / enable debug drawing (contact points, aabb's etc) -- cgit v1.2.3 From 06d455f4280815c9197f8d9cb6c0cadcdfc5e838 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 9 Mar 2009 07:12:16 +0000 Subject: Add support to lock individual axis during rigid body simulation, for translation and rotation. This makes it easier to do 1D or 2D physics (tetris, blockout) todo: create some example/demo.blend. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 3a0302562e6..d74243b0eb0 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1315,6 +1315,12 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, CreateMaterialFromBlenderObject(blenderobject, kxscene); KX_ObjectProperties objprop; + objprop.m_lockXaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_AXIS) !=0; + objprop.m_lockYaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_AXIS) !=0; + objprop.m_lockZaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_AXIS) !=0; + objprop.m_lockXRotaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_ROT_AXIS) !=0; + objprop.m_lockYRotaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS) !=0; + objprop.m_lockZRotaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS) !=0; objprop.m_isCompoundChild = isCompoundChild; objprop.m_hasCompoundChildren = (blenderobject->gameflag & OB_CHILD) != 0; -- cgit v1.2.3