Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
aecaccb
ci: test older ubuntu version
Thyodas Sep 10, 2025
e094779
feat: Video component + system
Sauterelle57 Sep 7, 2025
c00d46e
fix: compilation
Sauterelle57 Sep 7, 2025
537492d
fix: crash when asset manager is not render
Sauterelle57 Sep 8, 2025
fd32f8a
fix: errors messages + add test video
Sauterelle57 Sep 8, 2025
431e0fe
fix: error message and add debug for video system
Sauterelle57 Sep 8, 2025
7dce056
feat: working video component + system
Sauterelle57 Sep 9, 2025
3ace4bd
fix: code style + norm
Sauterelle57 Sep 10, 2025
71c3c43
fix: play video only if scene is played
Sauterelle57 Sep 10, 2025
44a68e7
fix(windows-deps): fix missing deps for some dll
Thyodas Sep 10, 2025
9221c97
fix: Load first frame of video
Sauterelle57 Sep 11, 2025
8f8b9c0
feat(nexo-vdeo): shortcut to play and pause game sim
ThomasParenteau Sep 11, 2025
dd17910
fix: clean resources folder + fix cube texture indices
Sauterelle57 Sep 11, 2025
1453ce6
feat(keyframe-video): add video keyframe hendling with shortcuts
ThomasParenteau Sep 11, 2025
ad6bb10
feat: add example scenes
Sauterelle57 Sep 12, 2025
a57a592
feat(demo/scenes): add moving lights
Sauterelle57 Sep 12, 2025
23c115a
Merge remote-tracking branch 'origin/fix/windows-deps' into demo/scenes
Sauterelle57 Sep 12, 2025
536350a
feat(demo/scenes): add all scene
Sauterelle57 Sep 12, 2025
031dc4c
feat(keyframe-video): bool for show toolbar
ThomasParenteau Sep 12, 2025
e28dcb6
Merge branch 'feat/keyframe-video' into demo/scenes
ThomasParenteau Sep 12, 2025
5086f27
fix(demo): init cpp scene
ThomasParenteau Sep 12, 2025
f109ad4
fix(demo): init scene
ThomasParenteau Sep 12, 2025
375b0ce
feat(demo): accurate keyframe for warmup pres
Sauterelle57 Sep 12, 2025
55ae427
feat(demo): camera in front of the video
Sauterelle57 Sep 12, 2025
48d37ed
feat(demo): physics ball spawn by pressing L
Sauterelle57 Sep 12, 2025
328e468
fix(demo): placement of light scripting scene
Sauterelle57 Sep 12, 2025
b897166
fix(demo/scenes): code style + sonar / clang tidy errors and warnings…
Sauterelle57 Sep 16, 2025
aff9889
fix(demo/scenes): code style + sonar / clang tidy errors and warnings…
Sauterelle57 Sep 17, 2025
a02ddd7
fix(demo/scenes): code style + sonar + doc + clang tidy errors and wa…
Sauterelle57 Sep 17, 2025
f1f62db
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
3f7a310
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
b0d3099
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
06aeba8
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
d70c143
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
f27012f
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
2cfc594
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
0874c59
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
adde6f5
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
e382aaf
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
099a758
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
e462807
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
541a596
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
0136113
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 17, 2025
3cb23ea
fix(demo/scenes): compilation on Windows
Sauterelle57 Sep 17, 2025
d022393
fix(demo/scenes): compilation on Windows
Sauterelle57 Sep 17, 2025
51f8b79
ci(demo/scenes): fix compilation on Ubuntu CI
Thyodas Sep 18, 2025
e79d481
fix(demo/scenes): include in FileSystem.cpp needed for Linux
Sauterelle57 Sep 26, 2025
dd53356
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 26, 2025
b91f67d
fix(demo/scenes): include in FileSystem.cpp needed for Linux
Sauterelle57 Sep 26, 2025
9d12d8f
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 26, 2025
db8535b
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 28, 2025
5554eed
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 28, 2025
937f43e
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 28, 2025
c23d5a0
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 28, 2025
0dc94a4
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 28, 2025
7505a66
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 28, 2025
02ed0d6
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 29, 2025
43e1610
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Sep 29, 2025
80d91de
fix(demo/scenes): compilation on ubuntu
Sauterelle57 Oct 2, 2025
8b237a2
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Oct 3, 2025
fd00ccf
fix(demo/scenes): clean files + code style + sonar errors + documenta…
Sauterelle57 Oct 3, 2025
9032f9d
chore(model-thumbnails): add cmake user presets to gitignore
iMeaNz Oct 4, 2025
8e7435c
fix(model-thumbnail): add default build variable (fixed on dev)
iMeaNz Oct 4, 2025
7b740c0
chore(asset-aab): add source files
iMeaNz Oct 5, 2025
f190d36
feat(asset-aab): add utils func for aabb
iMeaNz Oct 5, 2025
62680f5
feat(asset-aabb): add simple box primitive with only 8 vertices
iMeaNz Oct 5, 2025
38ce960
feat(asset-aab): add draw indexed for line primitive + set line width…
iMeaNz Oct 5, 2025
e422361
feat(asset-aab): add debug box shader
iMeaNz Oct 5, 2025
3ea1817
feat(asset-aabb): add aabb debug system
iMeaNz Oct 5, 2025
df69da7
feat(asset-aab): draw commands now handle line primitive commands
iMeaNz Oct 5, 2025
a119604
tests(asset-aabb): add source files to renderer test cmake
iMeaNz Oct 5, 2025
9b33b82
feat(asset-aabb): add aabb and bsphere to model asset + fix: fix cond…
iMeaNz Oct 5, 2025
1c257dc
feat(asset-aab): init + call aabb debug system
iMeaNz Oct 5, 2025
853c3e5
style(asset-aab): remove useless comment
iMeaNz Oct 5, 2025
186962e
fix(asset-aabb): fix sonar errors
iMeaNz Oct 5, 2025
f41b8d8
style(asset-aabb): add '*' to comment
iMeaNz Oct 5, 2025
d4a5702
fix(asset-aabb): add check to setLineWidth + add util func to convert…
iMeaNz Oct 5, 2025
1bca049
fix(asset-aabb): add check to model aabb to make sure it is valid + a…
iMeaNz Oct 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 15 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest] # TODO: Add macos-latest later
os: [windows-latest, ubuntu-22.04] # TODO: Add macos-latest later
compiler: [gcc, msvc] # TODO: add clang later
include:
- os: ubuntu-latest
- os: ubuntu-22.04
compiler: gcc
version: 13
generator: Ninja
Expand All @@ -38,7 +38,7 @@ jobs:
version: 14
generator: "Visual Studio 17 2022"
exclude:
- os: ubuntu-latest
- os: ubuntu-22.04
compiler: msvc
- os: windows-latest
compiler: gcc
Expand All @@ -63,13 +63,13 @@ jobs:
detached: true # Run in the background and wait for connection

