Commit 3bab298
committed
fix: hit area detection when wandering Doro faces right (flip_h=true)
When the wandering Doro turned to face right, clicks on body parts
(face, legs, etc.) would not trigger interactions. The model still
animated, but `recalc_mouse_position` returned coordinates far outside
the canvas so no hit-area test ever matched.
Root cause: in `model.gd`, `flip_h = true` sets the Node2D scale to
`(-0.3, 0.3)`. That negative-x scale flows through Godot's coordinate
transforms automatically:
1. `model.to_local(event.position)` already divides by the negative
scale, mirroring x once.
2. `position * model.get_scale()` then multiplies by the same
negative scale, mirroring x back to viewport space.
So at line 27 the position is *already* in unflipped viewport coords.
The extra `if model.flip_h: position.x = -position.x` on lines 28-29
was a spurious third flip, performed in viewport coords *before* the
center offset and canvas-scale division. The later flip on lines 36-37
is the correct one: it mirrors around the canvas origin (after the
viewport-center subtraction), which is what hit-area detection
expects when the model is rendered mirrored.
With both flips active, a click at viewport (320, 320) on a flipped
model came out as (1024, 0) in canvas coords instead of the correct
(0, 0) — one full canvas-width off, so no hit area ever triggered.
Fix: drop the redundant first flip; keep the canvas-space flip at the
end of the function. The unflipped (flip_h=false) code path is
unchanged — same diff outputs for every input I traced through.
Testing scope (please regression-check before merging):
- Bug analysis is platform-independent — depends only on Godot's
Node2D transform semantics and on `model.gd` setting a negative
x-scale for flip_h. Both apply on Windows the same way they
apply on Linux.
- Verified informally by manual click-testing on a downstream RHEL
9.7 / X11 build (via WSL 2 + WSLg). Walked the wandering Doro
right-ward and confirmed the SmileEyeClosed expression triggers
on the face hit area from both facing directions.
- NOT re-tested on the upstream Windows build. A regression check
there before merging would be appreciated, particularly on the
flip_h=false path to confirm nothing changes for Windows users
whose pets face left.1 parent c2050bd commit 3bab298
1 file changed
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 28 | + | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | | - | |
| 36 | + | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
| |||
0 commit comments