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 #2
0
 public void Execute(PhysxScene scene)
 {
     scene.RemovePrim(Object);
 }
Beispiel #3
0
 public void Execute(PhysxScene scene)
 {
     scene.RemovePrim(Object);
 }
Beispiel #4
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();
            }
        }