add box2D colliders simple impl, some little tweaks, fixed camera bug
This commit is contained in:
@ -18,5 +18,27 @@ namespace Prism
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public Vec2(Vec3 vec) {
|
||||
X = vec.X;
|
||||
Y = vec.Y;
|
||||
}
|
||||
|
||||
public void Clamp(Vec2 min, Vec2 max) {
|
||||
if (X < min.X)
|
||||
X = min.X;
|
||||
if (X > max.X)
|
||||
X = max.X;
|
||||
|
||||
if (Y < min.Y)
|
||||
Y = min.Y;
|
||||
if (Y > max.Y)
|
||||
Y = max.Y;
|
||||
}
|
||||
|
||||
public static Vec2 operator -(Vec2 vector)
|
||||
{
|
||||
return new Vec2(-vector.X, -vector.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,18 +2,24 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Prism
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vec3
|
||||
{
|
||||
[FieldOffset(0)] public float X;
|
||||
[FieldOffset(4)] public float Y;
|
||||
[FieldOffset(8)] public float Z;
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
|
||||
public Vec3(float scalar)
|
||||
{
|
||||
X = Y = Z = scalar;
|
||||
}
|
||||
|
||||
public Vec3(Vec2 vec) {
|
||||
X = vec.X;
|
||||
Y = vec.Y;
|
||||
Z = 0.0f;
|
||||
}
|
||||
|
||||
public Vec3(float x, float y, float z)
|
||||
{
|
||||
X = x;
|
||||
@ -21,6 +27,27 @@ namespace Prism
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public Vec3(Vec4 vec) {
|
||||
X = vec.X;
|
||||
Y = vec.Y;
|
||||
Z = vec.Z;
|
||||
}
|
||||
|
||||
public Vec2 XY {
|
||||
get { return new Vec2(X, Y); }
|
||||
set { X = value.X; Y = value.Y; }
|
||||
}
|
||||
|
||||
public Vec2 XZ
|
||||
{
|
||||
get { return new Vec2(X, Z); }
|
||||
set { X = value.X; Z = value.Y; }
|
||||
}
|
||||
public Vec2 YZ
|
||||
{
|
||||
get { return new Vec2(Y, Z); }
|
||||
set { Y = value.X; Z = value.Y; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user