fix(crossing): preserve flying avatar velocity during region transfer (#221)

* fix(crossing): preserve flight velocity in viewer CrossRegion transition

* test(crossing): keep flight momentum on viewer crossing packet

* ci(crossing): enforce flight velocity hand-off

* docs(crossing): explain flight velocity continuity and prefetch milestones
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-10-15 00:23:27 +02:00
1 parent 8eb11eee17
commit a6b9dfbc6a
4 files changed
+66

No files matched your search

+4
View File
@@ -465,6 +465,10 @@ jobs:
shell: bash
run: python3 tools/ci/verify_object_messaging.py
- name: Verify flight crossing velocity hand-off
shell: bash
run: python3 tools/ci/verify_cross_region_flight_velocity.py
- name: Verify cross-region llListen and NexBus chat forwarding
shell: bash
run: |
@@ -1859,9 +1859,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
// CrossRegion previously sent zero velocity for all normal avatars,
// even when they were actively flying. The viewer then decelerated
// abruptly at the region boundary before new physics updates arrived.
// Preserve actual flight velocity; keep ground and seated behavior
// unchanged until separately validated with their movement models.
Vector3 vel2 = Vector3.Zero;
if((agent.m_crossingFlags & 2) != 0)
vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);
else if (isFlying)
vel2 = agent.Velocity;
if (m_eqModule != null)
{
@@ -0,0 +1,32 @@
# OGL regions: flight velocity continuity, stage 1
`EntityTransferModule.CrossAgentIntoNewRegionMain` previously populated the
EventQueue `CrossRegion` viewer packet with `Vector3.Zero` for all
ordinary avatars. A seated avatar already retained its horizontal
velocity. Thus a flying avatar was handed to the viewer with **zero
velocity**, even though the destination `AgentData` contains motion
data. This can cause a sudden visible deceleration during flight.
The first-stage fix sends `agent.Velocity` for **flying avatars**,
while preserving previous default values for walking and seated avatars.
The fallback old CrossRegion packet already sends `agent.Velocity` and
remains unchanged.
This does **not** make distributed crossings perfectly invisible.
A seamless experience also requires:
- Predicting a boundary crossing from avatar position/velocity, including
diagonal flight and varregion boundaries.
- Preparing child-agent, CAPS and destination region presence **before**
crossing, with sufficient lead time based on velocity and RTT.
- Measuring `SimulationService.UpdateAgent` latency, physics detach/
attach time, viewer `CrossRegion` receipt and texture/attachment catch-up.
- Keeping predictive work bounded to authorized neighboring regions;
handling cancel/retry/teleport/rapid reversal, and hard stop on rejection.
- Performing real viewer testing for different flight speeds, diagonal
crossings, busy sims, and inter-server transfers; comparing viewer
frame gaps (p50/p95/p99), avatar position discontinuity and velocity
before and after.
**Tests:** The CI static contract verifies preservation of flying
velocity and unchanged seated fallback. It is not a replacement for
real Firestorm/OGL Viewer motion tests. No claim of zero jerk is made.
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
"""Regression contract for preserving flying avatar velocity during CrossRegion."""
from pathlib import Path
code=(Path(__file__).resolve().parents[2] /
"OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs").read_text()
block=code.split("public bool CrossAgentIntoNewRegionMain(",1)[1].split(
"private void CrossAgentToNewRegionCompleted(",1)[0]
must=[
"Vector3 vel2 = Vector3.Zero;",
"if((agent.m_crossingFlags & 2) != 0)",
"vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);",
"else if (isFlying)",
"vel2 = agent.Velocity;",
"m_eqModule.CrossRegion(",
"neighbourRegion.RegionHandle, pos, vel2",
]
for part in must:
assert part in block, part
assert block.index("else if (isFlying)") < block.index("m_eqModule.CrossRegion(")
assert "agent.CopyTo(cAgent,true);" in block
assert "m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent, ctx)" in block
print("Flight crossing velocity hand-off: OK")