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 /doc | |
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 'doc')
-rw-r--r-- | doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst index 74df50ddb58..d8cc5e45e83 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst @@ -799,7 +799,7 @@ base class --- :class:`SCA_IObject` :return: the first object hit or None if no object or object does not match prop :rtype: :class:`KX_GameObject` - .. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly) + .. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly, mask) Look from a point/object to another point/object and find first object hit within dist that matches prop. if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None, None, None) if no hit. @@ -851,6 +851,8 @@ base class --- :class:`SCA_IObject` * 2: return value is a 5-tuple and the 5th element is a 2-tuple (u, v) with the UV mapping of the hit point or None if no hit, or the object doesn't use a mesh collision shape, or doesn't have a UV mapping. :type poly: integer + :arg mask: collision mask: The collision mask (16 layers mapped to a 16-bit integer) is combined with each object's collision group, to hit only a subset of the objects in the scene. Only those objects for which ``collisionGroup & mask`` is true can be hit. + :type mask: bitfield :return: (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv). * object, hitpoint and hitnormal are None if no hit. |