blender/source/gameengine/Ketsji
Benoit Bolsee 5372def2b0 BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of 
sensor and actuators, full GUI support and selective display of sensors and actuators. 
Note: Python API is available but not documented yet. It will be added asap.

State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value; 
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers 
that belong to active states. Sensors and actuators don't have a state mask but are effectively 
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors 
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated, 
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated, 
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more 
controllers of a single state) will generate a pulse each time the state becomes active. This feature is 
not available on all sensors, see the notes below.

GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object. 
The Ini button sets the state mask back to the object default state. You can change the default state 
of object by first selecting the desired state mask and storing using the menu under the State button. 
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender, 
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.

The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state 
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility. 

The new Sta button in the sensor and actuator column header allows you to display only the sensors and 
actuators that are linked to visible controllers.

A new state actuator is available to modify the state during the game. It defines a bit mask and 
the operation to apply on the current object state mask:

Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.

Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller 
  of the state as the state name. The GUI will support that convention by displaying as a hint the name
  of the first controller of the state when you move the mouse over a state bit of the object state mask
  or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are 
  part of a logical group, it is recommended to put the state engine only in the main object and to
  link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1 
  so that all the controllers belong to this single state. This ensures backward compatibility with 
  existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are 
  guaranteed to execute before being eventually disabled due to the state change. This is useful for
  example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
  are acticated again, they will behave as follow:
  * keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive 
    to new key press.
  * collision sensor: objects already colliding won't be detected. Only new collisions are 
    detected.
  * near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
