Beispiel #1
0
        public void Execute(PhysxScene scene)
        {
            if (_newShape == null)
            {
                if (_parent.Disposed || _child.Disposed)
                {
                    return;
                }

                _child.Parent = _parent;

                //we need to remesh the prim and then free the old shapes
                _child.BeginDelayCommands(this);
                scene.MeshingStageImpl.QueueForMeshing(_child.SOPName, _child.Shape, _child.Size,
                                                       Meshing.MeshingStage.SCULPT_MESH_LOD, _parent.IsPhysical, null, false,
                                                       delegate(PhysicsShape meshedShape)
                {
                    _newShape = meshedShape;
                    scene.QueueCommand(this);
                }
                                                       );
            }
            else
            {
                _parent.LinkPrimAsChildSync(_newShape, _child, _localPos, _localRot, false);
                _child.EndDelayCommands();
            }
        }
        public void Execute(PhysxScene scene)
        {
            if (_newShape == null)
            {
                if (_parent.Disposed || _child.Disposed) return;

                _child.Parent = _parent;

                //we need to remesh the prim and then free the old shapes
                _child.BeginDelayCommands(this);
                scene.MeshingStageImpl.QueueForMeshing(_child.SOPName, _child.Shape, _child.Size, 
                    Meshing.MeshingStage.SCULPT_MESH_LOD, _parent.IsPhysical, null, false,
                        delegate(PhysicsShape meshedShape)
                        {
                            _newShape = meshedShape;
                            scene.QueueCommand(this);
                        }
                    );
            }
            else
            {
                _parent.LinkPrimAsChildSync(_newShape, _child, _localPos, _localRot, false);
                _child.EndDelayCommands();
            }
        }
Beispiel #3
0
 public BulkCreateObjectCmd(PhysxScene.AddPrimShapeFlags flags, ICollection<BulkShapeData> shapes)
 {
     _flags = flags;
     _shapes = shapes;
     _totalNumShapes = shapes.Count;
     _meshedSoFar = 0;
 }
Beispiel #4
0
 public RemeshActorWorker(PhysxScene scene, PhysxPrim actor, bool isPhysical, CompletedCallback callBack)
 {
     _scene = scene;
     _actor = actor;
     _isPhysical = isPhysical;
     _callBack = callBack;
 }
 public RemeshActorWorker(PhysxScene scene, PhysxPrim actor, bool isPhysical, CompletedCallback callBack)
 {
     _scene      = scene;
     _actor      = actor;
     _isPhysical = isPhysical;
     _callBack   = callBack;
 }
Beispiel #6
0
        public void Execute(PhysxScene scene)
        {
            if (_target.Disposed) return;

            if (_material is Material)
            {
                //this is already our native material
                _target.SetMaterialSync((Material)_material, _applyToObject);
            }
            else
            {
                IMaterial currMat = _target.PrimMaterial;
                
                //we need to build our native material
                Material material = new Material
                {
                    Density = ((_changes & MaterialChanges.Density) != 0) ? Utils.Clamp(_material.Density, 1.0f, 22587.0f) : currMat.Density,
                    StaticFriction = ((_changes & MaterialChanges.Friction) != 0) ? Utils.Clamp(_material.StaticFriction, 0.0f, 255.0f) : currMat.StaticFriction,
                    DynamicFriction = ((_changes & MaterialChanges.Friction) != 0) ? Utils.Clamp(_material.DynamicFriction, 0.0f, 255.0f) : currMat.DynamicFriction,
                    Restitution = ((_changes & MaterialChanges.Restitution) != 0) ? Utils.Clamp(_material.Restitution, 0.0f, 1.0f) : currMat.Restitution,
                    GravityMultiplier = ((_changes & MaterialChanges.GravityMultiplier) != 0) ? Utils.Clamp(_material.GravityMultiplier, -1.0f, 28.0f) : currMat.GravityMultiplier,
                    MaterialPreset = _material.MaterialPreset
                };

                _target.SetMaterialSync(material.ToLocalMaterial(scene.SceneImpl.Physics), _applyToObject);
            }
        }
        public void Execute(PhysxScene scene)
        {
            if (_target.Disposed)
            {
                return;
            }

            if (_material is Material)
            {
                //this is already our native material
                _target.SetMaterialSync((Material)_material, _applyToObject);
            }
            else
            {
                IMaterial currMat = _target.PrimMaterial;

                //we need to build our native material
                Material material = new Material
                {
                    Density           = ((_changes & MaterialChanges.Density) != 0) ? Utils.Clamp(_material.Density, 1.0f, 22587.0f) : currMat.Density,
                    StaticFriction    = ((_changes & MaterialChanges.Friction) != 0) ? Utils.Clamp(_material.StaticFriction, 0.0f, 255.0f) : currMat.StaticFriction,
                    DynamicFriction   = ((_changes & MaterialChanges.Friction) != 0) ? Utils.Clamp(_material.DynamicFriction, 0.0f, 255.0f) : currMat.DynamicFriction,
                    Restitution       = ((_changes & MaterialChanges.Restitution) != 0) ? Utils.Clamp(_material.Restitution, 0.0f, 1.0f) : currMat.Restitution,
                    GravityMultiplier = ((_changes & MaterialChanges.GravityMultiplier) != 0) ? Utils.Clamp(_material.GravityMultiplier, -1.0f, 28.0f) : currMat.GravityMultiplier,
                    MaterialPreset    = _material.MaterialPreset
                };

                _target.SetMaterialSync(material.ToLocalMaterial(scene.SceneImpl.Physics), _applyToObject);
            }
        }
        public void Execute(PhysxScene scene)
        {
            if (_target.Disposed)
            {
                return;
            }

            _target.SetBuoyancy(_buoyancy);
        }
