aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs1
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs82
3 files changed, 23 insertions, 64 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 4c2c1c1..0204967 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -1029,8 +1029,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1029 // Add this correction to the velocity to make it faster/slower. 1029 // Add this correction to the velocity to make it faster/slower.
1030 VehicleVelocity += linearMotorVelocityW; 1030 VehicleVelocity += linearMotorVelocityW;
1031 1031
1032 VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},tgt={3},correctV={4},correctW={5},newVelW={6},fricFact={7}", 1032 VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6}",
1033 ControllingPrim.LocalID, origVelW, currentVelV, m_linearMotor.TargetValue, linearMotorCorrectionV, 1033 ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV,
1034 linearMotorVelocityW, VehicleVelocity, frictionFactorV); 1034 linearMotorVelocityW, VehicleVelocity, frictionFactorV);
1035 } 1035 }
1036 1036
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 3668456..1d94142 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -59,7 +59,6 @@ public sealed class BSLinksetCompound : BSLinkset
59 { 59 {
60 DetailLog("{0},BSLinksetCompound.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", 60 DetailLog("{0},BSLinksetCompound.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}",
61 requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); 61 requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren));
62
63 // When rebuilding, it is possible to set properties that would normally require a rebuild. 62 // When rebuilding, it is possible to set properties that would normally require a rebuild.
64 // If already rebuilding, don't request another rebuild. 63 // If already rebuilding, don't request another rebuild.
65 // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. 64 // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index f17d698..a06a44d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -48,22 +48,12 @@ public sealed class BSLinksetConstraints : BSLinkset
48 { 48 {
49 base.Refresh(requestor); 49 base.Refresh(requestor);
50 50
51 } 51 if (HasAnyChildren && IsRoot(requestor))
52
53 private void ScheduleRebuild(BSPrimLinkable requestor)
54 {
55 DetailLog("{0},BSLinksetConstraint.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}",
56 requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren));
57
58 // When rebuilding, it is possible to set properties that would normally require a rebuild.
59 // If already rebuilding, don't request another rebuild.
60 // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding.
61 if (!Rebuilding && HasAnyChildren)
62 { 52 {
63 // Queue to happen after all the other taint processing 53 // Queue to happen after all the other taint processing
64 m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() 54 m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate()
65 { 55 {
66 if (HasAnyChildren) 56 if (HasAnyChildren && IsRoot(requestor))
67 RecomputeLinksetConstraints(); 57 RecomputeLinksetConstraints();
68 }); 58 });
69 } 59 }
@@ -77,14 +67,8 @@ public sealed class BSLinksetConstraints : BSLinkset
77 // Called at taint-time! 67 // Called at taint-time!
78 public override bool MakeDynamic(BSPrimLinkable child) 68 public override bool MakeDynamic(BSPrimLinkable child)
79 { 69 {
80 bool ret = false; 70 // What is done for each object in BSPrim is what we want.
81 DetailLog("{0},BSLinksetConstraints.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); 71 return false;
82 if (IsRoot(child))
83 {
84 // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly.
85 ScheduleRebuild(LinksetRoot);
86 }
87 return ret;
88 } 72 }
89 73
90 // The object is going static (non-physical). Do any setup necessary for a static linkset. 74 // The object is going static (non-physical). Do any setup necessary for a static linkset.
@@ -94,16 +78,8 @@ public sealed class BSLinksetConstraints : BSLinkset
94 // Called at taint-time! 78 // Called at taint-time!
95 public override bool MakeStatic(BSPrimLinkable child) 79 public override bool MakeStatic(BSPrimLinkable child)
96 { 80 {
97 bool ret = false; 81 // What is done for each object in BSPrim is what we want.
98 82 return false;
99 DetailLog("{0},BSLinksetConstraint.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child));
100 child.ClearDisplacement();
101 if (IsRoot(child))
102 {
103 // Schedule a rebuild to verify that the root shape is set to the real shape.
104 ScheduleRebuild(LinksetRoot);
105 }
106 return ret;
107 } 83 }
108 84
109 // Called at taint-time!! 85 // Called at taint-time!!
@@ -129,7 +105,7 @@ public sealed class BSLinksetConstraints : BSLinkset
129 // Just undo all the constraints for this linkset. Rebuild at the end of the step. 105 // Just undo all the constraints for this linkset. Rebuild at the end of the step.
130 ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); 106 ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot);
131 // Cause the constraints, et al to be rebuilt before the next simulation step. 107 // Cause the constraints, et al to be rebuilt before the next simulation step.
132 ScheduleRebuild(LinksetRoot); 108 Refresh(LinksetRoot);
133 } 109 }
134 return ret; 110 return ret;
135 } 111 }
@@ -147,7 +123,7 @@ public sealed class BSLinksetConstraints : BSLinkset
147 DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); 123 DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID);
148 124
149 // Cause constraints and assorted properties to be recomputed before the next simulation step. 125 // Cause constraints and assorted properties to be recomputed before the next simulation step.
150 ScheduleRebuild(LinksetRoot); 126 Refresh(LinksetRoot);
151 } 127 }
152 return; 128 return;
153 } 129 }
@@ -171,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset
171 PhysicallyUnlinkAChildFromRoot(rootx, childx); 147 PhysicallyUnlinkAChildFromRoot(rootx, childx);
172 }); 148 });
173 // See that the linkset parameters are recomputed at the end of the taint time. 149 // See that the linkset parameters are recomputed at the end of the taint time.
174 ScheduleRebuild(LinksetRoot); 150 Refresh(LinksetRoot);
175 } 151 }
176 else 152 else
177 { 153 {
@@ -189,7 +165,6 @@ public sealed class BSLinksetConstraints : BSLinkset
189 Refresh(rootPrim); 165 Refresh(rootPrim);
190 } 166 }
191 167
192 // Create a static constraint between the two passed objects
193 private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) 168 private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim)
194 { 169 {
195 // Zero motion for children so they don't interpolate 170 // Zero motion for children so they don't interpolate
@@ -306,39 +281,24 @@ public sealed class BSLinksetConstraints : BSLinkset
306 DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", 281 DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}",
307 LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); 282 LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass);
308 283
309 try 284 foreach (BSPrimLinkable child in m_children)
310 { 285 {
311 Rebuilding = true; 286 // A child in the linkset physically shows the mass of the whole linkset.
287 // This allows Bullet to apply enough force on the child to move the whole linkset.
288 // (Also do the mass stuff before recomputing the constraint so mass is not zero.)
289 child.UpdatePhysicalMassProperties(linksetMass, true);
312 290
313 // There is no reason to build all this physical stuff for a non-physical linkset. 291 BSConstraint constrain;
314 if (!LinksetRoot.IsPhysicallyActive) 292 if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain))
315 { 293 {
316 DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); 294 // If constraint doesn't exist yet, create it.
317 return; // Note the 'finally' clause at the botton which will get executed. 295 constrain = BuildConstraint(LinksetRoot, child);
318 } 296 }
297 constrain.RecomputeConstraintVariables(linksetMass);
319 298
320 foreach (BSPrimLinkable child in m_children) 299 // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG
321 {
322 // A child in the linkset physically shows the mass of the whole linkset.
323 // This allows Bullet to apply enough force on the child to move the whole linkset.
324 // (Also do the mass stuff before recomputing the constraint so mass is not zero.)
325 child.UpdatePhysicalMassProperties(linksetMass, true);
326
327 BSConstraint constrain;
328 if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain))
329 {
330 // If constraint doesn't exist yet, create it.
331 constrain = BuildConstraint(LinksetRoot, child);
332 }
333 constrain.RecomputeConstraintVariables(linksetMass);
334
335 // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG
336 }
337 }
338 finally
339 {
340 Rebuilding = false;
341 } 300 }
301
342 } 302 }
343} 303}
344} 304}