diff --git a/MUNGA/CAMSHIP.cpp b/MUNGA/CAMSHIP.cpp index 567cf0e..1c78814 100644 --- a/MUNGA/CAMSHIP.cpp +++ b/MUNGA/CAMSHIP.cpp @@ -349,6 +349,30 @@ void static int moved = 0; static Scalar biggest = 0.0f; + // + // A visible tick IS a step that moves much further, or much less, + // than the steps around it. Measuring that directly beats measuring + // anything about where the number came from: it does not care + // whether the cause is the network, the catch-up rule, or something + // nobody has thought of yet. + // + // Judged against a short running mean rather than an absolute + // distance, because a pod at 75 m/s moves 1.5 m per step and one + // sitting against a wall moves nothing - a fixed threshold would + // call every acceleration a spike. + // + // What confirms: spikes running at a few per second. That is the + // reported tick, and its rate is in the count. + // What refutes: spikes and stalls near zero. Then entity motion is + // smooth and the tick is not in the simulation at all, which points + // at frame delivery or the map raster instead. + // + static Scalar mean_step = 0.0f; + static int spikes = 0; + static int stalls = 0; + static int respawns = 0; + static Scalar worst_ratio = 0.0f; + ++steps; if (have_last) { @@ -363,6 +387,38 @@ void { biggest = distance; } + + // + // A respawn teleports hundreds of metres and is MEANT to be a + // discontinuity. Counted, excluded, and the mean restarted so + // one does not brand the following steps as stalls. + // + if (distance > 50.0f) + { + ++respawns; + mean_step = 0.0f; + } + else if (mean_step > 0.01f) + { + Scalar ratio = distance / mean_step; + if (ratio > 2.5f) + { + ++spikes; + if (ratio > worst_ratio) + { + worst_ratio = ratio; + } + } + else if (ratio < 0.4f) + { + ++stalls; + } + mean_step = mean_step * 0.9f + distance * 0.1f; + } + else + { + mean_step = distance; + } } last_target = target; have_last = True; @@ -374,11 +430,19 @@ void DEBUG_STREAM << "CamLog: follow - " << steps << " steps, " << moved << " moved, biggest jump " << biggest << "m, " << gCameraCuts << " cut(s)\n" << std::flush; + DEBUG_STREAM << "CamLog: smoothness - " << spikes + << " spike(s), " << stalls << " stall(s), " + << respawns << " respawn(s), worst " << worst_ratio + << "x the running mean of " << mean_step << "m\n" << std::flush; } next_say = ((Scalar) Now()) + 5.0f; steps = 0; moved = 0; biggest = 0.0f; + spikes = 0; + stalls = 0; + respawns = 0; + worst_ratio = 0.0f; gCameraCuts = 0; } }