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

Add Jolt Physics as an alternative 3D physics engine #99895

Merged
merged 1 commit into from
Dec 11, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ Copyright: 2007, Starbreeze Studios
2007-2014, Juan Linietsky, Ariel Manzur
License: Expat and Zlib

Files: ./modules/jolt_physics/spaces/jolt_temp_allocator.cpp
Comment: Jolt Physics
Copyright: 2021, Jorrit Rouwe
2014-present, Godot Engine contributors
2007-2014, Juan Linietsky, Ariel Manzur
License: Expat

Files: ./modules/lightmapper_rd/lm_compute.glsl
Comment: Joint Non-Local Means (JNLM) denoiser
Copyright: 2020, Manuel Prandini
Expand Down Expand Up @@ -294,6 +301,11 @@ Comment: International Components for Unicode
Copyright: 2016-2024, Unicode, Inc.
License: Unicode

Files: ./thirdparty/jolt_physics/
Comment: Jolt Physics
Copyright: 2021, Jorrit Rouwe
License: Expat

Files: ./thirdparty/jpeg-compressor/
Comment: jpeg-compressor
Copyright: 2012, Rich Geldreich
Expand Down
8 changes: 4 additions & 4 deletions core/os/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
return p_obj;
}

#define memnew(m_class) _post_initialize(new ("") m_class)
#define memnew(m_class) _post_initialize(::new ("") m_class)
mihe marked this conversation as resolved.
Show resolved Hide resolved

#define memnew_allocator(m_class, m_allocator) _post_initialize(new (m_allocator::alloc) m_class)
#define memnew_placement(m_placement, m_class) _post_initialize(new (m_placement) m_class)
#define memnew_allocator(m_class, m_allocator) _post_initialize(::new (m_allocator::alloc) m_class)
#define memnew_placement(m_placement, m_class) _post_initialize(::new (m_placement) m_class)

