From c331e190a778cc493156d94437130c09bd2abeb4 Mon Sep 17 00:00:00 2001
From: "(no author)" <(no author)@993157c7-ee19-0410-b2c4-bb4e9862e678>
Date: Sat, 21 Jul 2007 03:52:14 +0000
Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1317
993157c7-ee19-0410-b2c4-bb4e9862e678
---
.../OpenRa.DataStructures.csproj | 3 +-
OpenRa.DataStructures/PriorityQueue.cs | 2 +-
OpenRa.DataStructures/Tuple.cs | 2 +-
.../float2.cs | 34 ++++++-------------
OpenRa.Game/OpenRa.Game.csproj | 1 -
OpenRa.Game/PathFinder.cs | 1 -
OpenRa.Game/Util.cs | 5 ---
OpenRa.Game/Viewport.cs | 4 +--
OpenRa.TechTree/Item.cs | 1 -
OpenRa.TechTree/TechTree.cs | 1 -
10 files changed, 16 insertions(+), 38 deletions(-)
rename {OpenRa.Game => OpenRa.DataStructures}/float2.cs (68%)
diff --git a/OpenRa.DataStructures/OpenRa.DataStructures.csproj b/OpenRa.DataStructures/OpenRa.DataStructures.csproj
index 11f3dd9b72..f74f3b89b1 100644
--- a/OpenRa.DataStructures/OpenRa.DataStructures.csproj
+++ b/OpenRa.DataStructures/OpenRa.DataStructures.csproj
@@ -7,7 +7,7 @@
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}
Library
Properties
- OpenRa.DataStructures
+ OpenRa
OpenRa.DataStructures
@@ -34,6 +34,7 @@
+
diff --git a/OpenRa.DataStructures/PriorityQueue.cs b/OpenRa.DataStructures/PriorityQueue.cs
index 83b4af4f68..2c8d610bb0 100644
--- a/OpenRa.DataStructures/PriorityQueue.cs
+++ b/OpenRa.DataStructures/PriorityQueue.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
-namespace OpenRa.DataStructures
+namespace OpenRa
{
public class PriorityQueue
where T : IComparable
diff --git a/OpenRa.DataStructures/Tuple.cs b/OpenRa.DataStructures/Tuple.cs
index 17233884c8..ebd08dedf8 100644
--- a/OpenRa.DataStructures/Tuple.cs
+++ b/OpenRa.DataStructures/Tuple.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text;
-namespace OpenRa.DataStructures
+namespace OpenRa
{
public class Tuple
{
diff --git a/OpenRa.Game/float2.cs b/OpenRa.DataStructures/float2.cs
similarity index 68%
rename from OpenRa.Game/float2.cs
rename to OpenRa.DataStructures/float2.cs
index 1efa986738..b0b5a6f4c1 100644
--- a/OpenRa.Game/float2.cs
+++ b/OpenRa.DataStructures/float2.cs
@@ -3,12 +3,11 @@ using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
-using BluntDirectX.Direct3D;
-namespace OpenRa.Game
+namespace OpenRa
{
[StructLayout(LayoutKind.Sequential)]
- struct float2
+ public struct float2
{
public float X, Y;
@@ -20,10 +19,7 @@ namespace OpenRa.Game
public PointF ToPointF() { return new PointF(X, Y); }
- public static implicit operator float2( int2 src )
- {
- return new float2( src.X, src.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); }
@@ -46,30 +42,22 @@ namespace OpenRa.Game
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 static float2 FromAngle(float a) { return new float2((float)Math.Sin(a), (float)Math.Cos(a)); }
- public float2 Constrain(Range r)
+ static float Constrain(float x, float a, float b) { return x < a ? a : x > b ? b : x; }
+
+ public float2 Constrain(float2 min, float2 max)
{
return new float2(
- Util.Constrain(X, new Range(r.Start.X, r.End.X)),
- Util.Constrain(Y, new Range(r.Start.Y, r.End.Y)));
+ Constrain(X, min.X, max.X),
+ Constrain(Y, min.Y, max.Y));
}
- public static float2 operator *(float a, float2 b)
- {
- return new float2(a * b.X, a * b.Y);
- }
+ public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); }
+ public static float2 operator /(float2 a, float2 b) { return new float2(a.X / b.X, a.Y / 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;
diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj
index 9a96039198..7802ddd2a2 100644
--- a/OpenRa.Game/OpenRa.Game.csproj
+++ b/OpenRa.Game/OpenRa.Game.csproj
@@ -48,7 +48,6 @@
-
diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs
index 7fa990ba8e..40602b23a8 100644
--- a/OpenRa.Game/PathFinder.cs
+++ b/OpenRa.Game/PathFinder.cs
@@ -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
diff --git a/OpenRa.Game/Util.cs b/OpenRa.Game/Util.cs
index 88ee729b68..f0cae6e99e 100644
--- a/OpenRa.Game/Util.cs
+++ b/OpenRa.Game/Util.cs
@@ -9,11 +9,6 @@ namespace OpenRa.Game
{
static class Util
{
- public static float Constrain(float x, Range range)
- {
- return x < range.Start ? range.Start : x > range.End ? range.End : x;
- }
-
static float2 EncodeVertexAttributes(TextureChannel channel, int paletteLine)
{
Converter channelEncoder = delegate(TextureChannel c)
diff --git a/OpenRa.Game/Viewport.cs b/OpenRa.Game/Viewport.cs
index 1af8da6cf1..e956b02f83 100644
--- a/OpenRa.Game/Viewport.cs
+++ b/OpenRa.Game/Viewport.cs
@@ -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.Zero, mapSize));
+ scrollPosition = (scrollPosition + delta).Constrain(float2.Zero, mapSize);
}
public Viewport(float2 size, float2 mapSize, Renderer renderer)
diff --git a/OpenRa.TechTree/Item.cs b/OpenRa.TechTree/Item.cs
index 7ff40eb3b6..b5c1855ee4 100644
--- a/OpenRa.TechTree/Item.cs
+++ b/OpenRa.TechTree/Item.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
-using OpenRa.DataStructures;
using OpenRa.FileFormats;
namespace OpenRa.TechTree
diff --git a/OpenRa.TechTree/TechTree.cs b/OpenRa.TechTree/TechTree.cs
index e24cceaf48..6e259683d2 100644
--- a/OpenRa.TechTree/TechTree.cs
+++ b/OpenRa.TechTree/TechTree.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
-using OpenRa.DataStructures;
using OpenRa.FileFormats;
namespace OpenRa.TechTree