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

@@ -7,7 +7,7 @@
<ProjectGuid>{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}</ProjectGuid> <ProjectGuid>{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenRa.DataStructures</RootNamespace> <RootNamespace>OpenRa</RootNamespace>
<AssemblyName>OpenRa.DataStructures</AssemblyName> <AssemblyName>OpenRa.DataStructures</AssemblyName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -34,6 +34,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="float2.cs" />
<Compile Include="int2.cs" /> <Compile Include="int2.cs" />
<Compile Include="PriorityQueue.cs" /> <Compile Include="PriorityQueue.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Diagnostics; using System.Diagnostics;
namespace OpenRa.DataStructures namespace OpenRa
{ {
public class PriorityQueue<T> public class PriorityQueue<T>
where T : IComparable<T> where T : IComparable<T>

View File

@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenRa.DataStructures namespace OpenRa
{ {
public class Tuple<A> public class Tuple<A>
{ {

View File

@@ -3,12 +3,11 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Drawing; using System.Drawing;
using BluntDirectX.Direct3D;
namespace OpenRa.Game namespace OpenRa
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
struct float2 public struct float2
{ {
public float X, Y; public float X, Y;
@@ -20,10 +19,7 @@ namespace OpenRa.Game
public PointF ToPointF() { return new PointF(X, Y); } public PointF ToPointF() { return new PointF(X, Y); }
public static implicit operator float2( int2 src ) public static implicit operator float2(int2 src) { return new float2(src.X, src.Y); }
{
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, 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)); Lerp(a.Y, b.Y, t.Y));
} }
public static float2 FromAngle(float a) public static float2 FromAngle(float a) { return new float2((float)Math.Sin(a), (float)Math.Cos(a)); }
{
return new float2((float)Math.Sin(a), (float)Math.Cos(a));
}
public float2 Constrain(Range<float2> 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( return new float2(
Util.Constrain(X, new Range<float>(r.Start.X, r.End.X)), Constrain(X, min.X, max.X),
Util.Constrain(Y, new Range<float>(r.Start.Y, r.End.Y))); Constrain(Y, min.Y, max.Y));
} }
public static float2 operator *(float a, float2 b) 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); }
return new float2(a * b.X, a * b.Y);
}
public static readonly float2 Zero = new float2(0, 0); 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) public static bool WithinEpsilon(float2 a, float2 b, float e)
{ {
float2 d = a - b; float2 d = a - b;

View File

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

View File

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

View File

@@ -9,11 +9,6 @@ namespace OpenRa.Game
{ {
static class Util 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) static float2 EncodeVertexAttributes(TextureChannel channel, int paletteLine)
{ {
Converter<TextureChannel, float> channelEncoder = delegate(TextureChannel c) Converter<TextureChannel, float> channelEncoder = delegate(TextureChannel c)

View File

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

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Text; using System.Text;
using OpenRa.DataStructures;
using OpenRa.FileFormats; using OpenRa.FileFormats;
namespace OpenRa.TechTree namespace OpenRa.TechTree

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using OpenRa.DataStructures;
using OpenRa.FileFormats; using OpenRa.FileFormats;
namespace OpenRa.TechTree namespace OpenRa.TechTree