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:
authorSybren A. Stüvel <sybren@stuvel.eu>2015-02-05 11:39:53 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2015-02-08 17:52:13 +0300
commitdd65a44c9a192d62f7661090682ee0dc99fb0491 (patch)
tree38a4a150113aca9c09de3851052597ee0f8bdfb9 /source/gameengine/Ketsji/KX_TouchEventManager.h
parent51b645a655eb41c5b73d8487ee7df9ba99fc692b (diff)
BGE physics: When colliding, report first contact point to Python
This patch adds two parameters to the functions in the collisionCallbacks list. The callback function should thus be like this: ``` def on_colliding(other, point, normal): print("Colliding with %s at %s with normal %s" % (other, point, normal)) game_ob.collisionCallbacks.append(on_colliding) ``` The `point` parameter will contain the collision point in world coordinates on the current object, and the `normal` contains the surface normal at the collision point. The callback functions are checked for the number of arguments `co_argcount`. The new `point` and `normal` arguments are only passed when `co_argcount > 1` or when `co_argcount` cannot be determined. Reviewers: brita_, campbellbarton Subscribers: sergey, sybren, agoose77 Projects: #game_physics Differential Revision: https://developer.blender.org/D926
Diffstat (limited to 'source/gameengine/Ketsji/KX_TouchEventManager.h')
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h
index bd4903c1545..d9c6fdad307 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.h
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.h
@@ -45,7 +45,29 @@ class PHY_IPhysicsEnvironment;
class KX_TouchEventManager : public SCA_EventManager
{
- typedef std::pair<PHY_IPhysicsController*, PHY_IPhysicsController*> NewCollision;
+ /**
+ * Contains two colliding objects and the first contact point.
+ */
+ class NewCollision {
+ public:
+ PHY_IPhysicsController *first;
+ PHY_IPhysicsController *second;
+ PHY_CollData *colldata;
+
+ /**
+ * Creates a copy of the given PHY_CollData; freeing that copy should be done by the owner of
+ * the NewCollision object.
+ *
+ * This allows us to efficiently store NewCollision objects in a std::set without creating more
+ * copies of colldata, as the NewCollision copy constructor reuses the pointer and doesn't clone
+ * it again. */
+ NewCollision(PHY_IPhysicsController *first,
+ PHY_IPhysicsController *second,
+ const PHY_CollData *colldata);
+ NewCollision(const NewCollision &to_copy);
+ bool operator<(const NewCollision &other) const;
+ };
+
PHY_IPhysicsEnvironment* m_physEnv;
std::set<NewCollision> m_newCollisions;