IPhysicsObject is the basic representation of a rigid VPhysics object. It is shared between the server, client and VPhysics libraries.
Getting and setting
- If you just want to create a physics object for your entity's model, use a
- An entity's main physics object can be accessed with
CBaseEntity::VPhysicsGetObject(), while a list of all its objects is returned by
IPhysicsObjects can be created with the
physenv->Create*()functions, or with the global
PhysModelCreate*()helpers.Note:Remember to call
physenv->DestroyObject()when you no longer need these.
- To improve performance physics objects will go to sleep after a second or so of inactivity. They will be woken by interaction with another object, but not by changes to their own internal state. If you change a simulation property of the object and want it to respond immediately, make sure that you
- Gets this object's
CPhysCollide(the actual geometry it represents).
- Confirm:The object stops colliding with other objects, but still triggers
- Various simulation features that can be enabled or disabled per-object.
- Overrides this object's mass (in kilos) and inertia (To do: units; it's a vector).
- Confirm:Sets rotation damping (how fast the object stops spinning)
- Set friction. To do: Units
- Sets how much upward force is exerted on the object (relative to its mass) whenever it is in water. 0 means that the object sinks, while >1 results in the object bouncing off the surface with increasing violence.
- Source does not simulate water pressure, so genuine buoyancy is not possible.
- Applies a inch per second per kilogram force relative to the world. If you specify an offset the force comes from a specific location, otherwise it applies evenly across the whole object.
- Applies a degrees per second per kilogram ([confirm]) rotation relative to the world.
- Adds or sets velocity (inch/s) and torque (degrees/s) in a physically incorrect way that affects the object regardless of its current mass/inertia.
- Teleports the object to a new location. To do: Impact of teleporting an object short distances every frame vs. letting it find its own way.
An entity can represent up to 1024
IPhysicsObjects. This happens in Valve's code with vehicle wheels and whenever a model has $collisionjoints (the "must all be convex" limitation of which is imposed by studiomdl, not the engine).