- name: Add Ubuntu toolchain repository
if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'}}
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.compiler == 'gcc'}}
run: |
sudo add-apt-repository --yes --update ppa:ubuntu-toolchain-r/test -y
sudo apt-get update

- name: Pre-install GCC with cache
if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc' }}
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.compiler == 'gcc' }}
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: cpp-13 g++-13 gcc-13 gcc-13-base libgcc-13-dev libhwasan0 \
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
toolset: ${{ matrix.version }}

- name: Install required system dependencies for Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libxrandr-dev libx11-dev
Expand All @@ -113,8 +113,8 @@ jobs:
libxcb-icccm4-dev libxcb-keysyms1-dev libxcb-dri2-0-dev libxcb-dri3-dev
libxcb-glx0-dev libx11-xcb-dev libglu1-mesa-dev
libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
libegl1-mesa-dev mono-complete
version: 1.0
libegl1-mesa-dev mono-complete libxtst-dev
version: 1.1
execute_install_scripts: true

- name: Install .NET SDK 9.0
Expand All @@ -127,7 +127,7 @@ jobs:
git submodule update --init --recursive

- name: Install sonar-scanner
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: sonarsource/sonarcloud-github-c-cpp@v3

- name: Install latest CMake and Ninja
Expand Down Expand Up @@ -201,14 +201,14 @@ jobs:
working-directory: 'build'

