diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 1754be6..af403aa 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -173,20 +173,16 @@ public sealed class BSPrim : BSPhysObject | |||
173 | } | 173 | } |
174 | // Whatever the linkset wants is what I want. | 174 | // Whatever the linkset wants is what I want. |
175 | public override ShapeData.PhysicsShapeType PreferredPhysicalShape | 175 | public override ShapeData.PhysicsShapeType PreferredPhysicalShape |
176 | { get { return Linkset.PreferredPhysicalShape; } } | 176 | { get { return Linkset.PreferredPhysicalShape(this); } } |
177 | 177 | ||
178 | public override bool ForceBodyShapeRebuild(bool inTaintTime) | 178 | public override bool ForceBodyShapeRebuild(bool inTaintTime) |
179 | { | 179 | { |
180 | LastAssetBuildFailed = false; | 180 | LastAssetBuildFailed = false; |
181 | BSScene.TaintCallback rebuildOperation = delegate() | 181 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() |
182 | { | 182 | { |
183 | _mass = CalculateMass(); // changing the shape changes the mass | 183 | _mass = CalculateMass(); // changing the shape changes the mass |
184 | CreateGeomAndObject(true); | 184 | CreateGeomAndObject(true); |
185 | }; | 185 | }); |
186 | if (inTaintTime) | ||
187 | rebuildOperation(); | ||
188 | else | ||
189 | PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", rebuildOperation); | ||
190 | return true; | 186 | return true; |
191 | } | 187 | } |
192 | public override bool Grabbed { | 188 | public override bool Grabbed { |
@@ -263,9 +259,9 @@ public sealed class BSPrim : BSPhysObject | |||
263 | } | 259 | } |
264 | public override OMV.Vector3 Position { | 260 | public override OMV.Vector3 Position { |
265 | get { | 261 | get { |
262 | // child prims move around based on their parent. Need to get the latest location | ||
266 | if (!Linkset.IsRoot(this)) | 263 | if (!Linkset.IsRoot(this)) |
267 | // child prims move around based on their parent. Need to get the latest location | 264 | _position = Linkset.Position(this); |
268 | _position = BulletSimAPI.GetPosition2(PhysBody.ptr); | ||
269 | 265 | ||
270 | // don't do the GetObjectPosition for root elements because this function is called a zillion times | 266 | // don't do the GetObjectPosition for root elements because this function is called a zillion times |
271 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 267 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); |
@@ -344,16 +340,11 @@ public sealed class BSPrim : BSPhysObject | |||
344 | { | 340 | { |
345 | // The new position value must be pushed into the physics engine but we can't | 341 | // The new position value must be pushed into the physics engine but we can't |
346 | // just assign to "Position" because of potential call loops. | 342 | // just assign to "Position" because of potential call loops. |
347 | BSScene.TaintCallback sanityOperation = delegate() | 343 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.PositionSanityCheck", delegate() |
348 | { | 344 | { |
349 | DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 345 | DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
350 | ForcePosition = _position; | 346 | ForcePosition = _position; |
351 | }; | 347 | }); |
352 | if (inTaintTime) | ||
353 | sanityOperation(); | ||
354 | else | ||
355 | PhysicsScene.TaintedObject("BSPrim.PositionSanityCheck", sanityOperation); | ||
356 | |||
357 | ret = true; | 348 | ret = true; |
358 | } | 349 | } |
359 | return ret; | 350 | return ret; |
@@ -542,10 +533,10 @@ public sealed class BSPrim : BSPhysObject | |||
542 | } | 533 | } |
543 | public override OMV.Quaternion Orientation { | 534 | public override OMV.Quaternion Orientation { |
544 | get { | 535 | get { |
536 | // Children move around because tied to parent. Get a fresh value. | ||
545 | if (!Linkset.IsRoot(this)) | 537 | if (!Linkset.IsRoot(this)) |
546 | { | 538 | { |
547 | // Children move around because tied to parent. Get a fresh value. | 539 | _orientation = Linkset.Orientation(this); |
548 | _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); | ||
549 | } | 540 | } |
550 | return _orientation; | 541 | return _orientation; |
551 | } | 542 | } |
@@ -946,7 +937,7 @@ public sealed class BSPrim : BSPhysObject | |||
946 | m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); | 937 | m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); |
947 | return; | 938 | return; |
948 | } | 939 | } |
949 | BSScene.TaintCallback addForceOperation = delegate() | 940 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() |
950 | { | 941 | { |
951 | OMV.Vector3 fSum = OMV.Vector3.Zero; | 942 | OMV.Vector3 fSum = OMV.Vector3.Zero; |
952 | lock (m_accumulatedForces) | 943 | lock (m_accumulatedForces) |
@@ -961,11 +952,7 @@ public sealed class BSPrim : BSPhysObject | |||
961 | DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum); | 952 | DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum); |
962 | if (fSum != OMV.Vector3.Zero) | 953 | if (fSum != OMV.Vector3.Zero) |
963 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum); | 954 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum); |
964 | }; | 955 | }); |
965 | if (inTaintTime) | ||
966 | addForceOperation(); | ||
967 | else | ||
968 | PhysicsScene.TaintedObject("BSPrim.AddForce", addForceOperation); | ||
969 | } | 956 | } |
970 | 957 | ||
971 | private List<OMV.Vector3> m_accumulatedAngularForces = new List<OMV.Vector3>(); | 958 | private List<OMV.Vector3> m_accumulatedAngularForces = new List<OMV.Vector3>(); |
@@ -985,7 +972,7 @@ public sealed class BSPrim : BSPhysObject | |||
985 | m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); | 972 | m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); |
986 | return; | 973 | return; |
987 | } | 974 | } |
988 | BSScene.TaintCallback addAngularForceOperation = delegate() | 975 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate() |
989 | { | 976 | { |
990 | OMV.Vector3 fSum = OMV.Vector3.Zero; | 977 | OMV.Vector3 fSum = OMV.Vector3.Zero; |
991 | lock (m_accumulatedAngularForces) | 978 | lock (m_accumulatedAngularForces) |
@@ -1003,26 +990,19 @@ public sealed class BSPrim : BSPhysObject | |||
1003 | BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum); | 990 | BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum); |
1004 | _torque = fSum; | 991 | _torque = fSum; |
1005 | } | 992 | } |
1006 | }; | 993 | }); |
1007 | if (inTaintTime) | ||
1008 | addAngularForceOperation(); | ||
1009 | else | ||
1010 | PhysicsScene.TaintedObject("BSPrim.AddAngularForce", addAngularForceOperation); | ||
1011 | } | 994 | } |
1012 | // A torque impulse. | 995 | // A torque impulse. |
1013 | public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) | 996 | public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) |
1014 | { | 997 | { |
1015 | OMV.Vector3 applyImpulse = impulse; | 998 | OMV.Vector3 applyImpulse = impulse; |
1016 | BSScene.TaintCallback applyTorqueImpulseOperation = delegate() | 999 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() |
1017 | { | 1000 | { |
1018 | DetailLog("{0},BSPrim.ApplyTorqueImpulse,taint,tImpulse={1}", LocalID, applyImpulse); | 1001 | DetailLog("{0},BSPrim.ApplyTorqueImpulse,taint,tImpulse={1}", LocalID, applyImpulse); |
1019 | BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse); | 1002 | BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse); |
1020 | }; | 1003 | }); |
1021 | if (inTaintTime) | ||
1022 | applyTorqueImpulseOperation(); | ||
1023 | else | ||
1024 | PhysicsScene.TaintedObject("BSPrim.ApplyTorqueImpulse", applyTorqueImpulseOperation); | ||
1025 | } | 1004 | } |
1005 | |||
1026 | public override void SetMomentum(OMV.Vector3 momentum) { | 1006 | public override void SetMomentum(OMV.Vector3 momentum) { |
1027 | // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); | 1007 | // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); |
1028 | } | 1008 | } |