Vphysics & Qphysics

As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.
The person who added this notice will be listed in its edit history should you wish to contact them.
Mechanics of Motion
Source uses four methods to simulate the effects Mechanical Forces on the Motion of World Objects in game:
- Particle-simulated objects : Source Particle Motion appears to be scripted? See info_particle_system. Particles are never Solid Todo: confirm.
- Ray-simulated objects : very small objects travelling at infinite speed are simulated as simple but accurate, straight-line ray-traces. They are not treated as Solid, until they hit a Solid Object.
- LOS tests are raytraced until blocked by an opaque surface (eg normal Solid surface is Solid to LOS). Range is also restricted to 2048 units (or more - see NPC_Sensing) and affected by env_fog_controller limited visibility.
- Bullets are also Ray-traced. Some surfaces (eg Grates) are NotSolid to Bullets. Their Range is determined by ... ?
- Hull-simulated objects : have simple, Solid Collision boxes which are moved by a controlling intelligence (or script), and only restricted by simple QPhys collisions and QPhys gravity.
- VPhysics-simulated objects are either Rigid or Deformable :
- VPhys Rigid Body : position ($origin) affected by VPhys Translational Motion plus orientation ($angles) affected by VPhys Rotational Motion (which requires a Collision Model)
- VPhys $concave Rigid Body : = unbreakable (rigid) constraints holding physboxes (bones?) together?
- VPhys Deformable Body is a constrained system of Rigid Bodies:
- VPhys Ragdoll object made of bones?: joints = (flexible) contraints allowing limited articulation by external forces.
- VPhys(?) Breakable object made of gibs: health = (rigid) constraints holding gibs together, damage = external force.
- VPhys Rigid Body : position ($origin) affected by VPhys Translational Motion plus orientation ($angles) affected by VPhys Rotational Motion (which requires a Collision Model)
Basic Concepts
- Linear Force affects the $origin (position) of the object in the World (induces Translational Motion).
- Angular Force affects the $angles (orientation) of the object in the World (induces Rotational Motion).
- Torque attempts to rotate or spin the object about its own Center of Mass: eg Angular Deflection, Stability, func_rotating, phys_motor, point_viewcontrol
- Mass of an object is its Inertial Mass] ie its resistance to acceleration.
- Mass appears to have negligible affect on Torque, but Center of Mass is very important.
- world constant : Water = 1kg/liter = 28.3 kg/cubic foot (= 6.9 g/unit3?)
- Velocity
- Gravity = acceleration = 9.81 m/sec2 (= 32 ft/sec2 = 21.9 mph/sec)
- Sliding Friction at the object's surface(s). Pressure (eg weight) * Friction Coefficient:
- Friction Coefficient is specific to each combination of surfaces; eg Rubber & Wood, Metal & Wood, Rubber & Metal, Rubber & Rubber, ... look-up table in Materials System ?
- Surface area is not a factor because total pressure is distributed over whatever contact area.
- Fluid Friction, eg Aerodynamics, Hydrodynamics, etc is simply represented by the entity's "max speed" for flying, running, swimming, falling, etc.
- Air Density = 0, Friction = 0 (negligible) : Terminal Velocity = worldconstant = 3500 units/sec (66.7 m/s)
- Water Density = 1 kg/l, Friction = ?
VPhysics & QPhysics
The VPhysics Engine determines Translational Motion and Rotational Motion of VPhys Objects resulting from the interaction of various (simulated) VPhys Forces. It is a kind of Procedural Animation Engine designed to simulate Classical Mechanics.
Hull simulated mechanics (dubbed "QPhysics" for "Quake Physics" - because I guess this is where it comes from) is not nearly as sophisticated as VPhys, but equally important as it is used in determining the Motion of all Hull-simulated NPCs and Players, several types of projectile and a number of Moving Brush Entities (eg func_door, etc).
The biggest difference is that VPhysics determines completely the Translational and Rotational Motion of Vphys objects, whereas QPhysics merely implements a few simple restrictions on objects which are primarily controlled by either Player Input, NPC AI, an I/O script, Scripted Sequence, Entity Script, etc, etc.