Beispiel #9
0
        public void Execute(PhysxScene scene)
        {
            if (_actor.Disposed)
            {
                return;
            }

            DoKinematic(scene);
        }
Beispiel #10
0
        public void Execute(PhysxScene scene)
        {
            if (_child.Disposed || _parent.Disposed)
            {
                return;
            }

            _parent.ChildPrimOffsetChangedSync(_child, _newOffset, _rotOffset);
        }
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed)
            {
                return;
            }

            _prim.SyncSetPos(_newPosition);
        }
        public void Execute(PhysxScene scene)
        {
            if (_child.Disposed || _parent == null || _parent.Disposed || _child.Parent != _parent)
            {
                return;
            }

            _child.UnlinkFromParent(_newWorldPosition, _newWorldRotation);
        }
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed)
            {
                return;
            }

            _prim.SyncSetRotation(_newRotation);
        }
Beispiel #14
0
        public void Execute(PhysxScene scene)
        {
            if (Actor.Disposed)
            {
                return;
            }

            Actor.AddForceSync(Force, ForceOffset, Type);
        }
Beispiel #15
0
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed)
            {
                return;
            }

            _prim.WakeUp();
        }
Beispiel #16
0
        public void Execute(PhysxScene scene)
        {
            if (_target != null && _target.Disposed)
            {
                //the target no longer exists
                return;
            }

            _delegate(scene);
        }
Beispiel #17
0
        public void Execute(PhysxScene scene)
        {
            if (_target != null && _target.Disposed)
            {
                //the target no longer exists
                return;
            }

            _delegate(scene);
        }
Beispiel #18
0
 public void Execute(PhysxScene scene)
 {
     if (_premeshedTerrainData == null)
     {
         scene.SetTerrainSync(_terrain, _canLoadFromCache, _revision);
     }
     else
     {
         scene.SetPremeshedTerrainSync(_premeshedTerrainData, _revision);
     }
 }
 public void Execute(PhysxScene scene)
 {
     if (_premeshedTerrainData == null)
     {
         scene.SetTerrainSync(_terrain, _canLoadFromCache, _revision);
     }
     else
     {
         scene.SetPremeshedTerrainSync(_premeshedTerrainData, _revision);
     }
 }
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed) return;

            if (_enable)
            {
                _prim.EnableCollisionEventsSync();
            }
            else
            {
                _prim.DisableCollisionEventsSync();
            }
        }
Beispiel #21
0
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed)
            {
                return;
            }

            if (_enable)
            {
                _prim.EnableCollisionEventsSync();
            }
            else
            {
                _prim.DisableCollisionEventsSync();
            }
        }
        public void Execute(PhysxScene scene)
        {
            if (Target.Disposed) return;

            if (Type == SRType.Suspend)
            {
                Target.SuspendPhysicsSync();
            }
            else
            {
                Target.ResumePhysicsSync(Interpolate);
                if (Callback != null)
                {
                    Callback();
                }
            }
        }
        public void Execute(PhysxScene scene)
        {
            if (_newPrimaryShape == null)
            {
                if (_actor.Disposed)
                {
                    return;
                }

                _actor.BeginDelayCommands(this);

                Meshing.RemeshActorWorker worker = new Meshing.RemeshActorWorker(scene, _actor, _vdActive || _actor.IsPhysical,
                                                                                 (PhysicsShape rootShape, Dictionary <PhysxPrim, RelatedShapes> childShapes) =>
                {
                    _newPrimaryShape = rootShape;
                    _newChildShapes  = childShapes;

                    scene.QueueCommand(this);
                });

                worker.Remesh();
            }
            else
            {
                try
                {
                    if (_actor.IsPhysical)
                    {
                        if (!_actor.DynamicsPrecheck(_newPrimaryShape, _newChildShapes))
                        {
                            return;
                        }
                    }

                    _actor.RebuildPhysxActorWithNewShape(_newPrimaryShape, _newChildShapes, _vdActive ? false : _actor.IsPhysical, false);
                    _actor.SetVolumeDetectSync(_vdActive);
                }
                finally
                {
                    _actor.EndDelayCommands();
                }
            }
        }
