I'm currently working on Ace on Steroids, an Astreroids clone using the Indiefreaks Game Framework which goals aims to create a set of tutorials explaining how to make a game from scratch with the framework, its SunBurn engine core component and obviously BEPUPhysics.
You can see the current stage of development in my video feed here: http://www.youtube.com/user/IndiefreakS ... ture=guide
As you can see everything works very nicely and I get a nice fixed 30 fps on Windows however, when porting the project to Xbox 360, I'm getting some really laggy behaviors when an asteroid gets destroyed. I've read the forums and the documentation to get it all optimized for Xbox 360 but I'm still meeting some horrible lags which I know why they are caused: ConvexHull broad and narrow phases.
I tried defining different settings on the overall simulation with no success:
1. I set multithreading as recommended:
Code: Select all
physics.Space.ThreadManager.AddThread(o => System.Threading.Thread.CurrentThread.SetProcessorAffinity(1), null);
physics.Space.ThreadManager.AddThread(o => System.Threading.Thread.CurrentThread.SetProcessorAffinity(3), null);
physics.Space.ThreadManager.AddThread(o => System.Threading.Thread.CurrentThread.SetProcessorAffinity(5), null);
Code: Select all
physics.UseInternalTimeStepping = true;
Code: Select all
SolverSettings.DefaultMinimumIterations = 0;
physics.Space.Solver.IterationLimit = 5;
GeneralConvexPairTester.UseSimplexCaching = false;
I wish I could since they bring the closest to reality collisions.
My current ideas to solve this situation are:
A. Recreate simpler models for my ConvexHull instances with the hope of getting significant better results in exchange of lowering the collision realism.
B. Use compound bodies made of several boxes to be as close as possible to the rendered shapes
C. Use even simpler entities such as Box entities but this one would be ultimatelly applied as it would be less than realistic

Hopefully, I can get it done with A. but I would like to get your advice and see if I didn't miss any opportunity to get ConvexHull working lagless.
For a better understanding, here is the code I use to create the Physics instance which actually is a TransformableShape as I wanted to share a static ConvexHull instance for all my asteroids.
Code: Select all
/// <summary>
/// Creates a new instance
/// </summary>
/// <param name="collisionObject">The ParentObject this instance will be associated with</param>
/// <param name="model">The Model used to compute the ConvexHull shape used for collision & physics</param>
/// <remarks>If a previously created instance uses the same Model as the one provided here, it will reuse the computed ConvexHull instance to save CPU</remarks>
public ConvexHullCollisionMove(ICollisionObject collisionObject, Model model) : base(collisionObject)
{
ModelReferencesToDelete.Clear();
foreach (var modelConvexHull in ModelConvexHulls)
{
if (!modelConvexHull.Key.IsAlive)
{
ModelReferencesToDelete.Add(modelConvexHull.Key);
}
else if (modelConvexHull.Key.Target == model)
{
ConvexHull convexHull = modelConvexHull.Value;
TransformableShape shape = new TransformableShape(convexHull.CollisionInformation.Shape, Matrix3X3.CreateFromMatrix(ParentObject.World));
SpaceObject = new Entity<ConvexCollidable<TransformableShape>>(
new ConvexCollidable<TransformableShape>(shape),
ParentObject.Mass,
convexHull.LocalInertiaTensor,
convexHull.Volume);
Entity.Position = ParentObject.World.Translation;
}
}
foreach (var modelReference in ModelReferencesToDelete)
{
ModelConvexHulls.Remove(modelReference);
}
if (SpaceObject == null)
{
Vector3[] vertices;
int[] indices;
TriangleMesh.GetVerticesAndIndicesFromModel(model, out vertices, out indices);
var modelReference = new WeakReference(model);
var convexHull = new ConvexHull(vertices, ParentObject.Mass);
ModelConvexHulls.Add(modelReference, convexHull);
TransformableShape shape = new TransformableShape(convexHull.CollisionInformation.Shape, Matrix3X3.CreateFromMatrix(ParentObject.World));
SpaceObject = new Entity<ConvexCollidable<TransformableShape>>(
new ConvexCollidable<TransformableShape>(shape),
ParentObject.Mass,
convexHull.LocalInertiaTensor,
convexHull.Volume);
Entity.Position = ParentObject.World.Translation;
}
ParentObject.World.GetScaleComponent(out CollisionObjectScale);
}