Example #1
0
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed)
            {
                return;
            }

            _prim.WakeUp();
        }
Example #2
0
        private void DoKinematic(PhysxScene scene)
        {
            /**
             * Reference Mantis #0001860
             *
             * The bug was that SetKinematic(false) was coming in after the object
             * was made non-physical by a call to SetStatus(PHYSICS, FALSE). That would
             * then try to set the kinematic to a dynamic with a trimesh shape.
             *
             * This necessitates the below check for _actor.IsPhysical == true
             */
            if (_actor.DynActorImpl != null && _actor.IsPhysical)
            {
                bool wasKinematic = (_actor.DynActorImpl.Flags & PhysX.RigidDynamicFlags.Kinematic) != 0;

                if (wasKinematic != _kinematic)
                {
                    if (!wasKinematic)
                    {
                        _actor.DynActorImpl.ClearForce();
                        _actor.DynActorImpl.LinearVelocity  = new PhysX.Math.Vector3();
                        _actor.DynActorImpl.AngularVelocity = new PhysX.Math.Vector3();
                    }

                    _actor.DynActorImpl.Flags = _kinematic ? _actor.DynActorImpl.Flags | PhysX.RigidDynamicFlags.Kinematic : _actor.DynActorImpl.Flags & ~PhysX.RigidDynamicFlags.Kinematic;
                    _actor.SyncWithPhysics(0.0f, 0, 0);

                    if (_kinematic)
                    {
                        _actor.InvalidateCollisionData();
                        scene.PrimMadeStaticKinematic(_actor);
                    }
                    else
                    {
                        _actor.InvalidateCollisionData();
                        scene.PrimMadeDynamic(_actor);
                        //also wake the actor up
                        _actor.WakeUp();
                    }
                }
            }
        }