Skip to content

feat(items): things on bones as data, with a live preview in the Style Editor (looks in data, PR 4) - #178

Open
Mosch0512 wants to merge 47 commits into
mainfrom
feat/looks-bones
Open

Mosch0512 wants to merge 47 commits into
mainfrom
feat/looks-bones

Conversation

@Mosch0512

Copy link
Copy Markdown
Owner

Summary

The fourth pull request of the looks-in-data design (sven-n#954), steps 2 and 3. The things item effects create on an item's bones every frame (sprites, particles, lightning and effects) move from code into data, and the Style Editor shows them live and edits them. The nine item effects that still had things on bones in code (six wings, Rena, the Devil's Key and Invitation) and the Pumpkin of Luck and Cursed Castle Water are data now; no item effect is code any more, and only helperNpcPlate, which lights the helper NPC, stays a render style in code (it moves with the monsters' looks). Each moved effect was run with its old code and with its data in the same build, and what it created was recorded and compared before the code was deleted.

What it does

  • Things on bones (L55, L56, design section 7b; format in docs/item-data.md → Render styles and item effects): an item effect's "onBones" lists things by their effect catalogue name and kind ("sprite", "particle", "joint" for lightning, "effect") with a subType, at a list of bones ("bones": [22, 21]), between pairs of bones for lightning ("between": [[30, 22]]) or at the item's own place ("at": "origin"), with scale, color, a sprite's rotation and lightning's direction as numbers or shapes. A chance is once in N frames at the game's reference frame rate or a plain draw, for each bone or once; a "together" group shares its places and chance, so the Wings of Darkness' two lightnings strike together, and a thing inside can roll again (the Wing of Storm's thunder).
  • Created in the update (ADR 0003), from the item's pose in that update, with the game's own create calls; the types are resolved by name when the effect table is built.
  • The moves: wingsOfDarkness, wingOfStorm, wingOfEternal, wingOfIllusion, wingOfRuin, wingOfDimension, rena, devilsKey and devilsInvitation, and the Pumpkin of Luck and the Cursed Castle Water with their drawings, things on bones and animation (L29).
  • New look parts: a layer's opacity, glow strength or scroll can be the item's value times a number ({"itemTimes": 1.5}, L59), a darken blend (the Pumpkin of Luck's reflection), and an item effect's animation speed (the Cursed Castle Water's ground item).
  • One fix (L57): the Devil's Key's and Invitation's sparks sat about a quarter farther out than the bones on the ground, because their code placed them without the model's scale; they now sit on the scaled bones like every other thing on bones.
  • The live preview (FX1.7c, L51 to L54, design section 7a), editor builds only: each view of the Style Editor's preview, and the Item Model window's, creates its item effect's things in the game's own effect lists, from its own copy of the item at the player's character, so they move as in the game and an edited look shows next to the one applied. Each slot of the effect, particle, lightning and sprite lists carries the view it belongs to: the world's draw loops skip a view's slots, and each view draws only its own, after its item, with its camera. Stop time stops them (lightning and particles hold still, sprites and lights follow the slider). The game comes first: a view creates nothing while a list has less than a quarter of its slots free, and the views together keep to a quarter. A create call takes the mark off the slot it fills, so the game's own lightning in a slot a view's lightning just left stays the game's.
  • Style Editor (L58): an item effect's list gets Animation speed and its On bones entries (Add, Copy, Move up, Move down, Remove). An entry's fields: at bones, between bones or at the item's place with its bones as number fields, its chance, Together, and each thing's kind, type from the effect catalogue (with a filter), SubType, scale, color, rotation, direction and own chance. Show bones draws the item's skeleton over each view (each bone joined to the bone it hangs on, its number and name on hover), the picked entry's bones in orange with their numbers, and a bone the fields point at ringed; Pick in the preview adds or takes out a bone with a click on its dot, and picks lightning pairs start first.
  • Data Checks: a type the effect catalogue doesn't have (error), a bone an item's model doesn't have (warning, about that item); the reader refuses lightning at bones, other things between bones, and places named twice or not at all.
  • The spawn recorder (tests): records what an item effect creates in the update, every thing with its place, values and type, over clock times and seeds; the baseline (tests/data/baseline/ItemEffectSpawns.txt, 94 lines) was recorded from the old code. The recorders now clear the effect lists' objects whole, so a record doesn't depend on what ran before it.
  • Texts: 49 new editor texts in English and German.
  • Docs: docs/item-data.md (things on bones, itemTimes, the darken blend, animation speed, the Style Editor's fields, live preview and bones), and the design document's decisions L51 to L59 (Q-L39 to Q-L47) with the FX1.7c design (section 7a).

Tests

  • render_style_tests (90 cases): things on bones read and written, the checks, the spawn baseline of the moved effects (equal to the old code's records but the Devil items' sparks, L57), the preview's marks in the draw and move loops, a view's life cycle (created at the character, drawn only by its view, stopped with the time, removed when its item, pose or effect changes, when it is no longer drawn and when the world is cleared), each view keeping its own lightning when other views' and the game's lightning of the same type take the slots it left, the bone marks (projection, pick rules, the skeleton's parents) and the marks sitting exactly where a view creates its things, in both poses and turned.
  • Locally at the head, rebased on main 549e87eec: the Windows Release editor build and the whole ctest run, 4202 of 4206 pass. The 4 that fail don't come from this branch: ci_build_plan, which can't run its PowerShell script on this machine; write_git_commit and ensure_submodule_leaves_history_out, which pass when run again alone; and the per-map file lists test, because main's Shared.json lacks Data/Items/Options/OptionRules.json (from the item options pull requests); rewritten, the lists change only that line. The rebase had a conflict in the editor texts, where main added the NPC rule texts; both are kept.
  • On Linux (WSL), each of the 27 commits on main 549e87eec built and passed render_style_tests, the editor's look, Style Editor, item effect and Data Checks cases (105 at the head) and test_item_database (278); the 10 commits that change only docs were skipped. Linux found that the spawn recorder's digest of the random engine was not the same on every platform (it hashed the engine's written state with std::hash, and both differ between MSVC and libstdc++); it is now taken from the engine's next numbers and hashed with FNV-1a, and the baseline was recorded again, the Devil items' lines before L57 from their old code. The records themselves were the same on both platforms, field for field.
  • clang-format 21.1.8 on the changed lines and cppcheck 2.13 and 2.19 on the 24 changed files of src/source are clean.
  • In the running editor: the live preview of the Wings of Darkness in the three views and the Item Model window, Stop time, the On bones fields, Show bones and picking.

Not checked yet

  • In game, before and after: the Devil's Key's and Invitation's sparks on their scaled bones (L57).
  • macOS: left to CI.

Not in this pull request

  • The bone effects of held and worn items (L27), after their survey: pull request 5, with the docs and the end of the design document.
  • helperNpcPlate: with the monsters' looks (MN8).

Related issues

Pull request 4 of the plan in sven-n#954 (0 was the design, 1 the mesh list, sven-n#970, 2 the first 96 looks, sven-n#1022, 3 the looks with conditions, item effects, shines and part models, sven-n#1050).

Checklist

…e game's own effect lists, marked for the view (L51)
…p with the preview's time (L54); where the preview creates and draws them
…preview (L58); pull requests 2 and 3 are done
…rticles, lightning and effects at bones, between pairs or at the origin, with chances and groups (L55, L56)
…talogue doesn't have, a bone an item's model doesn't have
…in the update, at the item's posed bones, with its chances; types are resolved when the effect table is built
…the update, and the baseline of the 9 item effects with things on bones, recorded from their code
…e data (wingsOfDarkness, wingOfStorm, wingOfEternal, wingOfIllusion, wingOfRuin, wingOfDimension), created as their code created them
…t on their scaled bones (L57); no item effect is code any more
…: their drawings with a darken blend and the item's value times a number (L59), their things on bones and animation as item effects of their names (L29)
… item effect's animation speed read and write back
…es live (FX1.7c, design section 7a, L51 to L54)

Each view of the Style Editor's preview keeps its own copy of the item at the player's character and, in a new
editor hook in the game's update (Core::EffectSpawnHook, after the world's effects moved), creates the things its
item effect creates there with the game's own calls. The slots they fill carry the view's mark
(Render::Effects::PreviewSlots): the world's draw loops skip them, CullEffects counts a marked effect as seen, and
each view draws only its own right after its item, with its camera moved to the character and no culling against the
world's view. While the preview's time is stopped the game moves none of a view's things and the view creates only
its sprites and light. A view's things are removed when its item, pose or effect changes, when it is no longer drawn,
and when the world is cleared; views create nothing while a list is three quarters full, and keep together to a
quarter of each list. The things play no sound.

The item's pose moves out of EffectPreviewScene::DrawItem into PosePreviewItem, so the views spawn from the pose
they draw. RenderParticles no longer needs the option window, as RenderSprites.
…stops the lightning that lives a frame

Each view forgot the slots its things had ended in only in its own turn, after the views before it had created: a
view's new lightning could land in a slot another view's had left, and that view took it for its own. The views then
showed different amounts (the first fewest). Now every view forgets what ended before any creates.

The Wings of Darkness' lightning lives a frame and is made anew each frame. The view stopped its things only in the
update after Stop time was ticked, when the game's move had already ended them, so the lightning went away. The
view's draw now stops them at once, and a view that has made nothing yet (its item, pose or effect changed while
stopped) makes its effect once to stop on.
…on bones too

Its preview is a fourth view of the bone things preview (design section 7a), with the item effect its item runs and
no stopped time. The design's Time bullet now says what Stop time does since the fix before.
…elf, not in SaveCameraPerspective's one slot
…and animation speed, shows the item's bones and picks them in the preview (L58)

An item effect's list gets the animation speed and its "On bones" entries, with Add, Copy, Move up, Move down and
Remove. An entry's fields: at bones, between bones or at the item's place, its bones as number fields (the bone a
field points at is ringed in the preview with its number), its chance, Together, and its things with kind, type
from the effect catalogue, SubType, scale, color, a sprite's rotation, lightning's direction and, in a group, their
own chance. "Show bones" draws every bone of the previewed item as a dot with its number and name on hover; "Pick in
the preview" adds or takes out a bone with a click on its dot, and picks lightning pairs start first.
…a record doesn't depend on what ran before it
…slot its own lightning left

A view's lightning lives a frame. When the game created its own lightning of the same type in a slot a view's
lightning had just left, the view kept that slot as its own: it drew the game's lightning, cast elsewhere, above its
item, and the world lost it. Each create call now takes the preview mark off the slot it fills
(PreviewSlots::Born); a view forgets the slots that no longer carry its mark before anything else, and takes its mark
off the slots it no longer keeps, so the marks stay from one update to the next.
…ne it hangs on, and the picked entry's bones carry their numbers
…rken blend and animation speed; the Style Editor's fields, live preview and bones for item effects
…r takes 0 to 199, and a bone the model doesn't have creates nothing
…ite's rotation and lightning's direction, which the other kinds can't have
…eep to what the files take, from the reader's own limits
…an't have: it rolls once each time the group's chance holds
…have is logged when the game loads its data, not only named by Data Checks
… the bone its first click picked, as a mesh pick does
…the item's times a number, as one the look sets
… it: the effect table hands out its own entry
…n the item has bones, so naming them allocates nothing
… as Data Checks does, with its place in a group and its kind
… bones once it is chosen, before the first pair
…its own, BoneMarks::PickTakeBack, tested without ImGui
…d direction; the change is a function of its own
… chance, and what a bone the model doesn't have and an unknown type do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant