Transform: scale, rotation and mirror as properties, world transform as a matrix chain, oriented colliders (#76)
game-maker / suite (push) Successful in 9m5s
game-maker / suite (push) Successful in 9m5s
Four new rows on sprite, text, collider and container (block TRANSFORM): scale, rotation in degrees clockwise, mirrorX, mirrorY. As properties they get override/reset/apply, loading of old projects, write-back after play and the Properties node for free; camera and behavior have none. The hierarchy composes T*R*S per level (composeAlongChain replaces sumAlongChain), so children rotate and scale with their parent. Reparenting and grouping keep the look (carriedTransform). Drawing goes through placeNode, the gizmo is a polygon, cull and objectRect use the AABB, drags are computed in the parent's system. Colliders are oriented boxes: SAT for box/box, box-circle in the box frame; exitDistance replaces axisSeparation/axisCorrection, moveAndSlide moves along the object's own axes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
f85606427b
commit
016e83c9b5
33 files changed
+1346
-274
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import type { PropertyBag } from '../model/Properties';
|
||||
import { sumAlongChain } from '../model/walk';
|
||||
import type { Mat } from '../model/matrix';
|
||||
import type { Position, PropertyBag } from '../model/Properties';
|
||||
import { type ChainTransform, composeAlongChain } from '../model/walk';
|
||||
import { enabledAlongChain } from '../properties/enabled';
|
||||
import { localMatrixOf, positionOf, transformOf } from '../properties/transform';
|
||||
|
||||
/**
|
||||
* Marks a live entity apart from a struct value: both reach a data edge as an object. A symbol
|
||||
@@ -26,14 +28,23 @@ export interface EntityHandle {
|
||||
parent: EntityHandle | null;
|
||||
}
|
||||
|
||||
export function worldPositionOf(handle: EntityHandle): { x: number; y: number; z: number } {
|
||||
return sumAlongChain(
|
||||
/** Position, rotation, scale and mirror of every ancestor applied, nearest last. */
|
||||
export function worldTransformOf(handle: EntityHandle): ChainTransform {
|
||||
return composeAlongChain(
|
||||
handle,
|
||||
(h) => h.parent,
|
||||
(h) => h,
|
||||
(h) => ({ m: localMatrixOf(h, transformOf(h.props)), z: h.z }),
|
||||
);
|
||||
}
|
||||
|
||||
export function worldMatrixOf(handle: EntityHandle): Mat {
|
||||
return worldTransformOf(handle).m;
|
||||
}
|
||||
|
||||
export function worldPositionOf(handle: EntityHandle): Position {
|
||||
return positionOf(worldTransformOf(handle));
|
||||
}
|
||||
|
||||
/** Whether a handle and every ancestor of it are switched on. */
|
||||
export function isHandleEnabled(handle: EntityHandle): boolean {
|
||||
return enabledAlongChain(
|
||||
|
||||
Reference in new issue
Block a user