- name: Collect coverage into XML report for SonarCloud
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
pip install gcovr
gcovr build --verbose --sonarqube -o coverage.xml --gcov-executable gcov-${{ matrix.version }}
cat coverage.xml

- name: Run sonar-scanner
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
cpack -G NSIS --verbose

- name: Generate DEB installer
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
shell: bash
run: |
cd build
Expand Down Expand Up @@ -338,7 +338,7 @@ jobs:

test-deb-installer:
name: Test DEB installer
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
DOTNET_INSTALL_DIR: "./.dotnet"
needs: build
Expand All @@ -347,7 +347,7 @@ jobs:
id: download
uses: actions/download-artifact@v4
with:
pattern: 'nexo-engine-installer-gcc13-ubuntu-latest'
pattern: 'nexo-engine-installer-gcc13-ubuntu-22.04'

- name: Install .NET SDK 9.0
uses: actions/setup-dotnet@v4
Expand All @@ -360,7 +360,7 @@ jobs:
sudo apt-get update
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -f install ${{steps.download.outputs.download-path}}/nexo-engine-installer-gcc13-ubuntu-latest/*.deb
sudo apt-get -f install ${{steps.download.outputs.download-path}}/nexo-engine-installer-gcc13-ubuntu-22.04/*.deb

- name: Write NEXO run script
uses: "DamianReeves/write-file-action@master"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ jobs:
libxcb-icccm4-dev libxcb-keysyms1-dev libxcb-dri2-0-dev libxcb-dri3-dev
libxcb-glx0-dev libx11-xcb-dev libglu1-mesa-dev
libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
libegl1-mesa-dev mono-complete
version: 1.0
libegl1-mesa-dev mono-complete libxtst-dev
version: 1.1
execute_install_scripts: true

- name: Install .NET SDK 9.0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fabric.properties
.cmake
CMakeCache.txt
cmake_install.cmake
CMakeUserPresets.json

B-CPP-500_rtype.pdf

Expand Down
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ set(NEXO_GRAPHICS_API "OpenGL" CACHE STRING "Graphics API to use")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(NEXO_COMPILER_FLAGS_ALL --std=c++${CMAKE_CXX_STANDARD})
set(NEXO_COMPILER_FLAGS_DEBUG -g -Wmissing-field-initializers -Wall -Wextra -Wpedantic)
set(NEXO_COMPILER_FLAGS_RELEASE -O3)
set(NEXO_COMPILER_FLAGS_RELEASE -O3 -DNDEBUG)
set(NEXO_COVERAGE_FLAGS -O0 --coverage)

set(NEXO_LINKER_FLAGS_ALL "")
set(NEXO_LINKER_FLAGS_DEBUG "")
set(NEXO_LINKER_FLAGS_RELEASE "-flto")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(NEXO_COMPILER_FLAGS_ALL /nologo /W4 /std:c++${CMAKE_CXX_STANDARD} /Zc:preprocessor /utf-8)
set(NEXO_COMPILER_FLAGS_DEBUG /Zi /Od /Zc:preprocessor /MDd /D_DEBUG /D_ITERATOR_DEBUG_LEVEL=2 /D_SECURE_SCL=1)
set(NEXO_COMPILER_FLAGS_RELEASE /O2 /Zc:preprocessor)
set(NEXO_COMPILER_FLAGS_RELEASE /O2 /Zc:preprocessor /DNDEBUG /MD)
set(NEXO_COVERAGE_FLAGS "") # MSVC doesn't support coverage in the same way

set(NEXO_LINKER_FLAGS_ALL "")
set(NEXO_LINKER_FLAGS_DEBUG "")
set(NEXO_LINKER_FLAGS_RELEASE "/LTCG")
else()
message(WARNING "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}, using default flags")
endif()
Expand All @@ -34,6 +42,12 @@ add_compile_options(
"$<$<CONFIG:Release>:${NEXO_COMPILER_FLAGS_RELEASE}>"
)

add_link_options(
"${NEXO_LINKER_FLAGS_ALL}"
"$<$<CONFIG:Debug>:${NEXO_LINKER_FLAGS_DEBUG}>"
"$<$<CONFIG:Release>:${NEXO_LINKER_FLAGS_RELEASE}>"
)

# Prevent Visual Studio (or other build tools) from creating per config sub-directories (e.g. Debug, Release)
# Useful to look for resource files relative to the executable path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}>)
Expand Down
4 changes: 4 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"type": "FILEPATH",
"value": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
},
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Debug"
},
"CMAKE_EXPORT_COMPILE_COMMANDS": {
"type": "BOOL",
"value": true
Expand Down
74 changes: 74 additions & 0 deletions common/math/Bounds.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//// Bounds.cpp ///////////////////////////////////////////////////
//
// ⢀⢀⢀⣤⣤⣤⡀⢀⢀⢀⢀⢀⢀⢠⣤⡄⢀⢀⢀⢀⣠⣤⣤⣤⣤⣤⣤⣤⣤⣤⡀⢀⢀⢀⢠⣤⣄⢀⢀⢀⢀⢀⢀⢀⣤⣤⢀⢀⢀⢀⢀⢀⢀⢀⣀⣄⢀⢀⢠⣄⣀⢀⢀⢀⢀⢀⢀⢀
// ⢀⢀⢀⣿⣿⣿⣷⡀⢀⢀⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⡟⡛⡛⡛⡛⡛⡛⡛⢁⢀⢀⢀⢀⢻⣿⣦⢀⢀⢀⢀⢠⣾⡿⢃⢀⢀⢀⢀⢀⣠⣾⣿⢿⡟⢀⢀⡙⢿⢿⣿⣦⡀⢀⢀⢀⢀
// ⢀⢀⢀⣿⣿⡛⣿⣷⡀⢀⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⡇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⡙⣿⡷⢀⢀⣰⣿⡟⢁⢀⢀⢀⢀⢀⣾⣿⡟⢁⢀⢀⢀⢀⢀⢀⢀⡙⢿⣿⡆⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⡈⢿⣷⡄⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⣇⣀⣀⣀⣀⣀⣀⣀⢀⢀⢀⢀⢀⢀⢀⡈⢀⢀⣼⣿⢏⢀⢀⢀⢀⢀⢀⣼⣿⡏⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⡘⣿⣿⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⡈⢿⣿⡄⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⣿⢿⢿⢿⢿⢿⢿⢿⢇⢀⢀⢀⢀⢀⢀⢀⢠⣾⣿⣧⡀⢀⢀⢀⢀⢀⢀⣿⣿⡇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣿⣿⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⢀⡈⢿⣿⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⡇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣰⣿⡟⡛⣿⣷⡄⢀⢀⢀⢀⢀⢿⣿⣇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣿⣿⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⢀⢀⡈⢿⢀⢀⢸⣿⡇⢀⢀⢀⢀⡛⡟⢁⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣼⣿⡟⢀⢀⡈⢿⣿⣄⢀⢀⢀⢀⡘⣿⣿⣄⢀⢀⢀⢀⢀⢀⢀⢀⢀⣼⣿⢏⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⢀⢀⢀⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⢀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀⢀⢀⢀⣠⣾⡿⢃⢀⢀⢀⢀⢀⢻⣿⣧⡀⢀⢀⢀⡈⢻⣿⣷⣦⣄⢀⢀⣠⣤⣶⣿⡿⢋⢀⢀⢀⢀
// ⢀⢀⢀⢿⢿⢀⢀⢀⢀⢀⢀⢀⢀⢸⢿⢃⢀⢀⢀⢀⢻⢿⢿⢿⢿⢿⢿⢿⢿⢿⢃⢀⢀⢀⢿⡟⢁⢀⢀⢀⢀⢀⢀⢀⡙⢿⡗⢀⢀⢀⢀⢀⡈⡉⡛⡛⢀⢀⢹⡛⢋⢁⢀⢀⢀⢀⢀⢀
//
// Author: Mehdy MORVAN
// Date: 05/10/2025
// Description: Source file for the bounds utils
//
///////////////////////////////////////////////////////////////////////////////

#include "Bounds.hpp"

namespace nexo::math {
bool AABB::empty() const
{
return min.x > max.x || min.y > max.y || min.z > max.z;
}

AABB aabbUnion(const AABB& a, const AABB& b)
{
if (a.empty())
return b;
if (b.empty())
return a;

AABB o;
o.min = glm::min(a.min, b.min);
o.max = glm::max(a.max, b.max);
return o;
}

BSphere sphereFromAABB(const AABB& b)
{
BSphere s{};
if (b.empty())
return s;
s.c = 0.5f * (b.min + b.max);
const glm::vec3 e = 0.5f * (b.max - b.min);
s.r = glm::length(e);
return s;
}

AABB aabbTransform(const AABB& local, const glm::mat4& M)
{
if (local.empty())
return {};
const glm::vec3 lc = 0.5f * (local.min + local.max);
const glm::vec3 le = 0.5f * (local.max - local.min);

const glm::vec3 t = { M[3][0], M[3][1], M[3][2] };
// upper-left 3x3
const auto L = glm::mat3(M);

// world center
const glm::vec3 wc = L * lc + t;
const auto A = glm::mat3( glm::abs(L[0][0]), glm::abs(L[0][1]), glm::abs(L[0][2]),
glm::abs(L[1][0]), glm::abs(L[1][1]), glm::abs(L[1][2]),
glm::abs(L[2][0]), glm::abs(L[2][1]), glm::abs(L[2][2]) );
const glm::vec3 we = A * le;

AABB out;
out.min = wc - we;
out.max = wc + we;
return out;
}
}
102 changes: 102 additions & 0 deletions common/math/Bounds.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//// Bounds.hpp ///////////////////////////////////////////////////////////////
//
// ⢀⢀⢀⣤⣤⣤⡀⢀⢀⢀⢀⢀⢀⢠⣤⡄⢀⢀⢀⢀⣠⣤⣤⣤⣤⣤⣤⣤⣤⣤⡀⢀⢀⢀⢠⣤⣄⢀⢀⢀⢀⢀⢀⢀⣤⣤⢀⢀⢀⢀⢀⢀⢀⢀⣀⣄⢀⢀⢠⣄⣀⢀⢀⢀⢀⢀⢀⢀
// ⢀⢀⢀⣿⣿⣿⣷⡀⢀⢀⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⡟⡛⡛⡛⡛⡛⡛⡛⢁⢀⢀⢀⢀⢻⣿⣦⢀⢀⢀⢀⢠⣾⡿⢃⢀⢀⢀⢀⢀⣠⣾⣿⢿⡟⢀⢀⡙⢿⢿⣿⣦⡀⢀⢀⢀⢀
// ⢀⢀⢀⣿⣿⡛⣿⣷⡀⢀⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⡇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⡙⣿⡷⢀⢀⣰⣿⡟⢁⢀⢀⢀⢀⢀⣾⣿⡟⢁⢀⢀⢀⢀⢀⢀⢀⡙⢿⣿⡆⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⡈⢿⣷⡄⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⣇⣀⣀⣀⣀⣀⣀⣀⢀⢀⢀⢀⢀⢀⢀⡈⢀⢀⣼⣿⢏⢀⢀⢀⢀⢀⢀⣼⣿⡏⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⡘⣿⣿⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⡈⢿⣿⡄⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⣿⢿⢿⢿⢿⢿⢿⢿⢇⢀⢀⢀⢀⢀⢀⢀⢠⣾⣿⣧⡀⢀⢀⢀⢀⢀⢀⣿⣿⡇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣿⣿⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⢀⡈⢿⣿⢀⢀⢸⣿⡇⢀⢀⢀⢀⣿⣿⡇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣰⣿⡟⡛⣿⣷⡄⢀⢀⢀⢀⢀⢿⣿⣇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣿⣿⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⢀⢀⡈⢿⢀⢀⢸⣿⡇⢀⢀⢀⢀⡛⡟⢁⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣼⣿⡟⢀⢀⡈⢿⣿⣄⢀⢀⢀⢀⡘⣿⣿⣄⢀⢀⢀⢀⢀⢀⢀⢀⢀⣼⣿⢏⢀⢀⢀
// ⢀⢀⢀⣿⣿⢀⢀⢀⢀⢀⢀⢀⢀⢸⣿⡇⢀⢀⢀⢀⢀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀⢀⢀⢀⣠⣾⡿⢃⢀⢀⢀⢀⢀⢻⣿⣧⡀⢀⢀⢀⡈⢻⣿⣷⣦⣄⢀⢀⣠⣤⣶⣿⡿⢋⢀⢀⢀⢀
// ⢀⢀⢀⢿⢿⢀⢀⢀⢀⢀⢀⢀⢀⢸⢿⢃⢀⢀⢀⢀⢻⢿⢿⢿⢿⢿⢿⢿⢿⢿⢃⢀⢀⢀⢿⡟⢁⢀⢀⢀⢀⢀⢀⢀⡙⢿⡗⢀⢀⢀⢀⢀⡈⡉⡛⡛⢀⢀⢹⡛⢋⢁⢀⢀⢀⢀⢀⢀
//
// Author: Mehdy MORVAN
// Date: 04/10/2025
// Description: Header file for the bounds utils
//
///////////////////////////////////////////////////////////////////////////////

#pragma once
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

namespace nexo::math {
/**
* @struct AABB
* @brief Axis-aligned bounding box defined by min/max corners.
*
* Default-constructed boxes are "empty" (min > max) so they can be
* safely adopted by the first union/merge operation.
*
* Members:
* - glm::vec3 min — minimum corner (x/y/z).
* - glm::vec3 max — maximum corner (x/y/z).
*/
struct AABB {
glm::vec3 min{ +FLT_MAX, +FLT_MAX, +FLT_MAX };
glm::vec3 max{ -FLT_MAX, -FLT_MAX, -FLT_MAX };

/**
* @brief Whether this AABB currently represents no valid volume.
*
* An AABB is considered empty if any component of min is greater
* than the corresponding component of max.
*
* @return true if empty (e.g., before any points/boxes were merged), false otherwise.
*/
bool empty() const;
};

