Force


LXsITYPE_FORCE

Force items all derive from a common type, a type of locator. Being a locator type means all forces have a location, which seems fairly reasonable. All forces implicitly support enable/disable, strength and inversion.

  • LXsICHAN_FORCE_FORCE

  • LXsICHAN_FORCE_FILTER

  • LXsICHAN_FORCE_ENABLE

  • LXsICHAN_FORCE_STRENGTH

  • LXsICHAN_FORCE_TORQUE

  • LXsICHAN_FORCE_INVERT


LXsGRAPH_FORCEFALLOFF

An item inheriting from this type writes a basic force object to the ‘forceObj’ channel. This is then overridden by the core implementation for the default behaviors. This includes a falloff on the force effect which can be set with a graph link.

ILxForce

class ILxForce

The force interface allows clients to compute forces from positions and other element features.

Public Functions

unsigned Flags(LXtObjectID self)

Get flag bits describing the force. A force can require velocity or mass as an input, and can optionally generate angular forces.

LxResult Force(LXtObjectID self, const LXtFVector pos, LXtFVector force)

These single point methods are optimized for computing a force for a single element. Any given force only needs to implement one of these based on the flags above. The client is required to call the right API.

LxResult ForceV(LXtObjectID self, const LXtFVector pos, const LXtFVector velocity, LXtFVector force)
LxResult ForceM(LXtObjectID self, const LXtFVector pos, float mass, LXtFVector force)
LxResult ForceVM(LXtObjectID self, const LXtFVector pos, const LXtFVector velocity, float mass, LXtFVector force)
LxResult ForceRun(LXtObjectID self, const float **pos, const float **velocity, const float *mass, float **force, unsigned num)

Computing forces over multiple elements is more efficiently done using runs which are arrays of floats. Anything not requested by the flags will be unset. Angular forces can only be computed in runs.

LxResult ForceRunAng(LXtObjectID self, const float **pos, const float **velocity, const float **angVel, const float *mass, float **force, float **torque, unsigned num)
  • LXfFORCE_VELOCITY

  • LXfFORCE_MASS