Exemplo n.º 1
0
        private void SetPhysicalProperties()
        {
            PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);

            ForcePosition = RawPosition;

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

            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;

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

            UpdatePhysicalMassProperties(RawMass, false);

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

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

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

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

            // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
            PhysScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION);
            PhysScene.PE.UpdateSingleAabb(PhysScene.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(PhysScene);
        }