Formatting pass
parent
a0c57c7a59
commit
8973b3e658
|
@ -0,0 +1,14 @@
|
||||||
|
# EditorConfig is awesome: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = tab
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.cs]
|
||||||
|
csharp_space_after_cast = true
|
||||||
|
charset = utf-8-bom
|
||||||
|
max_line_length = 100
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using MoonWorks.Math;
|
using MoonWorks.Math;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using MoonWorks.Math;
|
using MoonWorks.Math;
|
||||||
|
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using MoonWorks.Math;
|
using MoonWorks.Math;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
{
|
{
|
||||||
public enum SoundState
|
public enum SoundState
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
|
@ -20,7 +20,8 @@ namespace MoonWorks.Audio
|
||||||
string filePath,
|
string filePath,
|
||||||
bool is3D = false,
|
bool is3D = false,
|
||||||
bool loop = false
|
bool loop = false
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var fileHandle = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero);
|
var fileHandle = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +60,8 @@ namespace MoonWorks.Audio
|
||||||
out uint bufferOffset,
|
out uint bufferOffset,
|
||||||
out uint bufferLength,
|
out uint bufferLength,
|
||||||
out bool reachedEnd
|
out bool reachedEnd
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
buffer = this.buffer;
|
buffer = this.buffer;
|
||||||
|
|
||||||
/* NOTE: this function returns samples per channel, not total samples */
|
/* NOTE: this function returns samples per channel, not total samples */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MoonWorks
|
namespace MoonWorks
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,8 @@ namespace MoonWorks
|
||||||
PresentMode presentMode,
|
PresentMode presentMode,
|
||||||
int targetTimestep = 60,
|
int targetTimestep = 60,
|
||||||
bool debugMode = false
|
bool debugMode = false
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
timestep = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / targetTimestep);
|
timestep = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / targetTimestep);
|
||||||
gameTimer = Stopwatch.StartNew();
|
gameTimer = Stopwatch.StartNew();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public struct BufferBinding
|
public struct BufferBinding
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using MoonWorks.Math;
|
using MoonWorks.Math;
|
||||||
using MoonWorks.Window;
|
using MoonWorks.Window;
|
||||||
|
@ -36,7 +36,8 @@ namespace MoonWorks.Graphics
|
||||||
Framebuffer framebuffer,
|
Framebuffer framebuffer,
|
||||||
in Rect renderArea,
|
in Rect renderArea,
|
||||||
in DepthStencilValue depthStencilClearValue
|
in DepthStencilValue depthStencilClearValue
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_BeginRenderPass(
|
Refresh.Refresh_BeginRenderPass(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -65,7 +66,8 @@ namespace MoonWorks.Graphics
|
||||||
in Rect renderArea,
|
in Rect renderArea,
|
||||||
in DepthStencilValue depthStencilClearValue,
|
in DepthStencilValue depthStencilClearValue,
|
||||||
params Vector4[] clearColors
|
params Vector4[] clearColors
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
|
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
|
||||||
|
|
||||||
for (var i = 0; i < clearColors.Length; i++)
|
for (var i = 0; i < clearColors.Length; i++)
|
||||||
|
@ -105,7 +107,8 @@ namespace MoonWorks.Graphics
|
||||||
Framebuffer framebuffer,
|
Framebuffer framebuffer,
|
||||||
in Rect renderArea,
|
in Rect renderArea,
|
||||||
params Vector4[] clearColors
|
params Vector4[] clearColors
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
|
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
|
||||||
|
|
||||||
for (var i = 0; i < clearColors.Length; i++)
|
for (var i = 0; i < clearColors.Length; i++)
|
||||||
|
@ -143,7 +146,8 @@ namespace MoonWorks.Graphics
|
||||||
RenderPass renderPass,
|
RenderPass renderPass,
|
||||||
Framebuffer framebuffer,
|
Framebuffer framebuffer,
|
||||||
in Rect renderArea
|
in Rect renderArea
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_BeginRenderPass(
|
Refresh.Refresh_BeginRenderPass(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -162,7 +166,8 @@ namespace MoonWorks.Graphics
|
||||||
/// <param name="computePipeline">The compute pipeline to bind.</param>
|
/// <param name="computePipeline">The compute pipeline to bind.</param>
|
||||||
public void BindComputePipeline(
|
public void BindComputePipeline(
|
||||||
ComputePipeline computePipeline
|
ComputePipeline computePipeline
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_BindComputePipeline(
|
Refresh.Refresh_BindComputePipeline(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -176,7 +181,8 @@ namespace MoonWorks.Graphics
|
||||||
/// <param name="buffers">A set of buffers to bind.</param>
|
/// <param name="buffers">A set of buffers to bind.</param>
|
||||||
public unsafe void BindComputeBuffers(
|
public unsafe void BindComputeBuffers(
|
||||||
params Buffer[] buffers
|
params Buffer[] buffers
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var bufferPtrs = stackalloc IntPtr[buffers.Length];
|
var bufferPtrs = stackalloc IntPtr[buffers.Length];
|
||||||
|
|
||||||
for (var i = 0; i < buffers.Length; i += 1)
|
for (var i = 0; i < buffers.Length; i += 1)
|
||||||
|
@ -197,7 +203,8 @@ namespace MoonWorks.Graphics
|
||||||
/// <param name="textures">A set of textures to bind.</param>
|
/// <param name="textures">A set of textures to bind.</param>
|
||||||
public unsafe void BindComputeTextures(
|
public unsafe void BindComputeTextures(
|
||||||
params Texture[] textures
|
params Texture[] textures
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var texturePtrs = stackalloc IntPtr[textures.Length];
|
var texturePtrs = stackalloc IntPtr[textures.Length];
|
||||||
|
|
||||||
for (var i = 0; i < textures.Length; i += 1)
|
for (var i = 0; i < textures.Length; i += 1)
|
||||||
|
@ -224,7 +231,8 @@ namespace MoonWorks.Graphics
|
||||||
uint groupCountY,
|
uint groupCountY,
|
||||||
uint groupCountZ,
|
uint groupCountZ,
|
||||||
uint computeParamOffset
|
uint computeParamOffset
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_DispatchCompute(
|
Refresh.Refresh_DispatchCompute(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -241,7 +249,8 @@ namespace MoonWorks.Graphics
|
||||||
/// <param name="graphicsPipeline">The graphics pipeline to bind.</param>
|
/// <param name="graphicsPipeline">The graphics pipeline to bind.</param>
|
||||||
public void BindGraphicsPipeline(
|
public void BindGraphicsPipeline(
|
||||||
GraphicsPipeline graphicsPipeline
|
GraphicsPipeline graphicsPipeline
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_BindGraphicsPipeline(
|
Refresh.Refresh_BindGraphicsPipeline(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -257,7 +266,8 @@ namespace MoonWorks.Graphics
|
||||||
public unsafe void BindVertexBuffers(
|
public unsafe void BindVertexBuffers(
|
||||||
uint firstBinding,
|
uint firstBinding,
|
||||||
params BufferBinding[] bufferBindings
|
params BufferBinding[] bufferBindings
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var bufferPtrs = stackalloc IntPtr[bufferBindings.Length];
|
var bufferPtrs = stackalloc IntPtr[bufferBindings.Length];
|
||||||
var offsets = stackalloc ulong[bufferBindings.Length];
|
var offsets = stackalloc ulong[bufferBindings.Length];
|
||||||
|
|
||||||
|
@ -283,7 +293,8 @@ namespace MoonWorks.Graphics
|
||||||
/// <param name="buffers">The buffers to bind.</param>
|
/// <param name="buffers">The buffers to bind.</param>
|
||||||
public unsafe void BindVertexBuffers(
|
public unsafe void BindVertexBuffers(
|
||||||
params Buffer[] buffers
|
params Buffer[] buffers
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var bufferPtrs = stackalloc IntPtr[buffers.Length];
|
var bufferPtrs = stackalloc IntPtr[buffers.Length];
|
||||||
var offsets = stackalloc ulong[buffers.Length];
|
var offsets = stackalloc ulong[buffers.Length];
|
||||||
|
|
||||||
|
@ -313,7 +324,8 @@ namespace MoonWorks.Graphics
|
||||||
Buffer indexBuffer,
|
Buffer indexBuffer,
|
||||||
IndexElementSize indexElementSize,
|
IndexElementSize indexElementSize,
|
||||||
uint offset = 0
|
uint offset = 0
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_BindIndexBuffer(
|
Refresh.Refresh_BindIndexBuffer(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -331,7 +343,8 @@ namespace MoonWorks.Graphics
|
||||||
public unsafe void BindVertexSamplers(
|
public unsafe void BindVertexSamplers(
|
||||||
TextureSamplerBinding[] textureSamplerBindings,
|
TextureSamplerBinding[] textureSamplerBindings,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
||||||
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
||||||
|
|
||||||
|
@ -355,7 +368,8 @@ namespace MoonWorks.Graphics
|
||||||
/// <param name="textureSamplerBindings">The texture-sampler pairs to bind.</param>
|
/// <param name="textureSamplerBindings">The texture-sampler pairs to bind.</param>
|
||||||
public unsafe void BindVertexSamplers(
|
public unsafe void BindVertexSamplers(
|
||||||
params TextureSamplerBinding[] textureSamplerBindings
|
params TextureSamplerBinding[] textureSamplerBindings
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
BindVertexSamplers(textureSamplerBindings, textureSamplerBindings.Length);
|
BindVertexSamplers(textureSamplerBindings, textureSamplerBindings.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +381,8 @@ namespace MoonWorks.Graphics
|
||||||
public unsafe void BindFragmentSamplers(
|
public unsafe void BindFragmentSamplers(
|
||||||
TextureSamplerBinding[] textureSamplerBindings,
|
TextureSamplerBinding[] textureSamplerBindings,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
||||||
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length];
|
||||||
|
|
||||||
|
@ -391,7 +406,8 @@ namespace MoonWorks.Graphics
|
||||||
/// <param name="textureSamplerBindings">An array of texture-sampler pairs to bind.</param>
|
/// <param name="textureSamplerBindings">An array of texture-sampler pairs to bind.</param>
|
||||||
public unsafe void BindFragmentSamplers(
|
public unsafe void BindFragmentSamplers(
|
||||||
params TextureSamplerBinding[] textureSamplerBindings
|
params TextureSamplerBinding[] textureSamplerBindings
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
BindFragmentSamplers(textureSamplerBindings, textureSamplerBindings.Length);
|
BindFragmentSamplers(textureSamplerBindings, textureSamplerBindings.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +481,8 @@ namespace MoonWorks.Graphics
|
||||||
ClearOptionsFlags clearOptions,
|
ClearOptionsFlags clearOptions,
|
||||||
in DepthStencilValue depthStencilClearValue,
|
in DepthStencilValue depthStencilClearValue,
|
||||||
params Vector4[] clearColors
|
params Vector4[] clearColors
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
|
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
|
||||||
for (var i = 0; i < clearColors.Length; i++)
|
for (var i = 0; i < clearColors.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -506,7 +523,8 @@ namespace MoonWorks.Graphics
|
||||||
uint instanceCount,
|
uint instanceCount,
|
||||||
uint vertexParamOffset,
|
uint vertexParamOffset,
|
||||||
uint fragmentParamOffset
|
uint fragmentParamOffset
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_DrawInstancedPrimitives(
|
Refresh.Refresh_DrawInstancedPrimitives(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -533,7 +551,8 @@ namespace MoonWorks.Graphics
|
||||||
uint primitiveCount,
|
uint primitiveCount,
|
||||||
uint vertexParamOffset,
|
uint vertexParamOffset,
|
||||||
uint fragmentParamOffset
|
uint fragmentParamOffset
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_DrawIndexedPrimitives(
|
Refresh.Refresh_DrawIndexedPrimitives(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -557,7 +576,8 @@ namespace MoonWorks.Graphics
|
||||||
uint primitiveCount,
|
uint primitiveCount,
|
||||||
uint vertexParamOffset,
|
uint vertexParamOffset,
|
||||||
uint fragmentParamOffset
|
uint fragmentParamOffset
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_DrawPrimitives(
|
Refresh.Refresh_DrawPrimitives(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -591,7 +611,8 @@ namespace MoonWorks.Graphics
|
||||||
in Rect destinationRectangle,
|
in Rect destinationRectangle,
|
||||||
Filter filter,
|
Filter filter,
|
||||||
OSWindow window
|
OSWindow window
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var refreshRect = destinationRectangle.ToRefresh();
|
var refreshRect = destinationRectangle.ToRefresh();
|
||||||
var refreshTextureSlice = new Refresh.TextureSlice
|
var refreshTextureSlice = new Refresh.TextureSlice
|
||||||
{
|
{
|
||||||
|
@ -629,7 +650,8 @@ namespace MoonWorks.Graphics
|
||||||
in Rect destinationRectangle,
|
in Rect destinationRectangle,
|
||||||
Filter filter,
|
Filter filter,
|
||||||
OSWindow window
|
OSWindow window
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
||||||
var refreshRect = destinationRectangle.ToRefresh();
|
var refreshRect = destinationRectangle.ToRefresh();
|
||||||
|
|
||||||
|
@ -653,7 +675,8 @@ namespace MoonWorks.Graphics
|
||||||
in TextureSlice textureSlice,
|
in TextureSlice textureSlice,
|
||||||
Filter filter,
|
Filter filter,
|
||||||
OSWindow window
|
OSWindow window
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_QueuePresent(
|
Refresh.Refresh_QueuePresent(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -674,7 +697,8 @@ namespace MoonWorks.Graphics
|
||||||
Texture texture,
|
Texture texture,
|
||||||
Filter filter,
|
Filter filter,
|
||||||
OSWindow window
|
OSWindow window
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var refreshTextureSlice = new Refresh.TextureSlice
|
var refreshTextureSlice = new Refresh.TextureSlice
|
||||||
{
|
{
|
||||||
texture = texture.Handle,
|
texture = texture.Handle,
|
||||||
|
@ -713,7 +737,8 @@ namespace MoonWorks.Graphics
|
||||||
IntPtr dataPtr,
|
IntPtr dataPtr,
|
||||||
uint bufferOffsetInBytes,
|
uint bufferOffsetInBytes,
|
||||||
uint dataLengthInBytes
|
uint dataLengthInBytes
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Refresh.Refresh_SetBufferData(
|
Refresh.Refresh_SetBufferData(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -849,7 +874,8 @@ namespace MoonWorks.Graphics
|
||||||
in TextureSlice sourceTextureSlice,
|
in TextureSlice sourceTextureSlice,
|
||||||
in TextureSlice destinationTextureSlice,
|
in TextureSlice destinationTextureSlice,
|
||||||
Filter filter
|
Filter filter
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var sourceRefreshTextureSlice = sourceTextureSlice.ToRefreshTextureSlice();
|
var sourceRefreshTextureSlice = sourceTextureSlice.ToRefreshTextureSlice();
|
||||||
var destRefreshTextureSlice = destinationTextureSlice.ToRefreshTextureSlice();
|
var destRefreshTextureSlice = destinationTextureSlice.ToRefreshTextureSlice();
|
||||||
|
|
||||||
|
@ -871,7 +897,8 @@ namespace MoonWorks.Graphics
|
||||||
public void CopyTextureToBuffer(
|
public void CopyTextureToBuffer(
|
||||||
in TextureSlice textureSlice,
|
in TextureSlice textureSlice,
|
||||||
Buffer buffer
|
Buffer buffer
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
||||||
|
|
||||||
Refresh.Refresh_CopyTextureToBuffer(
|
Refresh.Refresh_CopyTextureToBuffer(
|
||||||
|
|
|
@ -18,7 +18,8 @@ namespace MoonWorks.Graphics
|
||||||
Refresh.PresentMode presentMode,
|
Refresh.PresentMode presentMode,
|
||||||
bool debugMode,
|
bool debugMode,
|
||||||
int initialCommandBufferPoolSize = 4
|
int initialCommandBufferPoolSize = 4
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var presentationParameters = new Refresh.PresentationParameters
|
var presentationParameters = new Refresh.PresentationParameters
|
||||||
{
|
{
|
||||||
deviceWindowHandle = deviceWindowHandle,
|
deviceWindowHandle = deviceWindowHandle,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using RefreshCS;
|
using RefreshCS;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ namespace MoonWorks.Graphics
|
||||||
ShaderStageState computeShaderState,
|
ShaderStageState computeShaderState,
|
||||||
uint bufferBindingCount,
|
uint bufferBindingCount,
|
||||||
uint imageBindingCount
|
uint imageBindingCount
|
||||||
) : base(device) {
|
) : base(device)
|
||||||
|
{
|
||||||
var computePipelineLayoutCreateInfo = new Refresh.ComputePipelineLayoutCreateInfo
|
var computePipelineLayoutCreateInfo = new Refresh.ComputePipelineLayoutCreateInfo
|
||||||
{
|
{
|
||||||
bufferBindingCount = bufferBindingCount,
|
bufferBindingCount = bufferBindingCount,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using RefreshCS;
|
using RefreshCS;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using RefreshCS;
|
using RefreshCS;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ namespace MoonWorks.Graphics
|
||||||
bool canBeSampled,
|
bool canBeSampled,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
TextureUsageFlags flags = 0;
|
TextureUsageFlags flags = 0;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -40,7 +41,8 @@ namespace MoonWorks.Graphics
|
||||||
format == TextureFormat.D32 ||
|
format == TextureFormat.D32 ||
|
||||||
format == TextureFormat.D16S8 ||
|
format == TextureFormat.D16S8 ||
|
||||||
format == TextureFormat.D32S8
|
format == TextureFormat.D32S8
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
flags |= TextureUsageFlags.DepthStencilTarget;
|
flags |= TextureUsageFlags.DepthStencilTarget;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using RefreshCS;
|
using RefreshCS;
|
||||||
|
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
|
|
|
@ -82,7 +82,8 @@ namespace MoonWorks.Graphics
|
||||||
TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var textureCreateInfo = new TextureCreateInfo
|
var textureCreateInfo = new TextureCreateInfo
|
||||||
{
|
{
|
||||||
Width = width,
|
Width = width,
|
||||||
|
@ -118,7 +119,8 @@ namespace MoonWorks.Graphics
|
||||||
TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var textureCreateInfo = new TextureCreateInfo
|
var textureCreateInfo = new TextureCreateInfo
|
||||||
{
|
{
|
||||||
Width = width,
|
Width = width,
|
||||||
|
@ -150,7 +152,8 @@ namespace MoonWorks.Graphics
|
||||||
TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
var textureCreateInfo = new TextureCreateInfo
|
var textureCreateInfo = new TextureCreateInfo
|
||||||
{
|
{
|
||||||
Width = size,
|
Width = size,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes how the graphics pipeline will blend colors.
|
/// Describes how the graphics pipeline will blend colors.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines how data is written to and read from the depth/stencil buffer.
|
/// Determines how data is written to and read from the depth/stencil buffer.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public struct GraphicsPipelineCreateInfo
|
public struct GraphicsPipelineCreateInfo
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes how many samplers will be used in each shader stage.
|
/// Describes how many samplers will be used in each shader stage.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies how many samples should be used in rasterization.
|
/// Specifies how many samples should be used in rasterization.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies how the rasterizer should be configured for a graphics pipeline.
|
/// Specifies how the rasterizer should be configured for a graphics pipeline.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies how the graphics pipeline will make use of a shader.
|
/// Specifies how the graphics pipeline will make use of a shader.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies how to interpet vertex data in a buffer to be passed to the vertex shader.
|
/// Specifies how to interpet vertex data in a buffer to be passed to the vertex shader.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes the dimensions of viewports and scissor areas.
|
/// Describes the dimensions of viewports and scissor areas.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public struct BlendConstants
|
public struct BlendConstants
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks
|
namespace MoonWorks
|
||||||
{
|
{
|
||||||
public static class Conversions
|
public static class Conversions
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Input
|
namespace MoonWorks.Input
|
||||||
{
|
{
|
||||||
public class ButtonState
|
public class ButtonState
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Input
|
namespace MoonWorks.Input
|
||||||
{
|
{
|
||||||
internal enum ButtonStatus
|
internal enum ButtonStatus
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using MoonWorks.Math;
|
using MoonWorks.Math;
|
||||||
using SDL2;
|
using SDL2;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using SDL2;
|
using SDL2;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using SDL2;
|
using SDL2;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Input
|
namespace MoonWorks.Input
|
||||||
{
|
{
|
||||||
// Enum values are equivalent to the SDL Scancode value.
|
// Enum values are equivalent to the SDL Scancode value.
|
||||||
public enum Keycode : int
|
public enum Keycode : int
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using RefreshCS;
|
using RefreshCS;
|
||||||
|
|
||||||
namespace MoonWorks
|
namespace MoonWorks
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -597,7 +597,8 @@ namespace MoonWorks.Math
|
||||||
ref Plane b,
|
ref Plane b,
|
||||||
ref Plane c,
|
ref Plane c,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
/* Formula used
|
/* Formula used
|
||||||
* d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 )
|
* d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 )
|
||||||
* P = -------------------------------------------------------------------
|
* P = -------------------------------------------------------------------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -474,7 +474,8 @@ namespace MoonWorks.Math
|
||||||
ref BoundingSphere original,
|
ref BoundingSphere original,
|
||||||
ref BoundingSphere additional,
|
ref BoundingSphere additional,
|
||||||
out BoundingSphere result
|
out BoundingSphere result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Vector3 ocenterToaCenter = Vector3.Subtract(additional.Center, original.Center);
|
Vector3 ocenterToaCenter = Vector3.Subtract(additional.Center, original.Center);
|
||||||
float distance = ocenterToaCenter.Length();
|
float distance = ocenterToaCenter.Length();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -98,7 +98,8 @@ namespace MoonWorks.Math
|
||||||
float value3,
|
float value3,
|
||||||
float amount1,
|
float amount1,
|
||||||
float amount2
|
float amount2
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2;
|
return value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +118,8 @@ namespace MoonWorks.Math
|
||||||
float value3,
|
float value3,
|
||||||
float value4,
|
float value4,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
/* Using formula from http://www.mvps.org/directx/articles/catmull/
|
/* Using formula from http://www.mvps.org/directx/articles/catmull/
|
||||||
* Internally using doubles not to lose precision.
|
* Internally using doubles not to lose precision.
|
||||||
*/
|
*/
|
||||||
|
@ -184,7 +186,8 @@ namespace MoonWorks.Math
|
||||||
float value2,
|
float value2,
|
||||||
float tangent2,
|
float tangent2,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
/* All transformed to double not to lose precision
|
/* All transformed to double not to lose precision
|
||||||
* Otherwise, for high numbers of param:amount the result is NaN instead
|
* Otherwise, for high numbers of param:amount the result is NaN instead
|
||||||
* of Infinity.
|
* of Infinity.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -316,7 +316,8 @@ namespace MoonWorks.Math
|
||||||
float m21, float m22, float m23, float m24,
|
float m21, float m22, float m23, float m24,
|
||||||
float m31, float m32, float m33, float m34,
|
float m31, float m32, float m33, float m34,
|
||||||
float m41, float m42, float m43, float m44
|
float m41, float m42, float m43, float m44
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
M11 = m11;
|
M11 = m11;
|
||||||
M12 = m12;
|
M12 = m12;
|
||||||
M13 = m13;
|
M13 = m13;
|
||||||
|
@ -350,7 +351,8 @@ namespace MoonWorks.Math
|
||||||
out Vector3 scale,
|
out Vector3 scale,
|
||||||
out Quaternion rotation,
|
out Quaternion rotation,
|
||||||
out Vector3 translation
|
out Vector3 translation
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
translation.X = M41;
|
translation.X = M41;
|
||||||
translation.Y = M42;
|
translation.Y = M42;
|
||||||
translation.Z = M43;
|
translation.Z = M43;
|
||||||
|
@ -555,7 +557,8 @@ namespace MoonWorks.Math
|
||||||
Vector3 cameraPosition,
|
Vector3 cameraPosition,
|
||||||
Vector3 cameraUpVector,
|
Vector3 cameraUpVector,
|
||||||
Nullable<Vector3> cameraForwardVector
|
Nullable<Vector3> cameraForwardVector
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 result;
|
Matrix4x4 result;
|
||||||
|
|
||||||
// Delegate to the other overload of the function to do the work
|
// Delegate to the other overload of the function to do the work
|
||||||
|
@ -584,7 +587,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 cameraUpVector,
|
ref Vector3 cameraUpVector,
|
||||||
Vector3? cameraForwardVector,
|
Vector3? cameraForwardVector,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Vector3 vector;
|
Vector3 vector;
|
||||||
Vector3 vector2;
|
Vector3 vector2;
|
||||||
Vector3 vector3;
|
Vector3 vector3;
|
||||||
|
@ -642,7 +646,8 @@ namespace MoonWorks.Math
|
||||||
Vector3 rotateAxis,
|
Vector3 rotateAxis,
|
||||||
Nullable<Vector3> cameraForwardVector,
|
Nullable<Vector3> cameraForwardVector,
|
||||||
Nullable<Vector3> objectForwardVector
|
Nullable<Vector3> objectForwardVector
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 result;
|
Matrix4x4 result;
|
||||||
CreateConstrainedBillboard(
|
CreateConstrainedBillboard(
|
||||||
ref objectPosition,
|
ref objectPosition,
|
||||||
|
@ -671,7 +676,8 @@ namespace MoonWorks.Math
|
||||||
Vector3? cameraForwardVector,
|
Vector3? cameraForwardVector,
|
||||||
Vector3? objectForwardVector,
|
Vector3? objectForwardVector,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float num;
|
float num;
|
||||||
Vector3 vector;
|
Vector3 vector;
|
||||||
Vector3 vector2;
|
Vector3 vector2;
|
||||||
|
@ -777,7 +783,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 axis,
|
ref Vector3 axis,
|
||||||
float angle,
|
float angle,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = axis.X;
|
float x = axis.X;
|
||||||
float y = axis.Y;
|
float y = axis.Y;
|
||||||
float z = axis.Z;
|
float z = axis.Z;
|
||||||
|
@ -883,7 +890,8 @@ namespace MoonWorks.Math
|
||||||
float pitch,
|
float pitch,
|
||||||
float roll,
|
float roll,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Quaternion quaternion;
|
Quaternion quaternion;
|
||||||
Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll, out quaternion);
|
Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll, out quaternion);
|
||||||
CreateFromQuaternion(ref quaternion, out result);
|
CreateFromQuaternion(ref quaternion, out result);
|
||||||
|
@ -900,7 +908,8 @@ namespace MoonWorks.Math
|
||||||
Vector3 cameraPosition,
|
Vector3 cameraPosition,
|
||||||
Vector3 cameraTarget,
|
Vector3 cameraTarget,
|
||||||
Vector3 cameraUpVector
|
Vector3 cameraUpVector
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 matrix;
|
Matrix4x4 matrix;
|
||||||
CreateLookAt(ref cameraPosition, ref cameraTarget, ref cameraUpVector, out matrix);
|
CreateLookAt(ref cameraPosition, ref cameraTarget, ref cameraUpVector, out matrix);
|
||||||
return matrix;
|
return matrix;
|
||||||
|
@ -918,7 +927,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 cameraTarget,
|
ref Vector3 cameraTarget,
|
||||||
ref Vector3 cameraUpVector,
|
ref Vector3 cameraUpVector,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Vector3 vectorA = Vector3.Normalize(cameraPosition - cameraTarget);
|
Vector3 vectorA = Vector3.Normalize(cameraPosition - cameraTarget);
|
||||||
Vector3 vectorB = Vector3.Normalize(Vector3.Cross(cameraUpVector, vectorA));
|
Vector3 vectorB = Vector3.Normalize(Vector3.Cross(cameraUpVector, vectorA));
|
||||||
Vector3 vectorC = Vector3.Cross(vectorA, vectorB);
|
Vector3 vectorC = Vector3.Cross(vectorA, vectorB);
|
||||||
|
@ -953,7 +963,8 @@ namespace MoonWorks.Math
|
||||||
float height,
|
float height,
|
||||||
float zNearPlane,
|
float zNearPlane,
|
||||||
float zFarPlane
|
float zFarPlane
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 matrix;
|
Matrix4x4 matrix;
|
||||||
CreateOrthographic(width, height, zNearPlane, zFarPlane, out matrix);
|
CreateOrthographic(width, height, zNearPlane, zFarPlane, out matrix);
|
||||||
return matrix;
|
return matrix;
|
||||||
|
@ -973,7 +984,8 @@ namespace MoonWorks.Math
|
||||||
float zNearPlane,
|
float zNearPlane,
|
||||||
float zFarPlane,
|
float zFarPlane,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.M11 = 2f / width;
|
result.M11 = 2f / width;
|
||||||
result.M12 = result.M13 = result.M14 = 0f;
|
result.M12 = result.M13 = result.M14 = 0f;
|
||||||
result.M22 = 2f / height;
|
result.M22 = 2f / height;
|
||||||
|
@ -1002,7 +1014,8 @@ namespace MoonWorks.Math
|
||||||
float top,
|
float top,
|
||||||
float zNearPlane,
|
float zNearPlane,
|
||||||
float zFarPlane
|
float zFarPlane
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 matrix;
|
Matrix4x4 matrix;
|
||||||
CreateOrthographicOffCenter(
|
CreateOrthographicOffCenter(
|
||||||
left,
|
left,
|
||||||
|
@ -1034,7 +1047,8 @@ namespace MoonWorks.Math
|
||||||
float zNearPlane,
|
float zNearPlane,
|
||||||
float zFarPlane,
|
float zFarPlane,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.M11 = (float) (2.0 / ((double) right - (double) left));
|
result.M11 = (float) (2.0 / ((double) right - (double) left));
|
||||||
result.M12 = 0.0f;
|
result.M12 = 0.0f;
|
||||||
result.M13 = 0.0f;
|
result.M13 = 0.0f;
|
||||||
|
@ -1075,7 +1089,8 @@ namespace MoonWorks.Math
|
||||||
float height,
|
float height,
|
||||||
float nearPlaneDistance,
|
float nearPlaneDistance,
|
||||||
float farPlaneDistance
|
float farPlaneDistance
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 matrix;
|
Matrix4x4 matrix;
|
||||||
CreatePerspective(width, height, nearPlaneDistance, farPlaneDistance, out matrix);
|
CreatePerspective(width, height, nearPlaneDistance, farPlaneDistance, out matrix);
|
||||||
return matrix;
|
return matrix;
|
||||||
|
@ -1095,7 +1110,8 @@ namespace MoonWorks.Math
|
||||||
float nearPlaneDistance,
|
float nearPlaneDistance,
|
||||||
float farPlaneDistance,
|
float farPlaneDistance,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (nearPlaneDistance <= 0f)
|
if (nearPlaneDistance <= 0f)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("nearPlaneDistance <= 0");
|
throw new ArgumentException("nearPlaneDistance <= 0");
|
||||||
|
@ -1135,7 +1151,8 @@ namespace MoonWorks.Math
|
||||||
float aspectRatio,
|
float aspectRatio,
|
||||||
float nearPlaneDistance,
|
float nearPlaneDistance,
|
||||||
float farPlaneDistance
|
float farPlaneDistance
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 result;
|
Matrix4x4 result;
|
||||||
CreatePerspectiveFieldOfView(
|
CreatePerspectiveFieldOfView(
|
||||||
fieldOfView,
|
fieldOfView,
|
||||||
|
@ -1161,7 +1178,8 @@ namespace MoonWorks.Math
|
||||||
float nearPlaneDistance,
|
float nearPlaneDistance,
|
||||||
float farPlaneDistance,
|
float farPlaneDistance,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if ((fieldOfView <= 0f) || (fieldOfView >= 3.141593f))
|
if ((fieldOfView <= 0f) || (fieldOfView >= 3.141593f))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("fieldOfView <= 0 or >= PI");
|
throw new ArgumentException("fieldOfView <= 0 or >= PI");
|
||||||
|
@ -1210,7 +1228,8 @@ namespace MoonWorks.Math
|
||||||
float top,
|
float top,
|
||||||
float nearPlaneDistance,
|
float nearPlaneDistance,
|
||||||
float farPlaneDistance
|
float farPlaneDistance
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 result;
|
Matrix4x4 result;
|
||||||
CreatePerspectiveOffCenter(
|
CreatePerspectiveOffCenter(
|
||||||
left,
|
left,
|
||||||
|
@ -1242,7 +1261,8 @@ namespace MoonWorks.Math
|
||||||
float nearPlaneDistance,
|
float nearPlaneDistance,
|
||||||
float farPlaneDistance,
|
float farPlaneDistance,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (nearPlaneDistance <= 0f)
|
if (nearPlaneDistance <= 0f)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("nearPlaneDistance <= 0");
|
throw new ArgumentException("nearPlaneDistance <= 0");
|
||||||
|
@ -1408,7 +1428,8 @@ namespace MoonWorks.Math
|
||||||
float yScale,
|
float yScale,
|
||||||
float zScale,
|
float zScale,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.M11 = xScale;
|
result.M11 = xScale;
|
||||||
result.M12 = 0;
|
result.M12 = 0;
|
||||||
result.M13 = 0;
|
result.M13 = 0;
|
||||||
|
@ -1527,7 +1548,8 @@ namespace MoonWorks.Math
|
||||||
float xPosition,
|
float xPosition,
|
||||||
float yPosition,
|
float yPosition,
|
||||||
float zPosition
|
float zPosition
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 result;
|
Matrix4x4 result;
|
||||||
CreateTranslation(xPosition, yPosition, zPosition, out result);
|
CreateTranslation(xPosition, yPosition, zPosition, out result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -1582,7 +1604,8 @@ namespace MoonWorks.Math
|
||||||
float yPosition,
|
float yPosition,
|
||||||
float zPosition,
|
float zPosition,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.M11 = 1;
|
result.M11 = 1;
|
||||||
result.M12 = 0;
|
result.M12 = 0;
|
||||||
result.M13 = 0;
|
result.M13 = 0;
|
||||||
|
@ -1672,7 +1695,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 forward,
|
ref Vector3 forward,
|
||||||
ref Vector3 up,
|
ref Vector3 up,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Vector3 x, y, z;
|
Vector3 x, y, z;
|
||||||
Vector3.Normalize(ref forward, out z);
|
Vector3.Normalize(ref forward, out z);
|
||||||
Vector3.Cross(ref forward, ref up, out x);
|
Vector3.Cross(ref forward, ref up, out x);
|
||||||
|
@ -2069,7 +2093,8 @@ namespace MoonWorks.Math
|
||||||
ref Matrix4x4 matrix2,
|
ref Matrix4x4 matrix2,
|
||||||
float amount,
|
float amount,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.M11 = matrix1.M11 + ((matrix2.M11 - matrix1.M11) * amount);
|
result.M11 = matrix1.M11 + ((matrix2.M11 - matrix1.M11) * amount);
|
||||||
result.M12 = matrix1.M12 + ((matrix2.M12 - matrix1.M12) * amount);
|
result.M12 = matrix1.M12 + ((matrix2.M12 - matrix1.M12) * amount);
|
||||||
result.M13 = matrix1.M13 + ((matrix2.M13 - matrix1.M13) * amount);
|
result.M13 = matrix1.M13 + ((matrix2.M13 - matrix1.M13) * amount);
|
||||||
|
@ -2097,7 +2122,8 @@ namespace MoonWorks.Math
|
||||||
public static Matrix4x4 Multiply(
|
public static Matrix4x4 Multiply(
|
||||||
Matrix4x4 matrix1,
|
Matrix4x4 matrix1,
|
||||||
Matrix4x4 matrix2
|
Matrix4x4 matrix2
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float m11 = (
|
float m11 = (
|
||||||
(matrix1.M11 * matrix2.M11) +
|
(matrix1.M11 * matrix2.M11) +
|
||||||
(matrix1.M12 * matrix2.M21) +
|
(matrix1.M12 * matrix2.M21) +
|
||||||
|
@ -2548,7 +2574,8 @@ namespace MoonWorks.Math
|
||||||
ref Matrix4x4 value,
|
ref Matrix4x4 value,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
out Matrix4x4 result
|
out Matrix4x4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Matrix4x4 rotMatrix = CreateFromQuaternion(rotation);
|
Matrix4x4 rotMatrix = CreateFromQuaternion(rotation);
|
||||||
Multiply(ref value, ref rotMatrix, out result);
|
Multiply(ref value, ref rotMatrix, out result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -233,7 +233,8 @@ namespace MoonWorks.Math
|
||||||
ref Plane plane,
|
ref Plane plane,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
out Plane result
|
out Plane result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
/* See "Transforming Normals" in
|
/* See "Transforming Normals" in
|
||||||
* http://www.glprogramming.com/red/appendixf.html
|
* http://www.glprogramming.com/red/appendixf.html
|
||||||
* for an explanation of how this works.
|
* for an explanation of how this works.
|
||||||
|
@ -277,7 +278,8 @@ namespace MoonWorks.Math
|
||||||
ref Plane plane,
|
ref Plane plane,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
out Plane result
|
out Plane result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Vector3.Transform(
|
Vector3.Transform(
|
||||||
ref plane.Normal,
|
ref plane.Normal,
|
||||||
ref rotation,
|
ref rotation,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -266,7 +266,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion1,
|
ref Quaternion quaternion1,
|
||||||
ref Quaternion quaternion2,
|
ref Quaternion quaternion2,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = quaternion1.X + quaternion2.X;
|
result.X = quaternion1.X + quaternion2.X;
|
||||||
result.Y = quaternion1.Y + quaternion2.Y;
|
result.Y = quaternion1.Y + quaternion2.Y;
|
||||||
result.Z = quaternion1.Z + quaternion2.Z;
|
result.Z = quaternion1.Z + quaternion2.Z;
|
||||||
|
@ -296,7 +297,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion value1,
|
ref Quaternion value1,
|
||||||
ref Quaternion value2,
|
ref Quaternion value2,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x1 = value1.X;
|
float x1 = value1.X;
|
||||||
float y1 = value1.Y;
|
float y1 = value1.Y;
|
||||||
float z1 = value1.Z;
|
float z1 = value1.Z;
|
||||||
|
@ -359,7 +361,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 axis,
|
ref Vector3 axis,
|
||||||
float angle,
|
float angle,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float half = angle * 0.5f;
|
float half = angle * 0.5f;
|
||||||
float sin = (float) System.Math.Sin((double) half);
|
float sin = (float) System.Math.Sin((double) half);
|
||||||
float cos = (float) System.Math.Cos((double) half);
|
float cos = (float) System.Math.Cos((double) half);
|
||||||
|
@ -499,7 +502,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion1,
|
ref Quaternion quaternion1,
|
||||||
ref Quaternion quaternion2,
|
ref Quaternion quaternion2,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = quaternion1.X;
|
float x = quaternion1.X;
|
||||||
float y = quaternion1.Y;
|
float y = quaternion1.Y;
|
||||||
float z = quaternion1.Z;
|
float z = quaternion1.Z;
|
||||||
|
@ -551,7 +555,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion1,
|
ref Quaternion quaternion1,
|
||||||
ref Quaternion quaternion2,
|
ref Quaternion quaternion2,
|
||||||
out float result
|
out float result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result = (
|
result = (
|
||||||
(quaternion1.X * quaternion2.X) +
|
(quaternion1.X * quaternion2.X) +
|
||||||
(quaternion1.Y * quaternion2.Y) +
|
(quaternion1.Y * quaternion2.Y) +
|
||||||
|
@ -603,7 +608,8 @@ namespace MoonWorks.Math
|
||||||
Quaternion quaternion1,
|
Quaternion quaternion1,
|
||||||
Quaternion quaternion2,
|
Quaternion quaternion2,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Quaternion quaternion;
|
Quaternion quaternion;
|
||||||
Lerp(ref quaternion1, ref quaternion2, amount, out quaternion);
|
Lerp(ref quaternion1, ref quaternion2, amount, out quaternion);
|
||||||
return quaternion;
|
return quaternion;
|
||||||
|
@ -621,7 +627,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion2,
|
ref Quaternion quaternion2,
|
||||||
float amount,
|
float amount,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float num = amount;
|
float num = amount;
|
||||||
float num2 = 1f - num;
|
float num2 = 1f - num;
|
||||||
float num5 = (
|
float num5 = (
|
||||||
|
@ -668,7 +675,8 @@ namespace MoonWorks.Math
|
||||||
Quaternion quaternion1,
|
Quaternion quaternion1,
|
||||||
Quaternion quaternion2,
|
Quaternion quaternion2,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Quaternion quaternion;
|
Quaternion quaternion;
|
||||||
Slerp(ref quaternion1, ref quaternion2, amount, out quaternion);
|
Slerp(ref quaternion1, ref quaternion2, amount, out quaternion);
|
||||||
return quaternion;
|
return quaternion;
|
||||||
|
@ -686,7 +694,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion2,
|
ref Quaternion quaternion2,
|
||||||
float amount,
|
float amount,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float num2;
|
float num2;
|
||||||
float num3;
|
float num3;
|
||||||
float num = amount;
|
float num = amount;
|
||||||
|
@ -743,7 +752,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion1,
|
ref Quaternion quaternion1,
|
||||||
ref Quaternion quaternion2,
|
ref Quaternion quaternion2,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = quaternion1.X - quaternion2.X;
|
result.X = quaternion1.X - quaternion2.X;
|
||||||
result.Y = quaternion1.Y - quaternion2.Y;
|
result.Y = quaternion1.Y - quaternion2.Y;
|
||||||
result.Z = quaternion1.Z - quaternion2.Z;
|
result.Z = quaternion1.Z - quaternion2.Z;
|
||||||
|
@ -786,7 +796,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion1,
|
ref Quaternion quaternion1,
|
||||||
ref Quaternion quaternion2,
|
ref Quaternion quaternion2,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = quaternion1.X;
|
float x = quaternion1.X;
|
||||||
float y = quaternion1.Y;
|
float y = quaternion1.Y;
|
||||||
float z = quaternion1.Z;
|
float z = quaternion1.Z;
|
||||||
|
@ -815,7 +826,8 @@ namespace MoonWorks.Math
|
||||||
ref Quaternion quaternion1,
|
ref Quaternion quaternion1,
|
||||||
float scaleFactor,
|
float scaleFactor,
|
||||||
out Quaternion result
|
out Quaternion result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = quaternion1.X * scaleFactor;
|
result.X = quaternion1.X * scaleFactor;
|
||||||
result.Y = quaternion1.Y * scaleFactor;
|
result.Y = quaternion1.Y * scaleFactor;
|
||||||
result.Z = quaternion1.Z * scaleFactor;
|
result.Z = quaternion1.Z * scaleFactor;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -396,7 +396,8 @@ namespace MoonWorks.Math
|
||||||
ref Rectangle value1,
|
ref Rectangle value1,
|
||||||
ref Rectangle value2,
|
ref Rectangle value2,
|
||||||
out Rectangle result
|
out Rectangle result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (value1.Intersects(value2))
|
if (value1.Intersects(value2))
|
||||||
{
|
{
|
||||||
int right_side = System.Math.Min(
|
int right_side = System.Math.Min(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -264,7 +264,8 @@ namespace MoonWorks.Math
|
||||||
Vector2 value3,
|
Vector2 value3,
|
||||||
float amount1,
|
float amount1,
|
||||||
float amount2
|
float amount2
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return new Vector2(
|
return new Vector2(
|
||||||
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
|
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
|
||||||
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2)
|
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2)
|
||||||
|
@ -287,7 +288,8 @@ namespace MoonWorks.Math
|
||||||
float amount1,
|
float amount1,
|
||||||
float amount2,
|
float amount2,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2);
|
result.X = MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2);
|
||||||
result.Y = MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
result.Y = MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
||||||
}
|
}
|
||||||
|
@ -307,7 +309,8 @@ namespace MoonWorks.Math
|
||||||
Vector2 value3,
|
Vector2 value3,
|
||||||
Vector2 value4,
|
Vector2 value4,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return new Vector2(
|
return new Vector2(
|
||||||
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
|
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
|
||||||
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount)
|
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount)
|
||||||
|
@ -330,7 +333,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 value4,
|
ref Vector2 value4,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount);
|
result.X = MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount);
|
||||||
result.Y = MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount);
|
result.Y = MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +366,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 min,
|
ref Vector2 min,
|
||||||
ref Vector2 max,
|
ref Vector2 max,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
|
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
|
||||||
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
|
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
|
||||||
}
|
}
|
||||||
|
@ -413,7 +418,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 value1,
|
ref Vector2 value1,
|
||||||
ref Vector2 value2,
|
ref Vector2 value2,
|
||||||
out float result
|
out float result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float v1 = value1.X - value2.X, v2 = value1.Y - value2.Y;
|
float v1 = value1.X - value2.X, v2 = value1.Y - value2.Y;
|
||||||
result = (v1 * v1) + (v2 * v2);
|
result = (v1 * v1) + (v2 * v2);
|
||||||
}
|
}
|
||||||
|
@ -507,7 +513,8 @@ namespace MoonWorks.Math
|
||||||
Vector2 value2,
|
Vector2 value2,
|
||||||
Vector2 tangent2,
|
Vector2 tangent2,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Vector2 result = new Vector2();
|
Vector2 result = new Vector2();
|
||||||
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
|
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -529,7 +536,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 tangent2,
|
ref Vector2 tangent2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
||||||
result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
||||||
}
|
}
|
||||||
|
@ -561,7 +569,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 value2,
|
ref Vector2 value2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
|
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
|
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
|
||||||
}
|
}
|
||||||
|
@ -773,7 +782,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 value2,
|
ref Vector2 value2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
|
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
|
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
|
||||||
}
|
}
|
||||||
|
@ -827,7 +837,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 position,
|
ref Vector2 position,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = (position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M41;
|
float x = (position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M41;
|
||||||
float y = (position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M42;
|
float y = (position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M42;
|
||||||
result.X = x;
|
result.X = x;
|
||||||
|
@ -856,7 +867,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 value,
|
ref Vector2 value,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = 2 * -(rotation.Z * value.Y);
|
float x = 2 * -(rotation.Z * value.Y);
|
||||||
float y = 2 * (rotation.Z * value.X);
|
float y = 2 * (rotation.Z * value.X);
|
||||||
float z = 2 * (rotation.X * value.Y - rotation.Y * value.X);
|
float z = 2 * (rotation.X * value.Y - rotation.Y * value.X);
|
||||||
|
@ -875,7 +887,8 @@ namespace MoonWorks.Math
|
||||||
Vector2[] sourceArray,
|
Vector2[] sourceArray,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
Vector2[] destinationArray
|
Vector2[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Transform(sourceArray, 0, ref matrix, destinationArray, 0, sourceArray.Length);
|
Transform(sourceArray, 0, ref matrix, destinationArray, 0, sourceArray.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -895,7 +908,8 @@ namespace MoonWorks.Math
|
||||||
Vector2[] destinationArray,
|
Vector2[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
for (int x = 0; x < length; x += 1)
|
for (int x = 0; x < length; x += 1)
|
||||||
{
|
{
|
||||||
Vector2 position = sourceArray[sourceIndex + x];
|
Vector2 position = sourceArray[sourceIndex + x];
|
||||||
|
@ -918,7 +932,8 @@ namespace MoonWorks.Math
|
||||||
Vector2[] sourceArray,
|
Vector2[] sourceArray,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
Vector2[] destinationArray
|
Vector2[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Transform(
|
Transform(
|
||||||
sourceArray,
|
sourceArray,
|
||||||
0,
|
0,
|
||||||
|
@ -945,7 +960,8 @@ namespace MoonWorks.Math
|
||||||
Vector2[] destinationArray,
|
Vector2[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
for (int i = 0; i < length; i += 1)
|
for (int i = 0; i < length; i += 1)
|
||||||
{
|
{
|
||||||
Vector2 position = sourceArray[sourceIndex + i];
|
Vector2 position = sourceArray[sourceIndex + i];
|
||||||
|
@ -979,7 +995,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 normal,
|
ref Vector2 normal,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
out Vector2 result
|
out Vector2 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = (normal.X * matrix.M11) + (normal.Y * matrix.M21);
|
float x = (normal.X * matrix.M11) + (normal.Y * matrix.M21);
|
||||||
float y = (normal.X * matrix.M12) + (normal.Y * matrix.M22);
|
float y = (normal.X * matrix.M12) + (normal.Y * matrix.M22);
|
||||||
result.X = x;
|
result.X = x;
|
||||||
|
@ -996,7 +1013,8 @@ namespace MoonWorks.Math
|
||||||
Vector2[] sourceArray,
|
Vector2[] sourceArray,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
Vector2[] destinationArray
|
Vector2[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
TransformNormal(
|
TransformNormal(
|
||||||
sourceArray,
|
sourceArray,
|
||||||
0,
|
0,
|
||||||
|
@ -1023,7 +1041,8 @@ namespace MoonWorks.Math
|
||||||
Vector2[] destinationArray,
|
Vector2[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
for (int i = 0; i < length; i += 1)
|
for (int i = 0; i < length; i += 1)
|
||||||
{
|
{
|
||||||
Vector2 position = sourceArray[sourceIndex + i];
|
Vector2 position = sourceArray[sourceIndex + i];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -383,7 +383,8 @@ namespace MoonWorks.Math
|
||||||
Vector3 value3,
|
Vector3 value3,
|
||||||
float amount1,
|
float amount1,
|
||||||
float amount2
|
float amount2
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return new Vector3(
|
return new Vector3(
|
||||||
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
|
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
|
||||||
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
|
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
|
||||||
|
@ -407,7 +408,8 @@ namespace MoonWorks.Math
|
||||||
float amount1,
|
float amount1,
|
||||||
float amount2,
|
float amount2,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2);
|
result.X = MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2);
|
||||||
result.Y = MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
result.Y = MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
||||||
result.Z = MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
|
result.Z = MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
|
||||||
|
@ -428,7 +430,8 @@ namespace MoonWorks.Math
|
||||||
Vector3 value3,
|
Vector3 value3,
|
||||||
Vector3 value4,
|
Vector3 value4,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return new Vector3(
|
return new Vector3(
|
||||||
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
|
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
|
||||||
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
|
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
|
||||||
|
@ -452,7 +455,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 value4,
|
ref Vector3 value4,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount);
|
result.X = MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount);
|
||||||
result.Y = MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount);
|
result.Y = MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount);
|
||||||
result.Z = MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount);
|
result.Z = MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount);
|
||||||
|
@ -486,7 +490,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 min,
|
ref Vector3 min,
|
||||||
ref Vector3 max,
|
ref Vector3 max,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
|
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
|
||||||
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
|
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
|
||||||
result.Z = MathHelper.Clamp(value1.Z, min.Z, max.Z);
|
result.Z = MathHelper.Clamp(value1.Z, min.Z, max.Z);
|
||||||
|
@ -501,7 +506,8 @@ namespace MoonWorks.Math
|
||||||
public static Vector3 ClampMagnitude(
|
public static Vector3 ClampMagnitude(
|
||||||
Vector3 value,
|
Vector3 value,
|
||||||
float maxLength
|
float maxLength
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return (value.LengthSquared() > maxLength * maxLength) ? (Vector3.Normalize(value) * maxLength) : value;
|
return (value.LengthSquared() > maxLength * maxLength) ? (Vector3.Normalize(value) * maxLength) : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +589,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 value1,
|
ref Vector3 value1,
|
||||||
ref Vector3 value2,
|
ref Vector3 value2,
|
||||||
out float result
|
out float result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result = (
|
result = (
|
||||||
(value1.X - value2.X) * (value1.X - value2.X) +
|
(value1.X - value2.X) * (value1.X - value2.X) +
|
||||||
(value1.Y - value2.Y) * (value1.Y - value2.Y) +
|
(value1.Y - value2.Y) * (value1.Y - value2.Y) +
|
||||||
|
@ -688,7 +695,8 @@ namespace MoonWorks.Math
|
||||||
Vector3 value2,
|
Vector3 value2,
|
||||||
Vector3 tangent2,
|
Vector3 tangent2,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Vector3 result = new Vector3();
|
Vector3 result = new Vector3();
|
||||||
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
|
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -710,7 +718,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 tangent2,
|
ref Vector3 tangent2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
||||||
result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
||||||
result.Z = MathHelper.Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount);
|
result.Z = MathHelper.Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount);
|
||||||
|
@ -744,7 +753,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 value2,
|
ref Vector3 value2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
|
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
|
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
|
||||||
result.Z = MathHelper.Lerp(value1.Z, value2.Z, amount);
|
result.Z = MathHelper.Lerp(value1.Z, value2.Z, amount);
|
||||||
|
@ -992,7 +1002,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 value2,
|
ref Vector3 value2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
|
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
|
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
|
||||||
result.Z = MathHelper.SmoothStep(value1.Z, value2.Z, amount);
|
result.Z = MathHelper.SmoothStep(value1.Z, value2.Z, amount);
|
||||||
|
@ -1047,7 +1058,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 position,
|
ref Vector3 position,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = (
|
float x = (
|
||||||
(position.X * matrix.M11) +
|
(position.X * matrix.M11) +
|
||||||
(position.Y * matrix.M21) +
|
(position.Y * matrix.M21) +
|
||||||
|
@ -1081,7 +1093,8 @@ namespace MoonWorks.Math
|
||||||
Vector3[] sourceArray,
|
Vector3[] sourceArray,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
Vector3[] destinationArray
|
Vector3[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Debug.Assert(
|
Debug.Assert(
|
||||||
destinationArray.Length >= sourceArray.Length,
|
destinationArray.Length >= sourceArray.Length,
|
||||||
"The destination array is smaller than the source array."
|
"The destination array is smaller than the source array."
|
||||||
|
@ -1121,7 +1134,8 @@ namespace MoonWorks.Math
|
||||||
Vector3[] destinationArray,
|
Vector3[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Debug.Assert(
|
Debug.Assert(
|
||||||
sourceArray.Length - sourceIndex >= length,
|
sourceArray.Length - sourceIndex >= length,
|
||||||
"The source array is too small for the given sourceIndex and length."
|
"The source array is too small for the given sourceIndex and length."
|
||||||
|
@ -1173,7 +1187,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 value,
|
ref Vector3 value,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = 2 * (rotation.Y * value.Z - rotation.Z * value.Y);
|
float x = 2 * (rotation.Y * value.Z - rotation.Z * value.Y);
|
||||||
float y = 2 * (rotation.Z * value.X - rotation.X * value.Z);
|
float y = 2 * (rotation.Z * value.X - rotation.X * value.Z);
|
||||||
float z = 2 * (rotation.X * value.Y - rotation.Y * value.X);
|
float z = 2 * (rotation.X * value.Y - rotation.Y * value.X);
|
||||||
|
@ -1193,7 +1208,8 @@ namespace MoonWorks.Math
|
||||||
Vector3[] sourceArray,
|
Vector3[] sourceArray,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
Vector3[] destinationArray
|
Vector3[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Debug.Assert(
|
Debug.Assert(
|
||||||
destinationArray.Length >= sourceArray.Length,
|
destinationArray.Length >= sourceArray.Length,
|
||||||
"The destination array is smaller than the source array."
|
"The destination array is smaller than the source array."
|
||||||
|
@ -1236,7 +1252,8 @@ namespace MoonWorks.Math
|
||||||
Vector3[] destinationArray,
|
Vector3[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Debug.Assert(
|
Debug.Assert(
|
||||||
sourceArray.Length - sourceIndex >= length,
|
sourceArray.Length - sourceIndex >= length,
|
||||||
"The source array is too small for the given sourceIndex and length."
|
"The source array is too small for the given sourceIndex and length."
|
||||||
|
@ -1289,7 +1306,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 normal,
|
ref Vector3 normal,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
out Vector3 result
|
out Vector3 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
float x = (normal.X * matrix.M11) + (normal.Y * matrix.M21) + (normal.Z * matrix.M31);
|
float x = (normal.X * matrix.M11) + (normal.Y * matrix.M21) + (normal.Z * matrix.M31);
|
||||||
float y = (normal.X * matrix.M12) + (normal.Y * matrix.M22) + (normal.Z * matrix.M32);
|
float y = (normal.X * matrix.M12) + (normal.Y * matrix.M22) + (normal.Z * matrix.M32);
|
||||||
float z = (normal.X * matrix.M13) + (normal.Y * matrix.M23) + (normal.Z * matrix.M33);
|
float z = (normal.X * matrix.M13) + (normal.Y * matrix.M23) + (normal.Z * matrix.M33);
|
||||||
|
@ -1308,7 +1326,8 @@ namespace MoonWorks.Math
|
||||||
Vector3[] sourceArray,
|
Vector3[] sourceArray,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
Vector3[] destinationArray
|
Vector3[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Debug.Assert(
|
Debug.Assert(
|
||||||
destinationArray.Length >= sourceArray.Length,
|
destinationArray.Length >= sourceArray.Length,
|
||||||
"The destination array is smaller than the source array."
|
"The destination array is smaller than the source array."
|
||||||
|
@ -1339,7 +1358,8 @@ namespace MoonWorks.Math
|
||||||
Vector3[] destinationArray,
|
Vector3[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (sourceArray == null)
|
if (sourceArray == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("sourceArray");
|
throw new ArgumentNullException("sourceArray");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -344,7 +344,8 @@ namespace MoonWorks.Math
|
||||||
Vector4 value3,
|
Vector4 value3,
|
||||||
float amount1,
|
float amount1,
|
||||||
float amount2
|
float amount2
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return new Vector4(
|
return new Vector4(
|
||||||
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
|
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
|
||||||
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
|
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
|
||||||
|
@ -369,7 +370,8 @@ namespace MoonWorks.Math
|
||||||
float amount1,
|
float amount1,
|
||||||
float amount2,
|
float amount2,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2);
|
result.X = MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2);
|
||||||
result.Y = MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
result.Y = MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
||||||
result.Z = MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
|
result.Z = MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
|
||||||
|
@ -391,7 +393,8 @@ namespace MoonWorks.Math
|
||||||
Vector4 value3,
|
Vector4 value3,
|
||||||
Vector4 value4,
|
Vector4 value4,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return new Vector4(
|
return new Vector4(
|
||||||
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
|
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
|
||||||
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
|
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
|
||||||
|
@ -416,7 +419,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 value4,
|
ref Vector4 value4,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount);
|
result.X = MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount);
|
||||||
result.Y = MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount);
|
result.Y = MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount);
|
||||||
result.Z = MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount);
|
result.Z = MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount);
|
||||||
|
@ -452,7 +456,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 min,
|
ref Vector4 min,
|
||||||
ref Vector4 max,
|
ref Vector4 max,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
|
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
|
||||||
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
|
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
|
||||||
result.Z = MathHelper.Clamp(value1.Z, min.Z, max.Z);
|
result.Z = MathHelper.Clamp(value1.Z, min.Z, max.Z);
|
||||||
|
@ -507,7 +512,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 value1,
|
ref Vector4 value1,
|
||||||
ref Vector4 value2,
|
ref Vector4 value2,
|
||||||
out float result
|
out float result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result = (
|
result = (
|
||||||
(value1.W - value2.W) * (value1.W - value2.W) +
|
(value1.W - value2.W) * (value1.W - value2.W) +
|
||||||
(value1.X - value2.X) * (value1.X - value2.X) +
|
(value1.X - value2.X) * (value1.X - value2.X) +
|
||||||
|
@ -572,7 +578,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 value1,
|
ref Vector4 value1,
|
||||||
ref Vector4 value2,
|
ref Vector4 value2,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.W = value1.W / value2.W;
|
result.W = value1.W / value2.W;
|
||||||
result.X = value1.X / value2.X;
|
result.X = value1.X / value2.X;
|
||||||
result.Y = value1.Y / value2.Y;
|
result.Y = value1.Y / value2.Y;
|
||||||
|
@ -626,7 +633,8 @@ namespace MoonWorks.Math
|
||||||
Vector4 value2,
|
Vector4 value2,
|
||||||
Vector4 tangent2,
|
Vector4 tangent2,
|
||||||
float amount
|
float amount
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return new Vector4(
|
return new Vector4(
|
||||||
MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount),
|
MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount),
|
||||||
MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount),
|
MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount),
|
||||||
|
@ -651,7 +659,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 tangent2,
|
ref Vector4 tangent2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.W = MathHelper.Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount);
|
result.W = MathHelper.Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount);
|
||||||
result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
||||||
result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
||||||
|
@ -687,7 +696,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 value2,
|
ref Vector4 value2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
|
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
|
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
|
||||||
result.Z = MathHelper.Lerp(value1.Z, value2.Z, amount);
|
result.Z = MathHelper.Lerp(value1.Z, value2.Z, amount);
|
||||||
|
@ -905,7 +915,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 value2,
|
ref Vector4 value2,
|
||||||
float amount,
|
float amount,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
|
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
|
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
|
||||||
result.Z = MathHelper.SmoothStep(value1.Z, value2.Z, amount);
|
result.Z = MathHelper.SmoothStep(value1.Z, value2.Z, amount);
|
||||||
|
@ -1081,7 +1092,8 @@ namespace MoonWorks.Math
|
||||||
Vector4[] sourceArray,
|
Vector4[] sourceArray,
|
||||||
ref Matrix4x4 matrix,
|
ref Matrix4x4 matrix,
|
||||||
Vector4[] destinationArray
|
Vector4[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (sourceArray == null)
|
if (sourceArray == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("sourceArray");
|
throw new ArgumentNullException("sourceArray");
|
||||||
|
@ -1122,7 +1134,8 @@ namespace MoonWorks.Math
|
||||||
Vector4[] destinationArray,
|
Vector4[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (sourceArray == null)
|
if (sourceArray == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("sourceArray");
|
throw new ArgumentNullException("sourceArray");
|
||||||
|
@ -1202,7 +1215,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector2 value,
|
ref Vector2 value,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
double xx = rotation.X + rotation.X;
|
double xx = rotation.X + rotation.X;
|
||||||
double yy = rotation.Y + rotation.Y;
|
double yy = rotation.Y + rotation.Y;
|
||||||
double zz = rotation.Z + rotation.Z;
|
double zz = rotation.Z + rotation.Z;
|
||||||
|
@ -1240,7 +1254,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector3 value,
|
ref Vector3 value,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
double xx = rotation.X + rotation.X;
|
double xx = rotation.X + rotation.X;
|
||||||
double yy = rotation.Y + rotation.Y;
|
double yy = rotation.Y + rotation.Y;
|
||||||
double zz = rotation.Z + rotation.Z;
|
double zz = rotation.Z + rotation.Z;
|
||||||
|
@ -1281,7 +1296,8 @@ namespace MoonWorks.Math
|
||||||
ref Vector4 value,
|
ref Vector4 value,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
out Vector4 result
|
out Vector4 result
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
double xx = rotation.X + rotation.X;
|
double xx = rotation.X + rotation.X;
|
||||||
double yy = rotation.Y + rotation.Y;
|
double yy = rotation.Y + rotation.Y;
|
||||||
double zz = rotation.Z + rotation.Z;
|
double zz = rotation.Z + rotation.Z;
|
||||||
|
@ -1322,7 +1338,8 @@ namespace MoonWorks.Math
|
||||||
Vector4[] sourceArray,
|
Vector4[] sourceArray,
|
||||||
ref Quaternion rotation,
|
ref Quaternion rotation,
|
||||||
Vector4[] destinationArray
|
Vector4[] destinationArray
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (sourceArray == null)
|
if (sourceArray == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("sourceArray");
|
throw new ArgumentException("sourceArray");
|
||||||
|
@ -1363,7 +1380,8 @@ namespace MoonWorks.Math
|
||||||
Vector4[] destinationArray,
|
Vector4[] destinationArray,
|
||||||
int destinationIndex,
|
int destinationIndex,
|
||||||
int length
|
int length
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (sourceArray == null)
|
if (sourceArray == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("sourceArray");
|
throw new ArgumentException("sourceArray");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -67,7 +67,8 @@ namespace MoonWorks
|
||||||
string libraryName,
|
string libraryName,
|
||||||
Assembly assembly,
|
Assembly assembly,
|
||||||
DllImportSearchPath? dllImportSearchPath
|
DllImportSearchPath? dllImportSearchPath
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
string mappedName;
|
string mappedName;
|
||||||
if (!mapDictionary.TryGetValue(libraryName, out mappedName))
|
if (!mapDictionary.TryGetValue(libraryName, out mappedName))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using SDL2;
|
using SDL2;
|
||||||
|
|
||||||
namespace MoonWorks.Window
|
namespace MoonWorks.Window
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Window
|
namespace MoonWorks.Window
|
||||||
{
|
{
|
||||||
public enum ScreenMode
|
public enum ScreenMode
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MoonWorks.Window
|
namespace MoonWorks.Window
|
||||||
{
|
{
|
||||||
public struct WindowCreateInfo
|
public struct WindowCreateInfo
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue