git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1317 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
(no author)
2007-07-21 03:52:14 +00:00
parent cb7b5dedd7
commit c331e190a7
10 changed files with 16 additions and 38 deletions

View File

@@ -48,7 +48,6 @@
<Compile Include="PathFinder.cs" />
<Compile Include="Sequence.cs" />
<Compile Include="ConstructionYard.cs" />
<Compile Include="float2.cs" />
<Compile Include="ISelectable.cs" />
<Compile Include="MoveOrder.cs" />
<Compile Include="Region.cs" />

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Text;
using OpenRa.FileFormats;
using OpenRa.DataStructures;
using System.Windows.Forms;
namespace OpenRa.Game

View File

@@ -9,11 +9,6 @@ namespace OpenRa.Game
{
static class Util
{
public static float Constrain(float x, Range<float> range)
{
return x < range.Start ? range.Start : x > range.End ? range.End : x;
}
static float2 EncodeVertexAttributes(TextureChannel channel, int paletteLine)
{
Converter<TextureChannel, float> channelEncoder = delegate(TextureChannel c)

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using BluntDirectX.Direct3D;
namespace OpenRa.Game
{
@@ -22,8 +21,7 @@ namespace OpenRa.Game
public void Scroll(float2 delta)
{
scrollPosition = (scrollPosition + delta).Constrain(
new Range<float2>(float2.Zero, mapSize));
scrollPosition = (scrollPosition + delta).Constrain(float2.Zero, mapSize);
}
public Viewport(float2 size, float2 mapSize, Renderer renderer)

View File

@@ -1,83 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using BluntDirectX.Direct3D;
namespace OpenRa.Game
{
[StructLayout(LayoutKind.Sequential)]
struct float2
{
public float X, Y;
public float2(float x, float y) { X = x; Y = y; }
public float2(PointF p) { X = p.X; Y = p.Y; }
public float2(Point p) { X = p.X; Y = p.Y; }
public float2(Size p) { X = p.Width; Y = p.Height; }
public float2(SizeF p) { X = p.Width; Y = p.Height; }
public PointF ToPointF() { return new PointF(X, Y); }
public static implicit operator float2( int2 src )
{
return new float2( src.X, src.Y );
}
public static float2 operator +(float2 a, float2 b) { return new float2(a.X + b.X, a.Y + b.Y); }
public static float2 operator -(float2 a, float2 b) { return new float2(a.X - b.X, a.Y - b.Y); }
public static float2 operator -(float2 a) { return new float2(-a.X, -a.Y); }
static float Lerp(float a, float b, float t) { return (1 - t) * a + t * b; }
public static float2 Lerp(float2 a, float2 b, float t)
{
return new float2(
Lerp(a.X, b.X, t),
Lerp(a.Y, b.Y, t));
}
public static float2 Lerp(float2 a, float2 b, float2 t)
{
return new float2(
Lerp(a.X, b.X, t.X),
Lerp(a.Y, b.Y, t.Y));
}
public static float2 FromAngle(float a)
{
return new float2((float)Math.Sin(a), (float)Math.Cos(a));
}
public float2 Constrain(Range<float2> r)
{
return new float2(
Util.Constrain(X, new Range<float>(r.Start.X, r.End.X)),
Util.Constrain(Y, new Range<float>(r.Start.Y, r.End.Y)));
}
public static float2 operator *(float a, float2 b)
{
return new float2(a * b.X, a * b.Y);
}
public static readonly float2 Zero = new float2(0, 0);
public static float2 operator /(float2 a, float2 b)
{
return new float2(a.X / b.X, a.Y / b.Y);
}
public static bool WithinEpsilon(float2 a, float2 b, float e)
{
float2 d = a - b;
return Math.Abs(d.X) < e && Math.Abs(d.Y) < e;
}
public float2 Sign() { return new float2(Math.Sign(X), Math.Sign(Y)); }
public static float Dot(float2 a, float2 b) { return a.X * b.X + a.Y * b.Y; }
public float2 Round() { return new float2((float)Math.Round(X), (float)Math.Round(Y)); }
}
}