Let a child sort with its parent so its Z stays local (#232)
An animated or set Z of -1 on a weapon put it behind everything on Z 0, not just behind the player holding it. A child can now opt in to being drawn at its parent's place, so its own Z only orders it against the parent and its siblings. - New property "Sort with parent" on sprites, texts and particle emitters, shown in the inspector right under Z. It is a normal property, set on the asset and overridable per object. - With it on, the rest of the scene sees only the parent's Z and, where the layer sorts by Y, the parent's feet. Below 0 the child is drawn behind the parent, from 0 on in front. - It works across levels: a grandchild with the switch hangs on the top object of the chain. - It has no effect under a parent that is not drawn itself (container, behavior, camera, collider) or under a tilemap. - New assets start with it on, saved ones read as off, so old projects draw unchanged. For that a schema row now has "initial" next to "default". The gold "changed" mark and reset follow "initial", so a fresh sprite is not marked as changed. No load migration is needed. - parentGroups() in drawOrder.ts gives a slot only to the top of a chain and inserts the children there. Editor, play mode and picking all use it, so they agree. Tests: - 10 new unit tests in tests/viewport/sort-with-parent.test.ts. - 8 existing tests list the sprite rows or defaults and got the row. - New e2e check 5b-ii clicks the switch and checks order and undo. - Counter-checks, all originals restored by cmp: switch ignored fails 7, children not sorted by Z fails 6, no chain fails 1, "initial" ignored fails 9, row missing in the inspector fails e2e 5. - ./check.sh: 166 files, 2426 tests, CHECK EXIT 0. - e2e 5: ALL PASSED, 13 checks. Check total 1398, computed only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fae827c087
commit
8b44f97c35
13 files changed
+351
-15
No files matched your search
@@ -32,6 +32,7 @@ import {
|
||||
COMMON_PROPS,
|
||||
isCommonProp,
|
||||
isRowShown,
|
||||
isSortProp,
|
||||
isTransformProp,
|
||||
type PropertyDef,
|
||||
schemaFor,
|
||||
@@ -180,6 +181,9 @@ export function buildObjectSection(host: InspectorHost, holderId: string, object
|
||||
),
|
||||
});
|
||||
}
|
||||
// Right under Z, which it changes the meaning of.
|
||||
for (const def of schemaForObject(project, asset, object).filter((d) => isSortProp(d.key)))
|
||||
propertyRow(host, holderId, objectId, asset, def, resolved);
|
||||
|
||||
// Turn, size and mirror sit with the position: together they are where the object is.
|
||||
const transform = schemaForObject(project, asset, object).filter((def) => isTransformProp(def.key));
|
||||
|
||||
Reference in new issue
Block a user