Raycast question

raycastAll(start, end) returns distance sorted array or not sorted?
PS: physics don’t have layer collision matrix?

I don’t think it’s guaranteed to be sorted judging from the documentation: https://pybullet.org/Bullet/BulletFull/classbtCollisionWorld.html#aaac6675c8134f6695fecb431c72b0a6a

1 Like

I think, need to add this to the documentation ))
like this:

if You need sort by distance use result.sort(function (a, b) { return (a.distance - b.distance); });

2 Likes
    BODYGROUP_ENGINE_1: 8,
    BODYGROUP_ENGINE_2: 32,
    BODYGROUP_ENGINE_3: 64,

This groups of physics engine need for? I can’t find description for this ((

They are reserved for potential future use.

1 Like

Ok, rigidbody layer collision configure works. Not enough custom editor functionality ((

var RbGroup = pc.createScript('rbGroup');
RbGroup.attributes.add('GROUP', { type: 'string', default: "" });
RbGroup.attributes.add('group_DYNAMIC'  , { type: 'boolean', default: true });
RbGroup.attributes.add('group_STATIC'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_KINEMATIC', { type: 'boolean', default: false });
RbGroup.attributes.add('group_ENGINE_1' , { type: 'boolean', default: false });
RbGroup.attributes.add('group_TRIGGER'  , { type: 'boolean', default: false });
RbGroup.attributes.add('group_ENGINE_2' , { type: 'boolean', default: false });
RbGroup.attributes.add('group_ENGINE_3' , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_1'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_2'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_3'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_4'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_5'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_6'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_7'   , { type: 'boolean', default: false });
RbGroup.attributes.add('group_USER_8'   , { type: 'boolean', default: false });
RbGroup.attributes.add('COLLISION_MASK', { type: 'string', default: "" });
RbGroup.attributes.add('mask_DYNAMIC'  , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_STATIC'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_KINEMATIC', { type: 'boolean', default: true });
RbGroup.attributes.add('mask_ENGINE_1' , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_TRIGGER',   { type: 'boolean', default: true });
RbGroup.attributes.add('mask_ENGINE_2' , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_ENGINE_3' , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_1'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_2'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_3'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_4'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_5'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_6'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_7'   , { type: 'boolean', default: true });
RbGroup.attributes.add('mask_USER_8'   , { type: 'boolean', default: true });

RbGroup.prototype.initialize = function() {
    this.app.on('rbGroup:set', function() { this.updateRb(); }.bind(this), this);
    this.updateRb();
};
RbGroup.prototype.postInitialize = function() { this.updateRb(); };
RbGroup.prototype.updateRb = function() {
    if (this.entity.rigidbody) {
        this.entity.rigidbody.mask = this.getMask();
        this.entity.rigidbody.group = this.getGroup();
    }
};
RbGroup.prototype.getGroup = function() {
 return (this.group_DYNAMIC   === true ? 1 : 0) + 
        (this.group_STATIC    === true ? 2 : 0) + 
        (this.group_KINEMATIC === true ? 4 : 0) + 
        (this.group_ENGINE_1  === true ? 8 : 0) + 
        (this.group_TRIGGER   === true ? 16 : 0) + 
        (this.group_ENGINE_2  === true ? 32 : 0) + 
        (this.group_ENGINE_3  === true ? 64 : 0) + 
        (this.group_USER_1    === true ? 128 : 0) + 
        (this.group_USER_2    === true ? 256 : 0) + 
        (this.group_USER_3    === true ? 512 : 0) + 
        (this.group_USER_4    === true ? 1024 : 0) + 
        (this.group_USER_5    === true ? 2048 : 0) + 
        (this.group_USER_6    === true ? 4096 : 0) + 
        (this.group_USER_7    === true ? 8192 : 0) + 
        (this.group_USER_8    === true ? 16384 : 0);
};
RbGroup.prototype.getMask = function () {
 return (this.mask_DYNAMIC   === true ? 1 : 0) + 
        (this.mask_STATIC    === true ? 2 : 0) + 
        (this.mask_KINEMATIC === true ? 4 : 0) + 
        (this.mask_ENGINE_1  === true ? 8 : 0) + 
        (this.mask_TRIGGER   === true ? 16 : 0) + 
        (this.mask_ENGINE_2  === true ? 32 : 0) + 
        (this.mask_ENGINE_3  === true ? 64 : 0) + 
        (this.mask_USER_1    === true ? 128 : 0) + 
        (this.mask_USER_2    === true ? 256 : 0) + 
        (this.mask_USER_3    === true ? 512 : 0) + 
        (this.mask_USER_4    === true ? 1024 : 0) + 
        (this.mask_USER_5    === true ? 2048 : 0) + 
        (this.mask_USER_6    === true ? 4096 : 0) + 
        (this.mask_USER_7    === true ? 8192 : 0) + 
        (this.mask_USER_8    === true ? 16384 : 0);
};```

@yaustar
Looks, like trigger haven’t same mask/group for configure?

Triggers are ‘special’ shapes in the physics world that don’t collide with anything. You can see from the group and mask above that there’s a mask_TRIGGER and group_TRIGGER. That’s what makes it a trigger.

1 Like

Yep, find it.
systems.rigidbody.addBody(body, pc.BODYGROUP_TRIGGER, pc.BODYMASK_NOT_STATIC ^ pc.BODYGROUP_TRIGGER);
Special group only (( Need mask/group like in rigidbody with default settings. Works same, but have additional setting for advanced users. Collision with RB solved by checking attached RB and link mask/group to RB.

GREAT perfomance problem if kinematic collision of unmovable colliders. About 5 collisions ruined perfomance too much. That forced me to create custom group+mask configurer )) But now I need same for trigger…
Because if presented collider ignored TRIGGER group, but trigger group is not ignoring

BODYMASK_NOT_STATIC: 65535 ^ 2
pc.BODYMASK_NOT_STATIC ^ pc.BODYGROUP_TRIGGER

All groups exclude TRIGGER & STATIC

Can I override system trigger.js in project folder by custom trigger.js with advanced functionality?


BLUE trigger intersect some colliders, colliders not push events (ignoring trigger), but trigger NOT ignore and push about 10 events (decreasing perfomance).
May be add to RB group TRIGGER for solve this? This is not broke reflection dynamical object by colliders with RB?
Edit: worked. Add to RB group TRIGGER for solve this