summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-04-02 13:42:24 +0800
committerchai <215380520@qq.com>2024-04-02 13:42:24 +0800
commitce3211f753719e76051074ed332123b59d7e7a38 (patch)
tree7fd305204e8c57303a2fd9b852e85694d0264b00
parent98bd6bcf2475bb6765bf02f851ea81aa7e4ae207 (diff)
*misc
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs5
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug.meta8
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs156
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs616
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs18
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs59
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs144
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs.meta11
-rw-r--r--ActiveRagdoll/ProjectSettings/BurstAotSettings_StandaloneWindows.json8
-rw-r--r--ActiveRagdoll/ProjectSettings/CommonBurstAotSettings.json2
14 files changed, 1067 insertions, 4 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs b/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs
index ce1018d..f8257e7 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs
@@ -1,3 +1,4 @@
+using Rigging.Debugging;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -45,6 +46,10 @@ namespace Rigging.Action
protected override void OnFixedUpdate()
{
+ }
+
+ protected override void OnUpdate()
+ {
}
}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug.meta b/ActiveRagdoll/Assets/TABG/Scripts/Debug.meta
new file mode 100644
index 0000000..32e4db4
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d7a38388debc604469a5acb430ab2d90
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs b/ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs
new file mode 100644
index 0000000..c12f3cf
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs
@@ -0,0 +1,156 @@
+
+using System;
+using UnityEngine;
+
+namespace Rigging.Debugging
+{
+
+ public class DebugRigidBody : MonoBehaviour
+ {
+
+ public enum EMode
+ {
+ Axis,
+ Cube,
+ Axis_Cube,
+ Custom,
+ }
+ public EMode mode = EMode.Axis;
+
+ public Color color = Color.white;
+
+ // When added to an object, draws colored rays from the
+ // transform position.
+ public int lineCount = 100;
+ public float radius = 3.0f;
+
+ public float cubeLen = 0.05f;
+
+ public System.Action customDraw;
+
+ static Material lineMaterial;
+ static void CreateLineMaterial()
+ {
+ if (!lineMaterial)
+ {
+ // Unity has a built-in shader that is useful for drawing
+ // simple colored things.
+ Shader shader = Shader.Find("Hidden/Internal-Colored");
+ lineMaterial = new Material(shader);
+ lineMaterial.hideFlags = HideFlags.HideAndDontSave;
+ // Turn on alpha blending
+ lineMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
+ lineMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
+ // Turn backface culling off
+ lineMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
+ // Turn off depth writes
+ lineMaterial.SetInt("_ZWrite", 0);
+ }
+ }
+
+ private void PutVertex(Vector3 vert)
+ {
+ GL.Vertex3(vert.x, vert.y, vert.z);
+ }
+
+ // Will be called after all regular rendering is done
+ public void OnRenderObject()
+ {
+ CreateLineMaterial();
+ // Apply the line material
+ lineMaterial.SetPass(0);
+
+ if (mode == EMode.Axis || mode == EMode.Axis_Cube)
+ {
+ GL.PushMatrix();
+ // Set transformation matrix for drawing to
+ // match our transform
+ GL.MultMatrix(transform.localToWorldMatrix);
+
+ // Draw lines
+ GL.Begin(GL.LINES);
+
+ float len = 0.3f;
+
+ GL.Color(Color.red);
+ PutVertex(Vector3.zero);
+ PutVertex(Vector3.right * len);
+
+ GL.Color(Color.green);
+ PutVertex(Vector3.zero);
+ PutVertex(Vector3.up * len);
+
+ GL.Color(Color.blue);
+ PutVertex(Vector3.zero);
+ PutVertex(Vector3.forward * len);
+
+ GL.End();
+ GL.PopMatrix();
+ }
+ if (mode == EMode.Cube || mode == EMode.Axis_Cube)
+ {
+ GL.PushMatrix();
+ // Set transformation matrix for drawing to
+ // match our transform
+ GL.MultMatrix(transform.localToWorldMatrix);
+
+ float len = cubeLen / 2.0f;
+
+ GL.wireframe = true;
+
+ GL.Begin(GL.QUADS);
+
+ GL.Color(color);
+
+ GL.Vertex3(len, len, -len);
+ GL.Vertex3(-len, len, -len);
+ GL.Vertex3(-len, len, len);
+ GL.Vertex3(len, len, len);
+
+ // Bottom face (y = -len)
+ GL.Vertex3(len, -len, len);
+ GL.Vertex3(-len, -len, len);
+ GL.Vertex3(-len, -len, -len);
+ GL.Vertex3(len, -len, -len);
+
+ // Front face (z = len)
+ GL.Vertex3(len, len, len);
+ GL.Vertex3(-len, len, len);
+ GL.Vertex3(-len, -len, len);
+ GL.Vertex3(len, -len, len);
+
+ // Back face (z = -len)
+ GL.Vertex3(len, -len, -len);
+ GL.Vertex3(-len, -len, -len);
+ GL.Vertex3(-len, len, -len);
+ GL.Vertex3(len, len, -len);
+
+ // Left face (x = -len)
+ GL.Vertex3(-len, len, len);
+ GL.Vertex3(-len, len, -len);
+ GL.Vertex3(-len, -len, -len);
+ GL.Vertex3(-len, -len, len);
+
+ // Right face (x = len)
+ GL.Vertex3(len, len, -len);
+ GL.Vertex3(len, len, len);
+ GL.Vertex3(len, -len, len);
+ GL.Vertex3(len, -len, -len);
+ GL.End(); // End of drawing color-cube
+
+ GL.wireframe = false;
+
+ GL.PopMatrix();
+ }
+ if (mode == EMode.Custom)
+ {
+ if (customDraw != null)
+ {
+ customDraw.Invoke();
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs.meta
new file mode 100644
index 0000000..b4a1972
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/DebugRigidBody.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fe7c669dcfdf0194a971bfa3576187db
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs b/ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs
new file mode 100644
index 0000000..07be5d6
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs
@@ -0,0 +1,616 @@
+///
+/// Draw lines at runtime
+/// by Nothke
+/// unlicensed, aka do whatever you want with it
+/// made during Stugan 2016 :)
+/// ..(it's midnight, and Robbie clicks A LOT, LOUDLY!)
+///
+/// Important:
+/// - Should be called in OnPostRender() (after everything else has been drawn)
+/// therefore the script that calls it must be attached to the camera
+/// - Use someMaterial.SetPass(0) to set that material for line rendering
+/// If no material is SetPass'd, Unity default material will be used
+/// - Use Draw.color = someColor to set line color
+/// - Most parameters are passed as screen 0-1 points (see function summaries)
+/// To input as pixel coordinates use PixelsToScreen(screenV2Coordinate)
+///
+/// See function summaries for what this script can do
+/// and check DrawExaple.cs for examples
+///
+
+using UnityEngine;
+using System.Collections.Generic;
+
+namespace Rigging.Debugging
+{
+
+ public static class Draw
+ {
+ public static Color color = Color.white;
+
+ #region Line
+
+ /// <summary>
+ /// Draws line between 2 screen points. Use Draw.PixelToScreen to convert from pixels to screen points
+ /// </summary>
+ public static void Line(Vector2 p1, Vector2 p2)
+ {
+ Prepare();
+
+ // Vertices
+ GL.Vertex(p1);
+ GL.Vertex(p2);
+
+ Postpare();
+ }
+
+ /// <summary>
+ /// Draws line between 2 world points
+ /// </summary>
+ public static void Line3D(Vector3 p1, Vector3 p2)
+ {
+ Prepare3D();
+
+ GL.Vertex(p1);
+ GL.Vertex(p2);
+
+ Postpare();
+ }
+
+ #endregion
+
+
+ #region Circles and Ellipses
+
+ /// <summary>
+ /// Draws circle using a screen point center, and pixel radius. Use Draw.ScreenToPixel to convert screen points to pixels
+ /// </summary>
+ public static void Circle(Vector2 center, float pixelRadius)
+ {
+ Vector2 size = new Vector2(pixelRadius / Screen.width, pixelRadius / Screen.height);
+
+ Ellipse(center, size);
+ }
+
+ /// <summary>
+ /// Draws dashed circle using a screen point center, and pixel radius. Use Draw.ScreenToPixel to convert screen points to pixels
+ /// The dashes are not very nice, just skipping every other point..
+ /// </summary>
+ public static void CircleDashed(Vector2 center, float radius)
+ {
+ Prepare();
+
+ float radX = radius / Screen.width;
+ float radY = radius / Screen.height;
+
+ // Vertices
+ for (float theta = 0.0f; theta < (2 * Mathf.PI); theta += 0.01f)
+ {
+ Vector2 ci = new Vector2(center.x + (Mathf.Cos(theta) * radX), center.y + (Mathf.Sin(theta) * radY));
+ GL.Vertex(ci);
+ }
+
+ Postpare();
+ }
+
+ /// <summary>
+ /// Draws an ellipse using a center, and size (in screen fractions). Use Draw.ScreenToPixel to convert screen points to pixels
+ /// </summary>
+ public static void Ellipse(Vector2 center, Vector2 size)
+ {
+ Prepare();
+
+ float radX = size.x;
+ float radY = size.y;
+
+ // Vertices
+ for (float theta = 0.0f; theta < (2 * Mathf.PI); theta += 0.01f)
+ {
+ Vector2 ci = new Vector2(center.x + (Mathf.Cos(theta) * radX), center.y + (Mathf.Sin(theta) * radY));
+ GL.Vertex(ci);
+
+ if (theta != 0)
+ GL.Vertex(ci);
+ }
+
+ Postpare();
+ }
+
+ /// <summary>
+ /// Draws a circle in world space
+ /// </summary>
+ public static void Circle3D(Vector3 center, float radius, Vector3 normal)
+ {
+ Prepare3D();
+
+ normal = normal.normalized;
+ Vector3 forward = normal == Vector3.up ?
+ Vector3.ProjectOnPlane(Vector3.forward, normal).normalized :
+ Vector3.ProjectOnPlane(Vector3.up, normal);
+ Vector3 right = Vector3.Cross(normal, forward);
+
+ for (float theta = 0.0f; theta < (2 * Mathf.PI); theta += 0.01f)
+ {
+ Vector3 ci = center + forward * Mathf.Cos(theta) * radius + right * Mathf.Sin(theta) * radius;
+ GL.Vertex(ci);
+
+ if (theta != 0)
+ GL.Vertex(ci);
+ }
+
+ Postpare();
+ }
+
+
+ /// <summary>
+ /// Draws an elliptic orbit using eccentricity and semi-major axis in pixels
+ /// </summary>
+ public static void Orbit(Vector2 center, float eccentricity, float semiMajorAxis, float dir = 0)
+ {
+ Prepare();
+
+ eccentricity = Mathf.Clamp01(eccentricity);
+
+ Vector2 up = new Vector2(Mathf.Cos(dir), Mathf.Sin(dir));
+ Vector2 right = Vector3.Cross(up, Vector3.forward);
+
+ for (float theta = 0.0f; theta < (2 * Mathf.PI); theta += 0.01f)
+ {
+ float r = (semiMajorAxis * (1 - eccentricity * eccentricity)) / (1 + eccentricity * Mathf.Cos(theta));
+
+ Vector2 point = PixelToScreen((right * Mathf.Cos(theta) * r) + (up * Mathf.Sin(theta) * r));
+ Vector2 ci = center + point;
+
+ GL.Vertex(ci);
+
+ if (theta != 0)
+ GL.Vertex(ci);
+ }
+
+ Postpare();
+ }
+
+ /// <summary>
+ /// Draws an elliptic orbit using periapsis and apoapsis in pixels
+ /// </summary>
+ public static void OrbitApses(Vector2 center, float periapsis, float apoapsis, float dir = 0)
+ {
+ float a = (periapsis + apoapsis) / 2;
+ float e = (apoapsis - periapsis) / (apoapsis + periapsis);
+
+ Orbit(center, e, a, dir);
+ }
+
+ /// <summary>
+ /// Draws an elliptic orbit in world space using eccentricity and semi-major axis
+ /// </summary>
+ public static void Orbit3D(Vector3 center, float eccentricity, float semiMajorAxis, Vector3 normal, Vector3 forward)
+ {
+ Prepare3D();
+
+ eccentricity = Mathf.Clamp01(eccentricity);
+
+ forward = Vector3.ProjectOnPlane(forward, normal).normalized;
+ Vector3 right = Vector3.Cross(forward, normal).normalized;
+
+ for (float theta = 0.0f; theta < (2 * Mathf.PI); theta += 0.01f)
+ {
+ float r = (semiMajorAxis * (1 - eccentricity * eccentricity)) / (1 + eccentricity * Mathf.Cos(theta));
+
+ Vector3 point = (right * Mathf.Cos(theta) * r) + (forward * Mathf.Sin(theta) * r);
+ Vector3 ci = center + point;
+
+ GL.Vertex(ci);
+
+ if (theta != 0)
+ GL.Vertex(ci);
+ }
+
+ Postpare();
+ }
+
+ /// <summary>
+ /// Draws an elliptic orbit in world space using periapsis and apoapsis
+ /// </summary>
+ public static void Orbit3DApses(Vector3 center, float periapsis, float apoapsis, Vector3 normal, Vector3 forward)
+ {
+ float a = (periapsis + apoapsis) / 2;
+ float e = (apoapsis - periapsis) / (apoapsis + periapsis);
+
+ Orbit3D(center, e, a, normal, forward);
+ }
+
+ #endregion
+
+
+ #region Rectangle
+
+ /// <summary>
+ /// Draws rectangle on screen using a Rect (in pixels)
+ /// </summary>
+ public static void Rect(Rect rect)
+ {
+ Rect(rect.x, rect.y, rect.width, rect.height);
+ }
+
+ /// <summary>
+ /// Draws rectangle on screen (in screen 0-1 fractions)
+ /// </summary>
+ public static void RectScreen(float x, float y, float width, float height)
+ {
+ Prepare();
+
+ GL.Vertex(new Vector3(x, y));
+ GL.Vertex(new Vector3(x + width, y));
+
+ GL.Vertex(new Vector3(x + width, y));
+ GL.Vertex(new Vector3(x + width, y + height));
+
+ GL.Vertex(new Vector3(x + width, y + height));
+ GL.Vertex(new Vector3(x, y + height));
+
+ GL.Vertex(new Vector3(x, y + height));
+ GL.Vertex(new Vector3(x, y));
+
+ Postpare();
+ }
+
+ /// <summary>
+ /// Draws rectangle on screen (in pixels)
+ /// </summary>
+ public static void Rect(float x, float y, float width, float height)
+ {
+ PreparePixel();
+
+ GL.Vertex(new Vector3(x, y));
+ GL.Vertex(new Vector3(x + width, y));
+
+ GL.Vertex(new Vector3(x + width, y));
+ GL.Vertex(new Vector3(x + width, y + height));
+
+ GL.Vertex(new Vector3(x + width, y + height));
+ GL.Vertex(new Vector3(x, y + height));
+
+ GL.Vertex(new Vector3(x, y + height));
+ GL.Vertex(new Vector3(x, y));
+
+ Postpare();
+ }
+
+ #endregion
+
+
+ #region Grid
+ /// <summary>
+ /// Draws a horizontal grid
+ /// </summary>
+ public static void Grid(Vector3 center, float edgeLength, int lines = 10)
+ {
+ Grid(center, edgeLength, lines, Vector3.forward, Vector3.up);
+ }
+
+ /// <summary>
+ /// Draws a gird with custom orientantion
+ /// </summary>
+ public static void Grid(Vector3 center, float edgeLength, int lines, Vector3 forward, Vector3 normal)
+ {
+ if (lines <= 1) return;
+
+ Prepare3D();
+
+ forward = forward.normalized;
+ normal = Vector3.ProjectOnPlane(normal, forward).normalized;
+ Vector3 right = Vector3.Cross(forward, normal);
+
+ // forward lines
+ for (int i = 0; i < lines; i++)
+ {
+ Vector3 fDir = forward * edgeLength * 0.5f;
+ Vector3 rDir = right * (-(edgeLength * 0.5f) + (i * edgeLength / (lines - 1)));
+
+ GL.Vertex(center - fDir + rDir);
+ GL.Vertex(center + fDir + rDir);
+ }
+
+ // sideways lines
+ for (int i = 0; i < lines; i++)
+ {
+ Vector3 rDir = right * edgeLength * 0.5f;
+ Vector3 fDir = forward * (-(edgeLength * 0.5f) + (i * edgeLength / (lines - 1)));
+
+ GL.Vertex(center - rDir + fDir);
+ GL.Vertex(center + rDir + fDir);
+ }
+
+ Postpare();
+ }
+
+ #endregion
+
+
+ #region 3D Primitives
+
+ /// <summary>
+ /// Draws a sphere in world space. Similar to Gizmos.DrawWireSphere, but with the ability to add radial and vertical segments
+ /// </summary>
+ public static void Sphere(Vector3 center, float radius, int verticalSegments = 1, int radialSegments = 2)
+ {
+ if (radialSegments > 2)
+ {
+ for (int i = 0; i < radialSegments; i++)
+ {
+ Vector3 normal = new Vector3(Mathf.Sin((i * Mathf.PI) / radialSegments), 0, Mathf.Cos((i * Mathf.PI) / radialSegments));
+
+ Circle3D(center, radius, normal);
+ }
+ }
+ else
+ {
+ Circle3D(center, radius, Vector3.forward);
+ Circle3D(center, radius, Vector3.right);
+ }
+
+ if (verticalSegments > 1)
+ {
+ for (int i = 1; i < verticalSegments; i++)
+ {
+ Vector3 c = center + Vector3.up * (-radius + (i * 2 * (radius / (verticalSegments))));
+
+ // Radius of base circle is a=sqrt(h(2R-h)),
+ float height = ((float)i / verticalSegments) * radius * 2;
+ float ra = Mathf.Sqrt(height * (2 * radius - height));
+
+ Circle3D(c, ra, Vector3.up);
+ }
+ }
+ else
+ Circle3D(center, radius, Vector3.up);
+ }
+
+ public static void Cube(Vector3 center, Vector3 size)
+ {
+ Cube(center, size, Vector3.forward, Vector3.up);
+ }
+
+ public static void Cube(Vector3 center, Vector3 size, Vector3 forward, Vector3 up)
+ {
+ Prepare3D();
+
+ forward = forward.normalized;
+ up = Vector3.ProjectOnPlane(up, forward).normalized;
+ Vector3 right = Vector3.Cross(forward, up);
+
+ Vector3 frw = forward * size.z * 0.5f;
+ Vector3 rgt = right * size.x * 0.5f;
+ Vector3 upw = up * size.y * 0.5f;
+
+ // vertical lines
+ GL.Vertex(center - frw - rgt - upw);
+ GL.Vertex(center - frw - rgt + upw);
+
+ GL.Vertex(center - frw + rgt - upw);
+ GL.Vertex(center - frw + rgt + upw);
+
+ GL.Vertex(center + frw - rgt - upw);
+ GL.Vertex(center + frw - rgt + upw);
+
+ GL.Vertex(center + frw + rgt - upw);
+ GL.Vertex(center + frw + rgt + upw);
+
+ // horizontal lines
+ GL.Vertex(center - frw - rgt - upw);
+ GL.Vertex(center - frw + rgt - upw);
+
+ GL.Vertex(center - frw - rgt + upw);
+ GL.Vertex(center - frw + rgt + upw);
+
+ GL.Vertex(center + frw - rgt - upw);
+ GL.Vertex(center + frw + rgt - upw);
+
+ GL.Vertex(center + frw - rgt + upw);
+ GL.Vertex(center + frw + rgt + upw);
+
+ // forward lines
+ GL.Vertex(center - frw - rgt - upw);
+ GL.Vertex(center + frw - rgt - upw);
+
+ GL.Vertex(center - frw + rgt - upw);
+ GL.Vertex(center + frw + rgt - upw);
+
+ GL.Vertex(center - frw - rgt + upw);
+ GL.Vertex(center + frw - rgt + upw);
+
+ GL.Vertex(center - frw + rgt + upw);
+ GL.Vertex(center + frw + rgt + upw);
+
+ Postpare();
+ }
+
+ #endregion
+
+
+ #region Wireframe
+
+ public struct Edge
+ {
+ public int i1;
+ public int i2;
+
+ public Edge(int i1, int i2)
+ {
+ this.i1 = i1;
+ this.i2 = i2;
+ }
+
+ public bool Match(Edge e)
+ {
+ return (e.i1 == i1 && e.i2 == i2) || (e.i1 == i2 && e.i2 == i1);
+ }
+ }
+
+ /// <summary>
+ /// Draws mesh wireframe. Use Draw.GetEdgePointsFromMesh() to get edgePoints, preferably only once
+ /// </summary>
+ public static void Wireframe(Transform t, Vector3[] edgePoints)
+ {
+ if (edgePoints == null) return;
+ if (edgePoints.Length < 2) return;
+
+ Prepare3D();
+
+ for (int i = 0; i < edgePoints.Length; i++)
+ GL.Vertex(t.TransformPoint(edgePoints[i]));
+
+ Postpare();
+ }
+
+ /// <summary>
+ /// Gets edge points from a mesh.
+ /// Call this once, and then use Wireframe() to draw the lines
+ /// </summary>
+ public static Vector3[] GetEdgePointsFromMesh(Mesh mesh)
+ {
+ Edge[] edges = GetEdges(mesh);
+ return EdgesToVertices(edges, mesh);
+ }
+
+ /// <summary>
+ /// Gets edge points from a mesh.
+ /// In case you want both the shaded model and wireframe to show, you can use normalPush to offset edges from the mesh so it doesn't intersect with it.
+ /// Call this once, and then use Wireframe() to draw the lines
+ /// </summary>
+ public static Vector3[] GetEdgePointsFromMesh(Mesh mesh, float normalPush)
+ {
+ Edge[] edges = GetEdges(mesh);
+ return EdgesToVertices(edges, mesh, normalPush);
+ }
+
+
+ static Edge[] GetEdges(Mesh mesh)
+ {
+ int[] tris = mesh.triangles;
+
+ List<Edge> edges = new List<Edge>();
+
+ for (int i = 0; i < tris.Length; i += 3)
+ {
+
+ Edge e1 = new Edge(tris[i], tris[i + 1]);
+ Edge e2 = new Edge(tris[i + 1], tris[i + 2]);
+ Edge e3 = new Edge(tris[i + 2], tris[i]);
+
+ // if line already exists, skip
+
+ foreach (var edge in edges)
+ if (edge.Match(e1)) goto NoE1;
+
+ edges.Add(e1);
+
+ NoE1:
+
+ foreach (var edge in edges)
+ if (edge.Match(e2)) goto NoE2;
+
+ edges.Add(e2);
+
+ NoE2:
+
+ foreach (var edge in edges)
+ if (edge.Match(e3)) goto NoE3;
+
+ edges.Add(e3);
+
+ NoE3:;
+
+ }
+
+ return edges.ToArray();
+ }
+
+ static Vector3[] EdgesToVertices(Edge[] edges, Mesh mesh, float normalPush = 0)
+ {
+ Vector3[] vertices = mesh.vertices;
+
+ Vector3[] edgesV3 = new Vector3[edges.Length * 2];
+
+ Vector3[] normals = null;
+
+ if (normalPush != 0)
+ normals = mesh.normals;
+
+ for (int i = 0; i < edges.Length; i++)
+ {
+ edgesV3[i * 2] = vertices[edges[i].i1];
+ edgesV3[i * 2 + 1] = vertices[edges[i].i2];
+
+ if (normalPush != 0)
+ {
+ edgesV3[i * 2] += normals[edges[i].i1] * normalPush;
+ edgesV3[i * 2 + 1] += normals[edges[i].i2] * normalPush;
+ }
+ }
+
+ return edgesV3;
+ }
+
+ #endregion Wireframe
+
+
+ #region Utils
+
+ /// <summary>
+ /// Converts a coordinate in pixels to screen 0-1 fraction point.
+ /// Example: 400, 300, on a 800x600 screen will output 0.5, 0.5 (middle of the screen)
+ /// </summary>
+ public static Vector2 PixelToScreen(Vector2 pos)
+ {
+ return new Vector2(pos.x / Screen.width, pos.y / Screen.height);
+ }
+
+ /// <summary>
+ /// Converts a coordinate in pixels to screen 0-1 fraction point.
+ /// Example: 400, 300, on a 800x600 screen will output 0.5, 0.5 (middle of the screen)
+ /// </summary>
+ public static Vector2 PixelToScreen(float x, float y)
+ {
+ return new Vector2(x / Screen.width, y / Screen.height);
+ }
+
+ static void Prepare()
+ {
+ GL.PushMatrix();
+ GL.LoadOrtho();
+
+ GL.Begin(GL.LINES);
+
+ GL.Color(color);
+ }
+
+ static void PreparePixel()
+ {
+ GL.PushMatrix();
+ GL.LoadPixelMatrix();
+
+ GL.Begin(GL.LINES);
+
+ GL.Color(color);
+ }
+
+ static void Prepare3D()
+ {
+ GL.PushMatrix();
+
+ GL.Begin(GL.LINES);
+
+ GL.Color(color);
+ }
+
+ static void Postpare()
+ {
+ GL.End();
+ GL.PopMatrix();
+ }
+
+ #endregion
+ }
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs.meta
new file mode 100644
index 0000000..ae8765e
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/Draw.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a227ae0c9fddd854f89b2f3f450d6d83
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs
new file mode 100644
index 0000000..f2a6679
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs
@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class GLHandle : MonoBehaviour
+{
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs.meta
new file mode 100644
index 0000000..a06c61e
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GLHandle.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d61c36453ba3e064aa9136f1d97515f8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs
new file mode 100644
index 0000000..2122912
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs
@@ -0,0 +1,59 @@
+using System.Collections;
+using System.Collections.Generic;
+using Unity.VisualScripting;
+using UnityEngine;
+
+namespace Rigging.Debugging
+{
+ [DefaultExecutionOrder(-100)]
+ public class GizmosHandle : MonoBehaviour
+ {
+ private static GizmosHandle instance;
+ private static event System.Action onDrawGizmos;
+ private static event System.Action onDrawGizmosFixedUpdate;
+
+ private void OnDrawGizmos()
+ {
+ onDrawGizmos?.Invoke();
+ onDrawGizmos = null;
+
+ onDrawGizmosFixedUpdate?.Invoke();
+ }
+
+ private void FixedUpdate()
+ {
+ onDrawGizmosFixedUpdate = null;
+ }
+
+ public static void DrawCube(Vector3 position, Vector3 size)
+ {
+ Check();
+
+ if (Time.inFixedTimeStep)
+ {
+ onDrawGizmosFixedUpdate += () =>
+ {
+ Gizmos.DrawCube(position, size);
+ };
+ }
+ else
+ {
+ onDrawGizmos += () =>
+ {
+ Gizmos.DrawCube(position, size);
+ };
+ }
+ }
+
+ static void Check()
+ {
+ if(instance == null) {
+ GameObject handle = new GameObject();
+ handle.name = "GizmosHandle";
+ instance = handle.AddComponent<GizmosHandle>();
+ }
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs.meta
new file mode 100644
index 0000000..2772af1
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/GizmosHandle.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f2caa4cbf7ff56b4d819d99d691bd081
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs b/ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs
new file mode 100644
index 0000000..83c0742
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs
@@ -0,0 +1,144 @@
+
+using UnityEngine;
+
+namespace Rigging.Debugging
+{
+
+ /// <summary>
+ /// A simple free camera to be added to a Unity game object.
+ ///
+ /// Keys:
+ /// wasd / arrows - movement
+ /// q/e - up/down (local space)
+ /// r/f - up/down (world space)
+ /// pageup/pagedown - up/down (world space)
+ /// hold shift - enable fast movement mode
+ /// right mouse - enable free look
+ /// mouse - free look / rotation
+ ///
+ /// </summary>
+ public class SimpleMoveCamera : MonoBehaviour
+ {
+ /// <summary>
+ /// Normal speed of camera movement.
+ /// </summary>
+ public float movementSpeed = 10f;
+
+ /// <summary>
+ /// Speed of camera movement when shift is held down,
+ /// </summary>
+ public float fastMovementSpeed = 100f;
+
+ /// <summary>
+ /// Sensitivity for free look.
+ /// </summary>
+ public float freeLookSensitivity = 3f;
+
+ /// <summary>
+ /// Amount to zoom the camera when using the mouse wheel.
+ /// </summary>
+ public float zoomSensitivity = 10f;
+
+ /// <summary>
+ /// Amount to zoom the camera when using the mouse wheel (fast mode).
+ /// </summary>
+ public float fastZoomSensitivity = 50f;
+
+ /// <summary>
+ /// Set to true when free looking (on right mouse button).
+ /// </summary>
+ private bool looking = false;
+
+ void Update()
+ {
+ var fastMode = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
+ var movementSpeed = fastMode ? this.fastMovementSpeed : this.movementSpeed;
+
+ if (Input.GetKey(KeyCode.H) || Input.GetKey(KeyCode.LeftArrow))
+ {
+ transform.position = transform.position + (-transform.right * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.K) || Input.GetKey(KeyCode.RightArrow))
+ {
+ transform.position = transform.position + (transform.right * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.U) || Input.GetKey(KeyCode.UpArrow))
+ {
+ transform.position = transform.position + (transform.forward * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.J) || Input.GetKey(KeyCode.DownArrow))
+ {
+ transform.position = transform.position + (-transform.forward * movementSpeed * Time.deltaTime);
+ }
+ if (Input.GetKey(KeyCode.Q))
+ {
+ transform.position = transform.position + (transform.up * movementSpeed * Time.deltaTime);
+ }
+ if (Input.GetKey(KeyCode.E))
+ {
+ transform.position = transform.position + (-transform.up * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.PageUp))
+ {
+ transform.position = transform.position + (Vector3.up * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.F) || Input.GetKey(KeyCode.PageDown))
+ {
+ transform.position = transform.position + (-Vector3.up * movementSpeed * Time.deltaTime);
+ }
+
+ if (looking)
+ {
+ float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * freeLookSensitivity;
+ float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * freeLookSensitivity;
+ transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f);
+ }
+
+ float axis = Input.GetAxis("Mouse ScrollWheel");
+ if (axis != 0)
+ {
+ var zoomSensitivity = fastMode ? this.fastZoomSensitivity : this.zoomSensitivity;
+ transform.position = transform.position + transform.forward * axis * zoomSensitivity;
+ }
+
+ if (Input.GetKeyDown(KeyCode.Mouse1))
+ {
+ StartLooking();
+ }
+ else if (Input.GetKeyUp(KeyCode.Mouse1))
+ {
+ StopLooking();
+ }
+ }
+
+ void OnDisable()
+ {
+ StopLooking();
+ }
+
+ /// <summary>
+ /// Enable free looking.
+ /// </summary>
+ public void StartLooking()
+ {
+ looking = true;
+ Cursor.visible = false;
+ Cursor.lockState = CursorLockMode.Locked;
+ }
+
+ /// <summary>
+ /// Disable free looking.
+ /// </summary>
+ public void StopLooking()
+ {
+ looking = false;
+ Cursor.visible = true;
+ Cursor.lockState = CursorLockMode.None;
+ }
+ }
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs.meta
new file mode 100644
index 0000000..ecda58a
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Debug/SimpleMoveCamera.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8e7c978536d546d43b9edbb449f2e3a0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/ProjectSettings/BurstAotSettings_StandaloneWindows.json b/ActiveRagdoll/ProjectSettings/BurstAotSettings_StandaloneWindows.json
index 2144f6d..36e6a2c 100644
--- a/ActiveRagdoll/ProjectSettings/BurstAotSettings_StandaloneWindows.json
+++ b/ActiveRagdoll/ProjectSettings/BurstAotSettings_StandaloneWindows.json
@@ -1,16 +1,18 @@
{
"MonoBehaviour": {
- "Version": 3,
+ "Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
- "UsePlatformSDKLinker": false,
+ "DebugDataKind": 0,
+ "EnableArmv9SecurityFeatures": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"CpuTargetsX32": 6,
- "CpuTargetsX64": 72
+ "CpuTargetsX64": 72,
+ "OptimizeFor": 0
}
}
diff --git a/ActiveRagdoll/ProjectSettings/CommonBurstAotSettings.json b/ActiveRagdoll/ProjectSettings/CommonBurstAotSettings.json
index 3dffdba..0293daf 100644
--- a/ActiveRagdoll/ProjectSettings/CommonBurstAotSettings.json
+++ b/ActiveRagdoll/ProjectSettings/CommonBurstAotSettings.json
@@ -1,6 +1,6 @@
{
"MonoBehaviour": {
- "Version": 3,
+ "Version": 4,
"DisabledWarnings": ""
}
}