_ALWAYS_INLINE_ bool predelete_handler(void *) {
return true;
Expand Down Expand Up @@ -189,7 +189,7 @@ T *memnew_arr_template(size_t p_elements) {

/* call operator new */
for (size_t i = 0; i < p_elements; i++) {
new (&elems[i]) T;
::new (&elems[i]) T;
}
}

Expand Down
131 changes: 131 additions & 0 deletions doc/classes/ProjectSettings.xml

Large diffs are not rendered by default.

178 changes: 178 additions & 0 deletions modules/jolt_physics/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *

Import("env")
Import("env_modules")

env_jolt = env_modules.Clone()

# Thirdparty source files

thirdparty_dir = "#thirdparty/jolt_physics/"
thirdparty_sources = [
"Jolt/RegisterTypes.cpp",
"Jolt/AABBTree/AABBTreeBuilder.cpp",
"Jolt/Core/Color.cpp",
"Jolt/Core/Factory.cpp",
"Jolt/Core/IssueReporting.cpp",
"Jolt/Core/JobSystemSingleThreaded.cpp",
"Jolt/Core/JobSystemThreadPool.cpp",
"Jolt/Core/JobSystemWithBarrier.cpp",
"Jolt/Core/LinearCurve.cpp",
"Jolt/Core/Memory.cpp",
"Jolt/Core/Profiler.cpp",
"Jolt/Core/RTTI.cpp",
"Jolt/Core/Semaphore.cpp",
"Jolt/Core/StringTools.cpp",
"Jolt/Core/TickCounter.cpp",
"Jolt/Geometry/ConvexHullBuilder.cpp",
"Jolt/Geometry/ConvexHullBuilder2D.cpp",
"Jolt/Geometry/Indexify.cpp",
"Jolt/Geometry/OrientedBox.cpp",
"Jolt/Math/Vec3.cpp",
"Jolt/ObjectStream/SerializableObject.cpp",
"Jolt/Physics/DeterminismLog.cpp",
"Jolt/Physics/IslandBuilder.cpp",
"Jolt/Physics/LargeIslandSplitter.cpp",
"Jolt/Physics/PhysicsScene.cpp",
"Jolt/Physics/PhysicsSystem.cpp",
"Jolt/Physics/PhysicsUpdateContext.cpp",
"Jolt/Physics/StateRecorderImpl.cpp",
"Jolt/Physics/Body/Body.cpp",
"Jolt/Physics/Body/BodyCreationSettings.cpp",
"Jolt/Physics/Body/BodyInterface.cpp",
"Jolt/Physics/Body/BodyManager.cpp",
"Jolt/Physics/Body/MassProperties.cpp",
"Jolt/Physics/Body/MotionProperties.cpp",
"Jolt/Physics/Character/Character.cpp",
"Jolt/Physics/Character/CharacterBase.cpp",
"Jolt/Physics/Character/CharacterVirtual.cpp",
"Jolt/Physics/Collision/CastConvexVsTriangles.cpp",
"Jolt/Physics/Collision/CastSphereVsTriangles.cpp",
"Jolt/Physics/Collision/CollideConvexVsTriangles.cpp",
"Jolt/Physics/Collision/CollideSphereVsTriangles.cpp",
"Jolt/Physics/Collision/CollisionDispatch.cpp",
"Jolt/Physics/Collision/CollisionGroup.cpp",
"Jolt/Physics/Collision/EstimateCollisionResponse.cpp",
"Jolt/Physics/Collision/GroupFilter.cpp",
"Jolt/Physics/Collision/GroupFilterTable.cpp",
"Jolt/Physics/Collision/ManifoldBetweenTwoFaces.cpp",
"Jolt/Physics/Collision/NarrowPhaseQuery.cpp",
"Jolt/Physics/Collision/NarrowPhaseStats.cpp",
"Jolt/Physics/Collision/PhysicsMaterial.cpp",
"Jolt/Physics/Collision/PhysicsMaterialSimple.cpp",
"Jolt/Physics/Collision/TransformedShape.cpp",
"Jolt/Physics/Collision/BroadPhase/BroadPhase.cpp",
"Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.cpp",
"Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.cpp",
"Jolt/Physics/Collision/BroadPhase/QuadTree.cpp",
"Jolt/Physics/Collision/Shape/BoxShape.cpp",
"Jolt/Physics/Collision/Shape/CapsuleShape.cpp",
"Jolt/Physics/Collision/Shape/CompoundShape.cpp",
"Jolt/Physics/Collision/Shape/ConvexHullShape.cpp",
"Jolt/Physics/Collision/Shape/ConvexShape.cpp",
"Jolt/Physics/Collision/Shape/CylinderShape.cpp",
"Jolt/Physics/Collision/Shape/DecoratedShape.cpp",
"Jolt/Physics/Collision/Shape/EmptyShape.cpp",
"Jolt/Physics/Collision/Shape/HeightFieldShape.cpp",
"Jolt/Physics/Collision/Shape/MeshShape.cpp",
"Jolt/Physics/Collision/Shape/MutableCompoundShape.cpp",
"Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.cpp",
"Jolt/Physics/Collision/Shape/PlaneShape.cpp",
"Jolt/Physics/Collision/Shape/RotatedTranslatedShape.cpp",
"Jolt/Physics/Collision/Shape/ScaledShape.cpp",
"Jolt/Physics/Collision/Shape/Shape.cpp",
"Jolt/Physics/Collision/Shape/SphereShape.cpp",
"Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp",
"Jolt/Physics/Collision/Shape/TaperedCapsuleShape.cpp",
"Jolt/Physics/Collision/Shape/TaperedCylinderShape.cpp",
"Jolt/Physics/Collision/Shape/TriangleShape.cpp",
"Jolt/Physics/Constraints/ConeConstraint.cpp",
"Jolt/Physics/Constraints/Constraint.cpp",
"Jolt/Physics/Constraints/ConstraintManager.cpp",
"Jolt/Physics/Constraints/ContactConstraintManager.cpp",
"Jolt/Physics/Constraints/DistanceConstraint.cpp",
"Jolt/Physics/Constraints/FixedConstraint.cpp",
"Jolt/Physics/Constraints/GearConstraint.cpp",
"Jolt/Physics/Constraints/HingeConstraint.cpp",
"Jolt/Physics/Constraints/MotorSettings.cpp",
"Jolt/Physics/Constraints/PathConstraint.cpp",
"Jolt/Physics/Constraints/PathConstraintPath.cpp",
"Jolt/Physics/Constraints/PathConstraintPathHermite.cpp",
"Jolt/Physics/Constraints/PointConstraint.cpp",
"Jolt/Physics/Constraints/PulleyConstraint.cpp",
"Jolt/Physics/Constraints/RackAndPinionConstraint.cpp",
"Jolt/Physics/Constraints/SixDOFConstraint.cpp",
"Jolt/Physics/Constraints/SliderConstraint.cpp",
"Jolt/Physics/Constraints/SpringSettings.cpp",
"Jolt/Physics/Constraints/SwingTwistConstraint.cpp",
"Jolt/Physics/Constraints/TwoBodyConstraint.cpp",
"Jolt/Physics/Ragdoll/Ragdoll.cpp",
"Jolt/Physics/SoftBody/SoftBodyCreationSettings.cpp",
"Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp",
"Jolt/Physics/SoftBody/SoftBodyShape.cpp",
"Jolt/Physics/SoftBody/SoftBodySharedSettings.cpp",
"Jolt/Physics/Vehicle/MotorcycleController.cpp",
"Jolt/Physics/Vehicle/TrackedVehicleController.cpp",
"Jolt/Physics/Vehicle/VehicleAntiRollBar.cpp",
"Jolt/Physics/Vehicle/VehicleCollisionTester.cpp",
"Jolt/Physics/Vehicle/VehicleConstraint.cpp",
"Jolt/Physics/Vehicle/VehicleController.cpp",
"Jolt/Physics/Vehicle/VehicleDifferential.cpp",
"Jolt/Physics/Vehicle/VehicleEngine.cpp",
"Jolt/Physics/Vehicle/VehicleTrack.cpp",
"Jolt/Physics/Vehicle/VehicleTransmission.cpp",
"Jolt/Physics/Vehicle/Wheel.cpp",
"Jolt/Physics/Vehicle/WheeledVehicleController.cpp",
"Jolt/Renderer/DebugRenderer.cpp",
"Jolt/Renderer/DebugRendererPlayback.cpp",
"Jolt/Renderer/DebugRendererRecorder.cpp",
"Jolt/Renderer/DebugRendererSimple.cpp",
"Jolt/Skeleton/SkeletalAnimation.cpp",
"Jolt/Skeleton/Skeleton.cpp",
"Jolt/Skeleton/SkeletonMapper.cpp",
"Jolt/Skeleton/SkeletonPose.cpp",
"Jolt/TriangleGrouper/TriangleGrouperClosestCentroid.cpp",
"Jolt/TriangleGrouper/TriangleGrouperMorton.cpp",
"Jolt/TriangleSplitter/TriangleSplitter.cpp",
"Jolt/TriangleSplitter/TriangleSplitterBinning.cpp",
"Jolt/TriangleSplitter/TriangleSplitterFixedLeafSize.cpp",
"Jolt/TriangleSplitter/TriangleSplitterLongestAxis.cpp",
"Jolt/TriangleSplitter/TriangleSplitterMean.cpp",
"Jolt/TriangleSplitter/TriangleSplitterMorton.cpp",
]

thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_jolt.Prepend(CPPPATH=[thirdparty_dir])

if env.dev_build:
env_jolt.Append(CPPDEFINES=["JPH_ENABLE_ASSERTS"])
akien-mga marked this conversation as resolved.
Show resolved Hide resolved

if env.editor_build:
env_jolt.Append(CPPDEFINES=["JPH_DEBUG_RENDERER"])

if env["precision"] == "double":
env_jolt.Append(CPPDEFINES=["JPH_DOUBLE_PRECISION"])

env_thirdparty = env_jolt.Clone()
env_thirdparty.disable_warnings()

thirdparty_obj = []
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
env.modules_sources += thirdparty_obj

# Godot source files

module_obj = []

env_jolt.add_source_files(module_obj, "*.cpp")
env_jolt.add_source_files(module_obj, "joints/*.cpp")
env_jolt.add_source_files(module_obj, "misc/*.cpp")
env_jolt.add_source_files(module_obj, "objects/*.cpp")
env_jolt.add_source_files(module_obj, "shapes/*.cpp")
env_jolt.add_source_files(module_obj, "spaces/*.cpp")
env.modules_sources += module_obj

# Needed to force rebuilding the module files when the thirdparty library is updated.
env.Depends(module_obj, thirdparty_obj)
6 changes: 6 additions & 0 deletions modules/jolt_physics/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def can_build(env, platform):
return not env["disable_3d"]


def configure(env):
pass
Loading