diff options
Diffstat (limited to 'source/gameengine')
154 files changed, 5961 insertions, 773 deletions
diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index ee15fd99ed5..704e3cef6cd 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -2,43 +2,46 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../source/kernel/gen_system - ../../../intern/string - ../../../intern/guardedalloc - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/Converter - ../../../source/blender/imbuf - ../../../intern/ghost/include - ../../../intern/moto/include - ../../../source/gameengine/Ketsji - ../../../source/blender/blenlib - ../../../source/blender/blenkernel - ../../../source/blender/blenfont - ../../../source/blender/editors/include - ../../../source/blender/windowmanager - ../../../source/blender - ../../../source/blender/include - ../../../source/blender/makesdna - ../../../source/blender/makesrna - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/GameLogic - ../../../source/gameengine/Expressions - ../../../source/gameengine/Network - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Physics/common - ../../../source/gameengine/Physics/Bullet - ../../../source/gameengine/Network/LoopBackNetwork - ../../../source/blender/misc - ../../../source/blender/blenloader - ../../../source/blender/gpu - ../../../extern/bullet2/src - ../../../extern/glew/include - ${PYTHON_INC} + . + ../../../source/kernel/gen_system + ../../../intern/string + ../../../intern/guardedalloc + ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer + ../../../source/gameengine/Converter + ../../../source/blender/imbuf + ../../../intern/ghost/include + ../../../intern/moto/include + ../../../source/gameengine/Ketsji + ../../../source/blender/blenlib + ../../../source/blender/blenkernel + ../../../source/blender/blenfont + ../../../source/blender/editors/include + ../../../source/blender/windowmanager + ../../../source/blender + ../../../source/blender/include + ../../../source/blender/makesdna + ../../../source/blender/makesrna + ../../../source/gameengine/Rasterizer + ../../../source/gameengine/GameLogic + ../../../source/gameengine/Expressions + ../../../source/gameengine/Network + ../../../source/gameengine/SceneGraph + ../../../source/gameengine/Physics/common + ../../../source/gameengine/Physics/Bullet + ../../../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 + ../../../extern/glew/include + ${PYTHON_INC} ) IF(WITH_FFMPEG) - ADD_DEFINITIONS(-DWITH_FFMPEG) + ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) BLENDERLIB(bf_blroutines "${SRC}" "${INC}") diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index dba6d1113c9..5cf696fe146 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -103,8 +103,6 @@ void BL_SwapBuffers(wmWindow *win) void DisableForText() { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */ - if(glIsEnabled(GL_BLEND)) glDisable(GL_BLEND); if(glIsEnabled(GL_ALPHA_TEST)) glDisable(GL_ALPHA_TEST); @@ -137,25 +135,32 @@ void DisableForText() } } -void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height) +void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height) { /* gl prepping */ DisableForText(); + //glDisable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - - glOrtho(0, width, 0, height, -100, 100); - + + glOrtho(0, width, + 0, height, 0, 1); + glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); /* the actual drawing */ glColor3ub(255, 255, 255); - BLF_draw_default(xco, height-yco, 0.0f, (char *)text); + BLF_draw_default(xco, height-yco, 0.0f, text); + glMatrixMode(GL_TEXTURE); + glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); @@ -163,29 +168,36 @@ void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int glEnable(GL_DEPTH_TEST); } -void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height) +void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int height) { /* This is a rather important line :( The gl-mode hasn't been left * behind quite as neatly as we'd have wanted to. I don't know * what cause it, though :/ .*/ DisableForText(); + //glDisable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho(0, width, 0, height, -100, 100); + glOrtho(0, width, + 0, height, 0, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); /* draw in black first*/ glColor3ub(0, 0, 0); - BLF_draw_default(xco+2, height-yco-2, 0.0f, (char *)text); + BLF_draw_default(xco+1, height-yco-1, 0.0f, text); glColor3ub(255, 255, 255); - BLF_draw_default(xco, height-yco, 0.0f, (char *)text); + BLF_draw_default(xco, height-yco, 0.0f, text); + glMatrixMode(GL_TEXTURE); + glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h index 5c947ff630e..1e65f29d87c 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h @@ -47,8 +47,8 @@ void BL_HideMouse(); void BL_NormalMouse(); void BL_WaitMouse(); -void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height); -void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height); +void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height); +void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int height); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index ee9dae14b9b..8ed36e860b4 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -284,10 +284,12 @@ void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, int width, int height) { + STR_String tmpstr(text); + if(mode == RAS_IRenderTools::RAS_TEXT_PADDED) - BL_print_gamedebug_line_padded(text, xco, yco, width, height); + BL_print_gamedebug_line_padded(tmpstr.Ptr(), xco, yco, width, height); else - BL_print_gamedebug_line(text, xco, yco, width, height); + BL_print_gamedebug_line(tmpstr.Ptr(), xco, yco, width, height); } /* Render Text renders text into a (series of) polygon, using a texture font, @@ -388,4 +390,4 @@ void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void* void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) { m_filtermanager.RenderFilters(canvas); -} +}
\ No newline at end of file diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index ad6f9f23fce..eb5f2a76e10 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -28,4 +28,10 @@ incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] -env.BlenderLib ( 'bf_bloutines', sources, Split(incs), defs, libtype=['core','player'], priority=[300,35] , cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc','win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib ( 'bf_bloutines', sources, Split(incs), defs, libtype=['core', 'player'], priority=[300, 45] , cxx_compileflags=cxxflags) diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt index 5a1887bd6c3..f546a31fb2e 100644 --- a/source/gameengine/CMakeLists.txt +++ b/source/gameengine/CMakeLists.txt @@ -41,5 +41,5 @@ ADD_SUBDIRECTORY(Physics/Bullet) ADD_SUBDIRECTORY(VideoTexture) IF(WITH_PLAYER) - ADD_SUBDIRECTORY(GamePlayer) + ADD_SUBDIRECTORY(GamePlayer) ENDIF(WITH_PLAYER) diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index ca4290703e1..5a3629cfcd3 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -436,6 +436,365 @@ 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 PyUnicode_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= _PyUnicode_AsString(value); @@ -490,6 +849,72 @@ 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 PyLong_FromSsize_t((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" @@ -603,7 +1028,31 @@ PyTypeObject BL_ActionActuator::Type = { }; PyMethodDef BL_ActionActuator::Methods[] = { + //Deprecated -----> + {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (const char *)SetAction_doc}, + {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (const char *)SetStart_doc}, + {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (const char *)SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (const char *)SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (const char *)SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (const char *)SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (const char *)SetFrameProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (const char *)SetBlendtime_doc}, + + {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (const char *)GetAction_doc}, + {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (const char *)GetStart_doc}, + {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (const char *)GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (const char *)GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (const char *)GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (const char *)GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (const char *)GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (const char *)GetFrameProperty_doc}, {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_O}, + {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (const char *)GetType_doc}, + {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (const char *)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 }; diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index a6b4c4a055d..6003e23e315 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -84,7 +84,32 @@ 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); static PyObject* pyattr_get_action(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 cfd90813a16..f8a9b1b637f 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -54,8 +54,8 @@ BL_ArmatureObject::BL_ArmatureObject( : KX_GameObject(sgReplicationInfo,callbacks), m_objArma(armature), - m_framePose(NULL), m_scene(scene), // maybe remove later. needed for where_is_pose + m_framePose(NULL), m_lastframe(0.0), m_activeAct(NULL), m_activePriority(999), diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 230820719aa..3d38759d951 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1377,9 +1377,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, bool isCompoundChild = false; bool hasCompoundChildren = !parent && (blenderobject->gameflag & OB_CHILD); - /* When the parent is not OB_DYNAMIC and has no OB_COLLISION then it gets no bullet controller - * and cant be apart of the parents compound shape */ - if (parent && (parent->gameflag & (OB_DYNAMIC | OB_COLLISION))) { + if (parent/* && (parent->gameflag & OB_DYNAMIC)*/) { if ((parent->gameflag & OB_CHILD) != 0 && (blenderobject->gameflag & OB_CHILD)) { @@ -2406,11 +2404,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, obj->Release(); } childrenlist->Release(); - // now destroy recursively - converter->UnregisterGameObject(childobj); // removing objects during conversion make sure this runs too kxscene->RemoveObject(childobj); - continue; } @@ -2487,10 +2482,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } } if (occlusion) - kxscene->SetDbvtOcclusionRes(blenderscene->gm.occlusionRes); + kxscene->SetDbvtOcclusionRes(blenderscene->world->occlusionRes); } if (blenderscene->world) - kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->gm.physubstep); + kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->world->physubstep); // now that the scenegraph is complete, let's instantiate the deformers. // We need that to create reusable derived mesh and physic shapes diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 81ce9ff6154..4af9a6c83a9 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -40,7 +40,6 @@ #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" @@ -52,10 +51,6 @@ #include "FloatValue.h" #include "PyObjectPlus.h" -extern "C" { - #include "BKE_animsys.h" -} - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -375,11 +370,8 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) m_blendstart = curtime; } // only interested in shape channel - - // 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 + // XXX extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime); + if (0) { // XXX !execute_ipochannels(&tchanbase)) { // no update, this is possible if action does not match the keys, stop the action keepgoing = false; @@ -442,6 +434,26 @@ PyTypeObject BL_ShapeActionActuator::Type = { PyMethodDef BL_ShapeActionActuator::Methods[] = { + {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, (const char *)SetAction_doc}, + {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, (const char *)SetStart_doc}, + {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, (const char *)SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, (const char *)SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, (const char *)SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, (const char *)SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, (const char *)SetFrameProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, (const char *)SetBlendtime_doc}, + + {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, (const char *)GetAction_doc}, + {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, (const char *)GetStart_doc}, + {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, (const char *)GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, (const char *)GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, (const char *)GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, (const char *)GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, (const char *)GetFrameProperty_doc}, + {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, (const char *)GetType_doc}, + {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, (const char *)SetType_doc}, {NULL,NULL} //Sentinel }; @@ -459,6 +471,370 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = { { NULL } //Sentinel }; +/* 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 PyUnicode_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); diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 28a6d90abdf..890fe3f9de9 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -82,6 +82,29 @@ 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); + 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 20ca7f07f2b..d39917b0e5c 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 diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 257ca856b2c..6732a62a5cb 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -27,40 +27,44 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../source/kernel/gen_system - ../../../intern/string - ../../../intern/guardedalloc - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../intern/audaspace/intern - ../../../source/gameengine/Converter - ../../../source/gameengine/BlenderRoutines - ../../../source/blender/imbuf - ../../../intern/moto/include - ../../../source/gameengine/Ketsji - ../../../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 - ../../../source/gameengine/Expressions - ../../../source/gameengine/Network - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Physics/common - ../../../source/gameengine/Physics/Bullet - ../../../source/gameengine/Physics/Dummy - ../../../source/gameengine/Network/LoopBackNetwork - ../../../source/blender/misc - ../../../source/blender/blenloader - ../../../source/blender/gpu - ../../../extern/bullet2/src - ${PYTHON_INC} + . + ../../../source/kernel/gen_system + ../../../intern/string + ../../../intern/guardedalloc + ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer + ../../../intern/audaspace/intern + ../../../source/gameengine/Converter + ../../../source/gameengine/BlenderRoutines + ../../../source/blender/imbuf + ../../../intern/moto/include + ../../../source/gameengine/Ketsji + ../../../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 + ../../../source/gameengine/Expressions + ../../../source/gameengine/Network + ../../../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} ) BLENDERLIB(bf_converter "${SRC}" "${INC}") diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp index 24910422176..c3264a2bc37 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp @@ -62,7 +62,7 @@ BL_InterpolatorList::~BL_InterpolatorList() { } } -KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index) { +KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(char *rna_path, int array_index) { for(BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ ) { FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve(); diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h index e7fbb8083e4..eb15cee8ff9 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h @@ -64,7 +64,7 @@ public: BL_InterpolatorList(struct AnimData *adt); ~BL_InterpolatorList(); - KX_IScalarInterpolator *GetScalarInterpolator(const char *rna_path, int array_index); + KX_IScalarInterpolator *GetScalarInterpolator(char *rna_path, int array_index); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 151564391f3..ebabaa55e21 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -462,11 +462,10 @@ void KX_BlenderSceneConverter::RegisterGameObject( m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject),gameobject); } -/* only need to run this during conversion since - * m_map_blender_to_gameobject is freed after conversion */ void KX_BlenderSceneConverter::UnregisterGameObject( KX_GameObject *gameobject) { +#if 0 struct Object *bobp= gameobject->GetBlenderObject(); if (bobp) { CHashedPtr bptr(bobp); @@ -478,6 +477,7 @@ void KX_BlenderSceneConverter::UnregisterGameObject( m_map_blender_to_gameobject.remove(bptr); } } +#endif } KX_GameObject *KX_BlenderSceneConverter::FindGameObject( @@ -795,7 +795,6 @@ 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(); @@ -805,6 +804,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) float tmat[3][3]; // XXX animato +#if 0 Ipo* ipo = blenderObject->ipo; //create the curves, if not existing, set linear if new diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 91a39bd7686..07f6f628e06 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -396,7 +396,7 @@ void BL_ConvertActuators(char* maggiename, "\" has no sound datablock." << std::endl; } else - snd_sound = sound->cache ? sound->cache : sound->handle; + snd_sound = sound->cache ? sound->cache : sound->snd_sound; KX_SoundActuator* tmpsoundact = new KX_SoundActuator(gameobj, snd_sound, diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index 1c22d2a0600..5e8d6f3cbf0 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -32,26 +32,26 @@ #include <config.h> #endif +/* This little block needed for linking to Blender... */ +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif #include "DNA_object_types.h" #include "DNA_property_types.h" /* end of blender include block */ - #include "Value.h" #include "VectorValue.h" #include "BoolValue.h" #include "StringValue.h" #include "FloatValue.h" #include "KX_GameObject.h" +//#include "ListValue.h" #include "IntValue.h" #include "SCA_TimeEventManager.h" #include "SCA_IScene.h" -/* This little block needed for linking to Blender... */ -#ifdef WIN32 -#include "BLI_winstuff.h" -#endif void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene, bool isInActiveLayer) { diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 09027f18844..eb77e087de5 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -536,7 +536,6 @@ void BL_ConvertSensors(struct Object* blenderobject, starty, keytype, trackfocus, - (bmouse->flag & SENS_MOUSE_FOCUS_PULSE) ? true:false, kxscene, kxengine, gameobj); diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 848fcfcdaa0..d3a2e1a9ba4 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -175,7 +175,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend KX_ObColorIpoSGController* ipocontr_obcol=NULL; for(int i=0; i<4; i++) { - if ((interp = adtList->GetScalarInterpolator("color", i))) { + if (interp = adtList->GetScalarInterpolator("color", i)) { if (!ipocontr_obcol) { ipocontr_obcol = new KX_ObColorIpoSGController(); gameobj->GetSGNode()->AddSGController(ipocontr_obcol); diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index 2d126310475..7d3185605d5 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -23,4 +23,4 @@ incs += ' #source/blender/makesrna' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_BULLET_INC'] -env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,40], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,50] ) diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index 439a50852a7..dffd13f64ff 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -27,13 +27,13 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../source/kernel/gen_system - ../../../intern/string - ../../../intern/moto/include - ../../../source/gameengine/SceneGraph - ../../../source/blender/blenloader - ${PYTHON_INC} + . + ../../../source/kernel/gen_system + ../../../intern/string + ../../../intern/moto/include + ../../../source/gameengine/SceneGraph + ../../../source/blender/blenloader + ${PYTHON_INC} ) BLENDERLIB(bf_expressions "${SRC}" "${INC}") diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index 002674450d1..5f45cdc48a2 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -300,6 +300,7 @@ PyMethodDef CListValue::Methods[] = { /* Dict style access */ {"get", (PyCFunction)CListValue::sPyget,METH_VARARGS}, + {"has_key", (PyCFunction)CListValue::sPyhas_key,METH_O}, /* Own cvalue funcs */ {"from_id", (PyCFunction)CListValue::sPyfrom_id,METH_O}, @@ -593,6 +594,14 @@ PyObject* CListValue::Pyget(PyObject *args) return def; } +/* Matches python dict.has_key() */ +PyObject* CListValue::Pyhas_key(PyObject* value) +{ + if (PyUnicode_Check(value) && FindValue((const char *)_PyUnicode_AsString(value))) + Py_RETURN_TRUE; + + Py_RETURN_FALSE; +} PyObject* CListValue::Pyfrom_id(PyObject* value) { diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h index 2dc458e0148..98e6f216f11 100644 --- a/source/gameengine/Expressions/ListValue.h +++ b/source/gameengine/Expressions/ListValue.h @@ -74,6 +74,7 @@ public: KX_PYMETHOD_O(CListValue,index); KX_PYMETHOD_O(CListValue,count); KX_PYMETHOD_VARARGS(CListValue,get); + KX_PYMETHOD_O(CListValue,has_key); KX_PYMETHOD_O(CListValue,from_id); diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 1d1d9e6103b..5be703f0fa4 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -751,17 +751,16 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt STR_String *var = reinterpret_cast<STR_String*>(ptr); if (PyUnicode_Check(value)) { - Py_ssize_t val_len; - char *val = _PyUnicode_AsStringAndSize(value, &val_len); + char *val = _PyUnicode_AsString(value); if (attrdef->m_clamp) { - if (val_len < attrdef->m_imin) + if (strlen(val) < attrdef->m_imin) { // can't increase the length of the string PyErr_Format(PyExc_ValueError, "string length too short for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } - else if (val_len > attrdef->m_imax) + else if (strlen(val) > attrdef->m_imax) { // trim the string char c = val[attrdef->m_imax]; @@ -770,7 +769,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt val[attrdef->m_imax] = c; break; } - } else if (val_len < attrdef->m_imin || val_len > attrdef->m_imax) + } else if (strlen(val) < attrdef->m_imin || strlen(val) > attrdef->m_imax) { PyErr_Format(PyExc_ValueError, "string length out of range for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; @@ -907,47 +906,45 @@ void PyObjectPlus::SetDeprecationWarnings(bool ignoreDeprecationWarnings) m_ignore_deprecation_warnings = ignoreDeprecationWarnings; } -void PyDebugLine() +void PyObjectPlus::ShowDeprecationWarning_func(const char* old_way,const char* new_way) { - // import sys; print '\t%s:%d' % (sys._getframe(0).f_code.co_filename, sys._getframe(0).f_lineno) - - PyObject *getframe, *frame; - PyObject *f_lineno, *f_code, *co_filename; - - getframe = PySys_GetObject((char *)"_getframe"); // borrowed - if (getframe) { - frame = PyObject_CallObject(getframe, NULL); - if (frame) { - f_lineno= PyObject_GetAttrString(frame, "f_lineno"); - f_code= PyObject_GetAttrString(frame, "f_code"); - if (f_lineno && f_code) { - co_filename= PyObject_GetAttrString(f_code, "co_filename"); - if (co_filename) { - - printf("\t%s:%d\n", _PyUnicode_AsString(co_filename), (int)PyLong_AsSsize_t(f_lineno)); - - Py_DECREF(f_lineno); - Py_DECREF(f_code); - Py_DECREF(co_filename); - Py_DECREF(frame); - return; + { + printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way); + + // import sys; print '\t%s:%d' % (sys._getframe(0).f_code.co_filename, sys._getframe(0).f_lineno) + + PyObject *getframe, *frame; + PyObject *f_lineno, *f_code, *co_filename; + + getframe = PySys_GetObject((char *)"_getframe"); // borrowed + if (getframe) { + frame = PyObject_CallObject(getframe, NULL); + if (frame) { + f_lineno= PyObject_GetAttrString(frame, "f_lineno"); + f_code= PyObject_GetAttrString(frame, "f_code"); + if (f_lineno && f_code) { + co_filename= PyObject_GetAttrString(f_code, "co_filename"); + if (co_filename) { + + printf("\t%s:%d\n", _PyUnicode_AsString(co_filename), (int)PyLong_AsSsize_t(f_lineno)); + + Py_DECREF(f_lineno); + Py_DECREF(f_code); + Py_DECREF(co_filename); + Py_DECREF(frame); + return; + } } + + Py_XDECREF(f_lineno); + Py_XDECREF(f_code); + Py_DECREF(frame); } - Py_XDECREF(f_lineno); - Py_XDECREF(f_code); - Py_DECREF(frame); } - + PyErr_Clear(); + printf("\tERROR - Could not access sys._getframe(0).f_lineno or sys._getframe().f_code.co_filename\n"); } - PyErr_Clear(); - printf("\tERROR - Could not access sys._getframe(0).f_lineno or sys._getframe().f_code.co_filename\n"); -} - -void PyObjectPlus::ShowDeprecationWarning_func(const char* old_way,const char* new_way) -{ - printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way); - PyDebugLine(); } void PyObjectPlus::ClearDeprecationWarning() diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index f9edb7877b0..e9e81dddaaa 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -86,7 +86,7 @@ typedef struct { -typedef struct PyObjectPlus_Proxy { +typedef struct { PyObject_HEAD /* required python macro */ class PyObjectPlus *ref; bool py_owns; @@ -99,9 +99,6 @@ typedef struct PyObjectPlus_Proxy { /* Note, sometimes we dont care what BGE type this is as long as its a proxy */ #define BGE_PROXY_CHECK_TYPE(_type) ((_type)->tp_dealloc == PyObjectPlus::py_base_dealloc) -/* Opposite of BGE_PROXY_REF */ -#define BGE_PROXY_FROM_REF(_self) (((PyObjectPlus *)_self)->GetProxy()) - // This must be the first line of each // PyC++ class diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript index c819bfb0d3e..69f87ffbb90 100644 --- a/source/gameengine/Expressions/SConscript +++ b/source/gameengine/Expressions/SConscript @@ -6,4 +6,10 @@ sources = env.Glob('*.cpp') incs ='. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/SceneGraph #source/blender/blenloader' incs += ' ' + env['BF_PYTHON_INC'] -env.BlenderLib ( 'bf_expressions', sources, Split(incs), [], libtype=['core','player'], priority = [360,80], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib ( 'bf_expressions', sources, Split(incs), [], libtype=['core','player'], priority = [360,120], cxx_compileflags=cxxflags) diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 130317d77e2..04bcc3a5561 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -62,9 +62,17 @@ PyTypeObject CValue::Type = { }; PyMethodDef CValue::Methods[] = { + { "getName", (PyCFunction) CValue::sPyGetName, METH_NOARGS}, {NULL,NULL} //Sentinel }; +PyObject* CValue::PyGetName() +{ + ShowDeprecationWarning("getName()", "the name property"); + + return PyUnicode_FromString(this->GetName()); +} + /*#define CVALUE_DEBUG*/ #ifdef CVALUE_DEBUG int gRefCount; diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 7d4adcdb64f..5f08736afde 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -242,6 +242,8 @@ public: static PyObject * pyattr_get_name(void * self, const KX_PYATTRIBUTE_DEF * attrdef); virtual PyObject* ConvertKeysToPython( void ); + + KX_PYMETHOD_NOARGS(CValue,GetName); #else CValue(); diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 601585f79d6..a1dce49e14b 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -27,20 +27,20 @@ FILE(GLOB SRC *.cpp Joystick/*.cpp) SET(INC - . - ../../../source/kernel/gen_system - ../../../intern/string - ../../../source/gameengine/Expressions - ../../../source/gameengine/SceneGraph - ../../../intern/moto/include - ../../../source/gameengine/Rasterizer - ${PYTHON_INC} + . + ../../../source/kernel/gen_system + ../../../intern/string + ../../../source/gameengine/Expressions + ../../../source/gameengine/SceneGraph + ../../../intern/moto/include + ../../../source/gameengine/Rasterizer + ${PYTHON_INC} ) IF(WITH_SDL) - SET(INC ${INC} ${SDL_INCLUDE_DIR}) + SET(INC ${INC} ${SDL_INCLUDE_DIR}) ELSE(WITH_SDL) - ADD_DEFINITIONS(-DDISABLE_SDL) + ADD_DEFINITIONS(-DDISABLE_SDL) ENDIF(WITH_SDL) BLENDERLIB(bf_logic "${SRC}" "${INC}") diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 428362a0a24..11ea089270a 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -143,6 +143,10 @@ PyTypeObject SCA_ActuatorSensor::Type = { }; PyMethodDef SCA_ActuatorSensor::Methods[] = { + //Deprecated functions ------> + {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (const char *)GetActuator_doc}, + {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (const char *)SetActuator_doc}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -163,4 +167,41 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*) return 1; } +/* 3. getActuator */ +const char SCA_ActuatorSensor::GetActuator_doc[] = +"getActuator()\n" +"\tReturn the Actuator with which the sensor operates.\n"; +PyObject* SCA_ActuatorSensor::PyGetActuator() +{ + ShowDeprecationWarning("getActuator()", "the actuator property"); + return PyUnicode_FromString(m_checkactname); +} + +/* 4. setActuator */ +const char SCA_ActuatorSensor::SetActuator_doc[] = +"setActuator(name)\n" +"\t- name: string\n" +"\tSets the Actuator with which to operate. If there is no Actuator\n" +"\tof this name, the call is ignored.\n"; +PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* args) +{ + ShowDeprecationWarning("setActuator()", "the actuator property"); + /* We should query whether the name exists. Or should we create a prop */ + /* on the fly? */ + char *actNameArg = NULL; + + if (!PyArg_ParseTuple(args, "s:setActuator", &actNameArg)) { + return NULL; + } + + SCA_IActuator* act = GetParent()->FindActuator(STR_String(actNameArg)); + if (act) { + m_checkactname = actNameArg; + m_actuator = act; + } else { + ; /* error: bad actuator name */ + } + Py_RETURN_NONE; +} + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h index 1a095148500..cf8e735cad4 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -59,6 +59,11 @@ public: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + + /* 3. setProperty */ + KX_PYMETHOD_DOC_VARARGS(SCA_ActuatorSensor,SetActuator); + /* 4. getProperty */ + KX_PYMETHOD_DOC_NOARGS(SCA_ActuatorSensor,GetActuator); static int CheckActuator(void *self, const PyAttributeDef*); }; diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index 0f67ddd56a5..0d563db910e 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -152,6 +152,16 @@ PyTypeObject SCA_DelaySensor::Type = { }; PyMethodDef SCA_DelaySensor::Methods[] = { + //Deprecated functions ------> + /* setProperty */ + {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, (const char *)SetDelay_doc}, + {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, (const char *)SetDuration_doc}, + {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, (const char *)SetRepeat_doc}, + /* getProperty */ + {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, (const char *)GetDelay_doc}, + {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, (const char *)GetDuration_doc}, + {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, (const char *)GetRepeat_doc}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -162,4 +172,91 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = { { NULL } //Sentinel }; +const char SCA_DelaySensor::SetDelay_doc[] = +"setDelay(delay)\n" +"\t- delay: length of the initial OFF period as number of frame\n" +"\t 0 for immediate trigger\n" +"\tSet the initial delay before the positive trigger\n"; +PyObject* SCA_DelaySensor::PySetDelay(PyObject* args) +{ + ShowDeprecationWarning("setDelay()", "the delay property"); + int delay; + + if(!PyArg_ParseTuple(args, "i:setDelay", &delay)) { + return NULL; + } + if (delay < 0) { + PyErr_SetString(PyExc_ValueError, "Delay cannot be negative"); + return NULL; + } + m_delay = delay; + Py_RETURN_NONE; +} + +const char SCA_DelaySensor::SetDuration_doc[] = +"setDuration(duration)\n" +"\t- duration: length of the ON period in number of frame after the initial off period\n" +"\t 0 for no ON period\n" +"\tSet the duration of the ON pulse after initial delay.\n" +"\tIf > 0, a negative trigger is fired at the end of the ON pulse.\n"; +PyObject* SCA_DelaySensor::PySetDuration(PyObject* args) +{ + ShowDeprecationWarning("setDuration()", "the duration property"); + int duration; + + if(!PyArg_ParseTuple(args, "i:setDuration", &duration)) { + return NULL; + } + if (duration < 0) { + PyErr_SetString(PyExc_ValueError, "Duration cannot be negative"); + return NULL; + } + m_duration = duration; + Py_RETURN_NONE; +} + +const char SCA_DelaySensor::SetRepeat_doc[] = +"setRepeat(repeat)\n" +"\t- repeat: 1 if the initial OFF-ON cycle should be repeated indefinately\n" +"\t 0 if the initial OFF-ON cycle should run only once\n" +"\tSet the sensor repeat mode\n"; +PyObject* SCA_DelaySensor::PySetRepeat(PyObject* args) +{ + ShowDeprecationWarning("setRepeat()", "the repeat property"); + int repeat; + + if(!PyArg_ParseTuple(args, "i:setRepeat", &repeat)) { + return NULL; + } + m_repeat = (repeat != 0); + Py_RETURN_NONE; +} + +const char SCA_DelaySensor::GetDelay_doc[] = +"getDelay()\n" +"\tReturn the delay parameter value\n"; +PyObject* SCA_DelaySensor::PyGetDelay() +{ + ShowDeprecationWarning("getDelay()", "the delay property"); + return PyLong_FromSsize_t(m_delay); +} + +const char SCA_DelaySensor::GetDuration_doc[] = +"getDuration()\n" +"\tReturn the duration parameter value\n"; +PyObject* SCA_DelaySensor::PyGetDuration() +{ + ShowDeprecationWarning("getDuration()", "the duration property"); + return PyLong_FromSsize_t(m_duration); +} + +const char SCA_DelaySensor::GetRepeat_doc[] = +"getRepeat()\n" +"\tReturn the repeat parameter value\n"; +PyObject* SCA_DelaySensor::PyGetRepeat() +{ + ShowDeprecationWarning("getRepeat()", "the repeat property"); + return BoolToPyArg(m_repeat); +} + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h index 187a9179b5d..8270e8959b7 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.h +++ b/source/gameengine/GameLogic/SCA_DelaySensor.h @@ -59,6 +59,14 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + /* setProperty */ + KX_PYMETHOD_DOC_VARARGS(SCA_DelaySensor,SetDelay); + KX_PYMETHOD_DOC_VARARGS(SCA_DelaySensor,SetDuration); + KX_PYMETHOD_DOC_VARARGS(SCA_DelaySensor,SetRepeat); + /* getProperty */ + KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDelay); + KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDuration); + KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetRepeat); }; diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 7cfd2adc1d0..24c39563c28 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -221,6 +221,13 @@ PyTypeObject SCA_IController::Type = { }; PyMethodDef SCA_IController::Methods[] = { + //Deprecated functions ------> + {"getSensor", (PyCFunction) SCA_IController::sPyGetSensor, METH_O}, + {"getActuator", (PyCFunction) SCA_IController::sPyGetActuator, METH_O}, + {"getSensors", (PyCFunction) SCA_IController::sPyGetSensors, METH_NOARGS}, + {"getActuators", (PyCFunction) SCA_IController::sPyGetActuators, METH_NOARGS}, + {"getState", (PyCFunction) SCA_IController::sPyGetState, METH_NOARGS}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -232,6 +239,85 @@ PyAttributeDef SCA_IController::Attributes[] = { { NULL } //Sentinel }; +PyObject* SCA_IController::PyGetActuators() +{ + ShowDeprecationWarning("getActuators()", "the actuators property"); + + PyObject* resultlist = PyList_New(m_linkedactuators.size()); + for (unsigned int index=0;index<m_linkedactuators.size();index++) + { + PyList_SET_ITEM(resultlist,index, m_linkedactuators[index]->GetProxy()); + } + + return resultlist; +} + +PyObject* SCA_IController::PyGetSensor(PyObject* value) +{ + ShowDeprecationWarning("getSensor(string)", "the sensors[string] property"); + + char *scriptArg = _PyUnicode_AsString(value); + if (scriptArg==NULL) { + PyErr_SetString(PyExc_TypeError, "controller.getSensor(string): Python Controller, expected a string (sensor name)"); + return NULL; + } + + for (unsigned int index=0;index<m_linkedsensors.size();index++) + { + SCA_ISensor* sensor = m_linkedsensors[index]; + STR_String& realname = sensor->GetName(); + if (realname == scriptArg) + { + return sensor->GetProxy(); + } + } + + PyErr_Format(PyExc_AttributeError, "controller.getSensor(string): Python Controller, unable to find requested sensor \"%s\"", scriptArg); + return NULL; +} + +PyObject* SCA_IController::PyGetActuator(PyObject* value) +{ + ShowDeprecationWarning("getActuator(string)", "the actuators[string] property"); + + char *scriptArg = _PyUnicode_AsString(value); + if (scriptArg==NULL) { + PyErr_SetString(PyExc_TypeError, "controller.getActuator(string): Python Controller, expected a string (actuator name)"); + return NULL; + } + + for (unsigned int index=0;index<m_linkedactuators.size();index++) + { + SCA_IActuator* actua = m_linkedactuators[index]; + if (actua->GetName() == scriptArg) + { + return actua->GetProxy(); + } + } + + PyErr_Format(PyExc_AttributeError, "controller.getActuator(string): Python Controller, unable to find requested actuator \"%s\"", scriptArg); + return NULL; +} + +PyObject* SCA_IController::PyGetSensors() +{ + ShowDeprecationWarning("getSensors()", "the sensors property"); + + PyObject* resultlist = PyList_New(m_linkedsensors.size()); + for (unsigned int index=0;index<m_linkedsensors.size();index++) + { + PyList_SET_ITEM(resultlist,index, m_linkedsensors[index]->GetProxy()); + } + + return resultlist; +} + +PyObject* SCA_IController::PyGetState() +{ + ShowDeprecationWarning("getState()", "the state property"); + return PyLong_FromSsize_t(m_statemask); +} + PyObject* SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_IController* self= static_cast<SCA_IController*>(self_v); diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h index 202921c6986..523878bee26 100644 --- a/source/gameengine/GameLogic/SCA_IController.h +++ b/source/gameengine/GameLogic/SCA_IController.h @@ -97,6 +97,12 @@ public: } } } + + KX_PYMETHOD_NOARGS(SCA_IController,GetSensors); + KX_PYMETHOD_NOARGS(SCA_IController,GetActuators); + KX_PYMETHOD_O(SCA_IController,GetSensor); + KX_PYMETHOD_O(SCA_IController,GetActuator); + KX_PYMETHOD_NOARGS(SCA_IController,GetState); static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index f679d0ee487..2c64e02913d 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -199,6 +199,11 @@ PyTypeObject SCA_ILogicBrick::Type = { }; PyMethodDef SCA_ILogicBrick::Methods[] = { + // --> Deprecated + {"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_NOARGS}, + {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPyGetExecutePriority, METH_NOARGS}, + {"setExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_VARARGS}, + // <-- Deprecated {NULL,NULL} //Sentinel }; @@ -227,6 +232,46 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef) return 0; } +PyObject* SCA_ILogicBrick::PyGetOwner() +{ + ShowDeprecationWarning("getOwner()", "the owner property"); + + CValue* parent = GetParent(); + if (parent) + { + return parent->GetProxy(); + } + + printf("ERROR: Python scriptblock without owner\n"); + Py_RETURN_NONE; //Int_FromLong(IsPositiveTrigger()); +} + + + +PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* args) +{ + ShowDeprecationWarning("setExecutePriority()", "the executePriority property"); + + int priority=0; + + if (!PyArg_ParseTuple(args, "i:setExecutePriority", &priority)) { + return NULL; + } + + m_Execute_Priority = priority; + + Py_RETURN_NONE; +} + + + +PyObject* SCA_ILogicBrick::PyGetExecutePriority() +{ + ShowDeprecationWarning("getExecutePriority()", "the executePriority property"); + return PyLong_FromSsize_t(m_Execute_Priority); +} + + /*Attribute functions */ PyObject* SCA_ILogicBrick::pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index ac533335f0b..50679856802 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -126,6 +126,10 @@ public: // python methods + + KX_PYMETHOD_NOARGS(SCA_ILogicBrick,GetOwner); + KX_PYMETHOD_VARARGS(SCA_ILogicBrick,SetExecutePriority); + KX_PYMETHOD_NOARGS(SCA_ILogicBrick,GetExecutePriority); static PyObject* pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 497a5d1095a..b018124dcca 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -292,6 +292,171 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) /* Python Functions */ /* ----------------------------------------------- */ +//Deprecated Functions ------> +const char SCA_ISensor::IsPositive_doc[] = +"isPositive()\n" +"\tReturns whether the sensor is in an active state.\n"; +PyObject* SCA_ISensor::PyIsPositive() +{ + ShowDeprecationWarning("isPositive()", "the read-only positive property"); + int retval = GetState(); + return PyLong_FromSsize_t(retval); +} + +const char SCA_ISensor::IsTriggered_doc[] = +"isTriggered()\n" +"\tReturns whether the sensor has triggered the current controller.\n"; +PyObject* SCA_ISensor::PyIsTriggered() +{ + ShowDeprecationWarning("isTriggered()", "the read-only triggered property"); + // check with the current controller + int retval = 0; + if (SCA_PythonController::m_sCurrentController) + retval = SCA_PythonController::m_sCurrentController->IsTriggered(this); + return PyLong_FromSsize_t(retval); +} + +/** + * getUsePulseMode: getter for the pulse mode (KX_TRUE = on) + */ +const char SCA_ISensor::GetUsePosPulseMode_doc[] = +"getUsePosPulseMode()\n" +"\tReturns whether positive pulse mode is active.\n"; +PyObject* SCA_ISensor::PyGetUsePosPulseMode() +{ + ShowDeprecationWarning("getUsePosPulseMode()", "the usePosPulseMode property"); + return BoolToPyArg(m_pos_pulsemode); +} + +/** + * setUsePulseMode: setter for the pulse mode (KX_TRUE = on) + */ +const char SCA_ISensor::SetUsePosPulseMode_doc[] = +"setUsePosPulseMode(pulse?)\n" +"\t - pulse? : Pulse when a positive event occurs?\n" +"\t (KX_TRUE, KX_FALSE)\n" +"\tSet whether to do pulsing when positive pulses occur.\n"; +PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* args) +{ + ShowDeprecationWarning("setUsePosPulseMode()", "the usePosPulseMode property"); + int pyarg = 0; + if(!PyArg_ParseTuple(args, "i:setUsePosPulseMode", &pyarg)) { return NULL; } + m_pos_pulsemode = PyArgToBool(pyarg); + Py_RETURN_NONE; +} + +/** + * getFrequency: getter for the pulse mode interval + */ +const char SCA_ISensor::GetFrequency_doc[] = +"getFrequency()\n" +"\tReturns the frequency of the updates in pulse mode.\n" ; +PyObject* SCA_ISensor::PyGetFrequency() +{ + ShowDeprecationWarning("getFrequency()", "the frequency property"); + return PyLong_FromSsize_t(m_pulse_frequency); +} + +/** + * setFrequency: setter for the pulse mode (KX_TRUE = on) + */ +const char SCA_ISensor::SetFrequency_doc[] = +"setFrequency(pulse_frequency)\n" +"\t- pulse_frequency: The frequency of the updates in pulse mode (integer)" +"\tSet the frequency of the updates in pulse mode.\n" +"\tIf the frequency is negative, it is set to 0.\n" ; +PyObject* SCA_ISensor::PySetFrequency(PyObject* args) +{ + ShowDeprecationWarning("setFrequency()", "the frequency property"); + int pulse_frequencyArg = 0; + + if(!PyArg_ParseTuple(args, "i:setFrequency", &pulse_frequencyArg)) { + return NULL; + } + + /* We can do three things here: clip, ignore and raise an exception. */ + /* Exceptions don't work yet, ignoring is not desirable now... */ + if (pulse_frequencyArg < 0) { + pulse_frequencyArg = 0; + }; + m_pulse_frequency = pulse_frequencyArg; + + Py_RETURN_NONE; +} + + +const char SCA_ISensor::GetInvert_doc[] = +"getInvert()\n" +"\tReturns whether or not pulses from this sensor are inverted.\n" ; +PyObject* SCA_ISensor::PyGetInvert() +{ + ShowDeprecationWarning("getInvert()", "the invert property"); + return BoolToPyArg(m_invert); +} + +const char SCA_ISensor::SetInvert_doc[] = +"setInvert(invert?)\n" +"\t- invert?: Invert the event-values? (KX_TRUE, KX_FALSE)\n" +"\tSet whether to invert pulses.\n"; +PyObject* SCA_ISensor::PySetInvert(PyObject* args) +{ + ShowDeprecationWarning("setInvert()", "the invert property"); + int pyarg = 0; + if(!PyArg_ParseTuple(args, "i:setInvert", &pyarg)) { return NULL; } + m_invert = PyArgToBool(pyarg); + Py_RETURN_NONE; +} + +const char SCA_ISensor::GetLevel_doc[] = +"getLevel()\n" +"\tReturns whether this sensor is a level detector or a edge detector.\n" +"\tIt makes a difference only in case of logic state transition (state actuator).\n" +"\tA level detector will immediately generate a pulse, negative or positive\n" +"\tdepending on the sensor condition, as soon as the state is activated.\n" +"\tA edge detector will wait for a state change before generating a pulse.\n"; +PyObject* SCA_ISensor::PyGetLevel() +{ + ShowDeprecationWarning("getLevel()", "the level property"); + return BoolToPyArg(m_level); +} + +const char SCA_ISensor::SetLevel_doc[] = +"setLevel(level?)\n" +"\t- level?: Detect level instead of edge? (KX_TRUE, KX_FALSE)\n" +"\tSet whether to detect level or edge transition when entering a state.\n"; +PyObject* SCA_ISensor::PySetLevel(PyObject* args) +{ + ShowDeprecationWarning("setLevel()", "the level property"); + int pyarg = 0; + if(!PyArg_ParseTuple(args, "i:setLevel", &pyarg)) { return NULL; } + m_level = PyArgToBool(pyarg); + Py_RETURN_NONE; +} + +const char SCA_ISensor::GetUseNegPulseMode_doc[] = +"getUseNegPulseMode()\n" +"\tReturns whether negative pulse mode is active.\n"; +PyObject* SCA_ISensor::PyGetUseNegPulseMode() +{ + ShowDeprecationWarning("getUseNegPulseMode()", "the useNegPulseMode property"); + return BoolToPyArg(m_neg_pulsemode); +} + +const char SCA_ISensor::SetUseNegPulseMode_doc[] = +"setUseNegPulseMode(pulse?)\n" +"\t - pulse? : Pulse when a negative event occurs?\n" +"\t (KX_TRUE, KX_FALSE)\n" +"\tSet whether to do pulsing when negative pulses occur.\n"; +PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* args) +{ + ShowDeprecationWarning("setUseNegPulseMode()", "the useNegPulseMode property"); + int pyarg = 0; + if(!PyArg_ParseTuple(args, "i:setUseNegPulseMode", &pyarg)) { return NULL; } + m_neg_pulsemode = PyArgToBool(pyarg); + Py_RETURN_NONE; +} +//<------Deprecated + KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset, "reset()\n" "\tReset sensor internal state, effect depends on the type of sensor and settings.\n" @@ -329,6 +494,32 @@ PyTypeObject SCA_ISensor::Type = { }; PyMethodDef SCA_ISensor::Methods[] = { + //Deprecated functions -----> + {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive, + METH_NOARGS, (const char *)IsPositive_doc}, + {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered, + METH_VARARGS, (const char *)IsTriggered_doc}, + {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode, + METH_NOARGS, (const char *)GetUsePosPulseMode_doc}, + {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode, + METH_VARARGS, (const char *)SetUsePosPulseMode_doc}, + {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency, + METH_NOARGS, (const char *)GetFrequency_doc}, + {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency, + METH_VARARGS, (const char *)SetFrequency_doc}, + {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode, + METH_NOARGS, (const char *)GetUseNegPulseMode_doc}, + {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode, + METH_VARARGS, (const char *)SetUseNegPulseMode_doc}, + {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert, + METH_NOARGS, (const char *)GetInvert_doc}, + {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, + METH_VARARGS, (const char *)SetInvert_doc}, + {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel, + METH_NOARGS, (const char *)GetLevel_doc}, + {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, + METH_VARARGS, (const char *)SetLevel_doc}, + //<----- Deprecated KX_PYMETHODTABLE_NOARGS(SCA_ISensor, reset), {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 742b05bd88b..81864ab6a34 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -172,6 +172,21 @@ public: { return !m_links; } /* Python functions: */ + + //Deprecated functions -----> + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsTriggered); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUsePosPulseMode); + KX_PYMETHOD_DOC_VARARGS(SCA_ISensor,SetUsePosPulseMode); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetFrequency); + KX_PYMETHOD_DOC_VARARGS(SCA_ISensor,SetFrequency); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUseNegPulseMode); + KX_PYMETHOD_DOC_VARARGS(SCA_ISensor,SetUseNegPulseMode); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetInvert); + KX_PYMETHOD_DOC_VARARGS(SCA_ISensor,SetInvert); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetLevel); + KX_PYMETHOD_DOC_VARARGS(SCA_ISensor,SetLevel); + //<------ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,reset); static PyObject* pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 4936b380352..02be7cd6a08 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -48,6 +48,7 @@ SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr, int button, int hat, int hatf, bool allevents) :SCA_ISensor(gameobj,eventmgr), + m_pJoystickMgr(eventmgr), m_axis(axis), m_axisf(axisf), m_button(button), @@ -102,7 +103,7 @@ bool SCA_JoystickSensor::IsPositiveTrigger() bool SCA_JoystickSensor::Evaluate() { - SCA_Joystick *js = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); + SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice(m_joyindex); bool result = false; bool reset = m_reset && m_level; @@ -273,6 +274,24 @@ PyTypeObject SCA_JoystickSensor::Type = { }; PyMethodDef SCA_JoystickSensor::Methods[] = { + //Deprecated functions ------> + {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (const char *)GetIndex_doc}, + {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (const char *)SetIndex_doc}, + {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (const char *)GetAxis_doc}, + {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, (const char *)SetAxis_doc}, + {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetAxisValue, METH_NOARGS, (const char *)GetAxisValue_doc}, + {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, (const char *)GetThreshold_doc}, + {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (const char *)SetThreshold_doc}, + {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (const char *)GetButton_doc}, + {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_O, (const char *)SetButton_doc}, + {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (const char *)GetHat_doc}, + {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (const char *)SetHat_doc}, + {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (const char *)NumberOfAxes_doc}, + {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, (const char *)NumberOfButtons_doc}, + {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, (const char *)NumberOfHats_doc}, + {"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, (const char *)Connected_doc}, + {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(const char *)GetButtonValue_doc}, + //<----- Deprecated {"getButtonActiveList",(PyCFunction) SCA_JoystickSensor::sPyGetButtonActiveList, METH_NOARGS,(const char *)GetButtonActiveList_doc}, {"getButtonStatus",(PyCFunction) SCA_JoystickSensor::sPyGetButtonStatus, METH_VARARGS,(const char *)GetButtonStatus_doc}, {NULL,NULL} //Sentinel @@ -296,12 +315,144 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = { { NULL } //Sentinel }; + +/* get index ---------------------------------------------------------- */ +const char SCA_JoystickSensor::GetIndex_doc[] = +"getIndex\n" +"\tReturns the joystick index to use.\n"; +PyObject* SCA_JoystickSensor::PyGetIndex( ) { + ShowDeprecationWarning("getIndex()", "the index property"); + return PyLong_FromSsize_t(m_joyindex); +} + + +/* set index ---------------------------------------------------------- */ +const char SCA_JoystickSensor::SetIndex_doc[] = +"setIndex\n" +"\tSets the joystick index to use.\n"; +PyObject* SCA_JoystickSensor::PySetIndex( PyObject* value ) { + ShowDeprecationWarning("setIndex()", "the index property"); + int index = PyLong_AsSsize_t( value ); /* -1 on error, will raise an error in this case */ + if (index < 0 || index >= JOYINDEX_MAX) { + PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int"); + return NULL; + } + + m_joyindex = index; + Py_RETURN_NONE; +} + +/* get axis ---------------------------------------------------------- */ +const char SCA_JoystickSensor::GetAxis_doc[] = +"getAxis\n" +"\tReturns the current axis this sensor reacts to.\n"; +PyObject* SCA_JoystickSensor::PyGetAxis( ) { + ShowDeprecationWarning("getAxis()", "the axis property"); + return Py_BuildValue("[ii]",m_axis, m_axisf); +} + + +/* set axis ---------------------------------------------------------- */ +const char SCA_JoystickSensor::SetAxis_doc[] = +"setAxis\n" +"\tSets the current axis this sensor reacts to.\n"; +PyObject* SCA_JoystickSensor::PySetAxis( PyObject* args ) { + ShowDeprecationWarning("setAxis()", "the axis property"); + + int axis,axisflag; + if(!PyArg_ParseTuple(args, "ii:setAxis", &axis, &axisflag)){ + return NULL; + } + m_axis = axis; + m_axisf = axisflag; + + CheckAxis((void *)this, NULL); /* clamp values */ + Py_RETURN_NONE; +} + + +/* get axis value ----------------------------------------------------- */ +const char SCA_JoystickSensor::GetAxisValue_doc[] = +"getAxisValue\n" +"\tReturns a list of the values for the current state of each axis.\n"; +PyObject* SCA_JoystickSensor::PyGetAxisValue( ) { + ShowDeprecationWarning("getAxisValue()", "the axisPosition property"); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); + + int axis_index= joy->GetNumberOfAxes(); + PyObject *list= PyList_New(axis_index); + + while(axis_index--) { + PyList_SET_ITEM(list, axis_index, PyLong_FromSsize_t(joy->GetAxisPosition(axis_index))); + } + + return list; +} + + +/* get threshold ----------------------------------------------------- */ +const char SCA_JoystickSensor::GetThreshold_doc[] = +"getThreshold\n" +"\tReturns the threshold of the axis.\n"; +PyObject* SCA_JoystickSensor::PyGetThreshold( ) { + ShowDeprecationWarning("getThreshold()", "the threshold property"); + return PyLong_FromSsize_t(m_precision); +} + + +/* set threshold ----------------------------------------------------- */ +const char SCA_JoystickSensor::SetThreshold_doc[] = +"setThreshold\n" +"\tSets the threshold of the axis.\n"; +PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* args ) { + ShowDeprecationWarning("setThreshold()", "the threshold property"); + int thresh; + if(!PyArg_ParseTuple(args, "i:setThreshold", &thresh)){ + return NULL; + } + m_precision = thresh; + Py_RETURN_NONE; +} + +/* get button -------------------------------------------------------- */ +const char SCA_JoystickSensor::GetButton_doc[] = +"getButton\n" +"\tReturns the current button this sensor is checking.\n"; +PyObject* SCA_JoystickSensor::PyGetButton( ) { + ShowDeprecationWarning("getButton()", "the button property"); + return PyLong_FromSsize_t(m_button); +} + +/* set button -------------------------------------------------------- */ +const char SCA_JoystickSensor::SetButton_doc[] = +"setButton\n" +"\tSets the button the sensor reacts to.\n"; +PyObject* SCA_JoystickSensor::PySetButton( PyObject* value ) { + ShowDeprecationWarning("setButton()", "the button property"); + int button = PyLong_AsSsize_t(value); + if(button==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_ValueError, "expected an int"); + return NULL; + } + m_button = button; + Py_RETURN_NONE; +} + +/* get button value -------------------------------------------------- */ +const char SCA_JoystickSensor::GetButtonValue_doc[] = +"getButtonValue\n" +"\tReturns a list containing the indicies of the current pressed state of each button.\n"; +PyObject* SCA_JoystickSensor::PyGetButtonValue( ) { + ShowDeprecationWarning("getButtonValue()", "getButtonActiveList"); + return PyGetButtonActiveList( ); +} + /* get button active list -------------------------------------------------- */ const char SCA_JoystickSensor::GetButtonActiveList_doc[] = "getButtonActiveList\n" "\tReturns a list containing the indicies of the button currently pressed.\n"; PyObject* SCA_JoystickSensor::PyGetButtonActiveList( ) { - SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); PyObject *ls = PyList_New(0); PyObject *value; int i; @@ -323,7 +474,7 @@ const char SCA_JoystickSensor::GetButtonStatus_doc[] = "getButtonStatus(buttonIndex)\n" "\tReturns a bool of the current pressed state of the specified button.\n"; PyObject* SCA_JoystickSensor::PyGetButtonStatus( PyObject* args ) { - SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); int index; if(!PyArg_ParseTuple(args, "i:getButtonStatus", &index)){ @@ -335,10 +486,79 @@ PyObject* SCA_JoystickSensor::PyGetButtonStatus( PyObject* args ) { return PyBool_FromLong(0); } +/* get hat ----------------------------------------------------------- */ +const char SCA_JoystickSensor::GetHat_doc[] = +"getHat\n" +"\tReturns the current direction of the hat.\n"; +PyObject* SCA_JoystickSensor::PyGetHat( ) { + ShowDeprecationWarning("getHat()", "the hat property"); + return Py_BuildValue("[ii]",m_hat, m_hatf); +} + + +/* set hat ----------------------------------------------------------- */ +const char SCA_JoystickSensor::SetHat_doc[] = +"setHat\n" +"\tSets the hat the sensor reacts to.\n"; +PyObject* SCA_JoystickSensor::PySetHat( PyObject* args ) { + ShowDeprecationWarning("setHat()", "the hat property"); + int hat,hatflag; + if(!PyArg_ParseTuple(args, "ii:setHat", &hat, &hatflag)){ + return NULL; + } + m_hat = hat; + m_hatf = hatflag; + + CheckHat((void *)this, NULL); /* clamp values */ + Py_RETURN_NONE; +} + + +/* get # of ----------------------------------------------------- */ +const char SCA_JoystickSensor::NumberOfAxes_doc[] = +"getNumAxes\n" +"\tReturns the number of axes .\n"; +PyObject* SCA_JoystickSensor::PyNumberOfAxes( ) { + ShowDeprecationWarning("getNumAxes()", "the numAxis property"); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); + // when the joystick is null their is 0 exis still. dumb but scripters should use isConnected() + return PyLong_FromSsize_t( joy ? joy->GetNumberOfAxes() : 0 ); +} + + +const char SCA_JoystickSensor::NumberOfButtons_doc[] = +"getNumButtons\n" +"\tReturns the number of buttons .\n"; +PyObject* SCA_JoystickSensor::PyNumberOfButtons( ) { + ShowDeprecationWarning("getNumButtons()", "the numButtons property"); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); + return PyLong_FromSsize_t( joy ? joy->GetNumberOfButtons() : 0 ); +} + + +const char SCA_JoystickSensor::NumberOfHats_doc[] = +"getNumHats\n" +"\tReturns the number of hats .\n"; +PyObject* SCA_JoystickSensor::PyNumberOfHats( ) { + ShowDeprecationWarning("getNumHats()", "the numHats property"); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); + return PyLong_FromSsize_t( joy ? joy->GetNumberOfHats() : 0 ); +} + +const char SCA_JoystickSensor::Connected_doc[] = +"getConnected\n" +"\tReturns True if a joystick is connected at this joysticks index.\n"; +PyObject* SCA_JoystickSensor::PyConnected( ) { + ShowDeprecationWarning("getConnected()", "the connected property"); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); + return PyBool_FromLong( joy ? joy->Connected() : 0 ); +} + + PyObject* SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); int axis_index= joy->GetNumberOfAxes(); PyObject *list= PyList_New(axis_index); @@ -353,7 +573,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYAT PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); if(self->m_joymode != KX_JOYSENSORMODE_AXIS_SINGLE) { PyErr_SetString(PyExc_TypeError, "val = sensor.axisSingle: Joystick Sensor, not 'Single Axis' type"); @@ -366,7 +586,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT PyObject* SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); int hat_index= joy->GetNumberOfHats(); PyObject *list= PyList_New(hat_index); @@ -381,7 +601,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATT PyObject* SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t(joy->GetHat(self->m_hat-1)); } @@ -389,27 +609,27 @@ PyObject* SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATT PyObject* SCA_JoystickSensor::pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t( joy ? joy->GetNumberOfAxes() : 0 ); } PyObject* SCA_JoystickSensor::pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t( joy ? joy->GetNumberOfButtons() : 0 ); } PyObject* SCA_JoystickSensor::pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t( joy ? joy->GetNumberOfHats() : 0 ); } PyObject* SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); - SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); + SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); return PyBool_FromLong( joy ? joy->Connected() : 0 ); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index b793c591ac1..32f8ce567d2 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -35,6 +35,7 @@ class SCA_JoystickSensor :public SCA_ISensor { Py_Header; + class SCA_JoystickManager* m_pJoystickMgr; /** * Axis 1-JOYAXIS_MAX, MUST be followed by m_axisf @@ -122,8 +123,28 @@ public: /* --------------------------------------------------------------------- */ /* Joystick Index */ + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex); + KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetIndex); + /* Axes*/ + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxis); + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetAxis); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxisValue); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetThreshold); + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetThreshold); + /* Buttons */ + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButton); + KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetButton); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonValue); KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonActiveList); KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,GetButtonStatus); + /* Hats */ + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetHat); + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetHat); + /* number of */ + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfAxes); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfButtons); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfHats); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,Connected); static PyObject* pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index d2e3871fec2..f065452f8c6 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -50,6 +50,7 @@ SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr, const STR_String& toggleProp, SCA_IObject* gameobj) :SCA_ISensor(gameobj,keybdmgr), + m_pKeyboardMgr(keybdmgr), m_hotkey(hotkey), m_qual(qual), m_qual2(qual2), @@ -124,7 +125,7 @@ bool SCA_KeyboardSensor::Evaluate() bool qual_change = false; short int m_val_orig = m_val; - SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); + SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); // cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n"; /* See if we need to do logging: togPropState exists and is @@ -359,7 +360,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) */ bool SCA_KeyboardSensor::IsShifted(void) { - SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); + SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); if ( (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status == SCA_InputEvent::KX_ACTIVE) @@ -378,7 +379,7 @@ bool SCA_KeyboardSensor::IsShifted(void) void SCA_KeyboardSensor::LogKeystrokes(void) { - SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); + SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); int num = inputdev->GetNumActiveEvents(); /* weird loop, this one... */ @@ -408,6 +409,184 @@ void SCA_KeyboardSensor::LogKeystrokes(void) /* Python Functions */ /* ------------------------------------------------------------------------- */ +//Deprecated -----> +/** 1. GetKey : check which key this sensor looks at */ +const char SCA_KeyboardSensor::GetKey_doc[] = +"getKey()\n" +"\tReturn the code of the key this sensor is listening to.\n" ; +PyObject* SCA_KeyboardSensor::PyGetKey() +{ + ShowDeprecationWarning("getKey()", "the key property"); + return PyLong_FromSsize_t(m_hotkey); +} + +/** 2. SetKey: change the key to look at */ +const char SCA_KeyboardSensor::SetKey_doc[] = +"setKey(keycode)\n" +"\t- keycode: any code from GameKeys\n" +"\tSet the key this sensor should listen to.\n" ; +PyObject* SCA_KeyboardSensor::PySetKey(PyObject* args) +{ + ShowDeprecationWarning("setKey()", "the key property"); + int keyCode; + + if(!PyArg_ParseTuple(args, "i:setKey", &keyCode)) { + return NULL; + } + + /* Since we have symbolic constants for this in Python, we don't guard */ + /* anything. It's up to the user to provide a sensible number. */ + m_hotkey = keyCode; + + Py_RETURN_NONE; +} + +/** 3. GetHold1 : set the first bucky bit */ +const char SCA_KeyboardSensor::GetHold1_doc[] = +"getHold1()\n" +"\tReturn the code of the first key modifier to the key this \n" +"\tsensor is listening to.\n" ; +PyObject* SCA_KeyboardSensor::PyGetHold1() +{ + ShowDeprecationWarning("getHold1()", "the hold1 property"); + return PyLong_FromSsize_t(m_qual); +} + +/** 4. SetHold1: change the first bucky bit */ +const char SCA_KeyboardSensor::SetHold1_doc[] = +"setHold1(keycode)\n" +"\t- keycode: any code from GameKeys\n" +"\tSet the first modifier to the key this sensor should listen to.\n" ; +PyObject* SCA_KeyboardSensor::PySetHold1(PyObject* args) +{ + ShowDeprecationWarning("setHold1()", "the hold1 property"); + int keyCode; + + if(!PyArg_ParseTuple(args, "i:setHold1", &keyCode)) { + return NULL; + } + + /* Since we have symbolic constants for this in Python, we don't guard */ + /* anything. It's up to the user to provide a sensible number. */ + m_qual = keyCode; + + Py_RETURN_NONE; +} + +/** 5. GetHold2 : get the second bucky bit */ +const char SCA_KeyboardSensor::GetHold2_doc[] = +"getHold2()\n" +"\tReturn the code of the second key modifier to the key this \n" +"\tsensor is listening to.\n" ; +PyObject* SCA_KeyboardSensor::PyGetHold2() +{ + ShowDeprecationWarning("getHold2()", "the hold2 property"); + return PyLong_FromSsize_t(m_qual2); +} + +/** 6. SetHold2: change the second bucky bit */ +const char SCA_KeyboardSensor::SetHold2_doc[] = +"setHold2(keycode)\n" +"\t- keycode: any code from GameKeys\n" +"\tSet the first modifier to the key this sensor should listen to.\n" ; +PyObject* SCA_KeyboardSensor::PySetHold2(PyObject* args) +{ + ShowDeprecationWarning("setHold2()", "the hold2 property"); + int keyCode; + + if(!PyArg_ParseTuple(args, "i:setHold2", &keyCode)) { + return NULL; + } + + /* Since we have symbolic constants for this in Python, we don't guard */ + /* anything. It's up to the user to provide a sensible number. */ + m_qual2 = keyCode; + + Py_RETURN_NONE; +} + + +const char SCA_KeyboardSensor::GetPressedKeys_doc[] = +"getPressedKeys()\n" +"\tGet a list of pressed keys that have either been pressed, or just released this frame.\n" ; + +PyObject* SCA_KeyboardSensor::PyGetPressedKeys() +{ + ShowDeprecationWarning("getPressedKeys()", "events"); + + SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); + + int num = inputdev->GetNumJustEvents(); + PyObject* resultlist = PyList_New(num); + + if (num > 0) + { + + int index = 0; + + for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++) + { + const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); + if ((inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED) + || (inevent.m_status == SCA_InputEvent::KX_JUSTRELEASED)) + { + PyObject* keypair = PyList_New(2); + PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i)); + PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status)); + PyList_SET_ITEM(resultlist,index,keypair); + index++; + + if (index >= num) /* should not happen */ + break; + } + } + } + + return resultlist; +} + + + +const char SCA_KeyboardSensor::GetCurrentlyPressedKeys_doc[] = +"getCurrentlyPressedKeys()\n" +"\tGet a list of keys that are currently pressed.\n" ; + +PyObject* SCA_KeyboardSensor::PyGetCurrentlyPressedKeys() +{ + ShowDeprecationWarning("getCurrentlyPressedKeys()", "events"); + + SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); + + int num = inputdev->GetNumActiveEvents(); + PyObject* resultlist = PyList_New(num); + + if (num > 0) + { + int index = 0; + + for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++) + { + const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); + if ( (inevent.m_status == SCA_InputEvent::KX_ACTIVE) + || (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED)) + { + PyObject* keypair = PyList_New(2); + PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i)); + PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status)); + PyList_SET_ITEM(resultlist,index,keypair); + index++; + + if (index >= num) /* should never happen */ + break; + } + } + } + + return resultlist; +} + +//<---- Deprecated + KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, "getKeyStatus(keycode)\n" "\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n") @@ -425,7 +604,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, return NULL; } - SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); + SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) keycode); return PyLong_FromSsize_t(inevent.m_status); } @@ -457,6 +636,16 @@ PyTypeObject SCA_KeyboardSensor::Type = { }; PyMethodDef SCA_KeyboardSensor::Methods[] = { + //Deprecated functions ------> + {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_NOARGS, (const char *)GetKey_doc}, + {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (const char *)SetKey_doc}, + {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_NOARGS, (const char *)GetHold1_doc}, + {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (const char *)SetHold1_doc}, + {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_NOARGS, (const char *)GetHold2_doc}, + {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (const char *)SetHold2_doc}, + {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_NOARGS, (const char *)GetPressedKeys_doc}, + {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_NOARGS, (const char *)GetCurrentlyPressedKeys_doc}, + //<----- Deprecated KX_PYMETHODTABLE_O(SCA_KeyboardSensor, getKeyStatus), {NULL,NULL} //Sentinel }; @@ -477,7 +666,7 @@ PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU { SCA_KeyboardSensor* self= static_cast<SCA_KeyboardSensor*>(self_v); - SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)self->m_eventmgr)->GetInputDevice(); + SCA_IInputDevice* inputdev = self->m_pKeyboardMgr->GetInputDevice(); PyObject* resultlist = PyList_New(0); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index d7e0f301a9d..3185b386d41 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -43,6 +43,8 @@ class SCA_KeyboardSensor : public SCA_ISensor { Py_Header; + class SCA_KeyboardManager* m_pKeyboardMgr; + /** * the key this sensor is sensing for @@ -107,6 +109,25 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + //Deprecated functions -----> + /** 1. GetKey : check which key this sensor looks at */ + KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,GetKey); + /** 2. SetKey: change the key to look at */ + KX_PYMETHOD_DOC_VARARGS(SCA_KeyboardSensor,SetKey); + /** 3. GetHold1 : set the first bucky bit */ + KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,GetHold1); + /** 4. SetHold1: change the first bucky bit */ + KX_PYMETHOD_DOC_VARARGS(SCA_KeyboardSensor,SetHold1); + /** 5. GetHold2 : set the second bucky bit */ + KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,GetHold2); + /** 6. SetHold2: change the second bucky bit */ + KX_PYMETHOD_DOC_VARARGS(SCA_KeyboardSensor,SetHold2); + /** 9. GetPressedKeys: */ + KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,GetPressedKeys); + /** 9. GetCurrrentlyPressedKeys: */ + KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,GetCurrentlyPressedKeys); + // <------ + // KeyEvents: KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,getEventList); // KeyStatus: diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 9d32682eaa9..c6703452337 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -51,6 +51,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, short int mousemode, SCA_IObject* gameobj) : SCA_ISensor(gameobj,eventmgr), + m_pMouseMgr(eventmgr), m_x(startx), m_y(starty) { @@ -146,7 +147,7 @@ bool SCA_MouseSensor::Evaluate() { bool result = false; bool reset = m_reset && m_level; - SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice(); + SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice(); m_reset = false; switch (m_mousemode) { @@ -243,6 +244,30 @@ bool SCA_MouseSensor::isValid(SCA_MouseSensor::KX_MOUSESENSORMODE m) /* Python functions */ /* ------------------------------------------------------------------------- */ +//Deprecated functions ------> +/* get x position ---------------------------------------------------------- */ +const char SCA_MouseSensor::GetXPosition_doc[] = +"getXPosition\n" +"\tReturns the x-coordinate of the mouse sensor, in frame coordinates.\n" +"\tThe lower-left corner is the origin. The coordinate is given in\n" +"\tpixels\n"; +PyObject* SCA_MouseSensor::PyGetXPosition() { + ShowDeprecationWarning("getXPosition()", "the position property"); + return PyLong_FromSsize_t(m_x); +} + +/* get y position ---------------------------------------------------------- */ +const char SCA_MouseSensor::GetYPosition_doc[] = +"getYPosition\n" +"\tReturns the y-coordinate of the mouse sensor, in frame coordinates.\n" +"\tThe lower-left corner is the origin. The coordinate is given in\n" +"\tpixels\n"; +PyObject* SCA_MouseSensor::PyGetYPosition() { + ShowDeprecationWarning("getYPosition()", "the position property"); + return PyLong_FromSsize_t(m_y); +} +//<----- Deprecated + KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus, "getButtonStatus(button)\n" "\tGet the given button's status (KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED).\n") @@ -257,7 +282,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus, return NULL; } - SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice(); + SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice(); const SCA_InputEvent& event = mousedev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) button); return PyLong_FromSsize_t(event.m_status); } @@ -292,6 +317,10 @@ PyTypeObject SCA_MouseSensor::Type = { }; PyMethodDef SCA_MouseSensor::Methods[] = { + //Deprecated functions ------> + {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (const char *)GetXPosition_doc}, + {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (const char *)GetYPosition_doc}, + //<----- Deprecated KX_PYMETHODTABLE_O(SCA_MouseSensor, getButtonStatus), {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h index a679e605428..47f0378bf69 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.h +++ b/source/gameengine/GameLogic/SCA_MouseSensor.h @@ -39,6 +39,7 @@ class SCA_MouseSensor : public SCA_ISensor { Py_Header; + class SCA_MouseManager* m_pMouseMgr; /** * Use SCA_IInputDevice values to encode the mouse mode for now. @@ -106,6 +107,13 @@ class SCA_MouseSensor : public SCA_ISensor /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + + //Deprecated functions -----> + /* read x-coordinate */ + KX_PYMETHOD_DOC_NOARGS(SCA_MouseSensor,GetXPosition); + /* read y-coordinate */ + KX_PYMETHOD_DOC_NOARGS(SCA_MouseSensor,GetYPosition); + //<----- deprecated // get button status KX_PYMETHOD_DOC_O(SCA_MouseSensor,getButtonStatus); diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 9446487cdb7..5afb537c28a 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -250,6 +250,12 @@ PyTypeObject SCA_PropertyActuator::Type = { }; PyMethodDef SCA_PropertyActuator::Methods[] = { + //Deprecated functions ------> + {"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, (const char *)GetProperty_doc}, + {"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, (const char *)SetValue_doc}, + {"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, (const char *)GetValue_doc}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -260,4 +266,71 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = { { NULL } //Sentinel }; +/* 1. setProperty */ +const char SCA_PropertyActuator::SetProperty_doc[] = +"setProperty(name)\n" +"\t- name: string\n" +"\tSet the property on which to operate. If there is no property\n" +"\tof this name, the call is ignored.\n"; +PyObject* SCA_PropertyActuator::PySetProperty(PyObject* args, PyObject* kwds) +{ + ShowDeprecationWarning("setProperty()", "the 'propName' property"); + /* Check whether the name exists first ! */ + char *nameArg; + if (!PyArg_ParseTuple(args, "s:setProperty", &nameArg)) { + return NULL; + } + + CValue* prop = GetParent()->FindIdentifier(nameArg); + + if (!prop->IsError()) { + m_propname = nameArg; + } else { + ; /* not found ... */ + } + prop->Release(); + + Py_RETURN_NONE; +} + +/* 2. getProperty */ +const char SCA_PropertyActuator::GetProperty_doc[] = +"getProperty(name)\n" +"\tReturn the property on which the actuator operates.\n"; +PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* args, PyObject* kwds) +{ + ShowDeprecationWarning("getProperty()", "the 'propName' property"); + return PyUnicode_FromString(m_propname); +} + +/* 3. setValue */ +const char SCA_PropertyActuator::SetValue_doc[] = +"setValue(value)\n" +"\t- value: string\n" +"\tSet the value with which the actuator operates. If the value\n" +"\tis not compatible with the type of the property, the subsequent\n" +"\t action is ignored.\n"; +PyObject* SCA_PropertyActuator::PySetValue(PyObject* args, PyObject* kwds) +{ + ShowDeprecationWarning("setValue()", "the value property"); + char *valArg; + if(!PyArg_ParseTuple(args, "s:setValue", &valArg)) { + return NULL; + } + + if (valArg) m_exprtxt = valArg; + + Py_RETURN_NONE; +} + +/* 4. getValue */ +const char SCA_PropertyActuator::GetValue_doc[] = +"getValue()\n" +"\tReturns the value with which the actuator operates.\n"; +PyObject* SCA_PropertyActuator::PyGetValue(PyObject* args, PyObject* kwds) +{ + ShowDeprecationWarning("getValue()", "the value property"); + return PyUnicode_FromString(m_exprtxt); +} + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index 833547a5cd3..8fb2e7a7bc5 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -83,6 +83,14 @@ public: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + + // python wrapped methods + KX_PYMETHOD_DOC(SCA_PropertyActuator,SetProperty); + KX_PYMETHOD_DOC(SCA_PropertyActuator,GetProperty); + KX_PYMETHOD_DOC(SCA_PropertyActuator,SetValue); + KX_PYMETHOD_DOC(SCA_PropertyActuator,GetValue); + + /* 5. - ... setObject, getObject, setProp2, getProp2, setMode, getMode*/ }; diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h index a9692377df8..011f3285f63 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h @@ -40,17 +40,16 @@ class SCA_PropertyEventManager : public SCA_EventManager class SCA_LogicManager* m_logicmgr; public: - SCA_PropertyEventManager(class SCA_LogicManager* logicmgr); - virtual ~SCA_PropertyEventManager(); - virtual void NextFrame(); - //SCA_LogicManager* GetLogicManager() { return m_logicmgr;} - #ifdef WITH_CXX_GUARDEDALLOC -public: void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_PropertyEventManager"); } void operator delete( void *mem ) { MEM_freeN(mem); } #endif + + SCA_PropertyEventManager(class SCA_LogicManager* logicmgr); + virtual ~SCA_PropertyEventManager(); + virtual void NextFrame(); + //SCA_LogicManager* GetLogicManager() { return m_logicmgr;} }; #endif //__KX_PROPERTYEVENTMANAGER diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 9c09c8410fb..96c769bd3d3 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -324,6 +324,14 @@ PyTypeObject SCA_PropertySensor::Type = { }; PyMethodDef SCA_PropertySensor::Methods[] = { + //Deprecated functions ------> + {"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_NOARGS, (const char *)GetType_doc}, + {"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, (const char *)SetType_doc}, + {"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + {"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_NOARGS, (const char *)GetValue_doc}, + {"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, (const char *)SetValue_doc}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -334,4 +342,111 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = { { NULL } //Sentinel }; +/* 1. getType */ +const char SCA_PropertySensor::GetType_doc[] = +"getType()\n" +"\tReturns the type of check this sensor performs.\n"; +PyObject* SCA_PropertySensor::PyGetType() +{ + ShowDeprecationWarning("getType()", "the mode property"); + return PyLong_FromSsize_t(m_checktype); +} + +/* 2. setType */ +const char SCA_PropertySensor::SetType_doc[] = +"setType(type)\n" +"\t- type: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,\n" +"\t KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,\n" +"\t or KX_PROPSENSOR_EXPRESSION.\n" +"\tSet the type of check to perform.\n"; +PyObject* SCA_PropertySensor::PySetType(PyObject* args) +{ + ShowDeprecationWarning("setType()", "the mode property"); + int typeArg; + + if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) { + return NULL; + } + + if ( (typeArg > KX_PROPSENSOR_NODEF) + && (typeArg < KX_PROPSENSOR_MAX) ) { + m_checktype = typeArg; + } + + Py_RETURN_NONE; +} + +/* 3. getProperty */ +const char SCA_PropertySensor::GetProperty_doc[] = +"getProperty()\n" +"\tReturn the property with which the sensor operates.\n"; +PyObject* SCA_PropertySensor::PyGetProperty() +{ + ShowDeprecationWarning("getProperty()", "the 'propName' property"); + return PyUnicode_FromString(m_checkpropname); +} + +/* 4. setProperty */ +const char SCA_PropertySensor::SetProperty_doc[] = +"setProperty(name)\n" +"\t- name: string\n" +"\tSets the property with which to operate. If there is no property\n" +"\tof this name, the call is ignored.\n"; +PyObject* SCA_PropertySensor::PySetProperty(PyObject* args) +{ + ShowDeprecationWarning("setProperty()", "the 'propName' property"); + /* We should query whether the name exists. Or should we create a prop */ + /* on the fly? */ + char *propNameArg = NULL; + + if (!PyArg_ParseTuple(args, "s:setProperty", &propNameArg)) { + return NULL; + } + + CValue *prop = FindIdentifier(STR_String(propNameArg)); + if (!prop->IsError()) { + m_checkpropname = propNameArg; + } else { + ; /* error: bad property name */ + } + prop->Release(); + Py_RETURN_NONE; +} + +/* 5. getValue */ +const char SCA_PropertySensor::GetValue_doc[] = +"getValue()\n" +"\tReturns the value with which the sensor operates.\n"; +PyObject* SCA_PropertySensor::PyGetValue() +{ + ShowDeprecationWarning("getValue()", "the value property"); + return PyUnicode_FromString(m_checkpropval); +} + +/* 6. setValue */ +const char SCA_PropertySensor::SetValue_doc[] = +"setValue(value)\n" +"\t- value: string\n" +"\tSet the value with which the sensor operates. If the value\n" +"\tis not compatible with the type of the property, the subsequent\n" +"\t action is ignored.\n"; +PyObject* SCA_PropertySensor::PySetValue(PyObject* args) +{ + ShowDeprecationWarning("setValue()", "the value property"); + /* Here, we need to check whether the value is 'valid' for this property.*/ + /* We know that the property exists, or is NULL. */ + char *propValArg = NULL; + + if(!PyArg_ParseTuple(args, "s:setValue", &propValArg)) { + return NULL; + } + STR_String oldval = m_checkpropval; + m_checkpropval = propValArg; + if (validValueForProperty(m_proxy, NULL)) { + m_checkpropval = oldval; + return NULL; + } + Py_RETURN_NONE; +} + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index a5bbfc8438b..3513fcdf5ae 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -88,6 +88,18 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + /* 1. getType */ + KX_PYMETHOD_DOC_NOARGS(SCA_PropertySensor,GetType); + /* 2. setType */ + KX_PYMETHOD_DOC_VARARGS(SCA_PropertySensor,SetType); + /* 3. setProperty */ + KX_PYMETHOD_DOC_VARARGS(SCA_PropertySensor,SetProperty); + /* 4. getProperty */ + KX_PYMETHOD_DOC_NOARGS(SCA_PropertySensor,GetProperty); + /* 5. getValue */ + KX_PYMETHOD_DOC_NOARGS(SCA_PropertySensor,GetValue); + /* 6. setValue */ + KX_PYMETHOD_DOC_VARARGS(SCA_PropertySensor,SetValue); /** * Test whether this is a sensible value (type check) */ diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index ecaa8c508db..8ece7fb4ae1 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -204,7 +204,27 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) return false; } +/* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */ +PyObject* SCA_PythonController::sPyAddActiveActuator(PyObject* self, PyObject* args) +{ + ShowDeprecationWarning("GameLogic.addActiveActuator(act, bool)", "controller.activate(act) or controller.deactivate(act)"); + + PyObject* ob1; + int activate; + if (!PyArg_ParseTuple(args, "Oi:addActiveActuator", &ob1,&activate)) + return NULL; + + SCA_IActuator* actu = LinkedActuatorFromPy(ob1); + if(actu==NULL) + return NULL; + + bool boolval = (activate!=0); + m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu,boolval); + Py_RETURN_NONE; +} + const char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()"; +const char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuator(actuator,bool)"; PyTypeObject SCA_PythonController::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -231,6 +251,11 @@ PyTypeObject SCA_PythonController::Type = { PyMethodDef SCA_PythonController::Methods[] = { {"activate", (PyCFunction) SCA_PythonController::sPyActivate, METH_O}, {"deactivate", (PyCFunction) SCA_PythonController::sPyDeActivate, METH_O}, + + //Deprecated functions ------> + {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O}, + {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -485,6 +510,33 @@ PyObject* SCA_PythonController::PyDeActivate(PyObject *value) Py_RETURN_NONE; } +/* 1. getScript */ +PyObject* SCA_PythonController::PyGetScript() +{ + ShowDeprecationWarning("getScript()", "the script property"); + return PyUnicode_FromString(m_scriptText); +} + +/* 2. setScript */ +PyObject* SCA_PythonController::PySetScript(PyObject* value) +{ + char *scriptArg = _PyUnicode_AsString(value); + + ShowDeprecationWarning("setScript()", "the script property"); + + if (scriptArg==NULL) { + PyErr_SetString(PyExc_TypeError, "expected a string (script name)"); + return NULL; + } + + /* set scripttext sets m_bModified to true, + so next time the script is needed, a reparse into byte code is done */ + + this->SetScriptText(scriptArg); + + Py_RETURN_NONE; +} + PyObject* SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { //SCA_PythonController* self= static_cast<SCA_PythonController*>(static_cast<SCA_IController*>(static_cast<SCA_ILogicBrick*>(static_cast<CValue*>(static_cast<PyObjectPlus*>(self_v))))); diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index a3a5cc2303e..2b10f491378 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -337,6 +337,15 @@ PyTypeObject SCA_RandomActuator::Type = { }; PyMethodDef SCA_RandomActuator::Methods[] = { + //Deprecated functions ------> + {"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (const char *)SetSeed_doc}, + {"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_NOARGS, (const char *)GetSeed_doc}, + {"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_NOARGS, (const char *)GetPara1_doc}, + {"getPara2", (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_NOARGS, (const char *)GetPara2_doc}, + {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_NOARGS, (const char *)GetDistribution_doc}, + {"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + //<----- Deprecated KX_PYMETHODTABLE(SCA_RandomActuator, setBoolConst), KX_PYMETHODTABLE_NOARGS(SCA_RandomActuator, setBoolUniform), KX_PYMETHODTABLE(SCA_RandomActuator, setBoolBernouilli), @@ -380,6 +389,104 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_ } } +/* 1. setSeed */ +const char SCA_RandomActuator::SetSeed_doc[] = +"setSeed(seed)\n" +"\t- seed: integer\n" +"\tSet the initial seed of the generator. Equal seeds produce\n" +"\tequal series. If the seed is 0, the generator will produce\n" +"\tthe same value on every call.\n"; +PyObject* SCA_RandomActuator::PySetSeed(PyObject* args) { + ShowDeprecationWarning("setSeed()", "the seed property"); + long seedArg; + if(!PyArg_ParseTuple(args, "i:setSeed", &seedArg)) { + return NULL; + } + + m_base->SetSeed(seedArg); + + Py_RETURN_NONE; +} +/* 2. getSeed */ +const char SCA_RandomActuator::GetSeed_doc[] = +"getSeed()\n" +"\tReturns the initial seed of the generator. Equal seeds produce\n" +"\tequal series.\n"; +PyObject* SCA_RandomActuator::PyGetSeed() +{ + ShowDeprecationWarning("getSeed()", "the seed property"); + return PyLong_FromSsize_t(m_base->GetSeed()); +} + +/* 4. getPara1 */ +const char SCA_RandomActuator::GetPara1_doc[] = +"getPara1()\n" +"\tReturns the first parameter of the active distribution. Refer\n" +"\tto the documentation of the generator types for the meaning\n" +"\tof this value."; +PyObject* SCA_RandomActuator::PyGetPara1() +{ + ShowDeprecationWarning("getPara1()", "the para1 property"); + return PyFloat_FromDouble(m_parameter1); +} + +/* 6. getPara2 */ +const char SCA_RandomActuator::GetPara2_doc[] = +"getPara2()\n" +"\tReturns the first parameter of the active distribution. Refer\n" +"\tto the documentation of the generator types for the meaning\n" +"\tof this value."; +PyObject* SCA_RandomActuator::PyGetPara2() +{ + ShowDeprecationWarning("getPara2()", "the para2 property"); + return PyFloat_FromDouble(m_parameter2); +} + +/* 8. getDistribution */ +const char SCA_RandomActuator::GetDistribution_doc[] = +"getDistribution()\n" +"\tReturns the type of the active distribution.\n"; +PyObject* SCA_RandomActuator::PyGetDistribution() +{ + ShowDeprecationWarning("getDistribution()", "the distribution property"); + return PyLong_FromSsize_t(m_distribution); +} + +/* 9. setProperty */ +const char SCA_RandomActuator::SetProperty_doc[] = +"setProperty(name)\n" +"\t- name: string\n" +"\tSet the property to which the random value is assigned. If the \n" +"\tgenerator and property types do not match, the assignment is ignored.\n"; +PyObject* SCA_RandomActuator::PySetProperty(PyObject* args) { + ShowDeprecationWarning("setProperty()", "the 'propName' property"); + char *nameArg; + if (!PyArg_ParseTuple(args, "s:setProperty", &nameArg)) { + return NULL; + } + + CValue* prop = GetParent()->FindIdentifier(nameArg); + + if (!prop->IsError()) { + m_propname = nameArg; + } else { + ; /* not found ... */ + } + prop->Release(); + + Py_RETURN_NONE; +} +/* 10. getProperty */ +const char SCA_RandomActuator::GetProperty_doc[] = +"getProperty(name)\n" +"\tReturn the property to which the random value is assigned. If the \n" +"\tgenerator and property types do not match, the assignment is ignored.\n"; +PyObject* SCA_RandomActuator::PyGetProperty() +{ + ShowDeprecationWarning("getProperty()", "the 'propName' property"); + return PyUnicode_FromString(m_propname); +} + /* 11. setBoolConst */ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setBoolConst, "setBoolConst(value)\n" diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index f84c44b43c9..c7d3fe21217 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -99,6 +99,16 @@ class SCA_RandomActuator : public SCA_IActuator static PyObject* pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + // Deprecated methods -----> + KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator,SetSeed); + KX_PYMETHOD_DOC_NOARGS(SCA_RandomActuator,GetSeed); + KX_PYMETHOD_DOC_NOARGS(SCA_RandomActuator,GetPara1); + KX_PYMETHOD_DOC_NOARGS(SCA_RandomActuator,GetPara2); + KX_PYMETHOD_DOC_NOARGS(SCA_RandomActuator,GetDistribution); + KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator,SetProperty); + KX_PYMETHOD_DOC_NOARGS(SCA_RandomActuator,GetProperty); + // <----- + KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setBoolConst); KX_PYMETHOD_DOC_NOARGS(SCA_RandomActuator, setBoolUniform); KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setBoolBernouilli); diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 890875e61c6..a09d8328906 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -152,6 +152,11 @@ PyTypeObject SCA_RandomSensor::Type = { }; PyMethodDef SCA_RandomSensor::Methods[] = { + //Deprecated functions -----> + {"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, (const char *)SetSeed_doc}, + {"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_NOARGS, (const char *)GetSeed_doc}, + {"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_NOARGS, (const char *)GetLastDraw_doc}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -161,6 +166,45 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = { {NULL} //Sentinel }; +/* 1. setSeed */ +const char SCA_RandomSensor::SetSeed_doc[] = +"setSeed(seed)\n" +"\t- seed: integer\n" +"\tSet the initial seed of the generator. Equal seeds produce\n" +"\tequal series. If the seed is 0, the generator will produce\n" +"\tthe same value on every call.\n"; +PyObject* SCA_RandomSensor::PySetSeed(PyObject* args) { + ShowDeprecationWarning("setSeed()", "the seed property"); + long seedArg; + if(!PyArg_ParseTuple(args, "i:setSeed", &seedArg)) { + return NULL; + } + + m_basegenerator->SetSeed(seedArg); + + Py_RETURN_NONE; +} + +/* 2. getSeed */ +const char SCA_RandomSensor::GetSeed_doc[] = +"getSeed()\n" +"\tReturns the initial seed of the generator. Equal seeds produce\n" +"\tequal series.\n"; +PyObject* SCA_RandomSensor::PyGetSeed() { + ShowDeprecationWarning("getSeed()", "the seed property"); + return PyLong_FromSsize_t(m_basegenerator->GetSeed()); +} + +/* 3. getLastDraw */ +const char SCA_RandomSensor::GetLastDraw_doc[] = +"getLastDraw()\n" +"\tReturn the last value that was drawn.\n"; +PyObject* SCA_RandomSensor::PyGetLastDraw() { + ShowDeprecationWarning("getLastDraw()", "the lastDraw property"); + return PyLong_FromSsize_t(m_lastdraw); +} + + PyObject* SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v); diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index f93cf57370e..5e66c36cccf 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -59,6 +59,13 @@ public: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + + /* 1. setSeed */ + KX_PYMETHOD_DOC_VARARGS(SCA_RandomSensor,SetSeed); + /* 2. getSeed */ + KX_PYMETHOD_DOC_NOARGS(SCA_RandomSensor,GetSeed); + /* 3. getLastDraw */ + KX_PYMETHOD_DOC_NOARGS(SCA_RandomSensor,GetLastDraw); static PyObject* pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index 1530c71c7f3..837769e5e78 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -17,8 +17,12 @@ if env['WITH_BF_SDL']: else: defs.append('DISABLE_SDL') +cxxflags = [] if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') if env['BF_DEBUG']: defs.append('_DEBUG') -env.BlenderLib ( 'bf_logic', sources, Split(incs), defs, libtype=['core','player'], priority=[330,65], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'bf_logic', sources, Split(incs), defs, libtype=['core','player'], priority=[330, 100], cxx_compileflags=cxxflags ) diff --git a/source/gameengine/GamePlayer/CMakeLists.txt b/source/gameengine/GamePlayer/CMakeLists.txt index 7b4fa4892df..134f8fce3b2 100644 --- a/source/gameengine/GamePlayer/CMakeLists.txt +++ b/source/gameengine/GamePlayer/CMakeLists.txt @@ -28,5 +28,5 @@ ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(ghost) IF(WITH_WEBPLUGIN) - ADD_SUBDIRECTORY(xembed) + ADD_SUBDIRECTORY(xembed) ENDIF(WITH_WEBPLUGIN) diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index c865cf5ce25..af25f4b884e 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -25,50 +25,52 @@ # ***** END GPL LICENSE BLOCK ***** SET(SRC - bmfont.cpp - GPC_Canvas.cpp - GPC_Engine.cpp - GPC_KeyboardDevice.cpp - GPC_MouseDevice.cpp - GPC_RawImage.cpp - GPC_RawLoadDotBlendArray.cpp - GPC_RawLogoArrays.cpp - GPC_RenderTools.cpp - GPC_System.cpp + bmfont.cpp + GPC_Canvas.cpp + GPC_Engine.cpp + GPC_KeyboardDevice.cpp + GPC_MouseDevice.cpp + GPC_RawImage.cpp + GPC_RawLoadDotBlendArray.cpp + GPC_RawLogoArrays.cpp + GPC_RenderTools.cpp + GPC_System.cpp ) SET(INC - . - ../../../../intern/string - ../../../../intern/ghost - ../../../../intern/guardedalloc - ../../../../intern/moto/include - ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../../source/kernel/gen_system - ../../../../source/kernel/gen_messaging - ../../../../source/gameengine/Converter - ../../../../source/blender/imbuf - ../../../../source/gameengine/Ketsji - ../../../../source/blender/blenlib - ../../../../source/blender/blenkernel - ../../../../source/blender - ../../../../source/blender/include - ../../../../source/blender/makesdna - ../../../../source/gameengine/Rasterizer - ../../../../source/gameengine/GameLogic - ../../../../source/gameengine/Expressions - ../../../../source/gameengine/Network - ../../../../source/gameengine/SceneGraph - ../../../../source/gameengine/Physics/common - ../../../../source/gameengine/Network/LoopBackNetwork - ../../../../source/gameengine/GamePlayer/ghost - ../../../../source/blender/misc - ../../../../source/blender/blenloader - ../../../../source/blender/gpu - ../../../../extern/glew/include - ${PYTHON_INC} - ${PNG_INC} - ${ZLIB_INC} + . + ../../../../intern/string + ../../../../intern/ghost + ../../../../intern/guardedalloc + ../../../../intern/moto/include + ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer + ../../../../source/kernel/gen_system + ../../../../source/kernel/gen_messaging + ../../../../source/gameengine/Converter + ../../../../source/blender/imbuf + ../../../../source/gameengine/Ketsji + ../../../../source/blender/blenlib + ../../../../source/blender/blenkernel + ../../../../source/blender + ../../../../source/blender/include + ../../../../source/blender/makesdna + ../../../../source/gameengine/Rasterizer + ../../../../source/gameengine/GameLogic + ../../../../source/gameengine/Expressions + ../../../../source/gameengine/Network + ../../../../source/gameengine/SceneGraph + ../../../../source/gameengine/Physics/common + ../../../../source/gameengine/Physics/Sumo + ../../../../source/gameengine/Physics/Sumo/Fuzzics/include + ../../../../source/gameengine/Network/LoopBackNetwork + ../../../../source/gameengine/GamePlayer/ghost + ../../../../source/blender/misc + ../../../../source/blender/blenloader + ../../../../source/blender/gpu + ../../../../extern/glew/include + ${PYTHON_INC} + ${PNG_INC} + ${ZLIB_INC} ) BLENDERLIB_NOLIST(gp_common "${SRC}" "${INC}") diff --git a/source/gameengine/GamePlayer/common/GPC_Engine.cpp b/source/gameengine/GamePlayer/common/GPC_Engine.cpp index 85a362d042a..a46f30c1209 100644 --- a/source/gameengine/GamePlayer/common/GPC_Engine.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Engine.cpp @@ -58,6 +58,7 @@ #include "NG_LoopBackNetworkDeviceInterface.h" #include "RAS_IRenderTools.h" +#include "SND_DeviceManager.h" #include "GPC_Engine.h" #include "GPC_KeyboardDevice.h" @@ -74,7 +75,8 @@ GPC_Engine::GPC_Engine(char *customLoadingAnimationURL, m_system(NULL), m_keyboarddev(NULL), m_mousedev(NULL), m_canvas(NULL), m_rendertools(NULL), m_portal(NULL), m_sceneconverter(NULL), m_networkdev(NULL), - m_curarea(NULL), m_customLoadingAnimationURL(NULL), + m_audiodevice(NULL), m_curarea(NULL), + m_customLoadingAnimationURL(NULL), m_foregroundColor(foregroundColor), m_backgroundColor(backgroundColor), m_frameRate(frameRate), m_BlenderLogo(0), m_Blender3DLogo(0)/*, m_NaNLogo(0)*/ @@ -199,6 +201,7 @@ bool GPC_Engine::StartKetsji(void) m_keyboarddev, m_mousedev, m_networkdev, + m_audiodevice, m_system); m_system->SetMainLoop(m_portal->m_ketsjieng); @@ -334,6 +337,12 @@ void GPC_Engine::Exit() m_networkdev = 0; } + if (m_audiodevice) + { + SND_DeviceManager::Unsubscribe(); + m_audiodevice = 0; + } + m_initialized = false; } diff --git a/source/gameengine/GamePlayer/common/GPC_Engine.h b/source/gameengine/GamePlayer/common/GPC_Engine.h index 42234bcbcd6..b7121599c6e 100644 --- a/source/gameengine/GamePlayer/common/GPC_Engine.h +++ b/source/gameengine/GamePlayer/common/GPC_Engine.h @@ -40,6 +40,7 @@ class RAS_IRenderTools; class KetsjiPortal; class KX_ISceneConverter; class NG_LoopBackNetworkDeviceInterface; +class SND_IAudioDevice; class GPC_RawImage; @@ -76,6 +77,8 @@ public: KX_ISceneConverter* m_sceneconverter; /** Network interface. */ NG_LoopBackNetworkDeviceInterface* m_networkdev; + /** Audiodevice interface */ + SND_IAudioDevice* m_audiodevice; struct ScrArea *m_curarea; // for future use, not used yet diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index dd5a48c2b55..1942cde2531 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -62,4 +62,10 @@ incs += Split(env['BF_PYTHON_INC']) incs += Split(env['BF_PNG_INC']) incs += Split(env['BF_ZLIB_INC']) -env.BlenderLib (libname='gp_common', sources=source_files, includes=incs, defines = [], libtype=['player'], priority=[5], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib (libname='gp_common', sources=source_files, includes=incs, defines = [], libtype='player', priority=5, cxx_compileflags=cxxflags) diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index d50784cb967..e07a7fb26ad 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -25,49 +25,52 @@ # ***** END GPL LICENSE BLOCK ***** SET(SRC - GPG_Application.cpp - GPG_Canvas.cpp - GPG_ghost.cpp - GPG_KeyboardDevice.cpp - GPG_System.cpp + GPG_Application.cpp + GPG_Canvas.cpp + GPG_ghost.cpp + GPG_KeyboardDevice.cpp + GPG_System.cpp ) SET(INC - . - ../../../../intern/string - ../../../../intern/ghost - ../../../../intern/guardedalloc - ../../../../intern/moto/include - ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../../source/kernel/gen_system - ../../../../source/kernel/gen_messaging - ../../../../source/gameengine/Converter - ../../../../source/blender/imbuf - ../../../../source/gameengine/Ketsji - ../../../../source/blender/blenlib - ../../../../source/blender/blenkernel - ../../../../source/blender/readblenfile - ../../../../source/blender - ../../../../source/blender/include - ../../../../source/blender/makesdna - ../../../../source/blender/makesrna - ../../../../source/gameengine/Rasterizer - ../../../../source/gameengine/GameLogic - ../../../../source/gameengine/Expressions - ../../../../source/gameengine/Network - ../../../../source/gameengine/SceneGraph - ../../../../source/gameengine/Physics/common - ../../../../source/gameengine/Network/LoopBackNetwork - ../../../../source/gameengine/GamePlayer/common - ../../../../source/blender/misc - ../../../../source/blender/blenloader - ../../../../source/blender/gpu - ../../../../extern/glew/include - ${PYTHON_INC} + . + ../../../../intern/string + ../../../../intern/ghost + ../../../../intern/guardedalloc + ../../../../intern/moto/include + ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer + ../../../../source/kernel/gen_system + ../../../../source/kernel/gen_messaging + ../../../../source/gameengine/Converter + ../../../../source/blender/imbuf + ../../../../source/gameengine/Ketsji + ../../../../source/blender/blenlib + ../../../../source/blender/blenkernel + ../../../../source/blender/readblenfile + ../../../../source/blender + ../../../../source/blender/include + ../../../../source/blender/makesdna + ../../../../source/blender/makesrna + ../../../../source/gameengine/Rasterizer + ../../../../source/gameengine/GameLogic + ../../../../source/gameengine/Expressions + ../../../../source/gameengine/Network + ../../../../source/gameengine/SceneGraph + ../../../../source/gameengine/Physics/common + ../../../../source/gameengine/Physics/Sumo + ../../../../source/gameengine/Physics/Sumo/Fuzzics/include + ../../../../source/gameengine/Network/LoopBackNetwork + ../../../../source/gameengine/GamePlayer/common + ../../../../source/blender/misc + ../../../../source/blender/blenloader + ../../../../source/blender/gpu + ../../../../extern/solid + ../../../../extern/glew/include + ${PYTHON_INC} ) IF(WITH_FFMPEG) - ADD_DEFINITIONS(-DWITH_FFMPEG) + ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) BLENDERLIB_NOLIST(gp_ghost "${SRC}" "${INC}") diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 8ec41968042..c9a2e81bdae 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -57,7 +57,6 @@ extern "C" #include "BLO_readfile.h" #include "BKE_global.h" #include "BKE_main.h" -#include "BKE_sound.h" #include "IMB_imbuf.h" #include "DNA_scene_types.h" #ifdef __cplusplus @@ -85,6 +84,7 @@ extern "C" #include "KX_BlenderSceneConverter.h" #include "NG_LoopBackNetworkDeviceInterface.h" +#include "SND_DeviceManager.h" #include "GPC_MouseDevice.h" #include "GPC_RenderTools.h" @@ -125,7 +125,8 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) m_rendertools(0), m_rasterizer(0), m_sceneconverter(0), - m_networkdevice(0), + m_networkdevice(0), + m_audiodevice(0), m_blendermat(0), m_blenderglslmat(0), m_pyGlobalDictString(0), @@ -583,8 +584,13 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (!m_networkdevice) goto initFailed; - sound_init(); - + // get an audiodevice + SND_DeviceManager::Subscribe(); + m_audiodevice = SND_DeviceManager::Instance(); + if (!m_audiodevice) + goto initFailed; + m_audiodevice->UseCD(); + // create a ketsjisystem (only needed for timing and stuff) m_kxsystem = new GPG_System (m_system); if (!m_kxsystem) @@ -601,7 +607,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) m_ketsjiengine->SetRenderTools(m_rendertools); m_ketsjiengine->SetRasterizer(m_rasterizer); m_ketsjiengine->SetNetworkDevice(m_networkdevice); - + m_ketsjiengine->SetAudioDevice(m_audiodevice); m_ketsjiengine->SetTimingDisplay(frameRate, false, false); CValue::SetDeprecationWarnings(nodepwarnings); @@ -614,8 +620,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) return m_engineInitialized; initFailed: - sound_exit(); delete m_kxsystem; + delete m_audiodevice; delete m_networkdevice; delete m_mouse; delete m_keyboard; @@ -628,6 +634,7 @@ initFailed: m_keyboard = NULL; m_mouse = NULL; m_networkdevice = NULL; + m_audiodevice = NULL; m_kxsystem = NULL; return false; } @@ -673,6 +680,7 @@ bool GPG_Application::startEngine(void) KX_Scene* startscene = new KX_Scene(m_keyboard, m_mouse, m_networkdevice, + m_audiodevice, startscenename, m_startScene); @@ -762,7 +770,6 @@ void GPG_Application::stopEngine() void GPG_Application::exitEngine() { - sound_exit(); if (m_ketsjiengine) { stopEngine(); @@ -774,6 +781,11 @@ void GPG_Application::exitEngine() delete m_kxsystem; m_kxsystem = 0; } + if (m_audiodevice) + { + SND_DeviceManager::Unsubscribe(); + m_audiodevice = 0; + } if (m_networkdevice) { delete m_networkdevice; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 73430213078..845686f5770 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -38,6 +38,7 @@ class KX_KetsjiEngine; class KX_ISceneConverter; class NG_LoopBackNetworkDeviceInterface; +class SND_IAudioDevice; class RAS_IRasterizer; class GHOST_IEvent; class GHOST_ISystem; @@ -141,6 +142,8 @@ protected: KX_ISceneConverter* m_sceneconverter; /** Network interface. */ NG_LoopBackNetworkDeviceInterface* m_networkdevice; + /** Sound device. */ + SND_IAudioDevice* m_audiodevice; bool m_blendermat; bool m_blenderglslmat; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index fb2e1c72a85..2433c587179 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -61,16 +61,12 @@ extern "C" #include "BKE_report.h" #include "BLI_blenlib.h" #include "DNA_scene_types.h" -#include "DNA_userdef_types.h" #include "BLO_readfile.h" #include "BLO_readblenfile.h" #include "IMB_imbuf.h" int GHOST_HACK_getFirstFile(char buf[]); -extern char bprogname[]; /* holds a copy of argv[0], from creator.c */ -extern char btempdir[]; /* use this to store a valid temp directory */ - #ifdef __cplusplus } #endif // __cplusplus @@ -391,13 +387,6 @@ int main(int argc, char** argv) } } #endif - // XXX add the ability to change this values to the command line parsing. - U.mixbufsize = 2048; - U.audiodevice = 2; - U.audiorate = 44100; - U.audioformat = 0x24; - U.audiochannels = 2; - for (i = 1; (i < argc) && !error #ifdef WIN32 && scr_saver_mode == SCREEN_SAVER_MODE_NONE diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index fdd7792b72a..83bc61381c0 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -42,8 +42,14 @@ incs = ['.', incs += Split(env['BF_PYTHON_INC']) -defs = [] +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +defs = '' if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') + defs += ' WITH_FFMPEG' -env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = defs, libtype=['player'],priority=[0], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = Split(defs), libtype='player',priority=5, cxx_compileflags=cxxflags) diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 01d369bc7a9..77bdd80721f 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -27,45 +27,48 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../source/kernel/gen_system - ../../../intern/string - ../../../intern/guardedalloc - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/Converter - ../../../source/blender/imbuf - ../../../intern/ghost/include - ../../../intern/moto/include - ../../../source/gameengine/Ketsji - ../../../source/blender/blenlib - ../../../source/blender/blenkernel - ../../../source/blender/python - ../../../source/blender/python/generic - ../../../source/blender - ../../../source/blender/include - ../../../source/blender/makesdna - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/GameLogic - ../../../source/gameengine/Expressions - ../../../source/gameengine/Ketsji/KXNetwork - ../../../source/gameengine/Network - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Physics/common - ../../../source/gameengine/Physics/Bullet - ../../../source/gameengine/Network/LoopBackNetwork - ../../../intern/audaspace/intern - ../../../source/blender/misc - ../../../source/blender/blenloader - ../../../source/blender/gpu - ../../../extern/bullet2/src - ../../../extern/glew/include - ${PYTHON_INC} + . + ../../../source/kernel/gen_system + ../../../intern/string + ../../../intern/guardedalloc + ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer + ../../../source/gameengine/Converter + ../../../source/blender/imbuf + ../../../intern/ghost/include + ../../../intern/moto/include + ../../../source/gameengine/Ketsji + ../../../source/blender/blenlib + ../../../source/blender/blenkernel + ../../../source/blender/python + ../../../source/blender/python/generic + ../../../source/blender + ../../../source/blender/include + ../../../source/blender/makesdna + ../../../source/gameengine/Rasterizer + ../../../source/gameengine/GameLogic + ../../../source/gameengine/Expressions + ../../../source/gameengine/Ketsji/KXNetwork + ../../../source/gameengine/Network + ../../../source/gameengine/SceneGraph + ../../../source/gameengine/Physics/common + ../../../source/gameengine/Physics/Bullet + ../../../source/gameengine/Physics/Sumo + ../../../source/gameengine/Physics/Sumo/Fuzzics/include + ../../../source/gameengine/Network/LoopBackNetwork + ../../../intern/audaspace/intern + ../../../source/blender/misc + ../../../source/blender/blenloader + ../../../source/blender/gpu + ../../../extern/bullet2/src + ../../../extern/solid + ../../../extern/glew/include + ${PYTHON_INC} ) IF(WITH_SDL) - SET(INC ${INC} ${SDL_INCLUDE_DIR}) + SET(INC ${INC} ${SDL_INCLUDE_DIR}) ELSE(WITH_SDL) - ADD_DEFINITIONS(-DDISABLE_SDL) + ADD_DEFINITIONS(-DDISABLE_SDL) ENDIF(WITH_SDL) BLENDERLIB(bf_ketsji "${SRC}" "${INC}") diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt index b89b0dcff9f..d9a9fc54f4b 100644 --- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt +++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt @@ -27,16 +27,16 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../../source/kernel/gen_system - ../../../../intern/string - ../../../../intern/moto/include - ../../../../source/gameengine/Ketsji - ../../../../source/gameengine/GameLogic - ../../../../source/gameengine/Expressions - ../../../../source/gameengine/SceneGraph - ../../../../source/gameengine/Network - ${PYTHON_INC} + . + ../../../../source/kernel/gen_system + ../../../../intern/string + ../../../../intern/moto/include + ../../../../source/gameengine/Ketsji + ../../../../source/gameengine/GameLogic + ../../../../source/gameengine/Expressions + ../../../../source/gameengine/SceneGraph + ../../../../source/gameengine/Network + ${PYTHON_INC} ) BLENDERLIB(kx_network "${SRC}" "${INC}") diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index 3af8f765251..410cf308217 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -123,6 +123,16 @@ PyTypeObject KX_NetworkMessageActuator::Type = { }; PyMethodDef KX_NetworkMessageActuator::Methods[] = { + // Deprecated -----> + {"setToPropName", (PyCFunction) + KX_NetworkMessageActuator::sPySetToPropName, METH_VARARGS}, + {"setSubject", (PyCFunction) + KX_NetworkMessageActuator::sPySetSubject, METH_VARARGS}, + {"setBodyType", (PyCFunction) + KX_NetworkMessageActuator::sPySetBodyType, METH_VARARGS}, + {"setBody", (PyCFunction) + KX_NetworkMessageActuator::sPySetBody, METH_VARARGS}, + // <----- {NULL,NULL} // Sentinel }; @@ -133,3 +143,78 @@ PyAttributeDef KX_NetworkMessageActuator::Attributes[] = { KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body), { NULL } //Sentinel }; + +// Deprecated -----> +// 1. SetToPropName +PyObject* KX_NetworkMessageActuator::PySetToPropName( + PyObject* args, + PyObject* kwds) +{ + ShowDeprecationWarning("setToProp()", "the propName property"); + char* ToPropName; + + if (PyArg_ParseTuple(args, "s:setToPropName", &ToPropName)) { + m_toPropName = ToPropName; + } + else { + return NULL; + } + + Py_RETURN_NONE; +} + +// 2. SetSubject +PyObject* KX_NetworkMessageActuator::PySetSubject( + PyObject* args, + PyObject* kwds) +{ + ShowDeprecationWarning("setSubject()", "the subject property"); + char* Subject; + + if (PyArg_ParseTuple(args, "s:setSubject", &Subject)) { + m_subject = Subject; + } + else { + return NULL; + } + + Py_RETURN_NONE; +} + +// 3. SetBodyType +PyObject* KX_NetworkMessageActuator::PySetBodyType( + PyObject* args, + PyObject* kwds) +{ + ShowDeprecationWarning("setBodyType()", "the usePropBody property"); + int BodyType; + + if (PyArg_ParseTuple(args, "i:setBodyType", &BodyType)) { + m_bPropBody = (BodyType != 0); + } + else { + return NULL; + } + + Py_RETURN_NONE; +} + +// 4. SetBody +PyObject* KX_NetworkMessageActuator::PySetBody( + PyObject* args, + PyObject* kwds) +{ + ShowDeprecationWarning("setBody()", "the body property"); + char* Body; + + if (PyArg_ParseTuple(args, "s:setBody", &Body)) { + m_body = Body; + } + else { + return NULL; + } + + Py_RETURN_NONE; +} + +// <----- Deprecated diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h index fa7a674c250..b4f55f2a466 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h @@ -60,6 +60,13 @@ public: /* Python interface ------------------------------------------- */ /* ------------------------------------------------------------ */ + // Deprecated -----> + KX_PYMETHOD(KX_NetworkMessageActuator, SetToPropName); + KX_PYMETHOD(KX_NetworkMessageActuator, SetSubject); + KX_PYMETHOD(KX_NetworkMessageActuator, SetBodyType); + KX_PYMETHOD(KX_NetworkMessageActuator, SetBody); + // <----- + }; #endif //__KX_NETWORKMESSAGEACTUATOR_H diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 392e9dd9d1b..7123277d4ef 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -53,6 +53,7 @@ KX_NetworkMessageSensor::KX_NetworkMessageSensor( const STR_String &subject ) : SCA_ISensor(gameobj,eventmgr), + m_Networkeventmgr(eventmgr), m_NetworkScene(NetworkScene), m_subject(subject), m_frame_message_count (0), @@ -186,6 +187,23 @@ PyTypeObject KX_NetworkMessageSensor::Type = { }; PyMethodDef KX_NetworkMessageSensor::Methods[] = { + // Deprecated -----> + {"setSubjectFilterText", (PyCFunction) + KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_O, + (const char *)SetSubjectFilterText_doc}, + {"getFrameMessageCount", (PyCFunction) + KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_NOARGS, + (const char *)GetFrameMessageCount_doc}, + {"getBodies", (PyCFunction) + KX_NetworkMessageSensor::sPyGetBodies, METH_NOARGS, + (const char *)GetBodies_doc}, + {"getSubject", (PyCFunction) + KX_NetworkMessageSensor::sPyGetSubject, METH_NOARGS, + (const char *)GetSubject_doc}, + {"getSubjects", (PyCFunction) + KX_NetworkMessageSensor::sPyGetSubjects, METH_NOARGS, + (const char *)GetSubjects_doc}, + // <----- {NULL,NULL} //Sentinel }; @@ -216,3 +234,75 @@ PyObject* KX_NetworkMessageSensor::pyattr_get_subjects(void *self_v, const KX_PY return (new CListValue())->NewProxy(true); } } + +// Deprecated -----> +// 1. Set the message subject that this sensor listens for +const char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] = +"\tsetSubjectFilterText(value)\n" +"\tChange the message subject text that this sensor is listening to.\n"; + +PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText(PyObject* value) +{ + ShowDeprecationWarning("setSubjectFilterText()", "subject"); + char* Subject = _PyUnicode_AsString(value); + if (Subject==NULL) { + PyErr_SetString(PyExc_TypeError, "sensor.tsetSubjectFilterText(string): KX_NetworkMessageSensor, expected a string message"); + return NULL; + } + + m_subject = Subject; + Py_RETURN_NONE; +} + +// 2. Get the number of messages received since the last frame +const char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] = +"\tgetFrameMessageCount()\n" +"\tGet the number of messages received since the last frame.\n"; + +PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount() +{ + ShowDeprecationWarning("getFrameMessageCount()", "frameMessageCount"); + return PyLong_FromSsize_t(long(m_frame_message_count)); +} + +// 3. Get the message bodies +const char KX_NetworkMessageSensor::GetBodies_doc[] = +"\tgetBodies()\n" +"\tGet the list of message bodies.\n"; + +PyObject* KX_NetworkMessageSensor::PyGetBodies() +{ + ShowDeprecationWarning("getBodies()", "bodies"); + if (m_BodyList) { + return m_BodyList->GetProxy(); + } else { + return (new CListValue())->NewProxy(true); + } +} + +// 4. Get the message subject: field of the message sensor +const char KX_NetworkMessageSensor::GetSubject_doc[] = +"\tgetSubject()\n" +"\tGet the subject: field of the message sensor.\n"; + +PyObject* KX_NetworkMessageSensor::PyGetSubject() +{ + ShowDeprecationWarning("getSubject()", "subject"); + return PyUnicode_FromString(m_subject ? m_subject : ""); +} + +// 5. Get the message subjects +const char KX_NetworkMessageSensor::GetSubjects_doc[] = +"\tgetSubjects()\n" +"\tGet list of message subjects.\n"; + +PyObject* KX_NetworkMessageSensor::PyGetSubjects() +{ + ShowDeprecationWarning("getSubjects()", "subjects"); + if (m_SubjectList) { + return m_SubjectList->GetProxy(); + } else { + return (new CListValue())->NewProxy(true); + } +} +// <----- Deprecated diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index d8a0651d2f1..ade87697303 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -39,6 +39,7 @@ class KX_NetworkMessageSensor : public SCA_ISensor { // note: Py_Header MUST BE the first listed here Py_Header; + KX_NetworkEventManager *m_Networkeventmgr; NG_NetworkScene *m_NetworkScene; // The subject we filter on. @@ -70,6 +71,14 @@ public: /* Python interface -------------------------------------------- */ /* ------------------------------------------------------------- */ + // Deprecated -----> + KX_PYMETHOD_DOC_O(KX_NetworkMessageSensor, SetSubjectFilterText); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetFrameMessageCount); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetBodies); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubject); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubjects); + // <----- + /* attributes */ static PyObject* pyattr_get_bodies(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_subjects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript index 8f88511acca..e6584b55ed2 100644 --- a/source/gameengine/Ketsji/KXNetwork/SConscript +++ b/source/gameengine/Ketsji/KXNetwork/SConscript @@ -9,4 +9,11 @@ incs += ' #source/gameengine/Network #source/gameengine/SceneGraph' incs += ' ' + env['BF_PYTHON_INC'] -env.BlenderLib ( 'bf_network', Split(sources), Split(incs), defines=[],libtype=['core','player'], priority=[400,125], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + + +env.BlenderLib ( 'kx_network', Split(sources), Split(incs), defines=[],libtype=['core', 'player'], priority=[400, 145], cxx_compileflags=cxxflags ) diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 0832809772d..fd289a0b55e 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -496,6 +496,12 @@ PyMethodDef KX_Camera::Methods[] = { KX_PYMETHODTABLE_O(KX_Camera, getScreenPosition), KX_PYMETHODTABLE(KX_Camera, getScreenVect), KX_PYMETHODTABLE(KX_Camera, getScreenRay), + + // DEPRECATED + KX_PYMETHODTABLE_O(KX_Camera, enableViewport), + KX_PYMETHODTABLE_NOARGS(KX_Camera, getProjectionMatrix), + KX_PYMETHODTABLE_O(KX_Camera, setProjectionMatrix), + {NULL,NULL} //Sentinel }; @@ -674,6 +680,92 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, getWorldToCamera, return PyObjectFrom(GetWorldToCamera()); /* new ref */ } +KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, getProjectionMatrix, +"getProjectionMatrix() -> Matrix4x4\n" +"\treturns this camera's projection matrix, as a list of four lists of four values.\n\n" +"\tie: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])\n" +) +{ + ShowDeprecationWarning("getProjectionMatrix()", "the projection_matrix property"); + return PyObjectFrom(GetProjectionMatrix()); /* new ref */ +} + +KX_PYMETHODDEF_DOC_O(KX_Camera, setProjectionMatrix, +"setProjectionMatrix(MT_Matrix4x4 m) -> None\n" +"\tSets this camera's projection matrix\n" +"\n" +"\tExample:\n" +"\timport GameLogic\n" +"\t# Set a perspective projection matrix\n" +"\tdef Perspective(left, right, bottom, top, near, far):\n" +"\t\tm = MT_Matrix4x4()\n" +"\t\tm[0][0] = m[0][2] = right - left\n" +"\t\tm[1][1] = m[1][2] = top - bottom\n" +"\t\tm[2][2] = m[2][3] = -far - near\n" +"\t\tm[3][2] = -1\n" +"\t\tm[3][3] = 0\n" +"\t\treturn m\n" +"\n" +"\t# Set an orthographic projection matrix\n" +"\tdef Orthographic(left, right, bottom, top, near, far):\n" +"\t\tm = MT_Matrix4x4()\n" +"\t\tm[0][0] = right - left\n" +"\t\tm[0][3] = -right - left\n" +"\t\tm[1][1] = top - bottom\n" +"\t\tm[1][3] = -top - bottom\n" +"\t\tm[2][2] = far - near\n" +"\t\tm[2][3] = -far - near\n" +"\t\tm[3][3] = 1\n" +"\t\treturn m\n" +"\n" +"\t# Set an isometric projection matrix\n" +"\tdef Isometric(left, right, bottom, top, near, far):\n" +"\t\tm = MT_Matrix4x4()\n" +"\t\tm[0][0] = m[0][2] = m[1][1] = 0.8660254037844386\n" +"\t\tm[1][0] = 0.25\n" +"\t\tm[1][2] = -0.25\n" +"\t\tm[3][3] = 1\n" +"\t\treturn m\n" +"\n" +"\t" +"\tco = GameLogic.getCurrentController()\n" +"\tcam = co.getOwner()\n" +"\tcam.setProjectionMatrix(Perspective(-1.0, 1.0, -1.0, 1.0, 0.1, 1))\n") +{ + ShowDeprecationWarning("setProjectionMatrix(mat)", "the projection_matrix property"); + + MT_Matrix4x4 mat; + if (!PyMatTo(value, mat)) + { + PyErr_SetString(PyExc_TypeError, "camera.setProjectionMatrix(matrix): KX_Camera, expected 4x4 list as matrix argument."); + return NULL; + } + + SetProjectionMatrix(mat); + Py_RETURN_NONE; +} + +KX_PYMETHODDEF_DOC_O(KX_Camera, enableViewport, +"enableViewport(viewport)\n" +"Sets this camera's viewport status\n" +) +{ + ShowDeprecationWarning("enableViewport(bool)", "the useViewport property"); + + int viewport = PyObject_IsTrue(value); + if (viewport == -1) { + PyErr_SetString(PyExc_ValueError, "camera.enableViewport(bool): KX_Camera, expected True/False or 0/1"); + return NULL; + } + + if(viewport) + EnableViewport(true); + else + EnableViewport(false); + + Py_RETURN_NONE; +} + KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, setViewport, "setViewport(left, bottom, right, top)\n" "Sets this camera's viewport\n") diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index bf7a39d93c8..74c8e6d4e4f 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -273,7 +273,10 @@ public: KX_PYMETHOD_DOC_NOARGS(KX_Camera, getCameraToWorld); KX_PYMETHOD_DOC_NOARGS(KX_Camera, getWorldToCamera); + KX_PYMETHOD_DOC_NOARGS(KX_Camera, getProjectionMatrix); + KX_PYMETHOD_DOC_O(KX_Camera, setProjectionMatrix); + KX_PYMETHOD_DOC_O(KX_Camera, enableViewport); KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport); KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 9c00b5991af..faf0ca50407 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -38,6 +38,9 @@ #include "PyObjectPlus.h" +STR_String KX_CameraActuator::X_AXIS_STRING = "x"; +STR_String KX_CameraActuator::Y_AXIS_STRING = "y"; + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -350,6 +353,15 @@ CValue *KX_CameraActuator::findObject(char *obName) return NULL; } +bool KX_CameraActuator::string2axischoice(const char *axisString) +{ + bool res = true; + + res = !(axisString == Y_AXIS_STRING); + + return res; +} + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -378,6 +390,17 @@ PyTypeObject KX_CameraActuator::Type = { }; PyMethodDef KX_CameraActuator::Methods[] = { + // ---> deprecated (all) + {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, + {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, (const char *)SetMin_doc}, + {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, (const char *)GetMin_doc}, + {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, (const char *)SetMax_doc}, + {"getMax" ,(PyCFunction) KX_CameraActuator::sPyGetMax, METH_NOARGS, (const char *)GetMax_doc}, + {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, (const char *)SetHeight_doc}, + {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, (const char *)GetHeight_doc}, + {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, (const char *)SetXY_doc}, + {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_NOARGS, (const char *)GetXY_doc}, {NULL,NULL,NULL,NULL} //Sentinel }; @@ -390,6 +413,152 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { {NULL} }; +/* get obj ---------------------------------------------------------- */ +const char KX_CameraActuator::GetObject_doc[] = +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" +"\tReturns the object this sensor reacts to.\n"; +PyObject* KX_CameraActuator::PyGetObject(PyObject* args) +{ + int ret_name_only = 1; + + ShowDeprecationWarning("getObject()", "the object property"); + + if (!PyArg_ParseTuple(args, "|i:getObject", &ret_name_only)) + return NULL; + + if (!m_ob) + Py_RETURN_NONE; + + if (ret_name_only) + return PyUnicode_FromString(m_ob->GetName().ReadPtr()); + else + return m_ob->GetProxy(); +} +/* set obj ---------------------------------------------------------- */ +const char KX_CameraActuator::SetObject_doc[] = +"setObject(object)\n" +"\t- object: KX_GameObject, string or None\n" +"\tSets the object this sensor reacts to.\n"; +PyObject* KX_CameraActuator::PySetObject(PyObject* value) +{ + KX_GameObject *gameobj; + + ShowDeprecationWarning("setObject()", "the object property"); + + if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.setObject(value): KX_CameraActuator")) + return NULL; // ConvertPythonToGameObject sets the error + + if (m_ob != NULL) + m_ob->UnregisterActuator(this); + + m_ob = (SCA_IObject*)gameobj; + if (m_ob) + m_ob->RegisterActuator(this); + + Py_RETURN_NONE; +} + +/* get min ---------------------------------------------------------- */ +const char KX_CameraActuator::GetMin_doc[] = +"getMin\n" +"\tReturns the minimum value set in the Min: field.\n"; +PyObject* KX_CameraActuator::PyGetMin() +{ + ShowDeprecationWarning("getMin()", "the min property"); + return PyFloat_FromDouble(m_minHeight); +} +/* set min ---------------------------------------------------------- */ +const char KX_CameraActuator::SetMin_doc[] = +"setMin\n" +"\tSets the minimum value.\n"; +PyObject* KX_CameraActuator::PySetMin(PyObject* args) +{ + ShowDeprecationWarning("setMin()", "the min property"); + float min; + if(PyArg_ParseTuple(args,"f:setMin", &min)) + { + m_minHeight = min; + Py_RETURN_NONE; + } + return NULL; +} +/* get min ---------------------------------------------------------- */ +const char KX_CameraActuator::GetMax_doc[] = +"getMax\n" +"\tReturns the maximum value set in the Max: field.\n"; +PyObject* KX_CameraActuator::PyGetMax() +{ + ShowDeprecationWarning("getMax()", "the max property"); + return PyFloat_FromDouble(m_maxHeight); +} +/* set min ---------------------------------------------------------- */ +const char KX_CameraActuator::SetMax_doc[] = +"setMax\n" +"\tSets the maximum value.\n"; +PyObject* KX_CameraActuator::PySetMax(PyObject* args) +{ + ShowDeprecationWarning("getMax()", "the max property"); + float max; + if(PyArg_ParseTuple(args,"f:setMax", &max)) + { + m_maxHeight = max; + Py_RETURN_NONE; + } + return NULL; +} +/* get height ---------------------------------------------------------- */ +const char KX_CameraActuator::GetHeight_doc[] = +"getHeight\n" +"\tReturns the height value set in the height: field.\n"; +PyObject* KX_CameraActuator::PyGetHeight() +{ + ShowDeprecationWarning("getHeight()", "the height property"); + return PyFloat_FromDouble(m_height); +} +/* set height ---------------------------------------------------------- */ +const char KX_CameraActuator::SetHeight_doc[] = +"setHeight\n" +"\tSets the height value.\n"; +PyObject* KX_CameraActuator::PySetHeight(PyObject* args) +{ + ShowDeprecationWarning("getHeight()", "the height property"); + float height; + if(PyArg_ParseTuple(args,"f:setHeight", &height)) + { + m_height = height; + Py_RETURN_NONE; + } + return NULL; +} +/* set XY ---------------------------------------------------------- */ +const char KX_CameraActuator::SetXY_doc[] = +"setXY\n" +"\tSets axis the camera tries to get behind.\n" +"\t1=x, 0=y\n"; +PyObject* KX_CameraActuator::PySetXY(PyObject* args) +{ + ShowDeprecationWarning("setXY()", "the useXY property"); + int value; + if(PyArg_ParseTuple(args,"i:setXY", &value)) + { + m_x = value != 0; + Py_RETURN_NONE; + } + return NULL; +} + +/* get XY -------------------------------------------------------------*/ +const char KX_CameraActuator::GetXY_doc[] = +"getXY\n" +"\tGets the axis the camera tries to get behind.\n" +"\tTrue = X, False = Y\n"; +PyObject* KX_CameraActuator::PyGetXY() +{ + ShowDeprecationWarning("getXY()", "the xy property"); + return PyLong_FromSsize_t(m_x); +} + PyObject* KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_CameraActuator* self= static_cast<KX_CameraActuator*>(self_v); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index e047e3724ea..057c6fed770 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -119,6 +119,18 @@ private : /* --------------------------------------------------------------------- */ /* set object to look at */ + KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject); + /* get current object */ + KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,GetObject); + KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,SetMin); + KX_PYMETHOD_DOC_NOARGS(KX_CameraActuator,GetMin); + KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,SetMax); + KX_PYMETHOD_DOC_NOARGS(KX_CameraActuator,GetMax); + KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,SetHeight); + KX_PYMETHOD_DOC_NOARGS(KX_CameraActuator,GetHeight); + KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,SetXY); + KX_PYMETHOD_DOC_NOARGS(KX_CameraActuator,GetXY); + static PyObject* pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 7f1d2c7d53c..5f6244c3ab6 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -587,6 +587,30 @@ PyTypeObject KX_ConstraintActuator::Type = { }; PyMethodDef KX_ConstraintActuator::Methods[] = { + // Deprecated --> + {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, (const char *)SetDamp_doc}, + {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, (const char *)GetDamp_doc}, + {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, (const char *)SetRotDamp_doc}, + {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, (const char *)GetRotDamp_doc}, + {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, (const char *)SetDirection_doc}, + {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, (const char *)GetDirection_doc}, + {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, (const char *)SetOption_doc}, + {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, (const char *)GetOption_doc}, + {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, (const char *)SetTime_doc}, + {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc}, + {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (const char *)SetMin_doc}, + {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (const char *)GetMin_doc}, + {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (const char *)SetDistance_doc}, + {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (const char *)GetDistance_doc}, + {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (const char *)SetMax_doc}, + {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (const char *)GetMax_doc}, + {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (const char *)SetRayLength_doc}, + {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (const char *)GetRayLength_doc}, + {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, (const char *)SetLimit_doc}, + {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, (const char *)GetLimit_doc}, + // <-- {NULL,NULL} //Sentinel }; @@ -618,4 +642,318 @@ int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PY return 0; } +/* 2. setDamp */ +const char KX_ConstraintActuator::SetDamp_doc[] = +"setDamp(duration)\n" +"\t- duration: integer\n" +"\tSets the time constant of the orientation and distance constraint.\n" +"\tIf the duration is negative, it is set to 0.\n"; +PyObject* KX_ConstraintActuator::PySetDamp(PyObject* args) { + ShowDeprecationWarning("setDamp()", "the damp property"); + int dampArg; + if(!PyArg_ParseTuple(args, "i:setDamp", &dampArg)) { + return NULL; + } + + m_posDampTime = dampArg; + if (m_posDampTime < 0) m_posDampTime = 0; + + Py_RETURN_NONE; +} +/* 3. getDamp */ +const char KX_ConstraintActuator::GetDamp_doc[] = +"getDamp()\n" +"\tReturns the damping parameter.\n"; +PyObject* KX_ConstraintActuator::PyGetDamp(){ + ShowDeprecationWarning("getDamp()", "the damp property"); + return PyLong_FromSsize_t(m_posDampTime); +} + +/* 2. setRotDamp */ +const char KX_ConstraintActuator::SetRotDamp_doc[] = +"setRotDamp(duration)\n" +"\t- duration: integer\n" +"\tSets the time constant of the orientation constraint.\n" +"\tIf the duration is negative, it is set to 0.\n"; +PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* args) { + ShowDeprecationWarning("setRotDamp()", "the rotDamp property"); + int dampArg; + if(!PyArg_ParseTuple(args, "i:setRotDamp", &dampArg)) { + return NULL; + } + + m_rotDampTime = dampArg; + if (m_rotDampTime < 0) m_rotDampTime = 0; + + Py_RETURN_NONE; +} +/* 3. getRotDamp */ +const char KX_ConstraintActuator::GetRotDamp_doc[] = +"getRotDamp()\n" +"\tReturns the damping time for application of the constraint.\n"; +PyObject* KX_ConstraintActuator::PyGetRotDamp(){ + ShowDeprecationWarning("getRotDamp()", "the rotDamp property"); + return PyLong_FromSsize_t(m_rotDampTime); +} + +/* 2. setDirection */ +const char KX_ConstraintActuator::SetDirection_doc[] = +"setDirection(vector)\n" +"\t- vector: 3-tuple\n" +"\tSets the reference direction in world coordinate for the orientation constraint.\n"; +PyObject* KX_ConstraintActuator::PySetDirection(PyObject* args) { + ShowDeprecationWarning("setDirection()", "the direction property"); + float x, y, z; + MT_Scalar len; + MT_Vector3 dir; + + if(!PyArg_ParseTuple(args, "(fff):setDirection", &x, &y, &z)) { + return NULL; + } + dir[0] = x; + dir[1] = y; + dir[2] = z; + len = dir.length(); + if (MT_fuzzyZero(len)) { + std::cout << "Invalid direction" << std::endl; + return NULL; + } + m_refDirVector = dir/len; + m_refDirection[0] = x/len; + m_refDirection[1] = y/len; + m_refDirection[2] = z/len; + + Py_RETURN_NONE; +} +/* 3. getDirection */ +const char KX_ConstraintActuator::GetDirection_doc[] = +"getDirection()\n" +"\tReturns the reference direction of the orientation constraint as a 3-tuple.\n"; +PyObject* KX_ConstraintActuator::PyGetDirection(){ + ShowDeprecationWarning("getDirection()", "the direction property"); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_refDirection[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_refDirection[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_refDirection[2])); + return retVal; +} + +/* 2. setOption */ +const char KX_ConstraintActuator::SetOption_doc[] = +"setOption(option)\n" +"\t- option: integer\n" +"\tSets several options of the distance constraint.\n" +"\tBinary combination of the following values:\n" +"\t\t 64 : Activate alignment to surface\n" +"\t\t128 : Detect material rather than property\n" +"\t\t256 : No deactivation if ray does not hit target\n" +"\t\t512 : Activate distance control\n"; +PyObject* KX_ConstraintActuator::PySetOption(PyObject* args) { + ShowDeprecationWarning("setOption()", "the option property"); + int option; + if(!PyArg_ParseTuple(args, "i:setOption", &option)) { + return NULL; + } + + m_option = option; + + Py_RETURN_NONE; +} +/* 3. getOption */ +const char KX_ConstraintActuator::GetOption_doc[] = +"getOption()\n" +"\tReturns the option parameter.\n"; +PyObject* KX_ConstraintActuator::PyGetOption(){ + ShowDeprecationWarning("getOption()", "the option property"); + return PyLong_FromSsize_t(m_option); +} + +/* 2. setTime */ +const char KX_ConstraintActuator::SetTime_doc[] = +"setTime(duration)\n" +"\t- duration: integer\n" +"\tSets the activation time of the actuator.\n" +"\tThe actuator disables itself after this many frame.\n" +"\tIf set to 0 or negative, the actuator is not limited in time.\n"; +PyObject* KX_ConstraintActuator::PySetTime(PyObject* args) { + ShowDeprecationWarning("setTime()", "the time property"); + int t; + if(!PyArg_ParseTuple(args, "i:setTime", &t)) { + return NULL; + } + + if (t < 0) + t = 0; + m_activeTime = t; + + Py_RETURN_NONE; +} +/* 3. getTime */ +const char KX_ConstraintActuator::GetTime_doc[] = +"getTime()\n" +"\tReturns the time parameter.\n"; +PyObject* KX_ConstraintActuator::PyGetTime(){ + ShowDeprecationWarning("getTime()", "the time property"); + return PyLong_FromSsize_t(m_activeTime); +} + +/* 2. setProperty */ +const char KX_ConstraintActuator::SetProperty_doc[] = +"setProperty(property)\n" +"\t- property: string\n" +"\tSets the name of the property or material for the ray detection of the distance constraint.\n" +"\tIf empty, the ray will detect any collisioning object.\n"; +PyObject* KX_ConstraintActuator::PySetProperty(PyObject* args) { + ShowDeprecationWarning("setProperty()", "the 'property' property"); + char *property; + if (!PyArg_ParseTuple(args, "s:setProperty", &property)) { + return NULL; + } + if (property == NULL) { + m_property = ""; + } else { + m_property = property; + } + + Py_RETURN_NONE; +} +/* 3. getProperty */ +const char KX_ConstraintActuator::GetProperty_doc[] = +"getProperty()\n" +"\tReturns the property parameter.\n"; +PyObject* KX_ConstraintActuator::PyGetProperty(){ + ShowDeprecationWarning("getProperty()", "the 'property' property"); + return PyUnicode_FromString(m_property.Ptr()); +} + +/* 4. setDistance */ +const char KX_ConstraintActuator::SetDistance_doc[] = +"setDistance(distance)\n" +"\t- distance: float\n" +"\tSets the target distance in distance constraint\n"; +/* 4. setMin */ +const char KX_ConstraintActuator::SetMin_doc[] = +"setMin(lower_bound)\n" +"\t- lower_bound: float\n" +"\tSets the lower value of the interval to which the value\n" +"\tis clipped.\n"; +PyObject* KX_ConstraintActuator::PySetMin(PyObject* args) { + ShowDeprecationWarning("setMin() or setDistance()", "the min or distance property"); + float minArg; + if(!PyArg_ParseTuple(args, "f:setMin", &minArg)) { + return NULL; + } + + switch (m_locrot) { + default: + m_minimumBound = minArg; + break; + case KX_ACT_CONSTRAINT_ROTX: + case KX_ACT_CONSTRAINT_ROTY: + case KX_ACT_CONSTRAINT_ROTZ: + m_minimumBound = MT_radians(minArg); + break; + } + + Py_RETURN_NONE; +} +/* 5. getDistance */ +const char KX_ConstraintActuator::GetDistance_doc[] = +"getDistance()\n" +"\tReturns the distance parameter \n"; +/* 5. getMin */ +const char KX_ConstraintActuator::GetMin_doc[] = +"getMin()\n" +"\tReturns the lower value of the interval to which the value\n" +"\tis clipped.\n"; +PyObject* KX_ConstraintActuator::PyGetMin() { + ShowDeprecationWarning("getMin() or getDistance()", "the min or distance property"); + return PyFloat_FromDouble(m_minimumBound); +} + +/* 6. setRayLength */ +const char KX_ConstraintActuator::SetRayLength_doc[] = +"setRayLength(length)\n" +"\t- length: float\n" +"\tSets the maximum ray length of the distance constraint\n"; +/* 6. setMax */ +const char KX_ConstraintActuator::SetMax_doc[] = +"setMax(upper_bound)\n" +"\t- upper_bound: float\n" +"\tSets the upper value of the interval to which the value\n" +"\tis clipped.\n"; +PyObject* KX_ConstraintActuator::PySetMax(PyObject* args){ + ShowDeprecationWarning("setMax() or setRayLength()", "the max or rayLength property"); + float maxArg; + if(!PyArg_ParseTuple(args, "f:setMax", &maxArg)) { + return NULL; + } + + switch (m_locrot) { + default: + m_maximumBound = maxArg; + break; + case KX_ACT_CONSTRAINT_ROTX: + case KX_ACT_CONSTRAINT_ROTY: + case KX_ACT_CONSTRAINT_ROTZ: + m_maximumBound = MT_radians(maxArg); + break; + } + + Py_RETURN_NONE; +} +/* 7. getRayLength */ +const char KX_ConstraintActuator::GetRayLength_doc[] = +"getRayLength()\n" +"\tReturns the length of the ray\n"; +/* 7. getMax */ +const char KX_ConstraintActuator::GetMax_doc[] = +"getMax()\n" +"\tReturns the upper value of the interval to which the value\n" +"\tis clipped.\n"; +PyObject* KX_ConstraintActuator::PyGetMax() { + ShowDeprecationWarning("getMax() or getRayLength()", "the max or rayLength property"); + return PyFloat_FromDouble(m_maximumBound); +} + + +/* This setter/getter probably for the constraint type */ +/* 8. setLimit */ +const char KX_ConstraintActuator::SetLimit_doc[] = +"setLimit(type)\n" +"\t- type: integer\n" +"\t 1 : LocX\n" +"\t 2 : LocY\n" +"\t 3 : LocZ\n" +"\t 7 : Distance along +X axis\n" +"\t 8 : Distance along +Y axis\n" +"\t 9 : Distance along +Z axis\n" +"\t 10 : Distance along -X axis\n" +"\t 11 : Distance along -Y axis\n" +"\t 12 : Distance along -Z axis\n" +"\t 13 : Align X axis\n" +"\t 14 : Align Y axis\n" +"\t 15 : Align Z axis\n" +"\tSets the type of constraint.\n"; +PyObject* KX_ConstraintActuator::PySetLimit(PyObject* args) { + ShowDeprecationWarning("setLimit()", "the limit property"); + int locrotArg; + if(!PyArg_ParseTuple(args, "i:setLimit", &locrotArg)) { + return NULL; + } + + if (IsValidMode((KX_CONSTRAINTTYPE)locrotArg)) m_locrot = locrotArg; + + Py_RETURN_NONE; +} +/* 9. getLimit */ +const char KX_ConstraintActuator::GetLimit_doc[] = +"getLimit()\n" +"\tReturns the type of constraint.\n"; +PyObject* KX_ConstraintActuator::PyGetLimit() { + ShowDeprecationWarning("setLimit()", "the limit property"); + return PyLong_FromSsize_t(m_locrot); +} + /* eof */ diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index 9b6ed59e75c..677904aedc9 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -143,6 +143,28 @@ protected: static int pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_check_min(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetDamp); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDamp); + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetRotDamp); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetRotDamp); + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetDirection); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDirection); + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetOption); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetOption); + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetTime); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetTime); + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetProperty); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetProperty); + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetMin); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMin); + static const char SetDistance_doc[]; + static const char GetDistance_doc[]; + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetMax); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMax); + static const char SetRayLength_doc[]; + static const char GetRayLength_doc[]; + KX_PYMETHOD_DOC_VARARGS(KX_ConstraintActuator,SetLimit); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetLimit); }; #endif //__KX_CONSTRAINTACTUATOR diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 42dc4d8fd24..3f67de1e9a9 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -230,6 +230,10 @@ PyTypeObject KX_GameActuator::Type = { PyMethodDef KX_GameActuator::Methods[] = { + // Deprecated -----> + {"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, (const char *)GetFile_doc}, + {"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, (const char *)SetFile_doc}, + // <----- {NULL,NULL} //Sentinel }; @@ -238,3 +242,36 @@ PyAttributeDef KX_GameActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("mode", KX_GAME_NODEF+1, KX_GAME_MAX-1, true, KX_GameActuator, m_mode), { NULL } //Sentinel }; + +// Deprecated -----> +/* getFile */ +const char KX_GameActuator::GetFile_doc[] = +"getFile()\n" +"get the name of the file to start.\n"; +PyObject* KX_GameActuator::PyGetFile(PyObject* args, PyObject* kwds) +{ + ShowDeprecationWarning("getFile()", "the fileName property"); + return PyUnicode_FromString(m_filename); +} + +/* setFile */ +const char KX_GameActuator::SetFile_doc[] = +"setFile(name)\n" +"set the name of the file to start.\n"; +PyObject* KX_GameActuator::PySetFile(PyObject* args, PyObject* kwds) +{ + char* new_file; + + ShowDeprecationWarning("setFile()", "the fileName property"); + + if (!PyArg_ParseTuple(args, "s:setFile", &new_file)) + { + return NULL; + } + + m_filename = STR_String(new_file); + + Py_RETURN_NONE; + +} +// <----- diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 37d09a5a9fb..cabbf827b40 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -75,6 +75,11 @@ protected: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + + // Deprecated functions -----> + KX_PYMETHOD_DOC(KX_GameActuator,GetFile); + KX_PYMETHOD_DOC(KX_GameActuator,SetFile); + // <----- }; /* end of class KX_GameActuator */ diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 8193aa8c37b..146b83abd17 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -464,7 +464,7 @@ void KX_GameObject::AddMeshUser() double* fl = GetOpenGLMatrixPtr()->getPointer(); SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots); -// RAS_MeshSlot* ms; + RAS_MeshSlot* ms; for(mit.begin(); !mit.end(); ++mit) { (*mit)->m_OpenGLMatrix = fl; @@ -1383,8 +1383,8 @@ PyMethodDef KX_GameObject::Methods[] = { {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, {"setOcclusion",(PyCFunction) KX_GameObject::sPySetOcclusion, METH_VARARGS}, {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_NOARGS}, - - + {"getChildren", (PyCFunction)KX_GameObject::sPyGetChildren,METH_NOARGS}, + {"getChildrenRecursive", (PyCFunction)KX_GameObject::sPyGetChildrenRecursive,METH_NOARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS}, {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS}, {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_VARARGS}, @@ -1398,8 +1398,21 @@ PyMethodDef KX_GameObject::Methods[] = { KX_PYMETHODTABLE(KX_GameObject, sendMessage), // dict style access for props + {"has_key",(PyCFunction) KX_GameObject::sPyhas_key, METH_O}, {"get",(PyCFunction) KX_GameObject::sPyget, METH_VARARGS}, + // deprecated + {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_NOARGS}, + {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O}, + {"setWorldPosition", (PyCFunction) KX_GameObject::sPySetWorldPosition, METH_O}, + {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_NOARGS}, + {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_O}, + {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_NOARGS}, + {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_O}, + {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_NOARGS}, + {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_NOARGS}, + {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_NOARGS}, + {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {NULL,NULL} //Sentinel }; @@ -1502,6 +1515,13 @@ PyObject* KX_GameObject::PyReinstancePhysicsMesh(PyObject* args) Py_RETURN_FALSE; } + +PyObject* KX_GameObject::PyGetPosition() +{ + ShowDeprecationWarning("getPosition()", "the position property"); + return PyObjectFrom(NodeGetWorldPosition()); +} + static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) { KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); @@ -1797,10 +1817,10 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { + KX_GameObject* self= static_cast<KX_GameObject*>(self_v); #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); + return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldPosition()); #endif } @@ -1819,10 +1839,10 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { + KX_GameObject* self= static_cast<KX_GameObject*>(self_v); #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL); + return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalPosition()); #endif } @@ -1841,10 +1861,10 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { + KX_GameObject* self= static_cast<KX_GameObject*>(self_v); #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); + return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); if (self->GetPhysicsController()) return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia()); return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); @@ -1854,7 +1874,7 @@ PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB PyObject* KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL); + return newMatrixObject_cb((PyObject *)self_v, 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldOrientation()); @@ -1879,7 +1899,7 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL); + return newMatrixObject_cb((PyObject *)self_v, 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalOrientation()); @@ -1902,20 +1922,20 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { + KX_GameObject* self= static_cast<KX_GameObject*>(self_v); #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); + return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldScaling()); #endif } PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { + KX_GameObject* self= static_cast<KX_GameObject*>(self_v); #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); + return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalScaling()); #endif } @@ -2181,6 +2201,41 @@ PyObject* KX_GameObject::PySetOcclusion(PyObject* args) Py_RETURN_NONE; } +PyObject* KX_GameObject::PyGetVisible() +{ + ShowDeprecationWarning("getVisible()", "the visible property"); + return PyLong_FromSsize_t(m_bVisible); +} + +PyObject* KX_GameObject::PyGetState() +{ + ShowDeprecationWarning("getState()", "the state property"); + int state = 0; + state |= GetState(); + return PyLong_FromSsize_t(state); +} + +PyObject* KX_GameObject::PySetState(PyObject* value) +{ + ShowDeprecationWarning("setState()", "the state property"); + int state_i = PyLong_AsSsize_t(value); + unsigned int state = 0; + + if (state_i == -1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "expected an int bit field"); + return NULL; + } + + state |= state_i; + if ((state & ((1<<30)-1)) == 0) { + PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); + return NULL; + } + SetState(state); + + Py_RETURN_NONE; +} + PyObject* KX_GameObject::PyGetVelocity(PyObject* args) { // only can get the velocity if we have a physics object connected to us... @@ -2199,6 +2254,14 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* args) } } + + +PyObject* KX_GameObject::PyGetMass() +{ + ShowDeprecationWarning("getMass()", "the mass property"); + return PyFloat_FromDouble((GetPhysicsController() != NULL) ? GetPhysicsController()->GetMass() : 0.0f); +} + PyObject* KX_GameObject::PyGetReactionForce() { // only can get the velocity if we have a physics object connected to us... @@ -2235,6 +2298,18 @@ PyObject* KX_GameObject::PyDisableRigidBody() } + +PyObject* KX_GameObject::PyGetParent() +{ + ShowDeprecationWarning("getParent()", "the parent property"); + KX_GameObject* parent = this->GetParent(); + if (parent) { + parent->Release(); /* self->GetParent() AddRef's */ + return parent->GetProxy(); + } + Py_RETURN_NONE; +} + PyObject* KX_GameObject::PySetParent(PyObject* args) { KX_Scene *scene = KX_GetActiveScene(); @@ -2260,6 +2335,41 @@ PyObject* KX_GameObject::PyRemoveParent() Py_RETURN_NONE; } +PyObject* KX_GameObject::PyGetChildren() +{ + ShowDeprecationWarning("getChildren()", "the children property"); + + return GetChildren()->NewProxy(true); +} + +PyObject* KX_GameObject::PyGetChildrenRecursive() +{ + ShowDeprecationWarning("getChildrenRecursive()", "the childrenRecursive property"); + + return GetChildrenRecursive()->NewProxy(true); +} + +PyObject* KX_GameObject::PyGetMesh(PyObject* args) +{ + ShowDeprecationWarning("getMesh()", "the meshes property (now a list of meshes)"); + + int mesh = 0; + + if (!PyArg_ParseTuple(args, "|i:getMesh", &mesh)) + return NULL; // python sets a simple error + + if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0) + { + KX_MeshProxy* meshproxy = new KX_MeshProxy(m_meshes[mesh]); + return meshproxy->NewProxy(true); // XXX Todo Python own. + } + + Py_RETURN_NONE; +} + + + + PyObject* KX_GameObject::PySetCollisionMargin(PyObject* value) { @@ -2323,6 +2433,29 @@ PyObject* KX_GameObject::PyRestoreDynamics() } + +PyObject* KX_GameObject::PyGetOrientation() //keywords +{ + ShowDeprecationWarning("getOrientation()", "the orientation property"); + return PyObjectFrom(NodeGetWorldOrientation()); +} + + + +PyObject* KX_GameObject::PySetOrientation(PyObject* value) +{ + ShowDeprecationWarning("setOrientation()", "the orientation property"); + MT_Matrix3x3 rot; + + /* if value is not a sequence PyOrientationTo makes an error */ + if (!PyOrientationTo(value, rot, "gameOb.setOrientation(sequence): KX_GameObject, ")) + return NULL; + + NodeSetLocalOrientation(rot); + NodeUpdateGS(0.f); + Py_RETURN_NONE; +} + PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* args) { PyObject* pyvect; @@ -2355,6 +2488,33 @@ PyObject* KX_GameObject::PyGetAxisVect(PyObject* value) return NULL; } +PyObject* KX_GameObject::PySetPosition(PyObject* value) +{ + ShowDeprecationWarning("setPosition()", "the localPosition property"); + MT_Point3 pos; + if (PyVecTo(value, pos)) + { + NodeSetLocalPosition(pos); + NodeUpdateGS(0.f); + Py_RETURN_NONE; + } + + return NULL; +} + +PyObject* KX_GameObject::PySetWorldPosition(PyObject* value) +{ + ShowDeprecationWarning("setWorldPosition()", "the worldPosition property"); + MT_Point3 pos; + if (PyVecTo(value, pos)) + { + NodeSetWorldPosition(pos); + NodeUpdateGS(0.f); + Py_RETURN_NONE; + } + + return NULL; +} PyObject* KX_GameObject::PyGetPhysicsId() { @@ -2520,10 +2680,12 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, } } MT_Point3 fromPoint = NodeGetWorldPosition(); - if (dist != 0.0f) - toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized(); - + { + MT_Vector3 toDir = toPoint-fromPoint; + toDir.normalize(); + toPoint = fromPoint + (dist) * toDir; + } PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); @@ -2716,7 +2878,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage, char* to = (char *)""; const STR_String& from = GetName(); - if (!PyArg_ParseTuple(args, "s|ss:sendMessage", &subject, &body, &to)) + if (!PyArg_ParseTuple(args, "s|sss:sendMessage", &subject, &body, &to)) return NULL; scene->GetNetworkScene()->SendMessage(to, from, subject, body); @@ -2757,6 +2919,14 @@ PyObject* KX_GameObject::Pyget(PyObject *args) return def; } +/* Matches python dict.has_key() */ +PyObject* KX_GameObject::Pyhas_key(PyObject* value) +{ + // the ONLY error case is invalid data, this is checked by the macro'd static function + // that calls this one. but make sure Seq_Contains doesnt add extra errors later on. + return PyBool_FromLong(Seq_Contains((PyObject *)this, value)); +} + /* --------------------------------------------------------------------- * Some stuff taken from the header * --------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 845cead1cdb..ba7451fdeef 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -795,7 +795,9 @@ public: { return PyUnicode_FromString(GetName().ReadPtr()); } - + + KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition); + KX_PYMETHOD_O(KX_GameObject,SetPosition); KX_PYMETHOD_O(KX_GameObject,SetWorldPosition); KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce); KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque); @@ -806,10 +808,10 @@ public: KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity); KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity); KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity); - + KX_PYMETHOD_NOARGS(KX_GameObject,GetMass); KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce); - - + KX_PYMETHOD_NOARGS(KX_GameObject,GetOrientation); + KX_PYMETHOD_O(KX_GameObject,SetOrientation); KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible); KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible); KX_PYMETHOD_VARARGS(KX_GameObject,SetOcclusion); @@ -826,7 +828,7 @@ public: KX_PYMETHOD_NOARGS(KX_GameObject,GetParent); KX_PYMETHOD_VARARGS(KX_GameObject,SetParent); KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent); - KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren); + KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren); KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive); KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh); KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId); @@ -842,6 +844,7 @@ public: /* Dict access */ KX_PYMETHOD_VARARGS(KX_GameObject,get); + KX_PYMETHOD_O(KX_GameObject,has_key); /* attributes */ static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index b71907be961..e4eaff4f401 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -49,13 +49,13 @@ /* Type strings */ /* ------------------------------------------------------------------------- */ -const char *KX_IpoActuator::S_KX_ACT_IPO_PLAY_STRING = "Play"; -const char *KX_IpoActuator::S_KX_ACT_IPO_PINGPONG_STRING = "PingPong"; -const char *KX_IpoActuator::S_KX_ACT_IPO_FLIPPER_STRING = "Flipper"; -const char *KX_IpoActuator::S_KX_ACT_IPO_LOOPSTOP_STRING = "LoopStop"; -const char *KX_IpoActuator::S_KX_ACT_IPO_LOOPEND_STRING = "LoopEnd"; -const char *KX_IpoActuator::S_KX_ACT_IPO_KEY2KEY_STRING = "Key2key"; -const char *KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp"; +STR_String KX_IpoActuator::S_KX_ACT_IPO_PLAY_STRING = "Play"; +STR_String KX_IpoActuator::S_KX_ACT_IPO_PINGPONG_STRING = "PingPong"; +STR_String KX_IpoActuator::S_KX_ACT_IPO_FLIPPER_STRING = "Flipper"; +STR_String KX_IpoActuator::S_KX_ACT_IPO_LOOPSTOP_STRING = "LoopStop"; +STR_String KX_IpoActuator::S_KX_ACT_IPO_LOOPEND_STRING = "LoopEnd"; +STR_String KX_IpoActuator::S_KX_ACT_IPO_KEY2KEY_STRING = "Key2key"; +STR_String KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp"; /* ------------------------------------------------------------------------- */ /* Native functions */ @@ -385,19 +385,19 @@ bool KX_IpoActuator::Update(double curtime, bool frame) int KX_IpoActuator::string2mode(char* modename) { IpoActType res = KX_ACT_IPO_NODEF; - if (strcmp(modename, S_KX_ACT_IPO_PLAY_STRING)==0) { + if (modename == S_KX_ACT_IPO_PLAY_STRING) { res = KX_ACT_IPO_PLAY; - } else if (strcmp(modename, S_KX_ACT_IPO_PINGPONG_STRING)==0) { + } else if (modename == S_KX_ACT_IPO_PINGPONG_STRING) { res = KX_ACT_IPO_PINGPONG; - } else if (strcmp(modename, S_KX_ACT_IPO_FLIPPER_STRING)==0) { + } else if (modename == S_KX_ACT_IPO_FLIPPER_STRING) { res = KX_ACT_IPO_FLIPPER; - } else if (strcmp(modename, S_KX_ACT_IPO_LOOPSTOP_STRING)==0) { + } else if (modename == S_KX_ACT_IPO_LOOPSTOP_STRING) { res = KX_ACT_IPO_LOOPSTOP; - } else if (strcmp(modename, S_KX_ACT_IPO_LOOPEND_STRING)==0) { + } else if (modename == S_KX_ACT_IPO_LOOPEND_STRING) { res = KX_ACT_IPO_LOOPEND; - } else if (strcmp(modename, S_KX_ACT_IPO_KEY2KEY_STRING)==0) { + } else if (modename == S_KX_ACT_IPO_KEY2KEY_STRING) { res = KX_ACT_IPO_KEY2KEY; - } else if (strcmp(modename, S_KX_ACT_IPO_FROM_PROP_STRING)==0) { + } else if (modename == S_KX_ACT_IPO_FROM_PROP_STRING) { res = KX_ACT_IPO_FROM_PROP; } @@ -434,6 +434,21 @@ PyTypeObject KX_IpoActuator::Type = { }; PyMethodDef KX_IpoActuator::Methods[] = { + // deprecated + {"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (const char *)Set_doc}, + {"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, (const char *)SetStart_doc}, + {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, METH_NOARGS, (const char *)GetStart_doc}, + {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd, METH_VARARGS, (const char *)SetEnd_doc}, + {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd, METH_NOARGS, (const char *)GetEnd_doc}, + {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce, METH_VARARGS, (const char *)SetIpoAsForce_doc}, + {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, METH_NOARGS, (const char *)GetIpoAsForce_doc}, + {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, METH_VARARGS, (const char *)SetIpoAdd_doc}, + {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, METH_NOARGS, (const char *)GetIpoAdd_doc}, + {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, METH_VARARGS, (const char *)SetForceIpoActsLocal_doc}, + {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, METH_NOARGS, (const char *)GetForceIpoActsLocal_doc}, + {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, (const char *)SetType_doc}, + {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, METH_NOARGS, (const char *)GetType_doc}, {NULL,NULL} //Sentinel }; @@ -451,4 +466,237 @@ PyAttributeDef KX_IpoActuator::Attributes[] = { { NULL } //Sentinel }; + +/* set --------------------------------------------------------------------- */ +const char KX_IpoActuator::Set_doc[] = +"set(type, startframe, endframe, mode?)\n" +"\t - type: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n" +"\t - startframe: first frame to use (int)\n" +"\t - endframe : last frame to use (int)\n" +"\t - mode? : special mode (0=normal, 1=interpret location as force, 2=additive)" +"\tSet the properties of the actuator.\n"; +PyObject* KX_IpoActuator::PySet(PyObject* args) { + + ShowDeprecationWarning("set()", "a range properties"); + + /* sets modes PLAY, PINGPONG, FLIPPER, LOOPSTOP, LOOPEND */ + /* arg 1 = mode string, arg 2 = startframe, arg3 = stopframe, */ + /* arg4 = force toggle */ + char* mode; + int forceToggle; + int modenum; + int startFrame, stopFrame; + if(!PyArg_ParseTuple(args, "siii:set", &mode, &startFrame, + &stopFrame, &forceToggle)) { + return NULL; + } + modenum = string2mode(mode); + + switch (modenum) { + case KX_ACT_IPO_PLAY: + case KX_ACT_IPO_PINGPONG: + case KX_ACT_IPO_FLIPPER: + case KX_ACT_IPO_LOOPSTOP: + case KX_ACT_IPO_LOOPEND: + m_type = modenum; + m_startframe = startFrame; + m_endframe = stopFrame; + m_ipo_as_force = forceToggle == 1; + m_ipo_add = forceToggle == 2; + break; + default: + ; /* error */ + } + + Py_RETURN_NONE; +} + +/* set property ----------------------------------------------------------- */ +const char KX_IpoActuator::SetProperty_doc[] = +"setProperty(propname)\n" +"\t - propname: name of the property (string)\n" +"\tSet the property to be used in FromProp mode.\n"; +PyObject* KX_IpoActuator::PySetProperty(PyObject* args) { + + ShowDeprecationWarning("setProperty()", "the propName property"); + + /* mode is implicit here, but not supported yet... */ + /* args: property */ + char *propertyName; + if(!PyArg_ParseTuple(args, "s:setProperty", &propertyName)) { + return NULL; + } + + m_propname = propertyName; + + Py_RETURN_NONE; +} + +/* 4. setStart: */ +const char KX_IpoActuator::SetStart_doc[] = +"setStart(frame)\n" +"\t - frame: first frame to use (int)\n" +"\tSet the frame from which the ipo starts playing.\n"; +PyObject* KX_IpoActuator::PySetStart(PyObject* args) { + + ShowDeprecationWarning("setStart()", "the frameStart property"); + + float startArg; + if(!PyArg_ParseTuple(args, "f:setStart", &startArg)) { + return NULL; + } + + m_startframe = startArg; + + Py_RETURN_NONE; +} +/* 5. getStart: */ +const char KX_IpoActuator::GetStart_doc[] = +"getStart()\n" +"\tReturns the frame from which the ipo starts playing.\n"; +PyObject* KX_IpoActuator::PyGetStart() { + ShowDeprecationWarning("getStart()", "the frameStart property"); + return PyFloat_FromDouble(m_startframe); +} + +/* 6. setEnd: */ +const char KX_IpoActuator::SetEnd_doc[] = +"setEnd(frame)\n" +"\t - frame: last frame to use (int)\n" +"\tSet the frame at which the ipo stops playing.\n"; +PyObject* KX_IpoActuator::PySetEnd(PyObject* args) { + ShowDeprecationWarning("setEnd()", "the frameEnd property"); + float endArg; + if(!PyArg_ParseTuple(args, "f:setEnd", &endArg)) { + return NULL; + } + + m_endframe = endArg; + + Py_RETURN_NONE; +} +/* 7. getEnd: */ +const char KX_IpoActuator::GetEnd_doc[] = +"getEnd()\n" +"\tReturns the frame at which the ipo stops playing.\n"; +PyObject* KX_IpoActuator::PyGetEnd() { + ShowDeprecationWarning("getEnd()", "the frameEnd property"); + return PyFloat_FromDouble(m_endframe); +} + +/* 6. setIpoAsForce: */ +const char KX_IpoActuator::SetIpoAsForce_doc[] = +"setIpoAsForce(force?)\n" +"\t - force? : interpret this ipo as a force? (KX_TRUE, KX_FALSE)\n" +"\tSet whether to interpret the ipo as a force rather than a displacement.\n"; +PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* args) { + ShowDeprecationWarning("setIpoAsForce()", "the useIpoAsForce property"); + int boolArg; + + if (!PyArg_ParseTuple(args, "i:setIpoAsForce", &boolArg)) { + return NULL; + } + + m_ipo_as_force = PyArgToBool(boolArg); + if (m_ipo_as_force) + m_ipo_add = false; + + Py_RETURN_NONE; +} +/* 7. getIpoAsForce: */ +const char KX_IpoActuator::GetIpoAsForce_doc[] = +"getIpoAsForce()\n" +"\tReturns whether to interpret the ipo as a force rather than a displacement.\n"; +PyObject* KX_IpoActuator::PyGetIpoAsForce() { + ShowDeprecationWarning("getIpoAsForce()", "the useIpoAsForce property"); + return BoolToPyArg(m_ipo_as_force); +} + +/* 6. setIpoAsForce: */ +const char KX_IpoActuator::SetIpoAdd_doc[] = +"setIpoAdd(add?)\n" +"\t - add? : add flag (KX_TRUE, KX_FALSE)\n" +"\tSet whether to interpret the ipo as additive rather than absolute.\n"; +PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* args) { + ShowDeprecationWarning("setIpoAdd()", "the useIpoAdd property"); + int boolArg; + + if (!PyArg_ParseTuple(args, "i:setIpoAdd", &boolArg)) { + return NULL; + } + + m_ipo_add = PyArgToBool(boolArg); + if (m_ipo_add) + m_ipo_as_force = false; + + Py_RETURN_NONE; +} +/* 7. getIpoAsForce: */ +const char KX_IpoActuator::GetIpoAdd_doc[] = +"getIpoAsAdd()\n" +"\tReturns whether to interpret the ipo as additive rather than absolute.\n"; +PyObject* KX_IpoActuator::PyGetIpoAdd() { + ShowDeprecationWarning("getIpoAdd()", "the useIpoAdd property"); + return BoolToPyArg(m_ipo_add); +} + +/* 8. setType: */ +const char KX_IpoActuator::SetType_doc[] = +"setType(mode)\n" +"\t - mode: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n" +"\tSet the operation mode of the actuator.\n"; +PyObject* KX_IpoActuator::PySetType(PyObject* args) { + ShowDeprecationWarning("setType()", "the mode property"); + int typeArg; + + if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) { + return NULL; + } + + if ( (typeArg > KX_ACT_IPO_NODEF) + && (typeArg < KX_ACT_IPO_MAX) ) { + m_type = typeArg; + } + + Py_RETURN_NONE; +} +/* 9. getType: */ +const char KX_IpoActuator::GetType_doc[] = +"getType()\n" +"\tReturns the operation mode of the actuator.\n"; +PyObject* KX_IpoActuator::PyGetType() { + ShowDeprecationWarning("getType()", "the mode property"); + return PyLong_FromSsize_t(m_type); +} + +/* 10. setForceIpoActsLocal: */ +const char KX_IpoActuator::SetForceIpoActsLocal_doc[] = +"setForceIpoActsLocal(local?)\n" +"\t - local? : Apply the ipo-as-force in the object's local\n" +"\t coordinates? (KX_TRUE, KX_FALSE)\n" +"\tSet whether to apply the force in the object's local\n" +"\tcoordinates rather than the world global coordinates.\n"; +PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* args) { + ShowDeprecationWarning("setForceIpoActsLocal()", "the useIpoLocal property"); + int boolArg; + + if (!PyArg_ParseTuple(args, "i:setForceIpoActsLocal", &boolArg)) { + return NULL; + } + + m_ipo_local = PyArgToBool(boolArg); + + Py_RETURN_NONE; +} +/* 11. getForceIpoActsLocal: */ +const char KX_IpoActuator::GetForceIpoActsLocal_doc[] = +"getForceIpoActsLocal()\n" +"\tReturn whether to apply the force in the object's local\n" +"\tcoordinates rather than the world global coordinates.\n"; +PyObject* KX_IpoActuator::PyGetForceIpoActsLocal() { + ShowDeprecationWarning("getForceIpoActsLocal()", "the useIpoLocal property"); + return BoolToPyArg(m_ipo_local); +} + + /* eof */ diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index 72fe812f98e..01051ca82dc 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -100,13 +100,13 @@ public: KX_ACT_IPO_MAX }; - static const char *S_KX_ACT_IPO_PLAY_STRING; - static const char *S_KX_ACT_IPO_PINGPONG_STRING; - static const char *S_KX_ACT_IPO_FLIPPER_STRING; - static const char *S_KX_ACT_IPO_LOOPSTOP_STRING; - static const char *S_KX_ACT_IPO_LOOPEND_STRING; - static const char *S_KX_ACT_IPO_KEY2KEY_STRING; - static const char *S_KX_ACT_IPO_FROM_PROP_STRING; + static STR_String S_KX_ACT_IPO_PLAY_STRING; + static STR_String S_KX_ACT_IPO_PINGPONG_STRING; + static STR_String S_KX_ACT_IPO_FLIPPER_STRING; + static STR_String S_KX_ACT_IPO_LOOPSTOP_STRING; + static STR_String S_KX_ACT_IPO_LOOPEND_STRING; + static STR_String S_KX_ACT_IPO_KEY2KEY_STRING; + static STR_String S_KX_ACT_IPO_FROM_PROP_STRING; int string2mode(char* modename); @@ -138,6 +138,23 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + //KX_PYMETHOD_DOC + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,Set); + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,SetProperty); +/* KX_PYMETHOD_DOC(KX_IpoActuator,SetKey2Key); */ + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,SetStart); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetStart); + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,SetEnd); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetEnd); + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,SetIpoAsForce); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetIpoAsForce); + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,SetIpoAdd); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetIpoAdd); + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,SetType); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetType); + KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,SetForceIpoActsLocal); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetForceIpoActsLocal); + }; #endif //__KX_IPOACTUATOR diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 4117e493322..13643e3a1ac 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -382,12 +382,12 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo) m_firstframe = true; m_bInitialized = true; // there is always one scene enabled at startup - Scene* scene = m_scenes[0]->GetBlenderScene(); - if (scene) + World* world = m_scenes[0]->GetBlenderScene()->world; + if (world) { - m_ticrate = scene->gm.ticrate ? scene->gm.ticrate : DEFAULT_LOGIC_TIC_RATE; - m_maxLogicFrame = scene->gm.maxlogicstep ? scene->gm.maxlogicstep : 5; - m_maxPhysicsFrame = scene->gm.maxphystep ? scene->gm.maxlogicstep : 5; + m_ticrate = world->ticrate ? world->ticrate : DEFAULT_LOGIC_TIC_RATE; + m_maxLogicFrame = world->maxlogicstep ? world->maxlogicstep : 5; + m_maxPhysicsFrame = world->maxphystep ? world->maxlogicstep : 5; } else { diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 744fdb75796..e15847fe6c6 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -68,12 +68,18 @@ PyTypeObject KX_MeshProxy::Type = { }; PyMethodDef KX_MeshProxy::Methods[] = { +// Deprecated -----> +{"getNumMaterials", (PyCFunction)KX_MeshProxy::sPyGetNumMaterials,METH_VARARGS}, +{"getNumPolygons", (PyCFunction)KX_MeshProxy::sPyGetNumPolygons,METH_NOARGS}, +// <----- + {"getMaterialName", (PyCFunction)KX_MeshProxy::sPyGetMaterialName,METH_VARARGS}, {"getTextureName", (PyCFunction)KX_MeshProxy::sPyGetTextureName,METH_VARARGS}, {"getVertexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetVertexArrayLength,METH_VARARGS}, {"getVertex", (PyCFunction)KX_MeshProxy::sPyGetVertex,METH_VARARGS}, {"getPolygon", (PyCFunction)KX_MeshProxy::sPyGetPolygon,METH_VARARGS}, //{"getIndexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetIndexArrayLength,METH_VARARGS}, + {NULL,NULL} //Sentinel }; @@ -113,6 +119,20 @@ CValue* KX_MeshProxy::GetReplica() { return NULL;} // stuff for python integration + +PyObject* KX_MeshProxy::PyGetNumMaterials(PyObject* args, PyObject* kwds) +{ + int num = m_meshobj->NumMaterials(); + ShowDeprecationWarning("getNumMaterials()", "the numMaterials property"); + return PyLong_FromSsize_t(num); +} + +PyObject* KX_MeshProxy::PyGetNumPolygons() +{ + int num = m_meshobj->NumPolygons(); + ShowDeprecationWarning("getNumPolygons()", "the numPolygons property"); + return PyLong_FromSsize_t(num); +} PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) { diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 8abc4f6b897..58053e1038d 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -61,13 +61,11 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, int starty, short int mousemode, int focusmode, - bool bTouchPulse, KX_Scene* kxscene, KX_KetsjiEngine *kxengine, SCA_IObject* gameobj) : SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj), m_focusmode(focusmode), - m_bTouchPulse(bTouchPulse), m_kxscene(kxscene), m_kxengine(kxengine) { @@ -79,7 +77,6 @@ void KX_MouseFocusSensor::Init() m_mouse_over_in_previous_frame = (m_invert)?true:false; m_positive_event = false; m_hitObject = 0; - m_hitObject_Last = NULL; m_reset = true; m_hitPosition.setValue(0,0,0); @@ -110,10 +107,7 @@ bool KX_MouseFocusSensor::Evaluate() m_positive_event = true; if (!m_mouse_over_in_previous_frame) { result = true; - } - else if(m_bTouchPulse && (m_hitObject != m_hitObject_Last)) { - result = true; - } + } } if (reset) { // force an event @@ -129,8 +123,7 @@ bool KX_MouseFocusSensor::Evaluate() } m_mouse_over_in_previous_frame = obHasFocus; - m_hitObject_Last = (void *)m_hitObject; - + return result; } @@ -368,6 +361,13 @@ PyTypeObject KX_MouseFocusSensor::Type = { }; PyMethodDef KX_MouseFocusSensor::Methods[] = { + {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, METH_NOARGS, (const char *)GetRayTarget_doc}, + {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, METH_NOARGS, (const char *)GetRaySource_doc}, + {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_NOARGS, (const char *)GetHitObject_doc}, + {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_NOARGS, (const char *)GetHitPosition_doc}, + {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_NOARGS, (const char *)GetHitNormal_doc}, + {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_NOARGS, (const char *)GetRayDirection_doc}, + {NULL,NULL} //Sentinel }; @@ -378,10 +378,81 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_MouseFocusSensor, pyattr_get_hit_object), KX_PYATTRIBUTE_RO_FUNCTION("hitPosition", KX_MouseFocusSensor, pyattr_get_hit_position), KX_PYATTRIBUTE_RO_FUNCTION("hitNormal", KX_MouseFocusSensor, pyattr_get_hit_normal), - KX_PYATTRIBUTE_BOOL_RW("usePulseFocus", KX_MouseFocusSensor,m_bTouchPulse), { NULL } //Sentinel }; +const char KX_MouseFocusSensor::GetHitObject_doc[] = +"getHitObject()\n" +"\tReturns the object that was hit by this ray.\n"; +PyObject* KX_MouseFocusSensor::PyGetHitObject() +{ + ShowDeprecationWarning("GetHitObject()", "the hitObject property"); + + if (m_hitObject) + return m_hitObject->GetProxy(); + + Py_RETURN_NONE; +} + + +const char KX_MouseFocusSensor::GetHitPosition_doc[] = +"getHitPosition()\n" +"\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n"; +PyObject* KX_MouseFocusSensor::PyGetHitPosition() +{ + ShowDeprecationWarning("getHitPosition()", "the hitPosition property"); + + return PyObjectFrom(m_hitPosition); +} + +const char KX_MouseFocusSensor::GetRayDirection_doc[] = +"getRayDirection()\n" +"\tReturns the direction from the ray (in worldcoordinates) .\n"; +PyObject* KX_MouseFocusSensor::PyGetRayDirection() +{ + ShowDeprecationWarning("getRayDirection()", "the rayDirection property"); + + MT_Vector3 dir = m_prevTargetPoint - m_prevSourcePoint; + if(MT_fuzzyZero(dir)) dir.setValue(0,0,0); + else dir.normalize(); + return PyObjectFrom(dir); +} + +const char KX_MouseFocusSensor::GetHitNormal_doc[] = +"getHitNormal()\n" +"\tReturns the normal (in worldcoordinates) at the point of collision where the object was hit by this ray.\n"; +PyObject* KX_MouseFocusSensor::PyGetHitNormal() +{ + ShowDeprecationWarning("getHitNormal()", "the hitNormal property"); + + return PyObjectFrom(m_hitNormal); +} + + +/* getRayTarget */ +const char KX_MouseFocusSensor::GetRayTarget_doc[] = +"getRayTarget()\n" +"\tReturns the target of the ray that seeks the focus object,\n" +"\tin worldcoordinates."; +PyObject* KX_MouseFocusSensor::PyGetRayTarget() +{ + ShowDeprecationWarning("getRayTarget()", "the rayTarget property"); + + return PyObjectFrom(m_prevTargetPoint); +} + +/* getRayTarget */ +const char KX_MouseFocusSensor::GetRaySource_doc[] = +"getRaySource()\n" +"\tReturns the source of the ray that seeks the focus object,\n" +"\tin worldcoordinates."; +PyObject* KX_MouseFocusSensor::PyGetRaySource() +{ + ShowDeprecationWarning("getRaySource()", "the raySource property"); + + return PyObjectFrom(m_prevSourcePoint); +} + /* Attributes */ PyObject* KX_MouseFocusSensor::pyattr_get_ray_source(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index 7b53557467f..dfada7a59cc 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -49,12 +49,11 @@ class KX_MouseFocusSensor : public SCA_MouseSensor public: - KX_MouseFocusSensor(class SCA_MouseManager* eventmgr, + KX_MouseFocusSensor(class SCA_MouseManager* keybdmgr, int startx, int starty, short int mousemode, int focusmode, - bool bTouchPulse, KX_Scene* kxscene, KX_KetsjiEngine* kxengine, SCA_IObject* gameobj); @@ -90,6 +89,14 @@ class KX_MouseFocusSensor : public SCA_MouseSensor /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayTarget); + KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRaySource); + + KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetHitObject); + KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetHitPosition); + KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetHitNormal); + KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayDirection); + /* attributes */ static PyObject* pyattr_get_ray_source(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_ray_target(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); @@ -100,7 +107,6 @@ class KX_MouseFocusSensor : public SCA_MouseSensor /* --------------------------------------------------------------------- */ SCA_IObject* m_hitObject; - void* m_hitObject_Last; /* only use for comparison, never access */ private: /** @@ -114,11 +120,6 @@ class KX_MouseFocusSensor : public SCA_MouseSensor bool m_mouse_over_in_previous_frame; /** - * Flags whether changes in hit object should trigger a pulse - */ - bool m_bTouchPulse; - - /** * Flags whether the previous test evaluated positive. */ bool m_positive_event; diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 2601ced9c38..2ee30ee0bfa 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -347,6 +347,32 @@ PyTypeObject KX_ObjectActuator::Type = { }; PyMethodDef KX_ObjectActuator::Methods[] = { + // Deprecated -----> + {"getForce", (PyCFunction) KX_ObjectActuator::sPyGetForce, METH_NOARGS}, + {"setForce", (PyCFunction) KX_ObjectActuator::sPySetForce, METH_VARARGS}, + {"getTorque", (PyCFunction) KX_ObjectActuator::sPyGetTorque, METH_NOARGS}, + {"setTorque", (PyCFunction) KX_ObjectActuator::sPySetTorque, METH_VARARGS}, + {"getDLoc", (PyCFunction) KX_ObjectActuator::sPyGetDLoc, METH_NOARGS}, + {"setDLoc", (PyCFunction) KX_ObjectActuator::sPySetDLoc, METH_VARARGS}, + {"getDRot", (PyCFunction) KX_ObjectActuator::sPyGetDRot, METH_NOARGS}, + {"setDRot", (PyCFunction) KX_ObjectActuator::sPySetDRot, METH_VARARGS}, + {"getLinearVelocity", (PyCFunction) KX_ObjectActuator::sPyGetLinearVelocity, METH_NOARGS}, + {"setLinearVelocity", (PyCFunction) KX_ObjectActuator::sPySetLinearVelocity, METH_VARARGS}, + {"getAngularVelocity", (PyCFunction) KX_ObjectActuator::sPyGetAngularVelocity, METH_NOARGS}, + {"setAngularVelocity", (PyCFunction) KX_ObjectActuator::sPySetAngularVelocity, METH_VARARGS}, + {"setDamping", (PyCFunction) KX_ObjectActuator::sPySetDamping, METH_VARARGS}, + {"getDamping", (PyCFunction) KX_ObjectActuator::sPyGetDamping, METH_NOARGS}, + {"setForceLimitX", (PyCFunction) KX_ObjectActuator::sPySetForceLimitX, METH_VARARGS}, + {"getForceLimitX", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitX, METH_NOARGS}, + {"setForceLimitY", (PyCFunction) KX_ObjectActuator::sPySetForceLimitY, METH_VARARGS}, + {"getForceLimitY", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitY, METH_NOARGS}, + {"setForceLimitZ", (PyCFunction) KX_ObjectActuator::sPySetForceLimitZ, METH_VARARGS}, + {"getForceLimitZ", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitZ, METH_NOARGS}, + {"setPID", (PyCFunction) KX_ObjectActuator::sPyGetPID, METH_NOARGS}, + {"getPID", (PyCFunction) KX_ObjectActuator::sPySetPID, METH_VARARGS}, + + // <----- Deprecated + {NULL,NULL} //Sentinel }; @@ -467,7 +493,7 @@ Mathutils_Callback mathutils_obactu_vector_cb = { PyObject* KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); + return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); } int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -481,7 +507,7 @@ int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *a PyObject* KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); + return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); } int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -641,4 +667,305 @@ int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIB return PY_SET_ATTR_SUCCESS; } + +/* 1. set ------------------------------------------------------------------ */ +/* Removed! */ + +/* 2. getForce */ +PyObject* KX_ObjectActuator::PyGetForce() +{ + ShowDeprecationWarning("getForce()", "the force and the useLocalForce properties"); + PyObject *retVal = PyList_New(4); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_force[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_force[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_force[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.Force)); + + return retVal; +} +/* 3. setForce */ +PyObject* KX_ObjectActuator::PySetForce(PyObject* args) +{ + ShowDeprecationWarning("setForce()", "the force and the useLocalForce properties"); + float vecArg[3]; + int bToggle = 0; + if (!PyArg_ParseTuple(args, "fffi:setForce", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { + return NULL; + } + m_force.setValue(vecArg); + m_bitLocalFlag.Force = PyArgToBool(bToggle); + UpdateFuzzyFlags(); + Py_RETURN_NONE; +} + +/* 4. getTorque */ +PyObject* KX_ObjectActuator::PyGetTorque() +{ + ShowDeprecationWarning("getTorque()", "the torque and the useLocalTorque properties"); + PyObject *retVal = PyList_New(4); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_torque[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_torque[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_torque[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.Torque)); + + return retVal; +} +/* 5. setTorque */ +PyObject* KX_ObjectActuator::PySetTorque(PyObject* args) +{ + ShowDeprecationWarning("setTorque()", "the torque and the useLocalTorque properties"); + float vecArg[3]; + int bToggle = 0; + if (!PyArg_ParseTuple(args, "fffi:setTorque", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { + return NULL; + } + m_torque.setValue(vecArg); + m_bitLocalFlag.Torque = PyArgToBool(bToggle); + UpdateFuzzyFlags(); + Py_RETURN_NONE; +} + +/* 6. getDLoc */ +PyObject* KX_ObjectActuator::PyGetDLoc() +{ + ShowDeprecationWarning("getDLoc()", "the dLoc and the useLocalDLoc properties"); + PyObject *retVal = PyList_New(4); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_dloc[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_dloc[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.DLoc)); + + return retVal; +} +/* 7. setDLoc */ +PyObject* KX_ObjectActuator::PySetDLoc(PyObject* args) +{ + ShowDeprecationWarning("setDLoc()", "the dLoc and the useLocalDLoc properties"); + float vecArg[3]; + int bToggle = 0; + if(!PyArg_ParseTuple(args, "fffi:setDLoc", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { + return NULL; + } + m_dloc.setValue(vecArg); + m_bitLocalFlag.DLoc = PyArgToBool(bToggle); + UpdateFuzzyFlags(); + Py_RETURN_NONE; +} + +/* 8. getDRot */ +PyObject* KX_ObjectActuator::PyGetDRot() +{ + ShowDeprecationWarning("getDRot()", "the dRot and the useLocalDRot properties"); + PyObject *retVal = PyList_New(4); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_drot[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_drot[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.DRot)); + + return retVal; +} +/* 9. setDRot */ +PyObject* KX_ObjectActuator::PySetDRot(PyObject* args) +{ + ShowDeprecationWarning("setDRot()", "the dRot and the useLocalDRot properties"); + float vecArg[3]; + int bToggle = 0; + if (!PyArg_ParseTuple(args, "fffi:setDRot", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { + return NULL; + } + m_drot.setValue(vecArg); + m_bitLocalFlag.DRot = PyArgToBool(bToggle); + UpdateFuzzyFlags(); + Py_RETURN_NONE; +} + +/* 10. getLinearVelocity */ +PyObject* KX_ObjectActuator::PyGetLinearVelocity() { + ShowDeprecationWarning("getLinearVelocity()", "the linV and the useLocalLinV properties"); + PyObject *retVal = PyList_New(4); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.LinearVelocity)); + + return retVal; +} + +/* 11. setLinearVelocity */ +PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* args) { + ShowDeprecationWarning("setLinearVelocity()", "the linV and the useLocalLinV properties"); + float vecArg[3]; + int bToggle = 0; + if (!PyArg_ParseTuple(args, "fffi:setLinearVelocity", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { + return NULL; + } + m_linear_velocity.setValue(vecArg); + m_bitLocalFlag.LinearVelocity = PyArgToBool(bToggle); + UpdateFuzzyFlags(); + Py_RETURN_NONE; +} + + +/* 12. getAngularVelocity */ +PyObject* KX_ObjectActuator::PyGetAngularVelocity() { + ShowDeprecationWarning("getAngularVelocity()", "the angV and the useLocalAngV properties"); + PyObject *retVal = PyList_New(4); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.AngularVelocity)); + + return retVal; +} +/* 13. setAngularVelocity */ +PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* args) { + ShowDeprecationWarning("setAngularVelocity()", "the angV and the useLocalAngV properties"); + float vecArg[3]; + int bToggle = 0; + if (!PyArg_ParseTuple(args, "fffi:setAngularVelocity", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { + return NULL; + } + m_angular_velocity.setValue(vecArg); + m_bitLocalFlag.AngularVelocity = PyArgToBool(bToggle); + UpdateFuzzyFlags(); + Py_RETURN_NONE; +} + +/* 13. setDamping */ +PyObject* KX_ObjectActuator::PySetDamping(PyObject* args) { + ShowDeprecationWarning("setDamping()", "the damping property"); + int damping = 0; + if (!PyArg_ParseTuple(args, "i:setDamping", &damping) || damping < 0 || damping > 1000) { + return NULL; + } + m_damping = damping; + Py_RETURN_NONE; +} + +/* 13. getVelocityDamping */ +PyObject* KX_ObjectActuator::PyGetDamping() { + ShowDeprecationWarning("getDamping()", "the damping property"); + return Py_BuildValue("i",m_damping); +} +/* 6. getForceLimitX */ +PyObject* KX_ObjectActuator::PyGetForceLimitX() +{ + ShowDeprecationWarning("getForceLimitX()", "the forceLimitX property"); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[0])); + PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.Torque)); + + return retVal; +} +/* 7. setForceLimitX */ +PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* args) +{ + ShowDeprecationWarning("setForceLimitX()", "the forceLimitX property"); + float vecArg[2]; + int bToggle = 0; + if(!PyArg_ParseTuple(args, "ffi:setForceLimitX", &vecArg[0], &vecArg[1], &bToggle)) { + return NULL; + } + m_drot[0] = vecArg[0]; + m_dloc[0] = vecArg[1]; + m_bitLocalFlag.Torque = PyArgToBool(bToggle); + Py_RETURN_NONE; +} + +/* 6. getForceLimitY */ +PyObject* KX_ObjectActuator::PyGetForceLimitY() +{ + ShowDeprecationWarning("getForceLimitY()", "the forceLimitY property"); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[1])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[1])); + PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.DLoc)); + + return retVal; +} +/* 7. setForceLimitY */ +PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* args) +{ + ShowDeprecationWarning("setForceLimitY()", "the forceLimitY property"); + float vecArg[2]; + int bToggle = 0; + if(!PyArg_ParseTuple(args, "ffi:setForceLimitY", &vecArg[0], &vecArg[1], &bToggle)) { + return NULL; + } + m_drot[1] = vecArg[0]; + m_dloc[1] = vecArg[1]; + m_bitLocalFlag.DLoc = PyArgToBool(bToggle); + Py_RETURN_NONE; +} + +/* 6. getForceLimitZ */ +PyObject* KX_ObjectActuator::PyGetForceLimitZ() +{ + ShowDeprecationWarning("getForceLimitZ()", "the forceLimitZ property"); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[2])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[2])); + PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.DRot)); + + return retVal; +} +/* 7. setForceLimitZ */ +PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* args) +{ + ShowDeprecationWarning("setForceLimitZ()", "the forceLimitZ property"); + float vecArg[2]; + int bToggle = 0; + if(!PyArg_ParseTuple(args, "ffi:setForceLimitZ", &vecArg[0], &vecArg[1], &bToggle)) { + return NULL; + } + m_drot[2] = vecArg[0]; + m_dloc[2] = vecArg[1]; + m_bitLocalFlag.DRot = PyArgToBool(bToggle); + Py_RETURN_NONE; +} + +/* 4. getPID */ +PyObject* KX_ObjectActuator::PyGetPID() +{ + ShowDeprecationWarning("getPID()", "the pid property"); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_pid[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_pid[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_pid[2])); + + return retVal; +} +/* 5. setPID */ +PyObject* KX_ObjectActuator::PySetPID(PyObject* args) +{ + ShowDeprecationWarning("setPID()", "the pid property"); + float vecArg[3]; + if (!PyArg_ParseTuple(args, "fff:setPID", &vecArg[0], &vecArg[1], &vecArg[2])) { + return NULL; + } + m_pid.setValue(vecArg); + Py_RETURN_NONE; +} + + + + + /* eof */ diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index 7a8c7de16b1..20aec9e0e86 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -163,6 +163,29 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForce); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetTorque); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetTorque); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDLoc); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetDLoc); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDRot); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetDRot); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetLinearVelocity); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetLinearVelocity); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetAngularVelocity); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetAngularVelocity); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetDamping); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDamping); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitX); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForceLimitX); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitY); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForceLimitY); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitZ); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForceLimitZ); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetPID); + KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetPID); + /* Attributes */ static PyObject* pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 20e982f03e0..621aeea87be 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -162,6 +162,10 @@ PyTypeObject KX_ParentActuator::Type = { }; PyMethodDef KX_ParentActuator::Methods[] = { + // Deprecated -----> + {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, + // <----- {NULL,NULL} //Sentinel }; @@ -201,4 +205,55 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE return PY_SET_ATTR_SUCCESS; } + +/* Deprecated -----> */ +/* 1. setObject */ +const char KX_ParentActuator::SetObject_doc[] = +"setObject(object)\n" +"\t- object: KX_GameObject, string or None\n" +"\tSet the object to set as parent.\n"; +PyObject* KX_ParentActuator::PySetObject(PyObject* value) { + KX_GameObject *gameobj; + + ShowDeprecationWarning("setObject()", "the object property"); + + if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.setObject(value): KX_ParentActuator")) + return NULL; // ConvertPythonToGameObject sets the error + + if (m_ob != NULL) + m_ob->UnregisterActuator(this); + + m_ob = (SCA_IObject*)gameobj; + if (m_ob) + m_ob->RegisterActuator(this); + + Py_RETURN_NONE; +} + +/* 2. getObject */ + +/* get obj ---------------------------------------------------------- */ +const char KX_ParentActuator::GetObject_doc[] = +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" +"\tReturns the object that is set to.\n"; +PyObject* KX_ParentActuator::PyGetObject(PyObject* args) +{ + int ret_name_only = 1; + + ShowDeprecationWarning("getObject()", "the object property"); + + if (!PyArg_ParseTuple(args, "|i:getObject", &ret_name_only)) + return NULL; + + if (!m_ob) + Py_RETURN_NONE; + + if (ret_name_only) + return PyUnicode_FromString(m_ob->GetName().ReadPtr()); + else + return m_ob->GetProxy(); +} +/* <----- */ + /* eof */ diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index f750affc8a1..aeb39eabf89 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -84,6 +84,11 @@ class KX_ParentActuator : public SCA_IActuator /* These are used to get and set m_ob */ static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + + // Deprecated -----> + KX_PYMETHOD_DOC_O(KX_ParentActuator,SetObject); + KX_PYMETHOD_DOC_VARARGS(KX_ParentActuator,GetObject); + // <----- }; /* end of class KX_ParentActuator : public SCA_PropertyActuator */ diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index af8e0510a11..eae1894428c 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -132,19 +132,19 @@ PyObject* KX_PolyProxy::py_getattro(PyObject *attr) } if (!strcmp(attr_str, "v1")) { - return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 0)); + return PyLong_FromSsize_t(m_polygon->GetVertexOffset(0)); } if (!strcmp(attr_str, "v2")) { - return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 1)); + return PyLong_FromSsize_t(m_polygon->GetVertexOffset(1)); } if (!strcmp(attr_str, "v3")) { - return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 2)); + return PyLong_FromSsize_t(m_polygon->GetVertexOffset(2)); } if (!strcmp(attr_str, "v4")) { - return PyLong_FromSsize_t(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffsetAbs(m_mesh, 3):0)); + return PyLong_FromSsize_t(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0)); } if (!strcmp(attr_str, "visible")) { @@ -244,7 +244,7 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex, } if (index < m_polygon->VertexCount()) { - return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, index)); + return PyLong_FromSsize_t(m_polygon->GetVertexOffset(index)); } return PyLong_FromSsize_t(0); } diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index a41dab194dd..6d33c38190c 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -146,7 +146,7 @@ PyObject* PyObjectFrom(const MT_Quaternion &qrot) { /* NOTE, were re-ordering here for Mathutils compat */ float fvec[4]= {qrot[3], qrot[0], qrot[1], qrot[2]}; - return newQuaternionObject(fvec, Py_NEW, NULL); + return newQuaternionObject(fvec, Py_WRAP, NULL); } #endif @@ -154,7 +154,7 @@ PyObject* PyObjectFrom(const MT_Tuple4 &vec) { #ifdef USE_MATHUTILS float fvec[4]= {vec[0], vec[1], vec[2], vec[3]}; - return newVectorObject(fvec, 4, Py_NEW, NULL); + return newVectorObject(fvec, 4, Py_WRAP, NULL); #else PyObject *list = PyList_New(4); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); @@ -169,7 +169,7 @@ PyObject* PyObjectFrom(const MT_Tuple3 &vec) { #ifdef USE_MATHUTILS float fvec[3]= {vec[0], vec[1], vec[2]}; - return newVectorObject(fvec, 3, Py_NEW, NULL); + return newVectorObject(fvec, 3, Py_WRAP, NULL); #else PyObject *list = PyList_New(3); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); @@ -183,7 +183,7 @@ PyObject* PyObjectFrom(const MT_Tuple2 &vec) { #ifdef USE_MATHUTILS float fvec[2]= {vec[0], vec[1]}; - return newVectorObject(fvec, 2, Py_NEW, NULL); + return newVectorObject(fvec, 2, Py_WRAP, NULL); #else PyObject *list = PyList_New(2); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index 17102905607..9ee11c9e745 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -109,33 +109,30 @@ bool PyVecTo(PyObject* pyval, T& vec) if(VectorObject_Check(pyval)) { VectorObject *pyvec= (VectorObject *)pyval; - BaseMath_ReadCallback(pyvec); if (pyvec->size != Size(vec)) { PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", pyvec->size, Size(vec)); return false; } - vec.setValue((float *) pyvec->vec); + vec.getValue((float *) pyvec->vec); return true; } else if(QuaternionObject_Check(pyval)) { QuaternionObject *pyquat= (QuaternionObject *)pyval; - BaseMath_ReadCallback(pyquat); if (4 != Size(vec)) { PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 4, Size(vec)); return false; } /* xyzw -> wxyz reordering is done by PyQuatTo */ - vec.setValue((float *) pyquat->quat); + vec.getValue((float *) pyquat->quat); return true; } else if(EulerObject_Check(pyval)) { EulerObject *pyeul= (EulerObject *)pyval; - BaseMath_ReadCallback(pyeul); if (3 != Size(vec)) { PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 3, Size(vec)); return false; } - vec.setValue((float *) pyeul->eul); + vec.getValue((float *) pyeul->eul); return true; } else #endif diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 298d485aaaf..de3dcd0ebf8 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -32,6 +32,11 @@ // directory header for py function getBlendFileList #include <stdlib.h> +#ifndef WIN32 + #include <dirent.h> +#else + #include "BLI_winstuff.h" +#endif #ifdef WIN32 #pragma warning (disable : 4786) @@ -75,6 +80,8 @@ extern "C" { #include "InputParser.h" #include "KX_Scene.h" +#include "NG_NetworkScene.h" //Needed for sendMessage() + #include "BL_Shader.h" #include "KX_PyMath.h" @@ -104,13 +111,6 @@ extern "C" { #include "BLI_blenlib.h" #include "GPU_material.h" -#ifndef WIN32 - #include <dirent.h> -#else - #include "BLI_winstuff.h" -#endif -#include "NG_NetworkScene.h" //Needed for sendMessage() - static void setSandbox(TPythonSecurityLevel level); // 'local' copy of canvas ptr, for window height/width python scripts @@ -142,7 +142,7 @@ void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,cons // List of methods defined in the module static PyObject* ErrorObject; -static const char *gPyGetRandomFloat_doc="getRandomFloat returns a random floating point value in the range [0..1]"; +STR_String gPyGetRandomFloat_doc="getRandomFloat returns a random floating point value in the range [0..1)"; static PyObject* gPyGetRandomFloat(PyObject*) { @@ -346,7 +346,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) return list; } -static const char *gPyGetCurrentScene_doc = +static STR_String gPyGetCurrentScene_doc = "getCurrentScene()\n" "Gets a reference to the current scene.\n"; static PyObject* gPyGetCurrentScene(PyObject* self) @@ -354,7 +354,7 @@ static PyObject* gPyGetCurrentScene(PyObject* self) return gp_KetsjiScene->GetProxy(); } -static const char *gPyGetSceneList_doc = +static STR_String gPyGetSceneList_doc = "getSceneList()\n" "Return a list of converted scenes.\n"; static PyObject* gPyGetSceneList(PyObject* self) @@ -448,18 +448,46 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) } +static PyObject *gEvalExpression(PyObject*, PyObject* value) +{ + char* txt= _PyUnicode_AsString(value); + + if (txt==NULL) { + PyErr_SetString(PyExc_TypeError, "Expression.calc(text): expects a single string argument"); + return NULL; + } + + CParser parser; + CExpression* expr = parser.ProcessText(txt); + CValue* val = expr->Calculate(); + expr->Release(); + + if (val) { + PyObject* pyobj = val->ConvertValueToPython(); + if (pyobj) + return pyobj; + else + return val->GetProxy(); + } + + Py_RETURN_NONE; +} + + static struct PyMethodDef game_methods[] = { {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (const char *)gPyExpandPath_doc}, {"sendMessage", (PyCFunction)gPySendMessage, METH_VARARGS, (const char *)gPySendMessage_doc}, {"getCurrentController", (PyCFunction) SCA_PythonController::sPyGetCurrentController, - METH_NOARGS, SCA_PythonController::sPyGetCurrentController__doc__}, + METH_NOARGS, (const char *)SCA_PythonController::sPyGetCurrentController__doc__}, {"getCurrentScene", (PyCFunction) gPyGetCurrentScene, - METH_NOARGS, gPyGetCurrentScene_doc}, + METH_NOARGS, (const char *)gPyGetCurrentScene_doc.Ptr()}, {"getSceneList", (PyCFunction) gPyGetSceneList, - METH_NOARGS, (const char *)gPyGetSceneList_doc}, + METH_NOARGS, (const char *)gPyGetSceneList_doc.Ptr()}, + {"addActiveActuator",(PyCFunction) SCA_PythonController::sPyAddActiveActuator, + METH_VARARGS, (const char *)SCA_PythonController::sPyAddActiveActuator__doc__}, {"getRandomFloat",(PyCFunction) gPyGetRandomFloat, - METH_NOARGS, (const char *)gPyGetRandomFloat_doc}, + METH_NOARGS, (const char *)gPyGetRandomFloat_doc.Ptr()}, {"setGravity",(PyCFunction) gPySetGravity, METH_O, (const char *)"set Gravitation"}, {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (const char *)"get audio spectrum"}, {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS, (const char *)"stop using the audio dsp (for performance reasons)"}, @@ -474,6 +502,7 @@ static struct PyMethodDef game_methods[] = { {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"}, {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (const char *)"Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"}, + {"EvalExpression", (PyCFunction)gEvalExpression, METH_O, (const char *)"Evaluate a string as a game logic expression"}, {NULL, (PyCFunction) NULL, 0, NULL } }; @@ -2016,3 +2045,6 @@ void resetGamePythonPath() { gp_GamePythonPathOrig[0] = '\0'; } + + + diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index 61e563791c3..5260c0bb01a 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -123,6 +123,9 @@ static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *a memset(attr_getset, 0, sizeof(PyGetSetDef)); } } else { + + PyObject *item; + PyType_Ready(tp); PyDict_SetItemString(dict, tp->tp_name, reinterpret_cast<PyObject *>(tp)); } diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index 75a7c9b8aeb..4fc5252de60 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -340,42 +340,11 @@ static PyObject *KX_PythonSeq_nextIter(KX_PythonSeq *self) } -static int KX_PythonSeq_compare( KX_PythonSeq * a, KX_PythonSeq * b ) +static int KX_PythonSeq_compare( KX_PythonSeq * a, KX_PythonSeq * b ) /* TODO - python3.x wants richcmp */ { return ( a->type == b->type && a->base == b->base) ? 0 : -1; } -static PyObject *KX_PythonSeq_richcmp(PyObject *a, PyObject *b, int op) -{ - PyObject *res; - int ok= -1; /* zero is true */ - - if(BPy_KX_PythonSeq_Check(a) && BPy_KX_PythonSeq_Check(b)) - ok= KX_PythonSeq_compare((KX_PythonSeq *)a, (KX_PythonSeq *)b); - - switch (op) { - case Py_NE: - ok = !ok; /* pass through */ - case Py_EQ: - res = ok ? Py_False : Py_True; - break; - - case Py_LT: - case Py_LE: - case Py_GT: - case Py_GE: - res = Py_NotImplemented; - break; - default: - PyErr_BadArgument(); - return NULL; - } - - Py_INCREF(res); - return res; -} - - /* * repr function * convert to a list and get its string value @@ -405,7 +374,8 @@ PyTypeObject KX_PythonSeq_Type = { NULL, /* printfunc tp_print; */ NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* cmpfunc tp_compare; */ + /* TODO, richcmp */ + NULL, /* ( cmpfunc ) KX_PythonSeq_compare, /* cmpfunc tp_compare; */ ( reprfunc ) KX_PythonSeq_repr, /* reprfunc tp_repr; */ /* Method suites for standard classes */ @@ -431,14 +401,14 @@ PyTypeObject KX_PythonSeq_Type = { NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ - NULL, /* traverseproc tp_traverse; */ + NULL, /* traverseproc tp_traverse; */ /* delete references to contained objects */ NULL, /* inquiry tp_clear; */ /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - (richcmpfunc)KX_PythonSeq_richcmp, /* richcmpfunc tp_richcompare; */ + NULL, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ 0, /* long tp_weaklistoffset; */ diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index eb127be8044..d020a2544d2 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -176,7 +176,51 @@ void KX_RadarSensor::SynchronizeTransform() /* Python Functions */ /* ------------------------------------------------------------------------- */ -/* none */ +//Deprecated -----> +/* getConeOrigin */ +const char KX_RadarSensor::GetConeOrigin_doc[] = +"getConeOrigin()\n" +"\tReturns the origin of the cone with which to test. The origin\n" +"\tis in the middle of the cone."; +PyObject* KX_RadarSensor::PyGetConeOrigin() { + ShowDeprecationWarning("getConeOrigin()", "the coneOrigin property"); + + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_cone_origin[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_cone_origin[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_cone_origin[2])); + + return retVal; +} + +/* getConeOrigin */ +const char KX_RadarSensor::GetConeTarget_doc[] = +"getConeTarget()\n" +"\tReturns the center of the bottom face of the cone with which to test.\n"; +PyObject* KX_RadarSensor::PyGetConeTarget() { + ShowDeprecationWarning("getConeTarget()", "the coneTarget property"); + + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_cone_target[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_cone_target[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_cone_target[2])); + + return retVal; +} + +/* getConeHeight */ +const char KX_RadarSensor::GetConeHeight_doc[] = +"getConeHeight()\n" +"\tReturns the height of the cone with which to test.\n"; +PyObject* KX_RadarSensor::PyGetConeHeight() { + + ShowDeprecationWarning("getConeHeight()", "the distance property"); + + return PyFloat_FromDouble(m_coneheight); +} +//<----- Deprecated /* ------------------------------------------------------------------------- */ /* Python Integration Hooks */ @@ -204,6 +248,14 @@ PyTypeObject KX_RadarSensor::Type = { }; PyMethodDef KX_RadarSensor::Methods[] = { + //Deprecated -----> + {"getConeOrigin", (PyCFunction) KX_RadarSensor::sPyGetConeOrigin, + METH_VARARGS, (const char *)GetConeOrigin_doc}, + {"getConeTarget", (PyCFunction) KX_RadarSensor::sPyGetConeTarget, + METH_VARARGS, (const char *)GetConeTarget_doc}, + {"getConeHeight", (PyCFunction) KX_RadarSensor::sPyGetConeHeight, + METH_VARARGS, (const char *)GetConeHeight_doc}, + //<----- {NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h index 487e9f1aaa7..9f38d75abc4 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.h +++ b/source/gameengine/Ketsji/KX_RadarSensor.h @@ -90,6 +90,11 @@ public: /* python */ virtual sensortype GetSensorType() { return ST_RADAR; } + //Deprecated -----> + KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeOrigin); + KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeTarget); + KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeHeight); + //<----- }; #endif //__KX_RADAR_SENSOR_H diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 1f36945ccaa..8616145d709 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -342,6 +342,12 @@ PyTypeObject KX_RaySensor::Type = { }; PyMethodDef KX_RaySensor::Methods[] = { + // Deprecated -----> + {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_NOARGS, (const char *)GetHitObject_doc}, + {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_NOARGS, (const char *)GetHitPosition_doc}, + {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_NOARGS, (const char *)GetHitNormal_doc}, + {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_NOARGS, (const char *)GetRayDirection_doc}, + // <----- {NULL,NULL} //Sentinel }; @@ -366,3 +372,68 @@ PyObject* KX_RaySensor::pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_ Py_RETURN_NONE; } + +// Deprecated -----> +const char KX_RaySensor::GetHitObject_doc[] = +"getHitObject()\n" +"\tReturns the name of the object that was hit by this ray.\n"; +PyObject* KX_RaySensor::PyGetHitObject() +{ + ShowDeprecationWarning("getHitObject()", "the hitObject property"); + if (m_hitObject) + { + return m_hitObject->GetProxy(); + } + Py_RETURN_NONE; +} + + +const char KX_RaySensor::GetHitPosition_doc[] = +"getHitPosition()\n" +"\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n"; +PyObject* KX_RaySensor::PyGetHitPosition() +{ + ShowDeprecationWarning("getHitPosition()", "the hitPosition property"); + + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_hitPosition[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_hitPosition[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_hitPosition[2])); + + return retVal; +} + +const char KX_RaySensor::GetRayDirection_doc[] = +"getRayDirection()\n" +"\tReturns the direction from the ray (in worldcoordinates) .\n"; +PyObject* KX_RaySensor::PyGetRayDirection() +{ + ShowDeprecationWarning("getRayDirection()", "the rayDirection property"); + + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_rayDirection[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_rayDirection[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_rayDirection[2])); + + return retVal; +} + +const char KX_RaySensor::GetHitNormal_doc[] = +"getHitNormal()\n" +"\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n"; +PyObject* KX_RaySensor::PyGetHitNormal() +{ + ShowDeprecationWarning("getHitNormal()", "the hitNormal property"); + + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_hitNormal[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_hitNormal[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_hitNormal[2])); + + return retVal; +} + +// <----- Deprecated diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index d3e92a14214..530c8ce54e5 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -84,6 +84,12 @@ public: KX_RAY_AXIS_NEG_Z }; + // Deprecated -----> + KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitObject); + KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitPosition); + KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitNormal); + KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetRayDirection); + // <----- /* Attributes */ static PyObject* pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 099403fc28d..fffb0ac1220 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -192,7 +192,18 @@ PyTypeObject KX_SCA_AddObjectActuator::Type = { }; PyMethodDef KX_SCA_AddObjectActuator::Methods[] = { + // ---> deprecated + {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (const char *)SetTime_doc}, + {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc}, + {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, (const char *)GetLinearVelocity_doc}, + {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, (const char *)SetLinearVelocity_doc}, + {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, (const char *)GetAngularVelocity_doc}, + {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, (const char *)SetAngularVelocity_doc}, + {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"}, {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"}, + {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, + {NULL,NULL} //Sentinel }; @@ -242,6 +253,181 @@ PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, con return actuator->m_lastCreatedObject->GetProxy(); } +/* 1. setObject */ +const char KX_SCA_AddObjectActuator::SetObject_doc[] = +"setObject(object)\n" +"\t- object: KX_GameObject, string or None\n" +"\tSets the object that will be added. There has to be an object\n" +"\tof this name. If not, this function does nothing.\n"; +PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* value) +{ + KX_GameObject *gameobj; + + ShowDeprecationWarning("setObject()", "the object property"); + + if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.setObject(value): KX_SCA_AddObjectActuator")) + return NULL; // ConvertPythonToGameObject sets the error + + if (m_OriginalObject != NULL) + m_OriginalObject->UnregisterActuator(this); + + m_OriginalObject = (SCA_IObject*)gameobj; + if (m_OriginalObject) + m_OriginalObject->RegisterActuator(this); + + Py_RETURN_NONE; +} + + + +/* 2. setTime */ +const char KX_SCA_AddObjectActuator::SetTime_doc[] = +"setTime(duration)\n" +"\t- duration: integer\n" +"\tSets the lifetime of the object that will be added, in frames. \n" +"\tIf the duration is negative, it is set to 0.\n"; + + +PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* value) +{ + ShowDeprecationWarning("setTime()", "the time property"); + int deltatime = PyLong_AsSsize_t(value); + if (deltatime==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "expected an int"); + return NULL; + } + + m_timeProp = deltatime; + if (m_timeProp < 0) m_timeProp = 0; + + Py_RETURN_NONE; +} + + + +/* 3. getTime */ +const char KX_SCA_AddObjectActuator::GetTime_doc[] = +"getTime()\n" +"\tReturns the lifetime of the object that will be added.\n"; + + +PyObject* KX_SCA_AddObjectActuator::PyGetTime() +{ + ShowDeprecationWarning("getTime()", "the time property"); + return PyLong_FromSsize_t(m_timeProp); +} + + +/* 4. getObject */ +const char KX_SCA_AddObjectActuator::GetObject_doc[] = +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" +"\tReturns the name of the object that will be added.\n"; +PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* args) +{ + int ret_name_only = 1; + + ShowDeprecationWarning("getObject()", "the object property"); + + if (!PyArg_ParseTuple(args, "|i:getObject", &ret_name_only)) + return NULL; + + if (!m_OriginalObject) + Py_RETURN_NONE; + + if (ret_name_only) + return PyUnicode_FromString(m_OriginalObject->GetName().ReadPtr()); + else + return m_OriginalObject->GetProxy(); +} + + + +/* 5. getLinearVelocity */ +const char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] = +"GetLinearVelocity()\n" +"\tReturns the linear velocity that will be assigned to \n" +"\tthe created object.\n"; + +PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity() +{ + ShowDeprecationWarning("getLinearVelocity()", "the linearVelocity property"); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2])); + + return retVal; +} + + + +/* 6. setLinearVelocity */ +const char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] = +"setLinearVelocity(vx, vy, vz)\n" +"\t- vx: float\n" +"\t- vy: float\n" +"\t- vz: float\n" +"\t- local: bool\n" +"\tAssign this velocity to the created object. \n"; + +PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* args) +{ + ShowDeprecationWarning("setLinearVelocity()", "the linearVelocity property"); + + float vecArg[3]; + if (!PyArg_ParseTuple(args, "fff:setLinearVelocity", &vecArg[0], &vecArg[1], &vecArg[2])) + return NULL; + + m_linear_velocity[0] = vecArg[0]; + m_linear_velocity[1] = vecArg[1]; + m_linear_velocity[2] = vecArg[2]; + Py_RETURN_NONE; +} + +/* 7. getAngularVelocity */ +const char KX_SCA_AddObjectActuator::GetAngularVelocity_doc[] = +"GetAngularVelocity()\n" +"\tReturns the angular velocity that will be assigned to \n" +"\tthe created object.\n"; + +PyObject* KX_SCA_AddObjectActuator::PyGetAngularVelocity() +{ + ShowDeprecationWarning("getAngularVelocity()", "the angularVelocity property"); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2])); + + return retVal; +} + + + +/* 8. setAngularVelocity */ +const char KX_SCA_AddObjectActuator::SetAngularVelocity_doc[] = +"setAngularVelocity(vx, vy, vz)\n" +"\t- vx: float\n" +"\t- vy: float\n" +"\t- vz: float\n" +"\t- local: bool\n" +"\tAssign this angular velocity to the created object. \n"; + +PyObject* KX_SCA_AddObjectActuator::PySetAngularVelocity(PyObject* args) +{ + ShowDeprecationWarning("setAngularVelocity()", "the angularVelocity property"); + + float vecArg[3]; + if (!PyArg_ParseTuple(args, "fff:setAngularVelocity", &vecArg[0], &vecArg[1], &vecArg[2])) + return NULL; + + m_angular_velocity[0] = vecArg[0]; + m_angular_velocity[1] = vecArg[1]; + m_angular_velocity[2] = vecArg[2]; + Py_RETURN_NONE; +} void KX_SCA_AddObjectActuator::InstantAddObject() { @@ -284,3 +470,26 @@ PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject() Py_RETURN_NONE; } + + + +/* 7. GetLastCreatedObject */ +const char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] = +"getLastCreatedObject()\n" +"\tReturn the last created object. \n"; + + +PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject() +{ + ShowDeprecationWarning("getLastCreatedObject()", "the objectLastCreated property"); + SCA_IObject* result = this->GetLastCreatedObject(); + + // if result->GetSGNode() is NULL + // it means the object has ended, The BGE python api crashes in many places if the object is returned. + if (result && (static_cast<KX_GameObject *>(result))->GetSGNode()) + { + return result->GetProxy(); + } + // don't return NULL to python anymore, it gives trouble in the scripts + Py_RETURN_NONE; +} diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 7137ba5209e..3151e7a89ca 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -115,6 +115,25 @@ public: void InstantAddObject(); + /* 1. setObject */ + KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetObject); + /* 2. setTime */ + KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetTime); + /* 3. getTime */ + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetTime); + /* 4. getObject */ + KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,GetObject); + /* 5. getLinearVelocity */ + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetLinearVelocity); + /* 6. setLinearVelocity */ + KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,SetLinearVelocity); + /* 7. getAngularVelocity */ + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetAngularVelocity); + /* 8. setAngularVelocity */ + KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,SetAngularVelocity); + /* 9. getLastCreatedObject */ + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetLastCreatedObject); + /* 10. instantAddObject*/ KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject); static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 646cfb7219f..196c1915f72 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -70,6 +70,9 @@ PyTypeObject KX_SCA_DynamicActuator::Type = { }; PyMethodDef KX_SCA_DynamicActuator::Methods[] = { + // ---> deprecated + KX_PYMETHODTABLE(KX_SCA_DynamicActuator, setOperation), + KX_PYMETHODTABLE(KX_SCA_DynamicActuator, getOperation), {NULL,NULL} //Sentinel }; @@ -79,6 +82,42 @@ PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = { { NULL } //Sentinel }; + +/* 1. setOperation */ +KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, setOperation, +"setOperation(operation?)\n" +"\t - operation? : type of dynamic operation\n" +"\t 0 = restore dynamics\n" +"\t 1 = disable dynamics\n" +"\t 2 = enable rigid body\n" +"\t 3 = disable rigid body\n" +"Change the dynamic status of the parent object.\n") +{ + ShowDeprecationWarning("setOperation()", "the mode property"); + int dyn_operation; + + if (!PyArg_ParseTuple(args, "i:setOperation", &dyn_operation)) + { + return NULL; + } + if (dyn_operation <0 || dyn_operation>3) { + PyErr_SetString(PyExc_IndexError, "Dynamic Actuator's setOperation() range must be between 0 and 3"); + return NULL; + } + m_dyn_operation= dyn_operation; + Py_RETURN_NONE; +} + +KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation, +"getOperation() -> integer\n" +"Returns the operation type of this actuator.\n" +) +{ + ShowDeprecationWarning("getOperation()", "the mode property"); + return PyLong_FromSsize_t((long)m_dyn_operation); +} + + /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h index 58b28654eca..8b598c9ecfa 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h @@ -71,6 +71,11 @@ class KX_SCA_DynamicActuator : public SCA_IActuator KX_DYN_DISABLE_RIGID_BODY, KX_DYN_SET_MASS, }; + + /* 1. setOperation */ + KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,setOperation); + KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,getOperation); + }; #endif diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index e85b8a32798..0819ad99633 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -74,6 +74,9 @@ PyTypeObject KX_SCA_ReplaceMeshActuator::Type = { PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = { KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh), + // Deprecated -----> + {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, (const char *)SetMesh_doc}, + KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh), {NULL,NULL} //Sentinel }; @@ -105,6 +108,37 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT return PY_SET_ATTR_SUCCESS; } +/* 1. setMesh */ +const char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = + "setMesh(name)\n" + "\t- name: string or None\n" + "\tSet the mesh that will be substituted for the current one.\n"; + +PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* value) +{ + ShowDeprecationWarning("setMesh()", "the mesh property"); + RAS_MeshObject* new_mesh; + + if (!ConvertPythonToMesh(value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator")) + return NULL; + + m_mesh = new_mesh; + Py_RETURN_NONE; +} + +KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh, +"getMesh() -> string\n" +"Returns the name of the mesh to be substituted.\n" +) +{ + ShowDeprecationWarning("getMesh()", "the mesh property"); + if (!m_mesh) + Py_RETURN_NONE; + + return PyUnicode_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr())); +} + + KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh, "instantReplaceMesh() : immediately replace mesh without delay\n") { diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index e5482c29aa7..ae2c0d2d6ce 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -50,8 +50,8 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator // mesh reference (mesh to replace) RAS_MeshObject* m_mesh; SCA_IScene* m_scene; - bool m_use_gfx; bool m_use_phys; + bool m_use_gfx; public: KX_SCA_ReplaceMeshActuator( @@ -74,13 +74,12 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator void InstantReplaceMesh(); - /* --------------------------------------------------------------------- */ - /* Python interface ---------------------------------------------------- */ - /* --------------------------------------------------------------------- */ - static PyObject* pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + /* 1. setMesh */ + KX_PYMETHOD_DOC_O(KX_SCA_ReplaceMeshActuator,SetMesh); + KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,getMesh); KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,instantReplaceMesh); }; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 3483496c3a6..5c19911fe58 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1615,10 +1615,7 @@ PyTypeObject KX_Scene::Type = { 0, 0, py_base_repr, - 0, - &Sequence, - &Mapping, - 0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 0,0,0,0,0,0,0, Methods, @@ -1630,117 +1627,13 @@ PyTypeObject KX_Scene::Type = { }; PyMethodDef KX_Scene::Methods[] = { + KX_PYMETHODTABLE_NOARGS(KX_Scene, getLightList), + KX_PYMETHODTABLE_NOARGS(KX_Scene, getObjectList), + KX_PYMETHODTABLE_NOARGS(KX_Scene, getName), KX_PYMETHODTABLE(KX_Scene, addObject), - /* dict style access */ - KX_PYMETHODTABLE(KX_Scene, get), - {NULL,NULL} //Sentinel }; -static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) -{ - KX_Scene* self= static_cast<KX_Scene*>BGE_PROXY_REF(self_v); - const char *attr_str= _PyUnicode_AsString(item); - PyObject* pyconvert; - - if (self==NULL) { - PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, "BGE_PROXY_ERROR_MSG); - return NULL; - } - - if (self->m_attr_dict && (pyconvert=PyDict_GetItem(self->m_attr_dict, item))) { - - if (attr_str) - PyErr_Clear(); - Py_INCREF(pyconvert); - return pyconvert; - } - else { - if(attr_str) PyErr_Format(PyExc_KeyError, "value = scene[key]: KX_Scene, key \"%s\" does not exist", attr_str); - else PyErr_SetString(PyExc_KeyError, "value = scene[key]: KX_Scene, key does not exist"); - return NULL; - } - -} - -static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) -{ - KX_Scene* self= static_cast<KX_Scene*>BGE_PROXY_REF(self_v); - const char *attr_str= _PyUnicode_AsString(key); - if(attr_str==NULL) - PyErr_Clear(); - - if (self==NULL) { - PyErr_SetString(PyExc_SystemError, "scene[key] = value: KX_Scene, "BGE_PROXY_ERROR_MSG); - return -1; - } - - if (val==NULL) { /* del ob["key"] */ - int del= 0; - - if(self->m_attr_dict) - del |= (PyDict_DelItem(self->m_attr_dict, key)==0) ? 1:0; - - if (del==0) { - if(attr_str) PyErr_Format(PyExc_KeyError, "scene[key] = value: KX_Scene, key \"%s\" could not be set", attr_str); - else PyErr_SetString(PyExc_KeyError, "del scene[key]: KX_Scene, key could not be deleted"); - return -1; - } - else if (self->m_attr_dict) { - PyErr_Clear(); /* PyDict_DelItem sets an error when it fails */ - } - } - else { /* ob["key"] = value */ - int set = 0; - - if (self->m_attr_dict==NULL) /* lazy init */ - self->m_attr_dict= PyDict_New(); - - - if(PyDict_SetItem(self->m_attr_dict, key, val)==0) - set= 1; - else - PyErr_SetString(PyExc_KeyError, "scene[key] = value: KX_Scene, key not be added to internal dictionary"); - - if(set==0) - return -1; /* pythons error value */ - - } - - return 0; /* success */ -} - -static int Seq_Contains(PyObject *self_v, PyObject *value) -{ - KX_Scene* self= static_cast<KX_Scene*>BGE_PROXY_REF(self_v); - - if (self==NULL) { - PyErr_SetString(PyExc_SystemError, "val in scene: KX_Scene, "BGE_PROXY_ERROR_MSG); - return -1; - } - - if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value)) - return 1; - - return 0; -} - -PyMappingMethods KX_Scene::Mapping = { - (lenfunc)NULL , /*inquiry mp_length */ - (binaryfunc)Map_GetItem, /*binaryfunc mp_subscript */ - (objobjargproc)Map_SetItem, /*objobjargproc mp_ass_subscript */ -}; - -PySequenceMethods KX_Scene::Sequence = { - NULL, /* Cant set the len otherwise it can evaluate as false */ - NULL, /* sq_concat */ - NULL, /* sq_repeat */ - NULL, /* sq_item */ - NULL, /* sq_slice */ - NULL, /* sq_ass_item */ - NULL, /* sq_ass_slice */ - (objobjproc)Seq_Contains, /* sq_contains */ -}; PyObject* KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { @@ -1821,6 +1714,33 @@ PyAttributeDef KX_Scene::Attributes[] = { { NULL } //Sentinel }; +KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getLightList, +"getLightList() -> list [KX_Light]\n" +"Returns a list of all lights in the scene.\n" +) +{ + ShowDeprecationWarning("getLightList()", "the lights property"); + return m_lightlist->GetProxy(); +} + +KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getObjectList, +"getObjectList() -> list [KX_GameObject]\n" +"Returns a list of all game objects in the scene.\n" +) +{ + ShowDeprecationWarning("getObjectList()", "the objects property"); + return m_objectlist->GetProxy(); +} + +KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getName, +"getName() -> string\n" +"Returns the name of the scene.\n" +) +{ + ShowDeprecationWarning("getName()", "the name property"); + return PyUnicode_FromString(GetName()); +} + KX_PYMETHODDEF_DOC(KX_Scene, addObject, "addObject(object, other, time=0)\n" "Returns the added object.\n") @@ -1845,22 +1765,3 @@ KX_PYMETHODDEF_DOC(KX_Scene, addObject, replica->Release(); return replica->GetProxy(); } - -/* Matches python dict.get(key, [default]) */ -KX_PYMETHODDEF_DOC(KX_Scene, get, "") -{ - PyObject *key; - PyObject* def = Py_None; - PyObject* ret; - - if (!PyArg_ParseTuple(args, "O|O:get", &key, &def)) - return NULL; - - if (m_attr_dict && (ret=PyDict_GetItem(m_attr_dict, key))) { - Py_INCREF(ret); - return ret; - } - - Py_INCREF(def); - return def; -} diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 3e0dc303d72..f48e9520f53 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -90,7 +90,6 @@ struct KX_ClientObjectInfo; class KX_Scene : public PyObjectPlus, public SCA_IScene { Py_Header; - PyObject* m_attr_dict; struct CullingInfo { int m_layer; @@ -263,10 +262,15 @@ protected: double m_suspendedtime; double m_suspendeddelta; + + /** + * This stores anything from python + */ + PyObject* m_attr_dict; struct Scene* m_blenderScene; -public: +public: KX_Scene(class SCA_IInputDevice* keyboarddevice, class SCA_IInputDevice* mousedevice, class NG_NetworkDeviceInterface* ndi, @@ -517,12 +521,23 @@ public: */ void SetNodeTree(SG_Tree* root); - /* --------------------------------------------------------------------- */ - /* Python interface ---------------------------------------------------- */ - /* --------------------------------------------------------------------- */ - + KX_PYMETHOD_DOC_NOARGS(KX_Scene, getLightList); + KX_PYMETHOD_DOC_NOARGS(KX_Scene, getObjectList); + KX_PYMETHOD_DOC_NOARGS(KX_Scene, getName); KX_PYMETHOD_DOC(KX_Scene, addObject); - KX_PYMETHOD_DOC(KX_Scene, get); +/* + KX_PYMETHOD_DOC(KX_Scene, getActiveCamera); + KX_PYMETHOD_DOC(KX_Scene, getActiveCamera); + KX_PYMETHOD_DOC(KX_Scene, findCamera); + + KX_PYMETHOD_DOC(KX_Scene, getGravity); + + KX_PYMETHOD_DOC(KX_Scene, setActivityCulling); + KX_PYMETHOD_DOC(KX_Scene, setActivityCullingRadius); + + KX_PYMETHOD_DOC(KX_Scene, setSceneViewport); + KX_PYMETHOD_DOC(KX_Scene, setSceneViewport); + */ /* attributes */ static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); @@ -534,11 +549,7 @@ public: static int pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); virtual PyObject* py_repr(void) { return PyUnicode_FromString(GetName().ReadPtr()); } - - /* getitem/setitem */ - static PyMappingMethods Mapping; - static PySequenceMethods Sequence; - + /** * Sets the time the scene was suspended */ diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index ea1be7bca6c..a0b7664d63a 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -245,6 +245,14 @@ PyTypeObject KX_SceneActuator::Type = { PyMethodDef KX_SceneActuator::Methods[] = { + //Deprecated functions ------> + {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (const char *)SetUseRestart_doc}, + {"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (const char *)SetScene_doc}, + {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_O, (const char *)SetCamera_doc}, + {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_NOARGS, (const char *)GetUseRestart_doc}, + {"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_NOARGS, (const char *)GetScene_doc}, + {"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_NOARGS, (const char *)GetCamera_doc}, + //<----- Deprecated {NULL,NULL} //Sentinel }; @@ -287,4 +295,117 @@ int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_ return PY_SET_ATTR_SUCCESS; } + +/* 2. setUseRestart--------------------------------------------------------- */ +const char KX_SceneActuator::SetUseRestart_doc[] = +"setUseRestart(flag)\n" +"\t- flag: 0 or 1.\n" +"\tSet flag to 1 to restart the scene.\n" ; +PyObject* KX_SceneActuator::PySetUseRestart(PyObject* args) +{ + ShowDeprecationWarning("setUseRestart()", "the useRestart property"); + int boolArg; + + if (!PyArg_ParseTuple(args, "i:setUseRestart", &boolArg)) + { + return NULL; + } + + m_restart = boolArg != 0; + + Py_RETURN_NONE; +} + + + +/* 3. getUseRestart: */ +const char KX_SceneActuator::GetUseRestart_doc[] = +"getUseRestart()\n" +"\tReturn whether the scene will be restarted.\n" ; +PyObject* KX_SceneActuator::PyGetUseRestart() +{ + ShowDeprecationWarning("getUseRestart()", "the useRestart property"); + return PyLong_FromSsize_t(!(m_restart == 0)); +} + + + +/* 4. set scene------------------------------------------------------------- */ +const char KX_SceneActuator::SetScene_doc[] = +"setScene(scene)\n" +"\t- scene: string\n" +"\tSet the name of scene the actuator will switch to.\n" ; +PyObject* KX_SceneActuator::PySetScene(PyObject* args) +{ + ShowDeprecationWarning("setScene()", "the scene property"); + /* one argument: a scene, ignore the rest */ + char *scene_name; + + if(!PyArg_ParseTuple(args, "s:setScene", &scene_name)) + { + return NULL; + } + + /* Scene switch is done by name. */ + m_nextSceneName = scene_name; + + Py_RETURN_NONE; +} + + + +/* 5. getScene: */ +const char KX_SceneActuator::GetScene_doc[] = +"getScene()\n" +"\tReturn the name of the scene the actuator wants to switch to.\n" ; +PyObject* KX_SceneActuator::PyGetScene() +{ + ShowDeprecationWarning("getScene()", "the scene property"); + return PyUnicode_FromString(m_nextSceneName); +} + + + +/* 6. set camera------------------------------------------------------------ */ +const char KX_SceneActuator::SetCamera_doc[] = +"setCamera(camera)\n" +"\t- camera: string\n" +"\tSet the camera to switch to.\n" ; +PyObject* KX_SceneActuator::PySetCamera(PyObject* value) +{ + ShowDeprecationWarning("setCamera()", "the camera property"); + KX_Camera *camOb; + + if (!ConvertPythonToCamera(value, &camOb, true, "actu.setCamera(value): KX_SceneActuator")) + return NULL; + + if (m_camera) + m_camera->UnregisterActuator(this); + + if(camOb==NULL) { + m_camera= NULL; + } + else { + m_camera = camOb; + m_camera->RegisterActuator(this); + } + Py_RETURN_NONE; +} + + + +/* 7. getCamera: */ +const char KX_SceneActuator::GetCamera_doc[] = +"getCamera()\n" +"\tReturn the name of the camera to switch to.\n" ; +PyObject* KX_SceneActuator::PyGetCamera() +{ + ShowDeprecationWarning("getCamera()", "the camera property"); + if (m_camera) { + return PyUnicode_FromString(m_camera->GetName()); + } + else { + Py_RETURN_NONE; + } +} /* eof */ diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index e979a8ce559..86de3395d1e 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -90,6 +90,22 @@ class KX_SceneActuator : public SCA_IActuator /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + + /* 1. set */ + /* Removed */ + + /* 2. setUseRestart: */ + KX_PYMETHOD_DOC_VARARGS(KX_SceneActuator,SetUseRestart); + /* 3. getUseRestart: */ + KX_PYMETHOD_DOC_NOARGS(KX_SceneActuator,GetUseRestart); + /* 4. setScene: */ + KX_PYMETHOD_DOC_VARARGS(KX_SceneActuator,SetScene); + /* 5. getScene: */ + KX_PYMETHOD_DOC_NOARGS(KX_SceneActuator,GetScene); + /* 6. setCamera: */ + KX_PYMETHOD_DOC_O(KX_SceneActuator,SetCamera); + /* 7. getCamera: */ + KX_PYMETHOD_DOC_NOARGS(KX_SceneActuator,GetCamera); static PyObject* pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index e2b4022a312..024c51cabc1 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -296,6 +296,17 @@ PyTypeObject KX_SoundActuator::Type = { }; PyMethodDef KX_SoundActuator::Methods[] = { + // Deprecated -----> + {"setGain",(PyCFunction) KX_SoundActuator::sPySetGain,METH_VARARGS,NULL}, + {"getGain",(PyCFunction) KX_SoundActuator::sPyGetGain,METH_NOARGS,NULL}, + {"setPitch",(PyCFunction) KX_SoundActuator::sPySetPitch,METH_VARARGS,NULL}, + {"getPitch",(PyCFunction) KX_SoundActuator::sPyGetPitch,METH_NOARGS,NULL}, + {"setRollOffFactor",(PyCFunction) KX_SoundActuator::sPySetRollOffFactor,METH_VARARGS,NULL}, + {"getRollOffFactor",(PyCFunction) KX_SoundActuator::sPyGetRollOffFactor,METH_NOARGS,NULL}, + {"setType",(PyCFunction) KX_SoundActuator::sPySetType,METH_VARARGS,NULL}, + {"getType",(PyCFunction) KX_SoundActuator::sPyGetType,METH_NOARGS,NULL}, + // <----- + KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, startSound), KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, pauseSound), KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, stopSound), @@ -416,3 +427,109 @@ int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATT return PY_SET_ATTR_SUCCESS; } + +PyObject* KX_SoundActuator::PySetGain(PyObject* args) +{ + ShowDeprecationWarning("setGain()", "the volume property"); + float gain = 1.0; + if (!PyArg_ParseTuple(args, "f:setGain", &gain)) + return NULL; + + m_volume = gain; + if(m_handle) + AUD_setSoundVolume(m_handle, gain); + + Py_RETURN_NONE; +} + + + +PyObject* KX_SoundActuator::PyGetGain() +{ + ShowDeprecationWarning("getGain()", "the volume property"); + float gain = m_volume; + PyObject* result = PyFloat_FromDouble(gain); + + return result; +} + + + +PyObject* KX_SoundActuator::PySetPitch(PyObject* args) +{ + ShowDeprecationWarning("setPitch()", "the pitch property"); + float pitch = 1.0; + if (!PyArg_ParseTuple(args, "f:setPitch", &pitch)) + return NULL; + + m_pitch = pitch; + if(m_handle) + AUD_setSoundPitch(m_handle, pitch); + + Py_RETURN_NONE; +} + + + +PyObject* KX_SoundActuator::PyGetPitch() +{ + ShowDeprecationWarning("getPitch()", "the pitch property"); + float pitch = m_pitch; + PyObject* result = PyFloat_FromDouble(pitch); + + return result; +} + + + +PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* args) +{ + ShowDeprecationWarning("setRollOffFactor()", "the rollOffFactor property"); + float rollofffactor = 1.0; + if (!PyArg_ParseTuple(args, "f:setRollOffFactor", &rollofffactor)) + return NULL; + + m_3d.rolloff_factor = rollofffactor; + if(m_handle) + AUD_set3DSourceSetting(m_handle, AUD_3DSS_ROLLOFF_FACTOR, rollofffactor); + + Py_RETURN_NONE; +} + + + +PyObject* KX_SoundActuator::PyGetRollOffFactor() +{ + ShowDeprecationWarning("getRollOffFactor()", "the rollOffFactor property"); + float rollofffactor = m_3d.rolloff_factor; + PyObject* result = PyFloat_FromDouble(rollofffactor); + + return result; +} + + + +PyObject* KX_SoundActuator::PySetType(PyObject* args) +{ + int typeArg; + ShowDeprecationWarning("setType()", "the mode property"); + + if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) { + return NULL; + } + + if ( (typeArg > KX_SOUNDACT_NODEF) + && (typeArg < KX_SOUNDACT_MAX) ) { + m_type = (KX_SOUNDACT_TYPE) typeArg; + } + + Py_RETURN_NONE; +} + +PyObject* KX_SoundActuator::PyGetType() +{ + ShowDeprecationWarning("getType()", "the mode property"); + return PyLong_FromSsize_t(m_type); +} +// <----- + diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 43198f1a253..bc0293ed2b4 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -110,6 +110,18 @@ public: static PyObject* pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + + // Deprecated -----> + KX_PYMETHOD_VARARGS(KX_SoundActuator,SetGain); + KX_PYMETHOD_NOARGS(KX_SoundActuator,GetGain); + KX_PYMETHOD_VARARGS(KX_SoundActuator,SetPitch); + KX_PYMETHOD_NOARGS(KX_SoundActuator,GetPitch); + KX_PYMETHOD_VARARGS(KX_SoundActuator,SetRollOffFactor); + KX_PYMETHOD_NOARGS(KX_SoundActuator,GetRollOffFactor); + KX_PYMETHOD_VARARGS(KX_SoundActuator,SetType); + KX_PYMETHOD_NOARGS(KX_SoundActuator,GetType); + // <----- + }; #endif //__KX_SOUNDACTUATOR diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index 4159e9c373d..09d95612cbb 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -159,6 +159,12 @@ PyTypeObject KX_StateActuator::Type = { }; PyMethodDef KX_StateActuator::Methods[] = { + // deprecated --> + {"setOperation", (PyCFunction) KX_StateActuator::sPySetOperation, + METH_VARARGS, (const char *)SetOperation_doc}, + {"setMask", (PyCFunction) KX_StateActuator::sPySetMask, + METH_VARARGS, (const char *)SetMask_doc}, + // <-- {NULL,NULL} //Sentinel }; @@ -167,3 +173,52 @@ PyAttributeDef KX_StateActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("mask",0,0x3FFFFFFF,false,KX_StateActuator,m_mask), { NULL } //Sentinel }; + + +/* set operation ---------------------------------------------------------- */ +const char +KX_StateActuator::SetOperation_doc[] = +"setOperation(op)\n" +"\t - op : bit operation (0=Copy, 1=Set, 2=Clear, 3=Negate)" +"\tSet the type of bit operation to be applied on object state mask.\n" +"\tUse setMask() to specify the bits that will be modified.\n"; +PyObject* + +KX_StateActuator::PySetOperation(PyObject* args) { + ShowDeprecationWarning("setOperation()", "the operation property"); + int oper; + + if(!PyArg_ParseTuple(args, "i:setOperation", &oper)) { + return NULL; + } + + m_operation = oper; + + Py_RETURN_NONE; +} + +/* set mask ---------------------------------------------------------- */ +const char +KX_StateActuator::SetMask_doc[] = +"setMask(mask)\n" +"\t - mask : bits that will be modified" +"\tSet the value that defines the bits that will be modified by the operation.\n" +"\tThe bits that are 1 in the value will be updated in the object state,\n" +"\tthe bits that are 0 are will be left unmodified expect for the Copy operation\n" +"\twhich copies the value to the object state.\n"; +PyObject* + +KX_StateActuator::PySetMask(PyObject* args) { + ShowDeprecationWarning("setMask()", "the mask property"); + int mask; + + if(!PyArg_ParseTuple(args, "i:setMask", &mask)) { + return NULL; + } + + m_mask = mask; + + Py_RETURN_NONE; +} + + diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h index 4cf84f74287..ce86c4b44fe 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.h +++ b/source/gameengine/Ketsji/KX_StateActuator.h @@ -88,7 +88,9 @@ class KX_StateActuator : public SCA_IActuator /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + //KX_PYMETHOD_DOC + KX_PYMETHOD_DOC_VARARGS(KX_StateActuator,SetOperation); + KX_PYMETHOD_DOC_VARARGS(KX_StateActuator,SetMask); }; #endif diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index cde67787e2f..bf8469f1ec9 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -101,7 +101,8 @@ KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj :SCA_ISensor(gameobj,eventmgr), m_touchedpropname(touchedpropname), m_bFindMaterial(bFindMaterial), -m_bTouchPulse(bTouchPulse) +m_bTouchPulse(bTouchPulse), +m_eventmgr(eventmgr) /*m_sumoObj(sumoObj),*/ { // KX_TouchEventManager* touchmgr = (KX_TouchEventManager*) eventmgr; @@ -315,6 +316,16 @@ PyTypeObject KX_TouchSensor::Type = { }; PyMethodDef KX_TouchSensor::Methods[] = { + //Deprecated -----> + {"setProperty", + (PyCFunction) KX_TouchSensor::sPySetProperty, METH_O, (const char *)SetProperty_doc}, + {"getProperty", + (PyCFunction) KX_TouchSensor::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + {"getHitObject", + (PyCFunction) KX_TouchSensor::sPyGetHitObject, METH_NOARGS, (const char *)GetHitObject_doc}, + {"getHitObjectList", + (PyCFunction) KX_TouchSensor::sPyGetHitObjectList, METH_NOARGS, (const char *)GetHitObjectList_doc}, + //<----- {NULL,NULL} //Sentinel }; @@ -329,6 +340,101 @@ PyAttributeDef KX_TouchSensor::Attributes[] = { /* Python API */ +/* 1. setProperty */ +const char KX_TouchSensor::SetProperty_doc[] = +"setProperty(name)\n" +"\t- name: string\n" +"\tSet the property or material to collide with. Use\n" +"\tsetTouchMaterial() to switch between properties and\n" +"\tmaterials."; +PyObject* KX_TouchSensor::PySetProperty(PyObject* value) +{ + ShowDeprecationWarning("setProperty()", "the propName property"); + char *nameArg= _PyUnicode_AsString(value); + if (nameArg==NULL) { + PyErr_SetString(PyExc_ValueError, "expected a "); + return NULL; + } + + m_touchedpropname = nameArg; + Py_RETURN_NONE; +} +/* 2. getProperty */ +const char KX_TouchSensor::GetProperty_doc[] = +"getProperty(name)\n" +"\tReturns the property or material to collide with. Use\n" +"\tgetTouchMaterial() to find out whether this sensor\n" +"\tlooks for properties or materials."; +PyObject* KX_TouchSensor::PyGetProperty() { + ShowDeprecationWarning("getProperty()", "the propName property"); + + return PyUnicode_FromString(m_touchedpropname); +} + +const char KX_TouchSensor::GetHitObject_doc[] = +"getHitObject()\n" +; +PyObject* KX_TouchSensor::PyGetHitObject() +{ + ShowDeprecationWarning("getHitObject()", "the hitObject property"); + /* to do: do Py_IncRef if the object is already known in Python */ + /* otherwise, this leaks memory */ + if (m_hitObject) + { + return m_hitObject->GetProxy(); + } + Py_RETURN_NONE; +} + +const char KX_TouchSensor::GetHitObjectList_doc[] = +"getHitObjectList()\n" +"\tReturn a list of the objects this object collided with,\n" +"\tbut only those matching the property/material condition.\n"; +PyObject* KX_TouchSensor::PyGetHitObjectList() +{ + ShowDeprecationWarning("getHitObjectList()", "the hitObjectList property"); + /* to do: do Py_IncRef if the object is already known in Python */ + /* otherwise, this leaks memory */ /* Edit, this seems ok and not to leak memory - Campbell */ + return m_colliders->GetProxy(); +} + +/*getTouchMaterial and setTouchMaterial were never added to the api, +they can probably be removed with out anyone noticing*/ + +/* 5. getTouchMaterial */ +const char KX_TouchSensor::GetTouchMaterial_doc[] = +"getTouchMaterial()\n" +"\tReturns KX_TRUE if this sensor looks for a specific material,\n" +"\tKX_FALSE if it looks for a specific property.\n" ; +PyObject* KX_TouchSensor::PyGetTouchMaterial() +{ + ShowDeprecationWarning("getTouchMaterial()", "the useMaterial property"); + return PyLong_FromSsize_t(m_bFindMaterial); +} + +/* 6. setTouchMaterial */ +#if 0 +const char KX_TouchSensor::SetTouchMaterial_doc[] = +"setTouchMaterial(flag)\n" +"\t- flag: KX_TRUE or KX_FALSE.\n" +"\tSet flag to KX_TRUE to switch on positive pulse mode,\n" +"\tKX_FALSE to switch off positive pulse mode.\n" ; +PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject *value) +{ + ShowDeprecationWarning("setTouchMaterial()", "the useMaterial property"); + int pulseArg = PyLong_AsSsize_t(value); + + if(pulseArg ==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_ValueError, "expected a bool"); + return NULL; + } + + m_bFindMaterial = pulseArg != 0; + + Py_RETURN_NONE; +} +#endif + PyObject* KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_TouchSensor* self= static_cast<KX_TouchSensor*>(self_v); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index ad1830e05c9..6cbf5b15e3b 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -58,6 +58,7 @@ protected: STR_String m_touchedpropname; bool m_bFindMaterial; bool m_bTouchPulse; /* changes in the colliding objects trigger pulses */ + class SCA_EventManager* m_eventmgr; class PHY_IPhysicsController* m_physCtrl; @@ -119,6 +120,23 @@ public: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + + //Deprecated -----> + /* 1. setProperty */ + KX_PYMETHOD_DOC_O(KX_TouchSensor,SetProperty); + /* 2. getProperty */ + KX_PYMETHOD_DOC_NOARGS(KX_TouchSensor,GetProperty); + /* 3. getHitObject */ + KX_PYMETHOD_DOC_NOARGS(KX_TouchSensor,GetHitObject); + /* 4. getHitObject */ + KX_PYMETHOD_DOC_NOARGS(KX_TouchSensor,GetHitObjectList); + /* 5. getTouchMaterial */ + KX_PYMETHOD_DOC_NOARGS(KX_TouchSensor,GetTouchMaterial); +#if 0 + /* 6. setTouchMaterial */ + KX_PYMETHOD_DOC_O(KX_TouchSensor,SetTouchMaterial); +#endif + //<----- static PyObject* pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_object_hit_list(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index e6c2f86bbce..b5b7e9de444 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -453,6 +453,14 @@ PyTypeObject KX_TrackToActuator::Type = { }; PyMethodDef KX_TrackToActuator::Methods[] = { + // ---> deprecated + {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, (const char *)SetTime_doc}, + {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc}, + {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, (const char *)SetUse3D_doc}, + {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_NOARGS, (const char *)GetUse3D_doc}, + {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, + {NULL,NULL} //Sentinel }; @@ -492,4 +500,123 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT return PY_SET_ATTR_SUCCESS; } + +/* 1. setObject */ +const char KX_TrackToActuator::SetObject_doc[] = +"setObject(object)\n" +"\t- object: KX_GameObject, string or None\n" +"\tSet the object to track with the parent of this actuator.\n"; +PyObject* KX_TrackToActuator::PySetObject(PyObject* value) +{ + KX_GameObject *gameobj; + + ShowDeprecationWarning("setObject()", "the object property"); + + if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.setObject(value): KX_TrackToActuator")) + return NULL; // ConvertPythonToGameObject sets the error + + if (m_object != NULL) + m_object->UnregisterActuator(this); + + m_object = (SCA_IObject*)gameobj; + if (m_object) + m_object->RegisterActuator(this); + + Py_RETURN_NONE; +} + + + +/* 2. getObject */ +const char KX_TrackToActuator::GetObject_doc[] = +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" +"\tReturns the object to track with the parent of this actuator\n"; +PyObject* KX_TrackToActuator::PyGetObject(PyObject* args) +{ + int ret_name_only = 1; + + ShowDeprecationWarning("getObject()", "the object property"); + + if (!PyArg_ParseTuple(args, "|i:getObject", &ret_name_only)) + return NULL; + + if (!m_object) + Py_RETURN_NONE; + + if (ret_name_only) + return PyUnicode_FromString(m_object->GetName()); + else + return m_object->GetProxy(); +} + + + +/* 3. setTime */ +const char KX_TrackToActuator::SetTime_doc[] = +"setTime(time)\n" +"\t- time: integer\n" +"\tSet the time in frames with which to delay the tracking motion.\n"; +PyObject* KX_TrackToActuator::PySetTime(PyObject* args) +{ + ShowDeprecationWarning("setTime()", "the timer property"); + int timeArg; + + if (!PyArg_ParseTuple(args, "i:setTime", &timeArg)) + { + return NULL; + } + + m_time= timeArg; + + Py_RETURN_NONE; +} + + + +/* 4.getTime */ +const char KX_TrackToActuator::GetTime_doc[] = +"getTime()\n" +"\t- time: integer\n" +"\tReturn the time in frames with which the tracking motion is delayed.\n"; +PyObject* KX_TrackToActuator::PyGetTime() +{ + ShowDeprecationWarning("getTime()", "the timer property"); + return PyLong_FromSsize_t(m_time); +} + + + +/* 5. getUse3D */ +const char KX_TrackToActuator::GetUse3D_doc[] = +"getUse3D()\n" +"\tReturns 1 if the motion is allowed to extend in the z-direction.\n"; +PyObject* KX_TrackToActuator::PyGetUse3D() +{ + ShowDeprecationWarning("setTime()", "the use3D property"); + return PyLong_FromSsize_t(!(m_allow3D == 0)); +} + + + +/* 6. setUse3D */ +const char KX_TrackToActuator::SetUse3D_doc[] = +"setUse3D(value)\n" +"\t- value: 0 or 1\n" +"\tSet to 1 to allow the tracking motion to extend in the z-direction,\n" +"\tset to 0 to lock the tracking motion to the x-y plane.\n"; +PyObject* KX_TrackToActuator::PySetUse3D(PyObject* args) +{ + ShowDeprecationWarning("setTime()", "the use3D property"); + int boolArg; + + if (!PyArg_ParseTuple(args, "i:setUse3D", &boolArg)) { + return NULL; + } + + m_allow3D = !(boolArg == 0); + + Py_RETURN_NONE; +} + /* eof */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index bbfc1d17576..801e695bb9b 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -74,6 +74,19 @@ class KX_TrackToActuator : public SCA_IActuator /* These are used to get and set m_ob */ static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + + /* 1. setObject */ + KX_PYMETHOD_DOC_O(KX_TrackToActuator,SetObject); + /* 2. getObject */ + KX_PYMETHOD_DOC_VARARGS(KX_TrackToActuator,GetObject); + /* 3. setTime */ + KX_PYMETHOD_DOC_VARARGS(KX_TrackToActuator,SetTime); + /* 4. getTime */ + KX_PYMETHOD_DOC_NOARGS(KX_TrackToActuator,GetTime); + /* 5. getUse3D */ + KX_PYMETHOD_DOC_NOARGS(KX_TrackToActuator,GetUse3D); + /* 6. setUse3D */ + KX_PYMETHOD_DOC_VARARGS(KX_TrackToActuator,SetUse3D); }; /* end of class KX_TrackToActuator : public KX_EditObjectActuator */ diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 184e127209f..97c893c6caa 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -113,6 +113,10 @@ PyTypeObject KX_VisibilityActuator::Type = { }; PyMethodDef KX_VisibilityActuator::Methods[] = { + // Deprecated -----> + {"set", (PyCFunction) KX_VisibilityActuator::sPySetVisible, METH_VARARGS, + (const char *) SetVisible_doc}, + // <----- {NULL,NULL} //Sentinel }; @@ -122,3 +126,26 @@ PyAttributeDef KX_VisibilityActuator::Attributes[] = { KX_PYATTRIBUTE_BOOL_RW("useRecursion", KX_VisibilityActuator, m_recursive), { NULL } //Sentinel }; + +/* set visibility ---------------------------------------------------------- */ +const char +KX_VisibilityActuator::SetVisible_doc[] = +"setVisible(visible?)\n" +"\t - visible? : Make the object visible? (KX_TRUE, KX_FALSE)" +"\tSet the properties of the actuator.\n"; +PyObject* + +KX_VisibilityActuator::PySetVisible(PyObject* args) { + int vis; + ShowDeprecationWarning("SetVisible()", "the visible property"); + + if(!PyArg_ParseTuple(args, "i:setVisible", &vis)) { + return NULL; + } + + m_visible = PyArgToBool(vis); + + Py_RETURN_NONE; +} + + diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h index e75551644a4..3ad50c6cea2 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.h +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h @@ -67,6 +67,11 @@ class KX_VisibilityActuator : public SCA_IActuator /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + // Deprecated -----> + KX_PYMETHOD_DOC_VARARGS(KX_VisibilityActuator,SetVisible); + // <----- + + }; #endif diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 5f38020780b..d3b67cfdb11 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -29,8 +29,12 @@ if env['WITH_BF_SDL']: else: defs.append('DISABLE_SDL') +cxxflags = [] if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') if env['BF_DEBUG']: defs.append('_DEBUG') # for Python -env.BlenderLib ( 'bf_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320,45], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'bf_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320, 60], cxx_compileflags = cxxflags ) diff --git a/source/gameengine/Network/CMakeLists.txt b/source/gameengine/Network/CMakeLists.txt index 1e467a7d08d..933f0550d0b 100644 --- a/source/gameengine/Network/CMakeLists.txt +++ b/source/gameengine/Network/CMakeLists.txt @@ -27,10 +27,10 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../source/kernel/gen_system - ../../../intern/string - ../../../intern/moto/include + . + ../../../source/kernel/gen_system + ../../../intern/string + ../../../intern/moto/include ) BLENDERLIB(bf_ngnetwork "${SRC}" "${INC}") diff --git a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt index 18e3d8ef496..0b958920dc5 100644 --- a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt +++ b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt @@ -27,10 +27,10 @@ SET(SRC NG_LoopBackNetworkDeviceInterface.cpp) SET(INC - . - ../../../../source/kernel/gen_system - ../../../../intern/string - ../../../../source/gameengine/Network + . + ../../../../source/kernel/gen_system + ../../../../intern/string + ../../../../source/gameengine/Network ) BLENDERLIB(bf_loopbacknetwork "${SRC}" "${INC}") diff --git a/source/gameengine/Network/LoopBackNetwork/SConscript b/source/gameengine/Network/LoopBackNetwork/SConscript index dd23e1327eb..be6545b4fd6 100644 --- a/source/gameengine/Network/LoopBackNetwork/SConscript +++ b/source/gameengine/Network/LoopBackNetwork/SConscript @@ -5,4 +5,4 @@ sources = 'NG_LoopBackNetworkDeviceInterface.cpp' incs = '. #source/kernel/gen_system #intern/string #source/gameengine/Network' -env.BlenderLib ( 'bf_loopbacknetwork', Split(sources), Split(incs), defines=[],libtype=['core','player'], priority=[400,135] ) +env.BlenderLib ( 'bf_loopbacknetwork', Split(sources), Split(incs), defines=[],libtype=['core', 'player'], priority=[400, 155] ) diff --git a/source/gameengine/Network/SConscript b/source/gameengine/Network/SConscript index 3883dc71c9c..804851973af 100644 --- a/source/gameengine/Network/SConscript +++ b/source/gameengine/Network/SConscript @@ -5,4 +5,4 @@ sources = env.Glob('*.cpp') #'NG_NetworkMessage.cpp NG_NetworkObject.cpp NG_Netw incs = '. #source/kernel/gen_system #intern/string #intern/moto/include' -env.BlenderLib ( 'bf_ngnetwork', sources, Split(incs), [], libtype=['core','player'], priority=[400,130] ) +env.BlenderLib ( 'bf_ngnetwork', sources, Split(incs), [], libtype=['core', 'player'], priority=[400, 150] ) diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index da885122a4f..7b7fb508ebd 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -27,23 +27,23 @@ SET(SRC CcdPhysicsEnvironment.cpp CcdPhysicsController.cpp CcdGraphicController.cpp) SET(INC - . - ../common - ../../../../extern/bullet2/src - ../../../../extern/glew/include - ../../../../intern/moto/include - ../../../../intern/guardedalloc - ../../../kernel/gen_system - ../../../../intern/string - ../../Rasterizer - ../../Ketsji - ../../Expressions - ../../GameLogic - ../../SceneGraph - ../../../../source/blender/makesdna - ../../../../source/blender/blenlib - ../../../../source/blender/blenkernel - ${PYTHON_INC} + . + ../common + ../../../../extern/bullet2/src + ../../../../extern/glew/include + ../../../../intern/moto/include + ../../../../intern/guardedalloc + ../../../kernel/gen_system + ../../../../intern/string + ../../Rasterizer + ../../Ketsji + ../../Expressions + ../../GameLogic + ../../SceneGraph + ../../../../source/blender/makesdna + ../../../../source/blender/blenlib + ../../../../source/blender/blenkernel + ${PYTHON_INC} ) BLENDERLIB(bf_bullet "${SRC}" "${INC}") diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index df8dc3560ac..20e830c9dc3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1073,7 +1073,7 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque //workaround for incompatibility between 'DYNAMIC' game object, and angular factor //a DYNAMIC object has some inconsistency: it has no angular effect due to collisions, but still has torque const btVector3& angFac = body->getAngularFactor(); - btVector3 tmpFac(1,1,1); + btVector3 tmpFac(0,0,1); body->setAngularFactor(tmpFac); body->applyTorque(torque); body->setAngularFactor(angFac); @@ -1829,6 +1829,8 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA } for(mf= mface, i=0; i < numpolys; mf++, i++) { + unsigned int *fv = &mf->v1; + if(mf->v4) { fv_pt= quad_verts; *poly_index_pt++ = *poly_index_pt++ = index[i]; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index bf28802870a..bc7ccacc39b 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -327,6 +327,7 @@ CcdPhysicsEnvironment::CcdPhysicsEnvironment(bool useDbvtCulling,btDispatcher* d :m_cullingCache(NULL), m_cullingTree(NULL), m_numIterations(10), +m_scalingPropagated(false), m_numTimeSubSteps(1), m_ccdMode(0), m_solverType(-1), @@ -335,8 +336,7 @@ m_enableSatCollisionDetection(false), m_solver(NULL), m_ownPairCache(NULL), m_filterCallback(NULL), -m_ownDispatcher(NULL), -m_scalingPropagated(false) +m_ownDispatcher(NULL) { for (int i=0;i<PHY_NUM_RESPONSE;i++) diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index 49f2af1b001..44b75402630 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -21,4 +21,10 @@ incs += ' #intern/guardedalloc' incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_PYTHON_INC'] -env.BlenderLib ( 'bf_bullet', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350,50], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib ( 'bf_bullet', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350,80], cxx_compileflags=cxxflags ) diff --git a/source/gameengine/Physics/Dummy/CMakeLists.txt b/source/gameengine/Physics/Dummy/CMakeLists.txt index d613bf8fd14..4bd29e7779b 100644 --- a/source/gameengine/Physics/Dummy/CMakeLists.txt +++ b/source/gameengine/Physics/Dummy/CMakeLists.txt @@ -27,8 +27,8 @@ SET(SRC DummyPhysicsEnvironment.cpp) SET(INC - . - ../common + . + ../common ) BLENDERLIB(bf_dummy "${SRC}" "${INC}") diff --git a/source/gameengine/Physics/Dummy/SConscript b/source/gameengine/Physics/Dummy/SConscript index dc76e8046a0..93d6ac36446 100644 --- a/source/gameengine/Physics/Dummy/SConscript +++ b/source/gameengine/Physics/Dummy/SConscript @@ -5,4 +5,4 @@ sources = 'DummyPhysicsEnvironment.cpp' incs = '. ../common' -env.BlenderLib ( 'bf_dummy', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350,60] ) +env.BlenderLib ( 'bf_dummy', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350,95] ) diff --git a/source/gameengine/Physics/common/CMakeLists.txt b/source/gameengine/Physics/common/CMakeLists.txt index a34bd19d400..41b2687fe38 100644 --- a/source/gameengine/Physics/common/CMakeLists.txt +++ b/source/gameengine/Physics/common/CMakeLists.txt @@ -27,9 +27,9 @@ SET(SRC PHY_IMotionState.cpp PHY_IController.cpp PHY_IPhysicsController.cpp PHY_IGraphicController.cpp PHY_IPhysicsEnvironment.cpp PHY_IVehicle.cpp) SET(INC - . - ../Dummy - ../../../intern/moto/include + . + ../Dummy + ../../../intern/moto/include ) BLENDERLIB(bf_common "${SRC}" "${INC}") diff --git a/source/gameengine/Physics/common/SConscript b/source/gameengine/Physics/common/SConscript index 719c028ee8f..447b0ec1bbb 100644 --- a/source/gameengine/Physics/common/SConscript +++ b/source/gameengine/Physics/common/SConscript @@ -5,4 +5,10 @@ sources = 'PHY_IMotionState.cpp PHY_IController.cpp PHY_IPhysicsController.cpp P incs = '. ../Dummy #intern/moto/include' -env.BlenderLib ( 'bf_physics_common', Split(sources), Split(incs), [], libtype=['core','player'], priority=[360,55], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib ( 'bf_common', Split(sources), Split(incs), [], libtype=['core','player'], priority=[360, 90], cxx_compileflags = cxxflags ) diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index d22b1690e74..72e2c3ed7f5 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -447,6 +447,14 @@ def setPhysicsTicRate(ticrate): @type ticrate: float """ +def EvalExpression(text): + """ + Evaluate the string as an expression, similar to the expression controller logic brick. + @param text: The expression to evaluate. + @type text: string + @return: The result of the expression. The type depends on the expression. + """ + #{ Utility functions def getAverageFrameRate(): """ diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py index c391d0c3dec..054b2cb4daf 100644 --- a/source/gameengine/PyDoc/GameTypes.py +++ b/source/gameengine/PyDoc/GameTypes.py @@ -1023,6 +1023,12 @@ class CListValue(CPropValue): Return the value matching key, or the default value if its not found. @return: The key value or a default. """ + def has_key(key): + """ + Return True if the key is found. + @rtype: boolean + @return: The key value or a default. + """ def from_id(id): """ This is a funtion especially for the game engine to return a value with a spesific id. @@ -1576,7 +1582,7 @@ class KX_GameObject(SCA_IObject): @ivar childrenRecursive: all children of this object including childrens children, (read-only). @type childrenRecursive: L{CListValue} of L{KX_GameObject}'s @group Deprecated: getPosition, setPosition, setWorldPosition, getOrientation, setOrientation, getState, setState, getParent, getVisible, getMass, getMesh, getChildren, getChildrenRecursive - @group Property Access: get, attrDict, getPropertyNames + @group Property Access: get, has_key, attrDict, getPropertyNames """ def endObject(): """ @@ -2048,6 +2054,12 @@ class KX_GameObject(SCA_IObject): Return the value matching key, or the default value if its not found. @return: The key value or a default. """ + def has_key(key): + """ + Return True if the key is found. + @rtype: boolean + @return: The key value or a default. + """ class KX_IpoActuator(SCA_IActuator): @@ -2407,8 +2419,6 @@ class KX_MouseFocusSensor(SCA_MouseSensor): @type hitPosition: list (vector of 3 floats) @ivar hitNormal: the worldspace normal from the face at point of intersection. @type hitNormal: list (normalized vector of 3 floats) - @ivar usePulseFocus: When enabled, moving the mouse over a different object generates a pulse. (only used when the 'Mouse Over Any' sensor option is set) - @type usePulseFocus: bool """ #{ Deprecated def getHitNormal(): @@ -2470,7 +2480,7 @@ class KX_TouchSensor(SCA_ISensor): @ivar useMaterial: Determines if the sensor is looking for a property or material. KX_True = Find material; KX_False = Find property @type useMaterial: boolean - @ivar usePulseCollision: When enabled, changes to the set of colliding objects generate a pulse. + @ivar usePulseCollision: The last collided object. @type usePulseCollision: bool @ivar hitObject: The last collided object. (read-only) @type hitObject: L{KX_GameObject} or None @@ -3856,12 +3866,6 @@ class KX_Scene(PyObjectPlus): @rtype: L{KX_GameObject} """ - - def get(key, default=None): - """ - Return the value matching key, or the default value if its not found. - @return: The key value or a default. - """ class KX_SceneActuator(SCA_IActuator): """ @@ -5733,7 +5737,7 @@ for name, val in locals().items(): # Store the mappings to new attributes in a list (because there # could be collisions). - if attrName not in depAttrs: + if not depAttrs.has_key(attrName): depAttrs[attrName] = {} mapping = depAttrs[attrName] @@ -5758,7 +5762,7 @@ for name, val in locals().items(): # Another mapping, from a conversion tuple to lists of class # names. conversion = (func, newAttrName) - if conversion not in mapping: + if not mapping.has_key(conversion): mapping[conversion] = [] mapping[conversion].append(name) break diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 51d1f5001dd..143209f5a54 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -27,15 +27,15 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../source/kernel/gen_system - ../../../source/blender/makesdna - ../../../source/gameengine/SceneGraph - ../../../intern/string - ../../../intern/moto/include - ../../../extern/glew/include - ../Expressions - ${PYTHON_INC} + . + ../../../source/kernel/gen_system + ../../../source/blender/makesdna + ../../../source/gameengine/SceneGraph + ../../../intern/string + ../../../intern/moto/include + ../../../extern/glew/include + ../Expressions + ${PYTHON_INC} ) BLENDERLIB(bf_rasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 033daabc48f..cb5c5a12397 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -70,6 +70,7 @@ void RAS_IPolyMaterial::Initialize( RAS_IPolyMaterial::RAS_IPolyMaterial() : m_texturename("__Dummy_Texture_Name__"), m_materialname("__Dummy_Material_Name__"), + m_materialindex(0), m_tile(0), m_tilexrep(0), m_tileyrep(0), @@ -77,7 +78,6 @@ RAS_IPolyMaterial::RAS_IPolyMaterial() m_transp(0), m_alpha(false), m_zsort(false), - m_materialindex(0), m_polymatid(0), m_flag(0), m_multimode(0) @@ -100,6 +100,7 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, bool zsort) : m_texturename(texname), m_materialname(matname), + m_materialindex(materialindex), m_tile(tile), m_tilexrep(tilexrep), m_tileyrep(tileyrep), @@ -107,7 +108,6 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, m_transp(transp), m_alpha(alpha), m_zsort(zsort), - m_materialindex(materialindex), m_polymatid(m_newpolymatid++), m_flag(0), m_multimode(0) diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index dc9abbfbddf..207763392b2 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -79,11 +79,8 @@ class RAS_DisplayArray public: vector<RAS_TexVert> m_vertex; vector<unsigned short> m_index; - /* LINE currently isnt used */ enum { LINE = 2, TRIANGLE = 3, QUAD = 4 } m_type; //RAS_MeshSlot *m_origSlot; - - /* Number of RAS_MeshSlot using this array */ int m_users; enum { BUCKET_MAX_INDEX = 65535 }; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index f2b97bedb2f..fe3d0f6aeea 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -27,18 +27,18 @@ FILE(GLOB SRC *.cpp) SET(INC - ../../../../source/kernel/gen_system - ../../../../intern/string - ../../../../intern/moto/include - ../../../../source/gameengine/Rasterizer - ../../../../source/gameengine/Ketsji - ../../../../source/gameengine/SceneGraph - ../../../../extern/glew/include - ../../../../source/blender/gpu - ../../../../source/blender/makesdna - ../../../../source/blender/blenkernel - ../../../../source/blender/blenlib - ../../../../source/blender/blenloader + ../../../../source/kernel/gen_system + ../../../../intern/string + ../../../../intern/moto/include + ../../../../source/gameengine/Rasterizer + ../../../../source/gameengine/Ketsji + ../../../../source/gameengine/SceneGraph + ../../../../extern/glew/include + ../../../../source/blender/gpu + ../../../../source/blender/makesdna + ../../../../source/blender/blenkernel + ../../../../source/blender/blenlib + ../../../../source/blender/blenloader ) BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index fb4c685f8d3..e206c90ea25 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -8,4 +8,10 @@ incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC'] incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #source/blender/makesdna #source/blender/blenkernel' incs += ' #intern/guardedalloc #source/blender/blenlib' -env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350,75], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350, 115], cxx_compileflags = cxxflags ) diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp index 87c5118c5fb..eacc1285166 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.cpp +++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp @@ -31,7 +31,6 @@ #endif #include "RAS_Polygon.h" -#include "RAS_MeshObject.h" /* only for GetVertexOffsetAbs */ RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert) { @@ -64,20 +63,6 @@ int RAS_Polygon::GetVertexOffset(int i) return m_offset[i]; } -int RAS_Polygon::GetVertexOffsetAbs(RAS_MeshObject *mesh, int i) -{ - /* hack that only works because there can only ever be 2 different - * GetDisplayArray's per mesh. if this uses a different display array to the first - * then its incices are offset. - * if support for edges is added back this would need to be changed. */ - RAS_DisplayArray* darray= mesh->GetPolygon(0)->GetDisplayArray(); - - if(m_darray != darray) - return m_offset[i] + darray->m_vertex.size(); - - return m_offset[i]; -} - /* int RAS_Polygon::GetEdgeCode() { diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h index bd8cfe0be28..a5b77738026 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.h +++ b/source/gameengine/Rasterizer/RAS_Polygon.h @@ -72,7 +72,6 @@ public: void SetVertexOffset(int i, unsigned short offset); int GetVertexOffset(int i); - int GetVertexOffsetAbs(RAS_MeshObject *mesh, int i); /* accounts for quad and tri arrays, slower, for python */ // each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc. // - Not used yet! diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index dbec2d92e31..255131f9a44 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -7,4 +7,10 @@ sources = env.Glob('*.cpp') incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/gameengine/SceneGraph #source/blender/blenkernel #source/blender/makesdna' incs += ' ' + env['BF_PYTHON_INC'] -env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['core','player'], priority=[350,70], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['core','player'], priority=[350,115], cxx_compileflags = cxxflags ) diff --git a/source/gameengine/SceneGraph/CMakeLists.txt b/source/gameengine/SceneGraph/CMakeLists.txt index 2ac52be938e..0409b8c0ac4 100644 --- a/source/gameengine/SceneGraph/CMakeLists.txt +++ b/source/gameengine/SceneGraph/CMakeLists.txt @@ -27,8 +27,8 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../intern/moto/include + . + ../../../intern/moto/include ) BLENDERLIB(bf_scenegraph "${SRC}" "${INC}") diff --git a/source/gameengine/SceneGraph/SConscript b/source/gameengine/SceneGraph/SConscript index 2a33cd67b5e..b3db50117f1 100644 --- a/source/gameengine/SceneGraph/SConscript +++ b/source/gameengine/SceneGraph/SConscript @@ -6,4 +6,10 @@ sources = env.Glob('*.cpp') incs = '. #intern/moto/include' -env.BlenderLib ( 'bf_scenegraph', sources, Split(incs), [], libtype=['core','player'], priority=[325,85], cxx_compileflags=env['BGE_CXXFLAGS']) +cxxflags = [] +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') + +env.BlenderLib ( 'bf_scenegraph', sources, Split(incs), [], libtype=['core','player'], priority=[325,125], cxx_compileflags = cxxflags ) diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index 935c5a2c292..255d0907101 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -27,34 +27,34 @@ FILE(GLOB SRC *.cpp) SET(INC - . - ../../../source/gameengine/Ketsji - ../../../source/gameengine/Expressions - ../../../source/gameengine/GameLogic - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/BlenderRoutines - ../../../source/blender/include - ../../../source/blender/blenlib - ../../../source/blender/blenkernel - ../../../source/blender/makesdna - ../../../source/blender/editors/include - ../../../source/blender/imbuf - ../../../source/blender/python - ../../../source/blender/gpu - ../../../source/kernel/gen_system - ../../../intern/string - ../../../intern/moto/include - ../../../intern/guardedalloc - ../../../extern/glew/include - ${PYTHON_INC} + . + ../../../source/gameengine/Ketsji + ../../../source/gameengine/Expressions + ../../../source/gameengine/GameLogic + ../../../source/gameengine/SceneGraph + ../../../source/gameengine/Rasterizer + ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer + ../../../source/gameengine/BlenderRoutines + ../../../source/blender/include + ../../../source/blender/blenlib + ../../../source/blender/blenkernel + ../../../source/blender/makesdna + ../../../source/blender/editors/include + ../../../source/blender/imbuf + ../../../source/blender/python + ../../../source/blender/gpu + ../../../source/kernel/gen_system + ../../../intern/string + ../../../intern/moto/include + ../../../intern/guardedalloc + ../../../extern/glew/include + ${PYTHON_INC} ) IF(WITH_FFMPEG) - SET(INC ${INC} ${FFMPEG_INC} ${PTHREADS_INC}) - ADD_DEFINITIONS(-DWITH_FFMPEG) - ADD_DEFINITIONS(-D__STDC_CONSTANT_MACROS) + SET(INC ${INC} ${FFMPEG_INC} ${PTHREADS_INC}) + ADD_DEFINITIONS(-DWITH_FFMPEG) + ADD_DEFINITIONS(-D__STDC_CONSTANT_MACROS) ENDIF(WITH_FFMPEG) BLENDERLIB(bf_videotex "${SRC}" "${INC}") diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index 35d335b5981..8704d49f2a7 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -21,7 +21,7 @@ http://www.gnu.org/copyleft/lesser.txt. */ -#include <sstream> +#include <strstream> #include <fstream> #include <PyObjectPlus.h> @@ -170,11 +170,11 @@ void Exception::setXptDesc (void) // length of result code const size_t rsltSize = 11; // delimit description - //const char delimRslt[] = ": "; + const char delimRslt[] = ": "; // set text of description char rsltTxt[rsltSize]; - std::ostringstream os; - os << std::hex << m_hRslt << ": " << '\0'; + std::ostrstream os(rsltTxt, rsltSize); + os << std::hex << m_hRslt << delimRslt << '\0'; // copy result to description m_desc.insert(0, rsltTxt); // copy exception description to last exception string diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index 0740afed2c6..5e2841271a6 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -219,17 +219,15 @@ bool ImageBase::checkSourceSizes (void) // get size of current source short * curSize = (*it)->getSize(); // if size is available and is not empty - if (curSize[0] != 0 && curSize[1] != 0) { + if (curSize[0] != 0 && curSize[1] != 0) // if reference size is not set - if (refSize == NULL) { + if (refSize == NULL) // set current size as reference refSize = curSize; // otherwise check with current size - } else if (curSize[0] != refSize[0] || curSize[1] != refSize[1]) { + else if (curSize[0] != refSize[0] || curSize[1] != refSize[1]) // if they don't match, report it return false; - } - } } // all sizes match return true; diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index 119bd1c9954..d6b78f6d1a6 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -15,15 +15,21 @@ incs += ' #source/blender/gpu #source/kernel/gen_system #intern/string #intern/m incs += ' #intern/guardedalloc #extern/glew/include' defs = [] +cxxflags = [] if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cxxflags.append ('/GR') + cxxflags.append ('/O2') + cxxflags.append ('/EHsc') if env['BF_DEBUG']: defs.append('_DEBUG') + incs += ' ' + env['BF_PYTHON_INC'] #incs += ' ' + env['BF_OPENGL_INC'] if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') incs += ' ' + env['BF_FFMPEG_INC'] + ' ' + env['BF_PTHREADS_INC'] + defs.append('__STDC_CONSTANT_MACROS') -env.BlenderLib ( 'bf_videotex', sources, Split(incs), defs, libtype=['core','player'], priority=[300,205], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'bf_videotex', sources, Split(incs), defs, libtype=['core','player'], priority=[300, 72], cxx_compileflags = cxxflags ) |