Formatting pass

pull/14/head
cosmonaut 2022-02-22 21:14:32 -08:00
parent a0c57c7a59
commit 8973b3e658
93 changed files with 5236 additions and 5080 deletions

14
.editorconfig Normal file
View File

@ -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

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
using MoonWorks.Math;

View File

@ -1,4 +1,4 @@
using System;
using System;
using MoonWorks.Math;
namespace MoonWorks.Audio

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace MoonWorks.Audio
{

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
using MoonWorks.Math;
@ -169,7 +169,7 @@ namespace MoonWorks.Audio
bool loop
) : base(device)
{
var blockAlign = (ushort)(4 * channels);
var blockAlign = (ushort) (4 * channels);
var format = new FAudio.FAudioWaveFormatEx
{
wFormatTag = 3,

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Audio
namespace MoonWorks.Audio
{
public enum SoundState
{

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
namespace MoonWorks.Audio

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace MoonWorks.Audio
{

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
@ -131,7 +131,7 @@ namespace MoonWorks.Audio
PlayLength = (
lengthInBytes /
Format.nChannels /
(uint)(Format.wBitsPerSample / 8)
(uint) (Format.wBitsPerSample / 8)
)
};

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
namespace MoonWorks.Audio
@ -20,7 +20,8 @@ namespace MoonWorks.Audio
string filePath,
bool is3D = false,
bool loop = false
) {
)
{
var fileHandle = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero);
if (error != 0)
{
@ -59,7 +60,8 @@ namespace MoonWorks.Audio
out uint bufferOffset,
out uint bufferLength,
out bool reachedEnd
) {
)
{
buffer = this.buffer;
/* NOTE: this function returns samples per channel, not total samples */

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace MoonWorks
{

View File

@ -46,7 +46,8 @@ namespace MoonWorks
PresentMode presentMode,
int targetTimestep = 60,
bool debugMode = false
) {
)
{
timestep = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / targetTimestep);
gameTimer = Stopwatch.StartNew();
@ -259,7 +260,7 @@ namespace MoonWorks
private unsafe static int MeasureStringLength(byte* ptr)
{
int bytes;
for (bytes = 0; *ptr != 0; ptr += 1, bytes += 1);
for (bytes = 0; *ptr != 0; ptr += 1, bytes += 1) ;
return bytes;
}
}

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
public struct BufferBinding
{

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -41,7 +41,7 @@ namespace MoonWorks.Graphics
{
unchecked
{
return (byte)(this.packedValue);
return (byte) (this.packedValue);
}
}
set
@ -59,12 +59,12 @@ namespace MoonWorks.Graphics
{
unchecked
{
return (byte)(this.packedValue >> 8);
return (byte) (this.packedValue >> 8);
}
}
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);
RoyalBlue = new Color(0xffe16941);
SaddleBrown = new Color(0xff13458b);
Salmon= new Color(0xff7280fa);
Salmon = new Color(0xff7280fa);
SandyBrown = new Color(0xff60a4f4);
SeaGreen = new Color(0xff578b2e);
SeaShell = new Color(0xffeef5ff);
Sienna = new Color(0xff2d52a0);
Silver = new Color(0xffc0c0c0);
SkyBlue = new Color(0xffebce87);
SlateBlue= new Color(0xffcd5a6a);
SlateGray= new Color(0xff908070);
Snow= new Color(0xfffafaff);
SpringGreen= new Color(0xff7fff00);
SteelBlue= new Color(0xffb48246);
Tan= new Color(0xff8cb4d2);
Teal= new Color(0xff808000);
Thistle= new Color(0xffd8bfd8);
Tomato= new Color(0xff4763ff);
Turquoise= new Color(0xffd0e040);
Violet= new Color(0xffee82ee);
Wheat= new Color(0xffb3def5);
White= new Color(uint.MaxValue);
WhiteSmoke= new Color(0xfff5f5f5);
SlateBlue = new Color(0xffcd5a6a);
SlateGray = new Color(0xff908070);
Snow = new Color(0xfffafaff);
SpringGreen = new Color(0xff7fff00);
SteelBlue = new Color(0xffb48246);
Tan = new Color(0xff8cb4d2);
Teal = new Color(0xff808000);
Thistle = new Color(0xffd8bfd8);
Tomato = new Color(0xff4763ff);
Turquoise = new Color(0xffd0e040);
Violet = new Color(0xffee82ee);
Wheat = new Color(0xffb3def5);
White = new Color(uint.MaxValue);
WhiteSmoke = new Color(0xfff5f5f5);
Yellow = new Color(0xff00ffff);
YellowGreen = new Color(0xff32cd9a);
}
@ -1623,7 +1623,7 @@ namespace MoonWorks.Graphics
R = (byte) MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue);
G = (byte) MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue);
B = (byte) MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue);
A = (byte)255;
A = (byte) 255;
}
/// <summary>
@ -1769,10 +1769,10 @@ namespace MoonWorks.Graphics
/// <returns><c>True</c> if the instances are equal; <c>false</c> otherwise.</returns>
public static bool operator ==(Color a, Color b)
{
return ( a.A == b.A &&
return (a.A == b.A &&
a.R == b.R &&
a.G == b.G &&
a.B == b.B );
a.B == b.B);
}
/// <summary>

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
using MoonWorks.Math;
using MoonWorks.Window;
@ -36,7 +36,8 @@ namespace MoonWorks.Graphics
Framebuffer framebuffer,
in Rect renderArea,
in DepthStencilValue depthStencilClearValue
) {
)
{
Refresh.Refresh_BeginRenderPass(
Device.Handle,
Handle,
@ -65,7 +66,8 @@ namespace MoonWorks.Graphics
in Rect renderArea,
in DepthStencilValue depthStencilClearValue,
params Vector4[] clearColors
) {
)
{
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
for (var i = 0; i < clearColors.Length; i++)
@ -86,7 +88,7 @@ namespace MoonWorks.Graphics
framebuffer.Handle,
renderArea.ToRefresh(),
(IntPtr) colors,
(uint)clearColors.Length,
(uint) clearColors.Length,
depthStencilClearValue.ToRefresh()
);
}
@ -105,7 +107,8 @@ namespace MoonWorks.Graphics
Framebuffer framebuffer,
in Rect renderArea,
params Vector4[] clearColors
) {
)
{
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
for (var i = 0; i < clearColors.Length; i++)
@ -143,7 +146,8 @@ namespace MoonWorks.Graphics
RenderPass renderPass,
Framebuffer framebuffer,
in Rect renderArea
) {
)
{
Refresh.Refresh_BeginRenderPass(
Device.Handle,
Handle,
@ -162,7 +166,8 @@ namespace MoonWorks.Graphics
/// <param name="computePipeline">The compute pipeline to bind.</param>
public void BindComputePipeline(
ComputePipeline computePipeline
) {
)
{
Refresh.Refresh_BindComputePipeline(
Device.Handle,
Handle,
@ -176,7 +181,8 @@ namespace MoonWorks.Graphics
/// <param name="buffers">A set of buffers to bind.</param>
public unsafe void BindComputeBuffers(
params Buffer[] buffers
) {
)
{
var bufferPtrs = stackalloc IntPtr[buffers.Length];
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>
public unsafe void BindComputeTextures(
params Texture[] textures
) {
)
{
var texturePtrs = stackalloc IntPtr[textures.Length];
for (var i = 0; i < textures.Length; i += 1)
@ -224,7 +231,8 @@ namespace MoonWorks.Graphics
uint groupCountY,
uint groupCountZ,
uint computeParamOffset
) {
)
{
Refresh.Refresh_DispatchCompute(
Device.Handle,
Handle,
@ -241,7 +249,8 @@ namespace MoonWorks.Graphics
/// <param name="graphicsPipeline">The graphics pipeline to bind.</param>
public void BindGraphicsPipeline(
GraphicsPipeline graphicsPipeline
) {
)
{
Refresh.Refresh_BindGraphicsPipeline(
Device.Handle,
Handle,
@ -257,7 +266,8 @@ namespace MoonWorks.Graphics
public unsafe void BindVertexBuffers(
uint firstBinding,
params BufferBinding[] bufferBindings
) {
)
{
var bufferPtrs = stackalloc IntPtr[bufferBindings.Length];
var offsets = stackalloc ulong[bufferBindings.Length];
@ -283,7 +293,8 @@ namespace MoonWorks.Graphics
/// <param name="buffers">The buffers to bind.</param>
public unsafe void BindVertexBuffers(
params Buffer[] buffers
) {
)
{
var bufferPtrs = stackalloc IntPtr[buffers.Length];
var offsets = stackalloc ulong[buffers.Length];
@ -313,7 +324,8 @@ namespace MoonWorks.Graphics
Buffer indexBuffer,
IndexElementSize indexElementSize,
uint offset = 0
) {
)
{
Refresh.Refresh_BindIndexBuffer(
Device.Handle,
Handle,
@ -331,7 +343,8 @@ namespace MoonWorks.Graphics
public unsafe void BindVertexSamplers(
TextureSamplerBinding[] textureSamplerBindings,
int length
) {
)
{
var texturePtrs = 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>
public unsafe void BindVertexSamplers(
params TextureSamplerBinding[] textureSamplerBindings
) {
)
{
BindVertexSamplers(textureSamplerBindings, textureSamplerBindings.Length);
}
@ -367,7 +381,8 @@ namespace MoonWorks.Graphics
public unsafe void BindFragmentSamplers(
TextureSamplerBinding[] textureSamplerBindings,
int length
) {
)
{
var texturePtrs = 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>
public unsafe void BindFragmentSamplers(
params TextureSamplerBinding[] textureSamplerBindings
) {
)
{
BindFragmentSamplers(textureSamplerBindings, textureSamplerBindings.Length);
}
@ -465,7 +481,8 @@ namespace MoonWorks.Graphics
ClearOptionsFlags clearOptions,
in DepthStencilValue depthStencilClearValue,
params Vector4[] clearColors
) {
)
{
Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
for (var i = 0; i < clearColors.Length; i++)
{
@ -482,7 +499,7 @@ namespace MoonWorks.Graphics
Device.Handle,
Handle,
clearRect.ToRefresh(),
(Refresh.ClearOptionsFlags)clearOptions,
(Refresh.ClearOptionsFlags) clearOptions,
(IntPtr) colors,
(uint) clearColors.Length,
depthStencilClearValue.ToRefresh()
@ -506,7 +523,8 @@ namespace MoonWorks.Graphics
uint instanceCount,
uint vertexParamOffset,
uint fragmentParamOffset
) {
)
{
Refresh.Refresh_DrawInstancedPrimitives(
Device.Handle,
Handle,
@ -533,7 +551,8 @@ namespace MoonWorks.Graphics
uint primitiveCount,
uint vertexParamOffset,
uint fragmentParamOffset
) {
)
{
Refresh.Refresh_DrawIndexedPrimitives(
Device.Handle,
Handle,
@ -557,7 +576,8 @@ namespace MoonWorks.Graphics
uint primitiveCount,
uint vertexParamOffset,
uint fragmentParamOffset
) {
)
{
Refresh.Refresh_DrawPrimitives(
Device.Handle,
Handle,
@ -591,7 +611,8 @@ namespace MoonWorks.Graphics
in Rect destinationRectangle,
Filter filter,
OSWindow window
) {
)
{
var refreshRect = destinationRectangle.ToRefresh();
var refreshTextureSlice = new Refresh.TextureSlice
{
@ -600,8 +621,8 @@ namespace MoonWorks.Graphics
{
x = 0,
y = 0,
w = (int)texture.Width,
h = (int)texture.Height
w = (int) texture.Width,
h = (int) texture.Height
},
layer = 0,
level = 0,
@ -613,7 +634,7 @@ namespace MoonWorks.Graphics
Handle,
refreshTextureSlice,
refreshRect,
(Refresh.Filter)filter,
(Refresh.Filter) filter,
window.Handle
);
}
@ -629,7 +650,8 @@ namespace MoonWorks.Graphics
in Rect destinationRectangle,
Filter filter,
OSWindow window
) {
)
{
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
var refreshRect = destinationRectangle.ToRefresh();
@ -653,7 +675,8 @@ namespace MoonWorks.Graphics
in TextureSlice textureSlice,
Filter filter,
OSWindow window
) {
)
{
Refresh.Refresh_QueuePresent(
Device.Handle,
Handle,
@ -674,7 +697,8 @@ namespace MoonWorks.Graphics
Texture texture,
Filter filter,
OSWindow window
) {
)
{
var refreshTextureSlice = new Refresh.TextureSlice
{
texture = texture.Handle,
@ -713,7 +737,8 @@ namespace MoonWorks.Graphics
IntPtr dataPtr,
uint bufferOffsetInBytes,
uint dataLengthInBytes
) {
)
{
Refresh.Refresh_SetBufferData(
Device.Handle,
Handle,
@ -849,7 +874,8 @@ namespace MoonWorks.Graphics
in TextureSlice sourceTextureSlice,
in TextureSlice destinationTextureSlice,
Filter filter
) {
)
{
var sourceRefreshTextureSlice = sourceTextureSlice.ToRefreshTextureSlice();
var destRefreshTextureSlice = destinationTextureSlice.ToRefreshTextureSlice();
@ -871,7 +897,8 @@ namespace MoonWorks.Graphics
public void CopyTextureToBuffer(
in TextureSlice textureSlice,
Buffer buffer
) {
)
{
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
Refresh.Refresh_CopyTextureToBuffer(

View File

@ -18,7 +18,8 @@ namespace MoonWorks.Graphics
Refresh.PresentMode presentMode,
bool debugMode,
int initialCommandBufferPoolSize = 4
) {
)
{
var presentationParameters = new Refresh.PresentationParameters
{
deviceWindowHandle = deviceWindowHandle,

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -104,7 +104,7 @@ namespace MoonWorks.Graphics
internal static float Convert(ushort value)
{
uint rst;
uint mantissa = (uint)(value & 1023);
uint mantissa = (uint) (value & 1023);
uint exp = 0xfffffff2;
if ((value & -33792) == 0)

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -192,7 +192,7 @@ namespace MoonWorks.Graphics
static ulong Pack(float x, float y, float z, float w)
{
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(z, -32768, 32767)) << 32) & 0xFFFF00000000) |
((long) System.Math.Round(MathHelper.Clamp(w, -32768, 32767)) << 48)

View File

@ -107,10 +107,10 @@ namespace MoonWorks.Graphics
{
return new Refresh.StencilOpState
{
failOp = (Refresh.StencilOp)FailOp,
passOp = (Refresh.StencilOp)PassOp,
depthFailOp = (Refresh.StencilOp)DepthFailOp,
compareOp = (Refresh.CompareOp)CompareOp,
failOp = (Refresh.StencilOp) FailOp,
passOp = (Refresh.StencilOp) PassOp,
depthFailOp = (Refresh.StencilOp) DepthFailOp,
compareOp = (Refresh.CompareOp) CompareOp,
compareMask = CompareMask,
writeMask = WriteMask,
reference = Reference

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
using RefreshCS;
@ -46,7 +46,7 @@ namespace MoonWorks.Graphics
Refresh.Refresh_GetBufferData(
Device.Handle,
Handle,
(IntPtr)ptr,
(IntPtr) ptr,
dataLengthInBytes
);
}

View File

@ -15,7 +15,8 @@ namespace MoonWorks.Graphics
ShaderStageState computeShaderState,
uint bufferBindingCount,
uint imageBindingCount
) : base(device) {
) : base(device)
{
var computePipelineLayoutCreateInfo = new Refresh.ComputePipelineLayoutCreateInfo
{
bufferBindingCount = bufferBindingCount,

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using RefreshCS;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
using RefreshCS;
@ -88,20 +88,20 @@ namespace MoonWorks.Graphics
refreshGraphicsPipelineCreateInfo.fragmentShaderState.shaderModule = fragmentShaderState.ShaderModule.Handle;
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.pipelineLayoutCreateInfo.vertexSamplerBindingCount = pipelineLayoutInfo.VertexSamplerBindingCount;
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.depthBiasConstantFactor = rasterizerState.DepthBiasConstantFactor;
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasEnable = Conversions.BoolToByte(rasterizerState.DepthBiasEnable);
refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasSlopeFactor = rasterizerState.DepthBiasSlopeFactor;
refreshGraphicsPipelineCreateInfo.rasterizerState.depthClampEnable = Conversions.BoolToByte(rasterizerState.DepthClampEnable);
refreshGraphicsPipelineCreateInfo.rasterizerState.fillMode = (Refresh.FillMode)rasterizerState.FillMode;
refreshGraphicsPipelineCreateInfo.rasterizerState.frontFace = (Refresh.FrontFace)rasterizerState.FrontFace;
refreshGraphicsPipelineCreateInfo.rasterizerState.fillMode = (Refresh.FillMode) rasterizerState.FillMode;
refreshGraphicsPipelineCreateInfo.rasterizerState.frontFace = (Refresh.FrontFace) rasterizerState.FrontFace;
refreshGraphicsPipelineCreateInfo.rasterizerState.lineWidth = rasterizerState.LineWidth;
refreshGraphicsPipelineCreateInfo.vertexInputState.vertexAttributes = vertexAttributesHandle.AddrOfPinnedObject();

View File

@ -48,8 +48,8 @@ namespace MoonWorks.Graphics
fixed (ColorTargetDescription* colorPtr = colorTargetDescriptions)
{
Refresh.RenderPassCreateInfo renderPassCreateInfo;
renderPassCreateInfo.colorTargetCount = (uint)colorTargetDescriptions.Length;
renderPassCreateInfo.colorTargetDescriptions = (IntPtr)colorPtr;
renderPassCreateInfo.colorTargetCount = (uint) colorTargetDescriptions.Length;
renderPassCreateInfo.colorTargetDescriptions = (IntPtr) colorPtr;
renderPassCreateInfo.depthStencilTargetDescription = (IntPtr) depthStencilPtr;
Handle = Refresh.Refresh_CreateRenderPass(device.Handle, renderPassCreateInfo);

View File

@ -32,7 +32,8 @@ namespace MoonWorks.Graphics
bool canBeSampled,
SampleCount sampleCount = SampleCount.One,
uint levelCount = 1
) {
)
{
TextureUsageFlags flags = 0;
if (
@ -40,7 +41,8 @@ namespace MoonWorks.Graphics
format == TextureFormat.D32 ||
format == TextureFormat.D16S8 ||
format == TextureFormat.D32S8
) {
)
{
flags |= TextureUsageFlags.DepthStencilTarget;
}
else

View File

@ -1,4 +1,4 @@
using System;
using System;
using RefreshCS;
namespace MoonWorks.Graphics

View File

@ -36,11 +36,11 @@ namespace MoonWorks.Graphics
out var channels
);
var byteCount = (uint)(width * height * channels);
var byteCount = (uint) (width * height * channels);
TextureCreateInfo textureCreateInfo;
textureCreateInfo.Width = (uint)width;
textureCreateInfo.Height = (uint)height;
textureCreateInfo.Width = (uint) width;
textureCreateInfo.Height = (uint) height;
textureCreateInfo.Depth = 1;
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
textureCreateInfo.IsCube = false;
@ -82,7 +82,8 @@ namespace MoonWorks.Graphics
TextureUsageFlags usageFlags,
SampleCount sampleCount = SampleCount.One,
uint levelCount = 1
) {
)
{
var textureCreateInfo = new TextureCreateInfo
{
Width = width,
@ -118,7 +119,8 @@ namespace MoonWorks.Graphics
TextureUsageFlags usageFlags,
SampleCount sampleCount = SampleCount.One,
uint levelCount = 1
) {
)
{
var textureCreateInfo = new TextureCreateInfo
{
Width = width,
@ -150,7 +152,8 @@ namespace MoonWorks.Graphics
TextureUsageFlags usageFlags,
SampleCount sampleCount = SampleCount.One,
uint levelCount = 1
) {
)
{
var textureCreateInfo = new TextureCreateInfo
{
Width = size,

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Describes how the graphics pipeline will blend colors.

View File

@ -108,13 +108,13 @@ namespace MoonWorks.Graphics
return new Refresh.ColorTargetBlendState
{
blendEnable = Conversions.BoolToByte(BlendEnable),
alphaBlendOp = (Refresh.BlendOp)AlphaBlendOp,
colorBlendOp = (Refresh.BlendOp)ColorBlendOp,
colorWriteMask = (Refresh.ColorComponentFlags)ColorWriteMask,
destinationAlphaBlendFactor = (Refresh.BlendFactor)DestinationAlphaBlendFactor,
destinationColorBlendFactor = (Refresh.BlendFactor)DestinationColorBlendFactor,
sourceAlphaBlendFactor = (Refresh.BlendFactor)SourceAlphaBlendFactor,
sourceColorBlendFactor = (Refresh.BlendFactor)SourceColorBlendFactor
alphaBlendOp = (Refresh.BlendOp) AlphaBlendOp,
colorBlendOp = (Refresh.BlendOp) ColorBlendOp,
colorWriteMask = (Refresh.ColorComponentFlags) ColorWriteMask,
destinationAlphaBlendFactor = (Refresh.BlendFactor) DestinationAlphaBlendFactor,
destinationColorBlendFactor = (Refresh.BlendFactor) DestinationColorBlendFactor,
sourceAlphaBlendFactor = (Refresh.BlendFactor) SourceAlphaBlendFactor,
sourceColorBlendFactor = (Refresh.BlendFactor) SourceColorBlendFactor
};
}
}

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Determines how data is written to and read from the depth/stencil buffer.

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
public struct GraphicsPipelineCreateInfo
{

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Describes how many samplers will be used in each shader stage.

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Specifies how many samples should be used in rasterization.

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Specifies how the rasterizer should be configured for a graphics pipeline.

View File

@ -115,20 +115,20 @@ namespace MoonWorks.Graphics
{
return new Refresh.SamplerStateCreateInfo
{
minFilter = (Refresh.Filter)MinFilter,
magFilter = (Refresh.Filter)MagFilter,
mipmapMode = (Refresh.SamplerMipmapMode)MipmapMode,
addressModeU = (Refresh.SamplerAddressMode)AddressModeU,
addressModeV = (Refresh.SamplerAddressMode)AddressModeV,
addressModeW = (Refresh.SamplerAddressMode)AddressModeW,
minFilter = (Refresh.Filter) MinFilter,
magFilter = (Refresh.Filter) MagFilter,
mipmapMode = (Refresh.SamplerMipmapMode) MipmapMode,
addressModeU = (Refresh.SamplerAddressMode) AddressModeU,
addressModeV = (Refresh.SamplerAddressMode) AddressModeV,
addressModeW = (Refresh.SamplerAddressMode) AddressModeW,
mipLodBias = MipLodBias,
anisotropyEnable = Conversions.BoolToByte(AnisotropyEnable),
maxAnisotropy = MaxAnisotropy,
compareEnable = Conversions.BoolToByte(CompareEnable),
compareOp = (Refresh.CompareOp)CompareOp,
compareOp = (Refresh.CompareOp) CompareOp,
minLod = MinLod,
maxLod = MaxLod,
borderColor = (Refresh.BorderColor)BorderColor
borderColor = (Refresh.BorderColor) BorderColor
};
}
}

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Specifies how the graphics pipeline will make use of a shader.

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Specifies how to interpet vertex data in a buffer to be passed to the vertex shader.

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
/// <summary>
/// Describes the dimensions of viewports and scissor areas.

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{
public struct BlendConstants
{

View File

@ -10,7 +10,7 @@ namespace MoonWorks.Graphics
int size;
using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
size = (int)stream.Length;
size = (int) stream.Length;
data = new byte[size];
stream.Read(data, 0, size);
}

View File

@ -1,10 +1,10 @@
namespace MoonWorks
namespace MoonWorks
{
public static class Conversions
{
public static byte BoolToByte(bool b)
{
return (byte)(b ? 1 : 0);
return (byte) (b ? 1 : 0);
}
public static bool ByteToBool(byte b)

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Input
namespace MoonWorks.Input
{
public class ButtonState
{

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Input
namespace MoonWorks.Input
{
internal enum ButtonStatus
{

View File

@ -1,4 +1,4 @@
using System;
using System;
using MoonWorks.Math;
using SDL2;
@ -40,8 +40,8 @@ namespace MoonWorks.Input
{
return SDL.SDL_GameControllerRumble(
Handle,
(ushort)(MathHelper.Clamp(leftMotor, 0f, 1f) * 0xFFFF),
(ushort)(MathHelper.Clamp(rightMotor, 0f, 1f) * 0xFFFF),
(ushort) (MathHelper.Clamp(leftMotor, 0f, 1f) * 0xFFFF),
(ushort) (MathHelper.Clamp(rightMotor, 0f, 1f) * 0xFFFF),
durationInMilliseconds
) == 0;
}

View File

@ -1,4 +1,4 @@
using SDL2;
using SDL2;
using System;
using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using SDL2;
@ -39,7 +39,7 @@ namespace MoonWorks.Input
Keys = new ButtonState[numKeys];
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 (TextInputBindings.TryGetValue((Keycode)keycode, out var textIndex))
if (TextInputBindings.TryGetValue((Keycode) keycode, out var 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]);
}
@ -68,22 +68,22 @@ namespace MoonWorks.Input
public bool IsDown(Keycode keycode)
{
return Keys[(int)keycode].IsDown;
return Keys[(int) keycode].IsDown;
}
public bool IsPressed(Keycode keycode)
{
return Keys[(int)keycode].IsPressed;
return Keys[(int) keycode].IsPressed;
}
public bool IsHeld(Keycode keycode)
{
return Keys[(int)keycode].IsHeld;
return Keys[(int) keycode].IsHeld;
}
public bool IsReleased(Keycode keycode)
{
return Keys[(int)keycode].IsReleased;
return Keys[(int) keycode].IsReleased;
}
}
}

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Input
namespace MoonWorks.Input
{
// Enum values are equivalent to the SDL Scancode value.
public enum Keycode : int

View File

@ -1,4 +1,4 @@
using System;
using System;
using RefreshCS;
namespace MoonWorks

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -91,23 +91,23 @@ namespace MoonWorks.Math
public ContainmentType Contains(BoundingBox box)
{
// 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.Max.Y < Min.Y ||
box.Min.Y > Max.Y ||
box.Max.Z < Min.Z ||
box.Min.Z > Max.Z )
box.Min.Z > Max.Z)
{
return ContainmentType.Disjoint;
}
if ( box.Min.X >= Min.X &&
if (box.Min.X >= Min.X &&
box.Max.X <= Max.X &&
box.Min.Y >= Min.Y &&
box.Max.Y <= Max.Y &&
box.Min.Z >= Min.Z &&
box.Max.Z <= Max.Z )
box.Max.Z <= Max.Z)
{
return ContainmentType.Contains;
}
@ -172,12 +172,12 @@ namespace MoonWorks.Math
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.Z - Min.Z >= sphere.Radius &&
Max.X - sphere.Center.X >= 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;
}
@ -261,12 +261,12 @@ namespace MoonWorks.Math
public void Contains(ref Vector3 point, out ContainmentType result)
{
// 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.Y < this.Min.Y ||
point.Y > this.Max.Y ||
point.Z < this.Min.Z ||
point.Z > this.Max.Z )
point.Z > this.Max.Z)
{
result = ContainmentType.Disjoint;
}
@ -380,12 +380,12 @@ namespace MoonWorks.Math
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.Z - Min.Z > sphere.Radius &&
Max.X - sphere.Center.X > 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;
}

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -597,7 +597,8 @@ namespace MoonWorks.Math
ref Plane b,
ref Plane c,
out Vector3 result
) {
)
{
/* Formula used
* d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 )
* P = -------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* 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>
public bool Equals(BoundingSphere other)
{
return ( Center == other.Center &&
Radius == other.Radius );
return (Center == other.Center &&
Radius == other.Radius);
}
#endregion
@ -474,7 +474,8 @@ namespace MoonWorks.Math
ref BoundingSphere original,
ref BoundingSphere additional,
out BoundingSphere result
) {
)
{
Vector3 ocenterToaCenter = Vector3.Subtract(additional.Center, original.Center);
float distance = ocenterToaCenter.Length();

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -98,7 +98,8 @@ namespace MoonWorks.Math
float value3,
float amount1,
float amount2
) {
)
{
return value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2;
}
@ -117,7 +118,8 @@ namespace MoonWorks.Math
float value3,
float value4,
float amount
) {
)
{
/* Using formula from http://www.mvps.org/directx/articles/catmull/
* Internally using doubles not to lose precision.
*/
@ -184,7 +186,8 @@ namespace MoonWorks.Math
float value2,
float tangent2,
float amount
) {
)
{
/* All transformed to double not to lose precision
* Otherwise, for high numbers of param:amount the result is NaN instead
* of Infinity.

View File

@ -1,4 +1,4 @@
/* MoonWorks - Game Development Framework
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
*/
@ -284,8 +284,8 @@ namespace MoonWorks.Math
{
Matrix3x2 result;
float xTan = (float)System.Math.Tan(radiansX);
float yTan = (float)System.Math.Tan(radiansY);
float xTan = (float) System.Math.Tan(radiansX);
float yTan = (float) System.Math.Tan(radiansY);
result.M11 = 1.0f;
result.M12 = yTan;
@ -308,8 +308,8 @@ namespace MoonWorks.Math
{
Matrix3x2 result;
float xTan = (float)System.Math.Tan(radiansX);
float yTan = (float)System.Math.Tan(radiansY);
float xTan = (float) System.Math.Tan(radiansX);
float yTan = (float) System.Math.Tan(radiansY);
float tx = -centerPoint.Y * xTan;
float ty = -centerPoint.X * yTan;
@ -333,11 +333,11 @@ namespace MoonWorks.Math
{
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;
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)
{
@ -366,8 +366,8 @@ namespace MoonWorks.Math
else
{
// Arbitrary rotation.
c = (float)System.Math.Cos(radians);
s = (float)System.Math.Sin(radians);
c = (float) System.Math.Cos(radians);
s = (float) System.Math.Sin(radians);
}
// [ c s ]
@ -393,11 +393,11 @@ namespace MoonWorks.Math
{
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;
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)
{
@ -426,8 +426,8 @@ namespace MoonWorks.Math
else
{
// Arbitrary rotation.
c = (float)System.Math.Cos(radians);
s = (float)System.Math.Sin(radians);
c = (float) System.Math.Cos(radians);
s = (float) System.Math.Sin(radians);
}
float x = centerPoint.X * (1 - c) + centerPoint.Y * s;
@ -793,7 +793,7 @@ namespace MoonWorks.Math
{
if (obj is Matrix3x2)
{
return Equals((Matrix3x2)obj);
return Equals((Matrix3x2) obj);
}
return false;

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -316,7 +316,8 @@ namespace MoonWorks.Math
float m21, float m22, float m23, float m24,
float m31, float m32, float m33, float m34,
float m41, float m42, float m43, float m44
) {
)
{
M11 = m11;
M12 = m12;
M13 = m13;
@ -350,7 +351,8 @@ namespace MoonWorks.Math
out Vector3 scale,
out Quaternion rotation,
out Vector3 translation
) {
)
{
translation.X = M41;
translation.Y = M42;
translation.Z = M43;
@ -363,9 +365,9 @@ namespace MoonWorks.Math
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);
if ( MathHelper.WithinEpsilon(scale.X, 0.0f) ||
if (MathHelper.WithinEpsilon(scale.X, 0.0f) ||
MathHelper.WithinEpsilon(scale.Y, 0.0f) ||
MathHelper.WithinEpsilon(scale.Z, 0.0f) )
MathHelper.WithinEpsilon(scale.Z, 0.0f))
{
rotation = Quaternion.Identity;
return false;
@ -413,7 +415,7 @@ namespace MoonWorks.Math
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
public bool Equals(Matrix4x4 other)
{
return ( M11 == other.M11 &&
return (M11 == other.M11 &&
M12 == other.M12 &&
M13 == other.M13 &&
M14 == other.M14 &&
@ -428,7 +430,7 @@ namespace MoonWorks.Math
M41 == other.M41 &&
M42 == other.M42 &&
M43 == other.M43 &&
M44 == other.M44 );
M44 == other.M44);
}
/// <summary>
@ -555,7 +557,8 @@ namespace MoonWorks.Math
Vector3 cameraPosition,
Vector3 cameraUpVector,
Nullable<Vector3> cameraForwardVector
) {
)
{
Matrix4x4 result;
// Delegate to the other overload of the function to do the work
@ -584,7 +587,8 @@ namespace MoonWorks.Math
ref Vector3 cameraUpVector,
Vector3? cameraForwardVector,
out Matrix4x4 result
) {
)
{
Vector3 vector;
Vector3 vector2;
Vector3 vector3;
@ -642,7 +646,8 @@ namespace MoonWorks.Math
Vector3 rotateAxis,
Nullable<Vector3> cameraForwardVector,
Nullable<Vector3> objectForwardVector
) {
)
{
Matrix4x4 result;
CreateConstrainedBillboard(
ref objectPosition,
@ -671,7 +676,8 @@ namespace MoonWorks.Math
Vector3? cameraForwardVector,
Vector3? objectForwardVector,
out Matrix4x4 result
) {
)
{
float num;
Vector3 vector;
Vector3 vector2;
@ -777,7 +783,8 @@ namespace MoonWorks.Math
ref Vector3 axis,
float angle,
out Matrix4x4 result
) {
)
{
float x = axis.X;
float y = axis.Y;
float z = axis.Z;
@ -883,7 +890,8 @@ namespace MoonWorks.Math
float pitch,
float roll,
out Matrix4x4 result
) {
)
{
Quaternion quaternion;
Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll, out quaternion);
CreateFromQuaternion(ref quaternion, out result);
@ -900,7 +908,8 @@ namespace MoonWorks.Math
Vector3 cameraPosition,
Vector3 cameraTarget,
Vector3 cameraUpVector
) {
)
{
Matrix4x4 matrix;
CreateLookAt(ref cameraPosition, ref cameraTarget, ref cameraUpVector, out matrix);
return matrix;
@ -918,7 +927,8 @@ namespace MoonWorks.Math
ref Vector3 cameraTarget,
ref Vector3 cameraUpVector,
out Matrix4x4 result
) {
)
{
Vector3 vectorA = Vector3.Normalize(cameraPosition - cameraTarget);
Vector3 vectorB = Vector3.Normalize(Vector3.Cross(cameraUpVector, vectorA));
Vector3 vectorC = Vector3.Cross(vectorA, vectorB);
@ -953,7 +963,8 @@ namespace MoonWorks.Math
float height,
float zNearPlane,
float zFarPlane
) {
)
{
Matrix4x4 matrix;
CreateOrthographic(width, height, zNearPlane, zFarPlane, out matrix);
return matrix;
@ -973,7 +984,8 @@ namespace MoonWorks.Math
float zNearPlane,
float zFarPlane,
out Matrix4x4 result
) {
)
{
result.M11 = 2f / width;
result.M12 = result.M13 = result.M14 = 0f;
result.M22 = 2f / height;
@ -1002,7 +1014,8 @@ namespace MoonWorks.Math
float top,
float zNearPlane,
float zFarPlane
) {
)
{
Matrix4x4 matrix;
CreateOrthographicOffCenter(
left,
@ -1034,7 +1047,8 @@ namespace MoonWorks.Math
float zNearPlane,
float zFarPlane,
out Matrix4x4 result
) {
)
{
result.M11 = (float) (2.0 / ((double) right - (double) left));
result.M12 = 0.0f;
result.M13 = 0.0f;
@ -1075,7 +1089,8 @@ namespace MoonWorks.Math
float height,
float nearPlaneDistance,
float farPlaneDistance
) {
)
{
Matrix4x4 matrix;
CreatePerspective(width, height, nearPlaneDistance, farPlaneDistance, out matrix);
return matrix;
@ -1095,7 +1110,8 @@ namespace MoonWorks.Math
float nearPlaneDistance,
float farPlaneDistance,
out Matrix4x4 result
) {
)
{
if (nearPlaneDistance <= 0f)
{
throw new ArgumentException("nearPlaneDistance <= 0");
@ -1135,7 +1151,8 @@ namespace MoonWorks.Math
float aspectRatio,
float nearPlaneDistance,
float farPlaneDistance
) {
)
{
Matrix4x4 result;
CreatePerspectiveFieldOfView(
fieldOfView,
@ -1161,7 +1178,8 @@ namespace MoonWorks.Math
float nearPlaneDistance,
float farPlaneDistance,
out Matrix4x4 result
) {
)
{
if ((fieldOfView <= 0f) || (fieldOfView >= 3.141593f))
{
throw new ArgumentException("fieldOfView <= 0 or >= PI");
@ -1210,7 +1228,8 @@ namespace MoonWorks.Math
float top,
float nearPlaneDistance,
float farPlaneDistance
) {
)
{
Matrix4x4 result;
CreatePerspectiveOffCenter(
left,
@ -1242,7 +1261,8 @@ namespace MoonWorks.Math
float nearPlaneDistance,
float farPlaneDistance,
out Matrix4x4 result
) {
)
{
if (nearPlaneDistance <= 0f)
{
throw new ArgumentException("nearPlaneDistance <= 0");
@ -1408,7 +1428,8 @@ namespace MoonWorks.Math
float yScale,
float zScale,
out Matrix4x4 result
) {
)
{
result.M11 = xScale;
result.M12 = 0;
result.M13 = 0;
@ -1527,7 +1548,8 @@ namespace MoonWorks.Math
float xPosition,
float yPosition,
float zPosition
) {
)
{
Matrix4x4 result;
CreateTranslation(xPosition, yPosition, zPosition, out result);
return result;
@ -1582,7 +1604,8 @@ namespace MoonWorks.Math
float yPosition,
float zPosition,
out Matrix4x4 result
) {
)
{
result.M11 = 1;
result.M12 = 0;
result.M13 = 0;
@ -1672,7 +1695,8 @@ namespace MoonWorks.Math
ref Vector3 forward,
ref Vector3 up,
out Matrix4x4 result
) {
)
{
Vector3 x, y, z;
Vector3.Normalize(ref forward, out z);
Vector3.Cross(ref forward, ref up, out x);
@ -2069,7 +2093,8 @@ namespace MoonWorks.Math
ref Matrix4x4 matrix2,
float amount,
out Matrix4x4 result
) {
)
{
result.M11 = matrix1.M11 + ((matrix2.M11 - matrix1.M11) * amount);
result.M12 = matrix1.M12 + ((matrix2.M12 - matrix1.M12) * amount);
result.M13 = matrix1.M13 + ((matrix2.M13 - matrix1.M13) * amount);
@ -2097,7 +2122,8 @@ namespace MoonWorks.Math
public static Matrix4x4 Multiply(
Matrix4x4 matrix1,
Matrix4x4 matrix2
) {
)
{
float m11 = (
(matrix1.M11 * matrix2.M11) +
(matrix1.M12 * matrix2.M21) +
@ -2548,7 +2574,8 @@ namespace MoonWorks.Math
ref Matrix4x4 value,
ref Quaternion rotation,
out Matrix4x4 result
) {
)
{
Matrix4x4 rotMatrix = CreateFromQuaternion(rotation);
Multiply(ref value, ref rotMatrix, out result);
}

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -233,7 +233,8 @@ namespace MoonWorks.Math
ref Plane plane,
ref Matrix4x4 matrix,
out Plane result
) {
)
{
/* See "Transforming Normals" in
* http://www.glprogramming.com/red/appendixf.html
* for an explanation of how this works.
@ -277,7 +278,8 @@ namespace MoonWorks.Math
ref Plane plane,
ref Quaternion rotation,
out Plane result
) {
)
{
Vector3.Transform(
ref plane.Normal,
ref rotation,

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* 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>
public bool Equals(Quaternion other)
{
return ( X == other.X &&
return (X == other.X &&
Y == other.Y &&
Z == other.Z &&
W == other.W );
W == other.W);
}
/// <summary>
@ -266,7 +266,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion1,
ref Quaternion quaternion2,
out Quaternion result
) {
)
{
result.X = quaternion1.X + quaternion2.X;
result.Y = quaternion1.Y + quaternion2.Y;
result.Z = quaternion1.Z + quaternion2.Z;
@ -296,7 +297,8 @@ namespace MoonWorks.Math
ref Quaternion value1,
ref Quaternion value2,
out Quaternion result
) {
)
{
float x1 = value1.X;
float y1 = value1.Y;
float z1 = value1.Z;
@ -359,7 +361,8 @@ namespace MoonWorks.Math
ref Vector3 axis,
float angle,
out Quaternion result
) {
)
{
float half = angle * 0.5f;
float sin = (float) System.Math.Sin((double) half);
float cos = (float) System.Math.Cos((double) half);
@ -415,12 +418,12 @@ namespace MoonWorks.Math
else if (matrix.M22 > 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.Y = 0.5f*sqrt;
result.Z = (matrix.M32 + matrix.M23)*half;
result.W = (matrix.M31 - matrix.M13)*half;
result.X = (matrix.M21 + matrix.M12) * half;
result.Y = 0.5f * sqrt;
result.Z = (matrix.M32 + matrix.M23) * half;
result.W = (matrix.M31 - matrix.M13) * half;
}
else
{
@ -499,7 +502,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion1,
ref Quaternion quaternion2,
out Quaternion result
) {
)
{
float x = quaternion1.X;
float y = quaternion1.Y;
float z = quaternion1.Z;
@ -551,7 +555,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion1,
ref Quaternion quaternion2,
out float result
) {
)
{
result = (
(quaternion1.X * quaternion2.X) +
(quaternion1.Y * quaternion2.Y) +
@ -603,7 +608,8 @@ namespace MoonWorks.Math
Quaternion quaternion1,
Quaternion quaternion2,
float amount
) {
)
{
Quaternion quaternion;
Lerp(ref quaternion1, ref quaternion2, amount, out quaternion);
return quaternion;
@ -621,7 +627,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion2,
float amount,
out Quaternion result
) {
)
{
float num = amount;
float num2 = 1f - num;
float num5 = (
@ -668,7 +675,8 @@ namespace MoonWorks.Math
Quaternion quaternion1,
Quaternion quaternion2,
float amount
) {
)
{
Quaternion quaternion;
Slerp(ref quaternion1, ref quaternion2, amount, out quaternion);
return quaternion;
@ -686,7 +694,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion2,
float amount,
out Quaternion result
) {
)
{
float num2;
float num3;
float num = amount;
@ -743,7 +752,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion1,
ref Quaternion quaternion2,
out Quaternion result
) {
)
{
result.X = quaternion1.X - quaternion2.X;
result.Y = quaternion1.Y - quaternion2.Y;
result.Z = quaternion1.Z - quaternion2.Z;
@ -786,7 +796,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion1,
ref Quaternion quaternion2,
out Quaternion result
) {
)
{
float x = quaternion1.X;
float y = quaternion1.Y;
float z = quaternion1.Z;
@ -815,7 +826,8 @@ namespace MoonWorks.Math
ref Quaternion quaternion1,
float scaleFactor,
out Quaternion result
) {
)
{
result.X = quaternion1.X * scaleFactor;
result.Y = quaternion1.Y * scaleFactor;
result.Z = quaternion1.Z * scaleFactor;

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -70,8 +70,8 @@ namespace MoonWorks.Math
public bool Equals(Ray other)
{
return ( this.Position.Equals(other.Position) &&
this.Direction.Equals(other.Direction) );
return (this.Position.Equals(other.Position) &&
this.Direction.Equals(other.Direction));
}
@ -124,8 +124,8 @@ namespace MoonWorks.Math
tMaxY = temp;
}
if ( (tMin.HasValue && tMin > tMaxY) ||
(tMax.HasValue && tMinY > tMax) )
if ((tMin.HasValue && tMin > tMaxY) ||
(tMax.HasValue && tMinY > tMax))
{
return null;
}
@ -153,8 +153,8 @@ namespace MoonWorks.Math
tMaxZ = temp;
}
if ( (tMin.HasValue && tMin > tMaxZ) ||
(tMax.HasValue && tMinZ > tMax) )
if ((tMin.HasValue && tMin > tMaxZ) ||
(tMax.HasValue && tMinZ > tMax))
{
return null;
}

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -117,10 +117,10 @@ namespace MoonWorks.Math
{
get
{
return ( (Width == 0) &&
return ((Width == 0) &&
(Height == 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>
public bool Contains(int x, int y)
{
return ( (this.X <= x) &&
return ((this.X <= x) &&
(x < (this.X + this.Width)) &&
(this.Y <= y) &&
(y < (this.Y + this.Height)) );
(y < (this.Y + this.Height)));
}
/// <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>
public bool Contains(Point value)
{
return ( (this.X <= value.X) &&
return ((this.X <= value.X) &&
(value.X < (this.X + this.Width)) &&
(this.Y <= value.Y) &&
(value.Y < (this.Y + this.Height)) );
(value.Y < (this.Y + this.Height)));
}
/// <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>
public bool Contains(Rectangle value)
{
return ( (this.X <= value.X) &&
return ((this.X <= value.X) &&
((value.X + value.Width) <= (this.X + this.Width)) &&
(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)
{
result = ( (this.X <= value.X) &&
result = ((this.X <= value.X) &&
(value.X < (this.X + this.Width)) &&
(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)
{
result = ( (this.X <= value.X) &&
result = ((this.X <= value.X) &&
((value.X + value.Width) <= (this.X + this.Width)) &&
(this.Y <= value.Y) &&
((value.Y + value.Height) <= (this.Y + this.Height)) );
((value.Y + value.Height) <= (this.Y + this.Height)));
}
/// <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>
public bool Intersects(Rectangle value)
{
return ( value.Left < Right &&
return (value.Left < Right &&
Left < value.Right &&
value.Top < Bottom &&
Top < value.Bottom );
Top < value.Bottom);
}
/// <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>
public void Intersects(ref Rectangle value, out bool result)
{
result = ( value.Left < Right &&
result = (value.Left < Right &&
Left < value.Right &&
value.Top < Bottom &&
Top < value.Bottom );
Top < value.Bottom);
}
#endregion
@ -374,10 +374,10 @@ namespace MoonWorks.Math
public static bool operator ==(Rectangle a, Rectangle b)
{
return ( (a.X == b.X) &&
return ((a.X == b.X) &&
(a.Y == b.Y) &&
(a.Width == b.Width) &&
(a.Height == b.Height) );
(a.Height == b.Height));
}
public static bool operator !=(Rectangle a, Rectangle b)
@ -396,7 +396,8 @@ namespace MoonWorks.Math
ref Rectangle value1,
ref Rectangle value2,
out Rectangle result
) {
)
{
if (value1.Intersects(value2))
{
int right_side = System.Math.Min(

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* 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>
public bool Equals(Vector2 other)
{
return ( X == other.X &&
Y == other.Y );
return (X == other.X &&
Y == other.Y);
}
/// <summary>
@ -264,7 +264,8 @@ namespace MoonWorks.Math
Vector2 value3,
float amount1,
float amount2
) {
)
{
return new Vector2(
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2)
@ -287,7 +288,8 @@ namespace MoonWorks.Math
float amount1,
float amount2,
out Vector2 result
) {
)
{
result.X = MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2);
result.Y = MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
}
@ -307,7 +309,8 @@ namespace MoonWorks.Math
Vector2 value3,
Vector2 value4,
float amount
) {
)
{
return new Vector2(
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount)
@ -330,7 +333,8 @@ namespace MoonWorks.Math
ref Vector2 value4,
float amount,
out Vector2 result
) {
)
{
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);
}
@ -362,7 +366,8 @@ namespace MoonWorks.Math
ref Vector2 min,
ref Vector2 max,
out Vector2 result
) {
)
{
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
}
@ -413,7 +418,8 @@ namespace MoonWorks.Math
ref Vector2 value1,
ref Vector2 value2,
out float result
) {
)
{
float v1 = value1.X - value2.X, v2 = value1.Y - value2.Y;
result = (v1 * v1) + (v2 * v2);
}
@ -507,7 +513,8 @@ namespace MoonWorks.Math
Vector2 value2,
Vector2 tangent2,
float amount
) {
)
{
Vector2 result = new Vector2();
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
return result;
@ -529,7 +536,8 @@ namespace MoonWorks.Math
ref Vector2 tangent2,
float amount,
out Vector2 result
) {
)
{
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);
}
@ -561,7 +569,8 @@ namespace MoonWorks.Math
ref Vector2 value2,
float amount,
out Vector2 result
) {
)
{
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
}
@ -773,7 +782,8 @@ namespace MoonWorks.Math
ref Vector2 value2,
float amount,
out Vector2 result
) {
)
{
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
}
@ -827,7 +837,8 @@ namespace MoonWorks.Math
ref Vector2 position,
ref Matrix4x4 matrix,
out Vector2 result
) {
)
{
float x = (position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M41;
float y = (position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M42;
result.X = x;
@ -856,7 +867,8 @@ namespace MoonWorks.Math
ref Vector2 value,
ref Quaternion rotation,
out Vector2 result
) {
)
{
float x = 2 * -(rotation.Z * value.Y);
float y = 2 * (rotation.Z * value.X);
float z = 2 * (rotation.X * value.Y - rotation.Y * value.X);
@ -875,7 +887,8 @@ namespace MoonWorks.Math
Vector2[] sourceArray,
ref Matrix4x4 matrix,
Vector2[] destinationArray
) {
)
{
Transform(sourceArray, 0, ref matrix, destinationArray, 0, sourceArray.Length);
}
@ -895,7 +908,8 @@ namespace MoonWorks.Math
Vector2[] destinationArray,
int destinationIndex,
int length
) {
)
{
for (int x = 0; x < length; x += 1)
{
Vector2 position = sourceArray[sourceIndex + x];
@ -918,7 +932,8 @@ namespace MoonWorks.Math
Vector2[] sourceArray,
ref Quaternion rotation,
Vector2[] destinationArray
) {
)
{
Transform(
sourceArray,
0,
@ -945,7 +960,8 @@ namespace MoonWorks.Math
Vector2[] destinationArray,
int destinationIndex,
int length
) {
)
{
for (int i = 0; i < length; i += 1)
{
Vector2 position = sourceArray[sourceIndex + i];
@ -979,7 +995,8 @@ namespace MoonWorks.Math
ref Vector2 normal,
ref Matrix4x4 matrix,
out Vector2 result
) {
)
{
float x = (normal.X * matrix.M11) + (normal.Y * matrix.M21);
float y = (normal.X * matrix.M12) + (normal.Y * matrix.M22);
result.X = x;
@ -996,7 +1013,8 @@ namespace MoonWorks.Math
Vector2[] sourceArray,
ref Matrix4x4 matrix,
Vector2[] destinationArray
) {
)
{
TransformNormal(
sourceArray,
0,
@ -1023,7 +1041,8 @@ namespace MoonWorks.Math
Vector2[] destinationArray,
int destinationIndex,
int length
) {
)
{
for (int i = 0; i < length; i += 1)
{
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>
public static bool operator ==(Vector2 value1, Vector2 value2)
{
return ( value1.X == value2.X &&
value1.Y == value2.Y );
return (value1.X == value2.X &&
value1.Y == value2.Y);
}
/// <summary>

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* 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>
public bool Equals(Vector3 other)
{
return ( X == other.X &&
return (X == other.X &&
Y == other.Y &&
Z == other.Z );
Z == other.Z);
}
/// <summary>
@ -383,7 +383,8 @@ namespace MoonWorks.Math
Vector3 value3,
float amount1,
float amount2
) {
)
{
return new Vector3(
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
@ -407,7 +408,8 @@ namespace MoonWorks.Math
float amount1,
float amount2,
out Vector3 result
) {
)
{
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.Z = MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
@ -428,7 +430,8 @@ namespace MoonWorks.Math
Vector3 value3,
Vector3 value4,
float amount
) {
)
{
return new Vector3(
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
@ -452,7 +455,8 @@ namespace MoonWorks.Math
ref Vector3 value4,
float amount,
out Vector3 result
) {
)
{
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.Z = MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount);
@ -486,7 +490,8 @@ namespace MoonWorks.Math
ref Vector3 min,
ref Vector3 max,
out Vector3 result
) {
)
{
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
result.Z = MathHelper.Clamp(value1.Z, min.Z, max.Z);
@ -501,7 +506,8 @@ namespace MoonWorks.Math
public static Vector3 ClampMagnitude(
Vector3 value,
float maxLength
) {
)
{
return (value.LengthSquared() > maxLength * maxLength) ? (Vector3.Normalize(value) * maxLength) : value;
}
@ -583,7 +589,8 @@ namespace MoonWorks.Math
ref Vector3 value1,
ref Vector3 value2,
out float result
) {
)
{
result = (
(value1.X - value2.X) * (value1.X - value2.X) +
(value1.Y - value2.Y) * (value1.Y - value2.Y) +
@ -688,7 +695,8 @@ namespace MoonWorks.Math
Vector3 value2,
Vector3 tangent2,
float amount
) {
)
{
Vector3 result = new Vector3();
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
return result;
@ -710,7 +718,8 @@ namespace MoonWorks.Math
ref Vector3 tangent2,
float amount,
out Vector3 result
) {
)
{
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.Z = MathHelper.Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount);
@ -744,7 +753,8 @@ namespace MoonWorks.Math
ref Vector3 value2,
float amount,
out Vector3 result
) {
)
{
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
result.Z = MathHelper.Lerp(value1.Z, value2.Z, amount);
@ -992,7 +1002,8 @@ namespace MoonWorks.Math
ref Vector3 value2,
float amount,
out Vector3 result
) {
)
{
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
result.Z = MathHelper.SmoothStep(value1.Z, value2.Z, amount);
@ -1047,7 +1058,8 @@ namespace MoonWorks.Math
ref Vector3 position,
ref Matrix4x4 matrix,
out Vector3 result
) {
)
{
float x = (
(position.X * matrix.M11) +
(position.Y * matrix.M21) +
@ -1081,7 +1093,8 @@ namespace MoonWorks.Math
Vector3[] sourceArray,
ref Matrix4x4 matrix,
Vector3[] destinationArray
) {
)
{
Debug.Assert(
destinationArray.Length >= sourceArray.Length,
"The destination array is smaller than the source array."
@ -1121,7 +1134,8 @@ namespace MoonWorks.Math
Vector3[] destinationArray,
int destinationIndex,
int length
) {
)
{
Debug.Assert(
sourceArray.Length - sourceIndex >= length,
"The source array is too small for the given sourceIndex and length."
@ -1173,7 +1187,8 @@ namespace MoonWorks.Math
ref Vector3 value,
ref Quaternion rotation,
out Vector3 result
) {
)
{
float x = 2 * (rotation.Y * value.Z - rotation.Z * value.Y);
float y = 2 * (rotation.Z * value.X - rotation.X * value.Z);
float z = 2 * (rotation.X * value.Y - rotation.Y * value.X);
@ -1193,7 +1208,8 @@ namespace MoonWorks.Math
Vector3[] sourceArray,
ref Quaternion rotation,
Vector3[] destinationArray
) {
)
{
Debug.Assert(
destinationArray.Length >= sourceArray.Length,
"The destination array is smaller than the source array."
@ -1236,7 +1252,8 @@ namespace MoonWorks.Math
Vector3[] destinationArray,
int destinationIndex,
int length
) {
)
{
Debug.Assert(
sourceArray.Length - sourceIndex >= length,
"The source array is too small for the given sourceIndex and length."
@ -1289,7 +1306,8 @@ namespace MoonWorks.Math
ref Vector3 normal,
ref Matrix4x4 matrix,
out Vector3 result
) {
)
{
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 z = (normal.X * matrix.M13) + (normal.Y * matrix.M23) + (normal.Z * matrix.M33);
@ -1308,7 +1326,8 @@ namespace MoonWorks.Math
Vector3[] sourceArray,
ref Matrix4x4 matrix,
Vector3[] destinationArray
) {
)
{
Debug.Assert(
destinationArray.Length >= sourceArray.Length,
"The destination array is smaller than the source array."
@ -1339,7 +1358,8 @@ namespace MoonWorks.Math
Vector3[] destinationArray,
int destinationIndex,
int length
) {
)
{
if (sourceArray == null)
{
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>
public static bool operator ==(Vector3 value1, Vector3 value2)
{
return ( value1.X == value2.X &&
return (value1.X == value2.X &&
value1.Y == value2.Y &&
value1.Z == value2.Z );
value1.Z == value2.Z);
}
/// <summary>

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* 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>
public bool Equals(Vector4 other)
{
return ( X == other.X &&
return (X == other.X &&
Y == other.Y &&
Z == other.Z &&
W == other.W );
W == other.W);
}
/// <summary>
@ -344,7 +344,8 @@ namespace MoonWorks.Math
Vector4 value3,
float amount1,
float amount2
) {
)
{
return new Vector4(
MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
@ -369,7 +370,8 @@ namespace MoonWorks.Math
float amount1,
float amount2,
out Vector4 result
) {
)
{
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.Z = MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
@ -391,7 +393,8 @@ namespace MoonWorks.Math
Vector4 value3,
Vector4 value4,
float amount
) {
)
{
return new Vector4(
MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
@ -416,7 +419,8 @@ namespace MoonWorks.Math
ref Vector4 value4,
float amount,
out Vector4 result
) {
)
{
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.Z = MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount);
@ -452,7 +456,8 @@ namespace MoonWorks.Math
ref Vector4 min,
ref Vector4 max,
out Vector4 result
) {
)
{
result.X = MathHelper.Clamp(value1.X, min.X, max.X);
result.Y = MathHelper.Clamp(value1.Y, min.Y, max.Y);
result.Z = MathHelper.Clamp(value1.Z, min.Z, max.Z);
@ -507,7 +512,8 @@ namespace MoonWorks.Math
ref Vector4 value1,
ref Vector4 value2,
out float result
) {
)
{
result = (
(value1.W - value2.W) * (value1.W - value2.W) +
(value1.X - value2.X) * (value1.X - value2.X) +
@ -572,7 +578,8 @@ namespace MoonWorks.Math
ref Vector4 value1,
ref Vector4 value2,
out Vector4 result
) {
)
{
result.W = value1.W / value2.W;
result.X = value1.X / value2.X;
result.Y = value1.Y / value2.Y;
@ -626,7 +633,8 @@ namespace MoonWorks.Math
Vector4 value2,
Vector4 tangent2,
float amount
) {
)
{
return new Vector4(
MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount),
MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount),
@ -651,7 +659,8 @@ namespace MoonWorks.Math
ref Vector4 tangent2,
float amount,
out Vector4 result
) {
)
{
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.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
@ -687,7 +696,8 @@ namespace MoonWorks.Math
ref Vector4 value2,
float amount,
out Vector4 result
) {
)
{
result.X = MathHelper.Lerp(value1.X, value2.X, amount);
result.Y = MathHelper.Lerp(value1.Y, value2.Y, amount);
result.Z = MathHelper.Lerp(value1.Z, value2.Z, amount);
@ -905,7 +915,8 @@ namespace MoonWorks.Math
ref Vector4 value2,
float amount,
out Vector4 result
) {
)
{
result.X = MathHelper.SmoothStep(value1.X, value2.X, amount);
result.Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount);
result.Z = MathHelper.SmoothStep(value1.Z, value2.Z, amount);
@ -1081,7 +1092,8 @@ namespace MoonWorks.Math
Vector4[] sourceArray,
ref Matrix4x4 matrix,
Vector4[] destinationArray
) {
)
{
if (sourceArray == null)
{
throw new ArgumentNullException("sourceArray");
@ -1122,7 +1134,8 @@ namespace MoonWorks.Math
Vector4[] destinationArray,
int destinationIndex,
int length
) {
)
{
if (sourceArray == null)
{
throw new ArgumentNullException("sourceArray");
@ -1202,7 +1215,8 @@ namespace MoonWorks.Math
ref Vector2 value,
ref Quaternion rotation,
out Vector4 result
) {
)
{
double xx = rotation.X + rotation.X;
double yy = rotation.Y + rotation.Y;
double zz = rotation.Z + rotation.Z;
@ -1240,7 +1254,8 @@ namespace MoonWorks.Math
ref Vector3 value,
ref Quaternion rotation,
out Vector4 result
) {
)
{
double xx = rotation.X + rotation.X;
double yy = rotation.Y + rotation.Y;
double zz = rotation.Z + rotation.Z;
@ -1281,7 +1296,8 @@ namespace MoonWorks.Math
ref Vector4 value,
ref Quaternion rotation,
out Vector4 result
) {
)
{
double xx = rotation.X + rotation.X;
double yy = rotation.Y + rotation.Y;
double zz = rotation.Z + rotation.Z;
@ -1322,7 +1338,8 @@ namespace MoonWorks.Math
Vector4[] sourceArray,
ref Quaternion rotation,
Vector4[] destinationArray
) {
)
{
if (sourceArray == null)
{
throw new ArgumentException("sourceArray");
@ -1363,7 +1380,8 @@ namespace MoonWorks.Math
Vector4[] destinationArray,
int destinationIndex,
int length
) {
)
{
if (sourceArray == null)
{
throw new ArgumentException("sourceArray");
@ -1405,10 +1423,10 @@ namespace MoonWorks.Math
public static bool operator ==(Vector4 value1, Vector4 value2)
{
return ( value1.X == value2.X &&
return (value1.X == value2.X &&
value1.Y == value2.Y &&
value1.Z == value2.Z &&
value1.W == value2.W );
value1.W == value2.W);
}
public static bool operator !=(Vector4 value1, Vector4 value2)

View File

@ -1,4 +1,4 @@
#region License
#region License
/* MoonWorks - Game Development Framework
* Copyright 2021 Evan Hemsley
@ -67,7 +67,8 @@ namespace MoonWorks
string libraryName,
Assembly assembly,
DllImportSearchPath? dllImportSearchPath
) {
)
{
string mappedName;
if (!mapDictionary.TryGetValue(libraryName, out mappedName))
{

View File

@ -1,4 +1,4 @@
using System;
using System;
using SDL2;
namespace MoonWorks.Window
@ -29,8 +29,8 @@ namespace MoonWorks.Window
windowCreateInfo.WindowTitle,
SDL.SDL_WINDOWPOS_UNDEFINED,
SDL.SDL_WINDOWPOS_UNDEFINED,
(int)windowCreateInfo.WindowWidth,
(int)windowCreateInfo.WindowHeight,
(int) windowCreateInfo.WindowWidth,
(int) windowCreateInfo.WindowHeight,
windowFlags
);
}
@ -59,7 +59,7 @@ namespace MoonWorks.Window
/// <param name="height"></param>
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)

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Window
namespace MoonWorks.Window
{
public enum ScreenMode
{

View File

@ -1,4 +1,4 @@
namespace MoonWorks.Window
namespace MoonWorks.Window
{
public struct WindowCreateInfo
{