Beispiel #1
0
 public FluidSystem2(Vec2 gravity, int maxParticleLimit, int worldWidth, int worldHeight)
 {
     _worldHeight = worldHeight;
     _worldWidth = worldWidth;
     Particles = new SpatialTable(worldWidth, worldHeight, CellSize);
     MaxParticleLimit = maxParticleLimit;
     Gravity = gravity;
     Particles.Initialize();
 }
Beispiel #2
0
 public float dst2(Vec2 v)
 {
     return (v.X - X) * (v.X - X) + (v.Y - Y) * (v.Y - Y);
 }
Beispiel #3
0
 public float dot(Vec2 v)
 {
     return X * v.X + Y * v.Y;
 }
Beispiel #4
0
 public float dst(Vec2 v)
 {
     float x_d = v.X - X;
     float y_d = v.Y - Y;
     return (float)Math.Sqrt(x_d * x_d + y_d * y_d);
 }
Beispiel #5
0
 public Vec2 add(Vec2 v)
 {
     X += v.X;
     Y += v.Y;
     return this;
 }
Beispiel #6
0
 public void Sub(Vec2 v)
 {
     X -= v.X;
     Y -= v.Y;
 }
Beispiel #7
0
 public void Set(Vec2 v)
 {
     X = v.X;
     Y = v.Y;
 }
Beispiel #8
0
 public Particle(float posX, float posY)
 {
     Position = new Vec2(posX, posY);
 }
Beispiel #9
0
 public void AddParticle(Vec2 vec2)
 {
     Particles.Add(new Particle(vec2.X, vec2.Y));
 }
Beispiel #10
0
        private void CapVelocity(Vec2 v)
        {
            if (v.X > VelocityCap)
                v.X = VelocityCap;
            else if (v.X < -VelocityCap)
                v.X = -VelocityCap;

            if (v.Y > VelocityCap)
                v.Y = VelocityCap;
            else if (v.Y < -VelocityCap)
                v.Y = -VelocityCap;
        }