Vphysics & Qphysics

From Valve Developer Community
Revision as of 00:06, 17 April 2008 by Beeswax (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Intended Audiences:

  • Level Design : predicting Collision (Push) & Constraint (Pull) interactions of Moving Objects.
  • Level Design : choice of Entity to use, eg phys_motor or func_rotating?
  • Modelling : configuring QCs for prop_physics, prop_static, prop_dynamic.
  • Modelling : building Boundingbox, Collisionmodel / Ragdoll, Hitboxes, etc (Anatomy of a Model)
  • Modding : Understanding Source Code concepts and variables.

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.

1. Motion Effects.

  • Translational Motion affects $origin (position)
  • Rotational Motion affects $angles (orientation)

2. Mechanical Forces:

VPhys Objects

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.

To do: 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

Non-VPhys 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: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

Not knowing if there is a real name for this, I have dubbed it QPhysics ("Quake Physics" - because I guess this is where it comes from). QPhys is not nearly as sophisticated as VPhys, but 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).

  • What about Player Hull, NPC Hull, etc Physics ?
  • Hull Translation and Rotation Motion : controlled by PlayerInput/AI/IO/WeaponScript/etc ...
  • Hull Trajectory : eg Jump Trajectory. Alternative, separate Gravity system to VPhys?
  • Hull Deflection : Static Solids cause Hulls to simply stop moving. Deflection/Ricochet/Knock-Back (Newton's reciprocal Push force) is not simulated. But Sliding Friction?
  • Hull 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).
  • Hull 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 Constraint Properties

To do: ?

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 interaction calculations

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.