..
KXNetwork BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
BL_BlenderShader.cpp Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
BL_BlenderShader.h Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
BL_Material.cpp Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
BL_Material.h Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
BL_Shader.cpp Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
BL_Shader.h applied Charlies patch, reverted some GLSL shader stuff, improved penetration depth estimate. 2006-04-11 05:57:30 +00:00
BL_Texture.cpp Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
BL_Texture.h First commit! Small bug fix for cube map crashing in the player. 2007-01-13 08:30:08 +00:00
CMakeLists.txt Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
KX_BlenderMaterial.cpp Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
KX_BlenderMaterial.h Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
KX_BulletPhysicsController.cpp BGE fix: game object to controller links consistancy maintained regardless of order of deletion 2008-03-09 21:51:38 +00:00
KX_BulletPhysicsController.h Removed old Blender/extern/bullet, and upgraded game engine to use Bullet 2.x 2006-11-21 00:53:40 +00:00
KX_Camera.cpp fix BGE bug #8646: unusable anaglyph settings 2008-05-24 08:34:04 +00:00
KX_Camera.h fix BGE bug #8646: unusable anaglyph settings 2008-05-24 08:34:04 +00:00
KX_CameraActuator.cpp Fix BGE bug #6054: Camera actuator crashes Blender. The crash occurs when min,max << height (bad practice anyway). 2008-05-07 22:32:45 +00:00
KX_CameraActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_CameraIpoSGController.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_CameraIpoSGController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_CDActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_CDActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ClientObjectInfo.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ConstraintActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ConstraintActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ConstraintWrapper.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ConstraintWrapper.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ConvertPhysicsObject.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ConvertPhysicsObjects.cpp Fix BGE bug: dynamic-but-not-rigid objects are added as rigid body during the game. 2008-05-01 16:00:59 +00:00
KX_EmptyObject.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_EmptyObject.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_GameActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_GameActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_GameObject.cpp BGE patch #13625: getLinearVelocity() rewrite to use only vector and matrix operations 2008-06-18 21:22:17 +00:00
KX_GameObject.h BGE Patch: Add Shape Action support and update MSCV_7 project file for glew. 2008-06-18 06:46:49 +00:00
KX_IInterpolator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_IPhysicsController.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_IPhysicsController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_IPO_SGController.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_IPO_SGController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_IpoActuator.cpp Use the scenes framerate for ipo and action framerate in the game engine, was hard coded to 25. 2008-06-17 10:06:38 +00:00
KX_IpoActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_IPOTransform.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_IScalarInterpolator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ISceneConverter.h Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
KX_ISystem.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_KetsjiEngine.cpp Use the scenes framerate for ipo and action framerate in the game engine, was hard coded to 25. 2008-06-17 10:06:38 +00:00
KX_KetsjiEngine.h Use the scenes framerate for ipo and action framerate in the game engine, was hard coded to 25. 2008-06-17 10:06:38 +00:00
KX_Light.cpp last commit had a typo, also adjusted teh and colour instances 2008-05-12 21:12:10 +00:00
KX_Light.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_LightIpoSGController.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_LightIpoSGController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_MaterialIpoController.cpp changed the size of some local vars for 64bit linux. 2006-01-06 15:29:11 +00:00
KX_MaterialIpoController.h Sorry to break the cvs-closed status, so if you really need to make a new 2.40 build, just disable the game engine if it doesn't compile for a platform. Again, sorry if this breaks non-windows platforms, but I hope people help to get this amazing fix working for all platforms. Armature-fixing contribution from Snailrose. Also lots of cool things from Snailrose and Lagan. 2006-01-06 03:46:54 +00:00
KX_MeshProxy.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_MeshProxy.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_MotionState.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_MotionState.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_MouseFocusSensor.cpp BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_MouseFocusSensor.h BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_NearSensor.cpp fix BGE bug #8094: Collision sensor on child object makes the object rotate or move very fast. Collision sensor can now be set on child object without side effect. 2008-04-19 21:09:40 +00:00
KX_NearSensor.h fix BGE bug #8094: Collision sensor on child object makes the object rotate or move very fast. Collision sensor can now be set on child object without side effect. 2008-04-19 21:09:40 +00:00
KX_ObColorIpoSGController.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ObColorIpoSGController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ObjectActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ObjectActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_OdePhysicsController.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_OdePhysicsController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_OrientationInterpolator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_OrientationInterpolator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ParentActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ParentActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PhysicsEngineEnums.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PhysicsObjectWrapper.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PhysicsObjectWrapper.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PhysicsPropertiesobsolete.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PolygonMaterial.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PolygonMaterial.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PositionInterpolator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PositionInterpolator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PyConstraintBinding.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PyConstraintBinding.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PyMath.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PyMath.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_PythonInit.cpp Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
KX_PythonInit.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_RadarSensor.cpp BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_RadarSensor.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_RayCast.cpp bugfix, BGE, use vec.safe_normalized() rather then vec.normalized() because in some cases the ray_cast sensor could crash blender. 2008-06-18 09:06:51 +00:00
KX_RayCast.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_RayEventManager.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_RayEventManager.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_RaySensor.cpp BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_RaySensor.h BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_SCA_AddObjectActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SCA_AddObjectActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SCA_EndObjectActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SCA_EndObjectActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SCA_ReplaceMeshActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SCA_ReplaceMeshActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ScalarInterpolator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ScalarInterpolator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ScalingInterpolator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_ScalingInterpolator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_Scene.cpp BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_Scene.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SceneActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SceneActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SG_BoneParentNodeRelationship.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SG_BoneParentNodeRelationship.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SG_NodeRelationships.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SG_NodeRelationships.h Added access for adjusting timeOffset value at runtime, used for apricot (Franky climbing walls) 2008-06-14 17:12:49 +00:00
KX_SoundActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_SoundActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_StateActuator.cpp BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_StateActuator.h BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_SumoPhysicsController.cpp Removed old Blender/extern/bullet, and upgraded game engine to use Bullet 2.x 2006-11-21 00:53:40 +00:00
KX_SumoPhysicsController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_TimeCategoryLogger.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_TimeCategoryLogger.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_TimeLogger.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_TimeLogger.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_TouchEventManager.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_TouchEventManager.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_TouchSensor.cpp BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_TouchSensor.h BGE patch: add state engine support in the logic bricks. 2008-06-22 14:23:57 +00:00
KX_TrackToActuator.cpp Fix BGE bug #7532: TrackTo Actuator does not work correctly if it has a Vertex Parent. This is only a partial fix: the user must put the parent vertex at the center of the parent object and disable the physics on the tracking object (use empty or collision free object). 2008-05-14 20:22:57 +00:00
KX_TrackToActuator.h BGE bug: crash when an object being tracked-to is deleted (bad practice anyway). Fix by creating a generic cross reference between actuators (only TrackTo uses it at the moment) and objects so that the actuator is informed when the target object is deleted 2008-04-26 20:41:25 +00:00
KX_VehicleWrapper.cpp //someone reversed axle direction conventions inside Bullet (axle winding), so need to compensate to keep game blender vehicles working the same. 2007-07-06 04:45:57 +00:00
KX_VehicleWrapper.h exposed a few more tuning paramters 2006-02-21 07:08:23 +00:00
KX_VertexProxy.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_VertexProxy.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_VisibilityActuator.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_VisibilityActuator.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_WorldInfo.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_WorldInfo.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_WorldIpoController.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
KX_WorldIpoController.h Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
Makefile Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00
SConscript Merge of apricot branch game engine changes into trunk, excluding GLSL. 2008-06-17 10:27:34 +00:00