diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 345 |
1 files changed, 316 insertions, 29 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 15b7090..a00991f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -34,6 +34,7 @@ using OMV = OpenMetaverse; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Physics.Manager; | 35 | using OpenSim.Region.Physics.Manager; |
36 | using OpenSim.Region.Physics.ConvexDecompositionDotNet; | 36 | using OpenSim.Region.Physics.ConvexDecompositionDotNet; |
37 | using OpenSim.Region.OptionalModules.Scripting; // for ExtendedPhysics | ||
37 | 38 | ||
38 | namespace OpenSim.Region.Physics.BulletSPlugin | 39 | namespace OpenSim.Region.Physics.BulletSPlugin |
39 | { | 40 | { |
@@ -95,11 +96,9 @@ public class BSPrim : BSPhysObject | |||
95 | _isPhysical = pisPhysical; | 96 | _isPhysical = pisPhysical; |
96 | _isVolumeDetect = false; | 97 | _isVolumeDetect = false; |
97 | 98 | ||
98 | // Add a dynamic vehicle to our set of actors that can move this prim. | ||
99 | // PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); | ||
100 | |||
101 | _mass = CalculateMass(); | 99 | _mass = CalculateMass(); |
102 | 100 | ||
101 | DetailLog("{0},BSPrim.constructor,pbs={1}", LocalID, BSScene.PrimitiveBaseShapeToString(pbs)); | ||
103 | // DetailLog("{0},BSPrim.constructor,call", LocalID); | 102 | // DetailLog("{0},BSPrim.constructor,call", LocalID); |
104 | // do the actual object creation at taint time | 103 | // do the actual object creation at taint time |
105 | PhysScene.TaintedObject(LocalID, "BSPrim.create", delegate() | 104 | PhysScene.TaintedObject(LocalID, "BSPrim.create", delegate() |
@@ -141,6 +140,18 @@ public class BSPrim : BSPhysObject | |||
141 | public override bool Stopped { | 140 | public override bool Stopped { |
142 | get { return false; } | 141 | get { return false; } |
143 | } | 142 | } |
143 | |||
144 | public override bool IsIncomplete { | ||
145 | get { | ||
146 | return ShapeRebuildScheduled; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | // 'true' if this object's shape is in need of a rebuild and a rebuild has been queued. | ||
151 | // The prim is still available but its underlying shape will change soon. | ||
152 | // This is protected by a 'lock(this)'. | ||
153 | public bool ShapeRebuildScheduled { get; protected set; } | ||
154 | |||
144 | public override OMV.Vector3 Size { | 155 | public override OMV.Vector3 Size { |
145 | get { return _size; } | 156 | get { return _size; } |
146 | set { | 157 | set { |
@@ -155,17 +166,42 @@ public class BSPrim : BSPhysObject | |||
155 | public override PrimitiveBaseShape Shape { | 166 | public override PrimitiveBaseShape Shape { |
156 | set { | 167 | set { |
157 | BaseShape = value; | 168 | BaseShape = value; |
169 | DetailLog("{0},BSPrim.changeShape,pbs={1}", LocalID, BSScene.PrimitiveBaseShapeToString(BaseShape)); | ||
158 | PrimAssetState = PrimAssetCondition.Unknown; | 170 | PrimAssetState = PrimAssetCondition.Unknown; |
159 | ForceBodyShapeRebuild(false); | 171 | ForceBodyShapeRebuild(false); |
160 | } | 172 | } |
161 | } | 173 | } |
174 | // Cause the body and shape of the prim to be rebuilt if necessary. | ||
175 | // If there are no changes required, this is quick and does not make changes to the prim. | ||
176 | // If rebuilding is necessary (like changing from static to physical), that will happen. | ||
177 | // The 'ShapeRebuildScheduled' tells any checker that the body/shape may change shortly. | ||
178 | // The return parameter is not used by anyone. | ||
162 | public override bool ForceBodyShapeRebuild(bool inTaintTime) | 179 | public override bool ForceBodyShapeRebuild(bool inTaintTime) |
163 | { | 180 | { |
164 | PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ForceBodyShapeRebuild", delegate() | 181 | if (inTaintTime) |
165 | { | 182 | { |
183 | // If called in taint time, do the operation immediately | ||
166 | _mass = CalculateMass(); // changing the shape changes the mass | 184 | _mass = CalculateMass(); // changing the shape changes the mass |
167 | CreateGeomAndObject(true); | 185 | CreateGeomAndObject(true); |
168 | }); | 186 | } |
187 | else | ||
188 | { | ||
189 | lock (this) | ||
190 | { | ||
191 | // If a rebuild is not already in the queue | ||
192 | if (!ShapeRebuildScheduled) | ||
193 | { | ||
194 | // Remember that a rebuild is queued -- this is used to flag an incomplete object | ||
195 | ShapeRebuildScheduled = true; | ||
196 | PhysScene.TaintedObject(LocalID, "BSPrim.ForceBodyShapeRebuild", delegate() | ||
197 | { | ||
198 | _mass = CalculateMass(); // changing the shape changes the mass | ||
199 | CreateGeomAndObject(true); | ||
200 | ShapeRebuildScheduled = false; | ||
201 | }); | ||
202 | } | ||
203 | } | ||
204 | } | ||
169 | return true; | 205 | return true; |
170 | } | 206 | } |
171 | public override bool Grabbed { | 207 | public override bool Grabbed { |
@@ -249,23 +285,21 @@ public class BSPrim : BSPhysObject | |||
249 | { | 285 | { |
250 | DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); | 286 | DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); |
251 | 287 | ||
252 | // "1" means free, "0" means locked | 288 | ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR, 0f, 0f); |
253 | OMV.Vector3 locking = LockedAxisFree; | 289 | if (axis.X != 1) |
254 | if (axis.X != 1) locking.X = 0f; | ||
255 | if (axis.Y != 1) locking.Y = 0f; | ||
256 | if (axis.Z != 1) locking.Z = 0f; | ||
257 | LockedAngularAxis = locking; | ||
258 | |||
259 | EnableActor(LockedAngularAxis != LockedAxisFree, LockedAxisActorName, delegate() | ||
260 | { | 290 | { |
261 | return new BSActorLockAxis(PhysScene, this, LockedAxisActorName); | 291 | ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_X, 0f, 0f); |
262 | }); | 292 | } |
263 | 293 | if (axis.Y != 1) | |
264 | // Update parameters so the new actor's Refresh() action is called at the right time. | ||
265 | PhysScene.TaintedObject(LocalID, "BSPrim.LockAngularMotion", delegate() | ||
266 | { | 294 | { |
267 | UpdatePhysicalParameters(); | 295 | ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Y, 0f, 0f); |
268 | }); | 296 | } |
297 | if (axis.Z != 1) | ||
298 | { | ||
299 | ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Z, 0f, 0f); | ||
300 | } | ||
301 | |||
302 | InitializeAxisActor(); | ||
269 | 303 | ||
270 | return; | 304 | return; |
271 | } | 305 | } |
@@ -376,18 +410,19 @@ public class BSPrim : BSPhysObject | |||
376 | { | 410 | { |
377 | bool ret = false; | 411 | bool ret = false; |
378 | 412 | ||
379 | uint wayOutThere = Constants.RegionSize * Constants.RegionSize; | 413 | int wayOverThere = -1000; |
414 | int wayOutThere = 10000; | ||
380 | // There have been instances of objects getting thrown way out of bounds and crashing | 415 | // There have been instances of objects getting thrown way out of bounds and crashing |
381 | // the border crossing code. | 416 | // the border crossing code. |
382 | if ( RawPosition.X < -Constants.RegionSize || RawPosition.X > wayOutThere | 417 | if ( RawPosition.X < wayOverThere || RawPosition.X > wayOutThere |
383 | || RawPosition.Y < -Constants.RegionSize || RawPosition.Y > wayOutThere | 418 | || RawPosition.Y < wayOverThere || RawPosition.X > wayOutThere |
384 | || RawPosition.Z < -Constants.RegionSize || RawPosition.Z > wayOutThere) | 419 | || RawPosition.Z < wayOverThere || RawPosition.X > wayOutThere) |
385 | { | 420 | { |
386 | RawPosition = new OMV.Vector3(10, 10, 50); | 421 | RawPosition = new OMV.Vector3(10, 10, 50); |
387 | ZeroMotion(inTaintTime); | 422 | ZeroMotion(inTaintTime); |
388 | ret = true; | 423 | ret = true; |
389 | } | 424 | } |
390 | if (RawVelocity.LengthSquared() > BSParam.MaxLinearVelocity) | 425 | if (RawVelocity.LengthSquared() > BSParam.MaxLinearVelocitySquared) |
391 | { | 426 | { |
392 | RawVelocity = Util.ClampV(RawVelocity, BSParam.MaxLinearVelocity); | 427 | RawVelocity = Util.ClampV(RawVelocity, BSParam.MaxLinearVelocity); |
393 | ret = true; | 428 | ret = true; |
@@ -496,6 +531,12 @@ public class BSPrim : BSPhysObject | |||
496 | { | 531 | { |
497 | return new BSActorSetForce(PhysScene, this, SetForceActorName); | 532 | return new BSActorSetForce(PhysScene, this, SetForceActorName); |
498 | }); | 533 | }); |
534 | |||
535 | // Call update so actor Refresh() is called to start things off | ||
536 | PhysScene.TaintedObject(LocalID, "BSPrim.setForce", delegate() | ||
537 | { | ||
538 | UpdatePhysicalParameters(); | ||
539 | }); | ||
499 | } | 540 | } |
500 | } | 541 | } |
501 | 542 | ||
@@ -729,6 +770,12 @@ public class BSPrim : BSPhysObject | |||
729 | return new BSActorSetTorque(PhysScene, this, SetTorqueActorName); | 770 | return new BSActorSetTorque(PhysScene, this, SetTorqueActorName); |
730 | }); | 771 | }); |
731 | DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, RawTorque); | 772 | DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, RawTorque); |
773 | |||
774 | // Call update so actor Refresh() is called to start things off | ||
775 | PhysScene.TaintedObject(LocalID, "BSPrim.setTorque", delegate() | ||
776 | { | ||
777 | UpdatePhysicalParameters(); | ||
778 | }); | ||
732 | } | 779 | } |
733 | } | 780 | } |
734 | public override OMV.Vector3 Acceleration { | 781 | public override OMV.Vector3 Acceleration { |
@@ -1086,13 +1133,27 @@ public class BSPrim : BSPhysObject | |||
1086 | } | 1133 | } |
1087 | } | 1134 | } |
1088 | 1135 | ||
1089 | public override bool PIDActive { | 1136 | public override bool PIDActive |
1090 | set { | 1137 | { |
1091 | base.MoveToTargetActive = value; | 1138 | get |
1139 | { | ||
1140 | return MoveToTargetActive; | ||
1141 | } | ||
1142 | |||
1143 | set | ||
1144 | { | ||
1145 | MoveToTargetActive = value; | ||
1146 | |||
1092 | EnableActor(MoveToTargetActive, MoveToTargetActorName, delegate() | 1147 | EnableActor(MoveToTargetActive, MoveToTargetActorName, delegate() |
1093 | { | 1148 | { |
1094 | return new BSActorMoveToTarget(PhysScene, this, MoveToTargetActorName); | 1149 | return new BSActorMoveToTarget(PhysScene, this, MoveToTargetActorName); |
1095 | }); | 1150 | }); |
1151 | |||
1152 | // Call update so actor Refresh() is called to start things off | ||
1153 | PhysScene.TaintedObject(LocalID, "BSPrim.PIDActive", delegate() | ||
1154 | { | ||
1155 | UpdatePhysicalParameters(); | ||
1156 | }); | ||
1096 | } | 1157 | } |
1097 | } | 1158 | } |
1098 | 1159 | ||
@@ -1119,6 +1180,12 @@ public class BSPrim : BSPhysObject | |||
1119 | { | 1180 | { |
1120 | return new BSActorHover(PhysScene, this, HoverActorName); | 1181 | return new BSActorHover(PhysScene, this, HoverActorName); |
1121 | }); | 1182 | }); |
1183 | |||
1184 | // Call update so actor Refresh() is called to start things off | ||
1185 | PhysScene.TaintedObject(LocalID, "BSPrim.PIDHoverActive", delegate() | ||
1186 | { | ||
1187 | UpdatePhysicalParameters(); | ||
1188 | }); | ||
1122 | } | 1189 | } |
1123 | } | 1190 | } |
1124 | 1191 | ||
@@ -1556,12 +1623,232 @@ public class BSPrim : BSPhysObject | |||
1556 | object ret = null; | 1623 | object ret = null; |
1557 | switch (pFunct) | 1624 | switch (pFunct) |
1558 | { | 1625 | { |
1626 | case ExtendedPhysics.PhysFunctAxisLockLimits: | ||
1627 | ret = SetAxisLockLimitsExtension(pParams); | ||
1628 | break; | ||
1559 | default: | 1629 | default: |
1560 | ret = base.Extension(pFunct, pParams); | 1630 | ret = base.Extension(pFunct, pParams); |
1561 | break; | 1631 | break; |
1562 | } | 1632 | } |
1563 | return ret; | 1633 | return ret; |
1564 | } | 1634 | } |
1635 | |||
1636 | private void InitializeAxisActor() | ||
1637 | { | ||
1638 | EnableActor(LockedAngularAxis != LockedAxisFree || LockedLinearAxis != LockedAxisFree, | ||
1639 | LockedAxisActorName, delegate() | ||
1640 | { | ||
1641 | return new BSActorLockAxis(PhysScene, this, LockedAxisActorName); | ||
1642 | }); | ||
1643 | |||
1644 | // Update parameters so the new actor's Refresh() action is called at the right time. | ||
1645 | PhysScene.TaintedObject(LocalID, "BSPrim.LockAxis", delegate() | ||
1646 | { | ||
1647 | UpdatePhysicalParameters(); | ||
1648 | }); | ||
1649 | } | ||
1650 | |||
1651 | // Passed an array of an array of parameters, set the axis locking. | ||
1652 | // This expects an int (PHYS_AXIS_*) followed by none or two limit floats | ||
1653 | // followed by another int and floats, etc. | ||
1654 | private object SetAxisLockLimitsExtension(object[] pParams) | ||
1655 | { | ||
1656 | DetailLog("{0} SetAxisLockLimitsExtension. parmlen={1}", LocalID, pParams.GetLength(0)); | ||
1657 | object ret = null; | ||
1658 | try | ||
1659 | { | ||
1660 | if (pParams.GetLength(0) > 1) | ||
1661 | { | ||
1662 | int index = 2; | ||
1663 | while (index < pParams.GetLength(0)) | ||
1664 | { | ||
1665 | var funct = pParams[index]; | ||
1666 | DetailLog("{0} SetAxisLockLimitsExtension. op={1}, index={2}", LocalID, funct, index); | ||
1667 | if (funct is Int32 || funct is Int64) | ||
1668 | { | ||
1669 | switch ((int)funct) | ||
1670 | { | ||
1671 | // Those that take no parameters | ||
1672 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR: | ||
1673 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_X: | ||
1674 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Y: | ||
1675 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Z: | ||
1676 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR: | ||
1677 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_X: | ||
1678 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Y: | ||
1679 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Z: | ||
1680 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR: | ||
1681 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_X: | ||
1682 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Y: | ||
1683 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Z: | ||
1684 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR: | ||
1685 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_X: | ||
1686 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Y: | ||
1687 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Z: | ||
1688 | case ExtendedPhysics.PHYS_AXIS_UNLOCK: | ||
1689 | ApplyAxisLimits((int)funct, 0f, 0f); | ||
1690 | index += 1; | ||
1691 | break; | ||
1692 | // Those that take two parameters (the limits) | ||
1693 | case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_X: | ||
1694 | case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Y: | ||
1695 | case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Z: | ||
1696 | case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_X: | ||
1697 | case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Y: | ||
1698 | case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Z: | ||
1699 | ApplyAxisLimits((int)funct, (float)pParams[index + 1], (float)pParams[index + 2]); | ||
1700 | index += 3; | ||
1701 | break; | ||
1702 | default: | ||
1703 | m_log.WarnFormat("{0} SetSxisLockLimitsExtension. Unknown op={1}", LogHeader, funct); | ||
1704 | index += 1; | ||
1705 | break; | ||
1706 | } | ||
1707 | } | ||
1708 | } | ||
1709 | InitializeAxisActor(); | ||
1710 | ret = (object)index; | ||
1711 | } | ||
1712 | } | ||
1713 | catch (Exception e) | ||
1714 | { | ||
1715 | m_log.WarnFormat("{0} SetSxisLockLimitsExtension exception in object {1}: {2}", LogHeader, this.Name, e); | ||
1716 | ret = null; | ||
1717 | } | ||
1718 | return ret; // not implemented yet | ||
1719 | } | ||
1720 | |||
1721 | // Set the locking parameters. | ||
1722 | // If an axis is locked, the limits for the axis are set to zero, | ||
1723 | // If the axis is being constrained, the high and low value are passed and set. | ||
1724 | // When done here, LockedXXXAxis flags are set and LockedXXXAxixLow/High are set to the range. | ||
1725 | protected void ApplyAxisLimits(int funct, float low, float high) | ||
1726 | { | ||
1727 | DetailLog("{0} ApplyAxisLimits. op={1}, low={2}, high={3}", LocalID, funct, low, high); | ||
1728 | float linearMax = 23000f; | ||
1729 | float angularMax = (float)Math.PI; | ||
1730 | |||
1731 | switch (funct) | ||
1732 | { | ||
1733 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR: | ||
1734 | this.LockedLinearAxis = new OMV.Vector3(LockedAxis, LockedAxis, LockedAxis); | ||
1735 | this.LockedLinearAxisLow = OMV.Vector3.Zero; | ||
1736 | this.LockedLinearAxisHigh = OMV.Vector3.Zero; | ||
1737 | break; | ||
1738 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_X: | ||
1739 | this.LockedLinearAxis.X = LockedAxis; | ||
1740 | this.LockedLinearAxisLow.X = 0f; | ||
1741 | this.LockedLinearAxisHigh.X = 0f; | ||
1742 | break; | ||
1743 | case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_X: | ||
1744 | this.LockedLinearAxis.X = LockedAxis; | ||
1745 | this.LockedLinearAxisLow.X = Util.Clip(low, -linearMax, linearMax); | ||
1746 | this.LockedLinearAxisHigh.X = Util.Clip(high, -linearMax, linearMax); | ||
1747 | break; | ||
1748 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Y: | ||
1749 | this.LockedLinearAxis.Y = LockedAxis; | ||
1750 | this.LockedLinearAxisLow.Y = 0f; | ||
1751 | this.LockedLinearAxisHigh.Y = 0f; | ||
1752 | break; | ||
1753 | case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Y: | ||
1754 | this.LockedLinearAxis.Y = LockedAxis; | ||
1755 | this.LockedLinearAxisLow.Y = Util.Clip(low, -linearMax, linearMax); | ||
1756 | this.LockedLinearAxisHigh.Y = Util.Clip(high, -linearMax, linearMax); | ||
1757 | break; | ||
1758 | case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Z: | ||
1759 | this.LockedLinearAxis.Z = LockedAxis; | ||
1760 | this.LockedLinearAxisLow.Z = 0f; | ||
1761 | this.LockedLinearAxisHigh.Z = 0f; | ||
1762 | break; | ||
1763 | case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Z: | ||
1764 | this.LockedLinearAxis.Z = LockedAxis; | ||
1765 | this.LockedLinearAxisLow.Z = Util.Clip(low, -linearMax, linearMax); | ||
1766 | this.LockedLinearAxisHigh.Z = Util.Clip(high, -linearMax, linearMax); | ||
1767 | break; | ||
1768 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR: | ||
1769 | this.LockedAngularAxis = new OMV.Vector3(LockedAxis, LockedAxis, LockedAxis); | ||
1770 | this.LockedAngularAxisLow = OMV.Vector3.Zero; | ||
1771 | this.LockedAngularAxisHigh = OMV.Vector3.Zero; | ||
1772 | break; | ||
1773 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_X: | ||
1774 | this.LockedAngularAxis.X = LockedAxis; | ||
1775 | this.LockedAngularAxisLow.X = 0; | ||
1776 | this.LockedAngularAxisHigh.X = 0; | ||
1777 | break; | ||
1778 | case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_X: | ||
1779 | this.LockedAngularAxis.X = LockedAxis; | ||
1780 | this.LockedAngularAxisLow.X = Util.Clip(low, -angularMax, angularMax); | ||
1781 | this.LockedAngularAxisHigh.X = Util.Clip(high, -angularMax, angularMax); | ||
1782 | break; | ||
1783 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Y: | ||
1784 | this.LockedAngularAxis.Y = LockedAxis; | ||
1785 | this.LockedAngularAxisLow.Y = 0; | ||
1786 | this.LockedAngularAxisHigh.Y = 0; | ||
1787 | break; | ||
1788 | case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Y: | ||
1789 | this.LockedAngularAxis.Y = LockedAxis; | ||
1790 | this.LockedAngularAxisLow.Y = Util.Clip(low, -angularMax, angularMax); | ||
1791 | this.LockedAngularAxisHigh.Y = Util.Clip(high, -angularMax, angularMax); | ||
1792 | break; | ||
1793 | case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Z: | ||
1794 | this.LockedAngularAxis.Z = LockedAxis; | ||
1795 | this.LockedAngularAxisLow.Z = 0; | ||
1796 | this.LockedAngularAxisHigh.Z = 0; | ||
1797 | break; | ||
1798 | case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Z: | ||
1799 | this.LockedAngularAxis.Z = LockedAxis; | ||
1800 | this.LockedAngularAxisLow.Z = Util.Clip(low, -angularMax, angularMax); | ||
1801 | this.LockedAngularAxisHigh.Z = Util.Clip(high, -angularMax, angularMax); | ||
1802 | break; | ||
1803 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR: | ||
1804 | this.LockedLinearAxis = LockedAxisFree; | ||
1805 | this.LockedLinearAxisLow = new OMV.Vector3(-linearMax, -linearMax, -linearMax); | ||
1806 | this.LockedLinearAxisHigh = new OMV.Vector3(linearMax, linearMax, linearMax); | ||
1807 | break; | ||
1808 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_X: | ||
1809 | this.LockedLinearAxis.X = FreeAxis; | ||
1810 | this.LockedLinearAxisLow.X = -linearMax; | ||
1811 | this.LockedLinearAxisHigh.X = linearMax; | ||
1812 | break; | ||
1813 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Y: | ||
1814 | this.LockedLinearAxis.Y = FreeAxis; | ||
1815 | this.LockedLinearAxisLow.Y = -linearMax; | ||
1816 | this.LockedLinearAxisHigh.Y = linearMax; | ||
1817 | break; | ||
1818 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Z: | ||
1819 | this.LockedLinearAxis.Z = FreeAxis; | ||
1820 | this.LockedLinearAxisLow.Z = -linearMax; | ||
1821 | this.LockedLinearAxisHigh.Z = linearMax; | ||
1822 | break; | ||
1823 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR: | ||
1824 | this.LockedAngularAxis = LockedAxisFree; | ||
1825 | this.LockedAngularAxisLow = new OMV.Vector3(-angularMax, -angularMax, -angularMax); | ||
1826 | this.LockedAngularAxisHigh = new OMV.Vector3(angularMax, angularMax, angularMax); | ||
1827 | break; | ||
1828 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_X: | ||
1829 | this.LockedAngularAxis.X = FreeAxis; | ||
1830 | this.LockedAngularAxisLow.X = -angularMax; | ||
1831 | this.LockedAngularAxisHigh.X = angularMax; | ||
1832 | break; | ||
1833 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Y: | ||
1834 | this.LockedAngularAxis.Y = FreeAxis; | ||
1835 | this.LockedAngularAxisLow.Y = -angularMax; | ||
1836 | this.LockedAngularAxisHigh.Y = angularMax; | ||
1837 | break; | ||
1838 | case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Z: | ||
1839 | this.LockedAngularAxis.Z = FreeAxis; | ||
1840 | this.LockedAngularAxisLow.Z = -angularMax; | ||
1841 | this.LockedAngularAxisHigh.Z = angularMax; | ||
1842 | break; | ||
1843 | case ExtendedPhysics.PHYS_AXIS_UNLOCK: | ||
1844 | ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR, 0f, 0f); | ||
1845 | ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR, 0f, 0f); | ||
1846 | break; | ||
1847 | default: | ||
1848 | break; | ||
1849 | } | ||
1850 | return; | ||
1851 | } | ||
1565 | #endregion // Extension | 1852 | #endregion // Extension |
1566 | 1853 | ||
1567 | // The physics engine says that properties have updated. Update same and inform | 1854 | // The physics engine says that properties have updated. Update same and inform |