Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDExtension build prototype #294

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ef2a4c2
Remove newton dynamics
Lamakaio Jun 24, 2024
49ee950
add gdextension mode for osp
Lamakaio Jun 24, 2024
9c91e24
wire test app with godot - untested
Lamakaio Jun 28, 2024
6d138a0
Almost working hacked-together physics scene
Lamakaio Jul 1, 2024
53f2703
working physics exemple
Lamakaio Jul 2, 2024
0899c8b
Rewrite a lot of stuff
Capital-Asterisk Aug 5, 2024
86ec8ef
Progress on testapp rewrite
Capital-Asterisk Aug 16, 2024
e59be0a
Reorganize directories to match gdextension branch
Capital-Asterisk Aug 16, 2024
7bc1090
Move and reorganize more testapp stuff into adera_app
Capital-Asterisk Aug 18, 2024
6f6ce3d
Add framework unit test
Capital-Asterisk Aug 23, 2024
5e8a0b5
Fix physics test scenario and more framework progress
Capital-Asterisk Aug 23, 2024
12b5988
Fix all test scenarios
Capital-Asterisk Aug 26, 2024
8e363b2
Implement scene changes while magnum is open
Capital-Asterisk Aug 28, 2024
5e7f6d6
Fix ctest failure in github workflows
Capital-Asterisk Aug 29, 2024
26c9570
Fix MSVC builds
Capital-Asterisk Aug 29, 2024
29cae46
Fix code scanning and clang-tidy issues
Capital-Asterisk Aug 30, 2024
ba00d9a
Merge commit '53f270304c445dbaec858085118c8d71f61e0bc5'
Capital-Asterisk Aug 30, 2024
d10e044
Update gdextension to new framework
Capital-Asterisk Aug 31, 2024
9277bbe
Fix Resource ID ownership bug, mostly in osp/drawing/drawing_fn.cpp
Capital-Asterisk Aug 31, 2024
463fe6e
Fix jolt rocket center of mass offset
Capital-Asterisk Aug 31, 2024
1f52957
Fix jolt cylinder and update forgotten cmake file
Capital-Asterisk Sep 1, 2024
58961ee
fix aliasing issue in framework
Lamakaio Sep 28, 2024
e6d3298
remove newton dynamics submodule
Lamakaio Sep 28, 2024
50e257f
Remove all the osp render stuff to simplify gd code
Lamakaio Sep 29, 2024
3e4a34a
attempt fix for windows build issue
Lamakaio Oct 3, 2024
f1eaa18
various fixes - memory leaks & object cleanup
Lamakaio Oct 3, 2024
081e842
fix smooth shading (by not ignoring normals)
Lamakaio Oct 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
# TODO: Why doesn't the "test" target execute tests?
- name: Run Unit Tests
run: |
ctest --schedule-random --progress --output-on-failure --parallel --no-tests error --build-config ${{ matrix.config }} --test-dir build
ctest --schedule-random --progress --output-on-failure --parallel --no-tests=error --build-config ${{ matrix.config }} --test-dir build

- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ jobs:
- name: Run Unit Tests
shell: bash
run: |
ctest --schedule-random --progress --output-on-failure --parallel --no-tests error --build-config ${{ matrix.config }} --test-dir build
ctest --schedule-random --progress --output-on-failure --parallel --no-tests=error --build-config ${{ matrix.config }} --test-dir build
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
# MSVC Generator doesn't support the special target "test" like Ninja generator does on linux.
- name: Run Unit Tests
run: |
ctest --schedule-random --progress --output-on-failure --parallel --no-tests error --build-config ${{ matrix.config }} --test-dir build
ctest --schedule-random --progress --output-on-failure --parallel --no-tests=error --build-config ${{ matrix.config }} --test-dir build

- uses: actions/upload-artifact@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ out/
.vs/
build/
.vscode/
.cache
.cache
.clang-format
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
[submodule "3rdparty/magnum-integration"]
path = 3rdparty/magnum-integration
url = https://github.com/mosra/magnum-integration.git
[submodule "3rdparty/newton-dynamics"]
path = 3rdparty/newton-dynamics
url = https://github.com/MADEAPPS/newton-dynamics.git
[submodule "3rdparty/entt"]
path = 3rdparty/entt
url = https://github.com/skypjack/entt.git
Expand Down Expand Up @@ -40,3 +37,6 @@
[submodule "3rdparty/JoltPhysics"]
path = 3rdparty/JoltPhysics
url = https://github.com/jrouwe/JoltPhysics.git
[submodule "3rdparty/godot-cpp"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably specify a branch (latest LTS? so 4.2 right now), the README for https://github.com/godotengine/godot-cpp?tab=readme-ov-file#versioning indicates tracking master is not a good idea unless you are building Godot from source to match

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully up to date on how the .gitmodules file works so maybe a new feature was added since i last looked, but as far as I understand, there isn't a way to explicitly indicate a branch in this file, and you have to instead rely on specifying the exact commit you want to refer to.

If they've added "Give me the latest in branch X" support, or "Give me whatever tag Y points to" support, i'd be happy to hear about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put the commit number, I'm pretty sure it's specified in the releases.

path = 3rdparty/godot-cpp
url = https://github.com/godotengine/godot-cpp
76 changes: 40 additions & 36 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ if(NOT OSP_USE_SYSTEM_SDL)
SET(SDL_VIRTUAL_JOYSTICK ON CACHE BOOL "" FORCE)

SET(LIBSAMPLERATE ON CACHE BOOL "" FORCE)
SET(LIBSAMPLERATE_SHARED ON CACHE BOOL "" FORCE)
SET(LIBSAMPLERATE_SHARED OFF CACHE BOOL "" FORCE)

SET(SDL_EVENTS ON CACHE BOOL "" FORCE)
SET(SDL_THREADS ON CACHE BOOL "" FORCE)

# This assumes you want to have SDL as a static library. If not, set SDL_STATIC
# to OFF instead.
SET(SDL_DLOPEN ON CACHE BOOL "" FORCE)
SET(SDL_SHARED ON CACHE BOOL "" FORCE)
SET(SDL_STATIC OFF CACHE BOOL "" FORCE)
SET(SDL_DLOPEN OFF CACHE BOOL "" FORCE)
SET(SDL_SHARED OFF CACHE BOOL "" FORCE)
SET(SDL_STATIC ON CACHE BOOL "" FORCE)

SET(SDL2_DISABLE_SDL2MAIN ON CACHE BOOL "" FORCE)
SET(SDL2_DISABLE_INSTALL ON CACHE BOOL "" FORCE)
Expand Down Expand Up @@ -186,31 +186,23 @@ SET(MAGNUM_WITH_DEBUGTOOLS OFF CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_MESHTOOLS ON CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_SCENEGRAPH OFF CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_SCENETOOLS OFF CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_SDL2APPLICATION ON CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_SHADERS ON CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_SHADERTOOLS OFF CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_TEXT OFF CACHE BOOL "" FORCE)

IF (OSP_BUILD_TESTAPP)
SET(MAGNUM_WITH_SDL2APPLICATION ON CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_SHADERS ON CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_GL ON CACHE BOOL "" FORCE)
SET(MAGNUM_TARGET_GL ON CACHE BOOL "" FORCE)
ENDIF()

ADD_SUBDIRECTORY(magnum EXCLUDE_FROM_ALL)

SET(MAGNUM_WITH_TINYGLTFIMPORTER ON CACHE BOOL "" FORCE)
SET(MAGNUM_WITH_STBIMAGEIMPORTER ON CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY(magnum-plugins EXCLUDE_FROM_ALL)

SET(NEWTON_BUILD_SANDBOX_DEMOS OFF CACHE BOOL "" FORCE)
SET(NEWTON_BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
SET(NEWTON_USE_PLUGIN_DLL OFF CACHE BOOL "" FORCE)
SET(NEWTON_WITH_AVX_PLUGIN OFF CACHE BOOL "" FORCE)
SET(NEWTON_WITH_REFERENCE_GPU_PLUGIN OFF CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY(newton-dynamics/newton-3.14/ EXCLUDE_FROM_ALL)

# Newton sets CMAKE_ARCHIVE_OUTPUT_DIRECTORY and CMAKE_LIBRARY_OUTPUT_DIRECTORY
# for UNIX, so manually set each target to our desired location
SET_TARGET_PROPERTIES(dAnimation dContainers dCustomJoints dMath dModel dNewton dScene dVehicle dgCore dgPhysics newton PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
)

ADD_SUBDIRECTORY(entt EXCLUDE_FROM_ALL)

# toml11 3.8.0 added a check for this global variable, which they should not have.
Expand All @@ -222,32 +214,44 @@ ADD_SUBDIRECTORY(toml11 EXCLUDE_FROM_ALL)
SET(SPDLOG_ENABLE_PCH ON CACHE BOOL "" FORCE)
# Not yet supported by github runners
# SET(SPDLOG_USE_STD_FORMAT ON CACHE BOOL "" FORCE)
SET(SPDLOG_BUILD_PIC ON CACHE BOOL "" FORCE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on this?

I don't mind it, but i'm curious to know your reasons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I had a link error due to positionning in spdlog, I saw there was a flag, I enabled it, it fixed the error.
Then again, I'm not sure how this all works, so if there is a preferred solution that's perfectly fine.

ADD_SUBDIRECTORY(spdlog EXCLUDE_FROM_ALL)
ADD_SUBDIRECTORY(longeronpp EXCLUDE_FROM_ALL)

# For Windows: Prevent overriding the parent project's compiler/linker settings
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY(googletest EXCLUDE_FROM_ALL)

SET(FT_DISABLE_ZLIB ON CACHE BOOL "" FORCE)
SET(FT_DISABLE_BZIP2 ON CACHE BOOL "" FORCE)
SET(FT_DISABLE_PNG ON CACHE BOOL "" FORCE)
SET(FT_DISABLE_HARFBUZZ ON CACHE BOOL "" FORCE)
SET(FT_DISABLE_BROTLI ON CACHE BOOL "" FORCE)
SET(SKIP_INSTALL_ALL ON CACHE BOOL "" FORCE)
SET(SKIP_INSTALL_LIBRARIES ON CACHE BOOL "" FORCE)
SET(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY(freetype EXCLUDE_FROM_ALL)

INSTALL(TARGETS freetype
EXPORT RmlUiTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# SET(FT_DISABLE_ZLIB ON CACHE BOOL "" FORCE)
# SET(FT_DISABLE_BZIP2 ON CACHE BOOL "" FORCE)
# SET(FT_DISABLE_PNG ON CACHE BOOL "" FORCE)
# SET(FT_DISABLE_HARFBUZZ ON CACHE BOOL "" FORCE)
# SET(FT_DISABLE_BROTLI ON CACHE BOOL "" FORCE)
# SET(SKIP_INSTALL_ALL ON CACHE BOOL "" FORCE)
# SET(SKIP_INSTALL_LIBRARIES ON CACHE BOOL "" FORCE)
# SET(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
# ADD_SUBDIRECTORY(freetype EXCLUDE_FROM_ALL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i recall correctly, we only need freetype for RmlUi.

So if we're going to go full steam on godot, then we can just drop RmlUi and freetype.

but in general, best not to leave commented out code in the source files.


# INSTALL(TARGETS freetype
# EXPORT RmlUiTargets
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
# )

SET(RML_SKIP_INSTALL ON CACHE BOOL "" FORCE)
SET(CUSTOM_CONFIGURATION ON CACHE BOOL "" FORCE)
#ADD_SUBDIRECTORY(RmlUi EXCLUDE_FROM_ALL)
SET(ENABLE_ALL_WARNINGS OFF CACHE BOOL "" FORCE)
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh lovely, Jolt doesn't namespace it's options? Rather selfish of them.

ADD_SUBDIRECTORY(JoltPhysics/Build EXCLUDE_FROM_ALL)
set_property(TARGET Jolt PROPERTY POSITION_INDEPENDENT_CODE ON)

SET( GODOT_CPP_SYSTEM_HEADERS ON CACHE BOOL "" FORCE )

ADD_SUBDIRECTORY( godot-cpp EXCLUDE_FROM_ALL)

SET_TARGET_PROPERTIES( godot-cpp
PROPERTIES
CXX_VISIBILITY_PRESET hidden # visibility needs to be the same as the main library
)
1 change: 1 addition & 0 deletions 3rdparty/godot-cpp
Submodule godot-cpp added at 98c143
1 change: 0 additions & 1 deletion 3rdparty/newton-dynamics
Submodule newton-dynamics deleted from d8fb1d
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ IF(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_SYSTEM_VERSION)
SET(CMAKE_SYSTEM_VERSION "10.0.18362.0" CACHE INTERNAL "" FORCE)
ENDIF()

#build universally on macOS
if ( APPLE )
set( CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" )
endif()

# Set project name
PROJECT(OSP-MAGNUM CXX)

Expand All @@ -56,6 +61,8 @@ OPTION(OSP_ENABLE_COMPILER_WARNINGS "Build with the majority of compiler warning
OPTION(OSP_ENABLE_IWYU "Build with warnings from IWYU turned on" OFF)
OPTION(OSP_ENABLE_CLANG_TIDY "Build with warnings from clang-tidy turned on" OFF)
OPTION(OSP_USE_SYSTEM_SDL "Build with SDL that you provide if turned on, compiles SDL if turned off. Off by default" OFF)
OPTION(OSP_BUILD_TESTAPP "Build OSP TestApp with Magnum, OpenGL, and SDL2" ON)
OPTION(OSP_BUILD_GDEXTENSION "Build OSP GDExtension" OFF)

# If the environment has these set, pull them into proper variables.
SET(CLANG_COMPILE_FLAGS ${CLANG_COMPILE_FLAGS})
Expand Down Expand Up @@ -138,6 +145,7 @@ IF(MSVC)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
# Force dynamic runtime library to be in debug mode in debug mode.
add_compile_options($<$<CONFIG:Debug>:$<$<CXX_COMPILER_ID:MSVC>:/MDd>>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already supposed to be the behavior that cmake has by default.

https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html

If this variable is not set then the MSVC_RUNTIME_LIBRARY target property will not be set automatically. If that property is not set then CMake uses the default value MultiThreaded$<$CONFIG:Debug:Debug>DLL to select a MSVC runtime library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is something for the Jolt PR, it was what was causing the windows compile error in debug mode in the CI. Adding that line fixed it. Maybe something in Jolt breaks it somehow ...

If that's the case, it might be better to upstream a fix in the long term.

add_compile_options($<$<CONFIG:Release>:$<$<CXX_COMPILER_ID:MSVC>:/MD>>)
# Don't generate a blah.manifest file for each build target.
add_link_options(LINKER:/MANIFEST:NO)
ELSEIF(UNIX)
Expand All @@ -163,4 +171,3 @@ ADD_SUBDIRECTORY(test)
# Set OSP as default startup project in Visual Studio
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT osp-magnum)
# Set execution directory of osp-magnum so that we don't have to copy the files
set_property(TARGET osp-magnum PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ By taking advantage of Entity Component System (ECS) architectures and Data-Orie
* Scene Graph
* Configurable multipass Renderer
* Straightforward interface for integrating any physics engine
* Out of the box we integrate with Newton Dynamics 3.14c.
* Out of the box we integrate with Jolt Physics 5.0.
* PRs to support other physics engines welcome!!!
* Wiring/Connection System
* Resource flow between ship components
Expand All @@ -50,7 +50,7 @@ By taking advantage of Entity Component System (ECS) architectures and Data-Orie

### Extra

* *Newton Dynamics* Physics Engine integration
* *Jolt Physics* Physics Engine integration
* Rockets, RCS, and Fuel tanks
* Rocket exhaust plume effects
* Planet terrain, Icosahedron-based tessellation
Expand Down
12 changes: 2 additions & 10 deletions bin/OSPData/adera/ph_rcs.sturdy.gltf
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"texCoord" : 0
},
"metallicRoughnessTexture" : {
"index" : 1,
"index" : 0,
"texCoord" : 0
}
}
Expand All @@ -117,22 +117,14 @@
"textures" : [
{
"source" : 0
},
{
"source" : 1
}
],
"images" : [
{
"mimeType" : "image/png",
"name" : "ph_base",
"uri" : "ph_base.png"
},
{
"mimeType" : "image/png",
"name" : "ph_metal-ph_rough",
"uri" : "ph_metal-ph_rough.png"
}
}
],
"accessors" : [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Welcome aboard! This document presents a high level overview of the project, aim
* `src/osp` - Core components for a spaceflight simulator.
* `src/adera` - Fun stuff. More gameplay and visual-effects focused.
* `src/planet-a` - Planet terrain subdivision code.
* `src/ospnewton` - Newton Dynamics physics engine integration
* `src/ospjolt` - Jolt Physics physics engine integration
* `src/testapp` - Runnable application. Assembles everything to make test scenarios.

Most components are separate building blocks (with intended uses). The 'game engine' only comes into existence within `testapp`.
Expand Down
8 changes: 4 additions & 4 deletions docs/dependencygraph.dot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ digraph {
"Longeron++"
"Magnum & Corrade"
"Magnum/GL";
"Newton Dynamics";
"Jolt Physics";

node [shape=rectangle, style=filled, fillcolor=white]
"osp/core" -> "Magnum & Corrade";
Expand All @@ -36,8 +36,8 @@ digraph {
"adera/machines" -> "osp/link";

node [shape=rectangle, style=filled, fillcolor=lightslateblue]
"ospnewton/activescene" -> "osp/activescene";
"ospnewton/activescene" -> "Newton Dynamics";
"ospjolt/activescene" -> "osp/activescene";
"ospjolt/activescene" -> "Jolt Physics";

node [shape=rectangle, style=filled, fillcolor=palegreen1]
"planet-a" -> "osp/core";
Expand All @@ -48,7 +48,7 @@ digraph {
"testapp/sessions" -> "adera/machines";
"testapp/sessions" -> "adera/drawing_gl";
"testapp/sessions" -> "adera/drawing";
"testapp/sessions" -> "ospnewton/activescene";
"testapp/sessions" -> "ospjolt/activescene";
"testapp/sessions" -> "planet-a";
"testapp/sessions" -> "adera/activescene";
"testapp" -> "testapp/sessions";
Expand Down
Loading
Loading