forked from MoonsideGames/MoonWorks
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;
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ namespace MoonWorks.Audio
|
||||||
bool loop
|
bool loop
|
||||||
) : base(device)
|
) : base(device)
|
||||||
{
|
{
|
||||||
var blockAlign = (ushort)(4 * channels);
|
var blockAlign = (ushort) (4 * channels);
|
||||||
var format = new FAudio.FAudioWaveFormatEx
|
var format = new FAudio.FAudioWaveFormatEx
|
||||||
{
|
{
|
||||||
wFormatTag = 3,
|
wFormatTag = 3,
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ namespace MoonWorks.Audio
|
||||||
PlayLength = (
|
PlayLength = (
|
||||||
lengthInBytes /
|
lengthInBytes /
|
||||||
Format.nChannels /
|
Format.nChannels /
|
||||||
(uint)(Format.wBitsPerSample / 8)
|
(uint) (Format.wBitsPerSample / 8)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
@ -259,7 +260,7 @@ namespace MoonWorks
|
||||||
private unsafe static int MeasureStringLength(byte* ptr)
|
private unsafe static int MeasureStringLength(byte* ptr)
|
||||||
{
|
{
|
||||||
int bytes;
|
int bytes;
|
||||||
for (bytes = 0; *ptr != 0; ptr += 1, bytes += 1);
|
for (bytes = 0; *ptr != 0; ptr += 1, bytes += 1) ;
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -41,7 +41,7 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
return (byte)(this.packedValue);
|
return (byte) (this.packedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
@ -59,12 +59,12 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
return (byte)(this.packedValue >> 8);
|
return (byte) (this.packedValue >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.packedValue = (this.packedValue & 0xffff00ff) | ((uint)value << 8);
|
this.packedValue = (this.packedValue & 0xffff00ff) | ((uint) value << 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1538,27 +1538,27 @@ namespace MoonWorks.Graphics
|
||||||
RosyBrown = new Color(0xff8f8fbc);
|
RosyBrown = new Color(0xff8f8fbc);
|
||||||
RoyalBlue = new Color(0xffe16941);
|
RoyalBlue = new Color(0xffe16941);
|
||||||
SaddleBrown = new Color(0xff13458b);
|
SaddleBrown = new Color(0xff13458b);
|
||||||
Salmon= new Color(0xff7280fa);
|
Salmon = new Color(0xff7280fa);
|
||||||
SandyBrown = new Color(0xff60a4f4);
|
SandyBrown = new Color(0xff60a4f4);
|
||||||
SeaGreen = new Color(0xff578b2e);
|
SeaGreen = new Color(0xff578b2e);
|
||||||
SeaShell = new Color(0xffeef5ff);
|
SeaShell = new Color(0xffeef5ff);
|
||||||
Sienna = new Color(0xff2d52a0);
|
Sienna = new Color(0xff2d52a0);
|
||||||
Silver = new Color(0xffc0c0c0);
|
Silver = new Color(0xffc0c0c0);
|
||||||
SkyBlue = new Color(0xffebce87);
|
SkyBlue = new Color(0xffebce87);
|
||||||
SlateBlue= new Color(0xffcd5a6a);
|
SlateBlue = new Color(0xffcd5a6a);
|
||||||
SlateGray= new Color(0xff908070);
|
SlateGray = new Color(0xff908070);
|
||||||
Snow= new Color(0xfffafaff);
|
Snow = new Color(0xfffafaff);
|
||||||
SpringGreen= new Color(0xff7fff00);
|
SpringGreen = new Color(0xff7fff00);
|
||||||
SteelBlue= new Color(0xffb48246);
|
SteelBlue = new Color(0xffb48246);
|
||||||
Tan= new Color(0xff8cb4d2);
|
Tan = new Color(0xff8cb4d2);
|
||||||
Teal= new Color(0xff808000);
|
Teal = new Color(0xff808000);
|
||||||
Thistle= new Color(0xffd8bfd8);
|
Thistle = new Color(0xffd8bfd8);
|
||||||
Tomato= new Color(0xff4763ff);
|
Tomato = new Color(0xff4763ff);
|
||||||
Turquoise= new Color(0xffd0e040);
|
Turquoise = new Color(0xffd0e040);
|
||||||
Violet= new Color(0xffee82ee);
|
Violet = new Color(0xffee82ee);
|
||||||
Wheat= new Color(0xffb3def5);
|
Wheat = new Color(0xffb3def5);
|
||||||
White= new Color(uint.MaxValue);
|
White = new Color(uint.MaxValue);
|
||||||
WhiteSmoke= new Color(0xfff5f5f5);
|
WhiteSmoke = new Color(0xfff5f5f5);
|
||||||
Yellow = new Color(0xff00ffff);
|
Yellow = new Color(0xff00ffff);
|
||||||
YellowGreen = new Color(0xff32cd9a);
|
YellowGreen = new Color(0xff32cd9a);
|
||||||
}
|
}
|
||||||
|
@ -1623,7 +1623,7 @@ namespace MoonWorks.Graphics
|
||||||
R = (byte) MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue);
|
R = (byte) MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue);
|
||||||
G = (byte) MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue);
|
G = (byte) MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue);
|
||||||
B = (byte) MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue);
|
B = (byte) MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue);
|
||||||
A = (byte)255;
|
A = (byte) 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1769,10 +1769,10 @@ namespace MoonWorks.Graphics
|
||||||
/// <returns><c>True</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>True</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public static bool operator ==(Color a, Color b)
|
public static bool operator ==(Color a, Color b)
|
||||||
{
|
{
|
||||||
return ( a.A == b.A &&
|
return (a.A == b.A &&
|
||||||
a.R == b.R &&
|
a.R == b.R &&
|
||||||
a.G == b.G &&
|
a.G == b.G &&
|
||||||
a.B == b.B );
|
a.B == b.B);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -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++)
|
||||||
|
@ -86,7 +88,7 @@ namespace MoonWorks.Graphics
|
||||||
framebuffer.Handle,
|
framebuffer.Handle,
|
||||||
renderArea.ToRefresh(),
|
renderArea.ToRefresh(),
|
||||||
(IntPtr) colors,
|
(IntPtr) colors,
|
||||||
(uint)clearColors.Length,
|
(uint) clearColors.Length,
|
||||||
depthStencilClearValue.ToRefresh()
|
depthStencilClearValue.ToRefresh()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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++)
|
||||||
{
|
{
|
||||||
|
@ -482,7 +499,7 @@ namespace MoonWorks.Graphics
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
clearRect.ToRefresh(),
|
clearRect.ToRefresh(),
|
||||||
(Refresh.ClearOptionsFlags)clearOptions,
|
(Refresh.ClearOptionsFlags) clearOptions,
|
||||||
(IntPtr) colors,
|
(IntPtr) colors,
|
||||||
(uint) clearColors.Length,
|
(uint) clearColors.Length,
|
||||||
depthStencilClearValue.ToRefresh()
|
depthStencilClearValue.ToRefresh()
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -600,8 +621,8 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
w = (int)texture.Width,
|
w = (int) texture.Width,
|
||||||
h = (int)texture.Height
|
h = (int) texture.Height
|
||||||
},
|
},
|
||||||
layer = 0,
|
layer = 0,
|
||||||
level = 0,
|
level = 0,
|
||||||
|
@ -613,7 +634,7 @@ namespace MoonWorks.Graphics
|
||||||
Handle,
|
Handle,
|
||||||
refreshTextureSlice,
|
refreshTextureSlice,
|
||||||
refreshRect,
|
refreshRect,
|
||||||
(Refresh.Filter)filter,
|
(Refresh.Filter) filter,
|
||||||
window.Handle
|
window.Handle
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -104,7 +104,7 @@ namespace MoonWorks.Graphics
|
||||||
internal static float Convert(ushort value)
|
internal static float Convert(ushort value)
|
||||||
{
|
{
|
||||||
uint rst;
|
uint rst;
|
||||||
uint mantissa = (uint)(value & 1023);
|
uint mantissa = (uint) (value & 1023);
|
||||||
uint exp = 0xfffffff2;
|
uint exp = 0xfffffff2;
|
||||||
|
|
||||||
if ((value & -33792) == 0)
|
if ((value & -33792) == 0)
|
||||||
|
|
|
@ -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
|
||||||
|
@ -192,7 +192,7 @@ namespace MoonWorks.Graphics
|
||||||
static ulong Pack(float x, float y, float z, float w)
|
static ulong Pack(float x, float y, float z, float w)
|
||||||
{
|
{
|
||||||
return (ulong) (
|
return (ulong) (
|
||||||
((long) System.Math.Round(MathHelper.Clamp(x, -32768, 32767)) & 0xFFFF ) |
|
((long) System.Math.Round(MathHelper.Clamp(x, -32768, 32767)) & 0xFFFF) |
|
||||||
(((long) System.Math.Round(MathHelper.Clamp(y, -32768, 32767)) << 16) & 0xFFFF0000) |
|
(((long) System.Math.Round(MathHelper.Clamp(y, -32768, 32767)) << 16) & 0xFFFF0000) |
|
||||||
(((long) System.Math.Round(MathHelper.Clamp(z, -32768, 32767)) << 32) & 0xFFFF00000000) |
|
(((long) System.Math.Round(MathHelper.Clamp(z, -32768, 32767)) << 32) & 0xFFFF00000000) |
|
||||||
((long) System.Math.Round(MathHelper.Clamp(w, -32768, 32767)) << 48)
|
((long) System.Math.Round(MathHelper.Clamp(w, -32768, 32767)) << 48)
|
||||||
|
|
|
@ -107,10 +107,10 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
return new Refresh.StencilOpState
|
return new Refresh.StencilOpState
|
||||||
{
|
{
|
||||||
failOp = (Refresh.StencilOp)FailOp,
|
failOp = (Refresh.StencilOp) FailOp,
|
||||||
passOp = (Refresh.StencilOp)PassOp,
|
passOp = (Refresh.StencilOp) PassOp,
|
||||||
depthFailOp = (Refresh.StencilOp)DepthFailOp,
|
depthFailOp = (Refresh.StencilOp) DepthFailOp,
|
||||||
compareOp = (Refresh.CompareOp)CompareOp,
|
compareOp = (Refresh.CompareOp) CompareOp,
|
||||||
compareMask = CompareMask,
|
compareMask = CompareMask,
|
||||||
writeMask = WriteMask,
|
writeMask = WriteMask,
|
||||||
reference = Reference
|
reference = Reference
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using RefreshCS;
|
using RefreshCS;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace MoonWorks.Graphics
|
||||||
Refresh.Refresh_GetBufferData(
|
Refresh.Refresh_GetBufferData(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
(IntPtr)ptr,
|
(IntPtr) ptr,
|
||||||
dataLengthInBytes
|
dataLengthInBytes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -88,20 +88,20 @@ namespace MoonWorks.Graphics
|
||||||
refreshGraphicsPipelineCreateInfo.fragmentShaderState.shaderModule = fragmentShaderState.ShaderModule.Handle;
|
refreshGraphicsPipelineCreateInfo.fragmentShaderState.shaderModule = fragmentShaderState.ShaderModule.Handle;
|
||||||
refreshGraphicsPipelineCreateInfo.fragmentShaderState.uniformBufferSize = fragmentShaderState.UniformBufferSize;
|
refreshGraphicsPipelineCreateInfo.fragmentShaderState.uniformBufferSize = fragmentShaderState.UniformBufferSize;
|
||||||
|
|
||||||
refreshGraphicsPipelineCreateInfo.multisampleState.multisampleCount = (Refresh.SampleCount)multisampleState.MultisampleCount;
|
refreshGraphicsPipelineCreateInfo.multisampleState.multisampleCount = (Refresh.SampleCount) multisampleState.MultisampleCount;
|
||||||
refreshGraphicsPipelineCreateInfo.multisampleState.sampleMask = multisampleState.SampleMask;
|
refreshGraphicsPipelineCreateInfo.multisampleState.sampleMask = multisampleState.SampleMask;
|
||||||
|
|
||||||
refreshGraphicsPipelineCreateInfo.pipelineLayoutCreateInfo.vertexSamplerBindingCount = pipelineLayoutInfo.VertexSamplerBindingCount;
|
refreshGraphicsPipelineCreateInfo.pipelineLayoutCreateInfo.vertexSamplerBindingCount = pipelineLayoutInfo.VertexSamplerBindingCount;
|
||||||
refreshGraphicsPipelineCreateInfo.pipelineLayoutCreateInfo.fragmentSamplerBindingCount = pipelineLayoutInfo.FragmentSamplerBindingCount;
|
refreshGraphicsPipelineCreateInfo.pipelineLayoutCreateInfo.fragmentSamplerBindingCount = pipelineLayoutInfo.FragmentSamplerBindingCount;
|
||||||
|
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.cullMode = (Refresh.CullMode)rasterizerState.CullMode;
|
refreshGraphicsPipelineCreateInfo.rasterizerState.cullMode = (Refresh.CullMode) rasterizerState.CullMode;
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasClamp = rasterizerState.DepthBiasClamp;
|
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasClamp = rasterizerState.DepthBiasClamp;
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasConstantFactor = rasterizerState.DepthBiasConstantFactor;
|
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasConstantFactor = rasterizerState.DepthBiasConstantFactor;
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasEnable = Conversions.BoolToByte(rasterizerState.DepthBiasEnable);
|
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasEnable = Conversions.BoolToByte(rasterizerState.DepthBiasEnable);
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasSlopeFactor = rasterizerState.DepthBiasSlopeFactor;
|
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasSlopeFactor = rasterizerState.DepthBiasSlopeFactor;
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.depthClampEnable = Conversions.BoolToByte(rasterizerState.DepthClampEnable);
|
refreshGraphicsPipelineCreateInfo.rasterizerState.depthClampEnable = Conversions.BoolToByte(rasterizerState.DepthClampEnable);
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.fillMode = (Refresh.FillMode)rasterizerState.FillMode;
|
refreshGraphicsPipelineCreateInfo.rasterizerState.fillMode = (Refresh.FillMode) rasterizerState.FillMode;
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.frontFace = (Refresh.FrontFace)rasterizerState.FrontFace;
|
refreshGraphicsPipelineCreateInfo.rasterizerState.frontFace = (Refresh.FrontFace) rasterizerState.FrontFace;
|
||||||
refreshGraphicsPipelineCreateInfo.rasterizerState.lineWidth = rasterizerState.LineWidth;
|
refreshGraphicsPipelineCreateInfo.rasterizerState.lineWidth = rasterizerState.LineWidth;
|
||||||
|
|
||||||
refreshGraphicsPipelineCreateInfo.vertexInputState.vertexAttributes = vertexAttributesHandle.AddrOfPinnedObject();
|
refreshGraphicsPipelineCreateInfo.vertexInputState.vertexAttributes = vertexAttributesHandle.AddrOfPinnedObject();
|
||||||
|
|
|
@ -48,8 +48,8 @@ namespace MoonWorks.Graphics
|
||||||
fixed (ColorTargetDescription* colorPtr = colorTargetDescriptions)
|
fixed (ColorTargetDescription* colorPtr = colorTargetDescriptions)
|
||||||
{
|
{
|
||||||
Refresh.RenderPassCreateInfo renderPassCreateInfo;
|
Refresh.RenderPassCreateInfo renderPassCreateInfo;
|
||||||
renderPassCreateInfo.colorTargetCount = (uint)colorTargetDescriptions.Length;
|
renderPassCreateInfo.colorTargetCount = (uint) colorTargetDescriptions.Length;
|
||||||
renderPassCreateInfo.colorTargetDescriptions = (IntPtr)colorPtr;
|
renderPassCreateInfo.colorTargetDescriptions = (IntPtr) colorPtr;
|
||||||
renderPassCreateInfo.depthStencilTargetDescription = (IntPtr) depthStencilPtr;
|
renderPassCreateInfo.depthStencilTargetDescription = (IntPtr) depthStencilPtr;
|
||||||
|
|
||||||
Handle = Refresh.Refresh_CreateRenderPass(device.Handle, renderPassCreateInfo);
|
Handle = Refresh.Refresh_CreateRenderPass(device.Handle, renderPassCreateInfo);
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -36,11 +36,11 @@ namespace MoonWorks.Graphics
|
||||||
out var channels
|
out var channels
|
||||||
);
|
);
|
||||||
|
|
||||||
var byteCount = (uint)(width * height * channels);
|
var byteCount = (uint) (width * height * channels);
|
||||||
|
|
||||||
TextureCreateInfo textureCreateInfo;
|
TextureCreateInfo textureCreateInfo;
|
||||||
textureCreateInfo.Width = (uint)width;
|
textureCreateInfo.Width = (uint) width;
|
||||||
textureCreateInfo.Height = (uint)height;
|
textureCreateInfo.Height = (uint) height;
|
||||||
textureCreateInfo.Depth = 1;
|
textureCreateInfo.Depth = 1;
|
||||||
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
|
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
|
||||||
textureCreateInfo.IsCube = false;
|
textureCreateInfo.IsCube = false;
|
||||||
|
@ -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.
|
||||||
|
|
|
@ -108,13 +108,13 @@ namespace MoonWorks.Graphics
|
||||||
return new Refresh.ColorTargetBlendState
|
return new Refresh.ColorTargetBlendState
|
||||||
{
|
{
|
||||||
blendEnable = Conversions.BoolToByte(BlendEnable),
|
blendEnable = Conversions.BoolToByte(BlendEnable),
|
||||||
alphaBlendOp = (Refresh.BlendOp)AlphaBlendOp,
|
alphaBlendOp = (Refresh.BlendOp) AlphaBlendOp,
|
||||||
colorBlendOp = (Refresh.BlendOp)ColorBlendOp,
|
colorBlendOp = (Refresh.BlendOp) ColorBlendOp,
|
||||||
colorWriteMask = (Refresh.ColorComponentFlags)ColorWriteMask,
|
colorWriteMask = (Refresh.ColorComponentFlags) ColorWriteMask,
|
||||||
destinationAlphaBlendFactor = (Refresh.BlendFactor)DestinationAlphaBlendFactor,
|
destinationAlphaBlendFactor = (Refresh.BlendFactor) DestinationAlphaBlendFactor,
|
||||||
destinationColorBlendFactor = (Refresh.BlendFactor)DestinationColorBlendFactor,
|
destinationColorBlendFactor = (Refresh.BlendFactor) DestinationColorBlendFactor,
|
||||||
sourceAlphaBlendFactor = (Refresh.BlendFactor)SourceAlphaBlendFactor,
|
sourceAlphaBlendFactor = (Refresh.BlendFactor) SourceAlphaBlendFactor,
|
||||||
sourceColorBlendFactor = (Refresh.BlendFactor)SourceColorBlendFactor
|
sourceColorBlendFactor = (Refresh.BlendFactor) SourceColorBlendFactor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -115,20 +115,20 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
return new Refresh.SamplerStateCreateInfo
|
return new Refresh.SamplerStateCreateInfo
|
||||||
{
|
{
|
||||||
minFilter = (Refresh.Filter)MinFilter,
|
minFilter = (Refresh.Filter) MinFilter,
|
||||||
magFilter = (Refresh.Filter)MagFilter,
|
magFilter = (Refresh.Filter) MagFilter,
|
||||||
mipmapMode = (Refresh.SamplerMipmapMode)MipmapMode,
|
mipmapMode = (Refresh.SamplerMipmapMode) MipmapMode,
|
||||||
addressModeU = (Refresh.SamplerAddressMode)AddressModeU,
|
addressModeU = (Refresh.SamplerAddressMode) AddressModeU,
|
||||||
addressModeV = (Refresh.SamplerAddressMode)AddressModeV,
|
addressModeV = (Refresh.SamplerAddressMode) AddressModeV,
|
||||||
addressModeW = (Refresh.SamplerAddressMode)AddressModeW,
|
addressModeW = (Refresh.SamplerAddressMode) AddressModeW,
|
||||||
mipLodBias = MipLodBias,
|
mipLodBias = MipLodBias,
|
||||||
anisotropyEnable = Conversions.BoolToByte(AnisotropyEnable),
|
anisotropyEnable = Conversions.BoolToByte(AnisotropyEnable),
|
||||||
maxAnisotropy = MaxAnisotropy,
|
maxAnisotropy = MaxAnisotropy,
|
||||||
compareEnable = Conversions.BoolToByte(CompareEnable),
|
compareEnable = Conversions.BoolToByte(CompareEnable),
|
||||||
compareOp = (Refresh.CompareOp)CompareOp,
|
compareOp = (Refresh.CompareOp) CompareOp,
|
||||||
minLod = MinLod,
|
minLod = MinLod,
|
||||||
maxLod = MaxLod,
|
maxLod = MaxLod,
|
||||||
borderColor = (Refresh.BorderColor)BorderColor
|
borderColor = (Refresh.BorderColor) BorderColor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace MoonWorks.Graphics
|
||||||
int size;
|
int size;
|
||||||
using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||||
{
|
{
|
||||||
size = (int)stream.Length;
|
size = (int) stream.Length;
|
||||||
data = new byte[size];
|
data = new byte[size];
|
||||||
stream.Read(data, 0, size);
|
stream.Read(data, 0, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
namespace MoonWorks
|
namespace MoonWorks
|
||||||
{
|
{
|
||||||
public static class Conversions
|
public static class Conversions
|
||||||
{
|
{
|
||||||
public static byte BoolToByte(bool b)
|
public static byte BoolToByte(bool b)
|
||||||
{
|
{
|
||||||
return (byte)(b ? 1 : 0);
|
return (byte) (b ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ByteToBool(byte b)
|
public static bool ByteToBool(byte b)
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ namespace MoonWorks.Input
|
||||||
{
|
{
|
||||||
return SDL.SDL_GameControllerRumble(
|
return SDL.SDL_GameControllerRumble(
|
||||||
Handle,
|
Handle,
|
||||||
(ushort)(MathHelper.Clamp(leftMotor, 0f, 1f) * 0xFFFF),
|
(ushort) (MathHelper.Clamp(leftMotor, 0f, 1f) * 0xFFFF),
|
||||||
(ushort)(MathHelper.Clamp(rightMotor, 0f, 1f) * 0xFFFF),
|
(ushort) (MathHelper.Clamp(rightMotor, 0f, 1f) * 0xFFFF),
|
||||||
durationInMilliseconds
|
durationInMilliseconds
|
||||||
) == 0;
|
) == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -39,7 +39,7 @@ namespace MoonWorks.Input
|
||||||
Keys = new ButtonState[numKeys];
|
Keys = new ButtonState[numKeys];
|
||||||
foreach (Keycode keycode in Enum.GetValues(typeof(Keycode)))
|
foreach (Keycode keycode in Enum.GetValues(typeof(Keycode)))
|
||||||
{
|
{
|
||||||
Keys[(int)keycode] = new ButtonState();
|
Keys[(int) keycode] = new ButtonState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ namespace MoonWorks.Input
|
||||||
|
|
||||||
if (Conversions.ByteToBool(keyDown))
|
if (Conversions.ByteToBool(keyDown))
|
||||||
{
|
{
|
||||||
if (TextInputBindings.TryGetValue((Keycode)keycode, out var textIndex))
|
if (TextInputBindings.TryGetValue((Keycode) keycode, out var textIndex))
|
||||||
{
|
{
|
||||||
Inputs.OnTextInput(TextInputCharacters[(textIndex)]);
|
Inputs.OnTextInput(TextInputCharacters[(textIndex)]);
|
||||||
}
|
}
|
||||||
else if (IsDown(Keycode.LeftControl) && (Keycode)keycode == Keycode.V)
|
else if (IsDown(Keycode.LeftControl) && (Keycode) keycode == Keycode.V)
|
||||||
{
|
{
|
||||||
Inputs.OnTextInput(TextInputCharacters[6]);
|
Inputs.OnTextInput(TextInputCharacters[6]);
|
||||||
}
|
}
|
||||||
|
@ -68,22 +68,22 @@ namespace MoonWorks.Input
|
||||||
|
|
||||||
public bool IsDown(Keycode keycode)
|
public bool IsDown(Keycode keycode)
|
||||||
{
|
{
|
||||||
return Keys[(int)keycode].IsDown;
|
return Keys[(int) keycode].IsDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPressed(Keycode keycode)
|
public bool IsPressed(Keycode keycode)
|
||||||
{
|
{
|
||||||
return Keys[(int)keycode].IsPressed;
|
return Keys[(int) keycode].IsPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsHeld(Keycode keycode)
|
public bool IsHeld(Keycode keycode)
|
||||||
{
|
{
|
||||||
return Keys[(int)keycode].IsHeld;
|
return Keys[(int) keycode].IsHeld;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsReleased(Keycode keycode)
|
public bool IsReleased(Keycode keycode)
|
||||||
{
|
{
|
||||||
return Keys[(int)keycode].IsReleased;
|
return Keys[(int) keycode].IsReleased;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -91,23 +91,23 @@ namespace MoonWorks.Math
|
||||||
public ContainmentType Contains(BoundingBox box)
|
public ContainmentType Contains(BoundingBox box)
|
||||||
{
|
{
|
||||||
// Test if all corner is in the same side of a face by just checking min and max
|
// Test if all corner is in the same side of a face by just checking min and max
|
||||||
if ( box.Max.X < Min.X ||
|
if (box.Max.X < Min.X ||
|
||||||
box.Min.X > Max.X ||
|
box.Min.X > Max.X ||
|
||||||
box.Max.Y < Min.Y ||
|
box.Max.Y < Min.Y ||
|
||||||
box.Min.Y > Max.Y ||
|
box.Min.Y > Max.Y ||
|
||||||
box.Max.Z < Min.Z ||
|
box.Max.Z < Min.Z ||
|
||||||
box.Min.Z > Max.Z )
|
box.Min.Z > Max.Z)
|
||||||
{
|
{
|
||||||
return ContainmentType.Disjoint;
|
return ContainmentType.Disjoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( box.Min.X >= Min.X &&
|
if (box.Min.X >= Min.X &&
|
||||||
box.Max.X <= Max.X &&
|
box.Max.X <= Max.X &&
|
||||||
box.Min.Y >= Min.Y &&
|
box.Min.Y >= Min.Y &&
|
||||||
box.Max.Y <= Max.Y &&
|
box.Max.Y <= Max.Y &&
|
||||||
box.Min.Z >= Min.Z &&
|
box.Min.Z >= Min.Z &&
|
||||||
box.Max.Z <= Max.Z )
|
box.Max.Z <= Max.Z)
|
||||||
{
|
{
|
||||||
return ContainmentType.Contains;
|
return ContainmentType.Contains;
|
||||||
}
|
}
|
||||||
|
@ -172,12 +172,12 @@ namespace MoonWorks.Math
|
||||||
|
|
||||||
public ContainmentType Contains(BoundingSphere sphere)
|
public ContainmentType Contains(BoundingSphere sphere)
|
||||||
{
|
{
|
||||||
if ( sphere.Center.X - Min.X >= sphere.Radius &&
|
if (sphere.Center.X - Min.X >= sphere.Radius &&
|
||||||
sphere.Center.Y - Min.Y >= sphere.Radius &&
|
sphere.Center.Y - Min.Y >= sphere.Radius &&
|
||||||
sphere.Center.Z - Min.Z >= sphere.Radius &&
|
sphere.Center.Z - Min.Z >= sphere.Radius &&
|
||||||
Max.X - sphere.Center.X >= sphere.Radius &&
|
Max.X - sphere.Center.X >= sphere.Radius &&
|
||||||
Max.Y - sphere.Center.Y >= sphere.Radius &&
|
Max.Y - sphere.Center.Y >= sphere.Radius &&
|
||||||
Max.Z - sphere.Center.Z >= sphere.Radius )
|
Max.Z - sphere.Center.Z >= sphere.Radius)
|
||||||
{
|
{
|
||||||
return ContainmentType.Contains;
|
return ContainmentType.Contains;
|
||||||
}
|
}
|
||||||
|
@ -261,12 +261,12 @@ namespace MoonWorks.Math
|
||||||
public void Contains(ref Vector3 point, out ContainmentType result)
|
public void Contains(ref Vector3 point, out ContainmentType result)
|
||||||
{
|
{
|
||||||
// Determine if point is outside of this box.
|
// Determine if point is outside of this box.
|
||||||
if ( point.X < this.Min.X ||
|
if (point.X < this.Min.X ||
|
||||||
point.X > this.Max.X ||
|
point.X > this.Max.X ||
|
||||||
point.Y < this.Min.Y ||
|
point.Y < this.Min.Y ||
|
||||||
point.Y > this.Max.Y ||
|
point.Y > this.Max.Y ||
|
||||||
point.Z < this.Min.Z ||
|
point.Z < this.Min.Z ||
|
||||||
point.Z > this.Max.Z )
|
point.Z > this.Max.Z)
|
||||||
{
|
{
|
||||||
result = ContainmentType.Disjoint;
|
result = ContainmentType.Disjoint;
|
||||||
}
|
}
|
||||||
|
@ -380,12 +380,12 @@ namespace MoonWorks.Math
|
||||||
|
|
||||||
public bool Intersects(BoundingSphere sphere)
|
public bool Intersects(BoundingSphere sphere)
|
||||||
{
|
{
|
||||||
if ( sphere.Center.X - Min.X > sphere.Radius &&
|
if (sphere.Center.X - Min.X > sphere.Radius &&
|
||||||
sphere.Center.Y - Min.Y > sphere.Radius &&
|
sphere.Center.Y - Min.Y > sphere.Radius &&
|
||||||
sphere.Center.Z - Min.Z > sphere.Radius &&
|
sphere.Center.Z - Min.Z > sphere.Radius &&
|
||||||
Max.X - sphere.Center.X > sphere.Radius &&
|
Max.X - sphere.Center.X > sphere.Radius &&
|
||||||
Max.Y - sphere.Center.Y > sphere.Radius &&
|
Max.Y - sphere.Center.Y > sphere.Radius &&
|
||||||
Max.Z - sphere.Center.Z > sphere.Radius )
|
Max.Z - sphere.Center.Z > sphere.Radius)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -297,8 +297,8 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public bool Equals(BoundingSphere other)
|
public bool Equals(BoundingSphere other)
|
||||||
{
|
{
|
||||||
return ( Center == other.Center &&
|
return (Center == other.Center &&
|
||||||
Radius == other.Radius );
|
Radius == other.Radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -284,8 +284,8 @@ namespace MoonWorks.Math
|
||||||
{
|
{
|
||||||
Matrix3x2 result;
|
Matrix3x2 result;
|
||||||
|
|
||||||
float xTan = (float)System.Math.Tan(radiansX);
|
float xTan = (float) System.Math.Tan(radiansX);
|
||||||
float yTan = (float)System.Math.Tan(radiansY);
|
float yTan = (float) System.Math.Tan(radiansY);
|
||||||
|
|
||||||
result.M11 = 1.0f;
|
result.M11 = 1.0f;
|
||||||
result.M12 = yTan;
|
result.M12 = yTan;
|
||||||
|
@ -308,8 +308,8 @@ namespace MoonWorks.Math
|
||||||
{
|
{
|
||||||
Matrix3x2 result;
|
Matrix3x2 result;
|
||||||
|
|
||||||
float xTan = (float)System.Math.Tan(radiansX);
|
float xTan = (float) System.Math.Tan(radiansX);
|
||||||
float yTan = (float)System.Math.Tan(radiansY);
|
float yTan = (float) System.Math.Tan(radiansY);
|
||||||
|
|
||||||
float tx = -centerPoint.Y * xTan;
|
float tx = -centerPoint.Y * xTan;
|
||||||
float ty = -centerPoint.X * yTan;
|
float ty = -centerPoint.X * yTan;
|
||||||
|
@ -333,11 +333,11 @@ namespace MoonWorks.Math
|
||||||
{
|
{
|
||||||
Matrix3x2 result;
|
Matrix3x2 result;
|
||||||
|
|
||||||
radians = (float)System.Math.IEEERemainder(radians, System.Math.PI * 2);
|
radians = (float) System.Math.IEEERemainder(radians, System.Math.PI * 2);
|
||||||
|
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
const float epsilon = 0.001f * (float)System.Math.PI / 180f; // 0.1% of a degree
|
const float epsilon = 0.001f * (float) System.Math.PI / 180f; // 0.1% of a degree
|
||||||
|
|
||||||
if (radians > -epsilon && radians < epsilon)
|
if (radians > -epsilon && radians < epsilon)
|
||||||
{
|
{
|
||||||
|
@ -366,8 +366,8 @@ namespace MoonWorks.Math
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Arbitrary rotation.
|
// Arbitrary rotation.
|
||||||
c = (float)System.Math.Cos(radians);
|
c = (float) System.Math.Cos(radians);
|
||||||
s = (float)System.Math.Sin(radians);
|
s = (float) System.Math.Sin(radians);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [ c s ]
|
// [ c s ]
|
||||||
|
@ -393,11 +393,11 @@ namespace MoonWorks.Math
|
||||||
{
|
{
|
||||||
Matrix3x2 result;
|
Matrix3x2 result;
|
||||||
|
|
||||||
radians = (float)System.Math.IEEERemainder(radians, System.Math.PI * 2);
|
radians = (float) System.Math.IEEERemainder(radians, System.Math.PI * 2);
|
||||||
|
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
const float epsilon = 0.001f * (float)System.Math.PI / 180f; // 0.1% of a degree
|
const float epsilon = 0.001f * (float) System.Math.PI / 180f; // 0.1% of a degree
|
||||||
|
|
||||||
if (radians > -epsilon && radians < epsilon)
|
if (radians > -epsilon && radians < epsilon)
|
||||||
{
|
{
|
||||||
|
@ -426,8 +426,8 @@ namespace MoonWorks.Math
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Arbitrary rotation.
|
// Arbitrary rotation.
|
||||||
c = (float)System.Math.Cos(radians);
|
c = (float) System.Math.Cos(radians);
|
||||||
s = (float)System.Math.Sin(radians);
|
s = (float) System.Math.Sin(radians);
|
||||||
}
|
}
|
||||||
|
|
||||||
float x = centerPoint.X * (1 - c) + centerPoint.Y * s;
|
float x = centerPoint.X * (1 - c) + centerPoint.Y * s;
|
||||||
|
@ -793,7 +793,7 @@ namespace MoonWorks.Math
|
||||||
{
|
{
|
||||||
if (obj is Matrix3x2)
|
if (obj is Matrix3x2)
|
||||||
{
|
{
|
||||||
return Equals((Matrix3x2)obj);
|
return Equals((Matrix3x2) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -363,9 +365,9 @@ namespace MoonWorks.Math
|
||||||
scale.Y = ys * (float) System.Math.Sqrt(M21 * M21 + M22 * M22 + M23 * M23);
|
scale.Y = ys * (float) System.Math.Sqrt(M21 * M21 + M22 * M22 + M23 * M23);
|
||||||
scale.Z = zs * (float) System.Math.Sqrt(M31 * M31 + M32 * M32 + M33 * M33);
|
scale.Z = zs * (float) System.Math.Sqrt(M31 * M31 + M32 * M32 + M33 * M33);
|
||||||
|
|
||||||
if ( MathHelper.WithinEpsilon(scale.X, 0.0f) ||
|
if (MathHelper.WithinEpsilon(scale.X, 0.0f) ||
|
||||||
MathHelper.WithinEpsilon(scale.Y, 0.0f) ||
|
MathHelper.WithinEpsilon(scale.Y, 0.0f) ||
|
||||||
MathHelper.WithinEpsilon(scale.Z, 0.0f) )
|
MathHelper.WithinEpsilon(scale.Z, 0.0f))
|
||||||
{
|
{
|
||||||
rotation = Quaternion.Identity;
|
rotation = Quaternion.Identity;
|
||||||
return false;
|
return false;
|
||||||
|
@ -413,7 +415,7 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public bool Equals(Matrix4x4 other)
|
public bool Equals(Matrix4x4 other)
|
||||||
{
|
{
|
||||||
return ( M11 == other.M11 &&
|
return (M11 == other.M11 &&
|
||||||
M12 == other.M12 &&
|
M12 == other.M12 &&
|
||||||
M13 == other.M13 &&
|
M13 == other.M13 &&
|
||||||
M14 == other.M14 &&
|
M14 == other.M14 &&
|
||||||
|
@ -428,7 +430,7 @@ namespace MoonWorks.Math
|
||||||
M41 == other.M41 &&
|
M41 == other.M41 &&
|
||||||
M42 == other.M42 &&
|
M42 == other.M42 &&
|
||||||
M43 == other.M43 &&
|
M43 == other.M43 &&
|
||||||
M44 == other.M44 );
|
M44 == other.M44);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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
|
||||||
|
@ -157,10 +157,10 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public bool Equals(Quaternion other)
|
public bool Equals(Quaternion other)
|
||||||
{
|
{
|
||||||
return ( X == other.X &&
|
return (X == other.X &&
|
||||||
Y == other.Y &&
|
Y == other.Y &&
|
||||||
Z == other.Z &&
|
Z == other.Z &&
|
||||||
W == other.W );
|
W == other.W);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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);
|
||||||
|
@ -415,12 +418,12 @@ namespace MoonWorks.Math
|
||||||
else if (matrix.M22 > matrix.M33)
|
else if (matrix.M22 > matrix.M33)
|
||||||
{
|
{
|
||||||
sqrt = (float) System.Math.Sqrt(1.0f + matrix.M22 - matrix.M11 - matrix.M33);
|
sqrt = (float) System.Math.Sqrt(1.0f + matrix.M22 - matrix.M11 - matrix.M33);
|
||||||
half = 0.5f/sqrt;
|
half = 0.5f / sqrt;
|
||||||
|
|
||||||
result.X = (matrix.M21 + matrix.M12)*half;
|
result.X = (matrix.M21 + matrix.M12) * half;
|
||||||
result.Y = 0.5f*sqrt;
|
result.Y = 0.5f * sqrt;
|
||||||
result.Z = (matrix.M32 + matrix.M23)*half;
|
result.Z = (matrix.M32 + matrix.M23) * half;
|
||||||
result.W = (matrix.M31 - matrix.M13)*half;
|
result.W = (matrix.M31 - matrix.M13) * half;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -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
|
||||||
|
@ -70,8 +70,8 @@ namespace MoonWorks.Math
|
||||||
|
|
||||||
public bool Equals(Ray other)
|
public bool Equals(Ray other)
|
||||||
{
|
{
|
||||||
return ( this.Position.Equals(other.Position) &&
|
return (this.Position.Equals(other.Position) &&
|
||||||
this.Direction.Equals(other.Direction) );
|
this.Direction.Equals(other.Direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ namespace MoonWorks.Math
|
||||||
tMaxY = temp;
|
tMaxY = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (tMin.HasValue && tMin > tMaxY) ||
|
if ((tMin.HasValue && tMin > tMaxY) ||
|
||||||
(tMax.HasValue && tMinY > tMax) )
|
(tMax.HasValue && tMinY > tMax))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,8 @@ namespace MoonWorks.Math
|
||||||
tMaxZ = temp;
|
tMaxZ = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (tMin.HasValue && tMin > tMaxZ) ||
|
if ((tMin.HasValue && tMin > tMaxZ) ||
|
||||||
(tMax.HasValue && tMinZ > tMax) )
|
(tMax.HasValue && tMinZ > tMax))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -117,10 +117,10 @@ namespace MoonWorks.Math
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ( (Width == 0) &&
|
return ((Width == 0) &&
|
||||||
(Height == 0) &&
|
(Height == 0) &&
|
||||||
(X == 0) &&
|
(X == 0) &&
|
||||||
(Y == 0) );
|
(Y == 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,10 +218,10 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>. <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>. <c>false</c> otherwise.</returns>
|
||||||
public bool Contains(int x, int y)
|
public bool Contains(int x, int y)
|
||||||
{
|
{
|
||||||
return ( (this.X <= x) &&
|
return ((this.X <= x) &&
|
||||||
(x < (this.X + this.Width)) &&
|
(x < (this.X + this.Width)) &&
|
||||||
(this.Y <= y) &&
|
(this.Y <= y) &&
|
||||||
(y < (this.Y + this.Height)) );
|
(y < (this.Y + this.Height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -231,10 +231,10 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>. <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>. <c>false</c> otherwise.</returns>
|
||||||
public bool Contains(Point value)
|
public bool Contains(Point value)
|
||||||
{
|
{
|
||||||
return ( (this.X <= value.X) &&
|
return ((this.X <= value.X) &&
|
||||||
(value.X < (this.X + this.Width)) &&
|
(value.X < (this.X + this.Width)) &&
|
||||||
(this.Y <= value.Y) &&
|
(this.Y <= value.Y) &&
|
||||||
(value.Y < (this.Y + this.Height)) );
|
(value.Y < (this.Y + this.Height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -244,26 +244,26 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>. <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>. <c>false</c> otherwise.</returns>
|
||||||
public bool Contains(Rectangle value)
|
public bool Contains(Rectangle value)
|
||||||
{
|
{
|
||||||
return ( (this.X <= value.X) &&
|
return ((this.X <= value.X) &&
|
||||||
((value.X + value.Width) <= (this.X + this.Width)) &&
|
((value.X + value.Width) <= (this.X + this.Width)) &&
|
||||||
(this.Y <= value.Y) &&
|
(this.Y <= value.Y) &&
|
||||||
((value.Y + value.Height) <= (this.Y + this.Height)) );
|
((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Contains(ref Point value, out bool result)
|
public void Contains(ref Point value, out bool result)
|
||||||
{
|
{
|
||||||
result = ( (this.X <= value.X) &&
|
result = ((this.X <= value.X) &&
|
||||||
(value.X < (this.X + this.Width)) &&
|
(value.X < (this.X + this.Width)) &&
|
||||||
(this.Y <= value.Y) &&
|
(this.Y <= value.Y) &&
|
||||||
(value.Y < (this.Y + this.Height)) );
|
(value.Y < (this.Y + this.Height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Contains(ref Rectangle value, out bool result)
|
public void Contains(ref Rectangle value, out bool result)
|
||||||
{
|
{
|
||||||
result = ( (this.X <= value.X) &&
|
result = ((this.X <= value.X) &&
|
||||||
((value.X + value.Width) <= (this.X + this.Width)) &&
|
((value.X + value.Width) <= (this.X + this.Width)) &&
|
||||||
(this.Y <= value.Y) &&
|
(this.Y <= value.Y) &&
|
||||||
((value.Y + value.Height) <= (this.Y + this.Height)) );
|
((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -349,10 +349,10 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise.</returns>
|
||||||
public bool Intersects(Rectangle value)
|
public bool Intersects(Rectangle value)
|
||||||
{
|
{
|
||||||
return ( value.Left < Right &&
|
return (value.Left < Right &&
|
||||||
Left < value.Right &&
|
Left < value.Right &&
|
||||||
value.Top < Bottom &&
|
value.Top < Bottom &&
|
||||||
Top < value.Bottom );
|
Top < value.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -362,10 +362,10 @@ namespace MoonWorks.Math
|
||||||
/// <param name="result"><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise. As an output parameter.</param>
|
/// <param name="result"><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise. As an output parameter.</param>
|
||||||
public void Intersects(ref Rectangle value, out bool result)
|
public void Intersects(ref Rectangle value, out bool result)
|
||||||
{
|
{
|
||||||
result = ( value.Left < Right &&
|
result = (value.Left < Right &&
|
||||||
Left < value.Right &&
|
Left < value.Right &&
|
||||||
value.Top < Bottom &&
|
value.Top < Bottom &&
|
||||||
Top < value.Bottom );
|
Top < value.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -374,10 +374,10 @@ namespace MoonWorks.Math
|
||||||
|
|
||||||
public static bool operator ==(Rectangle a, Rectangle b)
|
public static bool operator ==(Rectangle a, Rectangle b)
|
||||||
{
|
{
|
||||||
return ( (a.X == b.X) &&
|
return ((a.X == b.X) &&
|
||||||
(a.Y == b.Y) &&
|
(a.Y == b.Y) &&
|
||||||
(a.Width == b.Width) &&
|
(a.Width == b.Width) &&
|
||||||
(a.Height == b.Height) );
|
(a.Height == b.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator !=(Rectangle a, Rectangle b)
|
public static bool operator !=(Rectangle a, Rectangle b)
|
||||||
|
@ -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
|
||||||
|
@ -163,8 +163,8 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public bool Equals(Vector2 other)
|
public bool Equals(Vector2 other)
|
||||||
{
|
{
|
||||||
return ( X == other.X &&
|
return (X == other.X &&
|
||||||
Y == other.Y );
|
Y == other.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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];
|
||||||
|
@ -1058,8 +1077,8 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public static bool operator ==(Vector2 value1, Vector2 value2)
|
public static bool operator ==(Vector2 value1, Vector2 value2)
|
||||||
{
|
{
|
||||||
return ( value1.X == value2.X &&
|
return (value1.X == value2.X &&
|
||||||
value1.Y == value2.Y );
|
value1.Y == value2.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -270,9 +270,9 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public bool Equals(Vector3 other)
|
public bool Equals(Vector3 other)
|
||||||
{
|
{
|
||||||
return ( X == other.X &&
|
return (X == other.X &&
|
||||||
Y == other.Y &&
|
Y == other.Y &&
|
||||||
Z == other.Z );
|
Z == other.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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");
|
||||||
|
@ -1396,9 +1416,9 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public static bool operator ==(Vector3 value1, Vector3 value2)
|
public static bool operator ==(Vector3 value1, Vector3 value2)
|
||||||
{
|
{
|
||||||
return ( value1.X == value2.X &&
|
return (value1.X == value2.X &&
|
||||||
value1.Y == value2.Y &&
|
value1.Y == value2.Y &&
|
||||||
value1.Z == value2.Z );
|
value1.Z == value2.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#region License
|
#region License
|
||||||
|
|
||||||
/* MoonWorks - Game Development Framework
|
/* MoonWorks - Game Development Framework
|
||||||
* Copyright 2021 Evan Hemsley
|
* Copyright 2021 Evan Hemsley
|
||||||
|
@ -234,10 +234,10 @@ namespace MoonWorks.Math
|
||||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||||
public bool Equals(Vector4 other)
|
public bool Equals(Vector4 other)
|
||||||
{
|
{
|
||||||
return ( X == other.X &&
|
return (X == other.X &&
|
||||||
Y == other.Y &&
|
Y == other.Y &&
|
||||||
Z == other.Z &&
|
Z == other.Z &&
|
||||||
W == other.W );
|
W == other.W);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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");
|
||||||
|
@ -1405,10 +1423,10 @@ namespace MoonWorks.Math
|
||||||
|
|
||||||
public static bool operator ==(Vector4 value1, Vector4 value2)
|
public static bool operator ==(Vector4 value1, Vector4 value2)
|
||||||
{
|
{
|
||||||
return ( value1.X == value2.X &&
|
return (value1.X == value2.X &&
|
||||||
value1.Y == value2.Y &&
|
value1.Y == value2.Y &&
|
||||||
value1.Z == value2.Z &&
|
value1.Z == value2.Z &&
|
||||||
value1.W == value2.W );
|
value1.W == value2.W);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator !=(Vector4 value1, Vector4 value2)
|
public static bool operator !=(Vector4 value1, Vector4 value2)
|
||||||
|
|
|
@ -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
|
||||||
|
@ -29,8 +29,8 @@ namespace MoonWorks.Window
|
||||||
windowCreateInfo.WindowTitle,
|
windowCreateInfo.WindowTitle,
|
||||||
SDL.SDL_WINDOWPOS_UNDEFINED,
|
SDL.SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL.SDL_WINDOWPOS_UNDEFINED,
|
SDL.SDL_WINDOWPOS_UNDEFINED,
|
||||||
(int)windowCreateInfo.WindowWidth,
|
(int) windowCreateInfo.WindowWidth,
|
||||||
(int)windowCreateInfo.WindowHeight,
|
(int) windowCreateInfo.WindowHeight,
|
||||||
windowFlags
|
windowFlags
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace MoonWorks.Window
|
||||||
/// <param name="height"></param>
|
/// <param name="height"></param>
|
||||||
public void SetWindowSize(uint width, uint height)
|
public void SetWindowSize(uint width, uint height)
|
||||||
{
|
{
|
||||||
SDL.SDL_SetWindowSize(Handle, (int)width, (int)height);
|
SDL.SDL_SetWindowSize(Handle, (int) width, (int) height);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
|
|
|
@ -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