Beispiel #24
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();
                    }
                }
            }
        }
Beispiel #25
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();
                    }
                }
            }
        }
Beispiel #26
0
        public void Execute(PhysxScene scene)
        {
            if (Target.Disposed)
            {
                return;
            }

            if (Type == SRType.Suspend)
            {
                Target.SuspendPhysicsSync();
            }
            else
            {
                Target.ResumePhysicsSync(Interpolate);
                if (Callback != null)
                {
                    Callback();
                }
            }
        }
Beispiel #27
0
        public void Execute(PhysxScene scene)
        {
            if (_newPrimaryShape == null)
            {
                if (_actor.Disposed) return;

                _actor.BeginDelayCommands(this);

                Meshing.RemeshActorWorker worker = new Meshing.RemeshActorWorker(scene, _actor, _isPhysical,
                    (PhysicsShape rootShape, Dictionary<PhysxPrim, RelatedShapes> childShapes) => 
                    {
                        _newPrimaryShape = rootShape;
                        _newChildShapes = childShapes;
                        scene.QueueCommand(this);
                    });

                worker.Remesh();
            }
            else
            {
                try
                {
                    if (_isPhysical)
                    {
                        if (!_actor.DynamicsPrecheck(_newPrimaryShape, _newChildShapes))
                        {
                            return;
                        }
                    }

                    _actor.RebuildPhysxActorWithNewShape(_newPrimaryShape, _newChildShapes, _isPhysical, false);
                }
                finally
                {
                    _actor.EndDelayCommands();
                }
            }
        }
Beispiel #28
0
        public void Execute(PhysxScene scene)
        {
            if (Actor.Disposed) return;

            Actor.AddForceSync(Force, ForceOffset, Type);
        }
Beispiel #29
0
 public void Execute(PhysxScene scene)
 {
     Shape.Dispose();
 }
