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:
authorCampbell Barton <ideasman42@gmail.com>2009-02-25 20:19:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-02-25 20:19:30 +0300
commita4ad52f1aaa1c8ed0d2f1345cbff99769f353ae9 (patch)
tree119ccf2f29b2e713ddbceafb63096e3e541ab95f /source/gameengine/Ketsji/KX_TouchSensor.h
parent7fffb0b6302618049a35e6bacf0aeed70a47d8aa (diff)
New Pulse option for the collision sensor (off by default wont change existing logic)
Previously only the first collision would trigger an event (no collisions a negative event ofcourse) With the Pulse option enabled, any change to the set of colliding objects will trigger an event. Added this because there was no way to count how many sheep were on a platform in YoFrankie without running a script periodically. Changes in collision are detected by comparing the number of objects colliding with the last event, as well as a hash made from the object pointers. Also changed the touch sensors internal list of colliding objects to only contain objects that match the property or material. - pulse isnt a great name, could change this.
Diffstat (limited to 'source/gameengine/Ketsji/KX_TouchSensor.h')
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h
index e07f89f0a31..c463226a5be 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.h
+++ b/source/gameengine/Ketsji/KX_TouchSensor.h
@@ -39,6 +39,12 @@ struct PHY_CollData;
#include "KX_ClientObjectInfo.h"
+#if defined(_WIN64)
+typedef unsigned __int64 uint_ptr;
+#else
+typedef unsigned long uint_ptr;
+#endif
+
class KX_TouchEventManager;
class KX_TouchSensor : public SCA_ISensor
@@ -51,6 +57,7 @@ protected:
*/
STR_String m_touchedpropname;
bool m_bFindMaterial;
+ bool m_bTouchPulse; /* changes in the colliding objects trigger pulses */
class SCA_EventManager* m_eventmgr;
class PHY_IPhysicsController* m_physCtrl;
@@ -58,13 +65,20 @@ protected:
bool m_bCollision;
bool m_bTriggered;
bool m_bLastTriggered;
+
+ // Use with m_bTouchPulse to detect changes
+ int m_bLastCount; /* size of m_colliders last tick */
+ uint_ptr m_bColliderHash; /* hash collision objects pointers to trigger incase one object collides and another takes its place */
+ uint_ptr m_bLastColliderHash;
+
SCA_IObject* m_hitObject;
class CListValue* m_colliders;
public:
KX_TouchSensor(class SCA_EventManager* eventmgr,
class KX_GameObject* gameobj,
- bool fFindMaterial,
+ bool bFindMaterial,
+ bool bTouchPulse,
const STR_String& touchedpropname,
PyTypeObject* T=&Type) ;
virtual ~KX_TouchSensor();