Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/GameLogic')
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt7
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorEventManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h6
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_BasicEventManager.cpp61
-rw-r--r--source/gameengine/GameLogic/SCA_BasicEventManager.h57
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.h8
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h32
-rw-r--r--source/gameengine/GameLogic/SCA_IController.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_IController.h4
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.h4
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.cpp33
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h17
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.cpp7
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.cpp7
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.h1
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp21
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h12
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp29
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp36
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h14
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h5
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.cpp3
-rw-r--r--source/gameengine/GameLogic/SConscript8
59 files changed, 420 insertions, 88 deletions
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
index 601585f79d6..819af4b56f8 100644
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ b/source/gameengine/GameLogic/CMakeLists.txt
@@ -34,7 +34,6 @@ SET(INC
../../../source/gameengine/SceneGraph
../../../intern/moto/include
../../../source/gameengine/Rasterizer
- ${PYTHON_INC}
)
IF(WITH_SDL)
@@ -43,5 +42,11 @@ ELSE(WITH_SDL)
ADD_DEFINITIONS(-DDISABLE_SDL)
ENDIF(WITH_SDL)
+IF(WITH_PYTHON)
+ SET(INC ${INC} ${PYTHON_INC})
+ELSE(WITH_PYTHON)
+ ADD_DEFINITIONS(-DDISABLE_PYTHON)
+ENDIF(WITH_PYTHON)
+
BLENDERLIB(bf_logic "${SRC}" "${INC}")
#env.BlenderLib ( 'bf_logic', sources, Split(incs), [], libtype=['game','player'], priority=[30, 110] )
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
index 9dfb5ddc38f..bd1e5fa7105 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -43,7 +43,7 @@ SCA_2DFilterActuator::SCA_2DFilterActuator(
int int_arg,
RAS_IRasterizer* rasterizer,
RAS_IRenderTools* rendertools)
- : SCA_IActuator(gameobj),
+ : SCA_IActuator(gameobj, KX_ACT_2DFILTER),
m_type(type),
m_disableMotionBlur(flag),
m_float_arg(float_arg),
@@ -99,12 +99,12 @@ void SCA_2DFilterActuator::SetShaderText(const char *text)
m_shaderText = text;
}
+#ifndef DISABLE_PYTHON
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
-
-
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_2DFilterActuator::Type = {
PyVarObject_HEAD_INIT(NULL, 0)
@@ -141,3 +141,5 @@ PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg),
{ NULL } //Sentinel
};
+
+#endif
diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp
index ac9e238bd64..21380caf6a0 100644
--- a/source/gameengine/GameLogic/SCA_ANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_ANDController.cpp
@@ -91,7 +91,7 @@ CValue* SCA_ANDController::GetReplica()
return replica;
}
-
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -127,5 +127,5 @@ PyMethodDef SCA_ANDController::Methods[] = {
PyAttributeDef SCA_ANDController::Attributes[] = {
{ NULL } //Sentinel
};
-
+#endif // DISABLE_PYTHON
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
index a80b2af55c8..e4dfe4e0bff 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
@@ -36,8 +36,7 @@
SCA_ActuatorEventManager::SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(ACTUATOR_EVENTMGR),
- m_logicmgr(logicmgr)
+ : SCA_EventManager(logicmgr, ACTUATOR_EVENTMGR)
{
}
diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
index f3884c87a75..8c86d0dd422 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
+++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
@@ -37,8 +37,6 @@ using namespace std;
class SCA_ActuatorEventManager : public SCA_EventManager
{
- class SCA_LogicManager* m_logicmgr;
-
public:
SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr);
virtual ~SCA_ActuatorEventManager();
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
index 428362a0a24..c5ba95e2c2c 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -114,6 +114,7 @@ void SCA_ActuatorSensor::Update()
}
}
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -163,4 +164,6 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
return 1;
}
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
index 1a095148500..299684fc955 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
@@ -56,11 +56,15 @@ public:
virtual void ReParent(SCA_IObject* parent);
void Update();
+#ifndef DISABLE_PYTHON
+
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
+
static int CheckActuator(void *self, const PyAttributeDef*);
+
+#endif // DISABLE_PYTHON
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
index dd3b55abcc9..aee01606974 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
@@ -42,8 +42,7 @@
using namespace std;
SCA_AlwaysEventManager::SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(ALWAYS_EVENTMGR),
- m_logicmgr(logicmgr)
+ : SCA_EventManager(logicmgr, ALWAYS_EVENTMGR)
{
}
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
index 9540e3b71f6..f7fb3b9714e 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
+++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
@@ -34,8 +34,6 @@
using namespace std;
class SCA_AlwaysEventManager : public SCA_EventManager
{
-
- class SCA_LogicManager* m_logicmgr;
public:
SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr);
virtual void NextFrame();
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
index 35b035f6466..898d0f4bb34 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
@@ -98,6 +98,8 @@ bool SCA_AlwaysSensor::Evaluate()
return result;
}
+#ifndef DISABLE_PYTHON
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@@ -133,4 +135,6 @@ PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
{ NULL } //Sentinel
};
+#endif
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_BasicEventManager.cpp b/source/gameengine/GameLogic/SCA_BasicEventManager.cpp
new file mode 100644
index 00000000000..a2a7e535b5c
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_BasicEventManager.cpp
@@ -0,0 +1,61 @@
+/**
+ * Manager for 'always' events. Since always sensors can operate in pulse
+ * mode, they need to be activated.
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "SCA_BasicEventManager.h"
+#include "SCA_LogicManager.h"
+#include <vector>
+#include "SCA_ISensor.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+SCA_BasicEventManager::SCA_BasicEventManager(class SCA_LogicManager* logicmgr)
+ : SCA_EventManager(logicmgr, BASIC_EVENTMGR)
+{
+}
+
+SCA_BasicEventManager::~SCA_BasicEventManager()
+{
+}
+
+void SCA_BasicEventManager::NextFrame()
+{
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
+ {
+ (*it)->Activate(m_logicmgr);
+ }
+}
+
diff --git a/source/gameengine/GameLogic/SCA_BasicEventManager.h b/source/gameengine/GameLogic/SCA_BasicEventManager.h
new file mode 100644
index 00000000000..3bd2df08c07
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_BasicEventManager.h
@@ -0,0 +1,57 @@
+/**
+ * Manager for sensor that only need to call Update
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __SCA_BASICEVENTMGR
+#define __SCA_BASICEVENTMGR
+
+#include "SCA_EventManager.h"
+#include <vector>
+
+using namespace std;
+
+class SCA_BasicEventManager : public SCA_EventManager
+{
+public:
+ SCA_BasicEventManager(class SCA_LogicManager* logicmgr);
+ ~SCA_BasicEventManager();
+
+ virtual void NextFrame();
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_BasicEventManager"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
+};
+
+#endif //__SCA_BASICEVENTMGR
+
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
index 0f67ddd56a5..2c2b588abd3 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -124,6 +124,8 @@ bool SCA_DelaySensor::Evaluate()
return trigger;
}
+#ifndef DISABLE_PYTHON
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@@ -162,4 +164,6 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = {
{ NULL } //Sentinel
};
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp
index d1301541a0a..5b6f3c46022 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_EventManager.cpp
@@ -35,8 +35,9 @@
#endif
-SCA_EventManager::SCA_EventManager(EVENT_MANAGER_TYPE mgrtype)
- :m_mgrtype(mgrtype)
+SCA_EventManager::SCA_EventManager(SCA_LogicManager* logicmgr, EVENT_MANAGER_TYPE mgrtype)
+ :m_logicmgr(logicmgr),
+ m_mgrtype(mgrtype)
{
}
diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h
index 424150ffa63..debefcc45b0 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.h
+++ b/source/gameengine/GameLogic/SCA_EventManager.h
@@ -38,6 +38,8 @@
class SCA_EventManager
{
protected:
+ class SCA_LogicManager* m_logicmgr; /* all event manager subclasses use this (other then TimeEventManager) */
+
// use a set to speed-up insertion/removal
//std::set <class SCA_ISensor*> m_sensors;
SG_DList m_sensors;
@@ -52,13 +54,13 @@ public:
TIME_EVENTMGR,
RANDOM_EVENTMGR,
RAY_EVENTMGR,
- RADAR_EVENTMGR,
NETWORK_EVENTMGR,
JOY_EVENTMGR,
- ACTUATOR_EVENTMGR
+ ACTUATOR_EVENTMGR,
+ BASIC_EVENTMGR
};
- SCA_EventManager(EVENT_MANAGER_TYPE mgrtype);
+ SCA_EventManager(SCA_LogicManager* logicmgr, EVENT_MANAGER_TYPE mgrtype);
virtual ~SCA_EventManager();
virtual void RemoveSensor(class SCA_ISensor* sensor);
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
index 60969300474..91135079fe6 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
@@ -36,6 +36,8 @@
#include "InputParser.h"
#include "MT_Transform.h" // for fuzzyZero
+#include <stdio.h>
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
index 0fda75590c1..13deed12dd1 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_IActuator.cpp
@@ -27,6 +27,7 @@
*/
#include "SCA_IActuator.h"
+#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -34,8 +35,9 @@
using namespace std;
-SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj) :
+SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type) :
SCA_ILogicBrick(gameobj),
+ m_type(type),
m_links(0),
m_posevent(false),
m_negevent(false)
diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h
index 00ba8c9ce4e..2f1c04192ab 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.h
+++ b/source/gameengine/GameLogic/SCA_IActuator.h
@@ -41,6 +41,7 @@ class SCA_IActuator : public SCA_ILogicBrick
{
friend class SCA_LogicManager;
protected:
+ int m_type;
int m_links; // number of active links to controllers
// when 0, the actuator is automatically stopped
//std::vector<CValue*> m_events;
@@ -60,8 +61,33 @@ public:
/**
* This class also inherits the default copy constructors
*/
-
- SCA_IActuator(SCA_IObject* gameobj);
+ enum KX_ACTUATOR_TYPE {
+ KX_ACT_OBJECT,
+ KX_ACT_IPO,
+ KX_ACT_CAMERA,
+ KX_ACT_SOUND,
+ KX_ACT_PROPERTY,
+ KX_ACT_ADD_OBJECT,
+ KX_ACT_END_OBJECT,
+ KX_ACT_DYNAMIC,
+ KX_ACT_REPLACE_MESH,
+ KX_ACT_TRACKTO,
+ KX_ACT_CONSTRAINT,
+ KX_ACT_SCENE,
+ KX_ACT_RANDOM,
+ KX_ACT_MESSAGE,
+ KX_ACT_ACTION,
+ KX_ACT_CD,
+ KX_ACT_GAME,
+ KX_ACT_VISIBILITY,
+ KX_ACT_2DFILTER,
+ KX_ACT_PARENT,
+ KX_ACT_SHAPEACTION,
+ KX_ACT_STATE,
+ KX_ACT_ARMATURE,
+ };
+
+ SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type);
/**
* UnlinkObject(...)
@@ -127,7 +153,7 @@ public:
void IncLink() { m_links++; }
void DecLink();
bool IsNoLink() const { return !m_links; }
-
+ bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; }
#ifdef WITH_CXX_GUARDEDALLOC
public:
diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp
index 7cfd2adc1d0..65c9c4d0f57 100644
--- a/source/gameengine/GameLogic/SCA_IController.cpp
+++ b/source/gameengine/GameLogic/SCA_IController.cpp
@@ -33,6 +33,8 @@
#include "PyObjectPlus.h"
#include "../Ketsji/KX_PythonSeq.h" /* not nice, only need for KX_PythonSeq_CreatePyObject */
+#include <stdio.h>
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -196,6 +198,8 @@ void SCA_IController::ApplyState(unsigned int state)
}
}
+#ifndef DISABLE_PYTHON
+
/* Python api */
PyTypeObject SCA_IController::Type = {
@@ -247,3 +251,4 @@ PyObject* SCA_IController::pyattr_get_actuators(void *self_v, const KX_PYATTRIBU
{
return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_ACTUATORS);
}
+#endif // DISABLE_PYTHON
diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h
index 202921c6986..48514121661 100644
--- a/source/gameengine/GameLogic/SCA_IController.h
+++ b/source/gameengine/GameLogic/SCA_IController.h
@@ -98,10 +98,12 @@ public:
}
}
+
+#ifndef DISABLE_PYTHON
static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
+#endif // DISABLE_PYTHON
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
index f679d0ee487..6502fc6de41 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
@@ -173,6 +173,7 @@ CValue* SCA_ILogicBrick::GetEvent()
+#ifndef DISABLE_PYTHON
/* python stuff */
@@ -255,3 +256,5 @@ PyObject* SCA_ILogicBrick::BoolToPyArg(bool boolarg)
{
return PyLong_FromSsize_t(boolarg? KX_TRUE: KX_FALSE);
}
+
+#endif // DISABLE_PYTHON
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h
index ac533335f0b..11885f988f3 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.h
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h
@@ -125,6 +125,7 @@ public:
static class SCA_LogicManager* m_sCurrentLogicManager;
+#ifndef DISABLE_PYTHON
// python methods
static PyObject* pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
@@ -147,8 +148,9 @@ protected:
/** Convert a a c++ value to KX_TRUE, KX_FALSE in Python. */
PyObject* BoolToPyArg(bool);
-
+#endif // DISABLE_PYTHON
+
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp
index 2bffd029bd4..e63b616cab0 100644
--- a/source/gameengine/GameLogic/SCA_IObject.cpp
+++ b/source/gameengine/GameLogic/SCA_IObject.cpp
@@ -26,6 +26,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <iostream>
+#include <algorithm>
#include "SCA_IObject.h"
#include "SCA_ISensor.h"
@@ -76,6 +77,12 @@ SCA_IObject::~SCA_IObject()
(*ita)->Delete();
}
+ SCA_ObjectList::iterator ito;
+ for (ito = m_registeredObjects.begin(); !(ito==m_registeredObjects.end()); ++ito)
+ {
+ (*ito)->UnlinkObject(this);
+ }
+
//T_InterpolatorList::iterator i;
//for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
// delete *i;
@@ -123,6 +130,26 @@ void SCA_IObject::UnregisterActuator(SCA_IActuator* act)
}
}
+void SCA_IObject::RegisterObject(SCA_IObject* obj)
+{
+ // one object may be registered multiple times via constraint target
+ // store multiple reference, this will serve as registration counter
+ m_registeredObjects.push_back(obj);
+}
+
+void SCA_IObject::UnregisterObject(SCA_IObject* obj)
+{
+ SCA_ObjectList::iterator ito;
+ for (ito = m_registeredObjects.begin(); ito != m_registeredObjects.end(); ++ito)
+ {
+ if ((*ito) == obj) {
+ (*ito) = m_registeredObjects.back();
+ m_registeredObjects.pop_back();
+ break;
+ }
+ }
+}
+
void SCA_IObject::ReParentLogic()
{
SCA_ActuatorList& oldactuators = GetActuators();
@@ -165,7 +192,7 @@ void SCA_IObject::ReParentLogic()
// a new object cannot be client of any actuator
m_registeredActuators.clear();
-
+ m_registeredObjects.clear();
}
@@ -280,7 +307,7 @@ void SCA_IObject::SetState(unsigned int state)
}
}
-
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -318,3 +345,5 @@ PyMethodDef SCA_IObject::Methods[] = {
PyAttributeDef SCA_IObject::Attributes[] = {
{ NULL } //Sentinel
};
+
+#endif // DISABLE_PYTHON
diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h
index 3060410dc6b..f078e129378 100644
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ b/source/gameengine/GameLogic/SCA_IObject.h
@@ -36,15 +36,19 @@
#include "Value.h"
#include <vector>
+class SCA_IObject;
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;
typedef std::vector<SCA_IActuator *> SCA_ActuatorList;
+typedef std::vector<SCA_IObject *> SCA_ObjectList;
class SCA_IObject : public CValue
{
@@ -59,6 +63,7 @@ protected:
SCA_ControllerList m_controllers;
SCA_ActuatorList m_actuators;
SCA_ActuatorList m_registeredActuators; // actuators that use a pointer to this object
+ SCA_ObjectList m_registeredObjects; // objects that hold reference to this object
// SG_Dlist: element of objects with active actuators
// Head: SCA_LogicManager::m_activeActuators
@@ -143,13 +148,22 @@ public:
void RegisterActuator(SCA_IActuator* act);
void UnregisterActuator(SCA_IActuator* act);
+ void RegisterObject(SCA_IObject* objs);
+ void UnregisterObject(SCA_IObject* objs);
+ /**
+ * UnlinkObject(...)
+ * this object is informed that one of the object to which it holds a reference is deleted
+ * returns true if there was indeed a reference.
+ */
+ virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; }
+
SCA_ISensor* FindSensor(const STR_String& sensorname);
SCA_IActuator* FindActuator(const STR_String& actuatorname);
SCA_IController* FindController(const STR_String& controllername);
void SetCurrentTime(float currentTime) {}
- void ReParentLogic();
+ virtual void ReParentLogic();
/**
* Set whether or not to ignore activity culling requests
@@ -205,6 +219,7 @@ public:
typedef enum ObjectTypes {
OBJ_ARMATURE=0,
OBJ_CAMERA=1,
+ OBJ_LIGHT=2,
}ObjectTypes;
};
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index 497a5d1095a..877563e3161 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -35,6 +35,8 @@
// needed for IsTriggered()
#include "SCA_PythonController.h"
+#include <stdio.h>
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -288,6 +290,9 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr)
}
}
}
+
+#ifndef DISABLE_PYTHON
+
/* ----------------------------------------------- */
/* Python Functions */
/* ----------------------------------------------- */
@@ -379,5 +384,6 @@ int SCA_ISensor::pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrde
self->m_level = false;
return 0;
}
+#endif // DISABLE_PYTHON
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index 742b05bd88b..fce5f340be1 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -171,6 +171,7 @@ public:
bool IsNoLink() const
{ return !m_links; }
+#ifndef DISABLE_PYTHON
/* Python functions: */
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,reset);
@@ -178,6 +179,7 @@ public:
static PyObject* pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+#endif // DISABLE_PYTHON
};
#endif //__SCA_ISENSOR
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
index ff8f3b1c81f..480292774da 100644
--- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
@@ -37,8 +37,7 @@
SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(JOY_EVENTMGR),
- m_logicmgr(logicmgr)
+ : SCA_EventManager(logicmgr, JOY_EVENTMGR)
{
int i;
for (i=0; i<JOYINDEX_MAX; i++) {
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h
index be55e95b033..cd0e22cc367 100644
--- a/source/gameengine/GameLogic/SCA_JoystickManager.h
+++ b/source/gameengine/GameLogic/SCA_JoystickManager.h
@@ -35,8 +35,6 @@
using namespace std;
class SCA_JoystickManager : public SCA_EventManager
{
-
- class SCA_LogicManager* m_logicmgr;
/**
* SDL Joystick Class Instance
*/
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 4936b380352..9ac64b7f31e 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -32,6 +32,7 @@
#include "PyObjectPlus.h"
+#include <stdio.h>
#include <iostream>
@@ -244,6 +245,7 @@ bool SCA_JoystickSensor::isValid(SCA_JoystickSensor::KX_JOYSENSORMODE m)
return res;
}
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -413,3 +415,5 @@ PyObject* SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTR
SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
return PyBool_FromLong( joy ? joy->Connected() : 0 );
}
+
+#endif
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index b793c591ac1..49ca58ee14f 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -117,6 +117,8 @@ public:
return m_joyindex;
}
+#ifndef DISABLE_PYTHON
+
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
@@ -155,6 +157,8 @@ public:
return 0;
}
+#endif // DISABLE_PYTHON
+
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
index 279adab94d8..3d010f57055 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
@@ -37,9 +37,8 @@
SCA_KeyboardManager::SCA_KeyboardManager(SCA_LogicManager* logicmgr,
SCA_IInputDevice* inputdev)
- : SCA_EventManager(KEYBOARD_EVENTMGR),
- m_inputDevice(inputdev),
- m_logicmanager(logicmgr)
+ : SCA_EventManager(logicmgr, KEYBOARD_EVENTMGR),
+ m_inputDevice(inputdev)
{
}
@@ -65,7 +64,7 @@ void SCA_KeyboardManager::NextFrame()
SG_DList::iterator<SCA_ISensor> it(m_sensors);
for (it.begin();!it.end();++it)
{
- (*it)->Activate(m_logicmanager);
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h
index c5553a74aef..8155283a274 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h
@@ -45,8 +45,6 @@ using namespace std;
class SCA_KeyboardManager : public SCA_EventManager
{
class SCA_IInputDevice* m_inputDevice;
- class SCA_LogicManager* m_logicmanager;
-
public:
SCA_KeyboardManager(class SCA_LogicManager* logicmgr,class SCA_IInputDevice* inputdev);
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index d2e3871fec2..dcad65e6459 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -403,6 +403,7 @@ void SCA_KeyboardSensor::LogKeystrokes(void)
}
}
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python Functions */
@@ -495,6 +496,7 @@ PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU
return resultlist;
}
+#endif // DISABLE_PYTHON
/* Accessed from python */
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index d7e0f301a9d..0ce08b3e408 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -103,6 +103,7 @@ public:
virtual bool IsPositiveTrigger();
bool TriggerOnAllKeys();
+#ifndef DISABLE_PYTHON
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
@@ -113,6 +114,7 @@ public:
KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus);
static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+#endif
};
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp
index b782c6dfb93..d93f2e70e36 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.cpp
+++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp
@@ -305,6 +305,9 @@ void SCA_LogicManager::EndFrame()
void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor)
{
controller->Activate(m_triggeredControllerSet);
+
+#ifndef DISABLE_PYTHON
+
// so that the controller knows which sensor has activited it
// only needed for python controller
// Note that this is safe even if the controller is subclassed.
@@ -313,6 +316,7 @@ void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_I
SCA_PythonController* pythonController = (SCA_PythonController*)controller;
pythonController->AddTriggeredSensor(sensor);
}
+#endif
}
SCA_EventManager* SCA_LogicManager::FindEventManager(int eventmgrtype)
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp
index d407647cec3..c752701e785 100644
--- a/source/gameengine/GameLogic/SCA_MouseManager.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp
@@ -48,9 +48,8 @@
SCA_MouseManager::SCA_MouseManager(SCA_LogicManager* logicmgr,
SCA_IInputDevice* mousedev)
- : SCA_EventManager(MOUSE_EVENTMGR),
- m_mousedevice (mousedev),
- m_logicmanager(logicmgr)
+ : SCA_EventManager(logicmgr, MOUSE_EVENTMGR),
+ m_mousedevice (mousedev)
{
m_xpos = 0;
m_ypos = 0;
@@ -93,7 +92,7 @@ void SCA_MouseManager::NextFrame()
mousesensor->setX(mx);
mousesensor->setY(my);
- mousesensor->Activate(m_logicmanager);
+ mousesensor->Activate(m_logicmgr);
}
}
}
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h
index ef1533c636b..00bbab66aa6 100644
--- a/source/gameengine/GameLogic/SCA_MouseManager.h
+++ b/source/gameengine/GameLogic/SCA_MouseManager.h
@@ -47,7 +47,6 @@ class SCA_MouseManager : public SCA_EventManager
{
class SCA_IInputDevice* m_mousedevice;
- class SCA_LogicManager* m_logicmanager;
unsigned short m_xpos; // Cached location of the mouse pointer
unsigned short m_ypos;
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index 9d32682eaa9..466b8f7e741 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -57,7 +57,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
m_mousemode = mousemode;
m_triggermode = true;
- UpdateHotkey(this, NULL);
+ UpdateHotkey(this);
Init();
}
@@ -72,7 +72,7 @@ SCA_MouseSensor::~SCA_MouseSensor()
/* Nothing to be done here. */
}
-int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*)
+void SCA_MouseSensor::UpdateHotkey(void *self)
{
// gosh, this function is so damn stupid
// its here because of a design mistake in the mouse sensor, it should only
@@ -100,9 +100,6 @@ int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*)
default:
; /* ignore, no hotkey */
}
- // return value is used in py_setattro(),
- // 0=attribute checked ok (see Attributes array definition)
- return 0;
}
CValue* SCA_MouseSensor::GetReplica()
@@ -239,6 +236,8 @@ bool SCA_MouseSensor::isValid(SCA_MouseSensor::KX_MOUSESENSORMODE m)
return ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX));
}
+#ifndef DISABLE_PYTHON
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@@ -296,10 +295,20 @@ PyMethodDef SCA_MouseSensor::Methods[] = {
{NULL,NULL} //Sentinel
};
+int SCA_MouseSensor::UpdateHotkeyPy(void *self, const PyAttributeDef*)
+{
+ UpdateHotkey(self);
+ // return value is used in py_setattro(),
+ // 0=attribute checked ok (see Attributes array definition)
+ return 0;
+}
+
PyAttributeDef SCA_MouseSensor::Attributes[] = {
- KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkey),
+ KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkeyPy),
KX_PYATTRIBUTE_SHORT_LIST_RO("position",SCA_MouseSensor,m_x,2),
{ NULL } //Sentinel
};
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
index a679e605428..25b3a6c2e6e 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.h
@@ -86,8 +86,6 @@ class SCA_MouseSensor : public SCA_ISensor
bool isValid(KX_MOUSESENSORMODE);
- static int UpdateHotkey(void *self, const PyAttributeDef*);
-
SCA_MouseSensor(class SCA_MouseManager* keybdmgr,
int startx,int starty,
short int mousemode,
@@ -102,14 +100,20 @@ class SCA_MouseSensor : public SCA_ISensor
SCA_IInputDevice::KX_EnumInputs GetHotKey();
void setX(short x);
void setY(short y);
-
+
+ static void UpdateHotkey(void *self);
+
+
+#ifndef DISABLE_PYTHON
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
+ static int UpdateHotkeyPy(void *self, const PyAttributeDef *);
+
// get button status
KX_PYMETHOD_DOC_O(SCA_MouseSensor,getButtonStatus);
-
+#endif
};
#endif //__KX_MOUSESENSOR
diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp
index c971c06fadd..99c74e6d737 100644
--- a/source/gameengine/GameLogic/SCA_NANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_NANDController.cpp
@@ -91,7 +91,7 @@ CValue* SCA_NANDController::GetReplica()
return replica;
}
-
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -128,4 +128,6 @@ PyAttributeDef SCA_NANDController::Attributes[] = {
{ NULL } //Sentinel
};
+#endif
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp
index 7a8b09e4bec..a84453de977 100644
--- a/source/gameengine/GameLogic/SCA_NORController.cpp
+++ b/source/gameengine/GameLogic/SCA_NORController.cpp
@@ -91,7 +91,7 @@ CValue* SCA_NORController::GetReplica()
return replica;
}
-
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -128,4 +128,6 @@ PyAttributeDef SCA_NORController::Attributes[] = {
{ NULL } //Sentinel
};
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp
index 12e2f610986..0f750eedf77 100644
--- a/source/gameengine/GameLogic/SCA_ORController.cpp
+++ b/source/gameengine/GameLogic/SCA_ORController.cpp
@@ -87,6 +87,8 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr)
}
}
+#ifndef DISABLE_PYTHON
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@@ -122,4 +124,6 @@ PyAttributeDef SCA_ORController::Attributes[] = {
{ NULL } //Sentinel
};
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 9446487cdb7..2b480a8e8cb 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -43,7 +43,7 @@
/* ------------------------------------------------------------------------- */
SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const STR_String& propname,const STR_String& expr,int acttype)
- : SCA_IActuator(gameobj),
+ : SCA_IActuator(gameobj, KX_ACT_PROPERTY),
m_type(acttype),
m_propname(propname),
m_exprtxt(expr),
@@ -221,6 +221,7 @@ void SCA_PropertyActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
}
}
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -260,4 +261,6 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = {
{ NULL } //Sentinel
};
+#endif
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
index 764465309df..e01ce74e0a9 100644
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
@@ -35,8 +35,7 @@
SCA_PropertyEventManager::SCA_PropertyEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(PROPERTY_EVENTMGR),
- m_logicmgr(logicmgr)
+ : SCA_EventManager(logicmgr, PROPERTY_EVENTMGR)
{
}
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h
index a9692377df8..5a036abb8b7 100644
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h
+++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h
@@ -37,8 +37,6 @@ using namespace std;
class SCA_PropertyEventManager : public SCA_EventManager
{
- class SCA_LogicManager* m_logicmgr;
-
public:
SCA_PropertyEventManager(class SCA_LogicManager* logicmgr);
virtual ~SCA_PropertyEventManager();
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index 9c09c8410fb..2a4222af355 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -38,6 +38,7 @@
#include "SCA_EventManager.h"
#include "SCA_LogicManager.h"
#include "BoolValue.h"
+#include "FloatValue.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -190,6 +191,22 @@ bool SCA_PropertySensor::CheckPropertyCondition()
m_checkpropval.Upper();
}
result = (testprop == m_checkpropval);
+
+ /* Patch: floating point values cant use strings usefully since you can have "0.0" == "0.0000"
+ * this could be made into a generic Value class function for comparing values with a string.
+ */
+ if(result==false && dynamic_cast<CFloatValue *>(orgprop) != NULL) {
+ float f;
+
+ if(EOF == sscanf(m_checkpropval.ReadPtr(), "%f", &f))
+ {
+ //error
+ }
+ else {
+ result = (f == ((CFloatValue *)orgprop)->GetFloat());
+ }
+ }
+ /* end patch */
}
orgprop->Release();
@@ -290,16 +307,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 +353,6 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = {
{ NULL } //Sentinel
};
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
index a5bbfc8438b..cd8a6713148 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.h
@@ -84,6 +84,8 @@ public:
virtual bool IsPositiveTrigger();
virtual CValue* FindIdentifier(const STR_String& identifiername);
+#ifndef DISABLE_PYTHON
+
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
@@ -92,6 +94,8 @@ public:
* Test whether this is a sensible value (type check)
*/
static int validValueForProperty(void* self, const PyAttributeDef*);
+
+#endif
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index ecaa8c508db..ac3e0434d20 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -34,8 +34,12 @@
#include "SCA_ISensor.h"
#include "SCA_IActuator.h"
#include "PyObjectPlus.h"
+
+#ifndef DISABLE_PYTHON
#include "compile.h"
#include "eval.h"
+#endif // DISABLE_PYTHON
+
#include <algorithm>
@@ -49,13 +53,18 @@ SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL;
SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode)
: SCA_IController(gameobj),
+#ifndef DISABLE_PYTHON
m_bytecode(NULL),
m_function(NULL),
+#endif
m_function_argc(0),
m_bModified(true),
m_debug(false),
- m_mode(mode),
- m_pythondictionary(NULL)
+ m_mode(mode)
+#ifndef DISABLE_PYTHON
+ , m_pythondictionary(NULL)
+#endif
+
{
}
@@ -78,6 +87,8 @@ int SCA_PythonController::Release()
SCA_PythonController::~SCA_PythonController()
{
+
+#ifndef DISABLE_PYTHON
//printf("released python byte script\n");
Py_XDECREF(m_bytecode);
@@ -88,6 +99,7 @@ SCA_PythonController::~SCA_PythonController()
PyDict_Clear(m_pythondictionary);
Py_DECREF(m_pythondictionary);
}
+#endif
}
@@ -95,7 +107,8 @@ SCA_PythonController::~SCA_PythonController()
CValue* SCA_PythonController::GetReplica()
{
SCA_PythonController* replica = new SCA_PythonController(*this);
-
+
+#ifndef DISABLE_PYTHON
/* why is this needed at all??? - m_bytecode is NULL'd below so this doesnt make sense
* but removing it crashes blender (with YoFrankie). so leave in for now - Campbell */
Py_XINCREF(replica->m_bytecode);
@@ -113,6 +126,7 @@ CValue* SCA_PythonController::GetReplica()
if (m_pythondictionary)
Py_INCREF(replica->m_pythondictionary);
*/
+#endif
// this will copy properties and so on...
replica->ProcessReplica();
@@ -136,8 +150,8 @@ void SCA_PythonController::SetScriptName(const STR_String& name)
}
-
-void SCA_PythonController::SetDictionary(PyObject* pythondictionary)
+#ifndef DISABLE_PYTHON
+void SCA_PythonController::SetNamespace(PyObject* pythondictionary)
{
if (m_pythondictionary)
{
@@ -151,6 +165,7 @@ void SCA_PythonController::SetDictionary(PyObject* pythondictionary)
PyDict_SetItemString(m_pythondictionary, "__file__", PyUnicode_FromString(m_scriptName.Ptr()));
}
+#endif
int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
{
@@ -160,6 +175,8 @@ int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
return 0;
}
+#ifndef DISABLE_PYTHON
+
/* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */
PyObject* SCA_PythonController::sPyGetCurrentController(PyObject *self)
{
@@ -360,6 +377,7 @@ bool SCA_PythonController::Import()
return true;
}
+
void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
{
m_sCurrentController = this;
@@ -514,5 +532,13 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D
return PY_SET_ATTR_SUCCESS;
}
+#else // DISABLE_PYTHON
+
+void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
+{
+ /* intentionally blank */
+}
+
+#endif // DISABLE_PYTHON
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
index 9311b3f355e..eeac710c6ea 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ b/source/gameengine/GameLogic/SCA_PythonController.h
@@ -42,8 +42,10 @@ class SCA_IObject;
class SCA_PythonController : public SCA_IController
{
Py_Header;
+#ifndef DISABLE_PYTHON
struct _object * m_bytecode; /* SCA_PYEXEC_SCRIPT only */
PyObject* m_function; /* SCA_PYEXEC_MODULE only */
+#endif
int m_function_argc;
bool m_bModified;
bool m_debug; /* use with SCA_PYEXEC_MODULE for reloading every logic run */
@@ -53,9 +55,10 @@ class SCA_PythonController : public SCA_IController
protected:
STR_String m_scriptText;
STR_String m_scriptName;
+#ifndef DISABLE_PYTHON
PyObject* m_pythondictionary; /* for SCA_PYEXEC_SCRIPT only */
PyObject* m_pythonfunction; /* for SCA_PYEXEC_MODULE only */
-
+#endif
std::vector<class SCA_ISensor*> m_triggeredSensors;
public:
@@ -80,7 +83,9 @@ class SCA_PythonController : public SCA_IController
void SetScriptText(const STR_String& text);
void SetScriptName(const STR_String& name);
- void SetDictionary(PyObject* pythondictionary);
+#ifndef DISABLE_PYTHON
+ void SetNamespace(PyObject* pythondictionary);
+#endif
void SetDebug(bool debug) { m_debug = debug; }
void AddTriggeredSensor(class SCA_ISensor* sensor)
{ m_triggeredSensors.push_back(sensor); }
@@ -89,7 +94,7 @@ class SCA_PythonController : public SCA_IController
bool Import();
void ErrorPrint(const char *error_msg);
-
+#ifndef DISABLE_PYTHON
static const char* sPyGetCurrentController__doc__;
static PyObject* sPyGetCurrentController(PyObject* self);
static const char* sPyAddActiveActuator__doc__;
@@ -106,8 +111,7 @@ class SCA_PythonController : public SCA_IController
static PyObject* pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
-
+#endif
};
#endif //KX_PYTHONCONTROLLER_H
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index a3a5cc2303e..fa85bdd768e 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -51,7 +51,7 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
float para1,
float para2,
const STR_String &propName)
- : SCA_IActuator(gameobj),
+ : SCA_IActuator(gameobj, KX_ACT_RANDOM),
m_propname(propName),
m_parameter1(para1),
m_parameter2(para2),
@@ -309,6 +309,8 @@ void SCA_RandomActuator::enforceConstraints() {
}
}
+#ifndef DISABLE_PYTHON
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@@ -546,5 +548,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential,
enforceConstraints();
Py_RETURN_NONE;
}
-
+
+#endif
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
index f84c44b43c9..2eb9b8d5d14 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.h
@@ -91,6 +91,8 @@ class SCA_RandomActuator : public SCA_IActuator
virtual CValue* GetReplica();
virtual void ProcessReplica();
+
+#ifndef DISABLE_PYTHON
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
@@ -109,6 +111,9 @@ class SCA_RandomActuator : public SCA_IActuator
KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatUniform);
KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatNormal);
KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential);
+
+#endif // DISABLE_PYTHON
+
}; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */
#endif
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
index 976597aa812..780f8d10857 100644
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
@@ -42,8 +42,7 @@ using namespace std;
#endif
SCA_RandomEventManager::SCA_RandomEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(RANDOM_EVENTMGR),
- m_logicmgr(logicmgr)
+ : SCA_EventManager(logicmgr, RANDOM_EVENTMGR)
{
}
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h
index c8b511b87b7..81896709551 100644
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.h
+++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h
@@ -39,8 +39,6 @@ using namespace std;
class SCA_RandomEventManager : public SCA_EventManager
{
- class SCA_LogicManager* m_logicmgr;
-
public:
SCA_RandomEventManager(class SCA_LogicManager* logicmgr);
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index 890875e61c6..922e44b1c1d 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -124,6 +124,8 @@ bool SCA_RandomSensor::Evaluate()
return evaluateResult;
}
+#ifndef DISABLE_PYTHON
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@@ -178,4 +180,6 @@ int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *at
return PY_SET_ATTR_SUCCESS;
}
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h
index f93cf57370e..8126824c3dd 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.h
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.h
@@ -56,13 +56,15 @@ public:
virtual bool IsPositiveTrigger();
virtual void Init();
+#ifndef DISABLE_PYTHON
+
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
static PyObject* pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
+#endif
};
#endif //__KX_RANDOMSENSOR
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
index 911ea772bef..1b49906b8de 100644
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
@@ -43,7 +43,7 @@
#include "FloatValue.h"
SCA_TimeEventManager::SCA_TimeEventManager(SCA_LogicManager* logicmgr)
-: SCA_EventManager(TIME_EVENTMGR)
+: SCA_EventManager(NULL, TIME_EVENTMGR)
{
}
diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp
index 17350feb98b..e726a49347c 100644
--- a/source/gameengine/GameLogic/SCA_XNORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XNORController.cpp
@@ -95,7 +95,7 @@ CValue* SCA_XNORController::GetReplica()
return replica;
}
-
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -132,4 +132,6 @@ PyAttributeDef SCA_XNORController::Attributes[] = {
{ NULL } //Sentinel
};
+#endif // DISABLE_PYTHON
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp
index a6a7cc25897..71cc4374e95 100644
--- a/source/gameengine/GameLogic/SCA_XORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XORController.cpp
@@ -95,7 +95,7 @@ CValue* SCA_XORController::GetReplica()
return replica;
}
-
+#ifndef DISABLE_PYTHON
/* ------------------------------------------------------------------------- */
/* Python functions */
@@ -131,5 +131,6 @@ PyMethodDef SCA_XORController::Methods[] = {
PyAttributeDef SCA_XORController::Attributes[] = {
{ NULL } //Sentinel
};
+#endif // DISABLE_PYTHON
/* eof */
diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript
index 1530c71c7f3..3840754ed06 100644
--- a/source/gameengine/GameLogic/SConscript
+++ b/source/gameengine/GameLogic/SConscript
@@ -7,9 +7,6 @@ incs = '. #/source/kernel/gen_system #/intern/string'
incs += ' #/source/gameengine/Expressions #/intern/moto/include'
incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph'
-incs += ' ' + env['BF_PYTHON_INC']
-
-
defs = []
if env['WITH_BF_SDL']:
@@ -17,6 +14,11 @@ if env['WITH_BF_SDL']:
else:
defs.append('DISABLE_SDL')
+if env['WITH_BF_PYTHON']:
+ incs += ' ' + env['BF_PYTHON_INC']
+else:
+ defs.append('DISABLE_PYTHON')
+
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
if env['BF_DEBUG']:
defs.append('_DEBUG')