1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:25:43 +00:00

Merge branch 'develop' into main

This commit is contained in:
Oliver Booth 2023-04-13 02:33:29 +01:00
commit 3bd69dfa36
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
9 changed files with 157 additions and 22 deletions

View File

@ -9,13 +9,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Publish Documentation name: Publish Documentation
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- uses: nikeee/docfx-action@v1.0.0 uses: actions/checkout@v3
name: Build Documentation
- name: Copy favicon
run: cp brandin_Icon.png docfx_project/images/favicon.png
- name: Build documentation
uses: nikeee/docfx-action@v1.0.0
with: with:
args: docfx_project/docfx.json args: docfx_project/docfx.json
- uses: maxheld83/ghpages@master
name: Publish Documentation on GitHub Pages - name: Publish documentation on GitHub Pages
uses: maxheld83/ghpages@master
env: env:
BUILD_DIR: docfx_project/_site BUILD_DIR: docfx_project/_site
GH_PAT: ${{ secrets.GH_PAT }} GH_PAT: ${{ secrets.GH_PAT }}

View File

@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- X10D: Added `TextWriter.WriteLineNoAlloc(long[, ReadOnlySpan<char>[, IFormatProvider]])`. - X10D: Added `TextWriter.WriteLineNoAlloc(long[, ReadOnlySpan<char>[, IFormatProvider]])`.
- X10D: Added `TextWriter.WriteLineNoAlloc(ulong[, ReadOnlySpan<char>[, IFormatProvider]])`. - X10D: Added `TextWriter.WriteLineNoAlloc(ulong[, ReadOnlySpan<char>[, IFormatProvider]])`.
- X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`. - X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`.
- X10D.Unity: Added `DebugUtility.DrawFunction`, and `DebugUtility.DrawUnjoinedPolyhedron` on which it relies.
### Changed ### Changed

View File

@ -1,4 +1,5 @@
using UnityEngine; using System;
using UnityEngine;
using X10D.Drawing; using X10D.Drawing;
using X10D.Unity.Drawing; using X10D.Unity.Drawing;
using Color = UnityEngine.Color; using Color = UnityEngine.Color;
@ -34,6 +35,9 @@ namespace X10D.Unity.Tests
var sphere = new Sphere(System.Numerics.Vector3.Zero, 0.5f); var sphere = new Sphere(System.Numerics.Vector3.Zero, 0.5f);
DebugUtility.DrawSphere(sphere, 25, new Vector2(0.0f, -1.5f), Color.white); DebugUtility.DrawSphere(sphere, 25, new Vector2(0.0f, -1.5f), Color.white);
DebugUtility.DrawFunction(x => MathF.Sin(x + UnityEngine.Time.time % (2 * MathF.PI)), -10, 10, 0.1f, Vector3.up * 4,
Color.yellow, 0.0f, false);
DebugUtility.Assert(true); DebugUtility.Assert(true);
} }
} }

View File

@ -1,2 +1,2 @@
m_EditorVersion: 2021.3.21f1 m_EditorVersion: 2021.3.22f1
m_EditorVersionWithRevision: 2021.3.21f1 (1b156197d683) m_EditorVersionWithRevision: 2021.3.22f1 (b6c551784ba3)

View File

@ -0,0 +1,69 @@
using UnityEngine;
using X10D.Drawing;
using X10D.Numerics;
using X10D.Unity.Numerics;
using Quaternion = System.Numerics.Quaternion;
namespace X10D.Unity;
public static partial class DebugUtility
{
/// <summary>
/// Draws a function plot.
/// </summary>
/// <param name="function">The function to plot.</param>
/// <param name="xMin">The minimum X value.</param>
/// <param name="xMax">The maximum X value.</param>
public static void DrawFunction(Func<float, float> function, float xMin, float xMax)
{
DrawFunction(function, xMin, xMax, 0.1f, Vector3.zero, Color.white, 0.0f, false);
}
/// <summary>
/// Draws a function plot.
/// </summary>
/// <param name="function">The function to plot.</param>
/// <param name="xMin">The minimum X value.</param>
/// <param name="xMax">The maximum X value.</param>
/// <param name="step">The X increment.</param>
/// <param name="offset">The drawing offset of the circle.</param>
/// <param name="color">The color of the circle.</param>
/// <param name="duration">
/// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame.
/// </param>
/// <param name="depthTest">
/// <see langword="true" /> if depth test should be applied; otherwise, <see langword="false" />. Passing
/// <see langword="true" /> will have the circle be obscured by objects closer to the camera.
/// </param>
/// <exception cref="ArgumentNullException"><paramref name="function" /> is <see langword="null" />.</exception>
public static void DrawFunction(Func<float, float> function, float xMin, float xMax, float step, in Vector3 offset,
in Color color, float duration,
bool depthTest)
{
if (function is null)
{
throw new ArgumentNullException(nameof(function));
}
DrawUnjoinedPolyhedron(CreateFunction(function, xMin, xMax, step, Vector3.zero), offset, color, duration, depthTest);
}
private static Polyhedron CreateFunction(Func<float, float> function, float xMin, float xMax, float step, in Vector3 axis)
{
var points = new List<System.Numerics.Vector3>();
for (float x = xMin; x < xMax; x += step)
{
float y = function(x);
var vector = new System.Numerics.Vector3(x, y, 0);
if (axis != Vector3.zero)
{
vector = Quaternion.CreateFromAxisAngle(axis.ToSystemVector(), MathF.PI / 2.0f).Multiply(vector);
}
points.Add(vector);
}
return new Polyhedron(points);
}
}

