diff options
author | Robert Adams | 2012-07-23 13:49:31 -0700 |
---|---|---|
committer | Robert Adams | 2012-07-23 16:32:41 -0700 |
commit | dda681515b31e528ae01954a583cd7a7b4e94987 (patch) | |
tree | ee9e1405f56a9d6ba94a6f1ee7b14f8ee860dddf /OpenSim/Region/Physics/BulletSPlugin | |
parent | BulletSim: add Dispose() code to free up resources and close log files. (diff) | |
download | opensim-SC-dda681515b31e528ae01954a583cd7a7b4e94987.zip opensim-SC-dda681515b31e528ae01954a583cd7a7b4e94987.tar.gz opensim-SC-dda681515b31e528ae01954a583cd7a7b4e94987.tar.bz2 opensim-SC-dda681515b31e528ae01954a583cd7a7b4e94987.tar.xz |
BulletSim: small optimizations for link and unlink code
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 29ddddd..b49b8d9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -293,7 +293,7 @@ public sealed class BSPrim : PhysicsActor | |||
293 | if (_childrenPrims.Contains(child)) | 293 | if (_childrenPrims.Contains(child)) |
294 | { | 294 | { |
295 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); | 295 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); |
296 | DetailLog("{0},RemoveChildToLinkset,child={1}", LocalID, pchild.LocalID); | 296 | DetailLog("{0},RemoveChildFromLinkset,child={1}", LocalID, pchild.LocalID); |
297 | _childrenPrims.Remove(child); | 297 | _childrenPrims.Remove(child); |
298 | child._parentPrim = null; // the child has lost its parent | 298 | child._parentPrim = null; // the child has lost its parent |
299 | if (_childrenPrims.Count == 0) | 299 | if (_childrenPrims.Count == 0) |
@@ -331,14 +331,12 @@ public sealed class BSPrim : PhysicsActor | |||
331 | _acceleration = OMV.Vector3.Zero; | 331 | _acceleration = OMV.Vector3.Zero; |
332 | _rotationalVelocity = OMV.Vector3.Zero; | 332 | _rotationalVelocity = OMV.Vector3.Zero; |
333 | 333 | ||
334 | // Zero some other properties directly into the physics engine | ||
334 | IntPtr obj = BulletSimAPI.GetBodyHandleWorldID2(_scene.WorldID, LocalID); | 335 | IntPtr obj = BulletSimAPI.GetBodyHandleWorldID2(_scene.WorldID, LocalID); |
335 | BulletSimAPI.SetVelocity2(obj, OMV.Vector3.Zero); | 336 | BulletSimAPI.SetVelocity2(obj, OMV.Vector3.Zero); |
336 | BulletSimAPI.SetAngularVelocity2(obj, OMV.Vector3.Zero); | 337 | BulletSimAPI.SetAngularVelocity2(obj, OMV.Vector3.Zero); |
337 | BulletSimAPI.SetInterpolation2(obj, OMV.Vector3.Zero, OMV.Vector3.Zero); | 338 | BulletSimAPI.SetInterpolation2(obj, OMV.Vector3.Zero, OMV.Vector3.Zero); |
338 | BulletSimAPI.ClearForces2(obj); | 339 | BulletSimAPI.ClearForces2(obj); |
339 | |||
340 | // make sure this new information is pushed to the client | ||
341 | base.RequestPhysicsterseUpdate(); | ||
342 | } | 340 | } |
343 | 341 | ||
344 | public override void LockAngularMotion(OMV.Vector3 axis) | 342 | public override void LockAngularMotion(OMV.Vector3 axis) |
@@ -1253,7 +1251,7 @@ public sealed class BSPrim : PhysicsActor | |||
1253 | if (IsRootOfLinkset) | 1251 | if (IsRootOfLinkset) |
1254 | { | 1252 | { |
1255 | // Create a linkset around this object | 1253 | // Create a linkset around this object |
1256 | CreateLinksetWithConstraints(); | 1254 | CreateLinkset(); |
1257 | } | 1255 | } |
1258 | else | 1256 | else |
1259 | { | 1257 | { |
@@ -1289,16 +1287,14 @@ public sealed class BSPrim : PhysicsActor | |||
1289 | 1287 | ||
1290 | // Create the linkset by putting constraints between the objects of the set so they cannot move | 1288 | // Create the linkset by putting constraints between the objects of the set so they cannot move |
1291 | // relative to each other. | 1289 | // relative to each other. |
1292 | void CreateLinksetWithConstraints() | 1290 | void CreateLinkset() |
1293 | { | 1291 | { |
1294 | DebugLog("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, _childrenPrims.Count+1); | 1292 | DebugLog("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, _childrenPrims.Count+1); |
1295 | 1293 | ||
1296 | // remove any constraints that might be in place | 1294 | // remove any constraints that might be in place |
1297 | foreach (BSPrim prim in _childrenPrims) | 1295 | DebugLog("{0}: CreateLinkset: RemoveConstraints between me and any children", LogHeader, LocalID); |
1298 | { | 1296 | BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID); |
1299 | DebugLog("{0}: CreateLinkset: RemoveConstraint between root prim {1} and child prim {2}", LogHeader, LocalID, prim.LocalID); | 1297 | |
1300 | BulletSimAPI.RemoveConstraint(_scene.WorldID, LocalID, prim.LocalID); | ||
1301 | } | ||
1302 | // create constraints between the root prim and each of the children | 1298 | // create constraints between the root prim and each of the children |
1303 | foreach (BSPrim prim in _childrenPrims) | 1299 | foreach (BSPrim prim in _childrenPrims) |
1304 | { | 1300 | { |
@@ -1430,7 +1426,7 @@ public sealed class BSPrim : PhysicsActor | |||
1430 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. | 1426 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. |
1431 | 1427 | ||
1432 | // Updates only for individual prims and for the root object of a linkset. | 1428 | // Updates only for individual prims and for the root object of a linkset. |
1433 | if (this._parentPrim == null) | 1429 | if (_parentPrim == null) |
1434 | { | 1430 | { |
1435 | // Assign to the local variables so the normal set action does not happen | 1431 | // Assign to the local variables so the normal set action does not happen |
1436 | _position = entprop.Position; | 1432 | _position = entprop.Position; |