BoundingBox - Move 'Abs' function into extension class

This commit is contained in:
miku-666
2024-10-23 10:26:32 +02:00
parent b9d7cebb1c
commit 1effa243fd
4 changed files with 27 additions and 27 deletions

View 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));
}
}
}

View File

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

View File

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

View File

@@ -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()
{