Physics optimization: Difference between revisions
m (cats) |
m (Fixed first phrase) |
||
(7 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
It's a | It's rare to have a map without any [[VPhysics|physically-simulated objects]]. How can we keep the performance costs of all these items under control? | ||
== Spawnflags == | == Spawnflags == | ||
These [[ | These [[Flag#Flags_in_Hammer|spawnflags]] apply to {{ent|prop_physics}}, and some to {{ent|prop_ragdoll}}. | ||
;Start | ;Start Asleep | ||
:Suspends all physics calculations until the entity has a force of some sort exerted on it. Its primary use is to avoid the first moments of a map being a slideshow as all of the objects in it 'settle'. | :Suspends all physics calculations until the entity has a force of some sort exerted on it (other than gravity and buoyancy). Its primary use is to avoid the first moments of a map being a slideshow as all of the objects in it 'settle'. | ||
:But of course you ''do'' want that settling to happen, or else objects will be suspended in the wrong position. You can escape this catch-22 with the <code>[[map_edit]]</code> command. | :But of course you ''do'' want that settling to happen, or else objects will be suspended in the wrong position. You can escape this catch-22 with the <code>[[map_edit]]</code> command or {{hammer++|2}}'s physics simulation tool. | ||
;Debris | ;Debris | ||
:Debris objects don't collide with anything but [[brush]]es, vastly reducing their [[cost]]. They can optionally be 'ploughed through' by the local player with | :Debris objects don't collide with anything but [[brush]]es, vastly reducing their [[cost]]. They can optionally be 'ploughed through' by the local player with {{cmd|cl_pushaway_force}}. | ||
:{{ | :{{note|It can get fiddly to set lots of tiny items as debris. Perhaps a programmer could write some code to automatically do so for models under a certain size when the map spawns?}} | ||
;Motion Disabled | ;Motion Disabled | ||
:Does exactly what its name suggests. Unlike sleeping, it can be (and is only) affected with the <code>EnableMotion</code> and <code>DisableMotion</code> [[input]]s. | :Does exactly what its name suggests. Unlike sleeping, it can be (and is only) affected with the <code>EnableMotion</code> and <code>DisableMotion</code> [[input]]s. | ||
Line 22: | Line 20: | ||
== Network performance == | == Network performance == | ||
The amount of network data physics objects create can become an issue in multiplayer. To help with this, use <code>[[prop_physics_multiplayer]]</code> (In [[Half-Life 2: Deathmatch]] maps use prop_physics or | The amount of network data physics objects create can become an issue in multiplayer. To help with this, use <code>[[prop_physics_multiplayer]]</code> (In [[Half-Life 2: Deathmatch]] maps use prop_physics or {{ent|prop_physics_respawnable}}, using {{ent|prop_physics_multiplayer}} highly not recommended); it simplifies collision models for complex entities to reduce bandwidth, and makes everything a little bit bouncier to try and hide latency paradoxes. | ||
It also automatically makes smaller objects client-side, which can be overridden with the 'Force server-side' spawnflag if needed. | It also automatically makes smaller objects client-side, which can be overridden with the 'Force server-side' spawnflag if needed. |
Latest revision as of 10:00, 25 July 2025
It's rare to have a map without any physically-simulated objects. How can we keep the performance costs of all these items under control?
Spawnflags
These spawnflags apply to prop_physics, and some to prop_ragdoll.
- Start Asleep
- Suspends all physics calculations until the entity has a force of some sort exerted on it (other than gravity and buoyancy). Its primary use is to avoid the first moments of a map being a slideshow as all of the objects in it 'settle'.
- But of course you do want that settling to happen, or else objects will be suspended in the wrong position. You can escape this catch-22 with the
map_edit
command orHammer++'s physics simulation tool.
- Debris
- Debris objects don't collide with anything but brushes, vastly reducing their cost. They can optionally be 'ploughed through' by the local player with cl_pushaway_force.
Note:It can get fiddly to set lots of tiny items as debris. Perhaps a programmer could write some code to automatically do so for models under a certain size when the map spawns?
- Motion Disabled
- Does exactly what its name suggests. Unlike sleeping, it can be (and is only) affected with the
EnableMotion
andDisableMotion
inputs.
phys_constraintsystem
This entity manages a group of interacting physics constraints to reduce processing overhead and keep them more stable. Just link the entities to it and the engine will do the rest.
Network performance
The amount of network data physics objects create can become an issue in multiplayer. To help with this, use prop_physics_multiplayer
(In Half-Life 2: Deathmatch maps use prop_physics or prop_physics_respawnable, using prop_physics_multiplayer highly not recommended); it simplifies collision models for complex entities to reduce bandwidth, and makes everything a little bit bouncier to try and hide latency paradoxes.
It also automatically makes smaller objects client-side, which can be overridden with the 'Force server-side' spawnflag if needed.
