GithubHelp home page GithubHelp logo

ficool2 / physswapper Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 1.0 39 KB

Standalone Source plugin to switch physics engines at runtime

License: GNU General Public License v3.0

Python 25.64% Shell 0.48% C++ 66.21% C 7.67%

physswapper's Introduction

PhysSwapper

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:

Usage

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.

Installation

  1. In the game directiory (example: Team Fortress 2/tf/...), create a folder named addons if it doesn't exist already.
  2. Download the latest build. Volt binaries are included in the release.
  3. Extract the 'sourcemod' folder to the addons folder (i.e addons/sourcemod/...)
  4. 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.
  5. 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.

Non-dedicated servers

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.

Build

Although the plugin is standalone, it is built ontop of the SourceMod repository for convenience.

  1. Follow instructions to build SourceMod successfully
  2. Clone the repository into the alliedmodders/sourcemod/public/PhysSwapper folder
  3. 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 the CAppSystemGroup class, add a public: line before the struct Module_t definition.
  4. Create a folder inside named 'build'. Configure the build first with python ../configure.py (might be python3 on some systems)
  5. Run the ambuild command. It should now build successfully.
  6. To build Volt, follow the guide on their repo. To build VPhysics-Bullet, follow the guide here.
  7. 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 main vphysics binary. It may be useful to modify the VPC $OUTBIN to do this automatically.
  8. 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.

Credits

  • Joshua Ashton (🐸✨) (@phys_ballsocket) and Josh Dowell (@Slartibarty) for making Volt
  • ozxybox for the SpeedyKeyV parser (modified)

physswapper's People

Contributors

ficool2 avatar

Stargazers

Nuno Carvalho avatar IBRS avatar  avatar  avatar  avatar Menoly avatar  avatar Sandust60 avatar  avatar koutsie avatar Jared Ketterer avatar sappho avatar Drew Edwards avatar Keith avatar jmar avatar  avatar  avatar  avatar Nopied◎ avatar Noodles avatar Artyom avatar sjain avatar  avatar ReplayCoding avatar Rafael Ristovski avatar Nicholas Hastings avatar Joacoco avatar

Watchers

Nicholas Hastings avatar  avatar Joacoco avatar

Forkers

pmarkive

physswapper's Issues

Failed to load `vphysics_jolt` for unknown reason.

[PhysSwapper] Swapping physics engine to Jolt...
[PhysSwapper] DBG: Fetching original vphysics interface
[PhysSwapper] DBG: Setting working directory
[PhysSwapper] DBG: Loading vphysics_jolt
[PhysSwapper] Failed to load vphysics_jolt

OS: Ubuntu 18.04 LTS
vphysics_jolt.so and other files have rwxrwxr-x permission.
It's in addons/sourcemod/extensions/bin/vphysics_jolt.so so path would be correct even if it's hardcoded to search.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.