mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
Initial Upload
it working and not nuking fps... wow
This commit is contained in:
parent
cb280bdf00
commit
29060f71c1
23 changed files with 1905 additions and 0 deletions
72
CVRGizmos/Gizmo/Drawers/SquareDrawer.cs
Normal file
72
CVRGizmos/Gizmo/Drawers/SquareDrawer.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Popcron
|
||||
{
|
||||
public class SquareDrawer : Drawer
|
||||
{
|
||||
public SquareDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override int Draw(ref Vector3[] buffer, params object[] values)
|
||||
{
|
||||
Vector2 position = default;
|
||||
if (values[0] is Vector2 p2)
|
||||
{
|
||||
position = p2;
|
||||
}
|
||||
else if (values[0] is Vector3 p3)
|
||||
{
|
||||
position = p3;
|
||||
}
|
||||
|
||||
Quaternion rotation = (Quaternion)values[1];
|
||||
|
||||
Vector2 size = default;
|
||||
if (values[2] is Vector2 s2)
|
||||
{
|
||||
size = s2;
|
||||
}
|
||||
else if (values[2] is Vector3 s3)
|
||||
{
|
||||
size = s3;
|
||||
}
|
||||
|
||||
size *= 0.5f;
|
||||
|
||||
Vector2 point1 = new Vector3(position.x - size.x, position.y - size.y);
|
||||
Vector2 point2 = new Vector3(position.x + size.x, position.y - size.y);
|
||||
Vector2 point3 = new Vector3(position.x + size.x, position.y + size.y);
|
||||
Vector2 point4 = new Vector3(position.x - size.x, position.y + size.y);
|
||||
|
||||
point1 = rotation * (point1 - position);
|
||||
point1 += position;
|
||||
|
||||
point2 = rotation * (point2 - position);
|
||||
point2 += position;
|
||||
|
||||
point3 = rotation * (point3 - position);
|
||||
point3 += position;
|
||||
|
||||
point4 = rotation * (point4 - position);
|
||||
point4 += position;
|
||||
|
||||
//square
|
||||
buffer[0] = point1;
|
||||
buffer[1] = point2;
|
||||
|
||||
buffer[2] = point2;
|
||||
buffer[3] = point3;
|
||||
|
||||
buffer[4] = point3;
|
||||
buffer[5] = point4;
|
||||
|
||||
//loop back to start
|
||||
buffer[6] = point4;
|
||||
buffer[7] = point1;
|
||||
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue