There's too many variables to figure it out based upon videos unfortunately. Can you reproduce and isolate the issue in the BEPUphysicsDemos, preferably with two parallel spaces updating simultaneously with elements from both spaces added to the drawer? That eliminates all the other extra systems and environmental conditions as confounding factors.
Here's an example demo, showing Space.Gravity's equivalence with the ConstantLinearGravityField by running two simulations next to each other:
Code: Select all
using BEPUphysics;
using BEPUphysics.Entities;
using BEPUphysics.Entities.Prefabs;
using BEPUphysics.UpdateableSystems.ForceFields;
using BEPUphysicsDemos.SampleCode;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using BEPUphysics.NarrowPhaseSystems;
namespace BEPUphysicsDemos.Demos
{
/// <summary>
/// Boxes fall on a planetoid.
/// </summary>
public class PlanetDemo : StandardDemo
{
private Space secondSpace;
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public PlanetDemo(DemosGame game)
: base(game)
{
Space.ForceUpdater.Gravity = Vector3.Zero;
//By pre-allocating a bunch of box-box pair handlers, the simulation will avoid having to allocate new ones at runtime.
NarrowPhaseHelper.Factories.BoxBox.EnsureCount(1000);
//Set up the first simulation.
Entity planet = new Box(new Vector3(0, 0, 0), 100, 5, 100);
Space.Add(planet);
//The first simulation uses a gravity field which emulates Space.ForceUpdater.Gravity.
var field = new ConstantLinearGravityField(new InfiniteForceFieldShape(), 9.81f);
Space.Add(field);
//Drop the "meteorites" on the planet.
Entity toAdd;
int numColumns = 10;
int numRows = 10;
int numHigh = 10;
float separation = 5;
for (int i = 0; i < numRows; i++)
for (int j = 0; j < numColumns; j++)
for (int k = 0; k < numHigh; k++)
{
toAdd = new Box(new Vector3(separation * i - numRows * separation / 2, 40 + k * separation, separation * j - numColumns * separation / 2), 1f, 1f, 1f, 5);
//toAdd.LinearVelocity = new Vector3(30, 0, 0);
toAdd.LinearDamping = 0;
toAdd.AngularDamping = 0;
Space.Add(toAdd);
}
//Set up the identical second parallel simulation.
secondSpace = new Space(Space.ThreadManager);
planet = new Box(new Vector3(0, 0, 0), 100, 5, 100);
secondSpace.Add(planet);
//The second simulation uses regular old gravity.
secondSpace.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
//Drop the "meteorites" on the planet.
for (int i = 0; i < numRows; i++)
for (int j = 0; j < numColumns; j++)
for (int k = 0; k < numHigh; k++)
{
toAdd = new Box(new Vector3(separation * i - numRows * separation / 2, 40 + k * separation, separation * j - numColumns * separation / 2), 1f, 1f, 1f, 5);
//toAdd.LinearVelocity = new Vector3(30, 0, 0);
toAdd.LinearDamping = 0;
toAdd.AngularDamping = 0;
secondSpace.Add(toAdd);
game.ModelDrawer.Add(toAdd);
}
game.Camera.Position = new Vector3(0, 0, 150);
}
public override void Update(float dt)
{
//Note that we are only moving forward by one time step. This is consistent with the Space.Update() call that the parent implementation will call.
secondSpace.Update();
base.Update(dt);
}
/// <summary>
/// Gets the name of the simulation.
/// </summary>
public override string Name
{
get { return "Planet"; }
}
}
}
The ConstantLinearGravityField is a simple modification to the GravitationalField:
Code: Select all
using System;
using BEPUphysics.BroadPhaseSystems;
using BEPUphysics.Entities;
using BEPUphysics.UpdateableSystems.ForceFields;
using Microsoft.Xna.Framework;
using BEPUphysics;
namespace BEPUphysicsDemos.SampleCode
{
/// <summary>
/// Applies a constant vertical linear impulse on all entities.
/// </summary>
public class ConstantLinearGravityField : ForceField
{
/// <summary>
/// Creates a gravitational field.
/// </summary>
/// <param name="shape">Shape representing the volume of the force field.</param>
/// <param name="acceleration">Acceleration the field applies.</param>
public ConstantLinearGravityField(ForceFieldShape shape, float acceleration)
: base(shape)
{
this.Acceleration = acceleration;
}
/// <summary>
/// Gets or sets the gravitational constant of the field times the effective mass at the center of the field.
/// </summary>
public float Acceleration { get; set; }
/// <summary>
/// Calculates the gravitational force to apply to the entity.
/// </summary>
/// <param name="e">Target of the impulse.</param>
/// <param name="dt">Time since the last frame in simulation seconds.</param>
/// <param name="impulse">Force to apply at the given position.</param>
protected override void CalculateImpulse(Entity e, float dt, out Vector3 impulse)
{
impulse = (-dt * e.Mass * Acceleration) * Vector3.Up;
}
}
}