Move 'SceneViewport.GetBounds' to 'BoundingBox.GetEnclosingBoundingBox'

This commit is contained in:
miku-666
2024-10-09 14:30:08 +02:00
parent 4be6fba77d
commit 953199d687
4 changed files with 7 additions and 7 deletions

View File

@@ -68,5 +68,10 @@ namespace PckStudio.Rendering
3, 7
];
}
public static BoundingBox GetEnclosingBoundingBox(IEnumerable<BoundingBox> boundingBoxes)
{
return boundingBoxes.Aggregate((a, b) => new BoundingBox(OpenTK.Vector3.ComponentMin(a.Start, b.Start), OpenTK.Vector3.ComponentMax(a.End, b.End)));
}
}
}

View File

@@ -115,7 +115,7 @@ namespace PckStudio.Rendering
.Select(b => new ModelBox(b.Position + p.Translation, b.Size, System.Numerics.Vector2.Zero, 0f, false)))
.Select(b => new BoundingBox(b.Position, b.Position + b.Size));
_maxBounds = GetBounds(allBoxes);
_maxBounds = BoundingBox.GetEnclosingBoundingBox(allBoxes);
if (!GameModelImporter.ModelMetaData.TryGetValue(model.Name, out JsonModelMetaData modelMetaData))
{

View File

@@ -283,11 +283,6 @@ namespace PckStudio.Rendering
Renderer.SetLineWidth(1f);
}
protected BoundingBox GetBounds(IEnumerable<BoundingBox> boundingBoxes)
{
return boundingBoxes.Aggregate((a, b) => new BoundingBox(Vector3.ComponentMin(a.Start, b.Start), Vector3.ComponentMax(a.End, b.End)));
}
static void DebugProc(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr instanceHandle)
{
string dbgMessage = Marshal.PtrToStringAnsi(message, length);

View File

@@ -1042,7 +1042,7 @@ namespace PckStudio.Rendering
}
yield break;
}
return SelectedIndices.Length >= 1 ? GetBounds(GetBoundingBoxesFromSelectedIndices(SelectedIndices)) : BoundingBox.Empty;
return SelectedIndices.Length >= 1 ? BoundingBox.GetEnclosingBoundingBox(GetBoundingBoxesFromSelectedIndices(SelectedIndices)) : BoundingBox.Empty;
}
private void RenderBodyPart(ShaderProgram shader, Matrix4 partsMatrix, Matrix4 globalMatrix, params string[] partNames)