diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-09-30 01:42:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-09-30 01:42:40 +0400 |
commit | 98ee2a781dd20bb58f72ee5700a11b2dd5124d74 (patch) | |
tree | 44825775e2d4ddc51d2138755b55c46fc17bb617 | |
parent | 53f0c3b018a995bbada591351568e4bb217dd1df (diff) |
option to build the BGE without python, uses existing python check (cmake and scons)
when python is disabled videotextures are not built.
171 files changed, 1204 insertions, 610 deletions
diff --git a/source/blender/editors/interface/SConscript b/source/blender/editors/interface/SConscript index e44de5410f1..bca0350d4fc 100644 --- a/source/blender/editors/interface/SConscript +++ b/source/blender/editors/interface/SConscript @@ -16,4 +16,7 @@ defs = [] if env['WITH_BF_INTERNATIONAL']: defs.append('INTERNATIONAL') -env.BlenderLib ( 'bf_editors_interface', sources, Split(incs), Split(defs), libtype=['core'], priority=[110] ) +if not env['WITH_BF_PYTHON']: + defs.append('DISABLE_PYTHON') + +env.BlenderLib ( 'bf_editors_interface', sources, Split(incs), defs, libtype=['core'], priority=[110] ) diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 1ede16f017e..5b825899739 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -34,6 +34,7 @@ #include <signal.h> #include <stdlib.h> +#include <stdio.h> #ifdef WIN32 // don't show stl-warnings @@ -137,6 +138,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); BLI_strncpy(oldsce, G.sce, sizeof(oldsce)); +#ifndef DISABLE_PYTHON resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path setGamePythonPath(G.sce); @@ -145,6 +147,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw PyGILState_STATE gilstate = PyGILState_Ensure(); PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */ +#endif bgl::InitExtensions(true); @@ -206,8 +209,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); +#ifndef DISABLE_PYTHON CValue::SetDeprecationWarnings(nodepwarnings); - +#endif //lock frame and camera enabled - storing global values int tmp_lay= scene->lay; @@ -288,7 +292,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw if(blenderdata) { BLI_strncpy(G.sce, blenderdata->name, sizeof(G.sce)); BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); +#ifndef DISABLE_PYTHON setGamePythonPath(G.sce); +#endif } } // else forget it, we can't find it @@ -365,7 +371,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw networkdevice, startscenename, blscene); - + +#ifndef DISABLE_PYTHON // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); ketsjiengine->SetPythonDictionary(dictionaryobject); @@ -383,6 +390,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw #ifdef WITH_FFMPEG initVideoTexture(); #endif +#endif // DISABLE_PYTHON //initialize Dome Settings if(blscene->gm.stereoflag == STEREO_DOME) @@ -398,7 +406,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw // convert and add scene sceneconverter->ConvertScene( startscene, +#ifndef DISABLE_PYTHON dictionaryobject, +#endif rendertools, canvas); ketsjiengine->AddScene(startscene); @@ -468,7 +478,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw // when exiting the mainloop - +#ifndef DISABLE_PYTHON // Clears the dictionary by hand: // This prevents, extra references to global variables // inside the GameLogic dictionary when the python interpreter is finalized. @@ -488,9 +498,11 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw } Py_DECREF(gameLogic_keys_new); gameLogic_keys_new = NULL; - +#endif ketsjiengine->StopEngine(); +#ifndef DISABLE_PYTHON exitGamePythonScripting(); +#endif networkdevice->Disconnect(); } if (sceneconverter) @@ -498,9 +510,11 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw delete sceneconverter; sceneconverter = NULL; } - + +#ifndef DISABLE_PYTHON Py_DECREF(gameLogic_keys); gameLogic_keys = NULL; +#endif } //lock frame and camera enabled - restoring global values if (v3d->scenelock==0){ @@ -555,14 +569,17 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); - Py_DECREF(pyGlobalDict); - if (bfd) BLO_blendfiledata_free(bfd); BLI_strncpy(G.sce, oldsce, sizeof(G.sce)); +#ifndef DISABLE_PYTHON + Py_DECREF(pyGlobalDict); + // Release Python's GIL PyGILState_Release(gilstate); +#endif + } extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, @@ -581,9 +598,11 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); +#ifndef DISABLE_PYTHON // Acquire Python's GIL (global interpreter lock) // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); +#endif bgl::InitExtensions(true); @@ -680,6 +699,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, startscenename, blscene); +#ifndef DISABLE_PYTHON // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); ketsjiengine->SetPythonDictionary(dictionaryobject); @@ -694,13 +714,16 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, #ifdef WITH_FFMPEG initVideoTexture(); #endif +#endif // DISABLE_PYTHON if (sceneconverter) { // convert and add scene sceneconverter->ConvertScene( startscene, +#ifndef DISABLE_PYTHON dictionaryobject, +#endif rendertools, canvas); ketsjiengine->AddScene(startscene); @@ -778,6 +801,8 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); +#ifndef DISABLE_PYTHON // Release Python's GIL PyGILState_Release(gilstate); +#endif } diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index ce85c1185b0..f2d6528d797 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -35,12 +35,17 @@ SET(INC ../../../source/blender/gpu ../../../extern/bullet2/src ../../../extern/glew/include - ${PYTHON_INC} ) IF(WITH_FFMPEG) ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_blroutines "${SRC}" "${INC}") #env.BlenderLib ( 'bf_bloutines', sources, Split(incs), [], libtype=['game', 'game2', 'player'], priority=[0, 0, 55] , compileflags=cxxflags) diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index 1e8ff3c48e8..f076612e231 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -25,7 +25,11 @@ incs += ' #source/blender/windowmanager' if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') -incs += ' ' + env['BF_PYTHON_INC'] +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt index 5a1887bd6c3..518e6a2bd58 100644 --- a/source/gameengine/CMakeLists.txt +++ b/source/gameengine/CMakeLists.txt @@ -38,7 +38,10 @@ ADD_SUBDIRECTORY(Rasterizer) ADD_SUBDIRECTORY(Rasterizer/RAS_OpenGLRasterizer) ADD_SUBDIRECTORY(SceneGraph) ADD_SUBDIRECTORY(Physics/Bullet) -ADD_SUBDIRECTORY(VideoTexture) + +IF(WITH_PYTHON) + ADD_SUBDIRECTORY(VideoTexture) +ENDIF(WITH_PYTHON) IF(WITH_PLAYER) ADD_SUBDIRECTORY(GamePlayer) diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 2f0e3e9fa65..6f3036d8e09 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -432,6 +432,8 @@ bool BL_ActionActuator::Update(double curtime, bool frame) return keepgoing; }; +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -675,3 +677,5 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA return ret; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 2e0e38b4cc3..3f3cd5f496d 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -84,6 +84,8 @@ public: bAction* GetAction() { return m_action; } void SetAction(bAction* act) { m_action= act; } +#ifndef DISABLE_PYTHON + KX_PYMETHOD_O(BL_ActionActuator,GetChannel); KX_PYMETHOD_DOC(BL_ActionActuator,setChannel); @@ -129,6 +131,7 @@ public: return 1; } } +#endif // DISABLE_PYTHON protected: diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp index 741f1cf0553..a018f0f938d 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.cpp +++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp @@ -175,6 +175,8 @@ bool BL_ArmatureActuator::Update(double curtime, bool frame) return result; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python Integration Hooks */ /* ------------------------------------------------------------------------- */ @@ -261,5 +263,5 @@ PyObject* BL_ArmatureActuator::pyattr_get_constraint(void *self, const struct KX return constraint->GetProxy(); } - +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Converter/BL_ArmatureActuator.h b/source/gameengine/Converter/BL_ArmatureActuator.h index 5a7752b8169..e7e12bc2e4e 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.h +++ b/source/gameengine/Converter/BL_ArmatureActuator.h @@ -66,11 +66,15 @@ public: virtual bool Update(double curtime, bool frame); virtual void ReParent(SCA_IObject* parent); +#ifndef DISABLE_PYTHON + /* These are used to get and set m_target */ static PyObject* pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 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); +#endif // DISABLE_PYTHON + private: // identify the constraint that this actuator controls void FindConstraint(); diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp index 2f21d4f2978..9a9161b080f 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.cpp +++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp @@ -37,6 +37,8 @@ #include "BLI_arithb.h" #include "BLI_string.h" +#ifndef DISABLE_PYTHON + PyTypeObject BL_ArmatureChannel::Type = { PyVarObject_HEAD_INIT(NULL, 0) "BL_ArmatureChannel", @@ -74,6 +76,8 @@ PyObject *BL_ArmatureChannel::NewProxy(bool py_owns) return NewProxyPlus_Ext(this, &Type, m_posechannel, py_owns); } +#endif // DISABLE_PYTHON + BL_ArmatureChannel::BL_ArmatureChannel( BL_ArmatureObject *armature, bPoseChannel *posechannel) @@ -85,6 +89,8 @@ BL_ArmatureChannel::~BL_ArmatureChannel() { } +#ifndef DISABLE_PYTHON + // PYTHON PyMethodDef BL_ArmatureChannel::Methods[] = { @@ -459,3 +465,5 @@ PyObject *BL_ArmatureBone::py_bone_get_children(void *self, const struct KX_PYAT return childrenlist; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Converter/BL_ArmatureChannel.h b/source/gameengine/Converter/BL_ArmatureChannel.h index 0f0f5a062e0..64b03835d83 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.h +++ b/source/gameengine/Converter/BL_ArmatureChannel.h @@ -57,14 +57,15 @@ public: struct bPoseChannel *posechannel); virtual ~BL_ArmatureChannel(); +#ifndef DISABLE_PYTHON + // Python access virtual PyObject* py_repr(void); - // Python access static PyObject* py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* py_attr_get_joint_rotation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int py_attr_set_joint_rotation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - +#endif // DISABLE_PYTHON }; /* this is a factory class to access bBone data field in the GE. @@ -80,9 +81,12 @@ private: virtual ~BL_ArmatureBone() {} public: + +#ifndef DISABLE_PYTHON static PyObject *py_bone_repr(PyObject *self); static PyObject *py_bone_get_parent(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static PyObject *py_bone_get_children(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); +#endif }; diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp index 15e12611483..42581b63ec4 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp +++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp @@ -37,6 +37,8 @@ #include "BLI_arithb.h" #include "BLI_string.h" +#ifndef DISABLE_PYTHON + PyTypeObject BL_ArmatureConstraint::Type = { PyVarObject_HEAD_INIT(NULL, 0) "BL_ArmatureConstraint", @@ -64,6 +66,8 @@ PyObject* BL_ArmatureConstraint::py_repr(void) return PyUnicode_FromString(m_name); } +#endif // DISABLE_PYTHON + BL_ArmatureConstraint::BL_ArmatureConstraint( BL_ArmatureObject *armature, bPoseChannel *posechannel, @@ -237,6 +241,8 @@ void BL_ArmatureConstraint::SetSubtarget(KX_GameObject* subtarget) } +#ifndef DISABLE_PYTHON + // PYTHON PyMethodDef BL_ArmatureConstraint::Methods[] = { @@ -445,3 +451,4 @@ int BL_ArmatureConstraint::py_attr_setattr(void *self_v, const struct KX_PYATTRI return PY_SET_ATTR_FAIL; } +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.h b/source/gameengine/Converter/BL_ArmatureConstraint.h index f10849ea05b..2a202dfe62e 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.h +++ b/source/gameengine/Converter/BL_ArmatureConstraint.h @@ -73,9 +73,6 @@ public: KX_GameObject* subtarget); virtual ~BL_ArmatureConstraint(); - - virtual PyObject* py_repr(void); - BL_ArmatureConstraint* GetReplica() const; void ReParent(BL_ArmatureObject* armature); void Relink(GEN_Map<GEN_HashedPtr, void*> *map); @@ -107,10 +104,14 @@ public: void SetTarget(KX_GameObject* target); void SetSubtarget(KX_GameObject* subtarget); +#ifndef DISABLE_PYTHON + // Python access + virtual PyObject* py_repr(void); + static PyObject* py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - +#endif // DISABLE_PYTHON }; #endif //__BL_ARMATURECONSTRAINT diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 54c1e8fc718..a6066adc03e 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -590,6 +590,8 @@ float BL_ArmatureObject::GetBoneLength(Bone* bone) const return (float)(MT_Point3(bone->head) - MT_Point3(bone->tail)).length(); } +#ifndef DISABLE_PYTHON + // PYTHON PyTypeObject BL_ArmatureObject::Type = { @@ -654,3 +656,5 @@ KX_PYMETHODDEF_DOC_NOARGS(BL_ArmatureObject, update, SetActiveAction(NULL, 0, KX_GetActiveEngine()->GetFrameTime()); Py_RETURN_NONE; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 8e3d5734b73..b7ef38468bb 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -108,11 +108,15 @@ public: virtual int GetGameObjectType() { return OBJ_ARMATURE; } +#ifndef DISABLE_PYTHON + // PYTHON static PyObject* pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); KX_PYMETHOD_DOC_NOARGS(BL_ArmatureObject, update); +#endif // DISABLE_PYTHON + protected: /* list element: BL_ArmatureConstraint. Use SG_DListHead to have automatic list replication */ SG_DListHead<BL_ArmatureConstraint> m_controlledConstraints; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 52fb13bd41c..8310294a73a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1897,7 +1897,9 @@ void BL_ConvertBlenderObjects(struct Main* maggie, KX_Scene* kxscene, KX_KetsjiEngine* ketsjiEngine, e_PhysicsEngine physics_engine, +#ifndef DISABLE_PYTHON PyObject* pythondictionary, +#endif RAS_IRenderTools* rendertools, RAS_ICanvas* canvas, KX_BlenderSceneConverter* converter, @@ -2653,7 +2655,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie, struct Object* blenderobj = gameobj->GetBlenderObject(); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; - BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,layerMask,isInActiveLayer,converter); + BL_ConvertControllers(blenderobj,gameobj,logicmgr, +#ifndef DISABLE_PYTHON + pythondictionary, +#endif + layerMask,isInActiveLayer,converter); } for ( i=0;i<logicbrick_conversionlist->GetCount();i++) { diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h index b8f9d1ec4e6..96ef7d5bc77 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.h +++ b/source/gameengine/Converter/BL_BlenderDataConversion.h @@ -40,7 +40,9 @@ void BL_ConvertBlenderObjects(struct Main* maggie, class KX_Scene* kxscene, class KX_KetsjiEngine* ketsjiEngine, e_PhysicsEngine physics_engine, +#ifndef DISABLE_PYTHON PyObject* pythondictionary, +#endif class RAS_IRenderTools* rendertools, class RAS_ICanvas* canvas, class KX_BlenderSceneConverter* sceneconverter, diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 81ce9ff6154..0af6556f285 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -412,6 +412,8 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) return keepgoing; }; +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -492,3 +494,5 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE return PY_SET_ATTR_SUCCESS; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 80157630e27..efb1293a5eb 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -82,6 +82,8 @@ public: bAction* GetAction() { return m_action; } void SetAction(bAction* act) { m_action= act; } +#ifndef DISABLE_PYTHON + 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); @@ -123,6 +125,8 @@ public: } +#endif // DISABLE_PYTHON + protected: void SetStartTime(float curtime); diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index d617934ec01..f9af2c23629 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -61,8 +61,13 @@ SET(INC ../../../source/blender/gpu ../../../source/blender/ikplugin ../../../extern/bullet2/src - ${PYTHON_INC} ) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_converter "${SRC}" "${INC}") #env.BlenderLib ( 'bf_converter', sources, Split(incs), [], libtype=['game','player'], priority=[5,70] ) diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 151564391f3..f0f5e1d4f41 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -243,7 +243,9 @@ struct BlenderDebugDraw : public btIDebugDraw #endif void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, +#ifndef DISABLE_PYTHON PyObject* dictobj, +#endif class RAS_IRenderTools* rendertools, class RAS_ICanvas* canvas) { @@ -328,7 +330,9 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, destinationscene, m_ketsjiEngine, physics_engine, +#ifndef DISABLE_PYTHON dictobj, +#endif rendertools, canvas, this, diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index bb87a21a683..fa066aac27e 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -89,7 +89,9 @@ public: */ virtual void ConvertScene( class KX_Scene* destinationscene, +#ifndef DISABLE_PYTHON PyObject* dictobj, +#endif class RAS_IRenderTools* rendertools, class RAS_ICanvas* canvas ); diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 85ab8e4f8b8..1cb15c932ac 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -91,8 +91,10 @@ LinkControllerToActuators( void BL_ConvertControllers( struct Object* blenderobject, class KX_GameObject* gameobj, - SCA_LogicManager* logicmgr, + SCA_LogicManager* logicmgr, +#ifndef DISABLE_PYTHON PyObject* pythondictionary, +#endif int activeLayerBitInfo, bool isInActiveLayer, KX_BlenderSceneConverter* converter @@ -159,6 +161,8 @@ void BL_ConvertControllers( SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode); gamecontroller = pyctrl; +#ifndef DISABLE_PYTHON + pyctrl->SetDictionary(pythondictionary); if(pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) { @@ -187,6 +191,8 @@ void BL_ConvertControllers( pyctrl->SetDebug(true); } +#endif // DISABLE_PYTHON + break; } default: @@ -211,7 +217,8 @@ void BL_ConvertControllers( gameobj->AddController(gamecontroller); converter->RegisterGameController(gamecontroller, bcontr); - + +#ifndef DISABLE_PYTHON if (bcontr->type==CONT_PYTHON) { SCA_PythonController *pyctrl= static_cast<SCA_PythonController*>(gamecontroller); /* not strictly needed but gives syntax errors early on and @@ -226,7 +233,8 @@ void BL_ConvertControllers( // pyctrl->Import(); } } - +#endif // DISABLE_PYTHON + //done with gamecontroller gamecontroller->Release(); } diff --git a/source/gameengine/Converter/KX_ConvertControllers.h b/source/gameengine/Converter/KX_ConvertControllers.h index d340778290c..3895ed2c873 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.h +++ b/source/gameengine/Converter/KX_ConvertControllers.h @@ -34,8 +34,10 @@ void BL_ConvertControllers( struct Object* blenderobject, class KX_GameObject* gameobj, - class SCA_LogicManager* logicmgr, + class SCA_LogicManager* logicmgr, +#ifndef DISABLE_PYTHON PyObject* pythondictionary, +#endif int activeLayerBitInfo, bool isInActiveLayer, class KX_BlenderSceneConverter* converter diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index 1c22d2a0600..7ecdb6c5db6 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -130,7 +130,7 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan propval->Release(); } - +#ifndef DISABLE_PYTHON /* Warn if we double up on attributes, this isnt quite right since it wont find inherited attributes however there arnt many */ for(PyAttributeDef *attrdef = KX_GameObject::Attributes; attrdef->m_name; attrdef++) { if(strcmp(prop->name, attrdef->m_name)==0) { @@ -145,6 +145,7 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan } } /* end warning check */ +#endif // DISABLE_PYTHON prop = prop->next; } diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 99a2ec3ca64..692cc91f340 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -28,6 +28,7 @@ * Conversion of Blender data blocks to KX sensor system */ +#include <stdio.h> #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index 8a5eb8a341c..616c205732c 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -21,11 +21,15 @@ incs += ' #source/blender/windowmanager' incs += ' #source/blender/makesrna' incs += ' #source/blender/ikplugin' -incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_BULLET_INC'] if env['BF_DEBUG']: if env['OURPLATFORM'] in ('win32-mingw', 'win32-vc', 'win64-vc'): defs.append('_DEBUG') + +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,40], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Expressions/BoolValue.cpp b/source/gameengine/Expressions/BoolValue.cpp index 6779c2ea780..62e43da335b 100644 --- a/source/gameengine/Expressions/BoolValue.cpp +++ b/source/gameengine/Expressions/BoolValue.cpp @@ -205,9 +205,9 @@ CValue* CBoolValue::GetReplica() return replica; } - - +#ifndef DISABLE_PYTHON PyObject* CBoolValue::ConvertValueToPython() { return PyBool_FromLong(m_bool != 0); } +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Expressions/BoolValue.h b/source/gameengine/Expressions/BoolValue.h index 4d0103ec1dd..baec6bdee69 100644 --- a/source/gameengine/Expressions/BoolValue.h +++ b/source/gameengine/Expressions/BoolValue.h @@ -45,7 +45,9 @@ public: void Configure(CValue* menuvalue); virtual CValue* GetReplica(); +#ifndef DISABLE_PYTHON virtual PyObject* ConvertValueToPython(); +#endif private: bool m_bool; diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index ec3738d1fe8..db7d12f313d 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -34,8 +34,13 @@ SET(INC ../../../intern/moto/include ../../../source/gameengine/SceneGraph ../../../source/blender/blenloader - ${PYTHON_INC} ) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_expressions "${SRC}" "${INC}") #env.BlenderLib ( 'bf_expressions', sources, Split(incs), [], libtype=['game','player'], priority = [45,125] ) diff --git a/source/gameengine/Expressions/FloatValue.cpp b/source/gameengine/Expressions/FloatValue.cpp index 4de685a82c1..b1ac0e1ea9a 100644 --- a/source/gameengine/Expressions/FloatValue.cpp +++ b/source/gameengine/Expressions/FloatValue.cpp @@ -314,9 +314,9 @@ CValue* CFloatValue::GetReplica() } - +#ifndef DISABLE_PYTHON PyObject* CFloatValue::ConvertValueToPython() { return PyFloat_FromDouble(m_float); } - +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Expressions/FloatValue.h b/source/gameengine/Expressions/FloatValue.h index 442f0eb6cf8..f1469734a1f 100644 --- a/source/gameengine/Expressions/FloatValue.h +++ b/source/gameengine/Expressions/FloatValue.h @@ -36,7 +36,9 @@ public: virtual CValue* GetReplica(); virtual CValue* Calc(VALUE_OPERATOR op, CValue *val); virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val); +#ifndef DISABLE_PYTHON virtual PyObject* ConvertValueToPython(); +#endif protected: float m_float; diff --git a/source/gameengine/Expressions/IntValue.cpp b/source/gameengine/Expressions/IntValue.cpp index b782de4bef6..badba8ead63 100644 --- a/source/gameengine/Expressions/IntValue.cpp +++ b/source/gameengine/Expressions/IntValue.cpp @@ -326,7 +326,7 @@ void CIntValue::SetValue(CValue* newval) } - +#ifndef DISABLE_PYTHON PyObject* CIntValue::ConvertValueToPython() { if((m_int > INT_MIN) && (m_int < INT_MAX)) @@ -334,3 +334,4 @@ PyObject* CIntValue::ConvertValueToPython() else return PyLong_FromLongLong(m_int); } +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Expressions/IntValue.h b/source/gameengine/Expressions/IntValue.h index 0513026c4cf..26150674c93 100644 --- a/source/gameengine/Expressions/IntValue.h +++ b/source/gameengine/Expressions/IntValue.h @@ -47,7 +47,10 @@ public: void Configure(CValue* menuvalue); void AddConfigurationData(CValue* menuvalue); virtual CValue* GetReplica(); + +#ifndef DISABLE_PYTHON virtual PyObject* ConvertValueToPython(); +#endif protected: virtual ~CIntValue(); diff --git a/source/gameengine/Expressions/KX_Python.h b/source/gameengine/Expressions/KX_Python.h index f41accec730..ecbd1b9b6b0 100644 --- a/source/gameengine/Expressions/KX_Python.h +++ b/source/gameengine/Expressions/KX_Python.h @@ -40,11 +40,13 @@ #undef _POSIX_C_SOURCE #endif - +#ifndef DISABLE_PYTHON #include "Python.h" #define USE_MATHUTILS // Blender 2.5x api will use mathutils, for a while we might want to test without it +#endif + #ifdef __FreeBSD__ #include <osreldate.h> #if __FreeBSD_version > 500039 diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index 002674450d1..6e47ed913db 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -14,6 +14,8 @@ * */ +#include <stdio.h> + #include "ListValue.h" #include "StringValue.h" #include "VoidValue.h" @@ -26,9 +28,255 @@ #include <config.h> #endif -#if ((PY_MAJOR_VERSION == 2) &&(PY_MINOR_VERSION < 5)) -#define Py_ssize_t int -#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CListValue::CListValue() +: CPropValue() +{ + m_bReleaseContents=true; +} + + + +CListValue::~CListValue() +{ + + if (m_bReleaseContents) { + for (unsigned int i=0;i<m_pValueArray.size();i++) { + m_pValueArray[i]->Release(); + } + } +} + + +static STR_String gstrListRep=STR_String("List"); + +const STR_String & CListValue::GetText() +{ + gstrListRep = "["; + STR_String commastr = ""; + + for (int i=0;i<GetCount();i++) + { + gstrListRep += commastr; + gstrListRep += GetValue(i)->GetText(); + commastr = ","; + } + gstrListRep += "]"; + + return gstrListRep; +} + + + +CValue* CListValue::GetReplica() { + CListValue* replica = new CListValue(*this); + + replica->ProcessReplica(); + + replica->m_bReleaseContents=true; // for copy, complete array is copied for now... + // copy all values + int numelements = m_pValueArray.size(); + unsigned int i=0; + replica->m_pValueArray.resize(numelements); + for (i=0;i<m_pValueArray.size();i++) + replica->m_pValueArray[i] = m_pValueArray[i]->GetReplica(); + + + return replica; +}; + + + +void CListValue::SetValue(int i, CValue *val) +{ + assertd(i < m_pValueArray.size()); + m_pValueArray[i]=val; +} + + + +void CListValue::Resize(int num) +{ + m_pValueArray.resize(num); +} + + + +void CListValue::Remove(int i) +{ + assertd(i<m_pValueArray.size()); + m_pValueArray.erase(m_pValueArray.begin()+i); +} + + + +void CListValue::ReleaseAndRemoveAll() +{ + for (unsigned int i=0;i<m_pValueArray.size();i++) + m_pValueArray[i]->Release(); + m_pValueArray.clear();//.Clear(); +} + + + +CValue* CListValue::FindValue(const STR_String & name) +{ + for (int i=0; i < GetCount(); i++) + if (GetValue(i)->GetName() == name) + return GetValue(i); + + return NULL; +} + +CValue* CListValue::FindValue(const char * name) +{ + for (int i=0; i < GetCount(); i++) + if (GetValue(i)->GetName() == name) + return GetValue(i); + + return NULL; +} + +bool CListValue::SearchValue(CValue *val) +{ + for (int i=0;i<GetCount();i++) + if (val == GetValue(i)) + return true; + return false; +} + + + +void CListValue::SetReleaseOnDestruct(bool bReleaseContents) +{ + m_bReleaseContents = bReleaseContents; +} + + + +bool CListValue::RemoveValue(CValue *val) +{ + bool result=false; + + for (int i=GetCount()-1;i>=0;i--) + if (val == GetValue(i)) + { + Remove(i); + result=true; + } + return result; +} + + + +void CListValue::MergeList(CListValue *otherlist) +{ + + int numelements = this->GetCount(); + int numotherelements = otherlist->GetCount(); + + + Resize(numelements+numotherelements); + + for (int i=0;i<numotherelements;i++) + { + SetValue(i+numelements,otherlist->GetValue(i)->AddRef()); + } +} + +bool CListValue::CheckEqual(CValue* first,CValue* second) +{ + bool result = false; + + CValue* eqval = ((CValue*)first)->Calc(VALUE_EQL_OPERATOR,(CValue*)second); + + if (eqval==NULL) + return false; + const STR_String& text = eqval->GetText(); + if (&text==&CBoolValue::sTrueString) + { + result = true; + } + eqval->Release(); + return result; + +} + + +/* --------------------------------------------------------------------- + * Some stuff taken from the header + * --------------------------------------------------------------------- */ +CValue* CListValue::Calc(VALUE_OPERATOR op,CValue *val) +{ + //assert(false); // todo: implement me! + static int error_printed = 0; + if (error_printed==0) { + fprintf(stderr, "CValueList::Calc not yet implimented\n"); + error_printed = 1; + } + return NULL; +} + +CValue* CListValue::CalcFinal(VALUE_DATA_TYPE dtype, + VALUE_OPERATOR op, + CValue* val) +{ + //assert(false); // todo: implement me! + static int error_printed = 0; + if (error_printed==0) { + fprintf(stderr, "CValueList::CalcFinal not yet implimented\n"); + error_printed = 1; + } + return NULL; +} + + + +void CListValue::Add(CValue* value) +{ + m_pValueArray.push_back(value); +} + + + +double CListValue::GetNumber() +{ + return -1; +} + + + +void CListValue::SetModified(bool bModified) +{ + CValue::SetModified(bModified); + int numels = GetCount(); + + for (int i=0;i<numels;i++) + GetValue(i)->SetModified(bModified); +} + + + +bool CListValue::IsModified() +{ + bool bmod = CValue::IsModified(); //normal own flag + int numels = GetCount(); + + for (int i=0;i<numels;i++) + bmod = bmod || GetValue(i)->IsModified(); + + return bmod; +} + +#ifndef DISABLE_PYTHON + +/* --------------------------------------------------------------------- */ +/* Python interface ---------------------------------------------------- */ +/* --------------------------------------------------------------------- */ Py_ssize_t listvalue_bufferlen(PyObject* self) { @@ -297,13 +545,13 @@ PyMethodDef CListValue::Methods[] = { {"reverse", (PyCFunction)CListValue::sPyreverse,METH_NOARGS}, {"index", (PyCFunction)CListValue::sPyindex,METH_O}, {"count", (PyCFunction)CListValue::sPycount,METH_O}, - + /* Dict style access */ {"get", (PyCFunction)CListValue::sPyget,METH_VARARGS}, - + /* Own cvalue funcs */ {"from_id", (PyCFunction)CListValue::sPyfrom_id,METH_O}, - + {NULL,NULL} //Sentinel }; @@ -311,213 +559,29 @@ PyAttributeDef CListValue::Attributes[] = { { NULL } //Sentinel }; -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CListValue::CListValue() -: CPropValue() -{ - m_bReleaseContents=true; -} - - - -CListValue::~CListValue() -{ - - if (m_bReleaseContents) { - for (unsigned int i=0;i<m_pValueArray.size();i++) { - m_pValueArray[i]->Release(); - } - } -} - - -static STR_String gstrListRep=STR_String("List"); - -const STR_String & CListValue::GetText() -{ - gstrListRep = "["; - STR_String commastr = ""; - - for (int i=0;i<GetCount();i++) - { - gstrListRep += commastr; - gstrListRep += GetValue(i)->GetText(); - commastr = ","; - } - gstrListRep += "]"; - - return gstrListRep; -} - - - -CValue* CListValue::GetReplica() { - CListValue* replica = new CListValue(*this); - - replica->ProcessReplica(); - - replica->m_bReleaseContents=true; // for copy, complete array is copied for now... - // copy all values - int numelements = m_pValueArray.size(); - unsigned int i=0; - replica->m_pValueArray.resize(numelements); - for (i=0;i<m_pValueArray.size();i++) - replica->m_pValueArray[i] = m_pValueArray[i]->GetReplica(); - - - return replica; -}; - - - -void CListValue::SetValue(int i, CValue *val) -{ - assertd(i < m_pValueArray.size()); - m_pValueArray[i]=val; -} - - - -void CListValue::Resize(int num) -{ - m_pValueArray.resize(num); -} - - - -void CListValue::Remove(int i) -{ - assertd(i<m_pValueArray.size()); - m_pValueArray.erase(m_pValueArray.begin()+i); -} - - - -void CListValue::ReleaseAndRemoveAll() -{ - for (unsigned int i=0;i<m_pValueArray.size();i++) - m_pValueArray[i]->Release(); - m_pValueArray.clear();//.Clear(); -} - - - -CValue* CListValue::FindValue(const STR_String & name) -{ - for (int i=0; i < GetCount(); i++) - if (GetValue(i)->GetName() == name) - return GetValue(i); - - return NULL; -} - -CValue* CListValue::FindValue(const char * name) -{ - for (int i=0; i < GetCount(); i++) - if (GetValue(i)->GetName() == name) - return GetValue(i); - - return NULL; -} - -bool CListValue::SearchValue(CValue *val) -{ - for (int i=0;i<GetCount();i++) - if (val == GetValue(i)) - return true; - return false; -} - - - -void CListValue::SetReleaseOnDestruct(bool bReleaseContents) -{ - m_bReleaseContents = bReleaseContents; -} - - - -bool CListValue::RemoveValue(CValue *val) -{ - bool result=false; - - for (int i=GetCount()-1;i>=0;i--) - if (val == GetValue(i)) - { - Remove(i); - result=true; - } - return result; -} - - - -void CListValue::MergeList(CListValue *otherlist) -{ - - int numelements = this->GetCount(); - int numotherelements = otherlist->GetCount(); - - - Resize(numelements+numotherelements); - - for (int i=0;i<numotherelements;i++) - { - SetValue(i+numelements,otherlist->GetValue(i)->AddRef()); - } -} - - PyObject* CListValue::Pyappend(PyObject* value) { CValue* objval = ConvertPythonToValue(value, "CList.append(i): CValueList, "); if (!objval) /* ConvertPythonToValue sets the error */ return NULL; - + if (!BGE_PROXY_PYOWNS(m_proxy)) { PyErr_SetString(PyExc_TypeError, "CList.append(i): this CValueList is used internally for the game engine and can't be modified"); return NULL; } - + Add(objval); - + Py_RETURN_NONE; } - - PyObject* CListValue::Pyreverse() { std::reverse(m_pValueArray.begin(),m_pValueArray.end()); Py_RETURN_NONE; } - - -bool CListValue::CheckEqual(CValue* first,CValue* second) -{ - bool result = false; - - CValue* eqval = ((CValue*)first)->Calc(VALUE_EQL_OPERATOR,(CValue*)second); - - if (eqval==NULL) - return false; - const STR_String& text = eqval->GetText(); - if (&text==&CBoolValue::sTrueString) - { - result = true; - } - eqval->Release(); - return result; - -} - - - PyObject* CListValue::Pyindex(PyObject *value) { PyObject* result = NULL; @@ -542,7 +606,7 @@ PyObject* CListValue::Pyindex(PyObject *value) PyErr_SetString(PyExc_ValueError, "CList.index(x): x not in CListValue"); } return result; - + } @@ -552,7 +616,7 @@ PyObject* CListValue::Pycount(PyObject* value) int numfound = 0; CValue* checkobj = ConvertPythonToValue(value, ""); /* error ignored */ - + if (checkobj==NULL) { /* in this case just return that there are no items in the list */ PyErr_Clear(); return PyLong_FromSsize_t(0); @@ -580,9 +644,9 @@ PyObject* CListValue::Pyget(PyObject *args) if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) return NULL; - + CValue *item = FindValue((const char *)key); - if (item) { + if (item) { PyObject* pyobj = item->ConvertValueToPython(); if (pyobj) return pyobj; @@ -597,7 +661,7 @@ PyObject* CListValue::Pyget(PyObject *args) PyObject* CListValue::Pyfrom_id(PyObject* value) { uintptr_t id= (uintptr_t)PyLong_AsVoidPtr(value); - + if (PyErr_Occurred()) return NULL; @@ -608,72 +672,8 @@ PyObject* CListValue::Pyfrom_id(PyObject* value) return GetValue(i)->GetProxy(); } PyErr_SetString(PyExc_IndexError, "from_id(#): id not found in CValueList"); - return NULL; - -} - - -/* --------------------------------------------------------------------- - * Some stuff taken from the header - * --------------------------------------------------------------------- */ -CValue* CListValue::Calc(VALUE_OPERATOR op,CValue *val) -{ - //assert(false); // todo: implement me! - static int error_printed = 0; - if (error_printed==0) { - fprintf(stderr, "CValueList::Calc not yet implimented\n"); - error_printed = 1; - } return NULL; -} - -CValue* CListValue::CalcFinal(VALUE_DATA_TYPE dtype, - VALUE_OPERATOR op, - CValue* val) -{ - //assert(false); // todo: implement me! - static int error_printed = 0; - if (error_printed==0) { - fprintf(stderr, "CValueList::CalcFinal not yet implimented\n"); - error_printed = 1; - } - return NULL; -} - - - -void CListValue::Add(CValue* value) -{ - m_pValueArray.push_back(value); -} - - -double CListValue::GetNumber() -{ - return -1; } - - -void CListValue::SetModified(bool bModified) -{ - CValue::SetModified(bModified); - int numels = GetCount(); - - for (int i=0;i<numels;i++) - GetValue(i)->SetModified(bModified); -} - - - -bool CListValue::IsModified() -{ - bool bmod = CValue::IsModified(); //normal own flag - int numels = GetCount(); - - for (int i=0;i<numels;i++) - bmod = bmod || GetValue(i)->IsModified(); - - return bmod; -} +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h index 2dc458e0148..8f3b9dcda0b 100644 --- a/source/gameengine/Expressions/ListValue.h +++ b/source/gameengine/Expressions/ListValue.h @@ -60,6 +60,7 @@ public: bool CheckEqual(CValue* first,CValue* second); +#ifndef DISABLE_PYTHON virtual PyObject* py_repr(void) { PyObject *py_proxy= this->GetProxy(); PyObject *py_list= PySequence_List(py_proxy); @@ -75,7 +76,7 @@ public: KX_PYMETHOD_O(CListValue,count); KX_PYMETHOD_VARARGS(CListValue,get); KX_PYMETHOD_O(CListValue,from_id); - +#endif private: diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 7adbf5ac651..54a33b76efd 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -30,8 +30,6 @@ #include <config.h> #endif -#ifndef NO_EXP_PYTHON_EMBEDDING - /*------------------------------ * PyObjectPlus cpp * @@ -52,6 +50,56 @@ #include "STR_String.h" #include "MT_Vector3.h" #include "MEM_guardedalloc.h" + +PyObjectPlus::~PyObjectPlus() +{ +#ifndef DISABLE_PYTHON + if(m_proxy) { + BGE_PROXY_REF(m_proxy)= NULL; + Py_DECREF(m_proxy); /* Remove own reference, python may still have 1 */ + } +// assert(ob_refcnt==0); +#endif +} + +PyObjectPlus::PyObjectPlus() : SG_QList() // constructor +{ +#ifndef DISABLE_PYTHON + m_proxy= NULL; +#endif +}; + +void PyObjectPlus::ProcessReplica() +{ +#ifndef DISABLE_PYTHON + /* Clear the proxy, will be created again if needed with GetProxy() + * otherwise the PyObject will point to the wrong reference */ + m_proxy= NULL; +#endif +} + +/* Sometimes we might want to manually invalidate a BGE type even if + * it hasnt been released by the BGE, say for example when an object + * is removed from a scene, accessing it may cause problems. + * + * In this case the current proxy is made invalid, disowned, + * and will raise an error on access. However if python can get access + * to this class again it will make a new proxy and work as expected. + */ +void PyObjectPlus::InvalidateProxy() // check typename of each parent +{ +#ifndef DISABLE_PYTHON + if(m_proxy) { + BGE_PROXY_REF(m_proxy)=NULL; + Py_DECREF(m_proxy); + m_proxy= NULL; + } +#endif +} + + +#ifndef DISABLE_PYTHON + /*------------------------------ * PyObjectPlus Type -- Every class, even the abstract one should have a Type ------------------------------*/ @@ -78,17 +126,6 @@ PyTypeObject PyObjectPlus::Type = { NULL // no subtype }; - -PyObjectPlus::~PyObjectPlus() -{ - if(m_proxy) { - BGE_PROXY_REF(m_proxy)= NULL; - Py_DECREF(m_proxy); /* Remove own reference, python may still have 1 */ - } -// assert(ob_refcnt==0); -} - - PyObject *PyObjectPlus::py_base_repr(PyObject *self) // This should be the entry in Type. { PyObjectPlus *self_plus= BGE_PROXY_REF(self); @@ -202,11 +239,6 @@ void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper #endif }; -PyObjectPlus::PyObjectPlus() : SG_QList() // constructor -{ - m_proxy= NULL; -}; - /*------------------------------ * PyObjectPlus Methods -- Every class, even the abstract one should have a Methods ------------------------------*/ @@ -1067,30 +1099,6 @@ PyObject *PyObjectPlus::py_repr(void) return NULL; } -void PyObjectPlus::ProcessReplica() -{ - /* Clear the proxy, will be created again if needed with GetProxy() - * otherwise the PyObject will point to the wrong reference */ - m_proxy= NULL; -} - -/* Sometimes we might want to manually invalidate a BGE type even if - * it hasnt been released by the BGE, say for example when an object - * is removed from a scene, accessing it may cause problems. - * - * In this case the current proxy is made invalid, disowned, - * and will raise an error on access. However if python can get access - * to this class again it will make a new proxy and work as expected. - */ -void PyObjectPlus::InvalidateProxy() // check typename of each parent -{ - if(m_proxy) { - BGE_PROXY_REF(m_proxy)=NULL; - Py_DECREF(m_proxy); - m_proxy= NULL; - } -} - PyObject *PyObjectPlus::GetProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr) { if (self->m_proxy==NULL) @@ -1220,5 +1228,4 @@ void PyObjectPlus::SetDeprecationWarningFirst(WarnLink* wlink) {m_base_wlink_f void PyObjectPlus::SetDeprecationWarningLinkLast(WarnLink* wlink) {m_base_wlink_last= wlink;} void PyObjectPlus::NullDeprecationWarning() {m_base_wlink_first= m_base_wlink_last= NULL;} -#endif //NO_EXP_PYTHON_EMBEDDING - +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 237f01f5a3a..971f9296912 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -27,8 +27,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef NO_EXP_PYTHON_EMBEDDING - #ifndef _adr_py_lib_h_ // only process once, #define _adr_py_lib_h_ // even if multiply included @@ -45,6 +43,7 @@ * Python defines ------------------------------*/ +#ifndef DISABLE_PYTHON #ifdef USE_MATHUTILS extern "C" { #include "../../blender/python/generic/Mathutils.h" /* so we can have mathutils callbacks */ @@ -463,6 +462,20 @@ typedef struct KX_PYATTRIBUTE_DEF { ------------------------------*/ typedef PyTypeObject * PyParentObject; // Define the PyParent Object +#else // DISABLE_PYTHON + +#define Py_Header \ + public: \ + + +#define Py_HeaderPtr \ + public: \ + + +#endif + + + // By making SG_QList the ultimate parent for PyObjectPlus objects, it // allows to put them in 2 different dynamic lists at the same time // The use of these links is interesting because they free of memory allocation @@ -480,11 +493,12 @@ class PyObjectPlus : public SG_QList public: PyObjectPlus(); - - PyObject *m_proxy; /* actually a PyObjectPlus_Proxy */ virtual ~PyObjectPlus(); // destructor +#ifndef DISABLE_PYTHON + PyObject *m_proxy; /* actually a PyObjectPlus_Proxy */ + /* These static functions are referenced by ALL PyObjectPlus_Proxy types * they take the C++ reference from the PyObjectPlus_Proxy and call * its own virtual py_repr, py_base_dealloc ,etc. functions. @@ -514,16 +528,6 @@ public: (assume object destructor takes care of it) */ static PyObject *NewProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr, bool py_owns); - void InvalidateProxy(); - - /** - * Makes sure any internal data owned by this class is deep copied. - */ - virtual void ProcessReplica(); - - - static bool m_ignore_deprecation_warnings; - static WarnLink* GetDeprecationWarningLinkFirst(void); static WarnLink* GetDeprecationWarningLinkLast(void); static void SetDeprecationWarningFirst(WarnLink* wlink); @@ -536,12 +540,20 @@ public: static void ShowDeprecationWarning_func(const char* method,const char* prop); static void ClearDeprecationWarning(); -}; +#endif + void InvalidateProxy(); -PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict); + /** + * Makes sure any internal data owned by this class is deep copied. + */ + virtual void ProcessReplica(); -#endif // _adr_py_lib_h_ + static bool m_ignore_deprecation_warnings; +}; -#endif //NO_EXP_PYTHON_EMBEDDING +#ifndef DISABLE_PYTHON +PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict); +#endif +#endif // _adr_py_lib_h_ diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript index 26cafb004b2..94af9dcfec8 100644 --- a/source/gameengine/Expressions/SConscript +++ b/source/gameengine/Expressions/SConscript @@ -4,6 +4,12 @@ Import ('env') sources = env.Glob('*.cpp') incs ='. #source/kernel/gen_system #intern/guardedalloc #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']) +defs = [] + +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + +env.BlenderLib ( 'bf_expressions', sources, Split(incs), defs, libtype=['core','player'], priority = [360,80], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h index 069eb8d9c24..a23bb4ec3e2 100644 --- a/source/gameengine/Expressions/StringValue.h +++ b/source/gameengine/Expressions/StringValue.h @@ -39,9 +39,11 @@ public: virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val); virtual void SetValue(CValue* newval) { m_strString = newval->GetText(); SetModified(true); }; virtual CValue* GetReplica(); +#ifndef DISABLE_PYTHON virtual PyObject* ConvertValueToPython() { return PyUnicode_FromString(m_strString.Ptr()); } +#endif // DISABLE_PYTHON private: // data member diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 130317d77e2..6d2dfe2a6e3 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -33,7 +33,7 @@ double CValue::m_sZeroVec[3] = {0.0,0.0,0.0}; -#ifndef NO_EXP_PYTHON_EMBEDDING +#ifndef DISABLE_PYTHON PyTypeObject CValue::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -64,6 +64,8 @@ PyTypeObject CValue::Type = { PyMethodDef CValue::Methods[] = { {NULL,NULL} //Sentinel }; +#endif // DISABLE_PYTHON + /*#define CVALUE_DEBUG*/ #ifdef CVALUE_DEBUG @@ -90,10 +92,6 @@ std::vector<SmartCValueRef> gRefList; CValue::CValue() : PyObjectPlus(), -#else -CValue::CValue() -: -#endif //NO_EXP_PYTHON_EMBEDDING m_pNamedPropertyArray(NULL), m_refcount(1) @@ -526,8 +524,7 @@ CValue* CValue::FindIdentifier(const STR_String& identifiername) return result; } - -#ifndef NO_EXP_PYTHON_EMBEDDING +#ifndef DISABLE_PYTHON PyAttributeDef CValue::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("name", CValue, pyattr_get_name), @@ -618,7 +615,8 @@ PyObject* CValue::ConvertKeysToPython( void ) return pylist; } -#endif //NO_EXP_PYTHON_EMBEDDING +#endif // DISABLE_PYTHON + /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 7d4adcdb64f..f639ae5af78 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -197,19 +197,14 @@ public: -#ifndef NO_EXP_PYTHON_EMBEDDING #include "PyObjectPlus.h" +#ifndef DISABLE_PYTHON #include "object.h" +#endif class CValue : public PyObjectPlus -#else -class CValue -#endif //NO_EXP_PYTHON_EMBEDDING - { -#ifndef NO_EXP_PYTHON_EMBEDDING Py_Header; -#endif //NO_EXP_PYTHON_EMBEDDING public: enum AllocationTYPE { STACKVALUE = 0, @@ -224,9 +219,9 @@ public: // Construction / Destruction -#ifndef NO_EXP_PYTHON_EMBEDDING - CValue(); + +#ifndef DISABLE_PYTHON //static PyObject* PyMake(PyObject*,PyObject*); virtual PyObject *py_repr(void) { @@ -242,10 +237,7 @@ public: static PyObject * pyattr_get_name(void * self, const KX_PYATTRIBUTE_DEF * attrdef); virtual PyObject* ConvertKeysToPython( void ); - -#else - CValue(); -#endif //NO_EXP_PYTHON_EMBEDDING +#endif // DISABLE_PYTHON @@ -416,12 +408,8 @@ public: \ class CPropValue : public CValue { public: -#ifndef NO_EXP_PYTHON_EMBEDDING CPropValue() : CValue(), -#else - CPropValue() : -#endif //NO_EXP_PYTHON_EMBEDDING m_strNewName() { diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 601585f79d6..819af4b56f8 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -34,7 +34,6 @@ SET(INC ../../../source/gameengine/SceneGraph ../../../intern/moto/include ../../../source/gameengine/Rasterizer - ${PYTHON_INC} ) IF(WITH_SDL) @@ -43,5 +42,11 @@ ELSE(WITH_SDL) ADD_DEFINITIONS(-DDISABLE_SDL) ENDIF(WITH_SDL) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_logic "${SRC}" "${INC}") #env.BlenderLib ( 'bf_logic', sources, Split(incs), [], libtype=['game','player'], priority=[30, 110] ) diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 9b04e263350..bd1e5fa7105 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -99,12 +99,12 @@ void SCA_2DFilterActuator::SetShaderText(const char *text) m_shaderText = text; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ - - /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_2DFilterActuator::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -141,3 +141,5 @@ PyAttributeDef SCA_2DFilterActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg), { NULL } //Sentinel }; + +#endif diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp index ac9e238bd64..21380caf6a0 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.cpp +++ b/source/gameengine/GameLogic/SCA_ANDController.cpp @@ -91,7 +91,7 @@ CValue* SCA_ANDController::GetReplica() return replica; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -127,5 +127,5 @@ PyMethodDef SCA_ANDController::Methods[] = { PyAttributeDef SCA_ANDController::Attributes[] = { { NULL } //Sentinel }; - +#endif // DISABLE_PYTHON /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 428362a0a24..c5ba95e2c2c 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -114,6 +114,7 @@ void SCA_ActuatorSensor::Update() } } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -163,4 +164,6 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*) return 1; } +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h index 1a095148500..299684fc955 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -56,11 +56,15 @@ public: virtual void ReParent(SCA_IObject* parent); void Update(); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + static int CheckActuator(void *self, const PyAttributeDef*); + +#endif // DISABLE_PYTHON }; #endif diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index 35b035f6466..898d0f4bb34 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -98,6 +98,8 @@ bool SCA_AlwaysSensor::Evaluate() return result; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -133,4 +135,6 @@ PyAttributeDef SCA_AlwaysSensor::Attributes[] = { { NULL } //Sentinel }; +#endif + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index 0f67ddd56a5..2c2b588abd3 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -124,6 +124,8 @@ bool SCA_DelaySensor::Evaluate() return trigger; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -162,4 +164,6 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp index 60969300474..91135079fe6 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp +++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp @@ -36,6 +36,8 @@ #include "InputParser.h" #include "MT_Transform.h" // for fuzzyZero +#include <stdio.h> + #ifdef HAVE_CONFIG_H #include <config.h> #endif diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp index 0338213b3cf..13deed12dd1 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.cpp +++ b/source/gameengine/GameLogic/SCA_IActuator.cpp @@ -27,6 +27,7 @@ */ #include "SCA_IActuator.h" +#include <stdio.h> #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 7cfd2adc1d0..65c9c4d0f57 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -33,6 +33,8 @@ #include "PyObjectPlus.h" #include "../Ketsji/KX_PythonSeq.h" /* not nice, only need for KX_PythonSeq_CreatePyObject */ +#include <stdio.h> + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -196,6 +198,8 @@ void SCA_IController::ApplyState(unsigned int state) } } +#ifndef DISABLE_PYTHON + /* Python api */ PyTypeObject SCA_IController::Type = { @@ -247,3 +251,4 @@ PyObject* SCA_IController::pyattr_get_actuators(void *self_v, const KX_PYATTRIBU { return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_ACTUATORS); } +#endif // DISABLE_PYTHON diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h index 202921c6986..48514121661 100644 --- a/source/gameengine/GameLogic/SCA_IController.h +++ b/source/gameengine/GameLogic/SCA_IController.h @@ -98,10 +98,12 @@ public: } } + +#ifndef DISABLE_PYTHON 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); static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - +#endif // DISABLE_PYTHON }; #endif diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index f679d0ee487..6502fc6de41 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -173,6 +173,7 @@ CValue* SCA_ILogicBrick::GetEvent() +#ifndef DISABLE_PYTHON /* python stuff */ @@ -255,3 +256,5 @@ PyObject* SCA_ILogicBrick::BoolToPyArg(bool boolarg) { return PyLong_FromSsize_t(boolarg? KX_TRUE: KX_FALSE); } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index ac533335f0b..11885f988f3 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -125,6 +125,7 @@ public: static class SCA_LogicManager* m_sCurrentLogicManager; +#ifndef DISABLE_PYTHON // python methods static PyObject* pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); @@ -147,8 +148,9 @@ protected: /** Convert a a c++ value to KX_TRUE, KX_FALSE in Python. */ PyObject* BoolToPyArg(bool); - +#endif // DISABLE_PYTHON + }; #endif diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index fbf66b64d08..e63b616cab0 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -307,7 +307,7 @@ void SCA_IObject::SetState(unsigned int state) } } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -345,3 +345,5 @@ PyMethodDef SCA_IObject::Methods[] = { PyAttributeDef SCA_IObject::Attributes[] = { { NULL } //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index 64ea0a76af1..60335f8fe01 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -41,7 +41,9 @@ class SCA_ISensor; class SCA_IController; class SCA_IActuator; +#ifndef DISABLE_PYTHON template<class T> T PyVecTo(PyObject*); +#endif typedef std::vector<SCA_ISensor *> SCA_SensorList; typedef std::vector<SCA_IController *> SCA_ControllerList; diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 497a5d1095a..877563e3161 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -35,6 +35,8 @@ // needed for IsTriggered() #include "SCA_PythonController.h" +#include <stdio.h> + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -288,6 +290,9 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) } } } + +#ifndef DISABLE_PYTHON + /* ----------------------------------------------- */ /* Python Functions */ /* ----------------------------------------------- */ @@ -379,5 +384,6 @@ int SCA_ISensor::pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrde self->m_level = false; return 0; } +#endif // DISABLE_PYTHON /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 742b05bd88b..fce5f340be1 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -171,6 +171,7 @@ public: bool IsNoLink() const { return !m_links; } +#ifndef DISABLE_PYTHON /* Python functions: */ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,reset); @@ -178,6 +179,7 @@ public: static PyObject* pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); +#endif // DISABLE_PYTHON }; #endif //__SCA_ISENSOR diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 4936b380352..9ac64b7f31e 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -32,6 +32,7 @@ #include "PyObjectPlus.h" +#include <stdio.h> #include <iostream> @@ -244,6 +245,7 @@ bool SCA_JoystickSensor::isValid(SCA_JoystickSensor::KX_JOYSENSORMODE m) return res; } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -413,3 +415,5 @@ PyObject* SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTR SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); return PyBool_FromLong( joy ? joy->Connected() : 0 ); } + +#endif diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index b793c591ac1..49ca58ee14f 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -117,6 +117,8 @@ public: return m_joyindex; } +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -155,6 +157,8 @@ public: return 0; } +#endif // DISABLE_PYTHON + }; #endif diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index d2e3871fec2..dcad65e6459 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -403,6 +403,7 @@ void SCA_KeyboardSensor::LogKeystrokes(void) } } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python Functions */ @@ -495,6 +496,7 @@ PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU return resultlist; } +#endif // DISABLE_PYTHON /* Accessed from python */ diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index d7e0f301a9d..0ce08b3e408 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -103,6 +103,7 @@ public: virtual bool IsPositiveTrigger(); bool TriggerOnAllKeys(); +#ifndef DISABLE_PYTHON /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -113,6 +114,7 @@ public: KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus); static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); +#endif }; diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index b782c6dfb93..d93f2e70e36 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -305,6 +305,9 @@ void SCA_LogicManager::EndFrame() void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor) { controller->Activate(m_triggeredControllerSet); + +#ifndef DISABLE_PYTHON + // so that the controller knows which sensor has activited it // only needed for python controller // Note that this is safe even if the controller is subclassed. @@ -313,6 +316,7 @@ void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_I SCA_PythonController* pythonController = (SCA_PythonController*)controller; pythonController->AddTriggeredSensor(sensor); } +#endif } SCA_EventManager* SCA_LogicManager::FindEventManager(int eventmgrtype) diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 9d32682eaa9..466b8f7e741 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -57,7 +57,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, m_mousemode = mousemode; m_triggermode = true; - UpdateHotkey(this, NULL); + UpdateHotkey(this); Init(); } @@ -72,7 +72,7 @@ SCA_MouseSensor::~SCA_MouseSensor() /* Nothing to be done here. */ } -int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*) +void SCA_MouseSensor::UpdateHotkey(void *self) { // gosh, this function is so damn stupid // its here because of a design mistake in the mouse sensor, it should only @@ -100,9 +100,6 @@ int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*) default: ; /* ignore, no hotkey */ } - // return value is used in py_setattro(), - // 0=attribute checked ok (see Attributes array definition) - return 0; } CValue* SCA_MouseSensor::GetReplica() @@ -239,6 +236,8 @@ bool SCA_MouseSensor::isValid(SCA_MouseSensor::KX_MOUSESENSORMODE m) return ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX)); } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -296,10 +295,20 @@ PyMethodDef SCA_MouseSensor::Methods[] = { {NULL,NULL} //Sentinel }; +int SCA_MouseSensor::UpdateHotkeyPy(void *self, const PyAttributeDef*) +{ + UpdateHotkey(self); + // return value is used in py_setattro(), + // 0=attribute checked ok (see Attributes array definition) + return 0; +} + PyAttributeDef SCA_MouseSensor::Attributes[] = { - KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkey), + KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkeyPy), KX_PYATTRIBUTE_SHORT_LIST_RO("position",SCA_MouseSensor,m_x,2), { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h index a679e605428..25b3a6c2e6e 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.h +++ b/source/gameengine/GameLogic/SCA_MouseSensor.h @@ -86,8 +86,6 @@ class SCA_MouseSensor : public SCA_ISensor bool isValid(KX_MOUSESENSORMODE); - static int UpdateHotkey(void *self, const PyAttributeDef*); - SCA_MouseSensor(class SCA_MouseManager* keybdmgr, int startx,int starty, short int mousemode, @@ -102,14 +100,20 @@ class SCA_MouseSensor : public SCA_ISensor SCA_IInputDevice::KX_EnumInputs GetHotKey(); void setX(short x); void setY(short y); - + + static void UpdateHotkey(void *self); + + +#ifndef DISABLE_PYTHON /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ + static int UpdateHotkeyPy(void *self, const PyAttributeDef *); + // get button status KX_PYMETHOD_DOC_O(SCA_MouseSensor,getButtonStatus); - +#endif }; #endif //__KX_MOUSESENSOR diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp index c971c06fadd..99c74e6d737 100644 --- a/source/gameengine/GameLogic/SCA_NANDController.cpp +++ b/source/gameengine/GameLogic/SCA_NANDController.cpp @@ -91,7 +91,7 @@ CValue* SCA_NANDController::GetReplica() return replica; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -128,4 +128,6 @@ PyAttributeDef SCA_NANDController::Attributes[] = { { NULL } //Sentinel }; +#endif + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp index 7a8b09e4bec..a84453de977 100644 --- a/source/gameengine/GameLogic/SCA_NORController.cpp +++ b/source/gameengine/GameLogic/SCA_NORController.cpp @@ -91,7 +91,7 @@ CValue* SCA_NORController::GetReplica() return replica; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -128,4 +128,6 @@ PyAttributeDef SCA_NORController::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp index 12e2f610986..0f750eedf77 100644 --- a/source/gameengine/GameLogic/SCA_ORController.cpp +++ b/source/gameengine/GameLogic/SCA_ORController.cpp @@ -87,6 +87,8 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr) } } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -122,4 +124,6 @@ PyAttributeDef SCA_ORController::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 2a3e600a653..2b480a8e8cb 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -221,6 +221,7 @@ void SCA_PropertyActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map) } } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -260,4 +261,6 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = { { NULL } //Sentinel }; +#endif + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 9c09c8410fb..40c5ac687f6 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -290,16 +290,18 @@ CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername) return GetParent()->FindIdentifier(identifiername); } +#ifndef DISABLE_PYTHON + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*) { /* There is no type checking at this moment, unfortunately... */ return 0; } -/* ------------------------------------------------------------------------- */ -/* Python functions */ -/* ------------------------------------------------------------------------- */ - /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PropertySensor::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -334,4 +336,6 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index a5bbfc8438b..cd8a6713148 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -84,6 +84,8 @@ public: virtual bool IsPositiveTrigger(); virtual CValue* FindIdentifier(const STR_String& identifiername); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -92,6 +94,8 @@ public: * Test whether this is a sensible value (type check) */ static int validValueForProperty(void* self, const PyAttributeDef*); + +#endif }; #endif diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index ecaa8c508db..3a70d1485dc 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -34,8 +34,12 @@ #include "SCA_ISensor.h" #include "SCA_IActuator.h" #include "PyObjectPlus.h" + +#ifndef DISABLE_PYTHON #include "compile.h" #include "eval.h" +#endif // DISABLE_PYTHON + #include <algorithm> @@ -49,13 +53,18 @@ SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL; SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode) : SCA_IController(gameobj), +#ifndef DISABLE_PYTHON m_bytecode(NULL), m_function(NULL), +#endif m_function_argc(0), m_bModified(true), m_debug(false), - m_mode(mode), - m_pythondictionary(NULL) + m_mode(mode) +#ifndef DISABLE_PYTHON + , m_pythondictionary(NULL) +#endif + { } @@ -78,6 +87,8 @@ int SCA_PythonController::Release() SCA_PythonController::~SCA_PythonController() { + +#ifndef DISABLE_PYTHON //printf("released python byte script\n"); Py_XDECREF(m_bytecode); @@ -88,6 +99,7 @@ SCA_PythonController::~SCA_PythonController() PyDict_Clear(m_pythondictionary); Py_DECREF(m_pythondictionary); } +#endif } @@ -95,7 +107,8 @@ SCA_PythonController::~SCA_PythonController() CValue* SCA_PythonController::GetReplica() { SCA_PythonController* replica = new SCA_PythonController(*this); - + +#ifndef DISABLE_PYTHON /* why is this needed at all??? - m_bytecode is NULL'd below so this doesnt make sense * but removing it crashes blender (with YoFrankie). so leave in for now - Campbell */ Py_XINCREF(replica->m_bytecode); @@ -113,6 +126,7 @@ CValue* SCA_PythonController::GetReplica() if (m_pythondictionary) Py_INCREF(replica->m_pythondictionary); */ +#endif // this will copy properties and so on... replica->ProcessReplica(); @@ -136,7 +150,7 @@ void SCA_PythonController::SetScriptName(const STR_String& name) } - +#ifndef DISABLE_PYTHON void SCA_PythonController::SetDictionary(PyObject* pythondictionary) { if (m_pythondictionary) @@ -151,6 +165,7 @@ void SCA_PythonController::SetDictionary(PyObject* pythondictionary) PyDict_SetItemString(m_pythondictionary, "__file__", PyUnicode_FromString(m_scriptName.Ptr())); } +#endif int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor) { @@ -160,6 +175,8 @@ int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor) return 0; } +#ifndef DISABLE_PYTHON + /* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */ PyObject* SCA_PythonController::sPyGetCurrentController(PyObject *self) { @@ -360,6 +377,7 @@ bool SCA_PythonController::Import() return true; } + void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) { m_sCurrentController = this; @@ -514,5 +532,13 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D return PY_SET_ATTR_SUCCESS; } +#else // DISABLE_PYTHON + +void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) +{ + /* intentionally blank */ +} + +#endif // DISABLE_PYTHON /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 9311b3f355e..f6a1064b77d 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -42,8 +42,10 @@ class SCA_IObject; class SCA_PythonController : public SCA_IController { Py_Header; +#ifndef DISABLE_PYTHON struct _object * m_bytecode; /* SCA_PYEXEC_SCRIPT only */ PyObject* m_function; /* SCA_PYEXEC_MODULE only */ +#endif int m_function_argc; bool m_bModified; bool m_debug; /* use with SCA_PYEXEC_MODULE for reloading every logic run */ @@ -53,9 +55,10 @@ class SCA_PythonController : public SCA_IController protected: STR_String m_scriptText; STR_String m_scriptName; +#ifndef DISABLE_PYTHON PyObject* m_pythondictionary; /* for SCA_PYEXEC_SCRIPT only */ PyObject* m_pythonfunction; /* for SCA_PYEXEC_MODULE only */ - +#endif std::vector<class SCA_ISensor*> m_triggeredSensors; public: @@ -80,7 +83,9 @@ class SCA_PythonController : public SCA_IController void SetScriptText(const STR_String& text); void SetScriptName(const STR_String& name); +#ifndef DISABLE_PYTHON void SetDictionary(PyObject* pythondictionary); +#endif void SetDebug(bool debug) { m_debug = debug; } void AddTriggeredSensor(class SCA_ISensor* sensor) { m_triggeredSensors.push_back(sensor); } @@ -89,7 +94,7 @@ class SCA_PythonController : public SCA_IController bool Import(); void ErrorPrint(const char *error_msg); - +#ifndef DISABLE_PYTHON static const char* sPyGetCurrentController__doc__; static PyObject* sPyGetCurrentController(PyObject* self); static const char* sPyAddActiveActuator__doc__; @@ -106,8 +111,7 @@ class SCA_PythonController : public SCA_IController static PyObject* pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - - +#endif }; #endif //KX_PYTHONCONTROLLER_H diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 8f9482b7826..fa85bdd768e 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -309,6 +309,8 @@ void SCA_RandomActuator::enforceConstraints() { } } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -546,5 +548,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential, enforceConstraints(); Py_RETURN_NONE; } - + +#endif + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index f84c44b43c9..2eb9b8d5d14 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -91,6 +91,8 @@ class SCA_RandomActuator : public SCA_IActuator virtual CValue* GetReplica(); virtual void ProcessReplica(); + +#ifndef DISABLE_PYTHON /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ @@ -109,6 +111,9 @@ class SCA_RandomActuator : public SCA_IActuator KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatUniform); KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatNormal); KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential); + +#endif // DISABLE_PYTHON + }; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */ #endif diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 890875e61c6..922e44b1c1d 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -124,6 +124,8 @@ bool SCA_RandomSensor::Evaluate() return evaluateResult; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -178,4 +180,6 @@ int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *at return PY_SET_ATTR_SUCCESS; } +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index f93cf57370e..8126824c3dd 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -56,13 +56,15 @@ public: virtual bool IsPositiveTrigger(); virtual void Init(); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ 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); - +#endif }; #endif //__KX_RANDOMSENSOR diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp index 17350feb98b..e726a49347c 100644 --- a/source/gameengine/GameLogic/SCA_XNORController.cpp +++ b/source/gameengine/GameLogic/SCA_XNORController.cpp @@ -95,7 +95,7 @@ CValue* SCA_XNORController::GetReplica() return replica; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -132,4 +132,6 @@ PyAttributeDef SCA_XNORController::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp index a6a7cc25897..71cc4374e95 100644 --- a/source/gameengine/GameLogic/SCA_XORController.cpp +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -95,7 +95,7 @@ CValue* SCA_XORController::GetReplica() return replica; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -131,5 +131,6 @@ PyMethodDef SCA_XORController::Methods[] = { PyAttributeDef SCA_XORController::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON /* eof */ diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index 1530c71c7f3..3840754ed06 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -7,9 +7,6 @@ incs = '. #/source/kernel/gen_system #/intern/string' incs += ' #/source/gameengine/Expressions #/intern/moto/include' incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph' -incs += ' ' + env['BF_PYTHON_INC'] - - defs = [] if env['WITH_BF_SDL']: @@ -17,6 +14,11 @@ if env['WITH_BF_SDL']: else: defs.append('DISABLE_SDL') +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): if env['BF_DEBUG']: defs.append('_DEBUG') diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index dd5a48c2b55..99eda4cb592 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -58,8 +58,14 @@ incs = ['.', # 'unix/GPU_System.cpp'] # gp_common_env.Append ( CPPPATH = ['unix']) -incs += Split(env['BF_PYTHON_INC']) +defs = [] + +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + 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']) +env.BlenderLib (libname='gp_common', sources=source_files, includes=incs, defines = defs, libtype=['player'], priority=[5], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index fdd7792b72a..cfb827cf8c3 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -40,9 +40,13 @@ incs = ['.', '#source/blender/gpu', '#extern/glew/include'] -incs += Split(env['BF_PYTHON_INC']) - defs = [] + +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index f548bcdaae1..35eb5dc124a 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -728,6 +728,8 @@ void BL_Shader::SetUniform(int uniform, const int* val, int len) } } +#ifndef DISABLE_PYTHON + PyMethodDef BL_Shader::Methods[] = { // creation @@ -1409,4 +1411,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" ) return NULL; } +#endif // DISABLE_PYTHON + // eof diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index b2610d7762a..ebd2e491f35 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -222,6 +222,7 @@ public: void SetUniform(int uniform, const int val); // Python interface +#ifndef DISABLE_PYTHON virtual PyObject* py_repr(void) { return PyUnicode_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", vertProg, fragProg); } // ----------------------------------- @@ -249,6 +250,7 @@ public: KX_PYMETHOD_DOC( BL_Shader, setUniformDef ); KX_PYMETHOD_DOC( BL_Shader, setAttrib ); KX_PYMETHOD_DOC( BL_Shader, setSampler); +#endif }; #endif//__BL_SHADER_H__ diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 01d369bc7a9..857be4bd827 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -59,7 +59,6 @@ SET(INC ../../../source/blender/gpu ../../../extern/bullet2/src ../../../extern/glew/include - ${PYTHON_INC} ) IF(WITH_SDL) @@ -68,5 +67,11 @@ ELSE(WITH_SDL) ADD_DEFINITIONS(-DDISABLE_SDL) ENDIF(WITH_SDL) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_ketsji "${SRC}" "${INC}") #env.BlenderLib ( 'bf_ketsji', sources, Split(incs), [], libtype=['game','player'], priority=[25, 72], compileflags = cflags ) diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt index b89b0dcff9f..1a608713c51 100644 --- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt +++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt @@ -36,8 +36,13 @@ SET(INC ../../../../source/gameengine/Expressions ../../../../source/gameengine/SceneGraph ../../../../source/gameengine/Network - ${PYTHON_INC} ) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(kx_network "${SRC}" "${INC}") #env.BlenderLib ( 'kx_network', Split(sources), Split(incs), defines=[],libtype=['game2', 'player'], priority=[5, 155] ) diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index 1cfab87d78b..04a7f2b3603 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -95,6 +95,8 @@ CValue* KX_NetworkMessageActuator::GetReplica() return replica; } +#ifndef DISABLE_PYTHON + /* -------------------------------------------------------------------- */ /* Python interface --------------------------------------------------- */ /* -------------------------------------------------------------------- */ @@ -133,3 +135,5 @@ PyAttributeDef KX_NetworkMessageActuator::Attributes[] = { KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body), { NULL } //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 392e9dd9d1b..18dc416cc1b 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -158,6 +158,8 @@ bool KX_NetworkMessageSensor::IsPositiveTrigger() return m_IsUp; } +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -216,3 +218,5 @@ PyObject* KX_NetworkMessageSensor::pyattr_get_subjects(void *self_v, const KX_PY return (new CListValue())->NewProxy(true); } } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index d8a0651d2f1..3a8fe760bb9 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -66,6 +66,8 @@ public: virtual void Init(); void EndFrame(); +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------- */ /* Python interface -------------------------------------------- */ /* ------------------------------------------------------------- */ @@ -74,6 +76,8 @@ public: 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); +#endif // DISABLE_PYTHON + }; #endif //__KX_NETWORKMESSAGE_SENSOR_H diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript index 8f88511acca..64d00489c89 100644 --- a/source/gameengine/Ketsji/KXNetwork/SConscript +++ b/source/gameengine/Ketsji/KXNetwork/SConscript @@ -7,6 +7,11 @@ incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/ incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions' incs += ' #source/gameengine/Network #source/gameengine/SceneGraph' -incs += ' ' + env['BF_PYTHON_INC'] +defs = [] -env.BlenderLib ( 'bf_network', Split(sources), Split(incs), defines=[],libtype=['core','player'], priority=[400,125], cxx_compileflags=env['BGE_CXXFLAGS']) +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + +env.BlenderLib ( 'bf_network', Split(sources), Split(incs), defines=defs,libtype=['core','player'], priority=[400,125], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp b/source/gameengine/Ketsji/KX_ArmatureSensor.cpp index 1b759bda28e..40e16744d71 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.cpp @@ -153,6 +153,7 @@ bool KX_ArmatureSensor::Evaluate() return (reset) ? true : false; } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -203,3 +204,5 @@ PyObject* KX_ArmatureSensor::pyattr_get_constraint(void *self, const struct KX_P } Py_RETURN_NONE; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.h b/source/gameengine/Ketsji/KX_ArmatureSensor.h index 2af002afff9..6dc6991873a 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.h +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.h @@ -66,11 +66,15 @@ public: // identify the constraint that this actuator controls void FindConstraint(); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ static PyObject* pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); +#endif // DISABLE_PYTHON + private: struct bConstraint* m_constraint; STR_String m_posechannel; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index be3d4906761..f5086ca89ac 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -777,6 +777,18 @@ void KX_BlenderMaterial::UpdateIPO( mMaterial->ref = (float)(ref); } +void KX_BlenderMaterial::SetBlenderGLSLShader(int layer) +{ + if(!mBlenderShader) + mBlenderShader = new BL_BlenderShader(mScene, mMaterial->material, layer); + + if(!mBlenderShader->Ok()) { + delete mBlenderShader; + mBlenderShader = 0; + } +} + +#ifndef DISABLE_PYTHON PyMethodDef KX_BlenderMaterial::Methods[] = { @@ -870,18 +882,6 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") return NULL; } - -void KX_BlenderMaterial::SetBlenderGLSLShader(int layer) -{ - if(!mBlenderShader) - mBlenderShader = new BL_BlenderShader(mScene, mMaterial->material, layer); - - if(!mBlenderShader->Ok()) { - delete mBlenderShader; - mBlenderShader = 0; - } -} - KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()") { return PyLong_FromSsize_t( GetMaterialIndex() ); @@ -941,3 +941,4 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( GameLogic.sr return NULL; } +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index cdbdc4bd429..0946cd320c5 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -83,6 +83,7 @@ public: MT_Scalar ref, MT_Scalar emit, MT_Scalar alpha ); +#ifndef DISABLE_PYTHON // -------------------------------- virtual PyObject* py_repr(void) { return PyUnicode_FromString(mMaterial->matname.ReadPtr()); } @@ -92,6 +93,7 @@ public: KX_PYMETHOD_DOC( KX_BlenderMaterial, setTexture ); KX_PYMETHOD_DOC( KX_BlenderMaterial, setBlending ); +#endif // DISABLE_PYTHON // -------------------------------- // pre calculate to avoid pops/lag at startup diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 0832809772d..384125119a9 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -481,6 +481,7 @@ int KX_Camera::GetViewportTop() const return m_camdata.m_viewporttop; } +#ifndef DISABLE_PYTHON //---------------------------------------------------------------------------- //Python @@ -1030,4 +1031,4 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay, return NULL; } - +#endif diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index bf7a39d93c8..71c66efaa87 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -41,8 +41,10 @@ #include "IntValue.h" #include "RAS_CameraData.h" +#ifndef DISABLE_PYTHON /* utility conversion function */ bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok, const char *error_prefix); +#endif class KX_Camera : public KX_GameObject { @@ -267,6 +269,7 @@ public: virtual int GetGameObjectType() { return OBJ_CAMERA; } +#ifndef DISABLE_PYTHON KX_PYMETHOD_DOC_VARARGS(KX_Camera, sphereInsideFrustum); KX_PYMETHOD_DOC_O(KX_Camera, boxInsideFrustum); KX_PYMETHOD_DOC_O(KX_Camera, pointInsideFrustum); @@ -304,6 +307,7 @@ public: static PyObject* pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); +#endif }; #endif //__KX_CAMERA diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 99618fab8e3..3b02227451c 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -350,6 +350,8 @@ CValue *KX_CameraActuator::findObject(char *obName) return NULL; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -416,4 +418,6 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_SUCCESS; } +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index e047e3724ea..875922b36e7 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -114,6 +114,8 @@ private : /** Methods inherited from SCA_ILogicBrick */ virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -122,6 +124,8 @@ private : 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); +#endif // DISABLE_PYTHON + }; #endif //__KX_CAMERAACTUATOR diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index ea0b9f4f1e2..7bbc53211b6 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -38,6 +38,8 @@ #include "KX_RayCast.h" #include "KX_PythonInit.h" // KX_GetActiveScene +#include <stdio.h> + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -559,6 +561,8 @@ bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE return res; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -618,4 +622,6 @@ int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PY return 0; } +#endif + /* eof */ diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index 54e083b48f0..aee7b3cc44c 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -26,7 +26,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ -#include <Python.h> + #include "PyObjectPlus.h" #include "KX_ConstraintWrapper.h" #include "PHY_IPhysicsEnvironment.h" @@ -49,6 +49,8 @@ KX_ConstraintWrapper::~KX_ConstraintWrapper() { } +#ifndef DISABLE_PYTHON + PyObject* KX_ConstraintWrapper::PyGetConstraintId() { return PyLong_FromSsize_t(m_constraintId); @@ -115,3 +117,5 @@ PyAttributeDef KX_ConstraintWrapper::Attributes[] = { //KX_PYATTRIBUTE_TODO("constraintId"), { NULL } //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h index 74670944415..300455aef6b 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h @@ -40,9 +40,11 @@ public: virtual ~KX_ConstraintWrapper (); int getConstraintId() { return m_constraintId;}; +#ifndef DISABLE_PYTHON KX_PYMETHOD_NOARGS(KX_ConstraintWrapper,GetConstraintId); KX_PYMETHOD(KX_ConstraintWrapper,SetParam); KX_PYMETHOD(KX_ConstraintWrapper,GetParam); +#endif private: int m_constraintId; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index daa31379985..c0d7b639077 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -18,13 +18,16 @@ http://www.gnu.org/copyleft/lesser.txt. Contributor(s): Dalai Felinto This code is originally inspired on some of the ideas and codes from Paul Bourke. -Developed as part of a Research and Development project for SAT - La Société des arts technologiques. +Developed as part of a Research and Development project for SAT - La Soci�t� des arts technologiques. ----------------------------------------------------------------------------- */ #include "KX_Dome.h" +#ifndef DISABLE_PYTHON #include <structmember.h> +#endif + #include <float.h> #include <math.h> @@ -558,7 +561,7 @@ void KX_Dome::CreateMeshDome180(void) m_radangle = m_angle * M_PI/180.0;//calculates the radians angle, used for flattening - //creating faces for the env mapcube 180º Dome + //creating faces for the env mapcube 180� Dome // Top Face - just a triangle cubetop[0].verts[0][0] = -sqrt_2 / 2.0; cubetop[0].verts[0][1] = 0.0; @@ -743,7 +746,7 @@ void KX_Dome::CreateMeshDome250(void) m_radangle = m_angle * M_PI/180.0;//calculates the radians angle, used for flattening /* verts_height is the exactly needed height of the cube faces (not always 1.0). -When we want some horizontal information (e.g. for horizontal 220º domes) we don't need to create and tesselate the whole cube. +When we want some horizontal information (e.g. for horizontal 220� domes) we don't need to create and tesselate the whole cube. Therefore the lateral cube faces could be small, and the tesselate mesh would be completely used. (if we always worked with verts_height = 1.0, we would be discarding a lot of the calculated and tesselated geometry). @@ -760,7 +763,7 @@ Then we need to multiply it by sqrt(2.0) to get the coordinate of the verts on t uv_height = uv_ratio * ((verts_height/2) + 0.5); uv_base = uv_ratio * (1.0 - ((verts_height/2) + 0.5)); - //creating faces for the env mapcube 180º Dome + //creating faces for the env mapcube 180� Dome // Front Face - 2 triangles cubefront[0].verts[0][0] =-1.0; cubefront[0].verts[0][1] = 1.0; @@ -1101,7 +1104,7 @@ void KX_Dome::CreateMeshPanorama(void) nfacesbottom = 2; - /* Left Back (135º) face - two triangles */ + /* Left Back (135�) face - two triangles */ cubeleftback[0].verts[0][0] = 0; cubeleftback[0].verts[0][1] = -sqrt_2; @@ -1223,7 +1226,7 @@ void KX_Dome::CreateMeshPanorama(void) nfacesright = 2; - /* Right Back (-135º) face - two triangles */ + /* Right Back (-135�) face - two triangles */ cuberightback[0].verts[0][0] = sqrt_2; cuberightback[0].verts[0][1] = 0; cuberightback[0].verts[0][2] = -1.0; @@ -1352,7 +1355,7 @@ void KX_Dome::FlattenDome(MT_Vector3 verts[3]) void KX_Dome::FlattenPanorama(MT_Vector3 verts[3]) { -// it creates a full spherical panoramic (360º) +// it creates a full spherical panoramic (360�) int i; double phi; bool edge=false; @@ -1445,7 +1448,7 @@ void KX_Dome::SplitFace(vector <DomeFace>& face, int *nfaces) void KX_Dome::CalculateFrustum(KX_Camera * cam) { /* - // manually creating a 90º Field of View Frustum + // manually creating a 90� Field of View Frustum the original formula: top = tan(fov*3.14159/360.0) * near [for fov in degrees] @@ -1466,7 +1469,7 @@ void KX_Dome::CalculateFrustum(KX_Camera * cam) m_frustrum.camfar = cam->GetCameraFar(); // float top = tan(90.0*MT_PI/360.0) * m_frustrum.camnear; - float top = m_frustrum.camnear; // for deg = 90º, tan = 1 + float top = m_frustrum.camnear; // for deg = 90�, tan = 1 m_frustrum.x1 = -top; m_frustrum.x2 = top; @@ -1481,9 +1484,9 @@ void KX_Dome::CalculateFrustum(KX_Camera * cam) void KX_Dome::CalculateCameraOrientation() { /* -Uses 4 cameras for angles up to 180º -Uses 5 cameras for angles up to 250º -Uses 6 cameras for angles up to 360º +Uses 4 cameras for angles up to 180� +Uses 5 cameras for angles up to 250� +Uses 6 cameras for angles up to 360� */ int i; float deg45 = MT_PI / 4; @@ -1494,22 +1497,22 @@ Uses 6 cameras for angles up to 360º || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR)){ - m_locRot[0] = MT_Matrix3x3( // 90º - Top + m_locRot[0] = MT_Matrix3x3( // 90� - Top c, -s, 0.0, 0.0,0.0, -1.0, s, c, 0.0); - m_locRot[1] = MT_Matrix3x3( // 90º - Bottom + m_locRot[1] = MT_Matrix3x3( // 90� - Bottom -s, c, 0.0, 0.0,0.0, 1.0, s, c, 0.0); - m_locRot[2] = MT_Matrix3x3( // 45º - Left + m_locRot[2] = MT_Matrix3x3( // 45� - Left c, 0.0, s, 0, 1.0, 0.0, -s, 0.0, c); - m_locRot[3] = MT_Matrix3x3( // 45º - Right + m_locRot[3] = MT_Matrix3x3( // 45� - Right c, 0.0, -s, 0.0, 1.0, 0.0, s, 0.0, c); @@ -1518,32 +1521,32 @@ Uses 6 cameras for angles up to 360º || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR))){ - m_locRot[0] = MT_Matrix3x3( // 90º - Top + m_locRot[0] = MT_Matrix3x3( // 90� - Top 1.0, 0.0, 0.0, 0.0, 0.0,-1.0, 0.0, 1.0, 0.0); - m_locRot[1] = MT_Matrix3x3( // 90º - Bottom + m_locRot[1] = MT_Matrix3x3( // 90� - Bottom 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,-1.0, 0.0); - m_locRot[2] = MT_Matrix3x3( // -90º - Left + m_locRot[2] = MT_Matrix3x3( // -90� - Left 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0); - m_locRot[3] = MT_Matrix3x3( // 90º - Right + m_locRot[3] = MT_Matrix3x3( // 90� - Right 0.0, 0.0,-1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0); - m_locRot[4] = MT_Matrix3x3( // 0º - Front + m_locRot[4] = MT_Matrix3x3( // 0� - Front 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); - m_locRot[5] = MT_Matrix3x3( // 180º - Back - USED for ENVMAP only + m_locRot[5] = MT_Matrix3x3( // 180� - Back - USED for ENVMAP only -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,-1.0); @@ -1560,22 +1563,22 @@ Uses 6 cameras for angles up to 360º 0.0 ,0.0, 1.0, s, -c, 0.0); - m_locRot[2] = MT_Matrix3x3( // 45º - Left + m_locRot[2] = MT_Matrix3x3( // 45� - Left -s, 0.0, c, 0, 1.0, 0.0, -c, 0.0, -s); - m_locRot[3] = MT_Matrix3x3( // 45º - Right + m_locRot[3] = MT_Matrix3x3( // 45� - Right c, 0.0, s, 0, 1.0, 0.0, -s, 0.0, c); - m_locRot[4] = MT_Matrix3x3( // 135º - LeftBack + m_locRot[4] = MT_Matrix3x3( // 135� - LeftBack -s, 0.0, -c, 0.0, 1.0, 0.0, c, 0.0, -s); - m_locRot[5] = MT_Matrix3x3( // 135º - RightBack + m_locRot[5] = MT_Matrix3x3( // 135� - RightBack c, 0.0, -s, 0.0, 1.0, 0.0, s, 0.0, c); @@ -1734,7 +1737,7 @@ void KX_Dome::DrawEnvMap(void) glVertex3f(-onebythree,-2 * onebythree, 3.0f); glEnd(); - // domefacesId[2] => -90º (left) + // domefacesId[2] => -90� (left) glBindTexture(GL_TEXTURE_2D, domefacesId[2]); glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); @@ -1747,7 +1750,7 @@ void KX_Dome::DrawEnvMap(void) glVertex3f(-onebythree, 0.0f, 3.0f); glEnd(); - // domefacesId[3] => 90º (right) + // domefacesId[3] => 90� (right) glBindTexture(GL_TEXTURE_2D, domefacesId[3]); glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); @@ -1760,7 +1763,7 @@ void KX_Dome::DrawEnvMap(void) glVertex3f(1.0f, 0.0f, 3.0f); glEnd(); - // domefacesId[4] => 0º (front) + // domefacesId[4] => 0� (front) glBindTexture(GL_TEXTURE_2D, domefacesId[4]); glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); @@ -1773,7 +1776,7 @@ void KX_Dome::DrawEnvMap(void) glVertex3f(1.0f, -2 * onebythree, 3.0f); glEnd(); - // domefacesId[5] => 180º (back) + // domefacesId[5] => 180� (back) glBindTexture(GL_TEXTURE_2D, domefacesId[5]); glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); @@ -1950,19 +1953,19 @@ void KX_Dome::DrawPanorama(void) glBindTexture(GL_TEXTURE_2D, domefacesId[1]); GLDrawTriangles(cubebottom, nfacesbottom); - // domefacesId[1] => -45º (left) + // domefacesId[1] => -45� (left) glBindTexture(GL_TEXTURE_2D, domefacesId[2]); GLDrawTriangles(cubeleft, nfacesleft); - // domefacesId[2] => 45º (right) + // domefacesId[2] => 45� (right) glBindTexture(GL_TEXTURE_2D, domefacesId[3]); GLDrawTriangles(cuberight, nfacesright); - // domefacesId[0] => -135º (leftback) + // domefacesId[0] => -135� (leftback) glBindTexture(GL_TEXTURE_2D, domefacesId[4]); GLDrawTriangles(cubeleftback, nfacesleftback); - // domefacesId[3] => 135º (rightback) + // domefacesId[3] => 135� (rightback) glBindTexture(GL_TEXTURE_2D, domefacesId[5]); GLDrawTriangles(cuberightback, nfacesrightback); } diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 71980a3347e..bc0f875bca6 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -36,6 +36,9 @@ #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" /* for config load/saving */ +#include <stdio.h> +#include <stdlib.h> + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -125,6 +128,7 @@ bool KX_GameActuator::Update() } case KX_GAME_SAVECFG: { +#ifndef DISABLE_PYTHON if (m_ketsjiengine) { char mashal_path[512]; @@ -152,9 +156,11 @@ bool KX_GameActuator::Update() delete [] marshal_buffer; } break; +#endif // DISABLE_PYTHON } case KX_GAME_LOADCFG: { +#ifndef DISABLE_PYTHON if (m_ketsjiengine) { char mashal_path[512]; @@ -189,6 +195,7 @@ bool KX_GameActuator::Update() } } break; +#endif // DISABLE_PYTHON } default: ; /* do nothing? this is an internal error !!! */ @@ -198,8 +205,7 @@ bool KX_GameActuator::Update() } - - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -238,3 +244,5 @@ PyAttributeDef KX_GameActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("mode", KX_GAME_NODEF+1, KX_GAME_MAX-1, true, KX_GameActuator, m_mode), { NULL } //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index c72958bbc46..9bb261fcba9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -104,8 +104,10 @@ KX_GameObject::KX_GameObject( m_pGraphicController(NULL), m_xray(false), m_pHitObject(NULL), - m_isDeformable(false), - m_attr_dict(NULL) + m_isDeformable(false) +#ifndef DISABLE_PYTHON + , m_attr_dict(NULL) +#endif { m_ignore_activity_culling = false; m_pClient_info = new KX_ClientObjectInfo(this, KX_ClientObjectInfo::ACTOR); @@ -149,11 +151,12 @@ KX_GameObject::~KX_GameObject() { delete m_pGraphicController; } - +#ifndef DISABLE_PYTHON if (m_attr_dict) { PyDict_Clear(m_attr_dict); /* incase of circular refs or other weired cases */ Py_DECREF(m_attr_dict); } +#endif // DISABLE_PYTHON } KX_GameObject* KX_GameObject::GetClientObject(KX_ClientObjectInfo* info) @@ -342,8 +345,11 @@ void KX_GameObject::ProcessReplica() m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info); m_pClient_info->m_gameobject = this; m_state = 0; + +#ifndef DISABLE_PYTHON if(m_attr_dict) m_attr_dict= PyDict_Copy(m_attr_dict); +#endif } @@ -1201,6 +1207,28 @@ CListValue* KX_GameObject::GetChildrenRecursive() return list; } +/* --------------------------------------------------------------------- + * Some stuff taken from the header + * --------------------------------------------------------------------- */ +void KX_GameObject::Relink(GEN_Map<GEN_HashedPtr, void*> *map_parameter) +{ + // we will relink the sensors and actuators that use object references + // if the object is part of the replicated hierarchy, use the new + // object reference instead + SCA_SensorList& sensorlist = GetSensors(); + SCA_SensorList::iterator sit; + for (sit=sensorlist.begin(); sit != sensorlist.end(); sit++) + { + (*sit)->Relink(map_parameter); + } + SCA_ActuatorList& actuatorlist = GetActuators(); + SCA_ActuatorList::iterator ait; + for (ait=actuatorlist.begin(); ait != actuatorlist.end(); ait++) + { + (*ait)->Relink(map_parameter); + } +} + #ifdef USE_MATHUTILS /* These require an SGNode */ @@ -1377,8 +1405,8 @@ void KX_GameObject_Mathutils_Callback_Init(void) #endif // USE_MATHUTILS +#ifndef DISABLE_PYTHON /* ------- python stuff ---------------------------------------------------*/ - PyMethodDef KX_GameObject::Methods[] = { {"applyForce", (PyCFunction) KX_GameObject::sPyApplyForce, METH_VARARGS}, {"applyTorque", (PyCFunction) KX_GameObject::sPyApplyTorque, METH_VARARGS}, @@ -1454,23 +1482,6 @@ PyAttributeDef KX_GameObject::Attributes[] = { {NULL} //Sentinel }; - -/* -bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args, - MT_Vector3& pos, - MT_Vector3& pos2) -{ - PyObject* pylist; - PyObject* pylist2; - bool error = (PyArg_ParseTuple(args,"OO",&pylist,&pylist2)) != 0; - - pos = ConvertPythonPylist(pylist); - pos2 = ConvertPythonPylist(pylist2); - - return error; -} -*/ - PyObject* KX_GameObject::PyReplaceMesh(PyObject* args) { KX_Scene *scene = KX_GetActiveScene(); @@ -2776,29 +2787,6 @@ PyObject* KX_GameObject::Pyget(PyObject *args) return def; } -/* --------------------------------------------------------------------- - * Some stuff taken from the header - * --------------------------------------------------------------------- */ -void KX_GameObject::Relink(GEN_Map<GEN_HashedPtr, void*> *map_parameter) -{ - // we will relink the sensors and actuators that use object references - // if the object is part of the replicated hierarchy, use the new - // object reference instead - SCA_SensorList& sensorlist = GetSensors(); - SCA_SensorList::iterator sit; - for (sit=sensorlist.begin(); sit != sensorlist.end(); sit++) - { - (*sit)->Relink(map_parameter); - } - SCA_ActuatorList& actuatorlist = GetActuators(); - SCA_ActuatorList::iterator ait; - for (ait=actuatorlist.begin(); ait != actuatorlist.end(); ait++) - { - (*ait)->Relink(map_parameter); - } -} - - bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok, const char *error_prefix) { if (value==NULL) { @@ -2854,3 +2842,4 @@ bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py return false; } +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 4c4eed9ca71..48ba573e01b 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -60,8 +60,10 @@ class PHY_IGraphicController; class PHY_IPhysicsEnvironment; struct Object; +#ifndef DISABLE_PYTHON /* utility conversion function */ bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok, const char *error_prefix); +#endif #ifdef USE_MATHUTILS void KX_GameObject_Mathutils_Callback_Init(void); @@ -114,6 +116,7 @@ public: */ static KX_GameObject* GetClientObject(KX_ClientObjectInfo* info); +#ifndef DISABLE_PYTHON // Python attributes that wont convert into CValue // // there are 2 places attributes can be stored, in the CValue, @@ -130,6 +133,7 @@ public: // * when assigning a value, first see if it can be a CValue, if it can remove the "m_attr_dict" and set the CValue // PyObject* m_attr_dict; +#endif virtual void /* This function should be virtual - derived classed override it */ Relink( @@ -796,7 +800,8 @@ public: CListValue* GetChildren(); CListValue* GetChildrenRecursive(); - + +#ifndef DISABLE_PYTHON /** * @section Python interface functions. */ @@ -894,22 +899,7 @@ public: /* getitem/setitem */ static PyMappingMethods Mapping; static PySequenceMethods Sequence; - -private : - - /** - * Random internal function to convert python function arguments - * to 2 vectors. - * @return true if conversion was possible. - */ - - bool - ConvertPythonVectorArgs( - PyObject* args, - MT_Vector3& pos, - MT_Vector3& pos2 - ); - +#endif }; diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index f098b0bebf5..3c3d1d700c4 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -53,7 +53,9 @@ public: */ virtual void ConvertScene( class KX_Scene* destinationscene, +#ifndef DISABLE_PYTHON PyObject* dictobj, +#endif class RAS_IRenderTools* rendertools, class RAS_ICanvas* canvas)=0; diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index d7f800fe5bd..58769b94d9b 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -404,12 +404,13 @@ int KX_IpoActuator::string2mode(char* modename) { return res; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ - /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_IpoActuator::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -451,4 +452,6 @@ PyAttributeDef KX_IpoActuator::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index e95676ff9d2..734b74b7456 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -112,7 +112,9 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_rendertools(NULL), m_sceneconverter(NULL), m_networkdevice(NULL), +#ifndef DISABLE_PYTHON m_pythondictionary(NULL), +#endif m_keyboarddevice(NULL), m_mousedevice(NULL), @@ -231,7 +233,7 @@ void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer) m_rasterizer = rasterizer; } - +#ifndef DISABLE_PYTHON /* * At the moment the GameLogic module is imported into 'pythondictionary' after this function is called. * if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand. @@ -241,7 +243,7 @@ void KX_KetsjiEngine::SetPythonDictionary(PyObject* pythondictionary) MT_assert(pythondictionary); m_pythondictionary = pythondictionary; } - +#endif void KX_KetsjiEngine::SetSceneConverter(KX_ISceneConverter* sceneconverter) @@ -604,7 +606,9 @@ else m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS1); // set Python hooks for each scene +#ifndef DISABLE_PYTHON PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment()); +#endif KX_SetActiveScene(scene); scene->GetPhysicsEnvironment()->endFrame(); @@ -706,7 +710,9 @@ else m_suspendeddelta = scene->getSuspendedDelta(); // set Python hooks for each scene +#ifndef DISABLE_PYTHON PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment()); +#endif KX_SetActiveScene(scene); m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); @@ -1612,7 +1618,9 @@ KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename) scene); m_sceneconverter->ConvertScene(tmpscene, +#ifndef DISABLE_PYTHON m_pythondictionary, +#endif m_rendertools, m_canvas); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 373e8bf218c..9cfca850bf3 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -70,7 +70,9 @@ private: class RAS_IRenderTools* m_rendertools; class KX_ISceneConverter* m_sceneconverter; class NG_NetworkDeviceInterface* m_networkdevice; +#ifndef DISABLE_PYTHON PyObject* m_pythondictionary; +#endif class SCA_IInputDevice* m_keyboarddevice; class SCA_IInputDevice* m_mousedevice; class KX_Dome* m_dome; // dome stereo mode @@ -201,7 +203,9 @@ public: void SetCanvas(RAS_ICanvas* canvas); void SetRenderTools(RAS_IRenderTools* rendertools); void SetRasterizer(RAS_IRasterizer* rasterizer); +#ifndef DISABLE_PYTHON void SetPythonDictionary(PyObject* pythondictionary); +#endif void SetSceneConverter(KX_ISceneConverter* sceneconverter); void SetGame2IpoMode(bool game2ipo,int startFrame); diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 85c495bc2bd..a0ecac178b3 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -264,6 +264,7 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras) GPU_lamp_shadow_buffer_unbind(lamp); } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python Integration Hooks */ /* ------------------------------------------------------------------------- */ @@ -384,3 +385,4 @@ int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attr return PY_SET_ATTR_SUCCESS; } +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 0b7ccbe81ab..74d8abcfeac 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -65,12 +65,14 @@ public: void UnbindShadowBuffer(class RAS_IRasterizer *ras); void Update(); +#ifndef DISABLE_PYTHON /* attributes */ static PyObject* pyattr_get_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value); static PyObject* pyattr_get_typeconst(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value); +#endif virtual bool IsLight(void) { return true; } }; diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 744fdb75796..a4815c5bd20 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -26,6 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ +#ifndef DISABLE_PYTHON + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -309,3 +311,5 @@ bool ConvertPythonToMesh(PyObject * value, RAS_MeshObject **object, bool py_none return false; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index 55684aa5ee9..12174f158f1 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -29,6 +29,8 @@ #ifndef __KX_MESHPROXY #define __KX_MESHPROXY +#ifndef DISABLE_PYTHON + #include "SCA_IObject.h" /* utility conversion function */ @@ -72,5 +74,7 @@ public: static PyObject * pyattr_get_numPolygons(void * self, const KX_PYATTRIBUTE_DEF * attrdef); }; +#endif // DISABLE_PYTHON + #endif //__KX_MESHPROXY diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 8abc4f6b897..2dbaf3c9081 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -340,6 +340,8 @@ const MT_Vector3& KX_MouseFocusSensor::HitNormal() const return m_hitNormal; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -426,7 +428,7 @@ PyObject* KX_MouseFocusSensor::pyattr_get_hit_normal(void *self_v, const KX_PYAT return PyObjectFrom(self->HitNormal()); } - +#endif // DISABLE_PYTHON /* eof */ diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index 7b53557467f..d4063ef1d16 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -86,6 +86,8 @@ class KX_MouseFocusSensor : public SCA_MouseSensor const MT_Point3& HitPosition() const; const MT_Vector3& HitNormal() const; +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -98,6 +100,8 @@ class KX_MouseFocusSensor : public SCA_MouseSensor static PyObject* pyattr_get_hit_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_hit_normal(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); +#endif // DISABLE_PYTHON + /* --------------------------------------------------------------------- */ SCA_IObject* m_hitObject; void* m_hitObject_Last; /* only use for comparison, never access */ diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index c6a6304cb2c..9cb0faab046 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -245,13 +245,12 @@ bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData return false; // was DT_CONTINUE; but this was defined in Sumo as false } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python Functions */ /* ------------------------------------------------------------------------- */ -//No methods - /* ------------------------------------------------------------------------- */ /* Python Integration Hooks */ /* ------------------------------------------------------------------------- */ @@ -288,3 +287,5 @@ PyAttributeDef KX_NearSensor::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW_CHECK("resetDistance", 0, 100, KX_NearSensor, m_ResetMargin, CheckResetDistance), {NULL} //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index 4f0247d209d..4bc4a7d1524 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -78,6 +78,8 @@ public: virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2) { return false; }; virtual sensortype GetSensorType() { return ST_NEAR; } +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -97,6 +99,8 @@ public: return 0; } +#endif // DISABLE_PYTHON + }; #endif //KX_NEARSENSOR_H diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 924e4a47008..03a80fdbc28 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -317,7 +317,7 @@ bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type) return res; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -641,4 +641,6 @@ int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIB return PY_SET_ATTR_SUCCESS; } +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index 7a8c7de16b1..900408a30ab 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -157,7 +157,7 @@ public: } virtual bool Update(); - +#ifndef DISABLE_PYTHON /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ @@ -216,6 +216,9 @@ public: return 0; } + +#endif // DISABLE_PYTHON + }; #endif //__KX_OBJECTACTUATOR diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index a4a6b67ad10..b70aa43ae9f 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -134,6 +134,8 @@ bool KX_ParentActuator::Update() return false; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -201,4 +203,6 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE return PY_SET_ATTR_SUCCESS; } +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index f750affc8a1..501533486cf 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -77,6 +77,8 @@ class KX_ParentActuator : public SCA_IActuator virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map); virtual bool UnlinkObject(SCA_IObject* clientobj); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -85,6 +87,8 @@ class KX_ParentActuator : public SCA_IActuator 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); +#endif // DISABLE_PYTHON + }; /* end of class KX_ParentActuator : public SCA_PropertyActuator */ #endif diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index edb19002671..0e149783338 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -26,7 +26,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ -#include <Python.h> + #include "PyObjectPlus.h" #include "KX_PhysicsObjectWrapper.h" @@ -50,6 +50,7 @@ KX_PhysicsObjectWrapper::~KX_PhysicsObjectWrapper() { } +#ifndef DISABLE_PYTHON PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* args) { @@ -141,3 +142,5 @@ PyMethodDef KX_PhysicsObjectWrapper::Methods[] = { {"setActive",(PyCFunction) KX_PhysicsObjectWrapper::sPySetActive, METH_VARARGS}, {NULL,NULL} //Sentinel }; + +#endif diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h index fa6fd1d1f2a..6fba1d0d95f 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h @@ -39,11 +39,15 @@ public: KX_PhysicsObjectWrapper(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsEnvironment* physenv); virtual ~KX_PhysicsObjectWrapper(); +#ifndef DISABLE_PYTHON + KX_PYMETHOD_VARARGS(KX_PhysicsObjectWrapper,SetPosition); KX_PYMETHOD_VARARGS(KX_PhysicsObjectWrapper,SetLinearVelocity); KX_PYMETHOD_VARARGS(KX_PhysicsObjectWrapper,SetAngularVelocity); KX_PYMETHOD_VARARGS(KX_PhysicsObjectWrapper,SetActive); +#endif // DISABLE_PYTHON + private: class PHY_IPhysicsController* m_ctrl; PHY_IPhysicsEnvironment* m_physenv; diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index af8e0510a11..3a9052bd95e 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -26,6 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ +#ifndef DISABLE_PYTHON + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -271,3 +273,5 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterial, return mat->GetProxy(); } } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h index e619617d312..e7584727a77 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.h +++ b/source/gameengine/Ketsji/KX_PolyProxy.h @@ -29,6 +29,8 @@ #ifndef __KX_POLYROXY #define __KX_POLYPROXY +#ifndef DISABLE_PYTHON + #include "SCA_IObject.h" class KX_PolyProxy : public CValue @@ -65,5 +67,7 @@ public: }; +#endif // DISABLE_PYTHON + #endif //__KX_POLYPROXY diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 5b4322ae4cd..54a0f51aa7c 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -58,7 +58,9 @@ KX_PolygonMaterial::KX_PolygonMaterial() m_tface(NULL), m_mcol(NULL), m_material(NULL), +#ifndef DISABLE_PYTHON m_pymaterial(NULL), +#endif m_pass(0) { } @@ -92,21 +94,27 @@ void KX_PolygonMaterial::Initialize( m_tface = tface; m_mcol = mcol; m_material = ma; +#ifndef DISABLE_PYTHON m_pymaterial = 0; +#endif m_pass = 0; } KX_PolygonMaterial::~KX_PolygonMaterial() { +#ifndef DISABLE_PYTHON if (m_pymaterial) { Py_DECREF(m_pymaterial); } +#endif // DISABLE_PYTHON } bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const { bool dopass = false; + +#ifndef DISABLE_PYTHON if (m_pymaterial) { PyObject *pyRasty = PyCObject_FromVoidPtr((void*)rasty, NULL); /* new reference */ @@ -126,6 +134,7 @@ bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingI } } else +#endif // DISABLE_PYTHON { switch (m_pass++) { @@ -196,6 +205,7 @@ void KX_PolygonMaterial::GetMaterialRGBAColor(unsigned char *rgba) const RAS_IPolyMaterial::GetMaterialRGBAColor(rgba); } +#ifndef DISABLE_PYTHON //---------------------------------------------------------------------------- //Python @@ -386,3 +396,5 @@ int KX_PolygonMaterial::pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_D self->m_specular= vec; return PY_SET_ATTR_SUCCESS; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index dc42bd2f81b..dba12acee7f 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -57,7 +57,10 @@ private: MTFace* m_tface; unsigned int* m_mcol; Material* m_material; + +#ifndef DISABLE_PYTHON PyObject* m_pymaterial; +#endif mutable int m_pass; public: @@ -114,6 +117,7 @@ public: } virtual void GetMaterialRGBAColor(unsigned char *rgba) const; +#ifndef DISABLE_PYTHON KX_PYMETHOD_DOC(KX_PolygonMaterial, updateTexture); KX_PYMETHOD_DOC(KX_PolygonMaterial, setTexture); KX_PYMETHOD_DOC(KX_PolygonMaterial, activate); @@ -133,6 +137,7 @@ public: static int pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_specular(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); +#endif }; #endif // __KX_POLYGONMATERIAL_H__ diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 04cec3c9106..05513d85fc6 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -41,6 +41,8 @@ #include <config.h> #endif +#ifndef DISABLE_PYTHON + // nasty glob variable to connect scripting language // if there is a better way (without global), please do so! static PHY_IPhysicsEnvironment* g_CurrentActivePhysicsEnvironment = NULL; @@ -661,3 +663,5 @@ PHY_IPhysicsEnvironment* PHY_GetActiveEnvironment() return g_CurrentActivePhysicsEnvironment; } +#endif // DISABLE_PYTHON + diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.h b/source/gameengine/Ketsji/KX_PyConstraintBinding.h index b898cba3796..7eb2fe8909c 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.h +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.h @@ -29,13 +29,15 @@ #ifndef PHY_PYTHON_CONSTRAINTBINDING #define PHY_PYTHON_CONSTRAINTBINDING +#ifndef DISABLE_PYTHON + #include <Python.h> PyObject* initPythonConstraintBinding(); void PHY_RemovePythonConstraintBinding(); void PHY_SetActiveEnvironment(class PHY_IPhysicsEnvironment* env); PHY_IPhysicsEnvironment* PHY_GetActiveEnvironment(); - +#endif // DISABLE_PYTHON #endif //PHY_PYTHON_CONSTRAINTBINDING diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index a41dab194dd..aef29286f4e 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -36,6 +36,8 @@ #pragma warning (disable : 4786) #endif //WIN32 +#ifndef DISABLE_PYTHON + #include "MT_Vector3.h" #include "MT_Vector4.h" #include "MT_Matrix4x4.h" @@ -191,3 +193,5 @@ PyObject* PyObjectFrom(const MT_Tuple2 &vec) return list; #endif } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index 1ce8bcafbb6..0ad91799983 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -42,6 +42,7 @@ #include "KX_Python.h" #include "PyObjectPlus.h" +#ifndef DISABLE_PYTHON #ifdef USE_MATHUTILS extern "C" { #include "../../blender/python/generic/Mathutils.h" /* so we can have mathutils callbacks */ @@ -237,3 +238,5 @@ PyObject* PyObjectFrom(const MT_Quaternion &qrot); PyObject* PyObjectFrom(const MT_Tuple4 &pos); #endif + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 36126b26a59..f09cdd7d720 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -37,12 +37,17 @@ #pragma warning (disable : 4786) #endif //WIN32 +#ifndef DISABLE_PYTHON + extern "C" { #include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */ #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. #include "Geometry.h" // Blender.Geometry module copied here so the blenderlayer can use. #include "BGL.h" + + #include "marshal.h" /* python header for loading/saving dicts */ } +#endif #include "KX_PythonInit.h" //python physics binding @@ -89,17 +94,7 @@ extern "C" { #include "DNA_ID.h" #include "DNA_scene_types.h" - -#include "marshal.h" /* python header for loading/saving dicts */ - #include "PHY_IPhysicsEnvironment.h" -// FIXME: Enable for access to blender python modules. This is disabled because -// python has dependencies on a lot of other modules and is a pain to link. -//#define USE_BLENDER_PYTHON -#ifdef USE_BLENDER_PYTHON -//#include "BPY_extern.h" -#endif - #include "BKE_main.h" #include "BKE_utildefines.h" #include "BKE_global.h" @@ -122,15 +117,34 @@ static KX_KetsjiEngine* gp_KetsjiEngine = NULL; static RAS_IRasterizer* gp_Rasterizer = NULL; static char gp_GamePythonPath[FILE_MAXDIR + FILE_MAXFILE] = ""; static char gp_GamePythonPathOrig[FILE_MAXDIR + FILE_MAXFILE] = ""; // not super happy about this, but we need to remember the first loaded file for the global/dict load save -static PyObject *gp_OrigPythonSysPath= NULL; -static PyObject *gp_OrigPythonSysModules= NULL; +void KX_SetActiveScene(class KX_Scene* scene) +{ + gp_KetsjiScene = scene; +} + +class KX_Scene* KX_GetActiveScene() +{ + return gp_KetsjiScene; +} + +class KX_KetsjiEngine* KX_GetActiveEngine() +{ + return gp_KetsjiEngine; +} + +/* why is this in python? */ void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color) { if (gp_Rasterizer) gp_Rasterizer->DrawDebugLine(from,to,color); } +#ifndef DISABLE_PYTHON + +static PyObject *gp_OrigPythonSysPath= NULL; +static PyObject *gp_OrigPythonSysModules= NULL; + /* Macro for building the keyboard translation */ //#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyLong_FromSsize_t(SCA_IInputDevice::KX_##name)) #define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, item=PyLong_FromSsize_t(name)); Py_DECREF(item) @@ -1950,21 +1964,6 @@ PyObject* initBGL() return BGL_Init(); } -void KX_SetActiveScene(class KX_Scene* scene) -{ - gp_KetsjiScene = scene; -} - -class KX_Scene* KX_GetActiveScene() -{ - return gp_KetsjiScene; -} - -class KX_KetsjiEngine* KX_GetActiveEngine() -{ - return gp_KetsjiEngine; -} - // utility function for loading and saving the globalDict int saveGamePythonConfig( char **marshal_buffer) { @@ -2065,3 +2064,5 @@ void resetGamePythonPath() { gp_GamePythonPathOrig[0] = '\0'; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 8f102d13a18..ad3cd15ab4a 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -39,7 +39,7 @@ typedef enum { extern bool gUseVisibilityTemp; - +#ifndef DISABLE_PYTHON PyObject* initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene* ketsjiscene); PyObject* initGameKeys(); PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas); @@ -57,6 +57,7 @@ void resetGamePythonPath(); void pathGamePythonConfig( char *path ); int saveGamePythonConfig( char **marshal_buffer); int loadGamePythonConfig(char *marshal_buffer, int marshal_length); +#endif class KX_KetsjiEngine; class KX_Scene; diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index c2c33918172..dd63163c663 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -32,6 +32,8 @@ #ifndef _adr_py_init_types_h_ // only process once, #define _adr_py_init_types_h_ // even if multiply included +#ifndef DISABLE_PYTHON + /* Only for Class::Parents */ #include "BL_BlenderShader.h" #include "BL_ShapeActionActuator.h" @@ -250,4 +252,6 @@ void initPyTypes(void) #endif } +#endif // DISABLE_PYTHON + #endif diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.h b/source/gameengine/Ketsji/KX_PythonInitTypes.h index 6da79be9301..5b368d240f1 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.h +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.h @@ -30,6 +30,8 @@ #ifndef _adr_py_init_types_h_ // only process once, #define _adr_py_init_types_h_ // even if multiply included +#ifndef DISABLE_PYTHON void initPyTypes(void); +#endif #endif diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index f7ad7acb252..5b7e770f4e6 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -28,6 +28,7 @@ * Readonly sequence wrapper for lookups on logic bricks */ +#ifndef DISABLE_PYTHON #include "KX_PythonSeq.h" #include "KX_GameObject.h" @@ -508,3 +509,5 @@ PyTypeObject KX_PythonSeq_Type = { NULL, /* PyObject *tp_weaklist; */ NULL }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_PythonSeq.h b/source/gameengine/Ketsji/KX_PythonSeq.h index 34243aa9b9c..22b968e9362 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.h +++ b/source/gameengine/Ketsji/KX_PythonSeq.h @@ -31,6 +31,8 @@ #ifndef _adr_py_seq_h_ // only process once, #define _adr_py_seq_h_ // even if multiply included +#ifndef DISABLE_PYTHON + #include "PyObjectPlus.h" // ------------------------- @@ -59,4 +61,6 @@ typedef struct { PyObject *KX_PythonSeq_CreatePyObject(PyObject *base, short type); +#endif // DISABLE_PYTHON + #endif // _adr_py_seq_h_ diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index eb127be8044..de5c0533ad3 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -176,7 +176,7 @@ void KX_RadarSensor::SynchronizeTransform() /* Python Functions */ /* ------------------------------------------------------------------------- */ -/* none */ +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python Integration Hooks */ @@ -216,3 +216,4 @@ PyAttributeDef KX_RadarSensor::Attributes[] = { {NULL} //Sentinel }; +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 1f36945ccaa..4902315fd47 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -43,6 +43,8 @@ #include "KX_IPhysicsController.h" #include "PHY_IPhysicsController.h" +#include <stdio.h> + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -311,7 +313,7 @@ bool KX_RaySensor::Evaluate() return result; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -366,3 +368,5 @@ PyObject* KX_RaySensor::pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_ Py_RETURN_NONE; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index d3e92a14214..39b447b5657 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -84,10 +84,13 @@ public: KX_RAY_AXIS_NEG_Z }; +#ifndef DISABLE_PYTHON /* Attributes */ static PyObject* pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); +#endif // DISABLE_PYTHON + }; #endif //__KX_RAYSENSOR_H diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index c1e74070d72..fb96834c836 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -163,6 +163,7 @@ void KX_SCA_AddObjectActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map) } } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -242,6 +243,14 @@ PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, con return actuator->m_lastCreatedObject->GetProxy(); } +PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject() +{ + InstantAddObject(); + + Py_RETURN_NONE; +} + +#endif // DISABLE_PYTHON void KX_SCA_AddObjectActuator::InstantAddObject() { @@ -277,10 +286,3 @@ void KX_SCA_AddObjectActuator::InstantAddObject() replica->Release(); } } - -PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject() -{ - InstantAddObject(); - - Py_RETURN_NONE; -} diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 7137ba5209e..4cccc406b58 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -115,12 +115,16 @@ public: void InstantAddObject(); +#ifndef DISABLE_PYTHON + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject); 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); static PyObject* pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); +#endif // DISABLE_PYTHON + }; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */ #endif diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 73c85ad07b3..07a0df8bf77 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -41,6 +41,8 @@ #include <config.h> #endif +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -79,6 +81,8 @@ PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index e7dc71d9b27..b37ea4d57c0 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -84,7 +84,7 @@ CValue* KX_SCA_EndObjectActuator::GetReplica() return replica; }; - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions : integration hooks */ @@ -120,4 +120,6 @@ PyAttributeDef KX_SCA_EndObjectActuator::Attributes[] = { { NULL } //Sentinel }; +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index e118972edc8..967bbfcdf1d 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -44,6 +44,8 @@ #include <config.h> #endif +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -112,6 +114,8 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh, Py_RETURN_NONE; } +#endif // DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index e5482c29aa7..47c823afa9f 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -74,6 +74,8 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator void InstantReplaceMesh(); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -83,6 +85,8 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,instantReplaceMesh); +#endif // DISABLE_PYTHON + }; #endif diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 140be3fb3db..94f62b5b4b6 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -94,6 +94,8 @@ #include "KX_Light.h" +#include <stdio.h> + void* KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene) { KX_GameObject* replica = ((KX_Scene*)scene)->AddNodeReplicaObject(node,(KX_GameObject*)gameobj); @@ -207,7 +209,9 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_bucketmanager=new RAS_BucketManager(); +#ifndef DISABLE_PYTHON m_attr_dict = PyDict_New(); /* new ref */ +#endif } @@ -256,8 +260,11 @@ KX_Scene::~KX_Scene() { delete m_bucketmanager; } + +#ifndef DISABLE_PYTHON PyDict_Clear(m_attr_dict); Py_DECREF(m_attr_dict); +#endif } RAS_BucketManager* KX_Scene::GetBucketManager() @@ -1604,6 +1611,8 @@ double KX_Scene::getSuspendedDelta() return m_suspendeddelta; } +#ifndef DISABLE_PYTHON + //---------------------------------------------------------------------------- //Python @@ -1867,3 +1876,5 @@ KX_PYMETHODDEF_DOC(KX_Scene, get, "") Py_INCREF(def); return def; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 3e0dc303d72..da72ba2ec98 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -90,7 +90,10 @@ struct KX_ClientObjectInfo; class KX_Scene : public PyObjectPlus, public SCA_IScene { Py_Header; + +#ifndef DISABLE_PYTHON PyObject* m_attr_dict; +#endif struct CullingInfo { int m_layer; @@ -517,6 +520,7 @@ public: */ void SetNodeTree(SG_Tree* root); +#ifndef DISABLE_PYTHON /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -539,6 +543,8 @@ public: static PyMappingMethods Mapping; static PySequenceMethods Sequence; +#endif + /** * Sets the time the scene was suspended */ diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index c7721c480e0..e0b6ab1a34c 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -214,7 +214,7 @@ KX_Scene* KX_SceneActuator::FindScene(char * sceneName) } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -287,4 +287,6 @@ int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_ return PY_SET_ATTR_SUCCESS; } +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index e979a8ce559..e11a94798c9 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -87,6 +87,8 @@ class KX_SceneActuator : public SCA_IActuator virtual bool Update(); +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -94,6 +96,8 @@ class KX_SceneActuator : public SCA_IActuator 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); +#endif // DISABLE_PYTHON + }; /* end of class KXSceneActuator */ #endif diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 9d261137497..c97b4618f28 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -264,7 +264,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame) } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -416,3 +416,5 @@ int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATT return PY_SET_ATTR_SUCCESS; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 43198f1a253..de862473aac 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -93,6 +93,8 @@ public: CValue* GetReplica(); void ProcessReplica(); +#ifndef DISABLE_PYTHON + /* -------------------------------------------------------------------- */ /* Python interface --------------------------------------------------- */ /* -------------------------------------------------------------------- */ @@ -110,6 +112,9 @@ 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); + +#endif // DISABLE_PYTHON + }; #endif //__KX_SOUNDACTUATOR diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index 60812220953..21ed087a3c1 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -128,6 +128,7 @@ void KX_StateActuator::Activate(SG_DList& head) } } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -167,3 +168,5 @@ PyAttributeDef KX_StateActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("mask",0,0x3FFFFFFF,false,KX_StateActuator,m_mask), { NULL } //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index cde67787e2f..2ce5b8d1496 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -287,6 +287,7 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll return false; // was DT_CONTINUE but this was defined in sumo as false. } +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -345,5 +346,6 @@ PyObject* KX_TouchSensor::pyattr_get_object_hit_list(void *self_v, const KX_PYAT return self->m_colliders->GetProxy(); } +#endif /* eof */ diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index ad1830e05c9..ae5b68da845 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -116,13 +116,16 @@ public: // todo: put some info for collision maybe +#ifndef DISABLE_PYTHON + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ 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); - + +#endif }; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index ace1cf8a6f4..01c7244b9d0 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -421,14 +421,12 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) return result; } - +#ifndef DISABLE_PYTHON /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ - - /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_TrackToActuator::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -492,4 +490,6 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT return PY_SET_ATTR_SUCCESS; } +#endif // DISABLE_PYTHON + /* eof */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index bbfc1d17576..880c3712e1f 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -69,12 +69,16 @@ class KX_TrackToActuator : public SCA_IActuator virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map); virtual bool Update(double curtime, bool frame); +#ifndef DISABLE_PYTHON + /* Python part */ /* 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); +#endif // DISABLE_PYTHON + }; /* end of class KX_TrackToActuator : public KX_EditObjectActuator */ #endif diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 1f46cbf53be..4adeefe32b4 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -1,6 +1,5 @@ -#include <Python.h> #include "PyObjectPlus.h" #include "KX_VehicleWrapper.h" @@ -34,6 +33,7 @@ KX_VehicleWrapper::~KX_VehicleWrapper() m_motionStates.clear(); } +#ifndef DISABLE_PYTHON PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* args) { @@ -322,3 +322,5 @@ PyMethodDef KX_VehicleWrapper::Methods[] = { PyAttributeDef KX_VehicleWrapper::Attributes[] = { { NULL } //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h index d7f2da5cd7c..2ca06da18fc 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.h +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.h @@ -20,6 +20,7 @@ public: virtual ~KX_VehicleWrapper (); int getConstraintId(); +#ifndef DISABLE_PYTHON KX_PYMETHOD_VARARGS(KX_VehicleWrapper,AddWheel); KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetNumWheels); @@ -46,7 +47,7 @@ public: KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSuspensionCompression); KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetRollInfluence); - +#endif // DISABLE_PYTHON private: PHY_IVehicle* m_vehicle; diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 6a47dec181b..62ae502cd39 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -26,6 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ +#ifndef DISABLE_PYTHON + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -442,3 +444,5 @@ PyObject* KX_VertexProxy::PySetUV2(PyObject* args) m_mesh->SetMeshModified(true); Py_RETURN_NONE; } + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h index 13c57e9f556..77ca0ad853a 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.h +++ b/source/gameengine/Ketsji/KX_VertexProxy.h @@ -29,6 +29,8 @@ #ifndef __KX_VERTEXPROXY #define __KX_VERTEXPROXY +#ifndef DISABLE_PYTHON + #include "SCA_IObject.h" class KX_VertexProxy : public CValue @@ -69,5 +71,7 @@ public: }; +#endif // DISABLE_PYTHON + #endif //__KX_VERTEXPROXY diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 5b0f6e6e9f2..8154c87ab42 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -83,6 +83,8 @@ KX_VisibilityActuator::Update() return false; } +#ifndef DISABLE_PYTHON + /* ------------------------------------------------------------------------- */ /* Python functions */ /* ------------------------------------------------------------------------- */ @@ -122,3 +124,5 @@ PyAttributeDef KX_VisibilityActuator::Attributes[] = { KX_PYATTRIBUTE_BOOL_RW("useRecursion", KX_VisibilityActuator, m_recursive), { NULL } //Sentinel }; + +#endif // DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index b20da20d0e2..69d146776db 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -20,7 +20,6 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common #sourc incs += ' #source/gameengine/Physics/Dummy' incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu' -incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] @@ -28,6 +27,11 @@ if env['WITH_BF_SDL']: incs += ' ' + env['BF_SDL_INC'] else: defs.append('DISABLE_SDL') + +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'): if env['BF_DEBUG']: diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index 49f2af1b001..976c6825351 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -19,6 +19,12 @@ incs += ' #source/blender/blenlib' 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']) +defs = [] + +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + +env.BlenderLib ( 'bf_bullet', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[350,50], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 239031866ca..75d80f4b3d5 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -49,6 +49,8 @@ #include "GL/glew.h" +#include <stdio.h> + #ifdef HAVE_CONFIG_H #include <config.h> #endif diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index dbec2d92e31..ea99fa966d8 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -5,6 +5,12 @@ 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']) +defs = [] + +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + +env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), defs, libtype=['core','player'], priority=[350,70], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/SConscript b/source/gameengine/SConscript index 592b138583f..e7c9328688f 100644 --- a/source/gameengine/SConscript +++ b/source/gameengine/SConscript @@ -14,9 +14,11 @@ SConscript(['BlenderRoutines/SConscript', 'Rasterizer/SConscript', 'Rasterizer/RAS_OpenGLRasterizer/SConscript', 'SceneGraph/SConscript', - 'Physics/Bullet/SConscript', - 'VideoTexture/SConscript' + 'Physics/Bullet/SConscript' ]) +if env['WITH_BF_PYTHON']: + SConscript(['VideoTexture/SConscript']) + if env['WITH_BF_PLAYER']: SConscript(['GamePlayer/SConscript']) diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index 935c5a2c292..d914783cff3 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -48,7 +48,6 @@ SET(INC ../../../intern/moto/include ../../../intern/guardedalloc ../../../extern/glew/include - ${PYTHON_INC} ) IF(WITH_FFMPEG) @@ -57,5 +56,11 @@ IF(WITH_FFMPEG) ADD_DEFINITIONS(-D__STDC_CONSTANT_MACROS) ENDIF(WITH_FFMPEG) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_videotex "${SRC}" "${INC}") #env.BlenderLib ( 'bf_videotex', sources, Split(incs), [], libtype=['game','player'], priority=[25, 72], compileflags = cflags ) diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index dac0b6d32ab..b6b60c593ed 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -19,7 +19,10 @@ if env['OURPLATFORM'] in ('win32-vc', 'win64-vc','win32-mingw'): if env['BF_DEBUG']: defs.append('_DEBUG') -incs += ' ' + env['BF_PYTHON_INC'] +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') |