Page 1 of 1
Collision Groups
Posted: Thu May 24, 2012 4:09 am
by Shadow0144
Hi, I'm trying to use the collision groups to get my lasers to just ignore each other, but it seems they aren't working like how I expect them to.
Code: Select all
if (!collisionSet)
{
projectileGroup = new CollisionGroup();
CollisionGroupPair pair = new CollisionGroupPair(projectileGroup, projectileGroup);
CollisionRules.CollisionGroupRules.Add(pair, CollisionRule.NoBroadPhase);
collisionSet = true;
}
else { }
((Sphere)collisionBase.getPhysicsCollider()).CollisionInformation.CollisionRules.Group = projectileGroup; // Returns a Sphere
Am I right that I can make a group, pair them up, add a rule, and then set my physics object to be a part of that group?
It doesn't seem to be working.
Re: Collision Groups
Posted: Thu May 24, 2012 5:06 am
by Norbo
Am I right that I can make a group, pair them up, add a rule, and then set my physics object to be a part of that group?
Yup; in what way is it not working?
Specific and personal rules both override group rules by default; are any specific or personal rules defined?
Re: Collision Groups
Posted: Sat May 26, 2012 5:51 pm
by Shadow0144
Nope, no specific or personal rules, I'm only using the groups. But the groups seem to be creating tremendous amounts of lag instead of being helpful. All the groups I use, I have them ignore BroadPhase, so I figured this should make them faster. It's laggier than without the groups. I'm using them for the MobileMeshs and for the Spheres.
Re: Collision Groups
Posted: Sat May 26, 2012 6:06 pm
by Norbo
Well, that's certainly not expected behavior
Could you reproduce the problem in a BEPUphysicsDemos demo for me to check out?
Re: Collision Groups
Posted: Sat May 26, 2012 10:23 pm
by Shadow0144
Is it possible that my meshs, which don't check against each other because they aren't dynamic, would begin checking against each other when added to a group? Also, is symmetric? Like
Code: Select all
esxolusProjectileGroup = new CollisionGroup();
CollisionGroupPair pairEP = new CollisionGroupPair(esxolusProjectileGroup, projectileGroup);
CollisionRules.CollisionGroupRules.Add(pairEP, CollisionRule.NoBroadPhase);
would gain nothing from also adding
Code: Select all
CollisionGroupPair pairPE = new CollisionGroupPair(projectileGroup, esxolusProjectileGroup);
CollisionRules.CollisionGroupRules.Add(pairPE, CollisionRule.NoBroadPhase);
, right?
I was going to poke around with it some more, since I am not sure I can get the demos to do it.
If I don't do the meshs, usually everything works, but I still get random massive spikes of lag that never resolve, and if I pause the debugger, it's in space.Update(deltaTime);
Re: Collision Groups
Posted: Sat May 26, 2012 10:45 pm
by Norbo
Is it possible that my meshs, which don't check against each other because they aren't dynamic, would begin checking against each other when added to a group?
It's possible. Kinematic entities belong to the CollisionRules.DefaultKinematicCollisionGroup by default which has a rule of NoBroadPhase with itself. If the group was changed but rules were not put in place to compensate, pairs will be generated.
Also, is symmetric?
The order does not matter; a pair (A,B) is the same as (B,A). So that's correct, nothing is gained by defining the rule both ways. In fact, it would throw an exception since the key already exists in the dictionary.
If I don't do the meshs, usually everything works, but I still get random massive spikes of lag that never resolve, and if I pause the debugger, it's in space.Update(deltaTime);
Are some NaNs or infinities sneaking in somewhere? They can slow things down a huge amount before they crash everything. The
development version has a math checker which looks for NaNs and infinities if compiled with the CHECKMATH symbol.
Re: Collision Groups
Posted: Sun May 27, 2012 4:08 pm
by Shadow0144
Norbo wrote:Is it possible that my meshs, which don't check against each other because they aren't dynamic, would begin checking against each other when added to a group?
It's possible. Kinematic entities belong to the CollisionRules.DefaultKinematicCollisionGroup by default which has a rule of NoBroadPhase with itself. If the group was changed but rules were not put in place to compensate, pairs will be generated.
That did it! Thank you!
If I don't do the meshs, usually everything works, but I still get random massive spikes of lag that never resolve, and if I pause the debugger, it's in space.Update(deltaTime);
Are some NaNs or infinities sneaking in somewhere? They can slow things down a huge amount before they crash everything. The
development version has a math checker which looks for NaNs and infinities if compiled with the CHECKMATH symbol.
I was thinking that, too, I'll look into it more. I think I had a similar problem where I was passing a NaN to the space and it was very unhappy.
It turns out it was the radius! Which explains why only some of the missiles had problems, even when using the same code - they were getting their radius from the models which as an int became zero.
This solved everything, thank you so much!