Repository navigation
feat(characters): Enhanced Movement: natural character movement, behind one graphics option - #868
Conversation
…he head turning the shoulders Walking: a character moves toward the next point of its path (its new MoveHeading) while its facing eases toward it, speeding up and slowing down to stop on it (StepEasedTurn, up to 540 degrees a second), where it used to snap on any turn of 45 degrees or more. Its route is the same. Standing: a turn the server gives another character (a stand action with a new direction), or the end of a turn a walk left unfinished, steps around with the walk animation at half speed (StartStandingTurn, FinishPendingTurn) instead of snapping; anything else that turns the character or gives it another action ends the turn there. The hero no longer turns toward the cursor every 40 frames: its head follows the cursor, and the body steps around only when the cursor stays more than 90 degrees away for half a second, telling the server when it ends. Head and shoulders: on a Biped skeleton the neck and spine take half of the head's turn (HeadTurn.h; the bones found when the model loads), so the shoulders follow; a player's wings, which hang from the root, turn with them. A head looking straight ahead keeps the bones' own rotations. StandTime, which only the removed idle turn read, goes.
A winged player flying or hovering outside the safe zones banks into its turns, up to 8 degrees at full turning speed, pivoting about the waist. It also drifts slowly up and back down, up to 30 units above its usual height and never below it, eased at the top and the bottom, on its own beat. Both fade in and out over about a quarter of a second. - The waist pivot moves the character sideways a little. Following a path removes that shift first, so the bank doesn't turn the heading and rock the character from side to side. - The camera resets the hero's height each frame. It now keeps the drift, and the camera follows the height without it, so the view stays steady. A hovering winged player breathes in time with its wings: Hovering in place, the body's breathing animation looped about one and a half times per wing beat. Its speed now follows the wings: one cycle per beat, from the wing model's key count and its hovering speed, so it fits any wings. It's scaled rather than set, so a freeze still slows it.
31 test programs compiled their own copy of Winmain.cpp, the client's biggest file, which made up most of a test build and ran the compiler out of heap with many parallel compiles. They now share one object library, mu_test_winmain. A full build with the tests took 6 minutes instead of about 10.
When a player turns, the wings and the ponytail lag a little behind the body: a damped spring (StepSpring, the same at any frame rate) lets them trail up to 12 degrees and settle with a slight overshoot. - The wings turn as a whole about the upright through Spine1, with the head's shoulder twist. - The ponytail (Bip01 Ponytail1, found when the model loads) swings about the head's upright at its root. The lag is passed into the skeleton build, since characters animate on several threads.
Characters' heads turn toward what's near instead of only glancing at random, if it's within 90 degrees of where they face with no wall between: - The hero, in a combat zone, looks at what it attacks, else the nearest enemy within 6 tiles, whatever the mouse does. Near an NPC (within 4 tiles) it follows the cursor only while the mouse is in use: moved for half a second, then for 2 seconds after it stops. - Other players do the same, without the cursor. - A monster looks at its target within 8 tiles, also while standing and attacking. - An NPC looks at the hero passing within 4 tiles. A player keeps the one it looks at while it stays in sight and looks around for another four times a second, each on its own beat. Players look at other players passing by: After enemies and NPCs, a player's head turns to another player within the same distance as an NPC (LookNearbyTiles, 4 tiles), in sight. The hero glances around when idle: With nothing to look at and the mouse resting for 4 seconds, the hero glances 25 to 55 degrees to a random side for 1 to 1.8 seconds, every 2.5 to 5 seconds. Any mouse movement ends it at once.
…nd shake their heads - A mount (Uniria, Dinorant, Dark Horse, Fenrir) leans into a turn up to 10 degrees on the move, its rider half as much. - Its head turns where the rider looks on purpose (at someone, or the hero at the cursor), not with the rider's idle glances. - Standing for 3 seconds, it shakes its head now and then: a quick roll along the snout that dies out, as a horse or a dog does. The head turns in the world (BMD::Animation's HeadTurnUp and HeadRoll): about the upright, and about whichever of the head bone's axes points along the snout. The four mounts' head bones lie every which way, so turning one of the bone's own axes rolled some and nodded others. The Dark Horse's head is its Bip01 Head now; BoneHead 7 was a body part. Wings turn with the back, and sit straight on a Uniria or a Dinorant: - The wings take only their bone's place (Bone05, on the spine), so the turn they follow is added: now the back's share of the head's turn (the two spine bones, 30%) instead of the shoulders' (50%, the neck too), as they sit at the middle of the back. - Riding a Uniria or a Dinorant, the wings tilted to a side on the move (main does it too, Fenrir doesn't): those riding actions turn the wings' bone askew on the spine. There they now sit on the spine as they do standing: their bone's turn under the spine from the standing action, in their bone's place.
An attack (about 30 places in the attack and skill code, and the server's actions and skills for others) snaps the facing to its target in one frame. The facing still does, since the attack and its effects aim by it; the body is now drawn catching up, a half turn eased in and out in 0.15 s (UpdateSnapTurn: any turn of 30 degrees or more in one frame). Weapons, wings and the mount follow the drawn body. A character's bones are built three times a frame: ahead of time (AnimateCharacterBones) and again when drawn, players by Calc_ObjectAnimation and everyone else by Calc_RenderObject. The draw builds are what's seen, and only had the plain facing, so they now share AnimateObjectBones with the same inputs as the ahead-of-time build: the drawn turn, the ponytail lag (which, it turns out, never showed before) and a mount's head.
A player's walk and run played at a fixed speed whatever the character really moved at, so the feet slid: walking 22% too fast, running with a wand 55%. The steps now play as fast as the character moves (CharacterMoveSpeed: its gear, mount, buffs and freezes), for the stride each action takes: how fast its planted foot moves back per key, measured from the skeleton once per action (StepPerKey). Actions that don't step (flying, riding, standing turns) keep their own speed. How fast the character moves doesn't change. Walking characters slow down and speed up: Clicking behind a walking character flipped its ground speed to the other way at once. Now (StepMomentum): - Turning back by more than a right angle, it slows to a stop the way it was going (0.12 s), then takes the new way. - From rest, and after that stop, it speeds up over 0.15 s. - Gentler turns follow at once, as before. The steps keep pace with it (step 6's speed matching uses the same share of the speed). It's kept short: the server times the walk tile by tile, and a turnaround costs about 0.14 s.
The slope is the terrain's rise between a little ahead of the character and a little behind it, along its facing (UpdateSlopeLean): - Riding, the mount follows it (nose up uphill, one and a half times the slope so the game's gentle slopes show, up to 25 degrees), and the rider on it with it. - Walking on foot, a player leans half the slope into a climb, up to 10 degrees; standing it stays upright. It eases in and out over a quarter of a second. Monsters keep their pose: whether a model should tilt with the ground (four legs) or stay upright (two) isn't known to the game. A player's feet stand on the ground under them: The animations stand on flat ground at the character's own height, so on a slope or a bump one foot floated and the other sank. Now (PlaceFeet, in each bone build, players on foot): - Each foot's ground is measured against the character's (up to 40 units either way). - The body goes down as far as the lower foot needs to reach. - Each leg bends to put its foot there: thigh and calf turned by a two-bone solve, the knee kept pointing as it did and the leg never fully straight; the foot keeps its own turn, its toes with it. Also: a mount in a safe zone isn't ridden (its rider walks there), for the slope lean too.
27 cases, at several frame rates where it matters: - Game logic: the damped spring; flight bank, waist pivot, hover and landing; the wings' and ponytail's turn lag; the drawn sudden turn; momentum from rest, turning back and gentle turns; who a head looks at (combat and safe zones, walls, sticking to a pick, monsters and NPCs); the slope lean on foot and riding; the back's share of a head turn. - With the real player model: feet on flat ground change nothing; a foot over lower ground reaches it with the body lowered and the legs bent, not stretched; the ponytail's lag; a head turned in the world. Benchmarks of the realism steps (ctest -E benchmark skips them): Per player, on a 12900K: a bone build plain 1129 ns, with the head turned into the neck and spine 1241, with the ponytail's lag 1240; feet on flat ground +8, on a slope +417. Per frame: flight 33 ns, turn lag 23, sudden turn 11, momentum 11, slope lean 24; a full look around a 400-character scene 649 ns, once every quarter of a second or so per player.
From the hero's point of view (UpdateNod): - A player or NPC within 2 tiles that has looked at the hero for 1.5 s greets it once (again only after looking away, at most once in 10 s): another player, or an NPC built on the player skeleton (Leo the Helper), standing, waves its Hello; another NPC with a second animation plays that once; the rest nod (a slow 25 degree dip of the head with a 5 degree bow of the body). Only on this screen: the server isn't told. - The hero always answers one it can turn its head to (60 degrees: the head and shoulders, never a step): it looks at them and, after a beat of 1.6 to 2.8 s (people don't greet at the same moment), nods back.
A player switching between standing, walking and running snapped from one pose to the next. BMD::Animation now blends a second pose into the one it builds (PoseBlend), and a character fading from one way of moving into the next keeps that pose for a quarter of a second, eased out (UpdatePoseFade, CharacterPoseFade): - From walking to running the new steps start where the old ones were in the stride (by where each action has the first foot furthest forward), so the feet don't jump. - A pose whose action locks its root in place has it locked in the blend too; otherwise the body lurched forward by the walk the keys hold. - All three bone builds (ahead of time, and players' and others' at draw time) get the same fade. Every player action fades by where it goes: Not only standing, walking and running: a player's switch from any action to the next fades (PoseFadeSecondsFor), by where it goes: - Moving (stand, walk, run, fly, ride, the Dark Horse and Fenrir), emotes, sitting, healing and poses: a quarter of a second. - Attacks, skills, defence and hits: 0.08 s, just enough to lose the snap while still starting at once. - Death, getting up and the special transformations: none, and a fade under way ends. A faded pose that isn't a stride plays on at its own speed, and one played once holds its end.
…ment change A graphics option, [Render] EnhancedMovement (on by default), in the options window's Quality section under the Enhanced rows: off, characters move and are drawn as before every change on this branch (smooth turning, the head's turn into the shoulders, look-at, greetings, flight feel, wing and hair lag, mount lean and head, the drawn sudden turn, stride matching, momentum, slope lean, foot placement and pose fades), and whatever a change had applied fades out or comes off. The rider's wings sitting straight and the mount in a safe zone are fixes and stay. Also, greetings: a character's greeting cooldown counts down again (it had stopped, so one that greeted never greeted again), and one that greeted the hero greets it again only once the hero has gone (off the screen or 8 tiles away), not when it just stepped round it. Movement features in their own files, one bone builder: - Engine/Object/Movement/ holds each movement feature (flight, turn lag, wings, attack turn, look-at, hero look, greetings, momentum, slope lean, foot placement, stride, pose fade), out of ZzzCharacter.cpp and ZzzInterface.cpp. - Engine::Characters::AnimateBones builds a character's bones for the pre-pass and both draw builds, with every extra (attack turn, ponytail lag, pose fade, mount head, feet) in one place. - The per-character movement state is one CharacterMotion, reset with the character; an NPC's greeting timer no longer carries over to the next character in its slot. - Render/Models/BoneMath.h has the rotation math the head turn, feet and ponytail shared; BMD::FindBone replaces five bone-by-name loops. - The look angles, eye height and turn thresholds are each defined once; docs/characters/animation-pipeline.md maps the features.
Mosch0512
left a comment
There was a problem hiding this comment.
Verdict: changes requested for five items; the rest is non-blocking. I built 61f317d (Release x64, editor build) and played it with two clients on a local OpenMU server. Overall the movement looks good, and the head following the mouse is great; it also works in the lean-on-wall pose. Two things I saw in game need fixing: fast direction changes got slow (bad for PvP), and a character bowed while walking. Two more come from reading the code: the turn toward the cursor sends the server the wrong action, and a standing turn can replace an action set in between. The new behaviour also needs tests, emotes included.
Required
- A fast 180° turn, for example on Fenrir, is instant on main but now plays a slow turn, and the rider first keeps going the old way. Seen in game; bad for PvP (inline, ZzzAI.h:49).
- The greeting nods and bows while walking or fighting, and plays the on-foot Hello on hovering and riding players. Seen in game: a Summoner bowed while walking (inline, Greetings.cpp:147).
- The end of a turn toward the cursor sends a stand action after an attack or sit, and nothing after a window interrupts it. Not tried in game (inline, ZzzInterface.cpp:2963).
- The first step of a standing turn replaces an action set in between, for example a sit. Not tried in game (inline, ZzzAI.cpp:545).
- Tests for the new behaviour, see below.
Tests (required). No test covers the pose fade, the stride matching, the greetings, the turn toward the cursor or the mount feel, and several of the points here are in exactly those paths. Emotes in particular have to keep working with the option on: they should start, play to the end and go back to standing, and neither a pose fade, a greeting nor a standing turn should cut them off or replace them. Please add tests for at least:
- A reversal: the facing and the travel go the new way at once.
- Greetings: only a standing character on foot greets, and nobody nods or bows while walking or fighting.
- A standing turn doesn't replace an action set in between (sit, emote, death).
- The turn toward the cursor sends
AT_STAND1only when it arrives. - The emotes play through with the option on.
- A pose fade with the head turned.
Non-blocking
- The pose fade skips the neck and both spine bones whenever the head is turned, which for the hero is nearly always (inline, ZzzBMD.cpp:356).
- The hero's lean, bank, hover and wing lag freeze while it is dead, stunned or asleep (inline, ZzzCharacter.cpp:6491).
- A position reset from the server keeps the old flight pivot shift as a lasting offset (inline, WSclient.cpp:3584).
- Question: the steps play at the linear pace, while the character moves at the eased pace (inline, ZzzCharacter.cpp:2483).
- The slope lean also tilts the movement direction, which costs a little ground speed. I couldn't see it in game (inline, ZzzCharacter.cpp:6378).
- Below 10 fps every step counts as a start from rest. I couldn't test it, since the frame limit goes down only to 24 fps (inline, Momentum.cpp:36).
- The Guardian Angel goes through the mount feel. I couldn't see an effect in game, but it isn't a mount (inline, GOBoid.cpp:246).
- Two of the "fixes on the way" don't apply with the option off, as the description says they do (inline, GOBoid.cpp:228).
What I checked: I played the build above with two clients, turning the option on and off: walking, running and riding Fenrir, the Guardian Angel and slopes. I also read the source diff and the functions it touches: MovePath, FinishPendingTurn, MoveHero with TurnToCursor, MoveMount, ReceiveAction, BMD::Animation, CharacterAnimation, MoveCharacterPosition and CalcFPS. Each point says whether I saw it in game or found it in the code. CI on 61f317d: Quality Gates and the Linux and macOS builds are green. The Windows jobs are skipped for pull requests.
|
|
||
| // How fast a character's facing turns toward the direction it travels, at most, and how quickly a turn gets up to | ||
| // that speed and slows down again before it arrives. | ||
| constexpr float WalkTurnDegreesPerSecond = 540.f; |
There was a problem hiding this comment.
Required. In game, turning around quickly feels much slower with the option on. On Fenrir a fast 180° is instant on main, but with Enhanced Movement it plays a turn first. For PvP, a turn has to be as quick as on main. Two things add up:
- The facing. A walking turn eases at 540°/s at most, with 1440°/s² acceleration. With
StepEasedTurnat 60 fps, that's 0.63 s for 180°, 0.45 s for 90° and 0.3 s for 45°. On main,MovePathsnapped turns of 45° and more. Meanwhile the character already travels the new way, so for half a second it moves sideways or backwards. - The travel. On a turn of more than 90°,
StepMomentum(Momentum.cpp:44) keeps the character going the old way for 0.13 s and then speeds it up over 0.15 s. Compared with main, it ends up 0.25 s of full-speed travel behind. At Fenrir's top speed (19 units per 25 fps frame, 475 units/s) that's about 120 units, more than a tile, after first going about 25 units the wrong way. The 0.15 s ramp from rest costs another 0.075 s of travel at every start.
Suggestion: keep both as quick as on main. Face sharp turns at once and let the drawn sudden turn (UpdateSnapTurn, 180° in 0.15 s) show the turn, for example in MovePath:
// A sharp turn (a reversal) faces the new way at once, as on main; UpdateSnapTurn draws it in 0.15 s.
if (FarAngle(o->Angle[2], c->MoveHeading) >= SharpTurnDegrees)
{
o->Angle[2] = c->MoveHeading;
c->TurnSpeed = 0.f;
}
else
{
TurnTowardsMoveHeading(c);
}with SharpTurnDegrees at 45 like main, or 90. Also keep the travel itself as on main (full speed along MoveHeading from the first frame). If the slowing down should still show, it can be shown in the animation, not in where the character goes.
There was a problem hiding this comment.
| return; | ||
| } | ||
| c->Motion.NoddedAtHero = true; | ||
| if (!Greet(c)) |
There was a problem hiding this comment.
Required. In game, with two clients, the other character (a Summoner) bowed while walking. That is most likely this fallback: when Greet can't greet, the character nods, and Greet can't whenever it isn't standing. So a player walking, running or attacking near the hero, looking at it for 1.5 s, dips its head 25° and bows its body 5° (BowFor) in the middle of its walk or attack. The hero's reply at line 126 also nods and bows whatever the hero is doing at that moment.
The Hello has the opposite problem (line 70): the range PLAYER_STOP_MALE..PLAYER_STOP_RIDE_WEAPON includes PLAYER_STOP_FLY, PLAYER_STOP_FLY_CROSSBOW, PLAYER_STOP_RIDE and PLAYER_STOP_RIDE_WEAPON. A hovering winged player waves the on-foot Hello in mid-air, and a rider standing on a Uniria or Dinorant waves through its mount.
Suggestion: greet only from a standing pose on foot (o->CurrentAction <= PLAYER_STOP_WAND for the player skeleton). Otherwise skip the greeting, or at most turn the head, without the bow. Do the same for the hero's reply: let it nod back only while it stands.
There was a problem hiding this comment.
Fixed in f3afbce: only a character standing on foot greets; a nod stops when the character moves, and the hero nods back only while standing. Tests by action (walk, run, attack, fly, ride, emote).
| } | ||
| if (s_turningToCursor) | ||
| { | ||
| if (c->TurnPending && mayTurn) |
There was a problem hiding this comment.
Required. (From the code; not tried in game.) The end of a turn toward the cursor is reported wrongly in two cases:
- Cut short by an attack, a sit or a pose.
FinishPendingTurnends the turn because the action or the facing changed.TurnPendingis then false here, so line 2973 sendsAT_STAND1right after the attack or theAT_SIT1. Other clients runReceiveAction(AT_STAND1), which callsSetPlayerStop, so they see the hero's attack cut off, or the hero sit down and stand straight back up. - The mouse moves onto a window (or auto-attack takes the head) while the turn runs.
mayTurnis false butTurnPendingis still true, sos_turningToCursoris cleared and nothing is sent.FinishPendingTurndoesn't checkmayTurnand finishes the turn to the lastMoveHeading. Becauses_turningToCursoris now false, the end of the turn is never sent either. Locally the hero faces the new direction, while the server and the other players keep the old one.
Suggestion: keep following the turn until it ends, and send the facing only when the turn arrived by itself. For example, FinishPendingTurn could set a flag when it ends by arriving (next to its SetPlayerStop, cleared by StartStandingTurn), and here:
if (s_turningToCursor)
{
if (c->TurnPending)
{
// Only while the cursor may turn him; otherwise the turn finishes where it was going.
if (mayTurn)
c->MoveHeading = cursorAngle;
}
else
{
s_turningToCursor = false;
// Arrived, not cut short by an attack or a sit, which tell the server themselves.
if (c->TurnArrived)
SendRequestAction(Hero->Object, AT_STAND1);
}
}There was a problem hiding this comment.
Fixed in 32d81b3: the turn records whether it actually arrived, FollowCursorTurn keeps following until the end, and AT_STAND1 is sent only on arrival. Tests: arrival sends once; an attack or sit sends nothing; a cursor on a window finishes the turn and sends.
| // The feet step around while the body turns, rather than the character spinning on the spot. | ||
| if (!stepping) | ||
| { | ||
| SetPlayerWalk(c); |
There was a problem hiding this comment.
Required. (From the code; not tried in game.) On the first frame of a turn, this switches to the walk whenever nothing moved the character or changed its facing, but it doesn't check that the character still stands. An action set in between without a new facing is replaced by the walk, and the SetPlayerStop at the end of the turn leaves the character standing. Two cases:
- The Kanturu 2nd sit spot. Unlike the chairs, its sit doesn't set a facing (
ZzzInterface.cpp:1861). The hero walks there, and the walk ends before the eased facing has arrived, soMovePathsetsTurnPending.MoveHerothen runsAction(), which setsPLAYER_SIT1and sendsAT_SIT1. InMoveCharactersClientthis line replaces the sit with the walk, and the end of the turn stands the hero up. Locally it stands; everyone else sees it sitting. - A remote player's
AT_STANDand its death arrive in the same frame (orAT_STANDand an attack in its old direction). The death or attack animation is replaced by the walk.
Suggestion: before the first step, end the turn where it is unless the character is alive and still in the stop action SetPlayerStop gave it. That matches how the turn already ends when a new action arrives after the stepping has started.
There was a problem hiding this comment.
| } | ||
| // The blended pose's rotation, toward it by its weight (a head turned above keeps its turn). | ||
| const BoneMatrix_t* blendMatrixes = blending ? &b->BoneMatrixes[Blend->Action] : nullptr; | ||
| const bool headTurned = q2 != bm2->Quaternion[currentAnimationFrame]; |
There was a problem hiding this comment.
Non-blocking. This skips the fade for every bone whose rotation comes from the head turn, and with Enhanced Movement those are Head, Neck, Spine1 and Spine. The chain is filled whenever HeadAngle isn't zero. For the hero that is almost always, since its head follows the cursor; for others it is whenever they look at someone. During a fade the two spine bones then jump to the new action at once while the rest of the body fades. From a run to standing, the run's forward lean is gone on the first frame of the 0.25 s fade, which is the snap the fade is meant to remove. To see it, run and stop with the cursor off to one side.
Suggestion: blend these bones too, turned the same way. Take the faded action's key rotations for the bone (blendMatrixes->Rotation[blendKey1] and [blendKey2]), subtract the bone's share from [0] (and, for the head, the nod from [2]) as for the current pose above, and blend toward that instead of skipping the bone.
There was a problem hiding this comment.
Fixed in 3cb306c: the turned bones fade too, turned the same way. The test fails without the fix.
| if (step > 0.f) | ||
| { | ||
| // (Slowing to a stop or speeding up, at the share of its speed it has: StepMomentum.) | ||
| PlaySpeed = CharacterMoveSpeed(c) * c->Motion.MomentumPace / (step * o->Scale); |
There was a problem hiding this comment.
Non-blocking, question. The steps play at the linear MomentumPace, but the character moves at what StepMomentum returns, which is eased (pace² × (3 − 2 × pace)). At a pace of 0.3 it moves at 0.22 of its speed while its steps play at 0.3, so the feet run a little ahead of the ground. Is the linear pace meant here? This doesn't keep any speed, since the movement already uses the eased value. If the travel goes back to main's speeds (ZzzAI.h:49), this goes away too.
There was a problem hiding this comment.
Fixed: the steps now play at the eased pace the body moves at (Motion.MomentumSpeed), so the feet keep to the ground while setting off. Test added. (dc80adc)
| OBJECT* o = &c->Object; | ||
| float Matrix[3][4]; | ||
| AngleMatrix(o->Angle, Matrix); | ||
| const vec3_t direction = {o->Angle[0], o->Angle[1], heading}; |
There was a problem hiding this comment.
Non-blocking. Angle[0] now holds the slope lean (UpdateSlopeLean: up to 25° riding, 10° walking) and the nod's bow. AngleMatrix turns the step (0, -speed, 0) by it as well, and the vertical part is lost when Position[2] is set from the terrain below. So ground speed becomes speed × cos(Angle[0]). That's a few percent at most on usual slopes, which I couldn't see in game, and up to 9% for a rider at the 25° cap. It's a one-line fix, though:
// The slope lean and the nod's bow tip the body, not the way it travels.
const vec3_t direction = {o->Angle[0] - c->Motion.SlopePitch - c->Motion.NodBowApplied, o->Angle[1], heading};There was a problem hiding this comment.
Fixed in aaec9f4 with your one-line fix. Test included.
| return 1.f; | ||
| } | ||
| const float seconds = FrameSeconds(); | ||
| if (c->Motion.MomentumAt < 0.0 || WorldTime - c->Motion.MomentumAt > MomentumRestMilliseconds || |
There was a problem hiding this comment.
Non-blocking. WorldTime is real time, but FrameSeconds() never goes above 0.04 s, because CalcFPS clamps FPS_ANIMATION_FACTOR to 1. Below 10 fps every frame is longer than 100 ms, so every frame starts from rest, and walkers move at about 18% of their speed for as long as the game stays that slow. I couldn't test it, because the frame limit goes down only to 24 fps; it would take a real drop under load. If the travel goes back to main's speeds (ZzzAI.h:49), this goes away. Otherwise, count the gap in frames (RENDERED_FRAME), not milliseconds.
There was a problem hiding this comment.
Fixed: rest is now counted in rendered frames (MomentumRestFrames), not world time, so a client below 10 fps keeps its speed between steps. Test at 6 fps added. (dc80adc)
| // It turns with its rider's drawn body, which catches up with a sudden turn (UpdateSnapTurn). | ||
| if (rider != nullptr) | ||
| { | ||
| o->Angle[2] += rider->Motion.SnapTurnOffset; |
There was a problem hiding this comment.
Non-blocking. Mounts holds the Guardian Angel too (MODEL_HELPER), so it goes through this function. Unlike the ridden mounts, it doesn't copy its owner's angles each frame, so this line adds the rider's SnapTurnOffset to its own facing on every frame of a sudden turn. The function also gives it twice its owner's roll and sets its model's BoneHead. I couldn't see an effect in game (it flies around on its own anyway, and the extra spin lasts 0.15 s). Still, the mount feel is meant for the four mounts, so I'd limit the call in MoveMount (line 739) to them:
// The mounts a player rides; the Guardian Angel flies on its own.
bool IsRiddenMount(int type)
{
return type == MODEL_UNICON || type == MODEL_PEGASUS || type == MODEL_DARK_HORSE ||
(type >= MODEL_FENRIR_BLACK && type <= MODEL_FENRIR_GOLD);
}There was a problem hiding this comment.
Fixed in e0de785: IsRiddenMount limits the mount feel to the four mounts; other helper slots, the Guardian Angel included, stay at zero. No test, since the helper is file-local.
| if (!Engine::Characters::EnhancedMovementEnabled()) | ||
| { | ||
| // As before: the model's own head bone, the rider's angles and head as copied, no shake. | ||
| b->BoneHead = ownHeadBones[o->Type]; |
There was a problem hiding this comment.
Non-blocking. The description has a list of "Fixes on the way (they apply with the option off too)". Two of the three only work with the option on:
- The Dark Horse's head. With the option off, this line puts the model's own
BoneHeadback. That is the bone 7 thatMoveMountsets every frame, the one the description calls a body part. So with the option off, the Dark Horse still turns bone 7. - "A mount in a safe zone isn't treated as ridden". That check is
IsRiding, and only the new features use it: the flight bank and mount lean, the slope lean and the foot placement. All of these are off with the option off, so nothing that runs with the option off changes.
Only the wing fix (Wings.cpp) runs with the option off. Either make the other two independent of the option, or move them out of that list.
There was a problem hiding this comment.
Agreed. The Dark Horse head and the safe-zone riding check are part of the option, so I moved them out of "Fixes on the way" into the Mounts row. Only the wing fix applies with the option off.
Filtered import onto upstream base 215d4fc. Excluded: Android/iOS entry points, touch controls, mobile HUD and layout editor, mobile event panel, mobile graphics presets, vendored ThirdParty sources, mobile build/launcher files and shaders; __ANDROID__/MU_IOS blocks removed from imported sources. Also excluded: upstream PR sven-n#868 (Enhanced Movement), which TwinMU-S6-Mobile carried unmerged and which conflicts with upstream's later pose rewrite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U8g9wnuqzx1fngfsm3ytha
Ports the TwinMU gameplay/content features into the PC client, without the mobile platform layer (touch HUD, Android/iOS, low-graphics/render scaling, mobile chat/minimap/options UI) and without unmerged upstream PR sven-n#868. Ported: - FinalMU custom items/skins, cosmetic armor, skin inventory and skin shop - Muun inventory, Muun mounts, mount companions, Fenrir skins - Jewel Bank (top bar BANK button, Window menu entry) - Excellent Combination, Event Schedule, Redeem Codes - Store Mail, multi-currency personal shop, combat statistics - Saved-accounts login, KMUA2 loading screen - MU Helper paid self-defense lease - Custom packets C2 FD 01/02/03/05/06, FA 19, FB 21, C1 FE - OpenMU protocol fixes (siege lists, hunt zone, shield damage, transform viewport) - Item JSON merged as a union; no item index collisions with upstream Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U8g9wNUqZX1fnGFSm3ythA
Conflicts and what replaced the branch's way: - BMD::Animation: the head turn spread into the neck and spine, the pose fade, the ponytail lag and the mount's head turn now work on main's sampled keys (AnimationSampling); a glTF model keeps main's head turn and its own crossfade. - Bone builds: main builds a pose once in the update and reuses it in the draws (Engine::Object::Pose). Pose::Build, Pose::World and DrawPose now go through Engine::Characters::AnimateBones, and the pose's recorded inputs include what the movement features add (CurrentMovementPoseKey), so a change to them rebuilds it. - Wings on the back: PlaceLinkedPart takes the pose's bones; the wings are placed from them. - Tests: main's mu_test_winmain replaces the branch's; the branch's FindBone(const char*) gives way to main's FindBone(string_view). - The head-turn and ponytail bones are copied by ShareFrom and SwapData.
…ps main's speed A fast change of direction, such as a 180 degree turn on Fenrir, played a slow eased turn and kept going the old way for a moment (review: bad for PvP). - A walking turn of 45 degrees or more faces the new way at once, as on main; the drawn sudden turn (UpdateSnapTurn) shows it in 0.15 s. A gentler turn still eases. - Momentum is gone: a walker travels at full speed along its heading from the first frame, as on main, and the steps play at that speed. This also drops the eased-vs-linear pace mismatch and the start from rest below 10 fps. Tests: a reversal faces and travels the new way at once, where it would without the option; a gentle turn eases while the walker already travels the new way.
A Summoner bowed in the middle of its walk (review): when it couldn't wave its Hello because it wasn't standing, it nodded instead, and the Hello's range of stands took in the flying and riding ones. - A player (or an NPC on the player skeleton) greets only from a stance on foot: the plain stands, not flying or riding. Another NPC or a monster from its standing actions. Walking, fighting, flying or riding, it doesn't greet; it may once it stands, still looking. - A nod under way stops when the character does anything else, and its bow comes off. - The hero nods back only while it stands on foot; otherwise only its head turns to the one who greeted it. Tests: who greets, by action (stands, walk, run, attack, fly, ride, an emote); a nod stops when the character walks; the hero answers only standing.
…s first step The first step of a standing turn switched to the walk whenever nothing had moved the character or changed its facing, without checking that it still stood (review). An action set in between was replaced by the walk, and the end of the turn stood the character up: the hero walking to the Kanturu sit spot stood up locally while the others saw it sit, and a remote player's death or attack arriving with its AT_STAND was replaced by the steps. A standing turn now remembers the stance it starts from (the action the character stood in when StartStandingTurn started it, or the one SetPlayerStop gave it when the walk ended). Before the first step, a character that died or has another action ends the turn where it is, as a new action already did once the stepping had started. Tests: a sit, an emote and death set before the first step stay, and the turn ends where it is.
…it arrives From the review (not seen in game): - A turn cut short by an attack, a sit or a pose sent AT_STAND1 right after it, so the other clients saw the attack cut off or the hero sit down and stand straight back up. - A turn under way when the cursor went onto a window (or auto-attack took the head) was dropped from the follow, finished locally, and its end was never sent: the hero faced one way here and another for everyone else. FinishPendingTurn now records whether a standing turn ended by arriving (TurnArrived). FollowCursorTurn keeps following the turn until it ends, heads for the cursor only while the cursor may turn the hero, and reports the arrival; TurnToCursor sends the facing only then. Tests: the facing is sent once when the turn arrives; nothing is sent when an attack or a sit cut it short; with the cursor on a window the turn finishes where it was going and that is sent.
…ns, too With Enhanced Movement the head's turn reaches Head, Neck, Spine1 and Spine, and the pose fade skipped those bones whenever the head was turned, which for the hero is nearly always (review). From a run to standing the run's forward lean was gone on the first frame of the fade, the snap the fade is there to remove. The pose faded out of is now sampled for the turned bones too, turned the same way (each bone's share of the turn, and the nod for the head), and blended like every other bone. Test: with the head turned and all of the run still faded in, the head, neck and spine show the run, not the standing pose (it fails without the fix).
Every emote of the shipped player model (Greeting to Salute) is started on a standing player while a standing turn is under way, and the frame's movement steps run with it (the standing turn, the nods and greetings, the pose fade in CharacterAnimation). The emote is never cut off or replaced, plays to its end, and the player goes back to the stance SetPlayerStop gives it; the turn gives way where it was.
…ing while it's dead, stunned or asleep The hero's flight feel, turn lag and slope lean ran in MoveHero after its early returns (dead, stunned, asleep, sliding, a cutscene, loading), so they froze in those states (review): killed walking uphill, it kept its slope pitch through the death animation; stunned in a banked flight, it stayed rolled. They now run for every character, the hero too, in MoveCharacterClient after its move; MainScene runs MoveCharactersClient right after MoveHero, so for the hero they still come after its own move.
ReceiveAction (and a teleport) put a character back on its tile centre but left Motion.FlightPivotShift as it was (review). UpdateFlightFeel then added only the difference to it, and MovePath took the old shift off again later, so a winged player that received an action mid-bank stood about 9 units off its tile from then on, through its next walks. ForgetFlightPivotShift clears the shift wherever the server sets the position; UpdateFlightFeel adds this frame's back. Test: after a position from the server, the next walk takes off no shift.
MoveCharacterPosition turned the step by the body's pitch, which now holds the slope lean (up to 25 degrees riding) and a nod's bow; the height comes from the terrain, so the ground speed became speed x cos(pitch), up to 9% slower for a rider (review). The step now leaves out the pitch those two add. Test: a leaning, bowing walker covers its whole step on the ground.
Mounts holds the Guardian Angel and the other helpers too, and the mount feel ran for them (review): it added its owner's sudden-turn offset to the angel's own facing every frame of a sudden turn, doubled its owner's roll and set its model's head bone. The feel now runs only for the mounts a player rides (Uniria, Dinorant, Dark Horse, Fenrir); the other slots' head turn and roll stay at zero.
…ith the head, as its BMD does After the merge of main, a BMD spread the head's turn into the neck and spine with Enhanced Movement on, while a model from a glTF binary turned only its head, so the two drew different poses and main's glb_model tests failed. The glTF joints of the turned bones now take the same shares (SkinnedModel::TurnHead, the head with its nod).
… does The `bones` check compared a reused pose with a plain BMD::Animation, so every pose with something from Enhanced Movement in it (a drawn sudden turn, a fade, the feet) counted as a mismatch. It now builds the fresh pose with Engine::Characters::AnimateBones, like every other build. In game (Lorencia, a walk with a reversal): 4707 reused poses checked, 0 mismatched.
…tay as quick as on main Momentum comes back for starts only, faster than before: a walker setting off from rest reaches its full speed in 0.06 s (about 0.03 s of travel lost, under a step). Turns keep the speed the walker has, a reversal too: there is no slowing to a stop the old way, and a turn of 45 degrees or more still faces and travels the new way at once. Also fixes the review's two momentum points: - A pause counts as rest by rendered frames (RENDERED_FRAME), not world time, so below 10 fps a walker no longer starts every step from rest. - The steps play at the eased pace the body moves at (Motion.MomentumSpeed), so the feet don't run ahead of the ground while setting off. The tunables (MomentumStartSeconds, MomentumRestFrames, SharpTurnDegrees) live together in Movement/MovementTuning.h, each with its unit and what raising or lowering it does; the tests derive from them. Tests: a start from rest reaches full speed within MomentumStartSeconds at 25, 60 and 240 fps; at 6 fps a walker keeps its speed, a pause up to the rest gap keeps it and a longer one starts over; the steps play at the eased pace; the option off moves at full speed at once.
|
Thanks for the thorough review. Every thread is addressed with ordinary commits on top (replies inline), and the description is updated. Main is merged in (latest ecc9b7a); after that merge, one test name lost its semicolon so CTest keeps it whole, and |
|
i will look at it in game tonight :D |
|
resolv conflicts so i can look at it again :D |
…t-clean # Conflicts: # src/source/UI/Options/OptionWindow.cpp # tests/gamelogic/CMakeLists.txt # tests/ui/test_ui_scaling.cpp
|
Conflicts resolved: merged current main in 68b50ed (both sides kept where Sunlight and Enhanced Movement were added next to each other). Windows x64 Release builds and all 2387 tests pass. |
Mosch0512
left a comment
There was a problem hiding this comment.
Verdict: changes requested for three items; the rest is non-blocking. Thanks for the fixes. I went through all 12 earlier threads in the code at 68b50ed, and each one is fixed as your replies describe: a sharp turn faces and travels the new way at once, only a character standing on foot greets, the turn toward the cursor tells the server only when it arrives, and a standing turn gives way to a sit, an emote or death. Reading the fix commits and the whole source diff again, I found three new bugs to fix before merging, plus a few smaller points. All of them come from the code; I haven't tried this head in game yet.
Required
- When a walk interrupts a standing turn,
TurnActionstays set, and the next standing turn is dropped on its first frame. Other players can then face the wrong way (inline, ZzzAI.cpp:610). - A reused character slot keeps the last character's movement state, so a new character, or the hero after a map join, can stay tilted (inline, w_CharacterInfo.cpp:88).
- A turn toward the cursor that starts during an emote replaces the emote with its steps (inline, ZzzInterface.cpp:2971).
- A test for each of the three.
Non-blocking
- A knock-back or the server's position correction keeps the hover and the pivot shift, so a hovering player can dip into the ground (inline, WSclient.cpp:3699).
- The lean, the bow, the bank and the hover are kept as deltas on
AngleandPosition; applying them when the bones are built would avoid this kind of bug (inline, SlopeLean.cpp:58). - A nod freezes while the character is off screen or stunned (inline, ZzzCharacter.cpp:5625).
- Three tests put global state back by hand after
REQUIREs (inline, test_character_realism_bones.cpp:444). - A second
IsFlyingwith a different meaning (inline, FlightFeel.cpp:40). - The movement settings are hard-coded; the coding rules now ask for data and an editor (inline, MovementTuning.h:10).
What I checked: the fix commits from 10818e9 to c772798 and the source diff against main at 68b50ed, with the functions they touch: MovePath, StartStandingTurn, FinishPendingTurn, FollowCursorTurn, TurnToCursor, ReceiveAction, ReceiveMovePosition with PushingCharacter, CreateCharacter with CreateCharacterPointer, CharacterAnimation, MoveCharacterVisual and BMD::Animation. CI on 68b50ed is green, the Windows build included.
| bool Success = false; | ||
| PATH_t* p = &c->Path; | ||
| // Walking again: the turn the last walk left is this walk's now. | ||
| c->TurnPending = false; |
There was a problem hiding this comment.
Required. (From the code; not tried in game.) This clears TurnPending but leaves TurnAction set. StartStandingTurn doesn't reset it either, and FinishPendingTurn, the only place that does, returns at once while no turn is pending. So when a walk interrupts a standing turn that is already stepping, TurnAction stays the walk action. The next standing turn then counts as already stepping: sameAction compares the stand action with the old walk action, and the turn ends on its first frame.
For example, another player turns (AT_STAND1), and on this screen the turn steps for up to 0.6 s. Meanwhile that player clicks to walk. When they turn again later, ReceiveAction calls SetPlayerStop and StartStandingTurn, and FinishPendingTurn drops the turn. On this screen they keep facing the old way, up to 180° off, until their next action. The same happens without a walk when two AT_STAND1 arrive within one turn, for example from a client with the option off at a high frame rate (SnapToCursor sends every 40 frames, 0.28 s at 144 fps). For the hero, it drops the turn at the end of a walk and the next turn toward the cursor, which starts again 0.5 s later.
The test "A standing turn starts only for a real change and gives way to anything else that turns the character" sets Movement and calls FinishPendingTurn directly, so its walk never goes through MovePath. That is how this got through.
Suggestion: clear it wherever a turn ends or a new one starts, here:
// Walking again: the turn the last walk left is this walk's now, and a standing turn's steps are over.
c->TurnPending = false;
c->TurnAction = -1;
c->TurnArrived = false;and with c->TurnAction = -1; in StartStandingTurn. A test: a standing turn that is stepping, a walk through MovePath to its end, then StartStandingTurn; the new turn steps and arrives.
There was a problem hiding this comment.
Fixed in 1032d34: MovePath clears TurnAction together with TurnPending, and StartStandingTurn starts every turn from standing (a turn that is still stepping stops first, then TurnAction = -1), so two AT_STAND1 close together work too. Tests: a stepping turn, a walk through MovePath to its end in MoveHero's order, then a new turn that steps and arrives (it was dropped on its first frame and stayed 180° off before the fix); and a second turn while the first still steps.
| TurnSpeed = 0.f; | ||
| TurnStance = -1; | ||
| TurnArrived = false; | ||
| Motion.Reset(); |
There was a problem hiding this comment.
Required. (From the code; not tried in game.) This is the only place the movement state is reset, and Initialize runs only in the CHARACTER constructor. A new character, though, gets a used slot: CreateCharacter takes a free slot (or the one with the same key), and CreateCharacterPointer resets its Angle and Position but not Motion, MoveHeading or the turn fields. The hero is no exception: ReceiveJoinMapServer picks a random slot and calls CreateCharacterPointer.
Because the lean, the bow and the bank are added to Angle as deltas, the old values become a lasting tilt. For example, a rider on a hill (SlopePitch -15°) leaves the screen, and a monster or player spawns in its slot with Angle[0] = 0. UpdateSlopeLean eases SlopePitch back to 0 with Angle[0] += pitch - SlopePitch, so Angle[0] ends at +15° and stays there, since nothing else resets it. The other fields cause similar problems:
- A stale
FlightBankrolls the new character the same way, and its mount twice as far. NodBowAppliedadds up to 5°.- A stale
SnapTurnFacingspins it into its facing. FadeLastActionfades it in from the old character's pose.- A pending turn may carry on the old character's turn.
The hero can pick up a tilt like this after a re-login or a server change. The new animation-pipeline.md also says this state is "reset with the character".
Suggestion: one function that resets the movement state, called by Initialize and by CreateCharacterPointer (after it sets the angle):
// A new character in this slot: none of the last one's movement state.
void CHARACTER::ResetMovement()
{
MoveHeading = Object.Angle[2];
TurnPending = false;
TurnLeftAt = 0.f;
TurnAction = -1;
TurnSpeed = 0.f;
TurnStance = -1;
TurnArrived = false;
Motion.Reset();
}A test: a character with a slope lean, a bank and a bow, then CreateCharacterPointer on its slot; after a few frames the new character stands upright.
There was a problem hiding this comment.
Fixed in c4fbd28 with your ResetMovement: Initialize calls it, and CreateCharacterPointer calls it after it sets the angle, so every CreateCharacter and the hero's ReceiveJoinMapServer start clean. It also takes the old nod off the head first. The monster recorder's field lists now include the movement state, so a dirty slot fills it too. Test: a dirty slot with a slope lean, a bank, a bow and a turn under way; the spawn has none of it and stays upright over the next frames.
| void TurnToCursor(CHARACTER* c, int heroX, int heroY, bool lookAtMouse) | ||
| { | ||
| OBJECT* o = &c->Object; | ||
| const bool mayTurn = |
There was a problem hiding this comment.
Required. (From the code; not tried in game.) mayTurn leaves out sitting, the poses and some skills, but not the emotes. A turn toward the cursor that starts during an emote records the emote as TurnStance (StartStandingTurn). FinishPendingTurn then sees the stance unchanged, and its first step calls SetPlayerWalk: the emote is replaced by the turn's steps, followed by SetPlayerStop and AT_STAND1.
For example, the hero types "hello" (SetActionClass plays PLAYER_GREETING1), and during the greeting the mouse or the camera moves the cursor more than 90° from where the hero faces. After 0.5 s the greeting stops and the hero shuffles around. On main the emote kept playing here, since SnapToCursor only changed the facing. The new emote test covers the other order (first the turn, then the emote), which works.
Suggestion: start a turn only while the hero stands in the stance SetPlayerStop gave it, which SetPlayerStop records in TurnStance, so an emote plays to its end first. This has to go into the condition that starts the turn, not into mayTurn: during the turn the hero plays its steps, and FollowCursorTurn still has to follow the cursor.
// Only standing: an emote plays to its end before the hero turns toward the cursor.
const bool standing = o->CurrentAction == c->TurnStance;
...
else if (mayTurn && standing && FarAngle(o->Angle[2], cursorAngle) > CursorTurnDegrees)If TurnStance isn't reliable enough for this, a helper that lists SetPlayerStop's stances works too. A test: an emote first, then a turn toward the cursor; the emote plays to its end.
There was a problem hiding this comment.
Fixed in fd8d5bc as you suggested, in the condition that starts the turn: the start moved into CursorTurnDue (ZzzAI), which also needs CurrentAction == TurnStance, the stance SetPlayerStop recorded. FollowCursorTurn is unchanged, so a turn under way still follows the cursor. Test: "hello" on the real player model with the cursor behind; the greeting plays to its end facing where it was, and the turn starts once he stands again.
|
|
||
| c->Object.Position[0] = c->TargetX * TERRAIN_SCALE + TERRAIN_SCALE * 0.5f; | ||
| c->Object.Position[1] = c->TargetY * TERRAIN_SCALE + TERRAIN_SCALE * 0.5f; | ||
| Engine::Characters::ForgetFlightPivotShift(c); |
There was a problem hiding this comment.
Non-blocking. (From the code; not tried in game.) Thanks, this covers ReceiveAction and the hero's teleport. One more place puts a character where the server says: ReceiveMovePosition (a knock-back, or the server correcting a position) starts PushingCharacter, which slides the character to the tile, sets Position[2] to the terrain every frame and ends on the tile centre. It keeps both the pivot shift and FlightHoverApplied.
When a hovering winged player is knocked back, UpdateFlightFeel afterwards adds only height - FlightHoverApplied to the terrain height. Its drift ends up lower by the height it had when the slide ended (up to 30 units), so it dips into the ground at the bottom of each cycle until its next walk resets the height. Its next MovePath also starts off by the old pivot shift. The hero's height is reset by the camera every frame, so for the hero only the pivot shift is affected.
Suggestion: ForgetFlightPivotShift(c) in ReceiveMovePosition, and c->Motion.FlightHoverApplied = 0.f where PushingCharacter sets the height, as MoveCharacterPosition does. Or see the next comment.
There was a problem hiding this comment.
Fixed in 198d12c: ReceiveMovePosition forgets the pivot shift, and PushingCharacter clears FlightHoverApplied wherever it sets the height to the terrain and forgets the pivot shift again when the slide ends on the tile centre (the bank can add it back during the slide). Test included.
| const float pitch = std::fabs(wanted - c->Motion.SlopePitch) < 0.01f | ||
| ? wanted | ||
| : c->Motion.SlopePitch + (wanted - c->Motion.SlopePitch) * ease; | ||
| o->Angle[0] += pitch - c->Motion.SlopePitch; |
There was a problem hiding this comment.
Non-blocking, suggestion. The slope lean here, the nod's bow, the flight bank, the hover and the pivot shift are all added into Object.Angle and Object.Position as deltas, with the last value added kept in Motion. Any other code that sets those fields breaks that bookkeeping. The reused slot and the knock-back are two cases, and the earlier pivot fix had to patch ReceiveAction and the teleport one by one. The drawn sudden turn already avoids it: SnapTurnOffset is added in AnimateBones when the bones are built and never stored in Angle. Passing the lean, the bow and the bank the same way (into AnimateBones' angle), and adding the hover to the height only when drawing, would remove the bookkeeping and this whole kind of bug. If that's too big for this PR, a follow-up is fine.
There was a problem hiding this comment.
Agreed that this is the better design, and SnapTurnOffset shows it works. I'd rather do it as a follow-up PR than here, because it's bigger than it looks: Object.Angle and Object.Position aren't read only by the body's bone build. The rider's mount, the wings, the weapons and other linked parts, the shadow, the body's bounding box and several effects build their own matrices from them, and the camera follows the hero's height. All of those would need the same offset passed along, or a mount would stop tilting with its rider and the wings would detach from a banked back. Moving them is a renderer change that needs its own in-game pass on mounts, wings and effects.
With this round, every place I found that sets the angle or position from outside now resets the bookkeeping: ReceiveAction, the teleport, ReceiveMovePosition with PushingCharacter, and slot reuse. So the follow-up is a cleanup rather than a bug fix. If you'd rather have it in this PR, I can do it here.
| } | ||
| } | ||
|
|
||
| Engine::Characters::RemoveNod(c); |
There was a problem hiding this comment.
Non-blocking. RemoveNod and UpdateNod run only inside if (o->Visible) and the check for Harden, Stun, Sleep and the three Ourforces buffs. If a character goes off screen or gets one of those buffs during a nod, it keeps the head dip and the 5° bow until it is visible again or the buff ends. Its nod cooldown also stops, and an NPC's greeting doesn't go back to standing. Suggestion: call RemoveNod and UpdateNod outside that block (the smoothing between them can stay inside it), or end the nod there.
There was a problem hiding this comment.
Fixed in 1246ab3: when the head doesn't move this frame (off screen, or Harden, Stun, Sleep or one of the Ourforces buffs), RemoveNod and UpdateNod still run, so the nod plays out, its cooldown counts down and an NPC's greeting goes back to standing. Only the head smoothing between them stays in the visible block. No new test: the path needs a model with actions, and the nod itself is covered by the greeting tests.
| { | ||
| PlayerModel player; | ||
| BMD& model = player.model; | ||
| const bool wasEnabled = Engine::Characters::EnhancedMovementEnabled(); |
There was a problem hiding this comment.
Non-blocking. This test, the pose fade test (line 399) and the walker's steps test (line 517) change Enhanced Movement and FPS_ANIMATION_FACTOR and put them back at the end, with REQUIREs in between. A failing REQUIRE ends the test case before the restore. Every later test in the binary then runs with the option forced on and the frame factor at 1 or 0.25, so one failure turns into many. test_smooth_turning.cpp already has guards for both (EnhancedMovementSwitch, AnimationFactor); these three could use them too.
| c->Helper.Type == MODEL_DARK_HORSE_ITEM || c->Helper.Type == MODEL_HORN_OF_FENRIR); | ||
| } | ||
|
|
||
| bool IsFlying(const OBJECT* o) |
There was a problem hiding this comment.
Non-blocking. main already has a global IsFlying(const OBJECT*) in ZzzCharacter.cpp, true only for PLAYER_FLY and PLAYER_FLY_CROSSBOW. This one has the same name and signature but also counts hovering (PLAYER_STOP_FLY, PLAYER_STOP_FLY_CROSSBOW). Inside Engine::Characters a call finds this one, and outside it finds main's. Moving code between the two, or a using namespace Engine::Characters, would change what a call means without a warning. Suggestion: name this one for what it checks, for example IsFlyingOrHovering.
There was a problem hiding this comment.
Renamed to IsFlyingOrHovering in 4a28d2a.
| // How long a walker setting off from rest takes to reach its full speed (seconds; StepMomentum, eased). Raising it | ||
| // makes the start heavier and loses more travel at every start (about half of it at full speed: 0.03 s here); | ||
| // lowering it towards 0 sets off at full speed at once, as without Enhanced Movement. | ||
| constexpr float MomentumStartSeconds = 0.06f; |
There was a problem hiding this comment.
Non-blocking. Since this PR was opened, docs/CODING_RULES.md (which CLAUDE.md and AGENTS.md point to for all code changes) starts with "Content and settings that a designer, admin or modder would want to change are data, not code". It also says a new feature with settings ships as data plus a MuEditor tool. This file describes its constants as tunables kept "together so they can be retuned in one place", and the flight, slope, nod, look-at, turn lag and pose fade constants are the same kind. A follow-up PR that moves them into a data file with an editor window would satisfy the rule; I wouldn't hold this PR for it. Also, under rule 3, a few numbers have no name yet: c->Key * 0.37f in UpdateFlightFeel, Random::RangeFloat(0.5f, 1.5f) in UpdateIdleGlance and Random::RangeFloat(0.f, 1.5f) in StepMountShake.
There was a problem hiding this comment.
Agreed. I'll do it in a follow-up PR: the movement tuning (turns, flight, slope, nods, look-at, turn lag, pose fade) moves into a data file with a MuEditor window, following CODING_RULES. The three bare numbers have names now (FlightHoverPhasePerKey, FirstIdleGlanceGapSeconds, MountFirstShakeSeconds) in 4a28d2a.
…t-clean Conflicts: Winmain.cpp keeps both start-up calls (the live monster setup and Enhanced Movement). EffectRecorder.cpp takes main's shared RecorderFields.h, which now lists the movement state too: OBJECT's Pose.Movement, CHARACTER's turn fields and its Motion (a field list of its own), with the new sizes.
… the next one A walk that interrupted a standing turn while it stepped left TurnAction set (MovePath cleared only TurnPending), so the next standing turn counted as already stepping and ended on its first frame: other players could keep facing the old way, up to 180 degrees off. MovePath now clears TurnAction, and StartStandingTurn starts every turn from standing (a turn still stepping stops first). Tests: a walk through MovePath to its end, then a turn that steps and arrives; a second turn while one still steps. The guards for the option and the frame factor move to tests/data/MovementTestScopes.h.
…one's movement state CreateCharacter reuses slots (and the hero takes one on every map join), but only Initialize reset MoveHeading, the turn fields and Motion. The lean, bow and bank are deltas on Angle, so the old values became a lasting tilt; a stale snap turn, pose fade or pending turn carried over too. The reset is now CHARACTER::ResetMovement, called by Initialize and by CreateCharacterPointer after it sets the angle (which also takes the old nod off the head). Test: a dirty slot with a slope lean, a bank, a bow and a turn; the spawn starts with none of it and stays upright over the next frames.
A turn toward the cursor that started during an emote took the emote as its stance and replaced it with its steps (the hero said "hello", the cursor went behind him, and half a second later the greeting stopped). The start of the turn moves from TurnToCursor into CursorTurnDue (ZzzAI), which now also needs the hero to stand in the stance SetPlayerStop gave him (TurnStance); the emote plays to its end, then the turn starts. The turn in progress still follows the cursor as before. Test: the greeting on the real player model with the cursor behind; it plays to its end facing where it was, then the turn starts. The emote test uses the option and frame-factor guards.
ReceiveMovePosition (a knock-back, or the server correcting a position) slides the character to its tile in PushingCharacter, which sets the height to the terrain but kept FlightHoverApplied and the pivot shift: a hovering player then dipped into the ground at the bottom of each drift, and its next walk started off by the old shift. ReceiveMovePosition and the end of the slide now forget the pivot shift, and the slide clears the applied hover wherever it sets the height, as MoveCharacterPosition does. Test: a hovering, banked flyer slid to its tile keeps neither, and its next walk starts from the tile centre.
…en or stunned RemoveNod and UpdateNod ran only while the character was visible and free of Harden, Stun, Sleep and the Ourforces buffs, so a nod caught by one of those kept its head dip and bow, its cooldown stopped, and an NPC's greeting didn't go back to standing. They now run every frame; only the head smoothing between them stays limited to a visible, free character.
…nd frame factor with guards They set Enhanced Movement and FPS_ANIMATION_FACTOR and put them back by hand after REQUIREs, so one failure left every later test in the binary with the option forced on and another frame factor. They use the guards of MovementTestScopes.h now.
…uning numbers The flight feel's IsFlying had the same name and signature as main's global IsFlying but also counted hovering; it is IsFlyingOrHovering now, so a call can't change meaning with a namespace. The hover's per-character phase, the first idle glance's gap and a mount's first head shake get named constants.
|
Thanks for the careful pass. All three required items are fixed, each with a test that fails without its fix (1032d34, c4fbd28, fd8d5bc). Of the non-blocking ones, the knock-back hover and pivot shift (198d12c), the nod off screen (1246ab3), the test guards (8a65881) and the Main is merged in again (29f9ec5). The one real conflict was |
Mosch0512
left a comment
There was a problem hiding this comment.
Verdict: changes requested for two items; the rest is non-blocking. Thanks again. I checked all seven new commits at 4a28d2a, and the round-2 points are fixed as your replies describe: a walk no longer drops the next standing turn, a reused slot starts clean, an emote plays out before the cursor turn, a knock-back keeps no hover or pivot shift, the nod plays out when the head is frozen, the tests use guards, and IsFlyingOrHovering has its name. Doing the two bigger points as follow-up PRs is fine with me: the lean and the hover applied when drawing, and the movement tuning as data with an editor window. I also played a Release x64 build of this head and like it a lot.
Required
- Changing maps resets the hero's forward tilt but keeps the slope lean and the bow, so a hero riding on a hill stays tilted after the Move command (inline, WSclient.cpp:2280).
- Please ship Enhanced Movement off by default (inline, GameConfigConstants.h:161).
- A test for each.
Non-blocking
- While the head is frozen (a stun, an Ourforces buff), a character can still start a greeting (inline, ZzzCharacter.cpp:5593).
- The end of a standing turn plays a monster's stand sound again, so idle sounds come more often (inline, ZzzAI.cpp:571).
What I checked: the commits 1032d34 to 4a28d2a, the merge of main (29f9ec5; only the recorder field lists and the start-up calls in Winmain.cpp changed, and the PR's source diff has no other changes), and every other place that sets a character's angle or position: CreateCharacterPointer, ReceiveAction, ReceiveTeleport with LoadWorld, ReceiveMovePosition with PushingCharacter, the Kanturu cutscene and the falling monsters. The new points come from the code; I haven't tried them in game.
| OBJECT* o = &Hero->Object; | ||
| o->Position[0] = ((float)(Hero->PositionX) + 0.5f) * TERRAIN_SCALE; | ||
| o->Position[1] = ((float)(Hero->PositionY) + 0.5f) * TERRAIN_SCALE; | ||
| Engine::Characters::ForgetFlightPivotShift(Hero); |
There was a problem hiding this comment.
Required. (From the code; not tried in game.) There is one more place that sets the hero's angle from outside. A teleport to another map calls LoadWorld, which calls g_Direction.HeroFallingDownInit() (MapManager.cpp:941), and that sets Hero->Object.Angle[0] = 0 (CDirection.cpp:393). It keeps Motion.SlopePitch and Motion.NodBowApplied, and a teleport doesn't go through ResetMovement. So the slope lean's bookkeeping breaks the same way it did for reused slots.
For example, the hero rides Fenrir standing on a hill, so SlopePitch is -12° and part of Angle[0]. They use the Move command to another map, and Angle[0] becomes 0. On the new map, UpdateSlopeLean eases SlopePitch from -12° to the new slope with Angle[0] += pitch - SlopePitch, so the hero (and the mount, which copies the angle) ends up tilted 12° for good, until the next map join or relog. A nod's bow under way at the warp does the same, with up to 5°. In Kanturu 3rd, KanturuAllDirection calls HeroFallingDownInit every frame, so there the hero's lean and bow never show, and the stored SlopePitch turns into the same tilt after leaving.
Suggestion: take the lean and the bow off together with the angle:
void CDirection::HeroFallingDownInit()
{
if (!m_bDownHero)
{
Hero->Object.m_bActionStart = false;
Hero->Object.Gravity = 0.0f;
// Upright, with the slope lean and a nod's bow taken off too, so they don't come back as a tilt.
Hero->Object.Angle[0] = 0.0f;
Hero->Motion.SlopePitch = 0.f;
Hero->Motion.NodBowApplied = 0.f;
}
}The lean then eases back in on the new map. A test: a hero with a slope lean and a bow, then HeroFallingDownInit, then frames of UpdateSlopeLean and UpdateNod on flat ground; Angle[0] ends at 0. (This is one more writer for the follow-up that applies the lean when drawing.)
There was a problem hiding this comment.
Fixed in e771d32 with your change: HeroFallingDownInit clears Motion.SlopePitch and Motion.NodBowApplied together with the pitch, so the lean eases back in on the new map instead of leaving a tilt (also after Kanturu 3rd). Test: a hero with a slope lean and a bow, then HeroFallingDownInit and frames of the lean and the nod on flat ground; it ends upright. Without the fix it stays tilted. The follow-up that applies the lean when drawing will cover this writer too.
| inline constexpr bool CfgDefaultSunlight = true; | ||
| inline constexpr bool CfgDefaultLightMood = true; | ||
| inline constexpr bool CfgDefaultPostProcessing = true; | ||
| inline constexpr bool CfgDefaultEnhancedMovement = true; |
There was a problem hiding this comment.
Required. Please ship Enhanced Movement off by default. It changes how every character moves and looks, so players should switch it on in the options rather than get it with an update. The places that set or describe the default:
CfgDefaultEnhancedMovementhere:false.src/bin/config.ini.template:41:EnhancedMovement=0. The client copies the template into the player's folder on the first start, so this is the default for new players; the constant is the default for a config.ini without the key.Engine/Object/EnhancedMovement.h:12:s_enhancedMovement = false, so nothing runs with it on before the config is read. The tests that rely on it being on (most oftest_character_realism.cpp) then switch it on withEnhancedMovementSwitch, as the newer tests do.UI/Options/OptionWindow.h:360:enhancedMovement = false, to match.docs/options-window.md:93("default1") and the PR description ("On by default").
A test: a config.ini without the key loads with Enhanced Movement off, and the template says EnhancedMovement=0. test_display_settings_contract.cmake already checks other defaults this way.
There was a problem hiding this comment.
Done in 6b155f1, everywhere you listed: CfgDefaultEnhancedMovement = false, EnhancedMovement=0 in config.ini.template, s_enhancedMovement = false, the options window's enhancedMovement = false, and options-window.md says default 0. The movement tests that are about the option on switch it on with EnhancedMovementSwitch. Tests: display_settings_contract checks the default and the template, and the switch test loads a config.ini without the key with Enhanced Movement off. The PR description is updated too.
| !g_isCharacterBuff(o, eDeBuff_Sleep) && !g_isCharacterBuff(o, eBuff_Att_up_Ourforces) && | ||
| !g_isCharacterBuff(o, eBuff_Hp_up_Ourforces) && | ||
| !g_isCharacterBuff(o, eBuff_Def_up_Ourforces); | ||
| if (!headMoves) |
There was a problem hiding this comment.
Non-blocking. (From the code; not tried in game.) When the head doesn't move, this runs UpdateNod in full, not only the nod under way. UpdateLookAt doesn't run then, so Motion.LookTarget keeps its last value, and WatchHero keeps counting toward a greeting.
For example, a player 2 tiles from the hero looks at it and gets stunned. LookTarget stays the hero, WatchHero passes 1.5 s, and StandsOnFoot is still true for the frozen stance, so Greet sets PLAYER_GREETING1 on the stunned player, and the hero schedules its nod back. When the stun ends, the player waves Hello out of nowhere. The same happens under the Ourforces buffs, which on main only stopped the head. The commit says this branch has no test.
Suggestion: while the head doesn't move, let UpdateNod only play out what is under way (PlayNod, EndGreeting, the cooldown) and skip WatchHero, for example with a headMoves argument.
There was a problem hiding this comment.
Fixed in 9a624f3 as you suggested: UpdateNod(c, headMoves). While the head doesn't move, only what is under way plays out (PlayNod, EndGreeting, the cooldown). Nobody watches the hero or starts a greeting meanwhile, and a nod back the hero still had pending is dropped. Test: a stunned player looking at the hero for 3 s starts no greeting, and a nod under way when the head froze still plays to its end.
| { | ||
| c->TurnAction = -1; | ||
| c->TurnArrived = true; | ||
| SetPlayerStop(c); |
There was a problem hiding this comment.
Non-blocking. (From the code; not tried in game.) A standing turn starts with SetPlayerWalk and ends with SetPlayerStop, and both play a monster's sound moments: the walk moment (PlayWalkIdle) and the stand moment (PlayMonsterMoment). A monster whose walk ends before its facing arrives therefore gets the stand moment twice: once from MoveMonsterClient's SetPlayerStop, and again when the turn arrives. It also gets a walk moment at the turn's first step, and an AT_STAND1 turn gets the stand moment twice as well.
62 of the 157 sets in Data/Monsters/Sounds.json have a stand event (an idle sound, one in 16). Walk-end turns are common, since gentle turns ease and usually leave more than 0.5° at the end of the path. So those monsters' idle sounds play noticeably more often than the sound sets intend. Suggestion: end the turn's steps without the stand moment, for example with SetAction back to TurnStance or a SetPlayerStop that skips PlayMonsterMoment, and play no walk moment for the turn's step.
There was a problem hiding this comment.
Fixed in 13e623b: SetPlayerWalk and SetPlayerStop take a playSounds flag (on by default). The turn's first step, its end, and the stop of a turn cut short by a new one pass false, so they play no walk or stand moment and no mount step sound. Test: 64 standing turns of the Bull Fighter play no sound. Without the fix its one-in-16 idle sounds play.
A teleport to another map calls LoadWorld, whose HeroFallingDownInit sets the hero's pitch to 0 but kept the slope lean and a nod's bow that were part of it, so when they eased out on the new map the hero (and its mount) stayed tilted until the next map join. HeroFallingDownInit now clears them with the pitch; the lean eases back in on the new map. Test: a hero with a slope lean and a bow, then HeroFallingDownInit and frames of the lean and the nod on flat ground: it ends upright.
… options It changes how every character moves and looks, so it is opt-in: the default for a config.ini without the key is off (CfgDefaultEnhancedMovement), the template copied into a new player's folder says EnhancedMovement=0, and the option starts off until the config is read. The options window and options-window.md say the same. Tests: the config contract checks the default and the template; the switch test loads a config.ini without the key with Enhanced Movement off. The movement tests that are about the option on switch it on with EnhancedMovementSwitch.
While the head doesn't move (off screen, a stun, sleep, an Ourforces buff), UpdateLookAt doesn't run, so LookTarget kept its last value and the nod code kept counting toward a greeting: a stunned player could wave Hello when the stun ended. UpdateNod(c, headMoves) now only plays out what is under way then (a nod, an NPC's greeting, the cooldown); nobody starts a greeting or a nod back meanwhile. Test: a stunned player looking at the hero starts no greeting, and a nod under way when the head froze still plays to its end.
A standing turn steps with SetPlayerWalk and ends with SetPlayerStop, and both played a monster's sound moments, so monsters whose walks end mid-turn played their idle sounds more often than their sound sets say. SetPlayerWalk and SetPlayerStop take a playSounds flag (on by default), and the turn's steps, its end and the stop of a turn cut short by a new one are silent. Test: 64 standing turns of the Bull Fighter (idle sounds one time in 16 at a walk or a stand) play no sound.
|
Thanks for playing it, and glad you like it. Both required items are fixed with tests that fail without them. A change of map no longer leaves the hero tilted (e771d32), and Enhanced Movement now ships off (6b155f1), with the PR description updated to match. The two non-blocking points are done too: no greeting while the head is frozen (9a624f3), and no extra idle sounds from a standing turn (13e623b). The follow-up PRs for the lean and hover in the bone build, and for the movement tuning as data with an editor window, come after this one. Windows x64 Release builds. All 3126 tests pass, run serially in random order, |
…i tests, not the static checks CI runs the static checks on a checkout without src/bin, so the contract couldn't open config.ini.template. The contract keeps checking CfgDefaultEnhancedMovement; ui_scaling_tests (full checkout) now checks that the template's [Render] EnhancedMovement is 0.
Summary
Implements #867. Characters turn, start, stop, look around and greet instead of snapping from one pose to the next, all
behind one graphics option, Enhanced Movement (Options → Graphics → Quality,
[Render] EnhancedMovement), next toEnhanced Lighting. Off by default (players turn it on in the options); off, characters move as on main. Client-side only: no packets change.
Bip01 Head(BoneHead7 was a body part).Fix on the way (it applies with the option off too): wings on a Uniria or a Dinorant sat tilted to one side while
riding (main does it too). They now take the back's standing rotation.
How it's built
AnimateCharacterBonesahead of time,Calc_ObjectAnimationandCalc_RenderObjectat draw time). All three go throughEngine::Characters::AnimateBones, so the drawn turn, the ponytail lag, the pose fade, the mount's head and the feetreach every build. Before, the draw builds only had the plain facing. Main's pose cache builds through it too, and
rebuilds when anything these features add changes.
Engine/Object/Movement/(namespaceEngine::Characters), the per-character state inone
CharacterMotion, reset with the character. Tunables are named constants next to their code; the momentum andsharp-turn values sit together in
Movement/MovementTuning.h, each with its unit and what changing it does.Render/Models/BoneMath.hholds the rotation math the head turn, feet and ponytail share;BMD::FindBonereplacesfive bone-by-name loops.
docs/characters/animation-pipeline.mddescribes how characters, monsters,NPCs and mounts are moved, animated and drawn, and where each feature hooks in.
Performance
Release build, Windows x64, i9-12900K; the range of five runs of the benchmark tests (named
benchmark, skipped byctest -E benchmark).A player's bone build (built up to three times a frame: ahead of time and when drawn):
Per character, per frame:
For scale: with 100 players on screen, every one turning its head with every per-frame step running, the extras come to
roughly 0.05 ms a frame, about 0.3% of a 60 fps frame (16.7 ms). Standing on slopes, the feet add about 0.13 ms more
for all 100. A character with nothing to do skips the work.
Videos
Side by side, off on the left and on on the right, at 1440p.
1-turning.mp4
2-start-stop-run.mp4
3-greetings.mp4
4-mount.mp4
5-flight.mp4
Commits
One per feature, in the order they were built:
feat(characters): smooth turning: eased walking and standing turns, the head turning the shouldersfeat(characters): winged players bank into turns and drift while flyingbuild(tests): compile Winmain.cpp once for every test that needs itfeat(characters): the wings and the ponytail trail behind a turnfeat(characters): heads look at what's nearfeat(characters): mounts lean into turns, look where the rider does and shake their headsfeat(characters): a sudden turn is drawn as a quick eased turnfeat(characters): walking and running keep the feet on the groundfeat(characters): mounts follow slopes, and walkers lean into a climbtest(characters): the character realism stepsfeat(characters): characters greet the hero, and the hero greets backfeat(animation): standing, walking and running fade into each otherfeat(options): Enhanced Movement, the option for every character movement changestyle: clang-format the lines this branch changedThe review fixes are ordinary commits on top, with merges of main.
Related issues
Closes #867.
Checklist
docs/CODING_RULES.md.docs/build/README.md).tests/gamelogic/test_smooth_turning.cpp,tests/gamelogic/test_character_realism.cpp(the optionswitched off included),
tests/data/test_character_realism_bones.cpp(with the real player model); benchmarks arethe tests named
benchmark, skipped byctest -E benchmark.matching a fresh build and drawing changing no game state.