Beispiel #30
0
        public void Execute(PhysxScene scene)
        {
            bool isPhysical = (_flags & PhysicsScene.AddPrimShapeFlags.Physical) != 0;

            if (_rootHasVdSet)
            {
                isPhysical = false;
            }

            if (_newPrimaryShape == null)
            {
                bool first = true;
                foreach (BulkShapeData shape in _shapes)
                {
                    BulkShapeData thisShape = shape;
                    if (first)
                    {
                        _primaryShapeData = thisShape;
                        PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, shape.Material, shape.PhysicsProperties);
                        _rootHasVdSet = properties.VolumeDetectActive;

                        if (_rootHasVdSet)
                        {
                            isPhysical = false;
                        }

                        scene.MeshingStageImpl.QueueForMeshing(String.Empty, shape.Pbs, shape.Size, Meshing.MeshingStage.SCULPT_MESH_LOD, 
                            isPhysical || _rootHasVdSet, shape.SerializedShapes, 
                            (_flags & PhysxScene.AddPrimShapeFlags.FromCrossing) == PhysicsScene.AddPrimShapeFlags.FromCrossing,
                                delegate(PhysicsShape meshedShape)
                                {
                                    _newPrimaryShape = meshedShape;
                                    _meshedShapes.Add(thisShape, meshedShape);
                                    if (++_meshedSoFar == _totalNumShapes)
                                    {
                                        scene.QueueCommand(this);
                                    }
                                }
                            );

                        first = false;
                    }
                    else
                    {
                        scene.MeshingStageImpl.QueueForMeshing(String.Empty, shape.Pbs, shape.Size, Meshing.MeshingStage.SCULPT_MESH_LOD, 
                            isPhysical || _rootHasVdSet, shape.SerializedShapes,
                            (_flags & PhysxScene.AddPrimShapeFlags.FromCrossing) == PhysicsScene.AddPrimShapeFlags.FromCrossing,
                                delegate(PhysicsShape meshedShape)
                                {
                                    _meshedShapes.Add(thisShape, meshedShape);
                                    if (++_meshedSoFar == _totalNumShapes)
                                    {
                                        scene.QueueCommand(this);
                                    }
                                }
                            );
                    }
                }
            }
            else
            {
                OpenMetaverse.Vector3 rootVelocity = OpenMetaverse.Vector3.Zero;
                OpenMetaverse.Vector3 rootAngularVelocity = OpenMetaverse.Vector3.Zero;

                //we have all the shapes for the parent and all children, time to construct the group
                bool first = true;
                PhysxPrim rootPrim = null;

                CollisionGroupFlag collisionGroup = (_flags & PhysicsScene.AddPrimShapeFlags.Phantom) == 0 ? CollisionGroupFlag.Normal : CollisionGroupFlag.PhysicalPhantom;
                foreach (BulkShapeData shape in _shapes)
                {
                    if (first)
                    {
                        bool kinematicStatic;

                        PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, shape.Material, shape.PhysicsProperties);

                        PhysX.RigidActor actor = PhysxActorFactory.CreateProperInitialActor(_newPrimaryShape, scene, shape.Position, shape.Rotation, _flags, out kinematicStatic,
                            properties.PhysxMaterial);

                        rootPrim = new PhysxPrim(scene, shape.Pbs, shape.Position, shape.Rotation, _newPrimaryShape, actor, 
                            isPhysical, properties, collisionGroup);

                        scene.AddPrimSync(rootPrim, isPhysical, kinematicStatic);

                        shape.OutActor = rootPrim;

                        rootVelocity = shape.Velocity;
                        rootAngularVelocity = shape.AngularVelocity;

                        first = false;
                    }
                    else
                    {
                        PhysicsShape phyShape = _meshedShapes[shape];

                        PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, shape.Material, shape.PhysicsProperties);

                        PhysxPrim childPrim = new PhysxPrim(rootPrim, scene, shape.Pbs, shape.Position, shape.Rotation, phyShape, 
                            null, isPhysical, properties, collisionGroup);
                        rootPrim.LinkPrimAsChildSync(phyShape, childPrim, shape.Position, shape.Rotation, true);

                        shape.OutActor = childPrim;
                    }
                }

                rootPrim.UpdateMassAndInertia();

                if (_rootHasVdSet)
                {
                    rootPrim.SetVolumeDetectSync(_rootHasVdSet);
                }

                if ((_flags & PhysicsScene.AddPrimShapeFlags.StartSuspended) != 0)
                {
                    rootPrim.SuspendPhysicsSync(_primaryShapeData.ObjectReceivedOn);
                }

                rootPrim.DynamicsPostcheck();

                rootPrim.SetInitialVelocities(rootVelocity, rootAngularVelocity);

                if ((_flags & PhysicsScene.AddPrimShapeFlags.Interpolate) != 0)
                {
                    rootPrim.SuspendPhysicsSync(_primaryShapeData.ObjectReceivedOn);
                    rootPrim.ResumePhysicsSync(true);
                }

                FinishedEvent.Set();
            }
        }
