Standalone plugin to switch physics engines at runtime, particularly on a per-map basis. Compatible with Windows and Linux on listen servers and dedicated servers. Only tested on Team Fortress 2.
The following physics engines are supported:
- Havok (
vphysics
) (Default) - Jolt (aka Volt) (
vphysics_jolt
) - Bullet (
vphysics_bullet
) NOT TESTED!
The plugin checks for the existence of a maps/<MAP NAME>_physics.cfg
file on disk or packed inside the BSP. Inside the file should be a single line of text stating which physics engine to use, for example jolt
. If the file exists, the physics engine will be swapped to the one stated. Otherwise, it is reverted to the default physics engine (Havok) if a different engine was set before, unless overriden by phys_override
.
The physics engine can also be overriden permanently using the phys_override <name>
command, though it can be reverted back to Havok afterwards. This command is admin-restricted and will only work while a map is active.
A convar named phys_engine
is exposed, which stores the current physics engine name. VScript can query this convar using Convars.GetStr("phys_engine")
. It can also be used to test if the plugin is loaded, if it returns null
the plugin is not loaded.
If experiencing crashes or issues, the phys_swap_debug
convar can be set to 1 to enable debug messages when swapping physics engines.
Currently, physics engines will only be swapped between level changes.
- In the game directiory (example:
Team Fortress 2/tf/...
), create a folder namedaddons
if it doesn't exist already. - Download the latest build. Volt binaries are included in the release.
- Extract the 'sourcemod' folder to the addons folder (i.e
addons/sourcemod/...
) - If SourceMod is installed: you don't need to do anything else. NOTE: The physics engine will not be swapped on first map load as SourceMod loads extensions too late. To workaround this, switch to another map after the first map is loaded.
- If SourceMod is NOT installed, download the PhysSwapper.vdf file and put it inside the addons folder. Done! SourceMod is not required for this plugin to work.
To load this plugin locally, you must launch the game with the '-insecure' launch option. Note that you cannot join online servers when this option is active, but other players can join you. Therefore to disable this plugin, simply remove the '-insecure' launch option.
Although the plugin is standalone, it is built ontop of the SourceMod repository for convenience.
- Follow instructions to build SourceMod successfully
- Clone the repository into the
alliedmodders/sourcemod/public/PhysSwapper
folder - Modify the hl2sdk for the game you will build for. This plugin requires accessing private variables in a certain class, so a change is required to make those public. The file is
public/appframework/IAppSystemGroup.h
. In theCAppSystemGroup
class, add apublic:
line before thestruct Module_t
definition. - Create a folder inside named 'build'. Configure the build first with
python ../configure.py
(might bepython3
on some systems) - Run the
ambuild
command. It should now build successfully. - To build Volt, follow the guide on their repo. To build VPhysics-Bullet, follow the guide here.
- Rename the physics binary to the naming convention listed at the top of this README, e.g.
vphysics_jolt
. Note that Volt has different SIMD modules for more CPU support, do not rename those. Only rename the mainvphysics
binary. It may be useful to modify the VPC$OUTBIN
to do this automatically. - LINUX ONLY: The rpath in the physics engine binaries must be patched to load dependencies relative to the game's bin folder instead. This can be done by installing the
patchelf
package and then running the PhysSwapper_linux_fix_rpath.sh batch script from this repository. Alternatively in GCC/Clang, the rpath can also be set using the-rpath
parameter, see the script for which path to use.
- Joshua Ashton (🐸✨) (
@phys_ballsocket
) and Josh Dowell (@Slartibarty
) for making Volt ozxybox
for the SpeedyKeyV parser (modified)