From c10e0d92f46e5eaf25a69e1fafe5f4dbd8eaab9d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 3 Nov 2021 09:52:26 +0800 Subject: *misc --- Runtime/Math/Vector2.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Runtime/Math/Vector2.h') diff --git a/Runtime/Math/Vector2.h b/Runtime/Math/Vector2.h index 27cf312..9d7e4e9 100644 --- a/Runtime/Math/Vector2.h +++ b/Runtime/Math/Vector2.h @@ -1,4 +1,6 @@ #pragma once +#include "MathHelper.h" +#include "Runtime/Utilities/Assert.h" namespace Internal { @@ -15,6 +17,21 @@ namespace Internal this->y = y; } + Vector2 Clamp(float xmin, float xmax, float ymin, float ymax) + { + Vector2 v; + v.x = clamp(x, xmin, xmax); + v.y = clamp(y, ymin, ymax); + return v; + } + + float operator[](int i) + { + if (i == 0) return x; + else if (i == 1) return y; + Assert(false); + } + bool operator == (const Vector2& v) const { return v.x == x && v.y == y; -- cgit v1.1-26-g67d0