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

Replace Newton Dynamics with Jolt Physics #287

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ out/
.vs/
build/
.vscode/
.cache
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@
[submodule "3rdparty/freetype"]
path = 3rdparty/freetype
url = https://github.com/freetype/freetype
[submodule "3rdparty/JoltPhysics"]
path = 3rdparty/JoltPhysics
url = https://github.com/jrouwe/JoltPhysics.git
2 changes: 2 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,5 @@ INSTALL(TARGETS freetype
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)
ADD_SUBDIRECTORY(JoltPhysics/Build EXCLUDE_FROM_ALL)
1 change: 1 addition & 0 deletions 3rdparty/JoltPhysics
Submodule JoltPhysics added at f2d117
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ IF(MSVC)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG> CACHE PATH "")
# Force multiprocessor compilation for all projects
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>>)
# Don't generate a blah.manifest file for each build target.
add_link_options(LINKER:/MANIFEST:NO)
ELSEIF(UNIX)
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ SET(OSP_MAGNUM_DEPS_LIBS
dNewton dScene dModel dVehicle
toml11
spdlog
longeron)
longeron
Jolt)
target_link_libraries(osp-magnum-deps INTERFACE ${OSP_MAGNUM_DEPS_LIBS})
add_dependencies(compile-osp-magnum-deps ${OSP_MAGNUM_DEPS_LIBS})

Expand Down
39 changes: 39 additions & 0 deletions src/ospjolt/activescene/forcefactors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Open Space Program
* Copyright © 2019-2024 Open Space Program Project
Copy link
Member

Choose a reason for hiding this comment

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

Arguably the copyright date for this file only starts in 2024, not 2019.

I'm not a lawyer, so i'm not 100% certain how this should be done.

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 copied some things straight from the forcefactor.h in ospnewton which starts in 2019, but honestly I have no idea either.

*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once

#include <array>
#include <cstdint>

namespace ospjolt
{

// Each rigid body is given 64 bits to enable/disable forces
// These determine which physics calculations are required for a certain
// rigid body, such as gravity, thurst, or aerodynamics.
// Forces are assignable at runtime in ACtxJoltWorld::m_factors
using ForceFactors_t = std::array<uint64_t, 1u>;
Copy link
Member

Choose a reason for hiding this comment

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

Why use an array of size one?

Copy link
Member

Choose a reason for hiding this comment

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

Is this to provide a strong typedef? or is the goal here to generically support any number of items in the array, but start with only 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(not my code, so I can't be 100% sure)
I think the intent is to be able to have a bigger array, so that more than 64 forces can be supported. Currently some things break if the array is bigger though.


}
Loading
Loading