Skip to content
Merged
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
15 changes: 15 additions & 0 deletions Source.Common/Mathematics/MathLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4010,6 +4010,21 @@ public static bool SolveInverseQuadraticMonotonic(float x1, float y1, float x2,
}
return true;
}

static InlineArray128<Vector3> tempVectors = default;
static int tempVectorIndex;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref Vector3 AllocTempVector() {
int Index;
while (true) {
int OldIndex = tempVectorIndex;
Index = (OldIndex + 0x10001) & 0x7F;

if (Interlocked.CompareExchange(ref tempVectorIndex, Index, OldIndex) == OldIndex)
break;
}
return ref tempVectors[Index];
}
}

[StructLayout(LayoutKind.Sequential, Pack = 16, Size = sizeof(float) * 4 * 3)]
Expand Down
19 changes: 17 additions & 2 deletions Source.Engine/StaticPropMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,23 @@ public void SetRefEHandle(in BaseHandle handle) {

public ref readonly Vector3 OBBMinsPreScaled() => ref OBBMins();
public ref readonly Vector3 OBBMaxsPreScaled() => ref OBBMaxs();
public ref readonly Vector3 OBBMins() => throw new NotImplementedException();
public ref readonly Vector3 OBBMaxs() => throw new NotImplementedException();

public ref readonly Vector3 OBBMins() {
if (GetSolid() == SolidType.VPhysics) {
return ref Model.Mins;
}
ref Vector3 tv = ref MathLib.AllocTempVector();
MathLib.VectorSubtract(WorldRenderBBoxMin, GetCollisionOrigin(), out tv);
return ref tv;
}
public ref readonly Vector3 OBBMaxs() {
if (GetSolid() == SolidType.VPhysics) {
return ref Model.Maxs;
}
ref Vector3 tv = ref MathLib.AllocTempVector();
MathLib.VectorSubtract(WorldRenderBBoxMax, GetCollisionOrigin(), out tv);
return ref tv;
}

public bool TestCollision(in Ray ray, Contents contentsMask, ref Trace tr) {
Assert(false);
Expand Down
Loading