Beispiel #31
0
        public void Execute(PhysxScene scene)
        {
            bool isPhysical = (_flags & PhysicsScene.AddPrimShapeFlags.Physical) != 0;

            if (_rootHasVdSet)
            {
                isPhysical = false;
            }

            if (_newPrimaryShape == null)
            {
                bool first = true;
                foreach (BulkShapeData shape in _shapes)
                {
                    BulkShapeData   thisShape = shape;
                    SceneObjectPart thisPart  = (SceneObjectPart)thisShape.Part;
                    String          primName  = String.Empty;
                    if (thisPart != null)
                    {
                        primName = thisPart.Name;
                    }
                    if (first)
                    {
                        _primaryShapeData = thisShape;
                        PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, shape.Material, shape.PhysicsProperties);
                        _rootHasVdSet = properties.VolumeDetectActive;

                        if (_rootHasVdSet)
                        {
                            isPhysical = false;
                        }

                        scene.MeshingStageImpl.QueueForMeshing(primName, shape.Pbs, shape.Size, Meshing.MeshingStage.SCULPT_MESH_LOD,
                                                               isPhysical || _rootHasVdSet, shape.SerializedShapes,
                                                               (_flags& PhysxScene.AddPrimShapeFlags.FromCrossing) == PhysicsScene.AddPrimShapeFlags.FromCrossing,
                                                               delegate(PhysicsShape meshedShape)
                        {
                            _newPrimaryShape = meshedShape;
                            _meshedShapes.Add(thisShape, meshedShape);
                            if (++_meshedSoFar == _totalNumShapes)
                            {
                                scene.QueueCommand(this);
                            }
                        }
                                                               );

                        first = false;
                    }
                    else
                    {
                        scene.MeshingStageImpl.QueueForMeshing(primName, shape.Pbs, shape.Size, Meshing.MeshingStage.SCULPT_MESH_LOD,
                                                               isPhysical || _rootHasVdSet, shape.SerializedShapes,
                                                               (_flags& PhysxScene.AddPrimShapeFlags.FromCrossing) == PhysicsScene.AddPrimShapeFlags.FromCrossing,
                                                               delegate(PhysicsShape meshedShape)
                        {
                            _meshedShapes.Add(thisShape, meshedShape);
                            if (++_meshedSoFar == _totalNumShapes)
                            {
                                scene.QueueCommand(this);
                            }
                        }
                                                               );
                    }
                }
            }
            else
            {
                OpenMetaverse.Vector3 rootVelocity        = OpenMetaverse.Vector3.Zero;
                OpenMetaverse.Vector3 rootAngularVelocity = OpenMetaverse.Vector3.Zero;

                //we have all the shapes for the parent and all children, time to construct the group
                bool      first    = true;
                PhysxPrim rootPrim = null;

                CollisionGroupFlag collisionGroup = (_flags & PhysicsScene.AddPrimShapeFlags.Phantom) == 0 ? CollisionGroupFlag.Normal : CollisionGroupFlag.PhysicalPhantom;
                foreach (BulkShapeData shape in _shapes)
                {
                    if (first)
                    {
                        bool kinematicStatic;

                        PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, shape.Material, shape.PhysicsProperties);

                        PhysX.RigidActor actor = PhysxActorFactory.CreateProperInitialActor(_newPrimaryShape, scene, shape.Position, shape.Rotation, _flags, out kinematicStatic,
                                                                                            properties.PhysxMaterial);

                        rootPrim = new PhysxPrim(scene, shape.Pbs, shape.Position, shape.Rotation, _newPrimaryShape, actor,
                                                 isPhysical, properties, collisionGroup);

                        scene.AddPrimSync(rootPrim, isPhysical, kinematicStatic);

                        shape.OutActor = rootPrim;

                        rootVelocity        = shape.Velocity;
                        rootAngularVelocity = shape.AngularVelocity;

                        first = false;
                    }
                    else
                    {
                        PhysicsShape phyShape = _meshedShapes[shape];

                        PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, shape.Material, shape.PhysicsProperties);

                        PhysxPrim childPrim = new PhysxPrim(rootPrim, scene, shape.Pbs, shape.Position, shape.Rotation, phyShape,
                                                            null, isPhysical, properties, collisionGroup);
                        rootPrim.LinkPrimAsChildSync(phyShape, childPrim, shape.Position, shape.Rotation, true);

                        shape.OutActor = childPrim;
                    }
                }

                rootPrim.UpdateMassAndInertia();

                if (_rootHasVdSet)
                {
                    rootPrim.SetVolumeDetectSync(_rootHasVdSet);
                }

                if ((_flags & PhysicsScene.AddPrimShapeFlags.StartSuspended) != 0)
                {
                    rootPrim.SuspendPhysicsSync(_primaryShapeData.ObjectReceivedOn);
                }

                rootPrim.DynamicsPostcheck();

                rootPrim.SetInitialVelocities(rootVelocity, rootAngularVelocity);

                if ((_flags & PhysicsScene.AddPrimShapeFlags.Interpolate) != 0)
                {
                    rootPrim.SuspendPhysicsSync(_primaryShapeData.ObjectReceivedOn);
                    rootPrim.ResumePhysicsSync(true);
                }

                FinishedEvent.Set();
            }
        }
Beispiel #32
0
 public void Execute(PhysxScene scene)
 {
     scene.RemovePrim(Object);
 }
Beispiel #33
0
        public VehicleDynamics(PhysxPrim physxPrim, VehicleProperties shadowProps, PhysX.Physics physics, PhysxScene scene)
        {
            _angularstatsX = new RunningStat();
            _angularstatsY = new RunningStat();
            _angularstatsZ = new RunningStat();
            _linearstatsX  = new RunningStat();
            _linearstatsY  = new RunningStat();
            _linearstatsZ  = new RunningStat();

            _actor = physxPrim;
            _props = new VehicleProperties();
            _physics = physics;
            _scene = scene;
            _motor = new VehicleMotor(ref _actor, ref _props, ref _physics, ref _scene);

            // Preset the defaults and new common keys. This ensures scripts with older versions of saved state
            // do not crash the simulator since the new keys do not exist in the old state.
            _props.Type = VehicleType.None;
            SetVehicleDefaults(_props);

            // Merge the new properties.
            _props.Merge(shadowProps);
            SetVehicleDefaultActions();

            if (VehicleLimits.DebugVehicleChange) m_log.InfoFormat("[VehicleDynamics] constructed type={0} name={1} at {2}", _props.Type, _actor.SOPName, _actor.Position);
            //DisplayParameters();
        }
