mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
style fixes
This commit is contained in:
@@ -37,8 +37,8 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(T value) {
|
public bool Contains(T item) {
|
||||||
return _dict.ContainsKey(value);
|
return _dict.ContainsKey(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(T item) {
|
public void Add(T item) {
|
||||||
|
|||||||
@@ -92,8 +92,7 @@ namespace IsoTools.Internal {
|
|||||||
set {
|
set {
|
||||||
if ( value < _size ) {
|
if ( value < _size ) {
|
||||||
throw new ArgumentOutOfRangeException("value");
|
throw new ArgumentOutOfRangeException("value");
|
||||||
}
|
} else if ( value != _data.Length ) {
|
||||||
if ( value != _data.Length ) {
|
|
||||||
if ( value > 0 ) {
|
if ( value > 0 ) {
|
||||||
var new_data = new T[value];
|
var new_data = new T[value];
|
||||||
if ( _size > 0 ) {
|
if ( _size > 0 ) {
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ namespace IsoTools.Internal {
|
|||||||
|
|
||||||
public static readonly Vector2 vec2OneX = new Vector2(1.0f, 0.0f);
|
public static readonly Vector2 vec2OneX = new Vector2(1.0f, 0.0f);
|
||||||
public static readonly Vector2 vec2OneY = new Vector2(0.0f, 1.0f);
|
public static readonly Vector2 vec2OneY = new Vector2(0.0f, 1.0f);
|
||||||
|
|
||||||
public static readonly Vector3 vec3OneX = new Vector3(1.0f, 0.0f, 0.0f);
|
public static readonly Vector3 vec3OneX = new Vector3(1.0f, 0.0f, 0.0f);
|
||||||
public static readonly Vector3 vec3OneY = new Vector3(0.0f, 1.0f, 0.0f);
|
public static readonly Vector3 vec3OneY = new Vector3(0.0f, 1.0f, 0.0f);
|
||||||
public static readonly Vector3 vec3OneZ = new Vector3(0.0f, 0.0f, 1.0f);
|
public static readonly Vector3 vec3OneZ = new Vector3(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
public static readonly Vector3 vec3OneXY = new Vector3(1.0f, 1.0f, 0.0f);
|
public static readonly Vector3 vec3OneXY = new Vector3(1.0f, 1.0f, 0.0f);
|
||||||
public static readonly Vector3 vec3OneYZ = new Vector3(0.0f, 1.0f, 1.0f);
|
public static readonly Vector3 vec3OneYZ = new Vector3(0.0f, 1.0f, 1.0f);
|
||||||
public static readonly Vector3 vec3OneXZ = new Vector3(1.0f, 0.0f, 1.0f);
|
public static readonly Vector3 vec3OneXZ = new Vector3(1.0f, 0.0f, 1.0f);
|
||||||
@@ -31,28 +33,37 @@ namespace IsoTools.Internal {
|
|||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public struct Rect {
|
public struct Rect {
|
||||||
public float xMin;
|
public MinMax x;
|
||||||
public float yMin;
|
public MinMax y;
|
||||||
public float xMax;
|
|
||||||
public float yMax;
|
|
||||||
|
|
||||||
public Rect(float xmin, float ymin, float width, float height) {
|
public Rect(float x_min, float y_min, float x_max, float y_max) : this() {
|
||||||
this.xMin = xmin;
|
x = new MinMax(x_min, x_max);
|
||||||
this.yMin = ymin;
|
y = new MinMax(y_min, y_max);
|
||||||
this.xMax = xmin + width;
|
|
||||||
this.yMax = ymin + height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 size {
|
public Vector2 size {
|
||||||
get {
|
get { return new Vector2(x.size, y.size); }
|
||||||
return new Vector2(xMax - xMin, yMax - yMin);
|
}
|
||||||
}
|
|
||||||
|
public Vector2 center {
|
||||||
|
get { return new Vector2(x.center, y.center); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(float x_min, float y_min, float x_max, float y_max) {
|
||||||
|
x.Set(x_min, x_max);
|
||||||
|
y.Set(y_min, y_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Overlaps(Rect other) {
|
public bool Overlaps(Rect other) {
|
||||||
return
|
return
|
||||||
xMax > other.xMin && xMin < other.xMax &&
|
x.Overlaps(other.x) &&
|
||||||
yMax > other.yMin && yMin < other.yMax;
|
y.Overlaps(other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Approximately(Rect other) {
|
||||||
|
return
|
||||||
|
x.Approximately(other.x) &&
|
||||||
|
y.Approximately(other.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Rect zero {
|
public static Rect zero {
|
||||||
@@ -70,7 +81,7 @@ namespace IsoTools.Internal {
|
|||||||
public float min;
|
public float min;
|
||||||
public float max;
|
public float max;
|
||||||
|
|
||||||
public MinMax(float min, float max) {
|
public MinMax(float min, float max) : this() {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
@@ -83,10 +94,21 @@ namespace IsoTools.Internal {
|
|||||||
get { return min / 2.0f + max / 2.0f; }
|
get { return min / 2.0f + max / 2.0f; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Approximately(MinMax minmax) {
|
public void Set(float min, float max) {
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Overlaps(MinMax other) {
|
||||||
return
|
return
|
||||||
Mathf.Approximately(min, minmax.min) &&
|
max > other.min &&
|
||||||
Mathf.Approximately(max, minmax.max);
|
min < other.max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Approximately(MinMax other) {
|
||||||
|
return
|
||||||
|
Mathf.Approximately(min, other.min) &&
|
||||||
|
Mathf.Approximately(max, other.max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MinMax zero {
|
public static MinMax zero {
|
||||||
@@ -141,46 +163,46 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 Vec2Min(Vector2 a, float b) {
|
public static Vector2 Vec2Min(Vector2 a, float b) {
|
||||||
if ( b < a.x ) {
|
if ( a.x > b ) {
|
||||||
a.x = b;
|
a.x = b;
|
||||||
}
|
}
|
||||||
if ( b < a.y ) {
|
if ( a.y > b ) {
|
||||||
a.y = b;
|
a.y = b;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 Vec2Min(Vector2 a, Vector2 b) {
|
public static Vector2 Vec2Min(Vector2 a, Vector2 b) {
|
||||||
if ( b.x < a.x ) {
|
if ( a.x > b.x ) {
|
||||||
a.x = b.x;
|
a.x = b.x;
|
||||||
}
|
}
|
||||||
if ( b.y < a.y ) {
|
if ( a.y > b.y ) {
|
||||||
a.y = b.y;
|
a.y = b.y;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3Min(Vector3 a, float b) {
|
public static Vector3 Vec3Min(Vector3 a, float b) {
|
||||||
if ( b < a.x ) {
|
if ( a.x > b ) {
|
||||||
a.x = b;
|
a.x = b;
|
||||||
}
|
}
|
||||||
if ( b < a.y ) {
|
if ( a.y > b ) {
|
||||||
a.y = b;
|
a.y = b;
|
||||||
}
|
}
|
||||||
if ( b < a.z ) {
|
if ( a.z > b ) {
|
||||||
a.z = b;
|
a.z = b;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3Min(Vector3 a, Vector3 b) {
|
public static Vector3 Vec3Min(Vector3 a, Vector3 b) {
|
||||||
if ( b.x < a.x ) {
|
if ( a.x > b.x ) {
|
||||||
a.x = b.x;
|
a.x = b.x;
|
||||||
}
|
}
|
||||||
if ( b.y < a.y ) {
|
if ( a.y > b.y ) {
|
||||||
a.y = b.y;
|
a.y = b.y;
|
||||||
}
|
}
|
||||||
if ( b.z < a.z ) {
|
if ( a.z > b.z ) {
|
||||||
a.z = b.z;
|
a.z = b.z;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
@@ -200,46 +222,46 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 Vec2Max(Vector2 a, float b) {
|
public static Vector2 Vec2Max(Vector2 a, float b) {
|
||||||
if ( b > a.x ) {
|
if ( a.x < b ) {
|
||||||
a.x = b;
|
a.x = b;
|
||||||
}
|
}
|
||||||
if ( b > a.y ) {
|
if ( a.y < b ) {
|
||||||
a.y = b;
|
a.y = b;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 Vec2Max(Vector2 a, Vector2 b) {
|
public static Vector2 Vec2Max(Vector2 a, Vector2 b) {
|
||||||
if ( b.x > a.x ) {
|
if ( a.x < b.x ) {
|
||||||
a.x = b.x;
|
a.x = b.x;
|
||||||
}
|
}
|
||||||
if ( b.y > a.y ) {
|
if ( a.y < b.y ) {
|
||||||
a.y = b.y;
|
a.y = b.y;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3Max(Vector3 a, float b) {
|
public static Vector3 Vec3Max(Vector3 a, float b) {
|
||||||
if ( b > a.x ) {
|
if ( a.x < b ) {
|
||||||
a.x = b;
|
a.x = b;
|
||||||
}
|
}
|
||||||
if ( b > a.y ) {
|
if ( a.y < b ) {
|
||||||
a.y = b;
|
a.y = b;
|
||||||
}
|
}
|
||||||
if ( b > a.z ) {
|
if ( a.z < b ) {
|
||||||
a.z = b;
|
a.z = b;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3Max(Vector3 a, Vector3 b) {
|
public static Vector3 Vec3Max(Vector3 a, Vector3 b) {
|
||||||
if ( b.x > a.x ) {
|
if ( a.x < b.x ) {
|
||||||
a.x = b.x;
|
a.x = b.x;
|
||||||
}
|
}
|
||||||
if ( b.y > a.y ) {
|
if ( a.y < b.y ) {
|
||||||
a.y = b.y;
|
a.y = b.y;
|
||||||
}
|
}
|
||||||
if ( b.z > a.z ) {
|
if ( a.z < b.z ) {
|
||||||
a.z = b.z;
|
a.z = b.z;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
@@ -256,16 +278,16 @@ namespace IsoTools.Internal {
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
public static Vector2 Vec2Ceil(Vector2 v) {
|
public static Vector2 Vec2Ceil(Vector2 v) {
|
||||||
return new Vector2(
|
v.x = Mathf.Ceil(v.x);
|
||||||
Mathf.Ceil(v.x),
|
v.y = Mathf.Ceil(v.y);
|
||||||
Mathf.Ceil(v.y));
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3Ceil(Vector3 v) {
|
public static Vector3 Vec3Ceil(Vector3 v) {
|
||||||
return new Vector3(
|
v.x = Mathf.Ceil(v.x);
|
||||||
Mathf.Ceil(v.x),
|
v.y = Mathf.Ceil(v.y);
|
||||||
Mathf.Ceil(v.y),
|
v.z = Mathf.Ceil(v.z);
|
||||||
Mathf.Ceil(v.z));
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
@@ -273,16 +295,16 @@ namespace IsoTools.Internal {
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
public static Vector2 Vec2Floor(Vector2 v) {
|
public static Vector2 Vec2Floor(Vector2 v) {
|
||||||
return new Vector2(
|
v.x = Mathf.Floor(v.x);
|
||||||
Mathf.Floor(v.x),
|
v.y = Mathf.Floor(v.y);
|
||||||
Mathf.Floor(v.y));
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3Floor(Vector3 v) {
|
public static Vector3 Vec3Floor(Vector3 v) {
|
||||||
return new Vector3(
|
v.x = Mathf.Floor(v.x);
|
||||||
Mathf.Floor(v.x),
|
v.y = Mathf.Floor(v.y);
|
||||||
Mathf.Floor(v.y),
|
v.z = Mathf.Floor(v.z);
|
||||||
Mathf.Floor(v.z));
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
@@ -290,16 +312,16 @@ namespace IsoTools.Internal {
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
public static Vector2 Vec2Round(Vector2 v) {
|
public static Vector2 Vec2Round(Vector2 v) {
|
||||||
return new Vector2(
|
v.x = Mathf.Round(v.x);
|
||||||
Mathf.Round(v.x),
|
v.y = Mathf.Round(v.y);
|
||||||
Mathf.Round(v.y));
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3Round(Vector3 v) {
|
public static Vector3 Vec3Round(Vector3 v) {
|
||||||
return new Vector3(
|
v.x = Mathf.Round(v.x);
|
||||||
Mathf.Round(v.x),
|
v.y = Mathf.Round(v.y);
|
||||||
Mathf.Round(v.y),
|
v.z = Mathf.Round(v.z);
|
||||||
Mathf.Round(v.z));
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
@@ -383,17 +405,18 @@ namespace IsoTools.Internal {
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
public static Vector2 Vec2ChangeX(Vector2 v, float x) {
|
public static Vector2 Vec2ChangeX(Vector2 v, float x) {
|
||||||
return new Vector2(x, v.y);
|
v.x = x;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 Vec2ChangeY(Vector2 v, float y) {
|
public static Vector2 Vec2ChangeY(Vector2 v, float y) {
|
||||||
return new Vector2(v.x, y);
|
v.y = y;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 Vec2ChangeI(Vector2 v, int index, float n) {
|
public static Vector2 Vec2ChangeI(Vector2 v, int index, float n) {
|
||||||
var c = v;
|
v[index] = n;
|
||||||
c[index] = n;
|
return v;
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
@@ -401,59 +424,63 @@ namespace IsoTools.Internal {
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
public static Vector3 Vec3ChangeX(Vector3 v, float x) {
|
public static Vector3 Vec3ChangeX(Vector3 v, float x) {
|
||||||
return new Vector3(x, v.y, v.z);
|
v.x = x;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3ChangeY(Vector3 v, float y) {
|
public static Vector3 Vec3ChangeY(Vector3 v, float y) {
|
||||||
return new Vector3(v.x, y, v.z);
|
v.y = y;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3ChangeZ(Vector3 v, float z) {
|
public static Vector3 Vec3ChangeZ(Vector3 v, float z) {
|
||||||
return new Vector3(v.x, v.y, z);
|
v.z = z;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3ChangeXY(Vector3 v, float x, float y) {
|
public static Vector3 Vec3ChangeXY(Vector3 v, float x, float y) {
|
||||||
return new Vector3(x, y, v.z);
|
v.x = x;
|
||||||
|
v.y = y;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3ChangeYZ(Vector3 v, float y, float z) {
|
public static Vector3 Vec3ChangeYZ(Vector3 v, float y, float z) {
|
||||||
return new Vector3(v.x, y, z);
|
v.y = y;
|
||||||
|
v.z = z;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3ChangeXZ(Vector3 v, float x, float z) {
|
public static Vector3 Vec3ChangeXZ(Vector3 v, float x, float z) {
|
||||||
return new Vector3(x, v.y, z);
|
v.x = x;
|
||||||
|
v.z = z;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 Vec3ChangeI(Vector3 v, int index, float n) {
|
public static Vector3 Vec3ChangeI(Vector3 v, int index, float n) {
|
||||||
var c = v;
|
v[index] = n;
|
||||||
c[index] = n;
|
return v;
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// ColorChange
|
// ColorChange
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
public static Color ColorChangeA(Color color, float a) {
|
public static Color ColorChangeA(Color c, float a) {
|
||||||
var c = color;
|
|
||||||
c.a = a;
|
c.a = a;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color ColorChangeR(Color color, float r) {
|
public static Color ColorChangeR(Color c, float r) {
|
||||||
var c = color;
|
|
||||||
c.r = r;
|
c.r = r;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color ColorChangeG(Color color, float g) {
|
public static Color ColorChangeG(Color c, float g) {
|
||||||
var c = color;
|
|
||||||
c.g = g;
|
c.g = g;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color ColorChangeB(Color color, float b) {
|
public static Color ColorChangeB(Color c, float b) {
|
||||||
var c = color;
|
|
||||||
c.b = b;
|
c.b = b;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -483,16 +510,16 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 VectorBeautifier(Vector2 v) {
|
public static Vector2 VectorBeautifier(Vector2 v) {
|
||||||
return new Vector2{
|
v.x = FloatBeautifier(v.x);
|
||||||
x = FloatBeautifier(v.x),
|
v.y = FloatBeautifier(v.y);
|
||||||
y = FloatBeautifier(v.y)};
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 VectorBeautifier(Vector3 v) {
|
public static Vector3 VectorBeautifier(Vector3 v) {
|
||||||
return new Vector3{
|
v.x = FloatBeautifier(v.x);
|
||||||
x = FloatBeautifier(v.x),
|
v.y = FloatBeautifier(v.y);
|
||||||
y = FloatBeautifier(v.y),
|
v.z = FloatBeautifier(v.z);
|
||||||
z = FloatBeautifier(v.z)};
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
@@ -508,52 +535,20 @@ namespace IsoTools.Internal {
|
|||||||
: obj.AddComponent<T>();
|
: obj.AddComponent<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IsoCollider IsoConvertCollider(Collider collider) {
|
|
||||||
var fake_collider = collider ? collider.GetComponent<IsoFakeCollider>() : null;
|
|
||||||
return fake_collider ? fake_collider.isoCollider : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IsoRigidbody IsoConvertRigidbody(Rigidbody rigidbody) {
|
|
||||||
var fake_rigidbody = rigidbody ? rigidbody.GetComponent<IsoFakeRigidbody>() : null;
|
|
||||||
return fake_rigidbody ? fake_rigidbody.isoRigidbody : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GameObject IsoConvertGameObject(GameObject game_object) {
|
|
||||||
var fake_object = game_object ? game_object.GetComponent<IsoFakeObject>() : null;
|
|
||||||
var iso_object = fake_object ? fake_object.isoObject : null;
|
|
||||||
return iso_object ? iso_object.gameObject : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IsoContactPoint[] IsoConvertContactPoints(ContactPoint[] points) {
|
|
||||||
var iso_points = new IsoContactPoint[points.Length];
|
|
||||||
for ( int i = 0, e = points.Length; i < e; ++i ) {
|
|
||||||
iso_points[i] = new IsoContactPoint(points[i]);
|
|
||||||
}
|
|
||||||
return iso_points;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IsoRaycastHit[] IsoConvertRaycastHits(RaycastHit[] hits) {
|
|
||||||
var iso_hits = new IsoRaycastHit[hits.Length];
|
|
||||||
for ( int i = 0, e = hits.Length; i < e; ++i ) {
|
|
||||||
iso_hits[i] = new IsoRaycastHit(hits[i]);
|
|
||||||
}
|
|
||||||
return iso_hits;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Debug draw
|
// Debug draw
|
||||||
//
|
//
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
static void DrawTop(IsoWorld iso_world, Vector3 pos, Vector3 size) {
|
static void DrawTop(IsoWorld iso_world, Vector3 pos, Vector3 size) {
|
||||||
if ( iso_world ) {
|
if ( iso_world ) {
|
||||||
var points = new Vector3[]{
|
var points = new Vector3[]{
|
||||||
iso_world.IsoToScreen(pos),
|
iso_world.IsoToScreen(pos),
|
||||||
iso_world.IsoToScreen(pos + IsoUtils.Vec3FromX(size.x)),
|
iso_world.IsoToScreen(pos + IsoUtils.Vec3FromX (size.x)),
|
||||||
iso_world.IsoToScreen(pos + IsoUtils.Vec3FromXY(size.x, size.y)),
|
iso_world.IsoToScreen(pos + IsoUtils.Vec3FromXY(size.x, size.y)),
|
||||||
iso_world.IsoToScreen(pos + IsoUtils.Vec3FromY(size.y)),
|
iso_world.IsoToScreen(pos + IsoUtils.Vec3FromY (size.y)),
|
||||||
iso_world.IsoToScreen(pos)
|
iso_world.IsoToScreen(pos)
|
||||||
};
|
};
|
||||||
Handles.DrawLine(points[0], points[1]);
|
Handles.DrawLine(points[0], points[1]);
|
||||||
@@ -576,10 +571,10 @@ namespace IsoTools.Internal {
|
|||||||
Handles.color = color;
|
Handles.color = color;
|
||||||
var pos = center - size * 0.5f;
|
var pos = center - size * 0.5f;
|
||||||
DrawTop (iso_world, pos, size);
|
DrawTop (iso_world, pos, size);
|
||||||
DrawTop (iso_world, pos + IsoUtils.Vec3FromZ(size.z), size);
|
DrawTop (iso_world, pos + IsoUtils.Vec3FromZ (size.z), size);
|
||||||
DrawVert(iso_world, pos, size);
|
DrawVert(iso_world, pos, size);
|
||||||
DrawVert(iso_world, pos + IsoUtils.Vec3FromX(size.x), size);
|
DrawVert(iso_world, pos + IsoUtils.Vec3FromX (size.x), size);
|
||||||
DrawVert(iso_world, pos + IsoUtils.Vec3FromY(size.y), size);
|
DrawVert(iso_world, pos + IsoUtils.Vec3FromY (size.y), size);
|
||||||
DrawVert(iso_world, pos + IsoUtils.Vec3FromXY(size.x, size.y), size);
|
DrawVert(iso_world, pos + IsoUtils.Vec3FromXY(size.x, size.y), size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -611,6 +606,6 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ namespace IsoTools {
|
|||||||
var r = iso_world.IsoToScreen(position + IsoUtils.Vec3FromX(size.x)).x;
|
var r = iso_world.IsoToScreen(position + IsoUtils.Vec3FromX(size.x)).x;
|
||||||
var b = iso_world.IsoToScreen(position).y;
|
var b = iso_world.IsoToScreen(position).y;
|
||||||
var t = iso_world.IsoToScreen(position + size).y;
|
var t = iso_world.IsoToScreen(position + size).y;
|
||||||
Internal.ScreenRect = new IsoUtils.Rect(l, b, r - l, t - b);
|
Internal.ScreenRect = new IsoUtils.Rect(l, b, r, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,14 +179,10 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
|
||||||
// Raycast
|
|
||||||
//
|
|
||||||
// ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// RayFromIsoCameraToIsoPoint
|
// RayFromIsoCameraToIsoPoint
|
||||||
//
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public Ray RayFromIsoCameraToIsoPoint(Vector3 iso_pnt) {
|
public Ray RayFromIsoCameraToIsoPoint(Vector3 iso_pnt) {
|
||||||
var screen_pnt = IsoToScreen(iso_pnt);
|
var screen_pnt = IsoToScreen(iso_pnt);
|
||||||
@@ -200,119 +196,6 @@ namespace IsoTools {
|
|||||||
return new Ray(iso_down_pnt, iso_pnt - iso_down_pnt);
|
return new Ray(iso_down_pnt, iso_pnt - iso_down_pnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Raycast
|
|
||||||
//
|
|
||||||
|
|
||||||
public bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info) {
|
|
||||||
return Raycast(ray, out iso_hit_info,
|
|
||||||
Mathf.Infinity, Physics.DefaultRaycastLayers,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info,
|
|
||||||
float max_distance)
|
|
||||||
{
|
|
||||||
return Raycast(ray, out iso_hit_info,
|
|
||||||
max_distance, Physics.DefaultRaycastLayers,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info,
|
|
||||||
float max_distance, int layer_mask)
|
|
||||||
{
|
|
||||||
return Raycast(ray, out iso_hit_info,
|
|
||||||
max_distance, layer_mask,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info,
|
|
||||||
float max_distance, int layer_mask,
|
|
||||||
QueryTriggerInteraction query_trigger_interaction)
|
|
||||||
{
|
|
||||||
var hit_info = new RaycastHit();
|
|
||||||
var result = Physics.Raycast(ray, out hit_info,
|
|
||||||
max_distance, layer_mask, query_trigger_interaction);
|
|
||||||
iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// RaycastAll
|
|
||||||
//
|
|
||||||
|
|
||||||
public IsoRaycastHit[] RaycastAll(Ray ray) {
|
|
||||||
return RaycastAll(ray,
|
|
||||||
Mathf.Infinity, Physics.DefaultRaycastLayers,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IsoRaycastHit[] RaycastAll(Ray ray,
|
|
||||||
float max_distance)
|
|
||||||
{
|
|
||||||
return RaycastAll(ray,
|
|
||||||
max_distance, Physics.DefaultRaycastLayers,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IsoRaycastHit[] RaycastAll(Ray ray,
|
|
||||||
float max_distance, int layer_mask)
|
|
||||||
{
|
|
||||||
return RaycastAll(ray,
|
|
||||||
max_distance, layer_mask,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IsoRaycastHit[] RaycastAll(Ray ray,
|
|
||||||
float max_distance, int layer_mask,
|
|
||||||
QueryTriggerInteraction query_trigger_interaction)
|
|
||||||
{
|
|
||||||
var hits_info = Physics.RaycastAll(ray,
|
|
||||||
max_distance, layer_mask, query_trigger_interaction);
|
|
||||||
return IsoUtils.IsoConvertRaycastHits(hits_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// RaycastNonAlloc
|
|
||||||
//
|
|
||||||
|
|
||||||
public int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results) {
|
|
||||||
return RaycastNonAlloc(ray, results,
|
|
||||||
Mathf.Infinity, Physics.DefaultRaycastLayers,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results,
|
|
||||||
float max_distance)
|
|
||||||
{
|
|
||||||
return RaycastNonAlloc(ray, results,
|
|
||||||
max_distance, Physics.DefaultRaycastLayers,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results,
|
|
||||||
float max_distance, int layer_mask)
|
|
||||||
{
|
|
||||||
return RaycastNonAlloc(ray, results,
|
|
||||||
max_distance, layer_mask,
|
|
||||||
QueryTriggerInteraction.UseGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
static RaycastHit[] _raycastNonAllocBuffer = new RaycastHit[128];
|
|
||||||
public int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results,
|
|
||||||
float max_distance, int layer_mask,
|
|
||||||
QueryTriggerInteraction query_trigger_interaction)
|
|
||||||
{
|
|
||||||
var hit_count = Physics.RaycastNonAlloc(ray, _raycastNonAllocBuffer,
|
|
||||||
max_distance, layer_mask, query_trigger_interaction);
|
|
||||||
var min_hit_count = Mathf.Min(hit_count, results.Length);
|
|
||||||
for ( var i = 0; i < min_hit_count; ++i ) {
|
|
||||||
results[i] = new IsoRaycastHit(_raycastNonAllocBuffer[i]);
|
|
||||||
}
|
|
||||||
System.Array.Clear(_raycastNonAllocBuffer, 0, _raycastNonAllocBuffer.Length);
|
|
||||||
return min_hit_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// TouchIsoPosition
|
// TouchIsoPosition
|
||||||
@@ -641,10 +524,10 @@ namespace IsoTools {
|
|||||||
var iso_internal = _visibles[i].Internal;
|
var iso_internal = _visibles[i].Internal;
|
||||||
|
|
||||||
// high performance tricks
|
// high performance tricks
|
||||||
var min_x = iso_internal.ScreenRect.xMin / _sectorsSize;
|
var min_x = iso_internal.ScreenRect.x.min / _sectorsSize;
|
||||||
var min_y = iso_internal.ScreenRect.yMin / _sectorsSize;
|
var min_y = iso_internal.ScreenRect.y.min / _sectorsSize;
|
||||||
var max_x = iso_internal.ScreenRect.xMax / _sectorsSize;
|
var max_x = iso_internal.ScreenRect.x.max / _sectorsSize;
|
||||||
var max_y = iso_internal.ScreenRect.yMax / _sectorsSize;
|
var max_y = iso_internal.ScreenRect.y.max / _sectorsSize;
|
||||||
iso_internal.MinSector.x = (int)(min_x >= 0.0f ? min_x : min_x - 1.0f);
|
iso_internal.MinSector.x = (int)(min_x >= 0.0f ? min_x : min_x - 1.0f);
|
||||||
iso_internal.MinSector.y = (int)(min_y >= 0.0f ? min_y : min_y - 1.0f);
|
iso_internal.MinSector.y = (int)(min_y >= 0.0f ? min_y : min_y - 1.0f);
|
||||||
iso_internal.MaxSector.x = (int)(max_x >= 0.0f ? max_x + 1.0f : max_x);
|
iso_internal.MaxSector.x = (int)(max_x >= 0.0f ? max_x + 1.0f : max_x);
|
||||||
|
|||||||
Reference in New Issue
Block a user