option to build the BGE without python, uses existing python check (cmake and scons)

when python is disabled videotextures are not built.
This commit is contained in:
Campbell Barton
2009-09-29 21:42:40 +00:00
parent 53f0c3b018
commit 98ee2a781d
171 changed files with 1205 additions and 611 deletions

View File

@@ -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] )

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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']

View File

@@ -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)

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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();

View File

@@ -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

View File

@@ -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
};

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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++)
{

View File

@@ -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,

View File

@@ -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

View File

@@ -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);

View File

@@ -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] )

View File

@@ -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,

View File

@@ -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
);

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -28,6 +28,7 @@
* Conversion of Blender data blocks to KX sensor system
*/
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>

View File

@@ -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'])

View File

@@ -205,9 +205,9 @@ CValue* CBoolValue::GetReplica()
return replica;
}
#ifndef DISABLE_PYTHON
PyObject* CBoolValue::ConvertValueToPython()
{
return PyBool_FromLong(m_bool != 0);
}
#endif // DISABLE_PYTHON

View File

@@ -45,7 +45,9 @@ public:
void Configure(CValue* menuvalue);
virtual CValue* GetReplica();
#ifndef DISABLE_PYTHON
virtual PyObject* ConvertValueToPython();
#endif
private:
bool m_bool;

View File

@@ -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] )

View File

@@ -314,9 +314,9 @@ CValue* CFloatValue::GetReplica()
}
#ifndef DISABLE_PYTHON
PyObject* CFloatValue::ConvertValueToPython()
{
return PyFloat_FromDouble(m_float);
}
#endif // DISABLE_PYTHON

View File

@@ -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;

View File

@@ -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

View File

@@ -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();

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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();
/**
* Makes sure any internal data owned by this class is deep copied.
*/
virtual void ProcessReplica();
static bool m_ignore_deprecation_warnings;
};
#ifndef DISABLE_PYTHON
PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict);
#endif
#endif // _adr_py_lib_h_
#endif //NO_EXP_PYTHON_EMBEDDING

View File

@@ -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'])

View File

@@ -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

View File

@@ -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
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -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()
{

View File

@@ -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] )

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -36,6 +36,8 @@
#include "InputParser.h"
#include "MT_Transform.h" // for fuzzyZero
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

View File

@@ -27,6 +27,7 @@
*/
#include "SCA_IActuator.h"
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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

View File

@@ -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

View File

@@ -117,6 +117,8 @@ public:
return m_joyindex;
}
#ifndef DISABLE_PYTHON
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
@@ -155,6 +157,8 @@ public:
return 0;
}
#endif // DISABLE_PYTHON
};
#endif

View File

@@ -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 */

View File

@@ -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
};

View File

@@ -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)

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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')

View File

@@ -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'])

View File

@@ -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')

View File

@@ -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

View File

@@ -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__

View File

@@ -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 )

View File

@@ -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] )

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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'])

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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;

View File

