Vphysics & Qphysics

From Valve Developer Community
Revision as of 17:37, 16 April 2008 by Beeswax (talk | contribs)
Jump to navigation Jump to search
Under construction.png
This page is actively undergoing a major edit.
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.

Both systems basically govern (partially or completely) the Motion of Solid World Objects in game by simulating the effects Mechanical Forces upon them.

1. Mechanical Motion:

  • Translational Motion affects the $origin (position) of the object.
  • Rotational Motion affects the $angles (orientation) of the object.

2. Mechanical Forces: Traditionally there are only the first two, but because Translational and Rotational Motion are handled quite differently by each system, I've added "Spin" which is can be a Push, Pull or Both that applies a Rotational Force to the object.


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.

Not knowing if there is a real name for this, I have dubbed all the non-VPhysics simulation stuff "QPhysics" ( for "Quake Physics" - because I guess this is where it comes from). QPhys is not nearly as sophisticated as VPhys, but equally important as it is used to determine the Motion of all Hull-simulated NPCs and Players, several types of projectile and a number of Moving Brush Entities (eg func_door, etc).


Objects

A VPhys object is a Physical Body It is Solid and can Move :

  • 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.
Todo: what is the correct term for a single piece of convex geometry within a concave or jointed collision model? a PhysBox? a PhysBone? ... some $bones in a Ragdoll may be NotSolid to Collision

A QPhys Objects may also be Solid and may also Move:

  • Particle Objects : Source Particle Motion appears to be scripted? See info_particle_system. (Brownian motion & Fluid Dynamics are not simulated!)
  • Hull Objects : (see below)
  • Ray Objects : travel at infinite speed and are very small, so they are simulated as simple. but accurate, straight-line ray-traces, or Vectors, having direction and range.
    • LOS tests are raytraced to 2048 units (or more - See NPC_Sensing) if not blocked by an opaque surface (eg normal Solid surface is NOTSolid to LOS) or env_fog_controller limited visibility.
    • Bullets are also Ray-traced. Some surfaces (eg Grates) are NotSolid to Bullets. Their Range is determined by ... ?
Projectile	Gravity 	Deflection	Impact Damage	Mechanics	NPC Push
LOS test	no		no		none		Ray		no
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		? 		Hull		yes
grenade-frag	VPhys		VPhys		?		VPhys		yes?
grenade-AR2	no ?		VPhys		?		VPhys		yes?
gravgun-prop	VPhys		VPhys		?		VPhys		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)
  • Impact Damage : Excluding explosion damage (defined in skill.cfg). Presumambly derived from Projectile's Momentum (kinetic energy). VPhys calculated or look-up table ?
  • Mechanics : Physics interaction simulation system used.
Note.pngNote:Gravgun Test: Gravgun can only Push/Pull VPhys Objects (if mass and range are < ?). It cannot Push/Pull Ray- or Hull-objects. However, Gravgun Push can cause Damage to NPCs.
  • NPC Push : All projectiles (except LOS test) will Push VPhys Objects (eg ragdolls), but can they affect (stop/slow/deflect) an NPC's 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?


QPhysics Interactions

  • What about Player Hull, NPC Hull, etc Physics ?
  • QPhys Translation and Rotation Motion : controlled by PlayerInput/AI/IO/WeaponScript/etc ...
  • QPhys Trajectory : eg Jump Trajectory. Alternative, separate Gravity system to VPhys?
  • QPhys Deflection : Static Solids cause Hulls to simply stop moving. Deflection/Ricochet/Knock-Back (Newton's reciprocal Push force) is not simulated. But Sliding Friction?
  • QPhys Impact Damage : Fall Damage to Player? Impact Damage to breakable object?
  • 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).
  • QPhys Friction :
Mud material reduces Player movements through it's own mechanism, not VPhys.
What about Animated Brushes: func_door, func_rotating ... can they be blocked by a Hull? they use Hull Collision?
  • {{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.


VPhys Object Properties

Sliding Friction is a 2-material interaction ... lookup table in Material System?
Is Static Friction simulated in VPhys ?
For Inertia & Momentum in both Rotational and Translational VPhys.
For Rotational VPhys.
  • Collision Model (=IPhysicsObject?)(= set of coords relative to $origin: (?), eg "16 16 72 1")
defined by physbox.mdl or brush vertices.
For Rotational VPhys. (This might be translated into tetrahedra: Triangles relative to $CofMass?)
  • Volume calculated from CollisionModel or simply a keyvalue (maybe $density) ?

VPhys Forces

  • World VPhys Properties (ie Constant values applicable to all VPhys Objects)
  • Impact Damage (to both colliding objects)
  • VPhys Push
  • VPhys Pull
  • VPhys Spin eg phys_motor

VPhys Interactions

Translational Events

Rotational Events

  • Settling (Gravity induces Rotational Motion about the CofMass until CollModel provides stable support)
  • Torque (rotational inertia)

Collision Events

1. Collision Detection - (see CollisionProperty]]) (occurs before VPhys simulation) 2. Calculate (Angular) Force of Impact (on both objects) 3. Deformation (does either object bend or break?) (can the other object move?) 4. Rotational Deflection (CollisionModel settles under object's CofMomentum) 5. Translational Deflection (resulting CofMomentum becomes Translational Motion) 6. Translational Motion (Gravity deforms Trajectory) 7. Next Collision Detection

Damage Events

? not sure this is really part of VPhys at all.