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(); } } }
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(); } }