Beispiel #34
0
 public void Execute(PhysxScene scene)
 {
     Shape.Dispose();
 }
Beispiel #35
0
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed) return;

            _prim.SyncSetRotation(_newRotation);
        }
 public override void Execute(PhysxScene scene)
 {
     _character.Dispose();
 }
Beispiel #37
0
 public ContactDebugManager(PhysxScene scene)
 {
     _scene = scene;
 }
Beispiel #38
0
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed) return;

            _prim.SyncSetPos(_newPosition);
        }
Beispiel #39
0
        public void Execute(PhysxScene scene)
        {
            if (_newShape == null)
            {
                if (_actor.Disposed) return;
                bool creatingNullShape = _actor.Shape.PreferredPhysicsShape == OpenMetaverse.PhysicsShapeType.None || _actor.Shape.FlexiEntry;

                if (_actor.HasActor && creatingNullShape)
                {
                    //invalid shape for a root prim
                    _actor.Shape.PreferredPhysicsShape = OpenMetaverse.PhysicsShapeType.Prim;
                    _actor.Shape.FlexiEntry = false;
                    creatingNullShape = false;
                }

                if (! creatingNullShape)
                {
                    //we need to remesh the prim and then free the old shapes
                    _actor.BeginDelayCommands(this);

                    scene.MeshingStageImpl.QueueForMeshing(_actor.SOPName, _actor.Shape, _actor.Size, 
                        Meshing.MeshingStage.SCULPT_MESH_LOD, _actor.IsPhysical, null, false,
                            delegate(PhysicsShape meshedShape)
                            {
                                _newShape = meshedShape;
                                scene.QueueCommand(this);
                            }
                        );
                }
                else
                {
                    //child should remove its shape from the parent
                    _actor.RebuildPhysxActorWithNewShape(PhysicsShape.Null, null, _actor.IsPhysical, false);
                }
            }
            else
            {
                try
                {
                    _actor.RebuildPhysxActorWithNewShape(_newShape, null, _actor.IsPhysical, false);
                }
                catch (Exception e)
                {
                    //I have seen some exceptions thrown from physx internals here
                    //everything ranging from physx simply failing to create the shape, to 
                    //null streams on shape creation. Pending finding a real reson for these
                    //issues, we simply report the exception and drop the rebuild in these cases
                    //rather than taking down the region.
                    m_log.ErrorFormat("[InWorldz.PhysX] (ChangedShapeCmd) Rebuilding physx actor failed: {0}", e);

                    //recover by removing this shape and actor
                    try
                    {
                        scene.RemovePrim(_actor);
                    }
                    catch (Exception e2)
                    {
                        m_log.ErrorFormat("[InWorldz.PhysX] (ChangedShapeCmd) Further exception during rebuild recovery: {0}", e2);
                    }
                }

                _actor.EndDelayCommands();
            }
        }
Beispiel #40
0
 public VehicleMotor(ref PhysxPrim _actor, ref VehicleProperties _props, ref PhysX.Physics _physics, ref PhysxScene _scene)
 {
     this._actor = _actor;
     this._props = _props;
     this._physics = _physics;
     this._scene = _scene;
 }
Beispiel #41
0
        public void Execute(PhysxScene scene)
        {
            if (_target.Disposed) return;

            _target.SetBuoyancy(_buoyancy);
        }
Beispiel #42
0
 public void Execute(PhysxScene scene)
 {
     scene.RemovePrim(Object);
 }
Beispiel #43
0
 public override void Execute(PhysxScene scene)
 {
     _character.Dispose();
 }
Beispiel #44
0
 public override void Execute(PhysxScene scene)
 {
     FinalActor = new PhysxCharacter(scene, _height, _radius, _position, _rotation, _flying, _initialVelocity);
     scene.AddCharacterSync(FinalActor);
     FinshedEvent.Set();
 }
Beispiel #45
0
 public ContactDebugManager(PhysxScene scene)
 {
     _scene = scene;
 }
        public void Execute(PhysxScene scene)
        {
            if (_child.Disposed || _parent.Disposed) return;

            _parent.ChildPrimOffsetChangedSync(_child, _newOffset, _rotOffset);
        }
