Skip to content
This repository was archived by the owner on Jan 6, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/Sandbox.Game/Game/Entities/Cube/MyCubeGrid.Static.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ public static bool CheckConnectivity(IMyGridConnectivityTest grid, MyCubeBlockDe
// This code is used to avoid mixed start, end values, overlapped values on sides. So as result we need precise neighbour(s). Not neighbours touched on edges.

// Start and end sometimes have exchanged values
Vector3 start = Vector3.Min(thisMountPoint.Start, thisMountPoint.End);
Vector3 end = Vector3.Max(thisMountPoint.Start, thisMountPoint.End);
Vector3 start, end;
Vector3.MinMax(thisMountPoint.Start, thisMountPoint.End, out start, out end);

// Clamp only overlapped values on sides not thickness of aabb of mount point
Vector3I clampMask = Vector3I.One - Vector3I.Abs(thisMountPoint.Normal);
Expand Down Expand Up @@ -547,8 +547,8 @@ public static bool CheckConnectivity(IMyGridConnectivityTest grid, MyCubeBlockDe

m_cacheNeighborBlocks.Clear();

var currentMin = Vector3.Min(gridPosStart, gridPosEnd);
var currentMax = Vector3.Max(gridPosStart, gridPosEnd);
Vector3 currentMin, currentMax;
Vector3.MinMax(gridPosStart, gridPosEnd, out currentMin, out currentMax);

var minI = Vector3I.Floor(currentMin);
var maxI = Vector3I.Floor(currentMax);
Expand Down
40 changes: 40 additions & 0 deletions Sources/VRage.Math/Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,46 @@ public float AbsMax()
}
}

/// <summary>
/// Returns the vector that contains the lowest and the highest value from each matching pair of components.
/// </summary>
/// <param name="value1">Source vector.</param><param name="value2">Source vector.</param><param name="min">[OutAttribute] The minimized vector.</param><param name="max">[OutAttribute] The maximized vector.</param>
public static void MinMax(Vector3 value1, Vector3 value2, out Vector3 min, out Vector3 max)
{
if (value1.X < value2.X)
{
min.X = value1.X;
max.X = value2.X;
}
else
{
max.X = value1.X;
min.X = value2.X;
}

if (value1.Y < value2.Y)
{
min.Y = value1.Y;
max.Y = value2.Y;
}
else
{
max.Y = value1.Y;
min.Y = value2.Y;
}

if (value1.Z < value2.Z)
{
min.Z = value1.Z;
max.Z = value2.Z;
}
else
{
max.Z = value1.Z;
min.Z = value2.Z;
}
}

/// <summary>
/// Returns a vector that contains the lowest value from each matching pair of components.
/// </summary>
Expand Down