@@ -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<63>t<EFBFBD> des arts technologiques.
Developed as part of a Research and Development project for SAT - La Soci<63>t<EFBFBD> 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<38> Dome
//creating faces for the env mapcube 180<38> 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<32> domes) we don't need to create and tesselate the whole cube.
When we want some horizontal information (e.g. for horizontal 220<32> 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<38> Dome
//creating faces for the env mapcube 180<38> 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<33>) face - two triangles */
/* Left Back (135<33>) 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<33>) face - two triangles */
/* Right Back (-135<33>) 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<36>)
// it creates a full spherical panoramic (360<36>)
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<39> Field of View Frustum
// manually creating a 90<39> 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<39>, tan = 1
float top = m_frustrum.camnear; // for deg = 90<39>, 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<38>
Uses 5 cameras for angles up to 250<35>
Uses 6 cameras for angles up to 360<36>
Uses 4 cameras for angles up to 180<38>
Uses 5 cameras for angles up to 250<35>
Uses 6 cameras for angles up to 360<36>
*/
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<39> - Top
m_locRot[0] = MT_Matrix3x3( // 90<39> - Top
c, -s, 0.0,
0.0,0.0, -1.0,
s, c, 0.0);
m_locRot[1] = MT_Matrix3x3( // 90<39> - Bottom
m_locRot[1] = MT_Matrix3x3( // 90<39> - Bottom
-s, c, 0.0,
0.0,0.0, 1.0,
s, c, 0.0);
m_locRot[2] = MT_Matrix3x3( // 45<34> - Left
m_locRot[2] = MT_Matrix3x3( // 45<34> - Left
c, 0.0, s,
0, 1.0, 0.0,
-s, 0.0, c);
m_locRot[3] = MT_Matrix3x3( // 45<34> - Right
m_locRot[3] = MT_Matrix3x3( // 45<34> - 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<39> - Top
m_locRot[0] = MT_Matrix3x3( // 90<39> - 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<39> - Bottom
m_locRot[1] = MT_Matrix3x3( // 90<39> - 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<39> - Left
m_locRot[2] = MT_Matrix3x3( // -90<39> - 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<39> - Right
m_locRot[3] = MT_Matrix3x3( // 90<39> - 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<38> - Back - USED for ENVMAP only
m_locRot[5] = MT_Matrix3x3( // 180<38> - 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<34> - Left
m_locRot[2] = MT_Matrix3x3( // 45<34> - Left
-s, 0.0, c,
0, 1.0, 0.0,
-c, 0.0, -s);
m_locRot[3] = MT_Matrix3x3( // 45<34> - Right
m_locRot[3] = MT_Matrix3x3( // 45<34> - Right
c, 0.0, s,
0, 1.0, 0.0,
-s, 0.0, c);
m_locRot[4] = MT_Matrix3x3( // 135<33> - LeftBack
m_locRot[4] = MT_Matrix3x3( // 135<33> - LeftBack
-s, 0.0, -c,
0.0, 1.0, 0.0,
c, 0.0, -s);
m_locRot[5] = MT_Matrix3x3( // 135<33> - RightBack
m_locRot[5] = MT_Matrix3x3( // 135<33> - 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<39> (left)
// domefacesId[2] => -90<39> (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<39> (right)
// domefacesId[3] => 90<39> (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<38> (back)
// domefacesId[5] => 180<38> (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<34> (left)
// domefacesId[1] => -45<34> (left)
glBindTexture(GL_TEXTURE_2D, domefacesId[2]);
GLDrawTriangles(cubeleft, nfacesleft);
// domefacesId[2] => 45<34> (right)
// domefacesId[2] => 45<34> (right)
glBindTexture(GL_TEXTURE_2D, domefacesId[3]);
GLDrawTriangles(cuberight, nfacesright);
// domefacesId[0] => -135<33> (leftback)
// domefacesId[0] => -135<33> (leftback)
glBindTexture(GL_TEXTURE_2D, domefacesId[4]);
GLDrawTriangles(cubeleftback, nfacesleftback);
// domefacesId[3] => 135<33> (rightback)
// domefacesId[3] => 135<33> (rightback)
glBindTexture(GL_TEXTURE_2D, domefacesId[5]);
GLDrawTriangles(cuberightback, nfacesrightback);
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
};

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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; }
};

View File

@@ -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

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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__

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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_

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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 */
/* ------------------------------------------------------------------------- */

View File

@@ -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 */

View File

@@ -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 */
/* ------------------------------------------------------------------------- */

View File

@@ -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

View File

@@ -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

View File

@@ -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
*/

View File

@@ -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 */

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 */

View File

@@ -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
};

View File

@@ -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 */

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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']:

View File

@@ -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'])

View File

@@ -49,6 +49,8 @@
#include "GL/glew.h"
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

View File

@@ -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'])

View File

@@ -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'])

View File

@@ -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 )

View File

@@ -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')