Beispiel #47
0
        public void Execute(PhysxScene scene)
        {
            if (Shape == null)
            {
                PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, _material, _serializedPhysicsProperties);
                _hasVdSet = properties.VolumeDetectActive;

                scene.MeshingStageImpl.QueueForMeshing(_primName, _pbs, _size, _lod,
                                                       (_flags& PhysicsScene.AddPrimShapeFlags.Physical) != 0 || _hasVdSet,
                                                       _serializedPhysicsShapes,
                                                       (_flags& PhysxScene.AddPrimShapeFlags.FromCrossing) == PhysicsScene.AddPrimShapeFlags.FromCrossing,
                                                       delegate(PhysicsShape meshedShape)
                {
                    Shape = meshedShape;
                    scene.QueueCommand(this);
                }
                                                       );
            }
            else
            {
                bool isPhysical = (_flags & PhysicsScene.AddPrimShapeFlags.Physical) != 0;
                if (_hasVdSet)
                {
                    isPhysical = false;
                }

                CollisionGroupFlag collisionGroup = (_flags & PhysicsScene.AddPrimShapeFlags.Phantom) == 0 ? CollisionGroupFlag.Normal : CollisionGroupFlag.PhysicalPhantom;
                if (_parent == null)
                {
                    bool kinematicStatic;

                    PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, _material, _serializedPhysicsProperties);

                    Actor = PhysxActorFactory.CreateProperInitialActor(Shape, scene, _position, _rotation, _flags, out kinematicStatic, properties.PhysxMaterial);

                    FinalPrim = new PhysxPrim(scene, _pbs, _position, _rotation, Shape, Actor, isPhysical, properties, collisionGroup);
                    scene.AddPrimSync(FinalPrim, isPhysical, kinematicStatic);
                }
                else
                {
                    PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, _material, _serializedPhysicsProperties);

                    FinalPrim = new PhysxPrim(_parent, scene, _pbs, _position, _rotation, Shape, null, isPhysical, properties, collisionGroup);
                    _parent.LinkPrimAsChildSync(Shape, FinalPrim, _position, _rotation, false);
                }

                if (_hasVdSet)
                {
                    FinalPrim.SetVolumeDetectSync(true);
                }

                if ((_flags & PhysicsScene.AddPrimShapeFlags.StartSuspended) != 0)
                {
                    FinalPrim.SuspendPhysicsSync(_interpolateTime);
                }

                FinalPrim.DynamicsPostcheck();

                FinalPrim.SetInitialVelocities(_velocity, _angularVelocity);

                if ((_flags & PhysicsScene.AddPrimShapeFlags.Interpolate) != 0)
                {
                    FinalPrim.SuspendPhysicsSync(_interpolateTime);
                    FinalPrim.ResumePhysicsSync(true);
                }

                this.FinshedEvent.Set();
            }
        }
        public void Execute(PhysxScene scene)
        {
            if (_newShape == null)
            {
                if (_actor.Disposed)
                {
                    return;
                }
                bool creatingNullShape = _actor.Shape.PreferredPhysicsShape == OpenMetaverse.PhysicsShapeType.None || _actor.Shape.FlexiEntry;

                if (_actor.HasActor && creatingNullShape)
                {
                    //invalid shape for a root prim
                    _actor.Shape.PreferredPhysicsShape = OpenMetaverse.PhysicsShapeType.Prim;
                    _actor.Shape.FlexiEntry            = false;
                    creatingNullShape = false;
                }

                if (!creatingNullShape)
                {
                    //we need to remesh the prim and then free the old shapes
                    _actor.BeginDelayCommands(this);

                    scene.MeshingStageImpl.QueueForMeshing(_actor.SOPName, _actor.Shape, _actor.Size,
                                                           Meshing.MeshingStage.SCULPT_MESH_LOD, _actor.IsPhysical, null, false,
                                                           delegate(PhysicsShape meshedShape)
                    {
                        _newShape = meshedShape;
                        scene.QueueCommand(this);
                    }
                                                           );
                }
                else
                {
                    //child should remove its shape from the parent
                    _actor.RebuildPhysxActorWithNewShape(PhysicsShape.Null, null, _actor.IsPhysical, false);
                }
            }
            else
            {
                try
                {
                    _actor.RebuildPhysxActorWithNewShape(_newShape, null, _actor.IsPhysical, false);
                }
                catch (Exception e)
                {
                    //I have seen some exceptions thrown from physx internals here
                    //everything ranging from physx simply failing to create the shape, to
                    //null streams on shape creation. Pending finding a real reson for these
                    //issues, we simply report the exception and drop the rebuild in these cases
                    //rather than taking down the region.
                    m_log.ErrorFormat("[InWorldz.PhysX] (ChangedShapeCmd) Rebuilding physx actor failed: {0}", e);

                    //recover by removing this shape and actor
                    try
                    {
                        scene.RemovePrim(_actor);
                    }
                    catch (Exception e2)
                    {
                        m_log.ErrorFormat("[InWorldz.PhysX] (ChangedShapeCmd) Further exception during rebuild recovery: {0}", e2);
                    }
                }

                _actor.EndDelayCommands();
            }
        }
