diff options
author | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-10-07 23:14:43 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-10-07 23:14:43 +0300 |
commit | 720d4521cdd0986d9c6df97924b72eed72e5a3af (patch) | |
tree | c90b5192844d4f0cb8c49f32596fcb60e2fe863d /source/gameengine/Ketsji/KX_RaySensor.cpp | |
parent | 7a06613b8219684459374b2440dbfc6a6f2cdbd5 (diff) |
BGE : Collision mask support in raycast + and raycast cleanup.
I have removed the m_pHitObject, m_xray and m_testPropName and replace them by a temporary struct "RayCastData" which contains these datas and a collision mask. Finally i add a collision mask argument in the python function "rayCast" :
```
rayCast(to, from, dist, prop, face, xray, poly, mask)
```
It can be useful to hit only object which are on the right colision layer. for example if you have hitbox for a charater or vehicle you don't want to hit it with raycast.
test file : {F237337}
left mouse click on two planes and see console messages.
Somewhat more elaborate test file by @sybren: {F237779}
Look around and click on the cubes. One cube lamp responds, the other doesn't, based on their collision groups.
Reviewers: moguri, hg1, agoose77, campbellbarton, sybren
Reviewed By: agoose77, campbellbarton, sybren
Subscribers: campbellbarton, sergey, blueprintrandom, sybren
Projects: #game_engine, #game_physics
Differential Revision: https://developer.blender.org/D1239
Diffstat (limited to 'source/gameengine/Ketsji/KX_RaySensor.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_RaySensor.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index c97d233a67b..4ffb5f332db 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -107,7 +107,7 @@ bool KX_RaySensor::IsPositiveTrigger() return result; } -bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void * const data) +bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void *UNUSED(data)) { KX_GameObject* hitKXObj = client->m_gameobject; @@ -158,7 +158,7 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void /* this function is used to pre-filter the object before casting the ray on them. * This is useful for "X-Ray" option when we want to see "through" unwanted object. */ -bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo *client) +bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data)) { KX_GameObject *hitKXObj = client->m_gameobject; @@ -282,7 +282,7 @@ bool KX_RaySensor::Evaluate() PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment(); - KX_RayCast::Callback<KX_RaySensor> callback(this, spc); + KX_RayCast::Callback<KX_RaySensor, void> callback(this, spc); KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback); /* now pass this result to some controller */ |