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:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-09-25 01:22:24 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-09-25 01:22:24 +0400
commit1483fafd1372a3d3e025d08634e798adb7da512f (patch)
tree9191765749e29866339f4c31d892603f5f8b334d /source/gameengine/GameLogic
parentc995c605f640d8d688e6e58e0fe247ca83f91696 (diff)
parent222fe6b1a5d49f67177cbb762f55a0e482145f5d (diff)
Merge of itasc branch. Project files, scons and cmake should be working. Makefile updated but not tested. Comes with Eigen2 2.0.6 C++ matrix library.
Diffstat (limited to 'source/gameengine/GameLogic')
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_BasicEventManager.cpp62
-rw-r--r--source/gameengine/GameLogic/SCA_BasicEventManager.h59
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.h4
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h32
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.cpp29
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h14
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp2
10 files changed, 198 insertions, 11 deletions
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
index 9dfb5ddc38f..9b04e263350 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),
diff --git a/source/gameengine/GameLogic/SCA_BasicEventManager.cpp b/source/gameengine/GameLogic/SCA_BasicEventManager.cpp
new file mode 100644
index 00000000000..24cae439fb7
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_BasicEventManager.cpp
@@ -0,0 +1,62 @@
+/**
+ * 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(BASIC_EVENTMGR),
+ m_logicmgr(logicmgr)
+{
+}
+
+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..1aae5f9be5c
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_BasicEventManager.h
@@ -0,0 +1,59 @@
+/**
+ * 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
+{
+ class SCA_LogicManager* m_logicmgr;
+
+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_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h
index 424150ffa63..f77b115ee03 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.h
+++ b/source/gameengine/GameLogic/SCA_EventManager.h
@@ -52,10 +52,10 @@ 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);
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
index 0fda75590c1..0338213b3cf 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_IActuator.cpp
@@ -34,8 +34,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_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp
index 2bffd029bd4..fbf66b64d08 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();
}
diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h
index 3060410dc6b..64ea0a76af1 100644
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ b/source/gameengine/GameLogic/SCA_IObject.h
@@ -36,6 +36,7 @@
#include "Value.h"
#include <vector>
+class SCA_IObject;
class SCA_ISensor;
class SCA_IController;
class SCA_IActuator;
@@ -45,6 +46,7 @@ template<class T> T PyVecTo(PyObject*);
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 +61,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 +146,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
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 9446487cdb7..2a3e600a653 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),
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index a3a5cc2303e..8f9482b7826 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),