Show a clickable symbol for colliders in the scene view
Colliders were the only placed part without a symbol in the scene view. A collider that sits exactly on its sprite was hard to find and could only be picked by its outline. - The symbol is the box with four corner handles from the asset panel. It stays upright and has a fixed size in world units. - colliderColor() holds the colour rule of the outline (green, trigger colour, red for a shape that collides with nothing). The outline and the symbol share it. - The symbol sits 28 units left of the collider centre. The sprite centre stays free for grabbing the sprite, and a rigidbody symbol on the same spot is not covered. - The symbol has its own 26x26 hit area and the outline's handler. A click selects the collider and a drag moves it. sceneStack counts it as a hit under the pointer. - The hook __gm.sceneIcon(id) also returns x, y, color, screen and clickable. Findings: - With the clickable symbol on the sprite centre, four checks in 01 and 09 dragged the collider instead of the crate. That is why the symbol moved beside the centre. Tests: - ./check.sh: 153 files, 2237 tests, CHECK EXIT 0 (was 152 / 2234). - New unit test for colliderColor. svg-icons.test.ts lists the collider symbol. - e2e 41b: 3 new checks (beside the centre without and with a rigidbody, click selects the collider). - e2e 1-16,39-43: ALL PASSED, 635 checks. e2e 41 alone: 20 checks. - Counter-probes: no symbol fails both placement checks. A symbol without hit area fails only the click check. - Check total 1348 + 3 = 1351, computed, not yet measured by CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
abf3b1f618
commit
e3d47ca9c1
8 files changed
+182
-25
No files matched your search
@@ -154,6 +154,56 @@ export async function physics(t) {
|
||||
await evaluate(`__gm.lookAt(0, ${Y + 100})`);
|
||||
await settle();
|
||||
await shot('41-rigidbody');
|
||||
// A collider has an icon like every other symbol. It stands left of the collider's centre, so the
|
||||
// middle of its sprite stays free, and so does a rigidbody's icon on the same spot.
|
||||
const icons = {
|
||||
ground: await json(`__gm.sceneIcon('phys-ground-col')`),
|
||||
crate: await json(`__gm.sceneIcon('phys-crate-col')`),
|
||||
ball: await json(`__gm.sceneIcon('phys-ball-col')`),
|
||||
};
|
||||
check(
|
||||
'a collider without a rigidbody shows its icon left of its centre',
|
||||
icons.ground?.visible === true &&
|
||||
icons.ground.layer === 'overlay' &&
|
||||
icons.ground.x === -28 &&
|
||||
icons.ground.y === Y + 200 &&
|
||||
icons.ground.color !== null,
|
||||
JSON.stringify(icons.ground),
|
||||
);
|
||||
check(
|
||||
"a collider's icon steps aside from the rigidbody on the same body, in the same colour",
|
||||
[
|
||||
[icons.crate, -100],
|
||||
[icons.ball, 100],
|
||||
].every(([icon, x]) => icon?.visible === true && icon.x === x - 28 && icon.y === Y) &&
|
||||
icons.crate.color === icons.ground.color,
|
||||
JSON.stringify(icons),
|
||||
);
|
||||
// The icon is clicked like the outline: it selects the collider, even over its sprite. On the
|
||||
// middle of the sprite, beside the icon, the sprite is picked as before.
|
||||
const selectedId = async () => {
|
||||
const s = await state();
|
||||
return s.selection?.kind === 'object' ? s.selection.objectId : null;
|
||||
};
|
||||
const picks = {};
|
||||
for (const [name, id, dx] of [
|
||||
['groundIcon', 'phys-ground-col', 0],
|
||||
['crateIcon', 'phys-crate-col', 0],
|
||||
['groundMiddle', 'phys-ground', null],
|
||||
]) {
|
||||
await select(null);
|
||||
const at = await json(dx === null ? `__gm.objectScreen('${id}')` : `__gm.sceneIcon('${id}')?.screen`);
|
||||
await click(at.x + (dx ?? 0), at.y);
|
||||
picks[name] = { selected: await selectedId() };
|
||||
}
|
||||
check(
|
||||
"a click on a collider's icon selects the collider, on the sprite's middle the sprite",
|
||||
icons.ground.clickable === true &&
|
||||
picks.groundIcon.selected === 'phys-ground-col' &&
|
||||
picks.crateIcon.selected === 'phys-crate-col' &&
|
||||
picks.groundMiddle.selected === 'phys-ground',
|
||||
JSON.stringify(picks),
|
||||
);
|
||||
|
||||
await selectObject('phys-ball-col');
|
||||
const field = await inView(t, '__gm.inspectorRect()', "__gm.inspectorField('Bounciness')");
|
||||
|
||||
Reference in new issue
Block a user