UltimateZoneBuilder/Source/Core/GZBuilder/Data/BoundingBox.cs
MaxED a523f7eb28 Changed, Visual mode: models and lights are much less prone to disappear when near the edges of the screen.
Fixed, Classic modes: MODELDEF model scale was not taken into account when calculating model visibility, which resulted in models with increased scaled disappearing when near screen edges.
2015-06-22 19:52:23 +00:00

47 lines
1.2 KiB
C#

using CodeImp.DoomBuilder.Rendering;
using SlimDX;
namespace CodeImp.DoomBuilder.GZBuilder.Data
{
public struct BoundingBoxSizes
{
public int MinX;
public int MaxX;
public int MinY;
public int MaxY;
public int MinZ;
public int MaxZ;
//we need some reference here
public BoundingBoxSizes(WorldVertex v)
{
MinX = MaxX = (int)v.x;
MinY = MaxY = (int)v.y;
MinZ = MaxZ = (int)v.z;
}
}
public static class BoundingBoxTools
{
public static Vector3[] CalculateBoundingPlane(BoundingBoxSizes bbs)
{
//mxd. looks like I need only these 2 points, so...
//center
Vector3 v0 = new Vector3(bbs.MinX + (bbs.MaxX - bbs.MinX) / 2, bbs.MinY + (bbs.MaxY - bbs.MinY) / 2, bbs.MinZ + (bbs.MaxZ - bbs.MinZ) / 2);
Vector3 v1 = new Vector3(bbs.MinX, bbs.MinY, bbs.MinZ);
return new[] { v0, v1 };
}
public static void UpdateBoundingBoxSizes(ref BoundingBoxSizes bbs, WorldVertex v)
{
if (v.x < bbs.MinX) bbs.MinX = (int)v.x;
else if(v.x > bbs.MaxX) bbs.MaxX = (int)v.x;
if(v.z < bbs.MinZ) bbs.MinZ = (int)v.z;
else if(v.z > bbs.MaxZ) bbs.MaxZ = (int)v.z;
if(v.y < bbs.MinY) bbs.MinY = (int)v.y;
else if(v.y > bbs.MaxY) bbs.MaxY = (int)v.y;
}
}
}