Universe.Physics.BulletSPlugin.BSActorAvatarMove.SetVelocityAndTarget C# (CSharp) Method

SetVelocityAndTarget() public method

public SetVelocityAndTarget ( OpenMetaverse vel, OpenMetaverse targ, bool inTaintTime, int targetValueDecayTimeScale ) : void
vel OpenMetaverse
targ OpenMetaverse
inTaintTime bool
targetValueDecayTimeScale int
return void
        public void SetVelocityAndTarget(OMV.Vector3 vel, OMV.Vector3 targ, bool inTaintTime,
            int targetValueDecayTimeScale)
        {
            if (m_disallowTargetVelocitySet)
            {
                if (m_controllingPrim.Flying && (m_controllingPrim.IsJumping || m_controllingPrim.IsPreJumping))
                    //They started flying while jumping
                {
                    m_physicsScene.TaintedObject(inTaintTime, "BSCharacter.setTargetVelocity", delegate()
                        {
                            //Reset everything in case something went wrong
                            m_disallowTargetVelocitySet = false;
                            m_jumpFallState = false;
                            m_controllingPrim.IsPreJumping = false;
                            m_controllingPrim.IsJumping = false;
                            m_jumpStart = 0;
                            m_preJumpStart = 0;
                        });
                }
                return;
            }

            if (!m_controllingPrim.Flying && m_controllingPrim.IsColliding && targ.Z >= 0.5f)
            {
                m_controllingPrim.IsPreJumping = true;
                m_disallowTargetVelocitySet = true;
                m_jumpDirection = targ;
                m_preJumpStart = Util.EnvironmentTickCount();
                return;
            }

            SetVelocityAndTargetInternal(vel, targ, inTaintTime, targetValueDecayTimeScale);
        }

Usage Example

Example #1
0
        void SetPhysicalProperties()
        {
            PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody);

            ForcePosition = RawPosition;

            // Set the velocity
            if (m_moveActor != null)
            {
                m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false, 0);
            }

            ForceVelocity  = RawVelocity;
            TargetVelocity = RawVelocity;

            // This will enable or disable the flying buoyancy of the avatar.
            // Needs to be reset especially when an avatar is recreated after crossing a region boundry.
            Flying = _flying;

            PhysicsScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution);
            PhysicsScene.PE.SetMargin(PhysShape.physShapeInfo, PhysicsScene.Params.collisionMargin);
            PhysicsScene.PE.SetLocalScaling(PhysShape.physShapeInfo, Scale);
            PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
            if (BSParam.CcdMotionThreshold > 0f)
            {
                PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
                PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
            }

            UpdatePhysicalMassProperties(RawMass, false);

            // Make so capsule does not fall over
            PhysicsScene.PE.SetAngularFactorV(PhysBody, OMV.Vector3.Zero);

            // The avatar mover sets some parameters.
            PhysicalActors.Refresh();

            PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT);

            PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);

            // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
            PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION);
            PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody);

            // Do this after the object has been added to the world
            if (BSParam.AvatarToAvatarCollisionsByDefault)
            {
                PhysBody.collisionType = CollisionType.Avatar;
            }
            else
            {
                PhysBody.collisionType = CollisionType.PhantomToOthersAvatar;
            }
            PhysBody.ApplyCollisionMask(PhysicsScene);
        }