mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-30 02:42:54 +08:00
6bce9acbcd
- Made some changes to the way I check for deleting instances. - Added a new bounding box check for painting grass. - Made GetNewGrassBounds return a bounding box instead of our parameters - Added new Expand method to bounding box util - Added instance radius check and instance brush check to project form for possible future instance types (Props) - Added grass brush gizmo - Updated gui for grass instance batch panel - Fixed bug with GoToPosition (with bounds)
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System;
|
|
using SharpDX;
|
|
|
|
namespace CodeWalker.Core.Utils
|
|
{
|
|
public static class BoundingBoxExtensions
|
|
{
|
|
public static Vector3 Size(this BoundingBox bounds)
|
|
{
|
|
return new Vector3(
|
|
Math.Abs(bounds.Maximum.X - bounds.Minimum.X),
|
|
Math.Abs(bounds.Maximum.Y - bounds.Minimum.Y),
|
|
Math.Abs(bounds.Maximum.Z - bounds.Minimum.Z));
|
|
}
|
|
|
|
public static Vector3 Center(this BoundingBox bounds)
|
|
{
|
|
return (bounds.Minimum + bounds.Maximum) * 0.5F;
|
|
}
|
|
|
|
public static BoundingBox Encapsulate(this BoundingBox box, BoundingBox bounds)
|
|
{
|
|
box.Minimum = Vector3.Min(box.Minimum, bounds.Minimum);
|
|
box.Maximum = Vector3.Max(box.Maximum, bounds.Maximum);
|
|
return box;
|
|
}
|
|
|
|
public static float Radius(this BoundingBox box)
|
|
{
|
|
var extents = (box.Maximum - box.Minimum) * 0.5F;
|
|
return extents.Length();
|
|
}
|
|
|
|
public static BoundingBox Expand(this BoundingBox b, float amount)
|
|
{
|
|
return new BoundingBox(b.Minimum - Vector3.One * amount, b.Maximum + Vector3.One * amount);
|
|
}
|
|
}
|
|
}
|