IPhysicsObject

From Valve Developer Community
Revision as of 08:55, 22 June 2011 by TomEdwards (talk | contribs)
Jump to navigation Jump to search

IPhysicsObject is the basic representation of a rigid VPhysics object. It can be accessed with CBaseEntity::VPhysicsGetObject().

Member functions

Properties

SetMass()
SetInertia()
Overrides this object's mass/inertia.
Todo: Units
SetDamping()
Confirm:Sets rotation damping (how fast the object stops spinning)
SetDragCoefficient()
Set friction.
Todo: Units
SetBuoyancyRatio()
Sets buoyancy
Todo: "Ratio"?

Forces

ApplyForceCenter()
ApplyForceOffset()
Applies inches/s force.
ApplyTorqueCenter()
Applies degrees/s rotation.
AddVelocity()
SetVelocity()
SetVelocityInstantaneous()
Adds or sets velocity in a physically incorrect way that affects the object regardless of its current mass/inertia.
SetPosition()
SetPositionMatrix()
Teleports the object to a new location.
Todo: Impact of teleporting an object short distances every frame vs. letting it find its own way.

Multiple IPhysicsObjects

An entity can represent up to 1024 IPhysicsObjects. This happens in Valve's code with vehicle wheels and whenever a model has $collisionjoints.

Note.pngNote:Avoid simulating completely separate physics objects with one entity. Although VPhysics doesn't care one way or the other, game systems which use bounding boxes will become very inefficient should the objects become far apart. You will also encounter problems with velocity calculations when the "main" object is moving but others aren't (or vice versa). It's probably possible to work around all of these issues with the mod SDK, but only after a lot of work!

See multi_phys for an example entity that performs all of the jobs needed for multiple IPhysicsObjects.