Vphysics & Qphysics: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
 
mNo edit summary
Line 1: Line 1:
{{wip}}
{{wip}}
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 [http://en.wikipedia.org/wiki/Rotational_motion#Translation_and_Rotation 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 [http://en.wikipedia.org/wiki/Classical_mechanics Classical Mechanics].
Both systems basically govern (partially or completely) the Motion of Solid World Objects in game by simulating the effects Mechanical Forces upon them.


1. Motion Effects.
1. Mechanical Motion:
* Translational Motion affects $origin (position)
* Translational Motion affects the $origin (position) of the object.
* Rotational Motion affects $angles (orientation)
* Rotational Motion affects the $angles (orientation) of the object.


2. Mechanical Forces:
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.
* Push : eg Collisions, Gravgun Attack1, Explosion, etc.  
* Push : eg Collisions, Gravgun Attack1, Explosion, etc.  
* Pull : eg Constraints, Gravgun Attack2, Gravity, etc.  
* Pull : eg Constraints, Gravgun Attack2, Gravity, etc.  
* Spin : eg VPhys Angular Collisions, [[func_rotating]], [[phys_motor]], [[point_viewcontrol]]
* Spin : eg Angular Collisions, Stability, [[func_rotating]], [[phys_motor]], [[point_viewcontrol]]
 
 
The VPhysics Engine determines [http://en.wikipedia.org/wiki/Rotational_motion#Translation_and_Rotation 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 [http://en.wikipedia.org/wiki/Classical_mechanics Classical Mechanics].


== VPhys Objects ==
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).


VPhys object is a [http://en.wikipedia.org/wiki/Physical_body Physical Body] It is Solid and can Move :
 
== Objects ==
 
 
 
A VPhys object is a [http://en.wikipedia.org/wiki/Physical_body Physical Body] It is Solid and can Move :
* VPhys [http://en.wikipedia.org/wiki/Rigid_bodies Rigid Body] : position ($origin) affected by VPhys Translational Motion ''plus'' orientation ($angles) affected by VPhys Rotational Motion (which requires a Collision Model)
* VPhys [http://en.wikipedia.org/wiki/Rigid_bodies 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 [[$concave]] Rigid Body : = unbreakable (rigid) constraints holding physboxes (bones?) together?
Line 28: Line 31:
{{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}}
{{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}}


Non-VPhys Objects may also be Solid and may also Move:
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!)
* Particle Objects : Source Particle Motion appears to be scripted? See [[info_particle_system]]. (Brownian motion & Fluid Dynamics are not simulated!)
* Hull Objects : (see below)
* Hull Objects : (see below)
Line 35: Line 38:
** Bullets are also Ray-traced. Some surfaces (eg Grates) are NotSolid to Bullets. Their Range is determined by ... ?
** 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
  Projectile Gravity Deflection Impact Damage Mechanics NPC Push
  LOS test no no none Ray no
  LOS test no no none Ray no
  bullet no no skill.cfg Ray no?
  bullet no no skill.cfg Ray no?
Line 55: Line 58:


== QPhysics Interactions ==
== 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 ?  
* What about [[Player Hull]], [[NPC Hull]], etc Physics ?  
* Hull Translation and Rotation Motion : controlled by PlayerInput/AI/IO/WeaponScript/etc ...
* QPhys Translation and Rotation Motion : controlled by PlayerInput/AI/IO/WeaponScript/etc ...
* Hull Trajectory : eg Jump Trajectory. Alternative, separate Gravity system to VPhys?
* QPhys 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?  
* 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?  
* Hull Impact Damage : Fall Damage to Player? Impact Damage to breakable object?
* 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]]).
* '''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 :  
* QPhys Friction :  
: Mud material reduces Player movements through it's own mechanism, not VPhys.
: Mud material reduces Player movements through it's own mechanism, not VPhys.


* Hull Push Entity (eg [[trigger_push]])
* QPhys Push Entity (eg [[trigger_push]])
* Hull Pull Entity (eg [[point_playermoveconstraint]])
* QPhys Pull Entity (eg [[point_playermoveconstraint]])
* Hull Spin Entity (eg [[point_viewcontrol]]? [[func_rotating]]?
* QPhys Spin Entity (eg [[point_viewcontrol]]? [[func_rotating]]?
: What about Animated Brushes: func_door, func_rotating ... can they be blocked by a Hull? they use Hull Collision?
: What about Animated Brushes: func_door, func_rotating ... can they be blocked by a Hull? they use Hull Collision?


Line 88: Line 89:
: For Rotational VPhys. (This might be translated into tetrahedra: Triangles relative to $CofMass?)
: For Rotational VPhys. (This might be translated into tetrahedra: Triangles relative to $CofMass?)
* Volume calculated from CollisionModel or simply a keyvalue (maybe $density) ?
* Volume calculated from CollisionModel or simply a keyvalue (maybe $density) ?
=== VPhys Constraint Properties ===
{{todo|?}}


== VPhys Forces ==
== VPhys Forces ==
Line 105: Line 102:
* VPhys Spin eg [[phys_motor]]
* VPhys Spin eg [[phys_motor]]


== VPhys interaction calculations ==
== VPhys Interactions==


=== Translational Events ===
=== Translational Events ===
Line 129: Line 126:
== Damage Events ==
== Damage Events ==
? not sure this is really part of VPhys at all.
? not sure this is really part of VPhys at all.
==References==
* [[Physics and Ragdolls]]
* [[CollisionProperty]]
* [[VPhysics]]

Revision as of 17:37, 16 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.

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.