mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* Reduce size of GfxObj * Use capacity when creating the list in BSPNode * /clearphysicscaches and /forcegc added * clear other caches too * Allow these commands in-game and at console * Only populated if !PhysicsEngine.Instance.Server
54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using ACE.DatLoader.Entity;
|
|
|
|
namespace ACE.Server.Physics.Entity
|
|
{
|
|
public static class VertexCache
|
|
{
|
|
public static bool Enabled = false;
|
|
|
|
public static readonly HashSet<Vertex> Vertices = new HashSet<Vertex>();
|
|
|
|
public static int Requests;
|
|
public static int Hits;
|
|
|
|
public static int Count => Vertices.Count;
|
|
|
|
public static void Clear()
|
|
{
|
|
Vertices.Clear();
|
|
}
|
|
|
|
public static Vertex Get(Vertex v)
|
|
{
|
|
if (!Enabled) return v;
|
|
|
|
Requests++;
|
|
|
|
//if (Requests % 100000 == 0)
|
|
//Console.WriteLine($"VertexCache: Requests={Requests}, Hits={Hits}");
|
|
|
|
if (Vertices.TryGetValue(v, out var result))
|
|
{
|
|
Hits++;
|
|
return result;
|
|
}
|
|
|
|
// not cached, add it
|
|
Vertices.Add(v);
|
|
return v;
|
|
}
|
|
|
|
public static Vertex Get(SWVertex swv)
|
|
{
|
|
var vertex = new Vertex(swv);
|
|
|
|
if (!Enabled)
|
|
return vertex;
|
|
|
|
return Get(vertex);
|
|
}
|
|
}
|
|
}
|