Skip to content

Read wheel slip from a single source - #340

Open
Sycatle wants to merge 1 commit into
StyledStrike:mainfrom
Sycatle:refactor/slip-single-source
Open

Read wheel slip from a single source#340
Sycatle wants to merge 1 commit into
StyledStrike:mainfrom
Sycatle:refactor/slip-single-source

Conversation

@Sycatle

@Sycatle Sycatle commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Addresses 339 — see #339.

Behaviour is identical by construction, since the value written to the network and the value read by the physics become the same variable.

The change

The branch in glide_wheel/init.lua that already decides what the wheel reports now stores its result before sending it:

if isAsleep or not state.isOnGround then
    state.effectiveForwardSlip = 0
    state.effectiveSideSlip = 0
else
    state.effectiveForwardSlip = state.lastForwardSlip
    state.effectiveSideSlip = state.lastSideSlip
end

selfTbl.SetForwardSlip( self, state.effectiveForwardSlip )
selfTbl.SetSideSlip( self, state.effectiveSideSlip )

base_glide_car/init.lua then accumulates from state instead of the network getters.

I went this way rather than the obvious one because reading state.lastSideSlip directly is not equivalent: the network value is forced to zero while a wheel is asleep or off the ground, and state keeps its last value, so a naive substitution would feed stale slip from airborne wheels into the steering. Mirroring the condition at the consumer would have worked too, but would encode the same rule in two places.

What it buys

The averages that steer the car and shift its gears no longer travel through the presentation layer, so the wheels' network traffic can be tuned — quantised, written on change only, sent less often — without touching how the vehicle drives.

It also removes eight network variable reads per vehicle per tick, though that is incidental.

Known issues

Touches the same file as #336, so the two will conflict textually if both are taken; they are independent in substance.

The averages that steer the car and pick its gear were built by reading the
wheels' network variables, so a physics decision travelled through the
presentation layer. Reading state directly is not equivalent, because the
network value is forced to zero while a wheel is asleep or airborne while state
keeps its last value.

The wheel now stores what it actually reports, and both the network variables
and the vehicle read that. Behaviour is identical and the zeroing rule stays
written once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant