aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs106
1 files changed, 80 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 638fae1..8b97ebb 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -41,18 +41,31 @@ public sealed class BSLinksetCompound : BSLinkset
41 base.Initialize(scene, parent); 41 base.Initialize(scene, parent);
42 } 42 }
43 43
44 // For compound implimented linksets, if there are children, use compound shape for the root.
45 public override ShapeData.PhysicsShapeType PreferredPhysicalShape(BSPhysObject requestor)
46 {
47 ShapeData.PhysicsShapeType ret = ShapeData.PhysicsShapeType.SHAPE_UNKNOWN;
48 if (IsRoot(requestor) && HasAnyChildren)
49 {
50 ret = ShapeData.PhysicsShapeType.SHAPE_COMPOUND;
51 }
52 // DetailLog("{0},BSLinksetCompound.PreferredPhysicalShape,call,shape={1}", LinksetRoot.LocalID, ret);
53 return ret;
54 }
55
44 // When physical properties are changed the linkset needs to recalculate 56 // When physical properties are changed the linkset needs to recalculate
45 // its internal properties. 57 // its internal properties.
46 // This is queued in the 'post taint' queue so the 58 // This is queued in the 'post taint' queue so the
47 // refresh will happen once after all the other taints are applied. 59 // refresh will happen once after all the other taints are applied.
48 public override void Refresh(BSPhysObject requestor) 60 public override void Refresh(BSPhysObject requestor)
49 { 61 {
62 DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,requestor={1}", LinksetRoot.LocalID, requestor.LocalID);
50 // Queue to happen after all the other taint processing 63 // Queue to happen after all the other taint processing
51 PhysicsScene.PostTaintObject("BSLinksetcompound.Refresh", requestor.LocalID, delegate() 64 PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", requestor.LocalID, delegate()
52 { 65 {
53 if (HasAnyChildren && IsRoot(requestor)) 66 if (IsRoot(requestor) && HasAnyChildren)
54 RecomputeLinksetCompound(); 67 RecomputeLinksetCompound();
55 }); 68 });
56 } 69 }
57 70
58 // The object is going dynamic (physical). Do any setup necessary 71 // The object is going dynamic (physical). Do any setup necessary
@@ -63,8 +76,17 @@ public sealed class BSLinksetCompound : BSLinkset
63 // Called at taint-time! 76 // Called at taint-time!
64 public override bool MakeDynamic(BSPhysObject child) 77 public override bool MakeDynamic(BSPhysObject child)
65 { 78 {
66 // What is done for each object in BSPrim is what we want. 79 bool ret = false;
67 return false; 80 DetailLog("{0},BSLinksetCompound.MakeDynamic,call,isChild={1}", child.LocalID, HasChild(child));
81 if (HasChild(child))
82 {
83 // Physical children are removed from the world as the shape ofthe root compound
84 // shape takes over.
85 BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
86 BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION);
87 ret = true;
88 }
89 return ret;
68 } 90 }
69 91
70 // The object is going static (non-physical). Do any setup necessary for a static linkset. 92 // The object is going static (non-physical). Do any setup necessary for a static linkset.
@@ -74,8 +96,17 @@ public sealed class BSLinksetCompound : BSLinkset
74 // Called at taint-time! 96 // Called at taint-time!
75 public override bool MakeStatic(BSPhysObject child) 97 public override bool MakeStatic(BSPhysObject child)
76 { 98 {
77 // What is done for each object in BSPrim is what we want. 99 bool ret = false;
78 return false; 100 DetailLog("{0},BSLinksetCompound.MakeStatic,call,hasChild={1}", child.LocalID, HasChild(child));
101 if (HasChild(child))
102 {
103 // The non-physical children can come back to life.
104 BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
105 // Don't force activation so setting of DISABLE_SIMULATION can stay.
106 BulletSimAPI.Activate2(child.PhysBody.ptr, false);
107 ret = true;
108 }
109 return ret;
79 } 110 }
80 111
81 // Called at taint-time!! 112 // Called at taint-time!!
@@ -84,20 +115,35 @@ public sealed class BSLinksetCompound : BSLinkset
84 // Nothing to do for constraints on property updates 115 // Nothing to do for constraints on property updates
85 } 116 }
86 117
118 // The children move around in relationship to the root.
119 // Just grab the current values of wherever it is right now.
120 public override OMV.Vector3 Position(BSPhysObject member)
121 {
122 return BulletSimAPI.GetPosition2(member.PhysBody.ptr);
123 }
124
125 public override OMV.Quaternion Orientation(BSPhysObject member)
126 {
127 return BulletSimAPI.GetOrientation2(member.PhysBody.ptr);
128 }
129
87 // Routine called when rebuilding the body of some member of the linkset. 130 // Routine called when rebuilding the body of some member of the linkset.
88 // Destroy all the constraints have have been made to root and set 131 // Since we don't keep in-physical world relationships, do nothing unless it's a child changing.
89 // up to rebuild the constraints before the next simulation step.
90 // Returns 'true' of something was actually removed and would need restoring 132 // Returns 'true' of something was actually removed and would need restoring
91 // Called at taint-time!! 133 // Called at taint-time!!
92 public override bool RemoveBodyDependencies(BSPrim child) 134 public override bool RemoveBodyDependencies(BSPrim child)
93 { 135 {
94 bool ret = false; 136 bool ret = false;
95 137
96 DetailLog("{0},BSLinksetcompound.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", 138 DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2},isRoot={3}",
97 child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X")); 139 child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), IsRoot(child));
98 140
99 // Cause the current shape to be freed and the new one to be built. 141 if (!IsRoot(child))
100 Refresh(LinksetRoot); 142 {
143 // Cause the current shape to be freed and the new one to be built.
144 Refresh(LinksetRoot);
145 ret = true;
146 }
101 147
102 return ret; 148 return ret;
103 } 149 }
@@ -139,13 +185,19 @@ public sealed class BSLinksetCompound : BSLinkset
139 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), 185 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"),
140 child.LocalID, child.PhysBody.ptr.ToString("X")); 186 child.LocalID, child.PhysBody.ptr.ToString("X"));
141 187
142 // See that the linkset parameters are recomputed at the end of the taint time. 188 // Cause the child's body to be rebuilt and thus restored to normal operation
143 Refresh(LinksetRoot); 189 child.ForceBodyShapeRebuild(false);
144 } 190
145 else 191 if (!HasAnyChildren)
146 { 192 {
147 // Non-fatal occurance. 193 // The linkset is now empty. The root needs rebuilding.
148 // PhysicsScene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader); 194 LinksetRoot.ForceBodyShapeRebuild(false);
195 }
196 else
197 {
198 // Schedule a rebuild of the linkset before the next simulation tick.
199 Refresh(LinksetRoot);
200 }
149 } 201 }
150 return; 202 return;
151 } 203 }
@@ -158,16 +210,18 @@ public sealed class BSLinksetCompound : BSLinkset
158 // Called at taint time!! 210 // Called at taint time!!
159 private void RecomputeLinksetCompound() 211 private void RecomputeLinksetCompound()
160 { 212 {
161 // Release the existing shape 213 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,start,rBody={1},numChildren={2}",
162 PhysicsScene.Shapes.DereferenceShape(LinksetRoot.PhysShape, true, null); 214 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), NumberOfChildren);
163 215
216 LinksetRoot.ForceBodyShapeRebuild(true);
217
164 float linksetMass = LinksetMass; 218 float linksetMass = LinksetMass;
165 LinksetRoot.UpdatePhysicalMassProperties(linksetMass); 219 LinksetRoot.UpdatePhysicalMassProperties(linksetMass);
166 220
167 // DEBUG: see of inter-linkset collisions are causing problems 221 // DEBUG: see of inter-linkset collisions are causing problems
168 // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, 222 // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr,
169 // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); 223 // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
170 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,set,rBody={1},linksetMass={2}", 224 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,end,rBody={1},linksetMass={2}",
171 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), linksetMass); 225 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), linksetMass);
172 226
173 227