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:
authorMitchell Stokes <mogurijin@gmail.com>2012-10-30 19:44:16 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-10-30 19:44:16 +0400
commit3bf9bb3b13521c8bba4d559f308c5b2c04973df8 (patch)
tree2f1e92d25671239d16b51df88f57ffc6dea93c79 /source/gameengine/Ketsji
parent5753ede9a5cda9e23cc346ca57f6fb677e9fbb92 (diff)
BGE: Adding support for Bullet's collision masks. Each object now has a collision mask and a collision group. Object A and object B collide if object A's groups is in object B's mask and object B's group is in object A's mask. In other words, the group defines what the object is (collision wise) and the group defines what the object can collide with.
The majority of this patch was provided by Kupoman with some edits from me and heavy testing by z0r.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp13
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h11
2 files changed, 24 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 48a45c2d1c2..a669f4346ea 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -531,6 +531,19 @@ void KX_GameObject::ActivateGraphicController(bool recurse)
}
}
+void KX_GameObject::SetUserCollisionGroup(short group)
+{
+ m_userCollisionGroup = group;
+}
+void KX_GameObject::SetUserCollisionMask(short mask)
+{
+ m_userCollisionMask = mask;
+}
+
+bool KX_GameObject::CheckCollision(KX_GameObject* other)
+{
+ return this->m_userCollisionGroup & other->m_userCollisionMask;
+}
CValue* KX_GameObject::GetReplica()
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 5ceef2c60c9..d5ae13eb702 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -98,6 +98,10 @@ protected:
bool m_bIsNegativeScaling;
MT_Vector4 m_objectColor;
+ // Bit fields for user control over physics collisions
+ short m_userCollisionGroup;
+ short m_userCollisionMask;
+
// visible = user setting
// culled = while rendering, depending on camera
bool m_bVisible;
@@ -494,6 +498,13 @@ public:
*/
void ActivateGraphicController(bool recurse);
+ void SetUserCollisionGroup(short filter);
+ void SetUserCollisionMask(short mask);
+ /**
+ * Extra broadphase check for user controllable collisions
+ */
+ bool CheckCollision(KX_GameObject *other);
+
/**
* \section Coordinate system manipulation functions
*/