Projectiles
- A VPhys object can be Pushed or Damaged by anything (solid) that hits it - Bullet, Hull, or VPhys object.
- A Bullet (ray) is so small and fast that nothing can Push or Damage it.
- All explosions push and damage VPhys objects. Hulls may be damaged.
Projectile Gravity Deflection Impact Damage Solid Model NPC Push bullet no no skill.cfg Ray no? grenade-SMG yes no (explode) no? Hull? no? crossbow bolt yes no (impale) skill.cfg Hull? no rocket no no (explode) no? Hull no? NPC/Player yes no no? Hull yes grenade-frag VPhys VPhys yes? VPhys yes? grenade-AR2 no ? VPhys yes? VPhys yes? gravgun-prop VPhys VPhys yes? VPhys yes? explosion no no no VPhys no func_door no no? crush? Hull? yes?
- Gravity : Will Gravity affect its Trajectory (Translational Motion).
- Deflection : Will it bounce/ricochet off a solid object rather than simply stopping ? (Translational & Rotational Motion)
- Solidity = surface CollisionProperty = boolean
- Impact Damage : Will it inflict damage on collision (excluding explosion damage defined in skill.cfg).
- Presumambly derived from Projectile's Momentum (kinetic energy): calculated or look-up table ?
- Constraint is a static pull force; it resists movement away. ?
- Impact Damage Table suggests vphys object mass is classed ("tiny, small, medium and large") relative to "Player, Player in Vehicle, NPC or Glass". Damage clamps & multipliers are specified for some classes, but the basic calculation ... ?
- Prop Data#Damage Modifiers for "bullet, club, explosive" are only applied to breakable-props.
- why should glass use a damage_table plus prop_data dam-mods ?
- Solid Model : Physics interaction simulation system used.
- NPC Push : Some collisions seem to affect (stop/slow/deflect) an NPC's Hull Momentum? Isn't there something like this in DOD? Hull Motion seems to be entirely immune to external (VPhys) forces unless specifically scripted otherwise - eg Combine_Soldier melee attack: Push back player ?. What about Rocket Jumping in TF2?
- Something to do with vphys-prop's physicsmode:
Number | Name | Description |
---|---|---|
1 | Solid, Server-side | Solid, pushes the player away. |
2 | Non-Solid, Server-side | Non-solid, but gets pushed away by the player. |
3 | Non-Solid, Client-side | Non-solid, clientside simulated only. |
- Todo: Are Collision Hulls really boxes? They seem to behave more like Cylinders in game. Eg A Player should not be able to walk diagonally (W+A) along a 34 unit passageway, as the diagonal dimension of his 32x32 Hull would be 45 units. For that matter, he would not be able to rotate (much) either. Cylinders don't have corners to catch on things and cause rotational deflection. The test would be an octagonal hole ...
Hull QPhysics Interactions
- Hull Translation and Rotation Motion : controlled by PlayerInput/AI/IO/WeaponScript/etc ...
- nb: dynamic light, turret & camera entities can track a moving target<target_destination>.
- Hull Gravity: eg Jump Trajectory. Alternative, separate Gravity system to VPhys ... ?
- Hull Linear Deflection : Static Solids cause Hulls to simply stop moving. Deflection/Ricochet/Knock-Back is not simulated.
- Hull Angular Deflection : vectors striking a hitbox but not passing through the CofMass do not induce rotation. Not simulated.
- Hull Friction : There is definitely some kind of Player Hull friction simulation going on in 33 unit passageways.
- Mud material reduces Player movements through it's own mechanism, not VPhys.
- Hull Impact Damage : Fall Damage to Player/NPC. Impact Damage to breakable object he lands on.... Impact Damage Tables.
- Physics Shadow: "If Players don't have a physics shadow they can't move objects just by touching them; they have to press USE to apply a pushing force" (from Alternate Multiplayer Physics).
- compare physicsmode_choices per prop_phys_mp : "Solid, pushes player away" vs "Non-solid, but gets pushed away by the player".
Collision Event
- Collision Detection - if projectile touches target's Bounding Box :
- If projectile = bullet, test against target's Hitbox and then CollisionProperty
- If projectile = Hull or VPhys, test against target's CollisionModel ?
- Calculate Angular Force of Impact on both objects; ie
- projectile's movement vector in relation to center of mass of target
- projectile's movement vector in relation to center of mass of projectile
- Projectile Momentum absorbed by / transferred to:
- damage to target
- damage to projectile
- angular deflection (spin force) on target (unless t = Hull)
- angular deflection (spin force) on projectile (unless p = Hull)
- linear deflection (push vector) on target
- linear deflection (bounce vector) on projectile (unless p = Hull)
Mechanical Properties & Interactions
- For Inertia & Momentum in both Rotational and Translational VPhys.
- Volume calculated from CollisionModel
- For $automass)
- Buoyancy in Water = Density = mass/volume ... or keyvalue ?
- Collision Model (=IPhysicsObject?)(= set of coords relative to $origin)
- defined by physbox.mdl or brush vertices.
- For Rotational VPhys. (This might be translated into tetrahedra: Triangles relative to $CofMass?)
- Center of Mass (CofMass) (= coords relative to $origin: "0 0 0 1")
- For Rotational VPhys.
- Center of Momentum (vector: CofMass * external forces)
- Coefficient of Friction (scale applied to CofMomentum?)
- Sliding Friction is a 2-material interaction ... lookup table in Material System?
- Is Static Friction simulated in VPhys ?
- Settling / Stability
- Gravity induces Rotational Motion about the CofMass until CollModel (Fulcrum) provides stable support.
- Impact Damage (to both colliding objects)
Force Entities
- QPhys Push Entity (eg trigger_push)
- QPhys Pull Entity (eg point_playermoveconstraint)
- QPhys Spin Entity (eg ... rather difficult ... point_viewcontrol func_door (use Hull Collision?)
- VPhys Push Entity (eg phys_thruster)
- VPhys Pull Entity (eg phys_constraint)
- VPhys Spin Entity (eg phys_motor, phys_thruster with torque, )