Collision Flags & Groups

Post Reply
SaShka
Posts: 2
Joined: Fri Aug 04, 2017 10:38 am

Collision Flags & Groups

Post by SaShka » Tue Sep 05, 2017 10:50 am

I'm a little confused in CollisionFlags & CollisionFilterGroups
I'm using BulletUnity (which is build upon BulletSharp - Bullet wrapper for C#).

Here every RigidBody has 3 properties:

Code: Select all

	BulletSharp.CollisionFlags collisionFlags
	BulletSharp.CollisionFilterGroups collisionGroupsIBelongTo
	BulletSharp.CollisionFilterGroups collisionMask
Each one could contain multiple flags on
(the only exclusion I met is TerrainCollisionObject, which has same props, but each of them could contain only 1 flag, but I suppose, it's not proper realization).

I tried to figure out, what every of these 3 props means.
If I've understand correct:
  • `collisionGroups` & `collisionMask` are used in broadPhase to weed out pairs, which should not collide (logically - e.g. arrow with grass)
    `collisionGroups` describes our object, while `collisionMask` describes "which other objects our one should collide" (logically)
  • I suppose, `collisionFlags` describes our object for narrow phase, but I couldn't find code, where it is used for this purpose.
So, my questions are:
  1. Am I right in my understanding of what `collisionGroups` & `collisionMask` are & how they used?
  2. What is `collisionFlags` & how it poperty is used basically & in connection with other 2 props?
    For example, why we need "static" and "kinematic" flags among CollisionFlags enum, if we already have same-named options among CollisionFilterGroups enum, which we could set in `collisionGroups` for our object?
Thank for your help!

PS:
here are corresponding enums (to perhaps save your time to find them in bullet code):

Code: Select all

	enum CollisionFlags
	{
		CF_STATIC_OBJECT= 1,
		CF_KINEMATIC_OBJECT= 2,
		CF_NO_CONTACT_RESPONSE = 4,
		CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle material (friction/restitution)
		CF_CHARACTER_OBJECT = 16,
		CF_DISABLE_VISUALIZE_OBJECT = 32, //disable debug drawing
		CF_DISABLE_SPU_COLLISION_PROCESSING = 64,//disable parallel/SPU processing
		CF_HAS_CONTACT_STIFFNESS_DAMPING = 128,
		CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR = 256,
		CF_HAS_FRICTION_ANCHOR = 512,
		CF_HAS_COLLISION_SOUND_TRIGGER = 1024
	};

	enum CollisionFilterGroups
	{
		DefaultFilter = 1,
		StaticFilter = 2,
		KinematicFilter = 4,
		DebrisFilter = 8,
		SensorTrigger = 16,
		CharacterFilter = 32,
		AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
	};

User avatar
drleviathan
Posts: 385
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Collision Flags & Groups

Post by drleviathan » Tue Sep 05, 2017 11:57 am

Your understanding of collisionGroups & collisionMask is correct.

The collisionFlags bits are used as boolean indicators to enable/disable various per-object behaviors. The "collision" part of the name is a bit of a misnomer: objectFlags might have been more correct.

Post Reply