Skip to content

Improve camera default mode, refactor math module, rename PointerEvent API, add source checking CI - #3228

Merged
halx99 merged 13 commits into
devfrom
improve-camera-default
Jul 8, 2026
Merged

Improve camera default mode, refactor math module, rename PointerEvent API, add source checking CI#3228
halx99 merged 13 commits into
devfrom
improve-camera-default

Conversation

@halx99

@halx99 halx99 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Changes Summary

1. Camera Improvements (axmol/scene/)

  • Camera::create() now accepts a CameraMode parameter (default Classic) instead of inferring from Director::getProjection
  • initDefault() renamed to initClassic() — initializes the camera with Classic calibrated perspective mode
  • Removed AX_ENABLE_3D guards from screenToRay(), isVisibleInFrustum(), and related members — 3D math types are always available
  • Default camera is created with CameraMode::Classic instead of reading old axmol.gl.projection env var

2. PointerEvent API Renames

Old Name New Name
getScreenLocation() getPoint()
getPreviousScreenLocation() getPrevPoint()
getStartScreenLocation() getStartPoint()
getLocation() getWorldPoint()
getPreviousLocation() getPrevWorldPoint()
getStartLocation() getStartWorldPoint()
  • getWorldPoint() now computes world position via the per-camera ray (Camera::screenToRay) instead of calling Director::screenToWorld()
  • getPrevWorldPoint() and getStartWorldPoint() also switched to ray-based computation
  • Removed the special-case logic for PointerType::Controller in world point methods

3. EventDispatcher / Hit-Testing Refactor

  • pointerHitTest() now sets the ray on the event via camera->screenToRay() before dispatching (except for Controller type)
  • onPointerHitTest signature simplified: the camera parameter removed from the callback — camera info is obtained via event->getCamera() / event->getRay()
  • Menu::hitTestNodeWithPointer() updated to always use ray-based hit testing (no longer falls back to camera->isWorldPointInRect)

4. Math Module Relocation

  • Files moved from axmol/3d/axmol/math/:
    • AABB.h/.cpp, Frustum.h/.cpp, OBB.h/.cpp, Plane.h/.cpp, Ray.h/.cpp
  • These types are now available unconditionally (removed AX_ENABLE_3D guards)
  • axmol/math/CMakeLists.txt updated with new sources

5. Types.h Simplification

  • Vertex structs (Tex2F, Quad2, Quad3, V2F_T2F_C4B, etc.) moved from axmol/base/Types.h to axmol/math/Vertex.h
  • Types.h now includes Vertex.h instead of defining them inline

6. Director Cleanup

  • Removed:
    • Director::setProjection(Projection)
    • Director::screenToWorld(Vec2) / Director::worldToScreen(Vec2)
    • Director::EVENT_PROJECTION_CHANGED and its dispatch
    • env var axmol.gl.projection support
    • _eventProjectionChanged member
  • Replaced by Camera API: Camera::deprojectScreenToWorld() for world-space conversion
  • Remaining projection/window event constants reorganized (blank lines removed)

7. CI / Tooling

  • New tools/cmdline/check-sources.ps1 — checks for UTF-8 BOM and cstd-header issues in source files
  • clang-format.yml renamed to source-tidy.yml — now runs both clang-format and check-sources in a single workflow
  • Standalone check-sources.yml deleted (merged into source-tidy)
  • check-cstd-headers.yml renamed to check-sources.yml → then merged into source-tidy

8. BOM Removal

  • UTF-8 BOM (\xEF\xBB\xBF) stripped from engine source files across axmol/, tests/, extensions/, templates/
  • Only .h, .cpp, .inl, .mm, .m files affected
  • BOM presence now causes CI failure via source-tidy.ps1

9. Lua Test Updates

  • All tests/lua-tests/Content/src/ files updated to use new PointerEvent API names
  • getLocation()getWorldPoint() (47 occurrences)
  • getScreenLocation()getPoint() (14 occurrences)

10. 3D Project Template

  • New templates/cpp/3d/ — starter template for 3D projects with MainScene.cpp/.h
  • Build integration added for the new template

Files Changed

  • 569 files modified, ~1955 insertions, ~2004 deletions
  • 1 file deleted: .github/workflows/check-cstd-headers.yml
  • 4 files renamed: clang-format.ymlsource-tidy.yml, AABB/Frustum/OBB/Plane/Ray moved from 3d/ to math/
  • 4 files created: check-sources.ps1, PipelineDesc.h (in rhi/), MainScene.cpp/.h

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

@halx99

halx99 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

2 similar comments
@halx99

halx99 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@axmol-bot

Copy link
Copy Markdown
Collaborator

/clang-format

@axmol-bot axmol-bot changed the title feat: replace Director::setProjection with Scene::getDefaultCameraMode Improve camera default mode, refactor math module, rename PointerEvent API, add source checking CI Jul 7, 2026
@halx99
halx99 force-pushed the improve-camera-default branch from e8ead9e to 9f90bf9 Compare July 7, 2026 11:58
@halx99

halx99 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99

halx99 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

/clang-format

@halx99
halx99 merged commit 369163b into dev Jul 8, 2026
20 checks passed
@halx99
halx99 deleted the improve-camera-default branch July 8, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants