diff options
Diffstat (limited to 'source/gameengine/Converter')
27 files changed, 548 insertions, 1877 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 88d6d294dc0..ca4290703e1 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -43,6 +43,7 @@ #include "BKE_action.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" +#include "DNA_scene_types.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_arithb.h" @@ -51,12 +52,18 @@ #include "FloatValue.h" #include "PyObjectPlus.h" #include "KX_PyMath.h" -#include "blendef.h" #ifdef HAVE_CONFIG_H #include <config.h> #endif +extern "C" { +#include "BKE_animsys.h" +#include "BKE_action.h" +#include "RNA_access.h" +#include "RNA_define.h" +} + BL_ActionActuator::~BL_ActionActuator() { if (m_pose) @@ -360,10 +367,31 @@ bool BL_ActionActuator::Update(double curtime, bool frame) /* Get the underlying pose from the armature */ obj->GetPose(&m_pose); - + +// 2.4x function, /* Override the necessary channels with ones from the action */ - extract_pose_from_action(m_pose, m_action, m_localtime); + // XXX extract_pose_from_action(m_pose, m_action, m_localtime); + + +// 2.5x - replacement for extract_pose_from_action(...) above. + { + struct PointerRNA id_ptr; + Object *arm= obj->GetArmatureObject(); + bPose *pose_back= arm->pose; + + arm->pose= m_pose; + RNA_id_pointer_create((ID *)arm, &id_ptr); + animsys_evaluate_action(&id_ptr, m_action, NULL, m_localtime); + + arm->pose= pose_back; + +// 2.5x - could also do this but looks too high level, constraints use this, it works ok. +// Object workob; /* evaluate using workob */ +// what_does_obaction((Scene *)obj->GetScene(), obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime); + } + // done getting the pose from the action + /* Perform the user override (if any) */ if (m_userpose){ extract_pose_from_pose(m_pose, m_userpose); @@ -381,7 +409,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) /* Find percentages */ newweight = (m_blendframe/(float)m_blendin); - blend_poses(m_pose, m_blendpose, 1.0 - newweight, ACTSTRIPMODE_BLEND); + game_blend_poses(m_pose, m_blendpose, 1.0 - newweight); /* Increment current blending percentage */ m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate(); @@ -408,367 +436,8 @@ bool BL_ActionActuator::Update(double curtime, bool frame) /* Python functions */ /* ------------------------------------------------------------------------- */ -/* setStart */ -const char BL_ActionActuator::GetAction_doc[] = -"getAction()\n" -"\tReturns a string containing the name of the current action.\n"; - -PyObject* BL_ActionActuator::PyGetAction(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getAction()", "the action property"); - - if (m_action){ - return PyString_FromString(m_action->id.name+2); - } - Py_RETURN_NONE; -} - -/* getProperty */ -const char BL_ActionActuator::GetProperty_doc[] = -"getProperty()\n" -"\tReturns the name of the property to be used in FromProp mode.\n"; - -PyObject* BL_ActionActuator::PyGetProperty(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getProperty()", "the property property"); - - PyObject *result; - - result = Py_BuildValue("s", (const char *)m_propname); - - return result; -} - -/* getProperty */ -const char BL_ActionActuator::GetFrameProperty_doc[] = -"getFrameProperty()\n" -"\tReturns the name of the property, that is set to the current frame number.\n"; - -PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getFrameProperty()", "the frameProperty property"); - - PyObject *result; - - result = Py_BuildValue("s", (const char *)m_framepropname); - - return result; -} - -/* getFrame */ -const char BL_ActionActuator::GetFrame_doc[] = -"getFrame()\n" -"\tReturns the current frame number.\n"; - -PyObject* BL_ActionActuator::PyGetFrame(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getFrame()", "the frame property"); - - PyObject *result; - - result = Py_BuildValue("f", m_localtime); - - return result; -} - -/* getEnd */ -const char BL_ActionActuator::GetEnd_doc[] = -"getEnd()\n" -"\tReturns the last frame of the action.\n"; - -PyObject* BL_ActionActuator::PyGetEnd(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getEnd()", "the end property"); - - PyObject *result; - - result = Py_BuildValue("f", m_endframe); - - return result; -} - -/* getStart */ -const char BL_ActionActuator::GetStart_doc[] = -"getStart()\n" -"\tReturns the starting frame of the action.\n"; - -PyObject* BL_ActionActuator::PyGetStart(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getStart()", "the start property"); - - PyObject *result; - - result = Py_BuildValue("f", m_startframe); - - return result; -} - -/* getBlendin */ -const char BL_ActionActuator::GetBlendin_doc[] = -"getBlendin()\n" -"\tReturns the number of interpolation animation frames to be\n" -"\tgenerated when this actuator is triggered.\n"; - -PyObject* BL_ActionActuator::PyGetBlendin(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getBlendin()", "the blendin property"); - - PyObject *result; - - result = Py_BuildValue("f", m_blendin); - - return result; -} - -/* getPriority */ -const char BL_ActionActuator::GetPriority_doc[] = -"getPriority()\n" -"\tReturns the priority for this actuator. Actuators with lower\n" -"\tPriority numbers will override actuators with higher numbers.\n"; - -PyObject* BL_ActionActuator::PyGetPriority(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("getPriority()", "the priority property"); - - PyObject *result; - - result = Py_BuildValue("i", m_priority); - - return result; -} - -/* setAction */ -const char BL_ActionActuator::SetAction_doc[] = -"setAction(action, (reset))\n" -"\t - action : The name of the action to set as the current action.\n" -"\t - reset : Optional parameter indicating whether to reset the\n" -"\t blend timer or not. A value of 1 indicates that the\n" -"\t timer should be reset. A value of 0 will leave it\n" -"\t unchanged. If reset is not specified, the timer will" -"\t be reset.\n"; - -PyObject* BL_ActionActuator::PySetAction(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setAction()", "the action property"); - - char *string; - int reset = 1; - - if (PyArg_ParseTuple(args,"s|i:setAction",&string, &reset)) - { - bAction *action; - - action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(STR_String(string)); - - if (!action){ - /* NOTE! Throw an exception or something */ - // printf ("setAction failed: Action not found\n", string); - } - else{ - m_action=action; - if (reset) - m_blendframe = 0; - } - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setStart */ -const char BL_ActionActuator::SetStart_doc[] = -"setStart(start)\n" -"\t - start : Specifies the starting frame of the animation.\n"; - -PyObject* BL_ActionActuator::PySetStart(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setStart()", "the start property"); - - float start; - - if (PyArg_ParseTuple(args,"f:setStart",&start)) - { - m_startframe = start; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setEnd */ -const char BL_ActionActuator::SetEnd_doc[] = -"setEnd(end)\n" -"\t - end : Specifies the ending frame of the animation.\n"; - -PyObject* BL_ActionActuator::PySetEnd(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setEnd()", "the end property"); - - float end; - - if (PyArg_ParseTuple(args,"f:setEnd",&end)) - { - m_endframe = end; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setBlendin */ -const char BL_ActionActuator::SetBlendin_doc[] = -"setBlendin(blendin)\n" -"\t - blendin : Specifies the number of frames of animation to generate\n" -"\t when making transitions between actions.\n"; - -PyObject* BL_ActionActuator::PySetBlendin(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setBlendin()", "the blendin property"); - - float blendin; - - if (PyArg_ParseTuple(args,"f:setBlendin",&blendin)) - { - m_blendin = blendin; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setBlendtime */ -const char BL_ActionActuator::SetBlendtime_doc[] = -"setBlendtime(blendtime)\n" -"\t - blendtime : Allows the script to directly modify the internal timer\n" -"\t used when generating transitions between actions. This\n" -"\t parameter must be in the range from 0.0 to 1.0.\n"; - -PyObject* BL_ActionActuator::PySetBlendtime(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setBlendtime()", "the blendtime property"); - - float blendframe; - - if (PyArg_ParseTuple(args,"f:setBlendtime",&blendframe)) - { - m_blendframe = blendframe * m_blendin; - if (m_blendframe<0) - m_blendframe = 0; - if (m_blendframe>m_blendin) - m_blendframe = m_blendin; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setPriority */ -const char BL_ActionActuator::SetPriority_doc[] = -"setPriority(priority)\n" -"\t - priority : Specifies the new priority. Actuators will lower\n" -"\t priority numbers will override actuators with higher\n" -"\t numbers.\n"; - -PyObject* BL_ActionActuator::PySetPriority(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setPriority()", "the priority property"); - - int priority; - - if (PyArg_ParseTuple(args,"i:setPriority",&priority)) - { - m_priority = priority; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setFrame */ -const char BL_ActionActuator::SetFrame_doc[] = -"setFrame(frame)\n" -"\t - frame : Specifies the new current frame for the animation\n"; - -PyObject* BL_ActionActuator::PySetFrame(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setFrame()", "the frame property"); - - float frame; - - if (PyArg_ParseTuple(args,"f:setFrame",&frame)) - { - m_localtime = frame; - if (m_localtime<m_startframe) - m_localtime=m_startframe; - else if (m_localtime>m_endframe) - m_localtime=m_endframe; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setProperty */ -const char BL_ActionActuator::SetProperty_doc[] = -"setProperty(prop)\n" -"\t - prop : A string specifying the property name to be used in\n" -"\t FromProp playback mode.\n"; - -PyObject* BL_ActionActuator::PySetProperty(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setProperty()", "the property property"); - - char *string; - - if (PyArg_ParseTuple(args,"s:setProperty",&string)) - { - m_propname = string; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setFrameProperty */ -const char BL_ActionActuator::SetFrameProperty_doc[] = -"setFrameProperty(prop)\n" -"\t - prop : A string specifying the property of the frame set up update.\n"; - -PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* args, - PyObject* kwds) { - ShowDeprecationWarning("setFrameProperty()", "the frameProperty property"); - - char *string; - - if (PyArg_ParseTuple(args,"s:setFrameProperty",&string)) - { - m_framepropname = string; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) { - char *string= PyString_AsString(value); + char *string= _PyUnicode_AsString(value); if (!string) { PyErr_SetString(PyExc_TypeError, "expected a single string"); @@ -821,72 +490,6 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) { */ } -/* getType */ -const char BL_ActionActuator::GetType_doc[] = -"getType()\n" -"\tReturns the operation mode of the actuator.\n"; -PyObject* BL_ActionActuator::PyGetType(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* args, - PyObject* kwds) { - ShowDeprecationWarning("setType()", "the type property"); - - short typeArg; - - if (!PyArg_ParseTuple(args, "h:setType", &typeArg)) { - return NULL; - } - - switch (typeArg) { - 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: - printf("Invalid type for action actuator: %d\n", typeArg); /* error */ - } - Py_RETURN_NONE; -} - -PyObject* BL_ActionActuator::PyGetContinue() { - ShowDeprecationWarning("getContinue()", "the continue property"); - - return PyInt_FromLong((long)(m_end_reset==0)); -} - -PyObject* BL_ActionActuator::PySetContinue(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" @@ -930,10 +533,10 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ game_copy_pose(&m_userpose, m_pose); } - //pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there. + // pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there. pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there. - if (pchan) { + if(pchan) { VECCOPY (pchan->loc, matrix[3]); Mat4ToSize(matrix, pchan->size); Mat4ToQuat(matrix, pchan->quat); @@ -942,9 +545,9 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, else { MT_Vector3 loc; MT_Vector3 size; - MT_Vector4 quat; + MT_Quaternion quat; - if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyVecTo(pyquat, quat)) + if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyQuatTo(pyquat, quat)) return NULL; // same as above @@ -953,14 +556,14 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ game_copy_pose(&m_userpose, m_pose); } - //pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there. - pchan= get_pose_channel(m_userpose, string); + // pchan= verify_pose_channel(m_userpose, string); + pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there. // for some reason loc.setValue(pchan->loc) fails if(pchan) { pchan->loc[0]= loc[0]; pchan->loc[1]= loc[1]; pchan->loc[2]= loc[2]; pchan->size[0]= size[0]; pchan->size[1]= size[1]; pchan->size[2]= size[2]; - pchan->quat[0]= quat[0]; pchan->quat[1]= quat[1]; pchan->quat[2]= quat[2]; pchan->quat[3]= quat[3]; + pchan->quat[0]= quat[3]; pchan->quat[1]= quat[0]; pchan->quat[2]= quat[1]; pchan->quat[3]= quat[2]; /* notice xyzw -> wxyz is intentional */ } } @@ -978,63 +581,29 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, /* ------------------------------------------------------------------------- */ PyTypeObject BL_ActionActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "BL_ActionActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0, - py_base_getattro, - py_base_setattro, - 0,0,0,0,0,0,0,0,0, - Methods -}; - -PyParentObject BL_ActionActuator::Parents[] = { - &BL_ActionActuator::Type, - &SCA_IActuator::Type, - &SCA_ILogicBrick::Type, - &CValue::Type, - NULL + "BL_ActionActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; 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}, - - {"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_O}, - {"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 }; @@ -1055,37 +624,24 @@ PyAttributeDef BL_ActionActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* BL_ActionActuator::py_getattro(PyObject *attr) { - py_getattro_up(SCA_IActuator); -} - -PyObject* BL_ActionActuator::py_getattro_dict() { - py_getattro_dict_up(SCA_IActuator); -} - -int BL_ActionActuator::py_setattro(PyObject *attr, PyObject* value) { - py_setattro_up(SCA_IActuator); -} - - PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); - return PyString_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); + return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); } int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); - if (!PyString_Check(value)) + if (!PyUnicode_Check(value)) { PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action"); return PY_SET_ATTR_FAIL; } bAction *action= NULL; - STR_String val = PyString_AsString(value); + STR_String val = _PyUnicode_AsString(value); if (val != "") { @@ -1113,7 +669,7 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA if(pose) { bPoseChannel *pchan; for(pchan= (bPoseChannel *)pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) { - item= PyString_FromString(pchan->name); + item= PyUnicode_FromString(pchan->name); PyList_Append(ret, item); Py_DECREF(item); } diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 088e7e3f4a8..a6b4c4a055d 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -49,9 +49,8 @@ public: short blendin, short priority, short end_reset, - float stride, - PyTypeObject* T=&Type) - : SCA_IActuator(gameobj,T), + float stride) + : SCA_IActuator(gameobj), m_lastpos(0, 0, 0), m_blendframe(0), @@ -85,38 +84,9 @@ public: bAction* GetAction() { return m_action; } void SetAction(bAction* act) { m_action= act; } - //Deprecated -----> - KX_PYMETHOD_DOC(BL_ActionActuator,SetAction); - KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendin); - KX_PYMETHOD_DOC(BL_ActionActuator,SetPriority); - KX_PYMETHOD_DOC(BL_ActionActuator,SetStart); - KX_PYMETHOD_DOC(BL_ActionActuator,SetEnd); - KX_PYMETHOD_DOC(BL_ActionActuator,SetFrame); - KX_PYMETHOD_DOC(BL_ActionActuator,SetProperty); - KX_PYMETHOD_DOC(BL_ActionActuator,SetFrameProperty); - KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendtime); - - KX_PYMETHOD_DOC(BL_ActionActuator,GetAction); - KX_PYMETHOD_DOC(BL_ActionActuator,GetBlendin); - KX_PYMETHOD_DOC(BL_ActionActuator,GetPriority); - KX_PYMETHOD_DOC(BL_ActionActuator,GetStart); - KX_PYMETHOD_DOC(BL_ActionActuator,GetEnd); - KX_PYMETHOD_DOC(BL_ActionActuator,GetFrame); - KX_PYMETHOD_DOC(BL_ActionActuator,GetProperty); - KX_PYMETHOD_DOC(BL_ActionActuator,GetFrameProperty); KX_PYMETHOD_O(BL_ActionActuator,GetChannel); - KX_PYMETHOD_DOC(BL_ActionActuator,GetType); - 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* py_getattro(PyObject* attr); - virtual PyObject* py_getattro_dict(); - virtual int py_setattro(PyObject* attr, PyObject* value); - static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index b00b493193d..cfd90813a16 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -38,6 +38,7 @@ #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "MT_Matrix4x4.h" @@ -48,17 +49,19 @@ BL_ArmatureObject::BL_ArmatureObject( void* sgReplicationInfo, SG_Callbacks callbacks, - Object *armature ) + Object *armature, + Scene *scene) : KX_GameObject(sgReplicationInfo,callbacks), m_objArma(armature), m_framePose(NULL), + m_scene(scene), // maybe remove later. needed for where_is_pose m_lastframe(0.0), m_activeAct(NULL), m_activePriority(999), m_lastapplyframe(0.0) { - m_armature = get_armature(m_objArma); + m_armature = (bArmature *)armature->data; /* we make a copy of blender object's pose, and then always swap it with * the original pose before calling into blender functions, to deal with @@ -93,9 +96,9 @@ void BL_ArmatureObject::ApplyPose() { m_armpose = m_objArma->pose; m_objArma->pose = m_pose; - + //m_scene->r.cfra++; if(m_lastapplyframe != m_lastframe) { - where_is_pose(m_objArma); + where_is_pose(m_scene, m_objArma); // XXX m_lastapplyframe = m_lastframe; } } diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index fdf961d5694..af0b7dc201c 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -51,7 +51,8 @@ public: BL_ArmatureObject( void* sgReplicationInfo, SG_Callbacks callbacks, - Object *armature + Object *armature, + Scene *scene ); virtual ~BL_ArmatureObject(); @@ -68,6 +69,7 @@ public: struct bArmature * GetArmature() { return m_armature; } const struct bArmature * GetArmature() const { return m_armature; } + const struct Scene * GetScene() const { return m_scene; } Object* GetArmatureObject() {return m_objArma;} @@ -85,11 +87,19 @@ protected: struct bPose *m_pose; struct bPose *m_armpose; struct bPose *m_framePose; + struct Scene *m_scene; // need for where_is_pose double m_lastframe; class BL_ActionActuator *m_activeAct; short m_activePriority; double m_lastapplyframe; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ArmatureObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index c2566caba1e..230820719aa 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -101,9 +101,6 @@ #include "KX_KetsjiEngine.h" #include "KX_BlenderSceneConverter.h" -#include"SND_Scene.h" -#include "SND_SoundListener.h" - /* This little block needed for linking to Blender... */ #ifdef WIN32 #include "BLI_winstuff.h" @@ -163,7 +160,6 @@ extern "C" { #include "SG_BBox.h" #include "SG_Tree.h" -// defines USE_ODE to choose physics engine #include "KX_ConvertPhysicsObject.h" #ifdef USE_BULLET #include "CcdPhysicsEnvironment.h" @@ -183,8 +179,8 @@ extern "C" { #ifdef __cplusplus extern "C" { #endif -#include "BSE_headerbuttons.h" -void update_for_newframe(); +//XXX #include "BSE_headerbuttons.h" +//XXX void update_for_newframe(); //void scene_update_for_newframe(struct Scene *sce, unsigned int lay); //#include "BKE_ipo.h" //void do_all_data_ipos(void); @@ -558,7 +554,7 @@ bool ConvertMaterial( material->ref = mat->ref; material->amb = mat->amb; - material->ras_mode |= (mat->mode & MA_WIRE)? WIRE: 0; + material->ras_mode |= (mat->material_type == MA_TYPE_WIRE)? WIRE: 0; } else { int valid = 0; @@ -627,7 +623,7 @@ bool ConvertMaterial( } // with ztransp enabled, enforce alpha blending mode - if(validmat && (mat->mode & MA_ZTRA) && (material->transp == TF_SOLID)) + if(validmat && (mat->mode & MA_TRANSP) && (mat->mode & MA_ZTRANSP) && (material->transp == TF_SOLID)) material->transp = TF_ALPHA; // always zsort alpha + add @@ -1609,18 +1605,6 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, break; #endif -#ifdef USE_SUMO_SOLID - case UseSumo: - KX_ConvertSumoObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop); - break; -#endif - -#ifdef USE_ODE - case UseODE: - KX_ConvertODEEngineObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop); - break; -#endif //USE_ODE - case UseDynamo: //KX_ConvertDynamoObject(gameobj,meshobj,kxscene,shapeprops, smmaterial, &objprop); break; @@ -1755,7 +1739,7 @@ static KX_GameObject *gameobject_from_blenderobject( if (bHasModifier) { BL_ModifierDeformer *dcont = new BL_ModifierDeformer((BL_DeformableGameObject *)gameobj, - ob, (BL_SkinMeshObject *)meshobj); + kxscene->GetBlenderScene(), ob, (BL_SkinMeshObject *)meshobj); ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont); if (bHasShapeKey && bHasArmature) dcont->LoadShapeDrivers(ob->parent); @@ -1793,7 +1777,8 @@ static KX_GameObject *gameobject_from_blenderobject( gameobj = new BL_ArmatureObject( kxscene, KX_Scene::m_callbacks, - ob // handle + ob, + kxscene->GetBlenderScene() // handle ); /* Get the current pose from the armature object and apply it as the rest pose */ break; @@ -1822,7 +1807,7 @@ struct parentChildLink { }; #include "DNA_constraint_types.h" -#include "BIF_editconstraint.h" +//XXX #include "BIF_editconstraint.h" bPoseChannel *get_active_posechannel2 (Object *ob) { @@ -1843,7 +1828,8 @@ ListBase *get_active_constraints2(Object *ob) if (!ob) return NULL; - if (ob->flag & OB_POSEMODE) { + // XXX - shouldnt we care about the pose data and not the mode??? + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; pchan = get_active_posechannel2(ob); @@ -1938,39 +1924,35 @@ void BL_ConvertBlenderObjects(struct Main* maggie, aspect_width = canvas->GetWidth(); aspect_height = canvas->GetHeight(); } else { - if (blenderscene->framing.type == SCE_GAMEFRAMING_BARS) { + if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_BARS) { frame_type = RAS_FrameSettings::e_frame_bars; - } else if (blenderscene->framing.type == SCE_GAMEFRAMING_EXTEND) { + } else if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_EXTEND) { frame_type = RAS_FrameSettings::e_frame_extend; } else { frame_type = RAS_FrameSettings::e_frame_scale; } - aspect_width = blenderscene->r.xsch; - aspect_height = blenderscene->r.ysch; + aspect_width = blenderscene->gm.xsch; + aspect_height = blenderscene->gm.ysch; } RAS_FrameSettings frame_settings( frame_type, - blenderscene->framing.col[0], - blenderscene->framing.col[1], - blenderscene->framing.col[2], + blenderscene->gm.framing.col[0], + blenderscene->gm.framing.col[1], + blenderscene->gm.framing.col[2], aspect_width, aspect_height ); kxscene->SetFramingType(frame_settings); - kxscene->SetGravity(MT_Vector3(0,0,(blenderscene->world != NULL) ? -blenderscene->world->gravity : -9.8)); + kxscene->SetGravity(MT_Vector3(0,0, -blenderscene->gm.gravity)); /* set activity culling parameters */ - if (blenderscene->world) { - kxscene->SetActivityCulling( (blenderscene->world->mode & WO_ACTIVITY_CULLING) != 0); - kxscene->SetActivityCullingRadius(blenderscene->world->activityBoxRadius); - kxscene->SetDbvtCulling((blenderscene->world->mode & WO_DBVT_CULLING) != 0); - } else { - kxscene->SetActivityCulling(false); - kxscene->SetDbvtCulling(false); - } + kxscene->SetActivityCulling( (blenderscene->gm.mode & WO_ACTIVITY_CULLING) != 0); + kxscene->SetActivityCullingRadius(blenderscene->gm.activityBoxRadius); + kxscene->SetDbvtCulling((blenderscene->gm.mode & WO_DBVT_CULLING) != 0); + // no occlusion culling by default kxscene->SetDbvtOcclusionRes(0); @@ -2039,7 +2021,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (converter->addInitFromFrame){//rcruiz float eulxyzPrev[3]; blenderscene->r.cfra=blenderscene->r.sfra-1; - update_for_newframe(); + //XXX update_for_newframe(); MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0], blenderobject->loc[1]+blenderobject->dloc[1], blenderobject->loc[2]+blenderobject->dloc[2] @@ -2057,7 +2039,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, tmp.scale(fps, fps, fps); iniang.push_back(tmp); blenderscene->r.cfra=blenderscene->r.sfra; - update_for_newframe(); + //XXX update_for_newframe(); } gameobj->NodeSetLocalPosition(pos); @@ -2230,7 +2212,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (converter->addInitFromFrame){//rcruiz float eulxyzPrev[3]; blenderscene->r.cfra=blenderscene->r.sfra-1; - update_for_newframe(); + //XXX update_for_newframe(); MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0], blenderobject->loc[1]+blenderobject->dloc[1], blenderobject->loc[2]+blenderobject->dloc[2] @@ -2248,7 +2230,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, tmp.scale(fps, fps, fps); iniang.push_back(tmp); blenderscene->r.cfra=blenderscene->r.sfra; - update_for_newframe(); + //XXX update_for_newframe(); } gameobj->NodeSetLocalPosition(pos); @@ -2451,7 +2433,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, case PARBONE: { // parent this to a bone - Bone *parent_bone = get_named_bone(get_armature(blenderchild->parent), blenderchild->parsubstr); + Bone *parent_bone = get_named_bone( (bArmature *)(blenderchild->parent)->data, blenderchild->parsubstr); if(parent_bone) { KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone); @@ -2505,10 +2487,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } } if (occlusion) - kxscene->SetDbvtOcclusionRes(blenderscene->world->occlusionRes); + kxscene->SetDbvtOcclusionRes(blenderscene->gm.occlusionRes); } if (blenderscene->world) - kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->world->physubstep); + kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->gm.physubstep); // now that the scenegraph is complete, let's instantiate the deformers. // We need that to create reusable derived mesh and physic shapes @@ -2637,23 +2619,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } } - sumolist->Release(); - - // convert global sound stuff - - /* XXX, glob is the very very wrong place for this - * to be, re-enable once the listener has been moved into - * the scene. */ -#if 1 - SND_Scene* soundscene = kxscene->GetSoundScene(); - SND_SoundListener* listener = soundscene->GetListener(); - if (listener && G.listener) - { - listener->SetDopplerFactor(G.listener->dopplerfactor); - listener->SetDopplerVelocity(G.listener->dopplervelocity); - listener->SetGain(G.listener->gain); - } -#endif + sumolist->Release(); // convert world KX_WorldInfo* worldinfo = new BlenderWorldInfo(blenderscene->world); diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index b20b8e81b37..ed329e7953d 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -45,7 +45,6 @@ struct Key; class BL_DeformableGameObject : public KX_GameObject { public: - CValue* GetReplica(); double GetLastFrame () @@ -100,6 +99,12 @@ protected: Object* m_blendobj; short m_activePriority; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_DeformableGameObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 289826e45e7..1749d438d21 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -85,6 +85,13 @@ protected: int m_tvtot; BL_DeformableGameObject* m_gameobj; double m_lastDeformUpdate; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_MeshDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index fe539f9a6c5..80165548ff2 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -48,6 +48,7 @@ #include "DNA_ipo_types.h" #include "DNA_curve_types.h" #include "DNA_modifier_types.h" +#include "DNA_scene_types.h" #include "BKE_armature.h" #include "BKE_action.h" #include "BKE_key.h" @@ -132,7 +133,7 @@ bool BL_ModifierDeformer::Update(void) Mesh *oldmesh = (Mesh*)blendobj->data; blendobj->data = m_bmesh; /* execute the modifiers */ - DerivedMesh *dm = mesh_create_derived_no_virtual(blendobj, m_transverts, CD_MASK_MESH); + DerivedMesh *dm = mesh_create_derived_no_virtual(m_scene, blendobj, m_transverts, CD_MASK_MESH); /* restore object data */ blendobj->data = oldmesh; /* free the current derived mesh and replace, (dm should never be NULL) */ diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h index d5a1caeb91f..5cc84c7d1e4 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.h +++ b/source/gameengine/Converter/BL_ModifierDeformer.h @@ -48,11 +48,13 @@ public: BL_ModifierDeformer(BL_DeformableGameObject *gameobj, + Scene *scene, Object *bmeshobj, BL_SkinMeshObject *mesh) : BL_ShapeDeformer(gameobj,bmeshobj, mesh), m_lastModifierUpdate(-1), + m_scene(scene), m_dm(NULL) { m_recalcNormal = false; @@ -60,6 +62,7 @@ public: /* this second constructor is needed for making a mesh deformable on the fly. */ BL_ModifierDeformer(BL_DeformableGameObject *gameobj, + struct Scene *scene, struct Object *bmeshobj_old, struct Object *bmeshobj_new, class BL_SkinMeshObject *mesh, @@ -68,6 +71,7 @@ public: : BL_ShapeDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, false, arma), m_lastModifierUpdate(-1), + m_scene(scene), m_dm(NULL) { }; @@ -94,8 +98,15 @@ public: protected: double m_lastModifierUpdate; + Scene *m_scene; DerivedMesh *m_dm; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ModifierDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index bf7edb5f641..81ce9ff6154 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -40,6 +40,8 @@ #include "STR_HashedString.h" #include "DNA_nla_types.h" #include "DNA_action_types.h" +#include "DNA_anim_types.h" +#include "DNA_scene_types.h" #include "BKE_action.h" #include "DNA_armature_types.h" #include "MEM_guardedalloc.h" @@ -49,7 +51,10 @@ #include "BKE_utildefines.h" #include "FloatValue.h" #include "PyObjectPlus.h" -#include "blendef.h" + +extern "C" { + #include "BKE_animsys.h" +} #ifdef HAVE_CONFIG_H #include <config.h> @@ -370,9 +375,12 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) m_blendstart = curtime; } // only interested in shape channel - extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime); - - if (!execute_ipochannels(&tchanbase)) { + + // in 2.4x was // extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime); + BKE_animsys_evaluate_animdata(&key->id, key->adt, m_localtime, ADT_RECALC_ANIM); + + // XXX - in 2.5 theres no way to do this. possibly not that important to support - Campbell + if (0) { // XXX !execute_ipochannels(&tchanbase)) { // no update, this is possible if action does not match the keys, stop the action keepgoing = false; } @@ -411,58 +419,29 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) /* Integration hooks ------------------------------------------------------- */ PyTypeObject BL_ShapeActionActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "BL_ShapeActionActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0, - py_base_getattro, - py_base_setattro, - 0,0,0,0,0,0,0,0,0, - Methods + "BL_ShapeActionActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; -PyParentObject BL_ShapeActionActuator::Parents[] = { - &BL_ShapeActionActuator::Type, - &SCA_IActuator::Type, - &SCA_ILogicBrick::Type, - &CValue::Type, - NULL -}; PyMethodDef BL_ShapeActionActuator::Methods[] = { - {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc}, - {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, - {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, - {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc}, - {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc}, - {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc}, - {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc}, - {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc}, - - {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, (PY_METHODCHAR)GetAction_doc}, - {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc}, - {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, (PY_METHODCHAR)GetEnd_doc}, - {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, (PY_METHODCHAR)GetBlendin_doc}, - {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, (PY_METHODCHAR)GetPriority_doc}, - {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, (PY_METHODCHAR)GetFrame_doc}, - {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, - {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, (PY_METHODCHAR)GetFrameProperty_doc}, - {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc}, - {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, (PY_METHODCHAR)SetType_doc}, {NULL,NULL} //Sentinel }; @@ -480,401 +459,24 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = { { NULL } //Sentinel }; - -PyObject* BL_ShapeActionActuator::py_getattro(PyObject* attr) { - py_getattro_up(SCA_IActuator); -} - -PyObject* BL_ShapeActionActuator::py_getattro_dict() { - py_getattro_dict_up(SCA_IActuator); -} - -int BL_ShapeActionActuator::py_setattro(PyObject *attr, PyObject* value) { - py_setattro_up(SCA_IActuator); -} - -/* setStart */ -const char BL_ShapeActionActuator::GetAction_doc[] = -"getAction()\n" -"\tReturns a string containing the name of the current action.\n"; - -PyObject* BL_ShapeActionActuator::PyGetAction() { - ShowDeprecationWarning("getAction()", "the action property"); - if (m_action){ - return PyString_FromString(m_action->id.name+2); - } - Py_RETURN_NONE; -} - -/* getProperty */ -const char BL_ShapeActionActuator::GetProperty_doc[] = -"getProperty()\n" -"\tReturns the name of the property to be used in FromProp mode.\n"; - -PyObject* BL_ShapeActionActuator::PyGetProperty() { - ShowDeprecationWarning("getProperty()", "the property property"); - PyObject *result; - - result = Py_BuildValue("s", (const char *)m_propname); - - return result; -} - -/* getFrame */ -const char BL_ShapeActionActuator::GetFrame_doc[] = -"getFrame()\n" -"\tReturns the current frame number.\n"; - -PyObject* BL_ShapeActionActuator::PyGetFrame() { - ShowDeprecationWarning("getFrame()", "the frame property"); - PyObject *result; - - result = Py_BuildValue("f", m_localtime); - - return result; -} - -/* getEnd */ -const char BL_ShapeActionActuator::GetEnd_doc[] = -"getEnd()\n" -"\tReturns the last frame of the action.\n"; - -PyObject* BL_ShapeActionActuator::PyGetEnd() { - ShowDeprecationWarning("getEnd()", "the end property"); - PyObject *result; - - result = Py_BuildValue("f", m_endframe); - - return result; -} - -/* getStart */ -const char BL_ShapeActionActuator::GetStart_doc[] = -"getStart()\n" -"\tReturns the starting frame of the action.\n"; - -PyObject* BL_ShapeActionActuator::PyGetStart() { - ShowDeprecationWarning("getStart()", "the start property"); - PyObject *result; - - result = Py_BuildValue("f", m_startframe); - - return result; -} - -/* getBlendin */ -const char BL_ShapeActionActuator::GetBlendin_doc[] = -"getBlendin()\n" -"\tReturns the number of interpolation animation frames to be\n" -"\tgenerated when this actuator is triggered.\n"; - -PyObject* BL_ShapeActionActuator::PyGetBlendin() { - ShowDeprecationWarning("getBlendin()", "the blendin property"); - PyObject *result; - - result = Py_BuildValue("f", m_blendin); - - return result; -} - -/* getPriority */ -const char BL_ShapeActionActuator::GetPriority_doc[] = -"getPriority()\n" -"\tReturns the priority for this actuator. Actuators with lower\n" -"\tPriority numbers will override actuators with higher numbers.\n"; - -PyObject* BL_ShapeActionActuator::PyGetPriority() { - ShowDeprecationWarning("getPriority()", "the priority property"); - PyObject *result; - - result = Py_BuildValue("i", m_priority); - - return result; -} - -/* setAction */ -const char BL_ShapeActionActuator::SetAction_doc[] = -"setAction(action, (reset))\n" -"\t - action : The name of the action to set as the current action.\n" -"\t Should be an action with Shape channels.\n" -"\t - reset : Optional parameter indicating whether to reset the\n" -"\t blend timer or not. A value of 1 indicates that the\n" -"\t timer should be reset. A value of 0 will leave it\n" -"\t unchanged. If reset is not specified, the timer will" -"\t be reset.\n"; - -PyObject* BL_ShapeActionActuator::PySetAction(PyObject* args) { - ShowDeprecationWarning("setAction()", "the action property"); - char *string; - int reset = 1; - - if (PyArg_ParseTuple(args,"s|i:setAction",&string, &reset)) - { - bAction *action; - - action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(STR_String(string)); - - if (!action){ - /* NOTE! Throw an exception or something */ - // printf ("setAction failed: Action not found\n", string); - } - else{ - m_action=action; - if (reset) - m_blendframe = 0.f; - } - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setStart */ -const char BL_ShapeActionActuator::SetStart_doc[] = -"setStart(start)\n" -"\t - start : Specifies the starting frame of the animation.\n"; - -PyObject* BL_ShapeActionActuator::PySetStart(PyObject* args) { - ShowDeprecationWarning("setStart()", "the start property"); - float start; - - if (PyArg_ParseTuple(args,"f:setStart",&start)) - { - m_startframe = start; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setEnd */ -const char BL_ShapeActionActuator::SetEnd_doc[] = -"setEnd(end)\n" -"\t - end : Specifies the ending frame of the animation.\n"; - -PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* args) { - ShowDeprecationWarning("setEnd()", "the end property"); - float end; - - if (PyArg_ParseTuple(args,"f:setEnd",&end)) - { - m_endframe = end; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setBlendin */ -const char BL_ShapeActionActuator::SetBlendin_doc[] = -"setBlendin(blendin)\n" -"\t - blendin : Specifies the number of frames of animation to generate\n" -"\t when making transitions between actions.\n"; - -PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* args) { - ShowDeprecationWarning("setBlendin()", "the blendin property"); - float blendin; - - if (PyArg_ParseTuple(args,"f:setBlendin",&blendin)) - { - m_blendin = blendin; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setBlendtime */ -const char BL_ShapeActionActuator::SetBlendtime_doc[] = -"setBlendtime(blendtime)\n" -"\t - blendtime : Allows the script to directly modify the internal timer\n" -"\t used when generating transitions between actions. This\n" -"\t parameter must be in the range from 0.0 to 1.0.\n"; - -PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* args) { - ShowDeprecationWarning("setBlendtime()", "the blendTime property"); - float blendframe; - - if (PyArg_ParseTuple(args,"f:setBlendtime",&blendframe)) - { - m_blendframe = blendframe * m_blendin; - if (m_blendframe<0.f) - m_blendframe = 0.f; - if (m_blendframe>m_blendin) - m_blendframe = m_blendin; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setPriority */ -const char BL_ShapeActionActuator::SetPriority_doc[] = -"setPriority(priority)\n" -"\t - priority : Specifies the new priority. Actuators will lower\n" -"\t priority numbers will override actuators with higher\n" -"\t numbers.\n"; - -PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* args) { - ShowDeprecationWarning("setPriority()", "the priority property"); - int priority; - - if (PyArg_ParseTuple(args,"i:setPriority",&priority)) - { - m_priority = priority; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* getProperty */ -const char BL_ShapeActionActuator::GetFrameProperty_doc[] = -"getFrameProperty()\n" -"\tReturns the name of the property, that is set to the current frame number.\n"; - -PyObject* BL_ShapeActionActuator::PyGetFrameProperty() { - ShowDeprecationWarning("getFrameProperty()", "the frameProperty property"); - PyObject *result; - - result = Py_BuildValue("s", (const char *)m_framepropname); - - return result; -} - - -/* setFrame */ -const char BL_ShapeActionActuator::SetFrame_doc[] = -"setFrame(frame)\n" -"\t - frame : Specifies the new current frame for the animation\n"; - -PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* args) { - ShowDeprecationWarning("setFrame()", "the frame property"); - float frame; - - if (PyArg_ParseTuple(args,"f:setFrame",&frame)) - { - m_localtime = frame; - if (m_localtime<m_startframe) - m_localtime=m_startframe; - else if (m_localtime>m_endframe) - m_localtime=m_endframe; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setProperty */ -const char BL_ShapeActionActuator::SetProperty_doc[] = -"setProperty(prop)\n" -"\t - prop : A string specifying the property name to be used in\n" -"\t FromProp playback mode.\n"; - -PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* args) { - ShowDeprecationWarning("setProperty()", "the property property"); - char *string; - - if (PyArg_ParseTuple(args,"s:setProperty",&string)) - { - m_propname = string; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* setFrameProperty */ -const char BL_ShapeActionActuator::SetFrameProperty_doc[] = -"setFrameProperty(prop)\n" -"\t - prop : A string specifying the property of the frame set up update.\n"; - -PyObject* BL_ShapeActionActuator::PySetFrameProperty(PyObject* args) { - ShowDeprecationWarning("setFrameProperty()", "the frameProperty property"); - char *string; - - if (PyArg_ParseTuple(args,"s:setFrameProperty",&string)) - { - m_framepropname = string; - } - else { - return NULL; - } - - Py_RETURN_NONE; -} - -/* getType */ -const char BL_ShapeActionActuator::GetType_doc[] = -"getType()\n" -"\tReturns the operation mode of the actuator.\n"; -PyObject* BL_ShapeActionActuator::PyGetType() { - ShowDeprecationWarning("getType()", "the type property"); - return Py_BuildValue("h", m_playtype); -} - -/* setType */ -const char BL_ShapeActionActuator::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_ShapeActionActuator::PySetType(PyObject* args) { - ShowDeprecationWarning("setType()", "the type property"); - short typeArg; - - if (!PyArg_ParseTuple(args, "h:setType", &typeArg)) { - return NULL; - } - - switch (typeArg) { - 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: - printf("Invalid type for action actuator: %d\n", typeArg); /* error */ - } - - Py_RETURN_NONE; -} - PyObject* BL_ShapeActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v); - return PyString_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); + return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); } int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v); /* exact copy of BL_ActionActuator's function from here down */ - if (!PyString_Check(value)) + if (!PyUnicode_Check(value)) { PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, expected the string name of the action"); return PY_SET_ATTR_FAIL; } bAction *action= NULL; - STR_String val = PyString_AsString(value); + STR_String val = _PyUnicode_AsString(value); if (val != "") { diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index d268eef6d23..28a6d90abdf 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -50,9 +50,8 @@ public: short playtype, short blendin, short priority, - float stride, - PyTypeObject* T=&Type) - : SCA_IActuator(gameobj,T), + float stride) + : SCA_IActuator(gameobj), m_lastpos(0, 0, 0), m_blendframe(0), @@ -83,33 +82,6 @@ public: bAction* GetAction() { return m_action; } void SetAction(bAction* act) { m_action= act; } - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetAction); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetBlendin); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetPriority); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetStart); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetEnd); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetFrame); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetProperty); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetFrameProperty); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetBlendtime); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetChannel); - - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetAction); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetBlendin); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetPriority); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetStart); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetEnd); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrame); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetProperty); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrameProperty); -// KX_PYMETHOD(BL_ActionActuator,GetChannel); - KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType); - KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetType); - - virtual PyObject* py_getattro(PyObject* attr); - virtual PyObject* py_getattro_dict(); - virtual int py_setattro(PyObject* attr, PyObject* value); - static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 12ef3ff84f1..20ca7f07f2b 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -109,8 +109,8 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void) { if (!m_shapeDrivers.empty() && PoseUpdated()) { vector<IpoCurve*>::iterator it; - void *poin; - int type; +// void *poin; +// int type; // the shape drivers use the bone matrix as input. Must // update the matrix now @@ -118,11 +118,11 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void) for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) { // no need to set a specific time: this curve has a driver - IpoCurve *icu = *it; - calc_icu(icu, 1.0f); - poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type); - if (poin) - write_ipo_poin(poin, type, icu->curval); + // XXX IpoCurve *icu = *it; + //calc_icu(icu, 1.0f); + //poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type); + //if (poin) + // write_ipo_poin(poin, type, icu->curval); } ForceUpdate(); diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 949e5e1e3ad..ca3770d4006 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -83,6 +83,12 @@ protected: vector<IpoCurve*> m_shapeDrivers; double m_lastShapeUpdate; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ShapeDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 7c43246a9d7..b83895d5609 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -105,6 +105,12 @@ protected: bool m_poseApplied; bool m_recalcNormal; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_SkinDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h index e2d0e37664d..838c6c3cb95 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.h +++ b/source/gameengine/Converter/BL_SkinMeshObject.h @@ -54,6 +54,13 @@ public: // for shape keys, void CheckWeightCache(struct Object* obj); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_SkinMeshObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index fd6bb0212b7..7ccb96e4683 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -94,6 +94,13 @@ public: setMistColorBlue( float d ); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BlenderWorldInfo"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__BLENDERWORLDINFO_H diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 217bdb30907..f16e9e169ab 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -32,12 +32,7 @@ SET(INC ../../../intern/string ../../../intern/guardedalloc ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../intern/bmfont - ../../../intern/SoundSystem - ../../../intern/SoundSystem/include - ../../../intern/SoundSystem/openal - ../../../intern/SoundSystem/dummy - ../../../intern/SoundSystem/intern + ../../../intern/audaspace/intern ../../../source/gameengine/Converter ../../../source/gameengine/BlenderRoutines ../../../source/blender/imbuf @@ -46,9 +41,11 @@ SET(INC ../../../source/gameengine/Ketsji/KXNetwork ../../../source/blender/blenlib ../../../source/blender/blenkernel + ../../../source/blender/windowmanager ../../../source/blender ../../../source/blender/include ../../../source/blender/makesdna + ../../../source/blender/makesrna ../../../source/gameengine/Rasterizer ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer ../../../source/gameengine/GameLogic @@ -57,16 +54,12 @@ SET(INC ../../../source/gameengine/SceneGraph ../../../source/gameengine/Physics/common ../../../source/gameengine/Physics/Bullet - ../../../source/gameengine/Physics/BlOde ../../../source/gameengine/Physics/Dummy - ../../../source/gameengine/Physics/Sumo - ../../../source/gameengine/Physics/Sumo/Fuzzics/include ../../../source/gameengine/Network/LoopBackNetwork ../../../source/blender/misc ../../../source/blender/blenloader ../../../source/blender/gpu ../../../extern/bullet2/src - ../../../extern/solid ${PYTHON_INC} ) diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp index 4d79febb7b4..24910422176 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp @@ -28,32 +28,30 @@ #include "KX_BlenderScalarInterpolator.h" +#include <cstring> + extern "C" { #include "DNA_ipo_types.h" -#include "BKE_ipo.h" +#include "DNA_action_types.h" +#include "DNA_anim_types.h" +#include "BKE_fcurve.h" } -static const int BL_MAX_CHANNELS = 32; - float BL_ScalarInterpolator::GetValue(float currentTime) const { - return IPO_GetFloatValue(m_blender_ipo, m_channel, currentTime); + // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime); + return evaluate_fcurve(m_fcu, currentTime); } - - -BL_InterpolatorList::BL_InterpolatorList(struct Ipo *ipo) { - IPO_Channel channels[BL_MAX_CHANNELS]; - - int num_channels = IPO_GetChannels(ipo, channels); - - int i; - - for (i = 0; i != num_channels; ++i) { - BL_ScalarInterpolator *new_ipo = - new BL_ScalarInterpolator(ipo, channels[i]); - - //assert(new_ipo); - push_back(new_ipo); +BL_InterpolatorList::BL_InterpolatorList(struct AnimData *adt) { + if(adt->action==NULL) + return; + + for(FCurve *fcu= (FCurve *)adt->action->curves.first; fcu; fcu= (FCurve *)fcu->next) { + if(fcu->rna_path) { + BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu); + //assert(new_ipo); + push_back(new_ipo); + } } } @@ -64,15 +62,13 @@ BL_InterpolatorList::~BL_InterpolatorList() { } } - -KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(BL_IpoChannel channel) { - BL_InterpolatorList::iterator i = begin(); - while (!(i == end()) && - (static_cast<BL_ScalarInterpolator *>(*i))->GetChannel() != - channel) { - ++i; +KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index) { + for(BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ ) + { + FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve(); + if(array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0) + return *i; } - - return (i == end()) ? 0 : *i; + return NULL; } diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h index 94d15aff6be..e7fbb8083e4 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h @@ -38,29 +38,40 @@ typedef unsigned short BL_IpoChannel; class BL_ScalarInterpolator : public KX_IScalarInterpolator { public: BL_ScalarInterpolator() {} // required for use in STL list - BL_ScalarInterpolator(struct Ipo *ipo, BL_IpoChannel channel) : - m_blender_ipo(ipo), - m_channel(channel) + BL_ScalarInterpolator(struct FCurve* fcu) : + m_fcu(fcu) {} virtual ~BL_ScalarInterpolator() {} virtual float GetValue(float currentTime) const; - - BL_IpoChannel GetChannel() const { return m_channel; } + struct FCurve *GetFCurve() { return m_fcu;}; private: - struct Ipo *m_blender_ipo; - BL_IpoChannel m_channel; + struct FCurve *m_fcu; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ScalarInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; class BL_InterpolatorList : public std::vector<KX_IScalarInterpolator *> { public: - BL_InterpolatorList(struct Ipo *ipo); + BL_InterpolatorList(struct AnimData *adt); ~BL_InterpolatorList(); - KX_IScalarInterpolator *GetScalarInterpolator(BL_IpoChannel channel); + KX_IScalarInterpolator *GetScalarInterpolator(const char *rna_path, int array_index); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_InterpolatorList"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_SCALARINTERPOLATOR_H diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 4f47ce7a036..151564391f3 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -44,21 +44,12 @@ #include "DummyPhysicsEnvironment.h" -//to decide to use sumo/ode or dummy physics - defines USE_ODE #include "KX_ConvertPhysicsObject.h" #ifdef USE_BULLET #include "CcdPhysicsEnvironment.h" #endif -#ifdef USE_ODE -#include "OdePhysicsEnvironment.h" -#endif //USE_ODE - -#ifdef USE_SUMO_SOLID -#include "SumoPhysicsEnvironment.h" -#endif - #include "KX_BlenderSceneConverter.h" #include "KX_BlenderScalarInterpolator.h" #include "BL_BlenderDataConversion.h" @@ -83,8 +74,8 @@ extern "C" #include "DNA_curve_types.h" #include "BLI_blenlib.h" #include "MEM_guardedalloc.h" -#include "BSE_editipo.h" -#include "BSE_editipo_types.h" +//XXX #include "BSE_editipo.h" +//XXX #include "BSE_editipo_types.h" #include "DNA_ipo_types.h" #include "BKE_global.h" #include "BKE_ipo.h" // eval_icu @@ -113,11 +104,11 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() // delete sumoshapes - int numipolists = m_map_blender_to_gameipolist.size(); - for (i=0; i<numipolists; i++) { - BL_InterpolatorList *ipoList= *m_map_blender_to_gameipolist.at(i); + int numAdtLists = m_map_blender_to_gameAdtList.size(); + for (i=0; i<numAdtLists; i++) { + BL_InterpolatorList *adtList= *m_map_blender_to_gameAdtList.at(i); - delete (ipoList); + delete (adtList); } vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator itw = m_worldinfos.begin(); @@ -145,10 +136,6 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() delete (*itm).second; itm++; } - -#ifdef USE_SUMO_SOLID - KX_ClearSumoSharedShapes(); -#endif #ifdef USE_BULLET KX_ClearBulletSharedShapes(); @@ -273,38 +260,34 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, if (blenderscene) { - if (blenderscene->world) + switch (blenderscene->gm.physicsEngine) { - switch (blenderscene->world->physicsEngine) + case WOPHY_BULLET: { - case WOPHY_BULLET: - { - physics_engine = UseBullet; - useDbvtCulling = (blenderscene->world->mode & WO_DBVT_CULLING) != 0; - break; - } - - case WOPHY_ODE: - { - physics_engine = UseODE; - break; - } - case WOPHY_DYNAMO: - { - physics_engine = UseDynamo; - break; - } - case WOPHY_SUMO: - { - physics_engine = UseSumo; - break; - } - case WOPHY_NONE: - { - physics_engine = UseNone; - } + physics_engine = UseBullet; + useDbvtCulling = (blenderscene->gm.mode & WO_DBVT_CULLING) != 0; + break; + } + + case WOPHY_ODE: + { + physics_engine = UseODE; + break; + } + case WOPHY_DYNAMO: + { + physics_engine = UseDynamo; + break; + } + case WOPHY_SUMO: + { + physics_engine = UseSumo; + break; + } + case WOPHY_NONE: + { + physics_engine = UseNone; } - } } @@ -329,20 +312,7 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, destinationscene->SetPhysicsEnvironment(ccdPhysEnv); break; } -#endif - -#ifdef USE_SUMO_SOLID - case UseSumo: - destinationscene ->SetPhysicsEnvironment(new SumoPhysicsEnvironment()); - break; -#endif -#ifdef USE_ODE - - case UseODE: - destinationscene ->SetPhysicsEnvironment(new ODEPhysicsEnvironment()); - break; -#endif //USE_ODE - +#endif case UseDynamo: { } @@ -554,18 +524,18 @@ void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat) void KX_BlenderSceneConverter::RegisterInterpolatorList( - BL_InterpolatorList *ipoList, - struct Ipo *for_ipo) + BL_InterpolatorList *adtList, + struct AnimData *for_adt) { - m_map_blender_to_gameipolist.insert(CHashedPtr(for_ipo), ipoList); + m_map_blender_to_gameAdtList.insert(CHashedPtr(for_adt), adtList); } BL_InterpolatorList *KX_BlenderSceneConverter::FindInterpolatorList( - struct Ipo *for_ipo) + struct AnimData *for_adt) { - BL_InterpolatorList **listp = m_map_blender_to_gameipolist[CHashedPtr(for_ipo)]; + BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_adt)]; return listp?*listp:NULL; } @@ -620,8 +590,9 @@ void KX_BlenderSceneConverter::RegisterWorldInfo( * When deleting an IPO curve from Python, check if the IPO is being * edited and if so clear the pointer to the old curve. */ -void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu) +void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu ) { +#if 0 //XXX if (!G.sipo) return; @@ -636,15 +607,16 @@ void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu) return; } } +#endif } //quick hack extern "C" { Ipo *add_ipo( char *name, int idcode ); - char *getIpoCurveName( IpoCurve * icu ); - struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int, short); - void testhandles_ipocurve(struct IpoCurve *icu); + //XXX char *getIpoCurveName( IpoCurve * icu ); + //XXX struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int); + //XXX void testhandles_ipocurve(struct IpoCurve *icu); void insert_vert_icu(struct IpoCurve *, float, float, short); float eval_icu(struct IpoCurve *icu, float ipotime); //void Mat3ToEul(float tmat[][3], float *eul); @@ -656,11 +628,11 @@ IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName) IpoCurve* icu1; for( icu1 = first; icu1; icu1 = icu1->next ) { - char* curveName = getIpoCurveName( icu1 ); + /*XXX char* curveName = getIpoCurveName( icu1 ); if( !strcmp( curveName, searchName) ) { return icu1; - } + }*/ } return 0; } @@ -734,7 +706,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) } } } else - { ipo = add_ipo(blenderObject->id.name+2, ID_OB); + { ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB); blenderObject->ipo = ipo; } @@ -823,6 +795,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->ipo) { +#if 0 const MT_Point3& position = gameObj->NodeGetWorldPosition(); //const MT_Vector3& scale = gameObj->NodeGetWorldScaling(); const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation(); @@ -831,6 +804,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f}; float tmat[3][3]; + // XXX animato Ipo* ipo = blenderObject->ipo; //create the curves, if not existing, set linear if new @@ -891,6 +865,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1); // Handles are corrected at the end, testhandles_ipocurve isnt needed yet +#endif } } } @@ -921,6 +896,8 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->ipo) { + // XXX animato +#if 0 Ipo* ipo = blenderObject->ipo; //create the curves, if not existing @@ -931,6 +908,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotX")); testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotY")); testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ")); +#endif } } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index e8a958a310a..bb87a21a683 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -61,7 +61,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter GEN_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator; /* cleared after conversion */ GEN_Map<CHashedPtr,SCA_IController*>m_map_blender_to_gamecontroller; /* cleared after conversion */ - GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameipolist; /* kept, should be freed, TODO */ + GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameAdtList; Main* m_maggie; @@ -111,8 +111,8 @@ public: void RegisterBlenderMaterial(BL_Material *mat); - void RegisterInterpolatorList(BL_InterpolatorList *ipoList, struct Ipo *for_ipo); - BL_InterpolatorList *FindInterpolatorList(struct Ipo *for_ipo); + void RegisterInterpolatorList(BL_InterpolatorList *adtList, struct AnimData *for_adt); + BL_InterpolatorList *FindInterpolatorList(struct AnimData *for_adt); void RegisterGameActuator(SCA_IActuator *act, struct bActuator *for_actuator); SCA_IActuator *FindGameActuator(struct bActuator *for_actuator); @@ -143,6 +143,12 @@ public: struct Main* GetMain() { return m_maggie; }; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderSceneConverter"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_BLENDERSCENECONVERTER_H diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index c18e4fce8a5..91a39bd7686 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -38,7 +38,7 @@ #include "KX_BlenderSceneConverter.h" #include "KX_ConvertActuators.h" -#include "SND_Scene.h" +#include "AUD_C-API.h" // Actuators //SCA logiclibrary native logicbricks #include "SCA_PropertyActuator.h" @@ -50,7 +50,6 @@ #include "KX_SceneActuator.h" #include "KX_IpoActuator.h" #include "KX_SoundActuator.h" -#include "KX_CDActuator.h" #include "KX_ObjectActuator.h" #include "KX_TrackToActuator.h" #include "KX_ConstraintActuator.h" @@ -347,8 +346,7 @@ void BL_ConvertActuators(char* maggiename, { bSoundActuator* soundact = (bSoundActuator*) bact->data; /* get type, and possibly a start and end frame */ - short startFrame = soundact->sta, stopFrame = soundact->end; - KX_SoundActuator::KX_SOUNDACT_TYPE + KX_SoundActuator::KX_SOUNDACT_TYPE soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF; switch(soundact->type) { @@ -378,173 +376,38 @@ void BL_ConvertActuators(char* maggiename, if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF) { - SND_Scene* soundscene = scene->GetSoundScene(); - STR_String samplename = ""; - bool sampleisloaded = false; - - if (soundact->sound) { - /* Need to convert the samplename into absolute path - * before checking if its loaded */ - char fullpath[FILE_MAX]; - - /* dont modify soundact->sound->name, only change a copy */ - BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath)); - BLI_convertstringcode(fullpath, maggiename); - samplename = fullpath; - - /* let's see if the sample was already loaded */ - if (soundscene->IsSampleLoaded(samplename)) - { - sampleisloaded = true; - } - else { - /* if not, make it so */ - PackedFile* pf = soundact->sound->newpackedfile; - - /* but we need a packed file then */ - if (pf) - { - if (soundscene->LoadSample(samplename, pf->data, pf->size) > -1) - sampleisloaded = true; - } - /* or else load it from disk */ - else - { - if (soundscene->LoadSample(samplename, NULL, 0) > -1) { - sampleisloaded = true; - } - else { - std::cout << "WARNING: Sound actuator \"" << bact->name << - "\" from object \"" << blenderobject->id.name+2 << - "\" failed to load sample." << std::endl; - } - } - } - } else { + bSound* sound = soundact->sound; + bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false; + AUD_Sound* snd_sound = NULL; + KX_3DSoundSettings settings; + settings.cone_inner_angle = soundact->sound3D.cone_inner_angle; + settings.cone_outer_angle = soundact->sound3D.cone_outer_angle; + settings.cone_outer_gain = soundact->sound3D.cone_outer_gain; + settings.max_distance = soundact->sound3D.max_distance; + settings.max_gain = soundact->sound3D.max_gain; + settings.min_gain = soundact->sound3D.min_gain; + settings.reference_distance = soundact->sound3D.reference_distance; + settings.rolloff_factor = soundact->sound3D.rolloff_factor; + + if(!sound) + { std::cout << "WARNING: Sound actuator \"" << bact->name << "\" from object \"" << blenderobject->id.name+2 << "\" has no sound datablock." << std::endl; } - - /* Note, allowing actuators for sounds that are not there was added since 2.47 - * This is because python may expect the actuator and raise an exception if it dosnt find it - * better just to add a dummy sound actuator. */ - SND_SoundObject* sndobj = NULL; - if (sampleisloaded) - { - /* setup the SND_SoundObject */ - sndobj = new SND_SoundObject(); - sndobj->SetSampleName(samplename.Ptr()); - sndobj->SetObjectName(bact->name); - if (soundact->sound) { - sndobj->SetRollOffFactor(soundact->sound->attenuation); - sndobj->SetGain(soundact->sound->volume); - sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0))); - // sndobj->SetLoopStart(soundact->sound->loopstart); - // sndobj->SetLoopStart(soundact->sound->loopend); - if (soundact->sound->flags & SOUND_FLAGS_LOOP) - { - if (soundact->sound->flags & SOUND_FLAGS_BIDIRECTIONAL_LOOP) - sndobj->SetLoopMode(SND_LOOP_BIDIRECTIONAL); - else - sndobj->SetLoopMode(SND_LOOP_NORMAL); - } - else { - sndobj->SetLoopMode(SND_LOOP_OFF); - } - - if (soundact->sound->flags & SOUND_FLAGS_PRIORITY) - sndobj->SetHighPriority(true); - else - sndobj->SetHighPriority(false); - - if (soundact->sound->flags & SOUND_FLAGS_3D) - sndobj->Set3D(true); - else - sndobj->Set3D(false); - } - else { - /* dummy values for a NULL sound - * see editsound.c - defaults are unlikely to change soon */ - sndobj->SetRollOffFactor(1.0); - sndobj->SetGain(1.0); - sndobj->SetPitch(1.0); - sndobj->SetLoopMode(SND_LOOP_OFF); - sndobj->SetHighPriority(false); - sndobj->Set3D(false); - } - } - KX_SoundActuator* tmpsoundact = - new KX_SoundActuator(gameobj, - sndobj, - scene->GetSoundScene(), // needed for replication! - soundActuatorType, - startFrame, - stopFrame); - + else + snd_sound = sound->cache ? sound->cache : sound->handle; + KX_SoundActuator* tmpsoundact = + new KX_SoundActuator(gameobj, + snd_sound, + soundact->volume, + exp((soundact->pitch / 12.0) * log(2.0)), + is3d, + settings, + soundActuatorType); + tmpsoundact->SetName(bact->name); baseact = tmpsoundact; - if (sndobj) - soundscene->AddObject(sndobj); - } - break; - } - case ACT_CD: - { - bCDActuator* cdact = (bCDActuator*) bact->data; - /* get type, and possibly a start and end frame */ - short startFrame = cdact->sta, stopFrame = cdact->end; - KX_CDActuator::KX_CDACT_TYPE - cdActuatorType = KX_CDActuator::KX_CDACT_NODEF; - - switch(cdact->type) - { - case ACT_CD_PLAY_ALL: - cdActuatorType = KX_CDActuator::KX_CDACT_PLAY_ALL; - break; - case ACT_CD_PLAY_TRACK: - cdActuatorType = KX_CDActuator::KX_CDACT_PLAY_TRACK; - break; - case ACT_CD_LOOP_TRACK: - cdActuatorType = KX_CDActuator::KX_CDACT_LOOP_TRACK; - break; - case ACT_CD_VOLUME: - cdActuatorType = KX_CDActuator::KX_CDACT_VOLUME; - break; - case ACT_CD_STOP: - cdActuatorType = KX_CDActuator::KX_CDACT_STOP; - break; - case ACT_CD_PAUSE: - cdActuatorType = KX_CDActuator::KX_CDACT_PAUSE; - break; - case ACT_CD_RESUME: - cdActuatorType = KX_CDActuator::KX_CDACT_RESUME; - break; - - default: - /* This is an error!!! */ - cdActuatorType = KX_CDActuator::KX_CDACT_NODEF; - } - - if (cdActuatorType != KX_CDActuator::KX_CDACT_NODEF) - { - SND_CDObject* pCD = SND_CDObject::Instance(); - - if (pCD) - { - pCD->SetGain(cdact->volume); - - KX_CDActuator* tmpcdact = - new KX_CDActuator(gameobj, - scene->GetSoundScene(), // needed for replication! - cdActuatorType, - cdact->track, - startFrame, - stopFrame); - - tmpcdact->SetName(bact->name); - baseact = tmpcdact; - } } break; } diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index e9984ee0525..5e8d6f3cbf0 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -66,58 +66,58 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan show_debug_info = bool (prop->flag & PROP_DEBUG); switch(prop->type) { - case PROP_BOOL: - { - propval = new CBoolValue((bool)(prop->data != 0)); - gameobj->SetProperty(prop->name,propval); - //promp->poin= &prop->data; - break; - } - case PROP_INT: - { - propval = new CIntValue((int)prop->data); - gameobj->SetProperty(prop->name,propval); - break; - } - case PROP_FLOAT: - { - //prop->poin= &prop->data; - float floatprop = *((float*)&prop->data); - propval = new CFloatValue(floatprop); - gameobj->SetProperty(prop->name,propval); - } - break; - case PROP_STRING: - { - //prop->poin= callocN(MAX_PROPSTRING, "property string"); - propval = new CStringValue((char*)prop->poin,""); - gameobj->SetProperty(prop->name,propval); + case GPROP_BOOL: + { + propval = new CBoolValue((bool)(prop->data != 0)); + gameobj->SetProperty(prop->name,propval); + //promp->poin= &prop->data; + break; + } + case GPROP_INT: + { + propval = new CIntValue((int)prop->data); + gameobj->SetProperty(prop->name,propval); + break; + } + case GPROP_FLOAT: + { + //prop->poin= &prop->data; + float floatprop = *((float*)&prop->data); + propval = new CFloatValue(floatprop); + gameobj->SetProperty(prop->name,propval); + } break; - } - case PROP_TIME: - { - float floatprop = *((float*)&prop->data); - - CValue* timeval = new CFloatValue(floatprop); - // set a subproperty called 'timer' so that - // we can register the replica of this property - // at the time a game object is replicated (AddObjectActuator triggers this) - CValue *bval = new CBoolValue(true); - timeval->SetProperty("timer",bval); - bval->Release(); - if (isInActiveLayer) + case GPROP_STRING: { - timemgr->AddTimeProperty(timeval); + //prop->poin= callocN(MAX_PROPSTRING, "property string"); + propval = new CStringValue((char*)prop->poin,""); + gameobj->SetProperty(prop->name,propval); + break; } - - propval = timeval; - gameobj->SetProperty(prop->name,timeval); + case GPROP_TIME: + { + float floatprop = *((float*)&prop->data); - } - default: - { - // todo make an assert etc. - } + CValue* timeval = new CFloatValue(floatprop); + // set a subproperty called 'timer' so that + // we can register the replica of this property + // at the time a game object is replicated (AddObjectActuator triggers this) + CValue *bval = new CBoolValue(true); + timeval->SetProperty("timer",bval); + bval->Release(); + if (isInActiveLayer) + { + timemgr->AddTimeProperty(timeval); + } + + propval = timeval; + gameobj->SetProperty(prop->name,timeval); + + } + default: + { + // todo make an assert etc. + } } if (propval) diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index a628881058a..09027f18844 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -37,6 +37,7 @@ #pragma warning (disable : 4786) #endif //WIN32 +#include "wm_event_types.h" #include "KX_BlenderSceneConverter.h" #include "KX_ConvertSensors.h" @@ -121,10 +122,11 @@ void BL_ConvertSensors(struct Object* blenderobject, gReverseKeyTranslateTable[TIMER0 ] = SCA_IInputDevice::KX_TIMER0; gReverseKeyTranslateTable[TIMER1 ] = SCA_IInputDevice::KX_TIMER1; gReverseKeyTranslateTable[TIMER2 ] = SCA_IInputDevice::KX_TIMER2; - gReverseKeyTranslateTable[TIMER3 ] = SCA_IInputDevice::KX_TIMER3; // SYSTEM +#if 0 + /* **** XXX **** */ gReverseKeyTranslateTable[KEYBD ] = SCA_IInputDevice::KX_KEYBD; gReverseKeyTranslateTable[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD; gReverseKeyTranslateTable[REDRAW ] = SCA_IInputDevice::KX_REDRAW; @@ -135,6 +137,8 @@ void BL_ConvertSensors(struct Object* blenderobject, gReverseKeyTranslateTable[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE; gReverseKeyTranslateTable[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT; gReverseKeyTranslateTable[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME; + /* **** XXX **** */ +#endif // standard keyboard @@ -145,7 +149,17 @@ void BL_ConvertSensors(struct Object* blenderobject, gReverseKeyTranslateTable[EKEY ] = SCA_IInputDevice::KX_EKEY; gReverseKeyTranslateTable[FKEY ] = SCA_IInputDevice::KX_FKEY; gReverseKeyTranslateTable[GKEY ] = SCA_IInputDevice::KX_GKEY; + +//XXX clean up +#ifdef WIN32 +#define HKEY 'h' +#endif gReverseKeyTranslateTable[HKEY ] = SCA_IInputDevice::KX_HKEY; +//XXX clean up +#ifdef WIN32 +#undef HKEY +#endif + gReverseKeyTranslateTable[IKEY ] = SCA_IInputDevice::KX_IKEY; gReverseKeyTranslateTable[JKEY ] = SCA_IInputDevice::KX_JKEY; gReverseKeyTranslateTable[KKEY ] = SCA_IInputDevice::KX_KKEY; diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index f19390db8a9..848fcfcdaa0 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -71,20 +71,20 @@ #include "STR_HashedString.h" -static BL_InterpolatorList *GetIpoList(struct Ipo *for_ipo, KX_BlenderSceneConverter *converter) { - BL_InterpolatorList *ipoList= converter->FindInterpolatorList(for_ipo); +static BL_InterpolatorList *GetAdtList(struct AnimData *for_adt, KX_BlenderSceneConverter *converter) { + BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_adt); - if (!ipoList) { - ipoList = new BL_InterpolatorList(for_ipo); - converter->RegisterInterpolatorList(ipoList, for_ipo); + if (!adtList) { + adtList = new BL_InterpolatorList(for_adt); + converter->RegisterInterpolatorList(adtList, for_adt); } - return ipoList; + return adtList; } void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_BlenderSceneConverter *converter) { - if (blenderobject->ipo) { + if (blenderobject->adt) { KX_IpoSGController* ipocontr = new KX_IpoSGController(); gameobj->GetSGNode()->AddSGController(ipocontr); @@ -120,271 +120,79 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend ) ); - BL_InterpolatorList *ipoList= GetIpoList(blenderobject->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderobject->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(OB_LOC_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_X, true); - - } - - ipo = ipoList->GetScalarInterpolator(OB_LOC_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_Y, true); - } - - ipo = ipoList->GetScalarInterpolator(OB_LOC_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_Z, true); - } - - // Master the art of cut & paste programming... - - ipo = ipoList->GetScalarInterpolator(OB_DLOC_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaPosition()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DLOC_X, true); - } - - ipo = ipoList->GetScalarInterpolator(OB_DLOC_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaPosition()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DLOC_Y, true); - } - - ipo = ipoList->GetScalarInterpolator(OB_DLOC_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaPosition()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DLOC_Z, true); - } - - // Explore the finesse of reuse and slight modification - - ipo = ipoList->GetScalarInterpolator(OB_ROT_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetEulerAngles()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_ROT_X, true); - } - ipo = ipoList->GetScalarInterpolator(OB_ROT_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetEulerAngles()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_ROT_Y, true); - } - ipo = ipoList->GetScalarInterpolator(OB_ROT_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetEulerAngles()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_ROT_Z, true); - } - - // Hmmm, the need for a macro comes to mind... - - ipo = ipoList->GetScalarInterpolator(OB_DROT_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DROT_X, true); - } - ipo = ipoList->GetScalarInterpolator(OB_DROT_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DROT_Y, true); - } - ipo = ipoList->GetScalarInterpolator(OB_DROT_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DROT_Z, true); - } - - // Hang on, almost there... - - ipo = ipoList->GetScalarInterpolator(OB_SIZE_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetScaling()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_SIZE_X, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("location", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_LOC_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_SIZE_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetScaling()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_SIZE_Y, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("delta_location", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaPosition()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_DLOC_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_SIZE_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetScaling()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_SIZE_Z, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("rotation", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetEulerAngles()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_ROT_X+i, true); + } } - - // The last few... - - ipo = ipoList->GetScalarInterpolator(OB_DSIZE_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaScaling()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DSIZE_X, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("delta_rotation", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_DROT_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaScaling()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DSIZE_Y, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("scale", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetScaling()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_SIZE_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaScaling()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DSIZE_Z, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("delta_scale", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaScaling()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_DSIZE_X+i, true); + } } { KX_ObColorIpoSGController* ipocontr_obcol=NULL; - - ipo = ipoList->GetScalarInterpolator(OB_COL_R); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[0], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); - } - ipo = ipoList->GetScalarInterpolator(OB_COL_G); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[1], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); - } - ipo = ipoList->GetScalarInterpolator(OB_COL_B); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[2], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); - } - ipo = ipoList->GetScalarInterpolator(OB_COL_A); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); + + for(int i=0; i<4; i++) { + if ((interp = adtList->GetScalarInterpolator("color", i))) { + if (!ipocontr_obcol) { + ipocontr_obcol = new KX_ObColorIpoSGController(); + gameobj->GetSGNode()->AddSGController(ipocontr_obcol); + ipocontr_obcol->SetObject(gameobj->GetSGNode()); + } + interpolator= new KX_ScalarInterpolator(&ipocontr_obcol->m_rgba[i], interp); + ipocontr_obcol->AddInterpolator(interpolator); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[3], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); } } - - } - - } void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_BlenderSceneConverter *converter) { - if (blenderlamp->ipo) { + if (blenderlamp->adt) { KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController(); lightobj->GetSGNode()->AddSGController(ipocontr); @@ -396,51 +204,32 @@ void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_Ble ipocontr->m_col_rgb[2] = blenderlamp->b; ipocontr->m_dist = blenderlamp->dist; - BL_InterpolatorList *ipoList= GetIpoList(blenderlamp->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderlamp->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(LA_ENERGY); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_energy, ipo); + if ((interp= adtList->GetScalarInterpolator("energy", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyEnergy(true); } - ipo = ipoList->GetScalarInterpolator(LA_DIST); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_dist, ipo); + if ((interp = adtList->GetScalarInterpolator("distance", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyDist(true); } - - ipo = ipoList->GetScalarInterpolator(LA_COL_R); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_col_rgb[0], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyColor(true); - } - - ipo = ipoList->GetScalarInterpolator(LA_COL_G); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_col_rgb[1], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyColor(true); - } - - ipo = ipoList->GetScalarInterpolator(LA_COL_B); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_col_rgb[2], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyColor(true); + + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("color", i))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyColor(true); + } } } } @@ -451,7 +240,7 @@ void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_Ble void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj,KX_BlenderSceneConverter *converter) { - if (blendercamera->ipo) { + if (blendercamera->adt) { KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController(); cameraobj->GetSGNode()->AddSGController(ipocontr); @@ -461,33 +250,28 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj ipocontr->m_clipstart = blendercamera->clipsta; ipocontr->m_clipend = blendercamera->clipend; - BL_InterpolatorList *ipoList= GetIpoList(blendercamera->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(CAM_LENS); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_lens, ipo); + if ((interp = adtList->GetScalarInterpolator("lens", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyLens(true); } - ipo = ipoList->GetScalarInterpolator(CAM_STA); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_clipstart, ipo); + if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyClipStart(true); } - ipo = ipoList->GetScalarInterpolator(CAM_END); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_clipend, ipo); + if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyClipEnd(true); } @@ -499,7 +283,7 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *converter) { - if (blenderworld->ipo) { + if (blenderworld->adt) { KX_WorldIpoController* ipocontr = new KX_WorldIpoController(); @@ -514,49 +298,30 @@ void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *co ipocontr->m_mist_rgb[1] = blenderworld->horg; ipocontr->m_mist_rgb[2] = blenderworld->horb; - BL_InterpolatorList *ipoList= GetIpoList(blenderworld->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderworld->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(WO_HOR_R); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[0], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyMistColor(true); - } - - ipo = ipoList->GetScalarInterpolator(WO_HOR_G); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[1], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyMistColor(true); - } - - ipo = ipoList->GetScalarInterpolator(WO_HOR_B); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[2], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyMistColor(true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("horizon_color", i))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[i], interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyMistColor(true); + } } - ipo = ipoList->GetScalarInterpolator(WO_MISTDI); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_dist, ipo); + if ((interp = adtList->GetScalarInterpolator("mist.depth", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_dist, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyMistDist(true); } - ipo = ipoList->GetScalarInterpolator(WO_MISTSTA); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_start, ipo); + if ((interp = adtList->GetScalarInterpolator("mist.start", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_start, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyMistStart(true); } @@ -570,12 +335,12 @@ static void ConvertMaterialIpos( KX_BlenderSceneConverter *converter ) { - if (blendermaterial->ipo) { + if (blendermaterial->adt) { KX_MaterialIpoController* ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); - BL_InterpolatorList *ipoList= GetIpoList(blendermaterial->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blendermaterial->adt, converter); ipocontr->m_rgba[0] = blendermaterial->r; @@ -592,163 +357,82 @@ static void ConvertMaterialIpos( ipocontr->m_ref = blendermaterial->ref; ipocontr->m_emit = blendermaterial->emit; ipocontr->m_alpha = blendermaterial->alpha; - KX_IScalarInterpolator *ipo; - // -- - ipo = ipoList->GetScalarInterpolator(MA_COL_R); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[0], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - ipo = ipoList->GetScalarInterpolator(MA_COL_G); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[1], - ipo); - ipocontr->AddInterpolator(interpolator); - } + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *sinterp; - ipo = ipoList->GetScalarInterpolator(MA_COL_B); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + // -- + for(int i=0; i<3; i++) { + if ((sinterp = adtList->GetScalarInterpolator("diffuse_color", i))) { + if (!ipocontr) { + ipocontr = new KX_MaterialIpoController(matname_hash); + gameobj->GetSGNode()->AddSGController(ipocontr); + ipocontr->SetObject(gameobj->GetSGNode()); + } + interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[i], sinterp); + ipocontr->AddInterpolator(interpolator); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[2], - ipo); - ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_ALPHA); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("alpha", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[3], - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[3], sinterp); ipocontr->AddInterpolator(interpolator); } - // -- - ipo = ipoList->GetScalarInterpolator(MA_SPEC_R ); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_specrgb[0], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - ipo = ipoList->GetScalarInterpolator(MA_SPEC_G); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + for(int i=0; i<3; i++) { + if ((sinterp = adtList->GetScalarInterpolator("specular_color", i))) { + if (!ipocontr) { + ipocontr = new KX_MaterialIpoController(matname_hash); + gameobj->GetSGNode()->AddSGController(ipocontr); + ipocontr->SetObject(gameobj->GetSGNode()); + } + interpolator= new KX_ScalarInterpolator(&ipocontr->m_specrgb[i], sinterp); + ipocontr->AddInterpolator(interpolator); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_specrgb[1], - ipo); - ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_SPEC_B); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_specrgb[2], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - // -- - ipo = ipoList->GetScalarInterpolator(MA_HARD); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("specular_hardness", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_hard, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_hard, sinterp); ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_SPEC); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("specularity", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_spec, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_spec, sinterp); ipocontr->AddInterpolator(interpolator); } - - ipo = ipoList->GetScalarInterpolator(MA_REF); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("diffuse_reflection", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_ref, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_ref, sinterp); ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_EMIT); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("emit", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_emit, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_emit, sinterp); ipocontr->AddInterpolator(interpolator); } } diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index 4dd63e428bd..e261f9350e9 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -37,17 +37,18 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include -CPPFLAGS += -I$(NAN_SOLID)/include +CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_BULLET2)/include +CPPFLAGS += -I$(NAN_AUDASPACE)/include CPPFLAGS += -I../../blender # these two needed because of blenkernel +CPPFLAGS += -I../../blender/windowmanager CPPFLAGS += -I../../blender/imbuf CPPFLAGS += -I../../blender/makesdna -CPPFLAGS += -I../../blender/include +CPPFLAGS += -I../../blender/makesrna +CPPFLAGS += -I../../blender/editors/include CPPFLAGS += -I../../blender/blenlib CPPFLAGS += -I../../blender/blenkernel CPPFLAGS += -I../../blender/render/extern/include diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index 361dca58005..7d3185605d5 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -5,26 +5,22 @@ sources = env.Glob('*.cpp') defs = [] incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc' -incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #intern/bmfont' -incs += ' #intern/SoundSystem #intern/SoundSystem/include #intern/SoundSystem/openal' -incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern #source/gameengine/Converter' +incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' +incs += ' #intern/audaspace/intern #source/gameengine/Converter' incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf' incs += ' #intern/moto/include #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork' incs += ' #source/blender/blenlib #source/blender/blenkernel #source/blender' -incs += ' #source/blender/include #source/blender/makesdna #source/gameengine/Rasterizer' +incs += ' #source/blender/editors/include #source/blender/makesdna #source/gameengine/Rasterizer' 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' 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 += ' #source/blender/windowmanager' +incs += ' #source/blender/makesrna' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_BULLET_INC'] -env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['game','player'], priority=[5,70] ) +env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,50] ) |