public void TestUpdate() { var forceRegistry = new ForceRegistry(); var force = new ParticleConstantForce(new Vector2D(5, 0)); var p = new Particle { Mass = 1 }; force.Add(p); this.TestAddForceGenerator(forceRegistry, force); forceRegistry.Update(1 / 60.0); p.Update(1 / 60.0); Assert.AreEqual(new Vector2D(5, 0), p.Acceleration, "物体被赋予正确的加速度"); p.Acceleration = Vector2D.Zero; this.TestRemoveForceGenerator(forceRegistry, force); forceRegistry.Update(1 / 60.0); p.Update(1 / 60.0); Assert.AreEqual(new Vector2D(0, 0), p.Acceleration, "删去作用力发生器,物体不再受该作用力发生器所产生的力"); force.Add(p); this.TestAddForceGenerator(forceRegistry, force); this.TestRemoveParticle(forceRegistry, p); forceRegistry.Update(1 / 60.0); p.Update(1 / 60.0); Assert.AreEqual(new Vector2D(0, 0), p.Acceleration, "删去物体,物体不再受该作用力发生器所产生的力"); }
/// <summary> /// Crea un nuovo particle simulator che gestisce il dato numero di contatti per frame. /// Si può specificare il numero di iterazioni massime da usare. /// </summary> /// <param name="maxContacts">Massimo numero di contacts gestiti</param> /// <param name="iteration">Massimo numero di iterazioni nella risoluzione dei contacts</param> public ParticleWorld(uint maxContacts, uint iteration) { Particles = new List <Particle>(); forceRegistry = new ForceRegistry(); resolver = new ParticleContactResolver(iteration); contactGenRegistration = new List <ParticleContactGenerator>(); contacts = new List <ParticleContact>(); }
private void TestRemoveParticle( ForceRegistry forceRegistry, Particle p) { forceRegistry.Remove(p); }
private void TestRemoveForceGenerator( ForceRegistry forceRegistry, ParticleForceGenerator force) { forceRegistry.Remove(force); }
private void TestAddForceGenerator( ForceRegistry forceRegistry, ParticleForceGenerator force) { forceRegistry.Add(force); }
/// <summary> /// Create the manager that handles the RigidBodies /// </summary> /// <param name="maxContacts">Maximum of contacts managed in a single iteration</param> /// <param name="iteration">Number of iterations used to resolve contacts</param> public RigidBodyWorld(uint maxContacts, uint iteration) { rigidBodies = new List <RigidBody>(); forceRegistry = new ForceRegistry(); }