|
| 1 | +# UnrealJolt |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +Plugin that brings [Jolt Physics](https://github.com/jrouwe/JoltPhysics) into unreal engine 5 |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Getting Started |
| 10 | + |
| 11 | +### Some things to consider before using this |
| 12 | + |
| 13 | +- This is a bolt on integration and not a replacement for the existing chaos physics solver. |
| 14 | +- You should only need this if you specifically want some kind of behaviour that's not available in chaos. |
| 15 | +- Deterministic physics, multicore processing of many bodies could make the case. |
| 16 | +- Multicore processing it not yet implemented properly using Unreal's own thread pool system. |
| 17 | +- The implementation of this plugin while is generic (somewhat), is still tied to something I am developing on the side. Just keep in mind that all features of UE might not be integrated, you might have to do it yourself. (Drop a PR if you do :) ) |
| 18 | +- There are possibilities of breaking changes, until 1.0.0 at least. (will try to avoid) |
| 19 | + |
| 20 | +### Requirements |
| 21 | + |
| 22 | +- Unreal engine 5 (mostly tested on 5.6.0, should work on older versions) |
| 23 | + |
| 24 | +### Installation |
| 25 | + |
| 26 | +- Clone (`git clone --recursive git@github.com:Yadhu-S/UnrealJolt.git`) or download into the `Plugins` folder (`<project>/Plugins or Engine/Plugins`) |
| 27 | +- Take a look inside `UnrealJoltLibrary.Build.cs` to see the user defines, modify what you need, or leave defaults. Check the available defines [ here ]( https://jrouwe.github.io/JoltPhysicsDocs/5.3.0/md__build__r_e_a_d_m_e.html ) |
| 28 | +- Compile project |
| 29 | +- Make sure UnrealJolt is enabled in "Plugins" |
| 30 | +- Use actor-tag and tag dynamic objects with `jolt-dynamic` (make sure that the object is movable) and static objects with `jolt-static` |
| 31 | + |
| 32 | +### Configuration |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +- Plugins->Jolt in your project settings. |
| 37 | +- Check the defaults, and change if required. |
| 38 | +- Debug rendering is slow, especially when visualizing large heightmaps. Drawing all those triangles. (Need to look into drawing triangles only once for |
| 39 | + static objects ) |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Features |
| 44 | + |
| 45 | +### UJoltSkeletalMeshComponent |
| 46 | +- UJoltSkeletalMeshComponent extends USkeletalMeshComponent to add jolt specific functionality (Browse JoltSkeletalMeshComponent.h to see the available functions) |
| 47 | + |
| 48 | +### Heightmaps |
| 49 | + |
| 50 | +  |
| 51 | + |
| 52 | +- **Landscapes** and **LandscapeSplines** are cooked automatically when you **Play in Editor**. |
| 53 | + - This may be a chore if you work with many levels, playing a level at least one time in editor (will work on it). |
| 54 | +- **Heightmaps must be cooked** in advance. They are not added dynamically like other physics bodies. |
| 55 | +- A `JoltData` directory is always generated during cooking and **must be included when packaging your project**. |
| 56 | +- #### ⚠️ Function for reading landscape spline data is not exposed by default in UE |
| 57 | + |
| 58 | +#### ✅ Enabling Landscape Spline Cooking |
| 59 | +1. `Engine/Source/Runtime/Landscape/Classes/LandscapeSplineSegment.h` |
| 60 | + and add `LANDSCAPE_API` to the `GetLocalMeshComponents()` declaration to fix link errors |
| 61 | +2. In `UnrealJolt/Source/UnrealJolt/UnrealJolt.Build.cs`, uncomment: |
| 62 | + `PublicDefinitions.Add("JOLT_PLUGIN_LANDSCAPE_API_MODIFIED");` |
| 63 | +--- |
| 64 | +## Deterministic simulation |
| 65 | + |
| 66 | +To ensure deterministic simulation with Jolt Physics across platforms, follow the [official guidelines](https://jrouwe.github.io/JoltPhysicsDocs/5.3.0/index.html#deterministic-simulation). Use Jolt’s math and utility functions (`Sin`, `Cos`, `QuickSort`, `BinaryHeapPush/Pop`, `Hash`) instead of STL or platform-dependent ones, and always keep API calls (body/constraint creation, updates) in the same order. |
| 67 | + |
| 68 | +For builds: |
| 69 | + |
| 70 | +- On **Windows (MSVC)**, add `FPSemantics = FPSemanticsMode.Precise;` to `<ProjectName>Target.cs` and `<ProjectName>Editor.Target.cs`. |
| 71 | +- On **Linux (Clang/GCC)**, add `AdditionalCompilerArguments += " -ffp-model=precise -ffp-contract=off";` to the same files. |
| 72 | + |
| 73 | +Because these options differ from Unreal defaults (`LinuxToolChain.cs`, `VCToolChain.cs`), create a custom build config or apply the changes consistently across both game and editor builds by modifying: |
| 74 | +`UnrealClient.Target.cs`, `UnrealEditor.Target.cs`, `UnrealGame.Target.cs`, and `UnrealServer.Target.cs`. |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## Contributing |
| 79 | + |
| 80 | + Found this project useful? Awesome! |
| 81 | + |
| 82 | + If you’ve added a feature, fixed a bug, or improved something that isn’t here yet—feel free to open a PR! |
| 83 | + |
| 84 | +--- |
| 85 | +## Credits |
| 86 | +- [Jorrit Rouwe](https://github.com/jrouwe) for making jolt |
| 87 | +- Andrea Catania for the video series on YouTube |
0 commit comments