Beispiel #49
0
 public abstract void Execute(PhysxScene scene);
Beispiel #50
0
        public void Execute(PhysxScene scene)
        {
            if (Shape == null)
            {
                PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, _material, _serializedPhysicsProperties);
                _hasVdSet = properties.VolumeDetectActive;

                scene.MeshingStageImpl.QueueForMeshing(_primName, _pbs, _size, _lod, 
                    (_flags & PhysicsScene.AddPrimShapeFlags.Physical) != 0 || _hasVdSet, 
                    _serializedPhysicsShapes,
                    (_flags & PhysxScene.AddPrimShapeFlags.FromCrossing) == PhysicsScene.AddPrimShapeFlags.FromCrossing,
                        delegate(PhysicsShape meshedShape)
                        {
                            Shape = meshedShape;
                            scene.QueueCommand(this);
                        }
                    );
            }
            else
            {
                bool isPhysical = (_flags & PhysicsScene.AddPrimShapeFlags.Physical) != 0;
                if (_hasVdSet)
                {
                    isPhysical = false;
                }

                CollisionGroupFlag collisionGroup = (_flags & PhysicsScene.AddPrimShapeFlags.Phantom) == 0 ? CollisionGroupFlag.Normal : CollisionGroupFlag.PhysicalPhantom;
                if (_parent == null)
                {
                    bool kinematicStatic;

                    PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, _material, _serializedPhysicsProperties);

                    Actor = PhysxActorFactory.CreateProperInitialActor(Shape, scene, _position, _rotation, _flags, out kinematicStatic, properties.PhysxMaterial);

                    FinalPrim = new PhysxPrim(scene, _pbs, _position, _rotation, Shape, Actor, isPhysical, properties, collisionGroup);
                    scene.AddPrimSync(FinalPrim, isPhysical, kinematicStatic);
                }
                else
                {
                    PhysicsProperties properties = PhysicsProperties.DeserializeOrCreateNew(scene, _material, _serializedPhysicsProperties);

                    FinalPrim = new PhysxPrim(_parent, scene, _pbs, _position, _rotation, Shape, null, isPhysical, properties, collisionGroup);
                    _parent.LinkPrimAsChildSync(Shape, FinalPrim, _position, _rotation, false);
                }

                if (_hasVdSet)
                {
                    FinalPrim.SetVolumeDetectSync(true);
                }

                if ((_flags & PhysicsScene.AddPrimShapeFlags.StartSuspended) != 0)
                {
                    FinalPrim.SuspendPhysicsSync(_interpolateTime);
                }

                FinalPrim.DynamicsPostcheck();

                FinalPrim.SetInitialVelocities(_velocity, _angularVelocity);

                if ((_flags & PhysicsScene.AddPrimShapeFlags.Interpolate) != 0)
                {
                    FinalPrim.SuspendPhysicsSync(_interpolateTime);
                    FinalPrim.ResumePhysicsSync(true);
                }

                this.FinshedEvent.Set();
            }
        }
Beispiel #51
0
        public void Execute(PhysxScene scene)
        {
            if (_child.Disposed || _parent == null || _parent.Disposed || _child.Parent != _parent) return;

            _child.UnlinkFromParent(_newWorldPosition, _newWorldRotation);
        }
Beispiel #52
0
        public void Execute(PhysxScene scene)
        {
            if (_prim.Disposed) return;

            _prim.WakeUp();
        }
Beispiel #53
0
 public override void Execute(PhysxScene scene)
 {
     FinalActor = new PhysxCharacter(scene, _height, _radius, _position, _rotation, _flying, _initialVelocity);
     scene.AddCharacterSync(FinalActor);
     FinshedEvent.Set();
 }
Beispiel #54
0
        public void Execute(PhysxScene scene)
        {
            if (_actor.Disposed) return;

            DoKinematic(scene);
        }
Beispiel #55
0
 public abstract void Execute(PhysxScene scene);