ExtendedPhysics

From OpenSimulator

Revision as of 07:52, 25 May 2023 by Misterblue (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

ExtendedPhysics

ExtendedPhysics is an OpenSimulator module that adds LSL functions and constants that provide physics engine extension functions.

The module is designed so to work with any physics engine but, at the moment, only BulletSim implements these functions. These functions can be called when using any physics engine but nothing will change.

The OpenSimulator default configuration has ExtendedPhysics disabled. To enable ExtendedPhysics, add the following to any of the configuration INI files:

    [ExtendedPhysics]
    Enabled = true

Informational Functions

This request returns the type of the physics engine. This function returns the same as osGetPhysicsEngineType which is a string identifying the type of the physics engine.

The BulletSim physics engine returns the string "BulletSim".

The function osGetPhysicsEngineName returns a string that has additional information than just the type. For instance, version numbers or types of accelerators being used.

    string physType = physGetEngineType();
    string morePhysType = osGetPhysicsEngineName();
    llOwnerSay(0, "Physics engine type = " + physType);
    llOwnerSay(0, "Physics engine type again = " + morePhysType);

Disable Deactivation Function

Disable physics deactivation on the containing physical object.

The Bullet physics engine saves CPU cycles by only checking "active" physical objects. Physical objects start out active and are deactivated when their linear or angular velocity falls below some threshold. For instance, if a scene has 100 physical balls that are dropped and roll around, the physics engine has to test each of the 100 balls multiple times a second to compute their movement. As some of the balls slow down and stop moving, the balls are stopped and "deactivated" and thus the physics engine doesn't need to check the stopped physical object any more.

Physical objects are re-activated when another physical object bumps into them but otherwise, they stay still.

This deactivation is usually a great CPU saver but there are cases where it causes objects with small movements or movements that are effected by non-physical objects. A ball on a tilting surface, for instance.

This function disables deactivation -- setting "true" means the object will never be deactivated.

    physDisableDeactivation(TRUE);

Axis Lock Functions

physAxisLock(int lockFlags, ...)
        PHYS_AXIS_LOCK_LINEAR     = 14700;
        PHYS_AXIS_LOCK_LINEAR_X   = 14701;
        PHYS_AXIS_LIMIT_LINEAR_X  = 14702;
        PHYS_AXIS_LOCK_LINEAR_Y   = 14703;
        PHYS_AXIS_LIMIT_LINEAR_Y  = 14704;
        PHYS_AXIS_LOCK_LINEAR_Z   = 14705;
        PHYS_AXIS_LIMIT_LINEAR_Z  = 14706;
        PHYS_AXIS_LOCK_ANGULAR    = 14707;
        PHYS_AXIS_LOCK_ANGULAR_X  = 14708;
        PHYS_AXIS_LIMIT_ANGULAR_X = 14709;
        PHYS_AXIS_LOCK_ANGULAR_Y  = 14710;
        PHYS_AXIS_LIMIT_ANGULAR_Y = 14711;
        PHYS_AXIS_LOCK_ANGULAR_Z  = 14712;
        PHYS_AXIS_LIMIT_ANGULAR_Z = 14713;
        PHYS_AXIS_UNLOCK_LINEAR   = 14714;
        PHYS_AXIS_UNLOCK_LINEAR_X = 14715;
        PHYS_AXIS_UNLOCK_LINEAR_Y = 14716;
        PHYS_AXIS_UNLOCK_LINEAR_Z = 14717;
        PHYS_AXIS_UNLOCK_ANGULAR  = 14718;
        PHYS_AXIS_UNLOCK_ANGULAR_X = 14719;
        PHYS_AXIS_UNLOCK_ANGULAR_Y = 14720;
        PHYS_AXIS_UNLOCK_ANGULAR_Z = 14721;
        PHYS_AXIS_UNLOCK           = 14722;


Linkset Manipulation Functions

        PHYS_LINKSET_TYPE_CONSTRAINT  = 0;
        PHYS_LINKSET_TYPE_COMPOUND    = 1;
        PHYS_LINKSET_TYPE_MANUAL      = 2;

        public int physSetLinksetType(int linksetType)

        int lsType = physGetLinksetType();

        PHYS_LINK_TYPE_FIXED  = 1234;
        PHYS_LINK_TYPE_HINGE  = 4;
        PHYS_LINK_TYPE_SPRING = 9;
        PHYS_LINK_TYPE_6DOF   = 6;
        PHYS_LINK_TYPE_SLIDER = 7;

        physChangeLinkType(int linkNum, int lType)

        physGetLinkType(int linkNum)

        physChangeLinkFixed(int linkNum)

        PHYS_PARAM_FRAMEINA_LOC           = 14401;
        PHYS_PARAM_FRAMEINA_ROT           = 14402;
        PHYS_PARAM_FRAMEINB_LOC           = 14403;
        PHYS_PARAM_FRAMEINB_ROT           = 14404;
        PHYS_PARAM_LINEAR_LIMIT_LOW       = 14405;
        PHYS_PARAM_LINEAR_LIMIT_HIGH      = 14406;
        PHYS_PARAM_ANGULAR_LIMIT_LOW      = 14407;
        PHYS_PARAM_ANGULAR_LIMIT_HIGH     = 14408;
        PHYS_PARAM_USE_FRAME_OFFSET       = 14409;
        PHYS_PARAM_ENABLE_TRANSMOTOR      = 14410;
        PHYS_PARAM_TRANSMOTOR_MAXVEL      = 14411;
        PHYS_PARAM_TRANSMOTOR_MAXFORCE    = 14412;
        PHYS_PARAM_CFM                    = 14413;
        PHYS_PARAM_ERP                    = 14414;
        PHYS_PARAM_SOLVER_ITERATIONS      = 14415;
        PHYS_PARAM_SPRING_AXIS_ENABLE     = 14416;
        PHYS_PARAM_SPRING_DAMPING         = 14417;
        PHYS_PARAM_SPRING_STIFFNESS       = 14418;
        PHYS_PARAM_LINK_TYPE              = 14419;
        PHYS_PARAM_USE_LINEAR_FRAMEA      = 14420;
        PHYS_PARAM_SPRING_EQUILIBRIUM_POINT = 14421;

        PHYS_AXIS_ALL = -1;
        PHYS_AXIS_LINEAR_ALL = -2;
        PHYS_AXIS_ANGULAR_ALL = -3;
        PHYS_AXIS_LINEAR_X  = 0;
        PHYS_AXIS_LINEAR_Y  = 1;
        PHYS_AXIS_LINEAR_Z  = 2;
        PHYS_AXIS_ANGULAR_X = 3;
        PHYS_AXIS_ANGULAR_Y = 4;
        PHYS_AXIS_ANGULAR_Z = 5;

        physChangeLinkParams(params ....)
Personal tools
General
About This Wiki