View File

@ -1,4 +1,4 @@
using UnityEngine; using UnityEngine;
using X10D.Drawing; using X10D.Drawing;
using X10D.Unity.Numerics; using X10D.Unity.Numerics;
@ -126,4 +126,47 @@ public static partial class DebugUtility
DrawLine(start, end, color, duration, depthTest); DrawLine(start, end, color, duration, depthTest);
} }
} }
/// <summary>
/// Draws a polyhedron.
/// </summary>
/// <param name="polyhedron">The polyhedron to draw.</param>
/// <param name="offset">The drawing offset of the polyhedron.</param>
/// <param name="color">The color to use for drawing.</param>
/// <param name="duration">
/// The duration of the polyhedron's visibility, in seconds. If 0 is passed, the polyhedron is visible for a single frame.
/// </param>
/// <param name="depthTest">
/// <see langword="true" /> if depth test should be applied; otherwise, <see langword="false" />. Passing
/// <see langword="true" /> will have the box be obscured by objects closer to the camera.
/// </param>
/// <exception cref="ArgumentNullException"><paramref name="polyhedron" /> is <see langword="null" />.</exception>
public static void DrawUnjoinedPolyhedron(Polyhedron polyhedron, in Vector3 offset, in Color color, float duration,
bool depthTest)
{
if (polyhedron is null)
{
throw new ArgumentNullException(nameof(polyhedron));
}
IReadOnlyList<System.Numerics.Vector3> points = polyhedron.Vertices;
if (points.Count < 2)
{
return;
}
for (var i = 0; i < points.Count; i++)
{
if (i >= points.Count - 2)
{
break;
}
int j = i + 1;
Vector3 start = points[i].ToUnityVector() + offset;
Vector3 end = points[j].ToUnityVector() + offset;
DrawLine(start, end, color, duration, depthTest);
}
}
} }

View File

@ -1,2 +1,3 @@
# PLACEHOLDER # Introduction
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*!
X10D (pronounced *extend*), is a .NET package that provides extension methods for numerous types. The purpose of this library is to simplify a codebase by reducing the need for repeated code when performing common operations. Simplify your codebase. Take advantage of .NET. Use extension methods.

View File

@ -51,7 +51,19 @@
} }
], ],
"dest": "_site", "dest": "_site",
"globalMetadataFiles": [], "globalMetadata": {
"_appTitle": "X10D",
"_appName": "X10D",
"_appFaviconPath": "images/favicon.png",
"_appLogoPath": "images/favicon.png",
"_appFooter": "<strong>DocFX + Singulink = ♥</strong>",
"_copyrightFooter": "© Singulink. All rights reserved.",
"_enableSearch": true,
"_disableSideFilter": false,
"_enableNewTab": true,
"_disableContribution": false,
"_disableBreadcrumb": false,
},
"fileMetadataFiles": [], "fileMetadataFiles": [],
"template": [ "template": [
"default", "templates/singulinkfx" "default", "templates/singulinkfx"

View File

@ -1,4 +1,3 @@
# This is the **HOMEPAGE**. # Introduction
Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
## Quick Start Notes: X10D (pronounced *extend*), is a .NET package that provides extension methods for numerous types. The purpose of this library is to simplify a codebase by reducing the need for repeated code when performing common operations. Simplify your codebase. Take advantage of .NET. Use extension methods.
1. Add images to the *images* folder if the file is referencing an image.