Vphysics & Qphysics: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
Line 66: Line 66:
* Solid Model : Physics interaction simulation system used.
* 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?  
* 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: {{physicsmode_choices}}


* {{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.}}
* {{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.}}

Revision as of 17:29, 17 April 2008

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.

Mechanics of Motion

Source uses four methods to simulate the effects Mechanical Forces on the Motion of World Objects in game:

  1. Particle-simulated objects : Source Particle Motion appears to be scripted? See info_particle_system. Particles are never Solid
    Todo: confirm
    .
  2. 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 ... ?
  3. 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.
  4. 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.
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.

Basic Concepts

  • Translational Motion affects the $origin (position) of the object.
  • Rotational Motion affects the $angles (orientation) of the object.
  • Push Force attempts to push the object away from its source (translation) eg Collisions, Gravgun Attack1, Explosion, etc.
  • Pull Force attempts to pull the object towards its source (translation): eg Constraints, Gravgun Attack2, Gravity, etc.
  • Spin Force attempts to push/pull the object so it rotates (rotational): eg Angular Collisions, Stability, func_rotating, phys_motor, point_viewcontrol

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.

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.

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)
  • 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 ?
  • 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.

QPhysics Interactions

  • Hull Translation and Rotation Motion : controlled by PlayerInput/AI/IO/WeaponScript/etc ...
  • Hull Gravity: 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.
  • 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.
  • 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).

Collision Event

  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

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?)
For Rotational VPhys.
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