public RemeshActorWorker(PhysxScene scene, PhysxPrim actor, bool isPhysical, CompletedCallback callBack) { _scene = scene; _actor = actor; _isPhysical = isPhysical; _callBack = callBack; }
public SetMaterialCmd(PhysxPrim target, IMaterial material, bool applyToObject, MaterialChanges changes) { _target = target; _material = material; _applyToObject = applyToObject; _changes = changes; }
public ChangeChildPrimOffsetCmd(PhysxPrim parent, PhysxPrim child, OpenMetaverse.Vector3 newOffset, OpenMetaverse.Quaternion rotOffset) { Util.ThrowIfNull(parent, "parent"); Util.ThrowIfNull(child, "child"); _parent = parent; _child = child; _newOffset = newOffset; _rotOffset = rotOffset; _affectedPrims = new List<PhysxPrim> { parent, child }; }
public UnlinkFromParentCmd(PhysxPrim child, PhysxPrim parent, OpenMetaverse.Vector3 newWorldPosition, OpenMetaverse.Quaternion newWorldRotation) { Util.ThrowIfNull(parent, "parent"); Util.ThrowIfNull(child, "child"); _child = child; _parent = parent; _newWorldPosition = newWorldPosition; _newWorldRotation = newWorldRotation; _targetPrims = new PhysxPrim[] { child, parent }; }
public PrepChildPrimAndLinkCmd(PhysxPrim parent, PhysxPrim child, OpenMetaverse.Vector3 localPos, OpenMetaverse.Quaternion localRot) { Util.ThrowIfNull(parent, "parent"); Util.ThrowIfNull(child, "child"); _parent = parent; _child = child; _localPos = localPos; _localRot = localRot; _newShape = null; _affectedPrims = new List<PhysxPrim> { parent, child }; _affectedPrims.AddRange(child.ChildShapes.Keys); }
public ChangeChildPrimOffsetCmd(PhysxPrim parent, PhysxPrim child, OpenMetaverse.Vector3 newOffset, OpenMetaverse.Quaternion rotOffset) { Util.ThrowIfNull(parent, "parent"); Util.ThrowIfNull(child, "child"); _parent = parent; _child = child; _newOffset = newOffset; _rotOffset = rotOffset; _affectedPrims = new List <PhysxPrim> { parent, child }; }
public PrepChildPrimAndLinkCmd(PhysxPrim parent, PhysxPrim child, OpenMetaverse.Vector3 localPos, OpenMetaverse.Quaternion localRot) { Util.ThrowIfNull(parent, "parent"); Util.ThrowIfNull(child, "child"); _parent = parent; _child = child; _localPos = localPos; _localRot = localRot; _newShape = null; _affectedPrims = new List <PhysxPrim> { parent, child }; _affectedPrims.AddRange(child.ChildShapes.Keys); }
public void Remesh() { //we need to remesh the prim and all of its child shapes _totalShapesToMesh = _actor.ChildShapes.Count + 1; _scene.MeshingStageImpl.QueueForMeshing(_actor.SOPName, _actor.Shape, _actor.Size, Meshing.MeshingStage.SCULPT_MESH_LOD, _isPhysical, null, false, delegate(PhysicsShape meshedShape) { RootShape = meshedShape; if (++_currentNumShapesMeshed == _totalShapesToMesh) { _callBack(RootShape, ChildShapes); } } ); if (_actor.ChildShapes.Count > 0) { ChildShapes = new Dictionary <PhysxPrim, RelatedShapes>(); } //remesh each child shape to match the parent status foreach (KeyValuePair <PhysxPrim, RelatedShapes> kvp in _actor.ChildShapes) { PhysxPrim thisChild = kvp.Key; _scene.MeshingStageImpl.QueueForMeshing(thisChild.SOPName, kvp.Key.Shape, thisChild.Size, Meshing.MeshingStage.SCULPT_MESH_LOD, _isPhysical, null, false, delegate(PhysicsShape meshedShape) { ChildShapes.Add(thisChild, new RelatedShapes { ChildShape = meshedShape }); if (++_currentNumShapesMeshed == _totalShapesToMesh) { _callBack(RootShape, ChildShapes); } } ); } }
public CreateObjectCmd(PhysxPrim parent, string primName, OpenSim.Framework.PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position, OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation, OpenMetaverse.Vector3 velocity, OpenMetaverse.Vector3 angularVelocity, float lod, PhysicsScene.AddPrimShapeFlags flags, Material material, byte[] serializedPhysicsProperties, byte[] serializedPhysicsShapes, ulong interpolateTime) { _parent = parent; _primName = primName; _pbs = pbs; _position = position; _size = size; _rotation = rotation; _velocity = velocity; _angularVelocity = angularVelocity; _lod = lod; _flags = flags; _material = material; _serializedPhysicsProperties = serializedPhysicsProperties; _serializedPhysicsShapes = serializedPhysicsShapes; _interpolateTime = interpolateTime; }
public SetPositionCmd(PhysxPrim prim, OpenMetaverse.Vector3 newPos) { _prim = prim; _newPosition = newPos; }
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(); }
public SetPhysicalityCmd(PhysxPrim actor, bool isPhysical) { _isPhysical = isPhysical; _actor = actor; _newPrimaryShape = null; }
public SetRotationCmd(PhysxPrim prim, OpenMetaverse.Quaternion newRot) { _prim = prim; _newRotation = newRot; }
public ChangedShapeCmd(PhysxPrim actor) { _actor = actor; }
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(); } }
public WakeUpCmd(PhysxPrim prim) { _prim = prim; }
public RemoveObjectCmd(PhysxPrim prim) { Object = prim; }
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 SetBuoyancyCmd(PhysxPrim target, float buoyancy) { _target = target; _buoyancy = buoyancy; }
public GenericSyncCmd(PhysxPrim target, CommandDelegate cmd) { _target = target; _delegate = cmd; }
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; }
public ChangeVolumeDetectCmd(PhysxPrim actor, bool vdActive) { _actor = actor; _vdActive = vdActive; }
public EnableCollisionEventsCmd(PhysxPrim prim, bool enable) { _prim = prim; _enable = enable; }
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(); } }
public SetKinematicCmd(PhysxPrim actor, bool kinematic) { _actor = actor; _kinematic = kinematic; }
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(); } }