Skip to content

Don't cache the ground ray while standing on a mover - #1082

Open
pieterdeschepper wants to merge 2 commits into
Try:masterfrom
pieterdeschepper:fix-mover-carries-idle-npc
Open

pieterdeschepper wants to merge 2 commits into
Try:masterfrom
pieterdeschepper:fix-mover-carries-idle-npc

Conversation

@pieterdeschepper

@pieterdeschepper pieterdeschepper commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1050: a character standing still on an elevator isn't carried up. The platform rises through it instead.

MoveAlgo::rayMain caches the ground ray by NPC position. While the NPC stands still on a mover, the cache keeps returning the old ground height, so the step-up code in implTick never runs.

Change

This is the first half of the approach suggested in #1050 ("keep collision uncached, if ground is movable"):

  • Bodies created by addMovableObj (what MoveTrigger uses) get a new collision category, C_Movable, instead of C_Object. Everything that handled C_Object treats C_Movable the same way.
  • RayLandResult::movable is set when the hit body is C_Movable.
  • rayMain skips the cache while the last ground hit was movable. The ground is then re-measured every tick, and the existing step-up code lifts the NPC with the platform. Nothing changes for NPCs on static ground or landscape, so the cache still applies everywhere else.

Not covered

  • Static objects nested under a mover (the second half of the suggestion: invalidating caches when a mover moves).
  • Horizontal or rotating movers: the NPC is still not moved sideways with the platform.

Testing

Gothic 1, Sleeper temple elevator (EVT_TPL_12_ELEVATOR_01), macOS on an Apple M3 Pro. Standing still on the lowered block, the player now rides up with it instead of falling through. Walking, jumping and climbing elsewhere behaved normally.
🤖 Generated with Claude Code

MoveAlgo caches the ground ray by npc position, so an npc standing still
on an elevator keeps the old ground height while the mover rises, and
the platform passes through it. Mark bodies created by addMovableObj and
skip the cache when the last ground hit was one of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Try

Try commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Hi, @pieterdeschepper !

Generally look nice, but can you please instead of using user-index3 add rather new kind of collision? Essentially split C_Object into C_Object and C_Movable, since user-indices are limited in bullet.

Movers get C_Movable instead of C_Object plus a user-index3 flag, since
bullet user indices are limited. Everything that handles C_Object
treats C_Movable the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pieterdeschepper

Copy link
Copy Markdown
Contributor Author

Done in 6f68e6c: movers now get their own collision category, C_Movable, instead of the user-index3 flag. Everything that handled C_Object (ray and sweep filters, sound occlusion, contact checks, setInteractive) accepts C_Movable too, and ItemType is private again. Retested on the Sleeper temple elevator: standing still on the block, the player rides up with it.

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.

2 participants