Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

fix(handed): a side view names the near part 'nearer the viewer', not 'in front of the body'

Soohong Kim9b9d6968e98b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52dd4d1..d3903ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the
- **A walk or run says "in place" and its view once.** The side and diagonal gait sentences ended "without moving across the screen" and the frame sentence said "does not move across the screen"; the gait sentences and holds no longer add it. A walk or run seen from the front, from behind or at a diagonal said its view in the gait sentence ("facing the viewer", "keeps the exact three-quarter back angle of the image") and again in the view sentence ("The character is seen from the front, facing the viewer directly."); its prompt now leaves the view sentence out (`batch.GAIT_SAYS_VIEW`). A side gait keeps the view sentence, and a caller's own side gait is held with "It stays in place as if on a treadmill." (its facing is the view sentence's). Other states are unchanged. A cached `video-set` clip made with the old wording is refused as before ("cached clip prompt differs"); pass `--force` to film it again.
- **The caller's own words are reported, not edited.** Text that turns the subject another way than `--facing` (or to a side in a front or back view), or puts a `--handed` item on its other side, is sent as written with a warning; text that repeats an option gets a note. `gen` prints them and records `extra.prompt_notes`; `video-prompt --json` lists conflicts in `warnings` and all of them in `notes`; `video-set` records `prompt_notes` per item.
- **Fix: a watch on the far wrist was in no frame of a side walk.** 2.22.0 said every item on the far side of a side view hidden, and never named it in the clip ("the wrist in front of the body stays bare"). A walking character's far arm comes forward of the body with every step, and what it wears shows then. An item on a far arm or leg (`handedness.limb` reads the body part) is now said to show wherever that limb is out in front of the body: in the still ("wherever the far arm reaches out in front of the body, clear of its outline, the black smartwatch shows whole on it; where the body covers that arm, it is hidden") and in a walk or run ("stays on the wrist that wears it in the image, on the arm on the far side of the body, and shows each time that arm swings forward; the arm nearer the viewer stays bare, exactly as in the image"). On the near arm the walk says the other arm stays bare "both where it shows behind the body and where it swings out in front of it". Both start "Both arms swing back and forth with each step, opposite to the legs.", and no sentence holds an arm still. A far part that does not swing (a pin on the far side of the head) and a state that does not step (idle, attack) keep the 2.22.0 sentences. [docs/video-pipeline.md](docs/video-pipeline.md#handedness--an-item-on-one-side).
+- **A side view names the near part "nearer the viewer", not "in front of the body"** (still and clip sentences): in a mid-stride still the far arm is the one in front of the body, so "the wrist in front of the body stays bare" named the wrist with the watch.
- **A clip keeps what its first frame shows**: for a walk or run with an item on the far limb of a side view, `video-prompt --json` (`still_needs`, and stderr) and `video-set` (each item's `still_needs`) say the still must be drawn mid-stride with that limb out in front of the body and the item in view. The docs give the pose sentence for the prompt.
- **One handed sentence per wrist, not per item**: with an item on each wrist a side clip said "the wrist in front of the body stays bare" and "the red ribbon stays on the wrist in front of the body" together, and with two items on one wrist it said the same sentence twice. Items on one part share a sentence, a part another item is on is not called bare, and a still says "none of it" there. A diagonal's clip sentence also reads "…, nearer the viewer, for the whole clip" (the comma was missing).
- **`handed-check` passes a far arm's item in view and fails the near arm's** (side views): 2.22.0 failed every frame that showed the far item whole ("in full view on the far side"). An item on a far arm or leg must now be out in front of the body in every frame it shows — on the facing side of the body's centre by at least a tenth of the body's height (`far_in_front`); at or behind the centre it is on the near limb. With the new `--state walk|run` it must also show in at least a quarter of the frames (`far_shown`; unchecked without `--state` or for a state that does not step). A side view's near item must show in three quarters of the frames, not half: a far item turned over to face the other way shows in about half. A far part that does not swing keeps the hidden-or-a-sliver rule (`far_hidden`), and a diagonal's near side keeps half.
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index dea0dfd..9cb5fce 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -372,8 +372,9 @@ swing ("Both arms swing back and forth with each step, opposite to the legs."),
No sentence holds an arm still: the arms swing with the walk. The other arm is said bare, never as a
list of what it must not wear — a clip prompt that lists that draws it there. Where nothing brings the
far side into view — a part that does not swing, or a state that does not step (idle, attack) — the
-item is not named at all: "The wrist in front of the body stays bare, exactly as in the image, for the
-whole clip." Items on the same wrist share one sentence, and with an item on each wrist neither is
+item is not named at all: "The wrist nearer the viewer stays bare, exactly as in the image, for the
+whole clip." A side view names the near part "nearer the viewer", not "in front of the body": in a
+mid-stride still the far arm is the one in front of the body. Items on the same wrist share one sentence, and with an item on each wrist neither is
called bare. `handed-check --strap` finds a bare band that a clip still grows on the other arm. A front
or back walk's mid-step redraw (`walk_start_prompt`, `video-prompt`'s `start_still`) ends with the
still's handedness sentences too: redrawn from the base alone, the model may put the item on the other
diff --git a/sprite_gen/gen/handedness.py b/sprite_gen/gen/handedness.py
index 83af6c3..25d3469 100644
--- a/sprite_gen/gen/handedness.py
+++ b/sprite_gen/gen/handedness.py
@@ -121,9 +121,9 @@ def _view_clause(h: Handed, view: str, facing: str | None, items: list[Handed])
if view == "side":
if at["depth"] == "near":
return (f"Facing {facing}, the character's own {h.side} side is toward the viewer: its {h.where()} is the near "
- f"one, in front of the body, and {h.item} on it shows clearly.")
- lead = (f"Facing {facing}, the character's own {h.other} side is toward the viewer: the near {h.part or 'side'}, in "
- f"front of the body, is its own {h.where(h.other)}, with {none}; the {h.where()} with {h.item} is on the far ")
+ f"one, nearer the viewer, and {h.item} on it shows clearly.")
+ lead = (f"Facing {facing}, the character's own {h.other} side is toward the viewer: the near {h.part or 'side'}, on the "
+ f"side nearer the viewer, is its own {h.where(h.other)}, with {none}; the {h.where()} with {h.item} is on the far ")
swings = limb(h.part)
if swings:
# the far limb is in view whenever it is forward of the body, and its item with it
@@ -171,9 +171,10 @@ def _clip_clause(group: list[Handed], view: str, facing: str | None, *, gait: bo
return (f"{_names(group)} {stay} on the {part} that wears {they} in the image, on the {swings} nearer the "
f"viewer{bare}.")
if view == "side" and at["depth"] == "far":
- return f"The {part} in front of the body stays bare, exactly as in the image, for the whole clip." if other_bare else ""
+ # "nearer the viewer", not "in front of the body": mid-stride, the far arm is the one in front of the body
+ return f"The {part} nearer the viewer stays bare, exactly as in the image, for the whole clip." if other_bare else ""
if view == "side":
- where = f"the {part} in front of the body"
+ where = f"the {part} nearer the viewer"
elif at["depth"] is None:
where = f"the {part} at the {at['picture']} of the picture"
else:
diff --git a/tests/gen/test_handedness.py b/tests/gen/test_handedness.py
index 5461ba7..5dc314c 100644
--- a/tests/gen/test_handedness.py
+++ b/tests/gen/test_handedness.py
@@ -85,7 +85,7 @@ def test_the_clip_sentence_anchors_to_the_image_and_never_names_a_hidden_item(vi
assert "exactly as in the image" in clip and "for the whole clip" in clip and "attached picture" not in clip
picture, depth = OWN_LEFT[(view, facing)]
if view == "side" and depth == "far":
- assert clip == "The wrist in front of the body stays bare, exactly as in the image, for the whole clip."
+ assert clip == "The wrist nearer the viewer stays bare, exactly as in the image, for the whole clip."
assert "watch" not in clip
else:
assert clip.startswith("The black smartwatch stays on the wrist ")
@@ -93,7 +93,7 @@ def test_the_clip_sentence_anchors_to_the_image_and_never_names_a_hidden_item(vi
if picture:
assert f"at the {picture} of the picture" in clip
if view == "side":
- assert "the wrist in front of the body" in clip
+ assert "the wrist nearer the viewer" in clip and "in front of the body" not in clip
def test_a_far_part_that_does_not_swing_stays_hidden() -> None:
@@ -104,7 +104,7 @@ def test_a_far_part_that_does_not_swing_stays_hidden() -> None:
assert "on the far side, behind the body, so the star pin is hidden or at most a sliver of it shows" in h.text(pin, "side", "right")
for gait in (False, True):
clip = h.text(pin, "side", "right", clip=True, gait=gait)
- assert clip == "The side of the head in front of the body stays bare, exactly as in the image, for the whole clip."
+ assert clip == "The side of the head nearer the viewer stays bare, exactly as in the image, for the whole clip."
def test_a_walk_shows_the_far_arms_item_when_that_arm_swings_forward() -> None:
@@ -123,7 +123,7 @@ def test_a_walk_shows_the_far_arms_item_when_that_arm_swings_forward() -> None:
"swings out in front of it.")
# no sentence holds an arm still, and a state that does not step keeps the 2.22.0 sentence
assert "still" not in far + near and "for the whole clip" not in far + near
- assert h.text(watch, "side", "right", clip=True) == "The wrist in front of the body stays bare, exactly as in the image, for the whole clip."
+ assert h.text(watch, "side", "right", clip=True) == "The wrist nearer the viewer stays bare, exactly as in the image, for the whole clip."
assert "shows each time that arm swings forward" in batch_mod.build_prompt("side", "walk", None, handed=watch)
assert "shows each time that arm swings forward" in batch_mod.build_prompt("side", "run", None, handed=watch)
assert "swing" not in batch_mod.build_prompt("side", "idle", None, handed=watch)
diff --git a/tests/gen/test_prompt_assembly.py b/tests/gen/test_prompt_assembly.py
index d54ffde..937a3ab 100644
--- a/tests/gen/test_prompt_assembly.py
+++ b/tests/gen/test_prompt_assembly.py
@@ -166,7 +166,7 @@ def test_no_prompt_says_a_sentence_twice_turns_both_ways_or_asks_for_two_keys(na
_CLIP_ROWS = [r for r in ROWS if r[0].startswith("clip")]
# (a part or limb said bare, the same one said to wear an item): never both in one prompt
_BARE_AND_WORN = [
- (r"\bThe (\w[\w ]*?) in front of the body stays bare\b", "stays? on the {0} in front of the body"),
+ (r"\bThe (\w[\w ]*?) nearer the viewer stays bare\b", "stays? on the {0} nearer the viewer"),
(r"\bthe (arm|leg) nearer the viewer stays bare\b", "on the {0} nearer the viewer"),
(r"\bthe other (arm|leg), on the far side of the body, stays bare\b", "on the {0} on the far side of the body"),
]
@@ -193,7 +193,7 @@ def test_no_clip_calls_a_limb_bare_and_dressed_or_swings_an_arm_that_stands_stil
far = "the red ribbon" if (row["handed"] == "watch+ribbon" and row["facing"] == "left") else "the black smartwatch"
if row["facing"] == "right" or row["handed"] == "watch+ribbon":
assert "each time that arm swings forward" in text and far[4:] in text, text
- assert "The wrist in front of the body stays bare" not in text
+ assert "The wrist nearer the viewer stays bare" not in text and "wrist in front of the body" not in text
assert text.count("Both arms swing back and forth with each step") == 1