Skip to content

Tune func_bob curve/timing, add trigger_push start_off/toggle - #938

Merged
jdolan merged 1 commit into
mainfrom
feature/func-bob-tuning
Aug 12, 2026
Merged

Tune func_bob curve/timing, add trigger_push start_off/toggle#938
jdolan merged 1 commit into
mainfrom
feature/func-bob-tuning

Conversation

@skies912

Copy link
Copy Markdown
Collaborator

Summary

func_bob (follow-up tuning after #911):

  • Scale the arrival-snap threshold to the leg's own travel distance (1% of distance, floored at .01, capped at the old flat .25) instead of a fixed .25 units. G_MoveInfo_Linear_Done snaps position exactly to the destination once within this threshold, and a flat .25 was a visible pop on short legs (e.g. ~3% of an 8-unit travel used for a shadow-sync bob).
  • Auto-derive compression from the leg's duration when the key is unset, instead of always defaulting to a flat 1.0 (pure sine). Uses a continuous falloff in log(leg_time) that peaks at 1.0 for a leg around 1 second and tapers toward a .35 floor for legs much shorter (too few ticks, stutters) or much longer (the sine's slow "wings" become a multi-second crawl before the entity visibly starts moving) than that. Calibrated against two tested legs (~1s and ~7s). Explicit compression keys still override.
  • drift now defaults to 0 (no startup delay) instead of silently defaulting to a full-cycle random delay whenever unset - the old default caused multi-second startup delays on any func_bob that wasn't actually part of a desynced array. Negative values are clamped to 0 rather than risking undefined behavior in the float-to-uint32_t cast.

trigger_push:

  • Adds start_off and toggle spawnflags so trigger_push can spawn inactive and be toggled on/off via Use, matching the pattern already used elsewhere (e.g. func_bob).

Test plan

  • Builds clean (game.vcxproj)
  • Manually tested in-map: short-leg arrival snap, long-leg startup delay, auto-compression on both a small shadow-sync bob and a 448-unit platform
  • trigger_push start_off/toggle behavior

func_bob:
- Scale the arrival-snap threshold to the leg's own distance (1% of
  travel, floored at .01 and capped at the old flat .25) instead of a
  fixed .25 units, which was a visible pop on short legs (e.g. ~3% of
  an 8-unit travel).
- Auto-derive "compression" from the leg's duration when unset, via a
  continuous falloff in log(leg_time) peaking at 1.0 around a ~1s leg
  and tapering toward a .35 floor for legs much shorter (stutters) or
  much longer (slow crawl before the entity gets moving) than that.
  Explicit "compression" keys still override.
- "drift" now defaults to 0 (no startup delay) instead of silently
  defaulting to a full-cycle random delay when unset, which was
  causing multi-second startup delays on entities that were never
  meant to be desynced. Negative values are clamped to 0 rather than
  risking UB in the float-to-uint32 cast.

trigger_push:
- Add start_off and toggle spawnflags so trigger_push can be spawned
  inactive and toggled on/off via Use, matching the pattern already
  used elsewhere (e.g. func_bob).
// is from that ~1s sweet spot in either direction. Calibrated against two tested legs: ~1s
// (wants ~1.0) and ~7s (wants ~0.5) - solving for the width that fits both against a 0.35 floor.
// log(0) degrades gracefully to the floor for a zero-velocity leg, no special case needed.
const float compression = gi.EntityValue(ent->def, "compression")->value;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, okay. These kinds of optimizations are pretty pointless. This will never show up on a profiler, I guarantee it. But it's fine if Claude thought it was being clever here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the problem that I found was that when using very small distances like 16u (was exp with bobbing lights)the movement stutters before resting and using compression to fix isn't accurate. Slow speeds like <15 are also affected. This fixes it so the movement is alot smoother.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, not the calculation. The storing of it on ent->random so that it's "not calculated every tick" was the silly bit 👍 It's a cheap calculation.

@jdolan jdolan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Word. Don't forget the TrenchBroom / Radiant configs for the new / modified entity fields :)

@jdolan
jdolan merged commit dc5a857 into main Aug 12, 2026
7 of 8 checks passed
@jdolan
jdolan deleted the feature/func-bob-tuning branch August 12, 2026 17:54
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