Skip to content

crackx02/Wireframe

Repository files navigation

Wireframe

This DLL mod re-implements the /polygonmode chat command from 0.1.11 Scrap Mechanic and adds a couple physics debug visualization features as well.

Showcase

Pictures say more than a thousand words, so take a look:

First, /polygonmode:

polygonmode1 polygonmode2

Now, physics visualization, such as showing accurate wireframes of the collision mesh...

collision

...Including AreaTrigger hitboxes!

areatrigger

AABB visualization ...

aabb

... Collision contact point visualization and contact counts ...

contacts contactcounts

... and last but not least, character capsule visualization:

capsule

UPDATE 1.2.0: Terrain and static objects visualization!

worldDebug2 worldDebug

How to use

Simply inject the DLL using a DLL injector of your choice.

All features of the mod are controlled through in-game chat commands, which are explained below.
All commands also have in-game descriptions available through the /help command.
Commands prefixed with wf_phys_ are specific to physics-related features.

  • /polygonmode: Switches all rendering between normal and wireframe render mode.
  • /wf_hide: Toggles whether the below chat commands are shown in the command autocomplete or not.
    This is purely visual to reduce chat pollution, the commands still work even if invisible.
  • /wf_phys_setworld [integer]: Scrap Mechanic simulates 4 (four!) physics worlds per one in-game world.
    This command selects which of these worlds to render:
    • 0: Renders TickDynamicsWorld (default, likely the main world).
    • 1: Renders TickRaycastWorld - World used for raycasts in the main tick loop (40 TPS). (?)
    • 2: Renders InterpolatedRaycastWorld - World used for raycasts in the render loop, is interpolated to avoid jitter. (?)
    • 3: Renders PhysicsWorld - Physics world #4, it seems to be empty, not sure what its purpose is.
      Note: The world information above may not be 100% accurate at the time of writing this.
  • /wf_phys_all: Toggles all physics-related features on or off at once.
  • /wf_phys_wireframe: Toggles rendering of physics collision mesh wireframe.
  • /wf_phys_aabb: Toggles rendering of physics object's AABB (bounding box).
  • /wf_phys_contacts: Toggles rendering of collision contact points.
  • /wf_phys_constraints: Toggles rendering of physics constraint(joint) origins.
  • /wf_phys_constraintLimits: Toggles rendering of physics constraint limits.
  • /wf_phys_normals: Toggles rendering of collision mesh normals.
  • /wf_phys_transforms: Toggles rendering of physics object's transforms (axes). Note: Requires wireframe to be enabled!
  • /wf_phys_capsules: Toggles rendering of character capsules. Note: Requires wireframe to be enabled!
  • /wf_phys_renderdistance [number] Sets the physics debug render distance in meters, around the camera.
  • /wf_phys_contactcount: Shows the number of collision contacts that were registered in the previous frame. Note: Requires contact rendering to be enabled!
  • /wf_phys_showHiddenObjects: Toggles rendering of object data for objects that were marked to not render (e.g. terrain cells).

Note: When using /wf_phys_wireframe together with /wf_phys_showHiddenObjects, the game may freeze or lag a bit when moving around the world for the first couple seconds, as the mod has to generate a large amount of debug data in the background. This data is cached and lag will stop after it is generated.

Collision wireframe colors

When collision wireframe rendering is enabled, the wireframe will show different colors.
Here's their meaning:

  • white: An active object, e.g. a dynamic body that is moving around.
  • green: A deactivated(sleeping) object, e.g. a dynamic body that, as a result of not moving, was set to sleep.
  • cyan: An object that is waiting to be set to sleep, but is not actually sleeping just yet.
  • AABBs are always red and collision contact points are always yellow.

Known issues

  • /wf_phys_constraintlimits and wf_phys_normals don't seem to work/render properly.
    Normals are only rendered when available, which currently seems to only be the case for terrain cell meshes (shown with hidden objects enabled).
    Constraint limit rendering seems to be an issue with the game's physics engine implementation. Might be fixed in a future mod update.
  • The visualization jitters when moving around.
    This depends on which physics world is being visualized - see /wf_phys_setworld (tick worlds are not interpolated and will thus jitter).
  • Some collision shapes appear to clip into each other a bit at the edges even when no forces are applied to them.
    The visualization is not 100% accurate.

About

Brings back /polygonmode and adds physics visualization to Scrap Mechanic

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages