/// <summary> /// Creates a gravitational field. /// </summary> /// <param name="shape">Shape representing the volume of the force field.</param> /// <param name="origin">Location that entities will be pushed toward.</param> /// <param name="multiplier">Represents the gravitational constant of the field times the effective mass at the center of the field.</param> /// <param name="maxForce">Maximum force the field can apply.</param> /// <param name="physicWorld">The physic world.</param> public GravitationalFieldObject(ForceFieldShape shape, Vector3 origin, float multiplier, float maxForce, BepuPhysicWorld physicWorld) : base(shape, physicWorld.Space.BroadPhase.QueryAccelerator) { this.Multiplier = multiplier; this.Origin = origin; this.MaxForce = maxForce; }
/// <summary> /// Applies some high quality, low performance settings. /// By using universal continuous collision detection, missed collisions /// will be much, much rarer. This actually doesn't have a huge performance cost. /// However, increasing the iteration limit and the minimum iterations to 5x the default /// will incur a pretty hefty overhead. /// On the upside, pretty much every simulation will be rock-solid. /// </summary> /// <param name="world">The world.</param> public static void ApplyHighStabilitySettings(BepuPhysicWorld world) { MotionSettings.DefaultPositionUpdateMode = PositionUpdateMode.Continuous; MotionSettings.UseExtraExpansionForContinuousBoundingBoxes = true; SolverSettings.DefaultMinimumIterations = 5; world.Space.Solver.IterationLimit = 50; }
/// <summary> /// Applies the default settings to the space. /// These values are what the engine starts with; they don't have to be applied unless you just want to get back to the defaults. /// This doesn't cover every single tunable field in the entire engine, just the main ones that this helper class is messing with. /// </summary> /// <param name="world">The world.</param> public static void ApplyDefaultSettings(BepuPhysicWorld world) { MotionSettings.ConserveAngularMomentum = false; MotionSettings.DefaultPositionUpdateMode = PositionUpdateMode.Discrete; MotionSettings.UseRk4AngularIntegration = false; SolverSettings.DefaultMinimumIterations = 1; world.Space.Solver.IterationLimit = 10; GeneralConvexPairTester.UseSimplexCaching = false; MotionSettings.UseExtraExpansionForContinuousBoundingBoxes = false; }
protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world) { BepuPhysicWorld BepuPhysicWorld = new BepuPhysicWorld(-0.97f); SimpleCuller SimpleCuller = new SimpleCuller(); world = new IWorld(BepuPhysicWorld, SimpleCuller); ForwardRenderTecnichDescription desc = ForwardRenderTecnichDescription.Default(); desc.BackGroundColor = Color.CornflowerBlue; renderTech = new ForwardRenderTecnich(desc); }
protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world) { BepuPhysicWorld bepuWorld = new BepuPhysicWorld(-0.98f,true,1,true); world = new IWorld(bepuWorld, new SimpleCuller()); BepuPhysicWorld.ApplyHighStabilitySettings(bepuWorld); DeferredRenderTechnicInitDescription desc = DeferredRenderTechnicInitDescription.Default(); desc.UseFloatingBufferForLightMap = true; desc.BackGroundColor = Color.CornflowerBlue; renderTech = new DeferredRenderTechnic(desc); }
/// <summary> /// Applies some higher quality settings. /// By using universal continuous collision detection, missed collisions /// will be much, much rarer. This actually doesn't have a huge performance cost. /// The increased iterations put this as a midpoint between the normal and high stability settings. /// </summary> /// <param name="world">The world.</param> public static void ApplyMediumHighStabilitySettings(BepuPhysicWorld world) { MotionSettings.DefaultPositionUpdateMode = PositionUpdateMode.Continuous; SolverSettings.DefaultMinimumIterations = 2; world.Space.Solver.IterationLimit = 15; }
/// <summary> /// Applies some low quality, high speed settings. /// The main benefit comes from the very low iteration cap. /// By enabling simplex caching, general convex collision detection /// gets a nice chunk faster, but some curved shapes lose collision detection robustness. /// </summary> /// <param name="world">The world.</param> public static void ApplySuperSpeedySettings(BepuPhysicWorld world) { SolverSettings.DefaultMinimumIterations = 0; world.Space.Solver.IterationLimit = 5; GeneralConvexPairTester.UseSimplexCaching = true; }
// //sets world and render technic // protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world) { BepuPhysicWorld bpw = new BepuPhysicWorld (-98.0F, true, 1.0F); world = new IWorld (bpw, new SimpleCuller ()); DeferredRenderTechnicInitDescription desc = DeferredRenderTechnicInitDescription.Default (); desc.UseFloatingBufferForLightMap = true; renderTech = new DeferredRenderTechnic (desc); }