Raycast and collision filtering

I almost finished implementing my (technical) POC.

But, I need to process raycasts through a group of objects! Everything about that it’s welcome.
I’m reading the code and bullet API. the bullet Lib implements two features: mask & group…
++

I implemented a work-around : I call recursivly the RayCast to ignore the group of object.

But I found the code, and group/mask are implemented ! !? bullet-group and Bullet-mask is mapped to collision_collections:

In UI Blender3d :

I will try collision collection in blender and effects in Armory3d .

Armory3D set group and mask with the same value, therefore we can’t use layer collision matrix

which objects can collide with which Layers.

So, I found …

BulletAPI > RayResultCallback :

  • short int m_collisionFilterGroup
  • short int m_collisionFilterMask

Accordingly in the Haxebullet Port > btCollisionWorld.h
but not in Haxe definitions

I changed two files:

# haxebullet > Sources/bullet/Bt.hx
@:native('Ammo.RayResultCallback')
extern class RayResultCallback {
    public function hasHit():Bool;
    public function new():Void;
    public function get_m_collisionFilterGroup():Int;
    public function set_m_collisionFilterGroup(g:Int):Void;
    public function get_m_collisionFilterMask():Int;
    public function set_m_collisionFilterMask(m:Int):Void;
    public function get_m_collisionObject():CollisionObject;
}
# Armory3d > PhysicsWorld.rayCast()

	public function rayCast(from:Vec4, to:Vec4, group:Int=0x00000001,mask=0xFFFFFFFF):Hit {
		var rayFrom = vec1;
		var rayTo = vec2;
		rayFrom.setValue(from.x, from.y, from.z);
		rayTo.setValue(to.x, to.y, to.z);

		var rayCallback = new bullet.Bt.ClosestRayResultCallback(rayFrom, rayTo);
		rayCallback.set_m_collisionFilterGroup(group);
		rayCallback.set_m_collisionFilterMask(mask);
(...)

The first try works! I’m testing more cases…

2 Likes

Blender3d is too basic, we can set groups but not the mask :(!

I implemented the UI in the add-on. But I don’t know how to create the same look and feel of Collections panel (see bellow) !?


ArmorySDK\armory\blender\arm\props.py
ArmorySDK\armory\blender\arm\props_ui.py

4 Likes

I found with the Blender3D documentation but it’s so hard: now, the collision filter mask is set by a “layer picker” :


    bpy.types.Object.arm_rb_collision_filter_mask = bpy.props.BoolVectorProperty(
        name="Collision Filter Mask",
        default=(True, False, False,False,False,False, False, False,False,False,False, False, False,False,False,False, False, False,False,False),
        size=20,
        subtype='LAYER')

I edited the exporter.py and everything works in Armory3D.

I could add the mask in the physicRayCast Node and I will create pull-requests!!

omg! I’m so happy. :smile:
That’s one small step for [a] coder, one giant leap for game creators :partying_face:

4 Likes

I pushed the code

I’m implementing Node integration of the feature :
->

3 Likes

Pretty good seeing your progress! :grinning: is in your plans creating a PR so we can get those goodies in the official repo? :thinking: :+1:

Hello,

I found an issue in official SDK : Convex hull shape isn’t processed in target C++ (Windows)…!?:upside_down_face:
deepkeras

But everything is ok for “collision filter mask”.

I created PRs :


EDIT : Merged!

3 Likes