Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(ui): the hit test stops asking for mouse state it throws away

esengine6d8e3ec2c9f1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62f8192c9..fa9812143 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -176,6 +176,15 @@ published separately; it ships inside the editor.
### Fixed
+- **The UI hit test took three mouse flags and threw them away.**
+ `uiHitTestWorld(world, x, y, mouseDown, mousePressed, mouseReleased)` carried
+ them into the engine, which `(void)`-ed all three: it is a raycast, and what a
+ press or a hover MEANS is the interaction system's, in TypeScript. The doc
+ comment said the flags "drive hover/press state", and a test asserted they
+ reached the engine — which is exactly what a test that checks the seam rather
+ than the behaviour can prove about a parameter nothing reads. The flags are
+ gone from the SDK function, the binding and the C++ method.
+
- **The project's default font family never took effect.** It was written into
`RuntimeConfig` and read by exactly one function — `applyRuntimeConfig`, which
nothing called — so setting it changed no text anywhere. Two more places
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 60e695096..c852b7b35 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -12170,7 +12170,7 @@ TrailPlugin
## uiHitTestWorld — function @experimental
```
-(world: PickableWorld, worldX: number, worldY: number, mouseDown?: boolean, mousePressed?: boolean, mouseReleased?: boolean): Entity | null
+(world: PickableWorld, worldX: number, worldY: number): Entity | null
```
## uiInteractionPlugin — const @experimental
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 8c75d2992..7c6a34918 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -12413,7 +12413,7 @@ TrailPlugin
## uiHitTestWorld — function @experimental
```
-(world: PickableWorld, worldX: number, worldY: number, mouseDown?: boolean, mousePressed?: boolean, mouseReleased?: boolean): Entity | null
+(world: PickableWorld, worldX: number, worldY: number): Entity | null
```
## uiInteractionPlugin — const @experimental
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 315a258c4..df4bb47ff 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -12175,7 +12175,7 @@ TrailPlugin
## uiHitTestWorld — function @experimental
```
-(world: PickableWorld, worldX: number, worldY: number, mouseDown?: boolean, mousePressed?: boolean, mouseReleased?: boolean): Entity | null
+(world: PickableWorld, worldX: number, worldY: number): Entity | null
```
## uiInteractionPlugin — const @experimental
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 011e8e6b8..59fe0b545 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -12425,7 +12425,7 @@ TrailPlugin
## uiHitTestWorld — function @experimental
```
-(world: PickableWorld, worldX: number, worldY: number, mouseDown?: boolean, mousePressed?: boolean, mouseReleased?: boolean): Entity | null
+(world: PickableWorld, worldX: number, worldY: number): Entity | null
```
## uiInteractionPlugin — const @experimental
diff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.md
index bb2e4aeab..8fc7b7d6c 100644
--- a/sdk/etc/wasm.api.md
+++ b/sdk/etc/wasm.api.md
@@ -440,7 +440,7 @@ uiHitTest_getHitEntityPrev: () => number
uiHitTest_pick: ((registry: CppRegistry, worldX: number, worldY: number) => number) | undefined
uiHitTest_pickAll: ((registry: CppRegistry, worldX: number, worldY: number) => number) | undefined
uiHitTest_pickResult: ((index: number) => number) | undefined
-uiHitTest_update: (registry: CppRegistry, mouseWorldX: number, mouseWorldY: number, mouseDown: boolean, mousePressed: boolean, mouseReleased: boolean) => void
+uiHitTest_update: (registry: CppRegistry, mouseWorldX: number, mouseWorldY: number) => void
uiLayout_update: (registry: CppRegistry, boxLeft: number, boxBottom: number, boxRight: number, boxTop: number, propertyDirty: boolean) => void
uiNode_computedHeight: (registry: CppRegistry, entity: number) => number
uiNode_computedWidth: (registry: CppRegistry, entity: number) => number
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index dac52c14e..d9d18d158 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -12197,7 +12197,7 @@ TrailPlugin
## uiHitTestWorld — function @experimental
```
-(world: PickableWorld, worldX: number, worldY: number, mouseDown?: boolean, mousePressed?: boolean, mouseReleased?: boolean): Entity | null
+(world: PickableWorld, worldX: number, worldY: number): Entity | null
```
## uiInteractionPlugin — const @experimental
diff --git a/sdk/src/ecs/bridge/nativeEngineApi.generated.ts b/sdk/src/ecs/bridge/nativeEngineApi.generated.ts
index 5f8356831..b1017c2fc 100644
--- a/sdk/src/ecs/bridge/nativeEngineApi.generated.ts
+++ b/sdk/src/ecs/bridge/nativeEngineApi.generated.ts
@@ -241,7 +241,7 @@ export interface NativeEngineApi {
uiHitTest_pick?(registry: unknown, worldX: number, worldY: number): number;
uiHitTest_pickAll?(registry: unknown, worldX: number, worldY: number): number;
uiHitTest_pickResult?(index: number): number;
- uiHitTest_update?(registry: unknown, mouseWorldX: number, mouseWorldY: number, mouseDown: boolean, mousePressed: boolean, mouseReleased: boolean): void;
+ uiHitTest_update?(registry: unknown, mouseWorldX: number, mouseWorldY: number): void;
uiLayout_update?(registry: unknown, boxLeft: number, boxBottom: number, boxRight: number, boxTop: number, propertyDirty: boolean): void;
uiNode_computedHeight?(registry: unknown, entity: number): number;
uiNode_computedWidth?(registry: unknown, entity: number): number;
diff --git a/sdk/src/ui/input/interaction.ts b/sdk/src/ui/input/interaction.ts
index c1eb6ff54..5a50a5564 100644
--- a/sdk/src/ui/input/interaction.ts
+++ b/sdk/src/ui/input/interaction.ts
@@ -106,11 +106,7 @@ export class UIInteractionPlugin implements Plugin {
let hitEntity: Entity | null = hoveredEntity;
if (needsHitTest) {
- hitEntity = uiHitTestWorld(
- world,
- worldMouse.x, worldMouse.y,
- mouseDown, mousePressed, mouseReleased,
- );
+ hitEntity = uiHitTestWorld(world, worldMouse.x, worldMouse.y);
}
if (hoveredEntity !== null && !world.valid(hoveredEntity)) {
diff --git a/sdk/src/ui/util/ui-pick.ts b/sdk/src/ui/util/ui-pick.ts
index 6f5b96580..5d1fe7d78 100644
--- a/sdk/src/ui/util/ui-pick.ts
+++ b/sdk/src/ui/util/ui-pick.ts
@@ -37,19 +37,12 @@ function core(world: PickableWorld) {
/**
* The topmost **interactable** entity at a world point — the same raycast the
* interaction system runs, so a custom cursor agrees with the built-in one.
- * The mouse flags drive hover/press state; leave them false to only look.
+ * A query: what a press or a hover MEANS is the interaction system's business.
*/
-export function uiHitTestWorld(
- world: PickableWorld,
- worldX: number,
- worldY: number,
- mouseDown = false,
- mousePressed = false,
- mouseReleased = false,
-): Entity | null {
+export function uiHitTestWorld(world: PickableWorld, worldX: number, worldY: number): Entity | null {
const c = core(world);
if (!c?.engine.uiHitTest_update || !c.engine.uiHitTest_getHitEntity) return null;
- c.engine.uiHitTest_update(c.registry, worldX, worldY, mouseDown, mousePressed, mouseReleased);
+ c.engine.uiHitTest_update(c.registry, worldX, worldY);
const hit = c.engine.uiHitTest_getHitEntity();
return hit === NO_HIT ? null : hit;
}
diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.ts
index 68400d28a..520b82763 100644
--- a/sdk/src/wasm.ts
+++ b/sdk/src/wasm.ts
@@ -570,7 +570,7 @@ export interface ESEngineModule {
// UI Systems
uiLayout_update(registry: CppRegistry, boxLeft: number, boxBottom: number, boxRight: number, boxTop: number, propertyDirty: boolean): void;
- uiHitTest_update(registry: CppRegistry, mouseWorldX: number, mouseWorldY: number, mouseDown: boolean, mousePressed: boolean, mouseReleased: boolean): void;
+ uiHitTest_update(registry: CppRegistry, mouseWorldX: number, mouseWorldY: number): void;
uiHitTest_getHitEntity(): number;
uiHitTest_getHitEntityPrev(): number;
uiHitTest_pick?(registry: CppRegistry, worldX: number, worldY: number): number;
diff --git a/sdk/tests/ui-pick.test.ts b/sdk/tests/ui-pick.test.ts
index 4d3101382..4e8525876 100644
--- a/sdk/tests/ui-pick.test.ts
+++ b/sdk/tests/ui-pick.test.ts
@@ -16,19 +16,13 @@ describe('uiHitTestWorld', () => {
it('returns the hit entity', () => {
const engine = hitTester(42);
expect(uiHitTestWorld(world(engine), 10, 20)).toBe(42);
- expect(engine.uiHitTest_update).toHaveBeenCalledWith(REGISTRY, 10, 20, false, false, false);
+ expect(engine.uiHitTest_update).toHaveBeenCalledWith(REGISTRY, 10, 20);
});
it('maps the no-hit sentinel to null', () => {
expect(uiHitTestWorld(world(hitTester(0xffffffff)), 0, 0)).toBeNull();
});
- it('passes mouse flags through (the input path)', () => {
- const engine = hitTester(7);
- uiHitTestWorld(world(engine), 1, 2, true, true, false);
- expect(engine.uiHitTest_update).toHaveBeenCalledWith(REGISTRY, 1, 2, true, true, false);
- });
-
it('answers null when the world has no engine core behind it', () => {
expect(uiHitTestWorld(world(null), 1, 2)).toBeNull();
});
diff --git a/src/esengine/bindings/UIBindings.cpp b/src/esengine/bindings/UIBindings.cpp
index a0d367028..53cb49095 100644
--- a/src/esengine/bindings/UIBindings.cpp
+++ b/src/esengine/bindings/UIBindings.cpp
@@ -32,9 +32,8 @@ void uiLayout_update(ecs::Registry& registry, f32 boxLeft, f32 boxBottom, f32 bo
ctx().require<ecs::UISystem>().layoutUpdate(registry, boxLeft, boxBottom, boxRight, boxTop, propertyDirty);
}
-void uiHitTest_update(ecs::Registry& registry, f32 mouseWorldX, f32 mouseWorldY,
- bool mouseDown, bool mousePressed, bool mouseReleased) {
- ctx().require<ecs::UISystem>().hitTestUpdate(registry, mouseWorldX, mouseWorldY, mouseDown, mousePressed, mouseReleased);
+void uiHitTest_update(ecs::Registry& registry, f32 mouseWorldX, f32 mouseWorldY) {
+ ctx().require<ecs::UISystem>().hitTestUpdate(registry, mouseWorldX, mouseWorldY);
}
u32 uiHitTest_getHitEntity() {
diff --git a/src/esengine/bindings/UIBindings.hpp b/src/esengine/bindings/UIBindings.hpp
index 3e0268f4b..e416744f3 100644
--- a/src/esengine/bindings/UIBindings.hpp
+++ b/src/esengine/bindings/UIBindings.hpp
@@ -28,8 +28,7 @@ namespace ecs {
void uiLayout_update(ecs::Registry& registry, f32 boxLeft, f32 boxBottom, f32 boxRight, f32 boxTop,
bool propertyDirty);
-void uiHitTest_update(ecs::Registry& registry, f32 mouseWorldX, f32 mouseWorldY,
- bool mouseDown, bool mousePressed, bool mouseReleased);
+void uiHitTest_update(ecs::Registry& registry, f32 mouseWorldX, f32 mouseWorldY);
u32 uiHitTest_getHitEntity();
u32 uiHitTest_getHitEntityPrev();
u32 uiHitTest_pick(ecs::Registry& registry, f32 worldX, f32 worldY);
diff --git a/src/esengine/ui/UISystem.cpp b/src/esengine/ui/UISystem.cpp
index e1fac70ce..5b43af99d 100644
--- a/src/esengine/ui/UISystem.cpp
+++ b/src/esengine/ui/UISystem.cpp
@@ -22,15 +22,7 @@
namespace esengine::ecs {
-void UISystem::hitTestUpdate(
- Registry& registry,
- f32 mouseWorldX, f32 mouseWorldY,
- bool mouseDown, bool mousePressed, bool mouseReleased
-) {
- (void)mouseDown;
- (void)mousePressed;
- (void)mouseReleased;
-
+void UISystem::hitTestUpdate(Registry& registry, f32 mouseWorldX, f32 mouseWorldY) {
hitResult.prev_hit_entity = hitResult.hit_entity;
hitResult.hit_entity = INVALID_ENTITY;
diff --git a/src/esengine/ui/UISystem.hpp b/src/esengine/ui/UISystem.hpp
index 42b733080..c11f5d4cd 100644
--- a/src/esengine/ui/UISystem.hpp
+++ b/src/esengine/ui/UISystem.hpp
@@ -44,7 +44,7 @@ struct UIHitTestResult {
* @code
* auto& ui = ctx.require<ecs::UISystem>();
* ui.layoutUpdate(registry, -960, -540, 960, 540);
- * ui.hitTestUpdate(registry, mouseX, mouseY, false, true, false);
+ * ui.hitTestUpdate(registry, mouseX, mouseY);
* auto hitEntity = ui.getHitEntity();
* @endcode
*/
@@ -77,10 +77,9 @@ public:
// ---- Hit test pass (defined in UISystem.cpp) ----
- /** @brief Run point-vs-UI hit-test, updating hitResult */
- void hitTestUpdate(Registry& registry,
- f32 mouseWorldX, f32 mouseWorldY,
- bool mouseDown, bool mousePressed, bool mouseReleased);
+ /** @brief Run point-vs-UI hit-test, updating hitResult. A query: what a
+ * press or a hover MEANS is the interaction system's, and it is in TS. */
+ void hitTestUpdate(Registry& registry, f32 mouseWorldX, f32 mouseWorldY);
/** @brief Editor pick: the most specific UI entity under the point. Unlike
* hitTestUpdate it ignores Interactable and mutates no state. */