/**
* @struct BSphere
* @brief Bounding sphere (center + radius).
*
* Members:
* - glm::vec3 c — sphere center.
* - float r — non-negative radius.
*/
struct BSphere {
glm::vec3 c{0.0f};
float r{0.0f};
};

/**
* @brief Component-wise union of two AABBs.
*
* If one input is empty, the other is returned. If both are empty,
* an empty AABB is returned.
*
* @param a First AABB.
* @param b Second AABB.
* @return AABB that minimally encloses both @p a and @p b.
*/
AABB aabbUnion(const AABB& a, const AABB& b);

/**
* @brief Construct a conservative bounding sphere from an AABB.
*
* The sphere center is the AABB center. The radius equals the length
* of the half-extents (distance to a farthest corner). Suitable for
* quick frustum/broad-phase rejects.
*
* @param b Source AABB (may be empty).
* @return BSphere enclosing @p b. For an empty AABB, returns {c=(0,0,0), r=0}.
*/
BSphere sphereFromAABB(const AABB& b);

/**
* @brief Transform a local-space AABB by a 4×4 matrix and return a world-space AABB.
*
* Interprets the local AABB as an oriented box (center + half-extents) and applies:
* world_center = L * local_center + t
* world_half_extents = |L| * local_half_extents
* where L is the upper-left 3×3 of @p M and t is the translation. Using the
* absolute value of L yields a conservative axis-aligned enclosure under rotation
* and non-uniform scale.
*
* @param local Local-space AABB.
* @param M Transform from local to world space.
* @return World-space AABB that encloses the transformed local box.
*/
AABB aabbTransform(const AABB& local, const glm::mat4& M);
}
1 change: 1 addition & 0 deletions editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(SRCS
editor/src/DocumentWindows/EditorScene/Shortcuts.cpp
editor/src/DocumentWindows/EditorScene/Show.cpp
editor/src/DocumentWindows/EditorScene/Shutdown.cpp
editor/src/DocumentWindows/EditorScene/Timecode.cpp
editor/src/DocumentWindows/EditorScene/Toolbar.cpp
editor/src/DocumentWindows/EditorScene/Update.cpp
editor/src/DocumentWindows/EditorScene/DragDrop.cpp
Expand Down
Loading
Loading