Fewer hitches: FSM scene scans less often, damage safety check one mesh at a time; hitch detector (per-subsystem timing, reports MSCO part or game) in the F7 console
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+7
-3
@@ -17,7 +17,7 @@ namespace MSCO
|
||||
const float CheckInterval = 0.5f; // so oft nach einem Aufprall prüfen
|
||||
const float ImpactWindow = 4f; // so lange nach einem Aufprall prüfen (Verformung läuft ein paar Frames)
|
||||
const float ImpactDeltaV = 2.5f; // plötzliche Geschwindigkeitsänderung (m/s pro Frame) = Aufprall
|
||||
const float SafetyCheckInterval = 30f; // sonst nur selten (z.B. Reparatur in der Werkstatt)
|
||||
const float SafetyCheckInterval = 2f; // sonst nur ab und zu EIN Mesh (z.B. Reparatur in der Werkstatt) - verteilt statt alle auf einmal
|
||||
const float MinMove = 0.002f;
|
||||
const int MaxPerMessage = 4000;
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace MSCO
|
||||
readonly HashSet<MeshFilter> seen = new HashSet<MeshFilter>();
|
||||
readonly List<int> changed = new List<int>();
|
||||
float nextScan, nextCheck, nextSafetyCheck;
|
||||
int safetyIndex;
|
||||
// Mesh-Daten lesen ist teuer (große Arrays, Speicher-Müll) - nur nach einem Aufprall
|
||||
readonly Dictionary<Rigidbody, Vector3> lastVelocity = new Dictionary<Rigidbody, Vector3>();
|
||||
readonly Dictionary<Rigidbody, float> lastImpact = new Dictionary<Rigidbody, float>();
|
||||
@@ -76,16 +77,19 @@ namespace MSCO
|
||||
if (Time.time < nextCheck) return;
|
||||
nextCheck = Time.time + CheckInterval;
|
||||
bool safety = Time.time >= nextSafetyCheck;
|
||||
if (safety) nextSafetyCheck = Time.time + SafetyCheckInterval;
|
||||
if (safety) { nextSafetyCheck = Time.time + SafetyCheckInterval; safetyIndex++; }
|
||||
int index = -1;
|
||||
|
||||
foreach (DamageMesh m in meshes.Values)
|
||||
{
|
||||
index++;
|
||||
if (m.Filter == null) continue;
|
||||
bool safetyThis = safety && meshes.Count > 0 && index == safetyIndex % meshes.Count;
|
||||
int owner = objects.VehicleOwner(m.Root);
|
||||
if (owner != SyncedBody.NoOwner && owner != localId) continue; // der Fahrer schickt die Schäden
|
||||
float impact;
|
||||
bool recentImpact = m.Body != null && lastImpact.TryGetValue(m.Body, out impact) && Time.time - impact < ImpactWindow;
|
||||
if (!recentImpact && !safety) continue;
|
||||
if (!recentImpact && !safetyThis) continue;
|
||||
|
||||
Mesh mesh = m.Filter.sharedMesh;
|
||||
if (mesh == null) continue;
|
||||
|
||||
Reference in New Issue
Block a user