mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-14 21:18:42 +00:00
BoundingBox - Move 'Abs' function into extension class
This commit is contained in:
25
PCK-Studio/Extensions/OpenTKExtensions.cs
Normal file
25
PCK-Studio/Extensions/OpenTKExtensions.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
|
||||
namespace PckStudio.Extensions
|
||||
{
|
||||
internal static class OpenTKExtensions
|
||||
{
|
||||
internal static Matrix4 Pivoted(this Matrix4 rotation, Vector3 pivot)
|
||||
{
|
||||
var model = Matrix4.CreateTranslation(pivot);
|
||||
model *= rotation;
|
||||
model *= Matrix4.CreateTranslation(pivot).Inverted();
|
||||
return model;
|
||||
}
|
||||
|
||||
public static Vector3 Abs(Vector3 value)
|
||||
{
|
||||
return new Vector3(Math.Abs(value.X), Math.Abs(value.Y), Math.Abs(value.Z));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
|
||||
namespace PckStudio.Extensions
|
||||
{
|
||||
internal static class OpenTkMatrixExtensions
|
||||
{
|
||||
internal static Matrix4 Pivoted(this Matrix4 target, Vector3 translation, Vector3 pivot)
|
||||
{
|
||||
var model = Matrix4.CreateTranslation(translation);
|
||||
model *= Matrix4.CreateTranslation(pivot);
|
||||
model *= target;
|
||||
model *= Matrix4.CreateTranslation(pivot).Inverted();
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@
|
||||
<Compile Include="Forms\ContributorsForm.Designer.cs">
|
||||
<DependentUpon>ContributorsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Extensions\OpenTkMatrixExtensions.cs" />
|
||||
<Compile Include="Extensions\OpenTKExtensions.cs" />
|
||||
<Compile Include="Forms\Editor\ModelEditor.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace PckStudio.Rendering
|
||||
Start = start;
|
||||
End = end;
|
||||
OpenTK.Vector3 size = End - Start;
|
||||
Volume = Abs(size);
|
||||
Volume = OpenTKExtensions.Abs(size);
|
||||
Center = start + Volume / 2;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,6 @@ namespace PckStudio.Rendering
|
||||
{
|
||||
}
|
||||
|
||||
private static OpenTK.Vector3 Abs(OpenTK.Vector3 value)
|
||||
{
|
||||
return new OpenTK.Vector3(Math.Abs(value.X), Math.Abs(value.Y), Math.Abs(value.Z));
|
||||
}
|
||||
|
||||
public ColorVertex[] GetVertices()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user