diff options
author | Robert Adams | 2013-07-22 12:10:23 -0700 |
---|---|---|
committer | Robert Adams | 2013-07-22 12:10:23 -0700 |
commit | 44543ebe638f391fc1c7ff532fe4470006dec55a (patch) | |
tree | 5e1e584eb5ce90ccebec9e2584af688359e3d8ee /OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | |
parent | Revert "Add experimental stubs for an extension function interface on both" (diff) | |
download | opensim-SC-44543ebe638f391fc1c7ff532fe4470006dec55a.zip opensim-SC-44543ebe638f391fc1c7ff532fe4470006dec55a.tar.gz opensim-SC-44543ebe638f391fc1c7ff532fe4470006dec55a.tar.bz2 opensim-SC-44543ebe638f391fc1c7ff532fe4470006dec55a.tar.xz |
Revert "BulletSim: freshen up the code for constraint based linksets."
The changes don't seem to be ready for prime time.
This reverts commit 803632f8f32d91bb4aec678d8b45a8430c2703e1.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 82 |
1 files changed, 21 insertions, 61 deletions
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 | } |