Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Apr 13, 2023
2 parents 9b4ef5a + 2f5d1ae commit 3bd69df
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 22 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/docfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ jobs:
runs-on: ubuntu-latest
name: Publish Documentation
steps:
- uses: actions/checkout@v3
- uses: nikeee/docfx-action@v1.0.0
name: Build Documentation
with:
args: docfx_project/docfx.json
- uses: maxheld83/ghpages@master
name: Publish Documentation on GitHub Pages
env:
BUILD_DIR: docfx_project/_site
GH_PAT: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3

- name: Copy favicon
run: cp brandin_Icon.png docfx_project/images/favicon.png

- name: Build documentation
uses: nikeee/docfx-action@v1.0.0
with:
args: docfx_project/docfx.json

- name: Publish documentation on GitHub Pages
uses: maxheld83/ghpages@master
env:
BUILD_DIR: docfx_project/_site
GH_PAT: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(ulong[, ReadOnlySpan<char>[, IFormatProvider]])`.
- X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`.
- X10D.Unity: Added `DebugUtility.DrawFunction`, and `DebugUtility.DrawUnjoinedPolyhedron` on which it relies.

### Changed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System;
using UnityEngine;
using X10D.Drawing;
using X10D.Unity.Drawing;
using Color = UnityEngine.Color;
Expand Down Expand Up @@ -34,6 +35,9 @@ private void Update()
var sphere = new Sphere(System.Numerics.Vector3.Zero, 0.5f);
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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2021.3.21f1
m_EditorVersionWithRevision: 2021.3.21f1 (1b156197d683)
m_EditorVersion: 2021.3.22f1
m_EditorVersionWithRevision: 2021.3.22f1 (b6c551784ba3)
69 changes: 69 additions & 0 deletions X10D.Unity/src/DebugUtility/DebugUtility.Function.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
45 changes: 44 additions & 1 deletion X10D.Unity/src/DebugUtility/DebugUtility.Polyhedron.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using X10D.Drawing;
using X10D.Unity.Numerics;

Expand Down Expand Up @@ -126,4 +126,47 @@ public static void DrawPolyhedron(Polyhedron polyhedron, in Vector3 offset, in C
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);
}
}
}
5 changes: 3 additions & 2 deletions docfx_project/api/index.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# PLACEHOLDER
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*!
# Introduction

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.
14 changes: 13 additions & 1 deletion docfx_project/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@
}
],
"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": [],
"template": [
"default", "templates/singulinkfx"
Expand Down
7 changes: 3 additions & 4 deletions docfx_project/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This is the **HOMEPAGE**.
Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
## Quick Start Notes:
1. Add images to the *images* folder if the file is referencing an image.
# Introduction

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.

0 comments on commit 3bd69df

Please sign in to comment.