Hair under hats: keep it inside the crown; sunglasses and the hat fit follow the head scale #466

Manually merged
github merged 13 commits from github-bot/gh-466 into gh-pr/466/base 2026-11-27 06:08:00 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 05:51 UTC · original
holdmysocks:people/hair-crown → master · +1063 −143 · 19 files · 13 commits · merged 2026-11-27 06:06 UTC

For #308. Builds on #457 and includes its commits until that merges.

What changed

  • Crown containment. A containment volume is fitted to the hat, in the form of the game's containment kind 16 (an ellipsoid with a cut plane):
    • the floor sits at the brim, where the hat reaches out furthest;
    • the semi-axes come from the crown's points, 6 mm inside them.
    • Groom::settle_in keeps scalp-hair guides inside it after every follow-the-leader and bend step. Below the brim the hair is free.
    • The game has no such volume for hats: it swaps to a hat variant of the hair where the hair item has one. So the fit is the viewer's own. Items without a hat variant keep their base hair, as chosen on #308.
  • Hat fit at any head scale. The head and hat points come already scaled by the body shape's head scale, but the hair is scaled with BM_Head only when drawn. At +1 the hair was pressed against a hat that had already grown, then scaled again and came out through it. The shell and crown are now fitted in the hair's space.
  • Sunglasses follow the head scale. An attached accessory whose attach bone hangs under SKEL_Head now scales with the head like other head accessories. Before, the sunglasses stayed the original size and sank into a bigger head.

Checks

  • New unit test: the crown fit on a brimmed hat; points outside the crown are pulled back, points under the brim are left alone, and a guide standing out of the crown settles inside it. All crate tests pass.
  • Herbert (fedora, cornrows with no hat variant) and Connie (fedora, her own hair) at head scale −1, 0 and +1, front and back. The hair stays under the hat at 0 and +1, and the sunglasses now scale.

Not fixed here

  • At head scale −1 the head itself disappears. This was already so before this PR; the hair and glasses now follow it out.
  • Connie's fedora shows grey patches at every scale. They are in the hat model as drawn, not hair.
**@⁠holdmysocks** on GitHub · 2026-11-27 05:51 UTC · [original](https://github.com/holdmysocks/SixNG/pull/466) `holdmysocks:people/hair-crown` → `master` · +1063 −143 · 19 files · 13 commits · merged 2026-11-27 06:06 UTC For #308. Builds on #457 and includes its commits until that merges. ## What changed - **Crown containment.** A containment volume is fitted to the hat, in the form of the game's containment kind 16 (an ellipsoid with a cut plane): - the floor sits at the brim, where the hat reaches out furthest; - the semi-axes come from the crown's points, 6 mm inside them. - `Groom::settle_in` keeps scalp-hair guides inside it after every follow-the-leader and bend step. Below the brim the hair is free. - The game has no such volume for hats: it swaps to a hat variant of the hair where the hair item has one. So the fit is the viewer's own. Items without a hat variant keep their base hair, as chosen on #308. - **Hat fit at any head scale.** The head and hat points come already scaled by the body shape's head scale, but the hair is scaled with BM_Head only when drawn. At +1 the hair was pressed against a hat that had already grown, then scaled again and came out through it. The shell and crown are now fitted in the hair's space. - **Sunglasses follow the head scale.** An attached accessory whose attach bone hangs under SKEL_Head now scales with the head like other head accessories. Before, the sunglasses stayed the original size and sank into a bigger head. ## Checks - New unit test: the crown fit on a brimmed hat; points outside the crown are pulled back, points under the brim are left alone, and a guide standing out of the crown settles inside it. All crate tests pass. - Herbert (fedora, cornrows with no hat variant) and Connie (fedora, her own hair) at head scale −1, 0 and +1, front and back. The hair stays under the hat at 0 and +1, and the sunglasses now scale. ## Not fixed here - At head scale −1 the head itself disappears. This was already so before this PR; the hair and glasses now follow it out. - Connie's fedora shows grey patches at every scale. They are in the hat model as drawn, not hair.
The viewer drew the guides as stored. The game runs its strand simulation
on them every frame, so on a still character the hair hangs under gravity
and drapes over the shoulders. Port the close-up simulation pass:

- read the groom's simulation inputs: per-point pull and bend compliance
  (graphics header B1), rest lengths (B2), the bend-constraint flag
  (header +0x50 bit 7) and the damping rate (system +0xF6)
- Groom::settle: gravity, the pull back to the stored shape with
  f = 1 / (1 + a c / dt^2), follow-the-leader rest lengths with the
  game's look-ahead, the bend constraint toward the stored segment
  angles (stiffened near colliders), and push-out of the body colliders,
  run to rest
- the viewer settles each groom before drawing; SIXNG_HAIR_NO_SIM=1
  keeps the stored guides for research

Left out: the leash scale on the pull (needs per-node pose data), the
point radius and extra damping set at run time, and wind.
The close-up strand simulation scales the pull's compliance by a leash:
c' = c m (R / |x - B|)^e. A point within R of its stored place is pulled
less, and one beyond it more. R is the length of the point's rest offset
in graphics header +0x3c (B3, the fourth byte / 600 m), or 4 a c without
B3. The exponent e = 3E/255 and the time scale m come from header +0x70
byte 2.

Read B3 and E into SimData and apply the leash in Groom::settle. The
step is now the game's substep at 30 fps (0.06 s), since m depends on it.
# Conflicts:
#	crates/sixng-core/src/groom.rs
- Crown: a containment volume fitted to the hat, in the form of the game's
  containment kind 16 (an ellipsoid with a cut plane). Floor at the brim,
  semi-axes from the crown's points, 6 mm inside. Groom::settle_in keeps
  scalp-hair guides inside it after every follow-the-leader and bend step;
  below the brim the hair is free. The game has no such volume for hats,
  so the fit is the viewer's own.
- The hat shell and crown are fitted in the hair's space. The head and hat
  points come already scaled by the body shape's head scale, while the hair
  is scaled with BM_Head only when drawn, so at head scale +1 the hair was
  pressed against a hat already grown and then scaled again through it.
- An attached accessory whose attach bone hangs under SKEL_Head (sunglasses)
  follows the head scale like other head accessories.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 05:54:42 +00:00
github-bot changed target branch from master to gh-pr/466/base 2026-11-27 06:07:59 +00:00
github manually merged commit 19a7071ada into gh-pr/466/base 2026-11-27 06:08:00 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.