Skip to content

Conversation

@liamdon
Copy link
Owner

@liamdon liamdon commented Nov 13, 2025

Summary

  • Extends unit-scale optimization by tracking unit-scale status on nodes and ancestors
  • Uses an optimized matrix multiply path for unit-scale transforms and fast-paths in world transform composition
  • Ensures world/local transforms remain correct when only translation/rotation changes

Changes

Core Functionality

  • Add internal flags on GraphNode to track unit-scale status and ancestor unit-scale status:
    • _hasUnitScale
    • _ancestorsHaveUnitScale
  • Propagate unit-scale status changes through the subtree when a node's local scale changes or when hierarchy topology changes
  • Introduce Mat4.mulAffine2NoScale(lhs, rhs) for unit-scale transforms and integrate a fast-path in mulAffine2 when scale is exactly (1,1,1)
  • In world transform calculation, use mulAffine2NoScale when this node and its ancestors are unit-scale to bypass redundant scale multiplications
  • Maintain correctness of world and local transforms for scenarios where only translation/rotation changes occur

Performance

  • Skip nine scale multiplications in common unit-scale hierarchies
  • Reduce matrix multiplications and allocations in the synchronization path

Tests

  • Extend unit tests to cover unit-scale optimization and ancestor propagation
  • Validate world/local transforms match pre-optimization results for unit-scale trees
  • Update existing tests to exercise the unit-scale code path

Dependency Updates

  • Bump PlayCanvas dependency to 2.9.0-beta.1 in examples/package-lock.json

Refactor

  • Centralize unit-scale handling logic in GraphNode and augment transform utilities with a dedicated unit-scale path

Test plan

  • Run unit tests for transform/hierarchy syncing
  • Validate world/local transforms for unit-scale trees
  • Benchmark performance on sizable unit-scale hierarchies

📎 Task: https://www.terragonlabs.com/task/f9946d6e-7d11-4228-abd1-ea617df67866

liamdon and others added 2 commits November 13, 2025 03:41
…0-beta.1

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…ices

- Added mulAffine2NoScale method to Mat4 for multiplying affine transformations without scale, improving performance.
- Enhanced setTRS method in Mat4 to fast path unit scale transformations, skipping unnecessary scale multiplications.
- Introduced _hasUnitScale and _ancestorsHaveUnitScale flags in GraphNode to track unit scale status locally and through ancestry.
- Optimized GraphNode hierarchy transform calculations to use the new no-scale multiplication method when applicable.
- Propagate unit scale status changes through node hierarchy to maintain accurate optimization flags.

These changes improve performance for common transform chains with no scaling by reducing computation overhead.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants