aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs64
1 files changed, 34 insertions, 30 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 2189468..4d4f712 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -28,6 +28,8 @@ using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30 30
31using OpenSim.Framework;
32
31using OMV = OpenMetaverse; 33using OMV = OpenMetaverse;
32 34
33namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.Physics.BulletSPlugin
@@ -45,6 +47,11 @@ sealed class BSLinksetCompoundInfo : BSLinksetInfo
45 OffsetPos = p; 47 OffsetPos = p;
46 OffsetRot = r; 48 OffsetRot = r;
47 } 49 }
50 public override void Clear()
51 {
52 OffsetPos = OMV.Vector3.Zero;
53 OffsetRot = OMV.Quaternion.Identity;
54 }
48 public override string ToString() 55 public override string ToString()
49 { 56 {
50 StringBuilder buff = new StringBuilder(); 57 StringBuilder buff = new StringBuilder();
@@ -82,22 +89,22 @@ public sealed class BSLinksetCompound : BSLinkset
82 // its internal properties. 89 // its internal properties.
83 public override void Refresh(BSPhysObject requestor) 90 public override void Refresh(BSPhysObject requestor)
84 { 91 {
85 // External request for Refresh (from BSPrim) doesn't need to do anything 92 // Something changed so do the rebuilding thing
86 // InternalRefresh(requestor); 93 // ScheduleRebuild();
87 } 94 }
88 95
89 // Schedule a refresh to happen after all the other taint processing. 96 // Schedule a refresh to happen after all the other taint processing.
90 private void InternalRefresh(BSPhysObject requestor) 97 private void ScheduleRebuild()
91 { 98 {
92 DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,requestor={1},rebuilding={2}", 99 DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,rebuilding={1}",
93 LinksetRoot.LocalID, requestor.LocalID, Rebuilding); 100 LinksetRoot.LocalID, Rebuilding);
94 // When rebuilding, it is possible to set properties that would normally require a rebuild. 101 // When rebuilding, it is possible to set properties that would normally require a rebuild.
95 // If already rebuilding, don't request another rebuild. 102 // If already rebuilding, don't request another rebuild.
96 if (!Rebuilding) 103 if (!Rebuilding)
97 { 104 {
98 PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", requestor.LocalID, delegate() 105 PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", LinksetRoot.LocalID, delegate()
99 { 106 {
100 if (IsRoot(requestor) && HasAnyChildren) 107 if (HasAnyChildren)
101 RecomputeLinksetCompound(); 108 RecomputeLinksetCompound();
102 }); 109 });
103 } 110 }
@@ -117,8 +124,7 @@ public sealed class BSLinksetCompound : BSLinkset
117 { 124 {
118 // The root is going dynamic. Make sure mass is properly set. 125 // The root is going dynamic. Make sure mass is properly set.
119 m_mass = ComputeLinksetMass(); 126 m_mass = ComputeLinksetMass();
120 if (HasAnyChildren) 127 ScheduleRebuild();
121 InternalRefresh(LinksetRoot);
122 } 128 }
123 else 129 else
124 { 130 {
@@ -147,8 +153,7 @@ public sealed class BSLinksetCompound : BSLinkset
147 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); 153 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child));
148 if (IsRoot(child)) 154 if (IsRoot(child))
149 { 155 {
150 if (HasAnyChildren) 156 ScheduleRebuild();
151 InternalRefresh(LinksetRoot);
152 } 157 }
153 else 158 else
154 { 159 {
@@ -164,22 +169,21 @@ public sealed class BSLinksetCompound : BSLinkset
164 return ret; 169 return ret;
165 } 170 }
166 171
167 // Called at taint-time!! 172 public override void UpdateProperties(BSPhysObject updated, bool physicalUpdate)
168 public override void UpdateProperties(BSPhysObject updated)
169 {
170 // Nothing to do for compound linksets on property updates
171 }
172
173 // The children move around in relationship to the root.
174 // Just grab the current values of wherever it is right now.
175 public override OMV.Vector3 Position(BSPhysObject member)
176 {
177 return BulletSimAPI.GetPosition2(member.PhysBody.ptr);
178 }
179
180 public override OMV.Quaternion Orientation(BSPhysObject member)
181 { 173 {
182 return BulletSimAPI.GetOrientation2(member.PhysBody.ptr); 174 // The user moving a child around requires the rebuilding of the linkset compound shape
175 // One problem is this happens when a border is crossed -- the simulator implementation
176 // is to store the position into the group which causes the move of the object
177 // but it also means all the child positions get updated.
178 // What would cause an unnecessary rebuild so we make sure the linkset is in a
179 // region before bothering to do a rebuild.
180 if (!IsRoot(updated)
181 && !physicalUpdate
182 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition))
183 {
184 updated.LinksetInfo = null;
185 ScheduleRebuild();
186 }
183 } 187 }
184 188
185 // Routine called when rebuilding the body of some member of the linkset. 189 // Routine called when rebuilding the body of some member of the linkset.
@@ -261,8 +265,8 @@ public sealed class BSLinksetCompound : BSLinkset
261 265
262 DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); 266 DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID);
263 267
264 // Cause constraints and assorted properties to be recomputed before the next simulation step. 268 // Rebuild the compound shape with the new child shape included
265 InternalRefresh(LinksetRoot); 269 ScheduleRebuild();
266 } 270 }
267 return; 271 return;
268 } 272 }
@@ -289,8 +293,8 @@ public sealed class BSLinksetCompound : BSLinkset
289 } 293 }
290 else 294 else
291 { 295 {
292 // Schedule a rebuild of the linkset before the next simulation tick. 296 // Rebuild the compound shape with the child removed
293 InternalRefresh(LinksetRoot); 297 ScheduleRebuild();
294 } 298 }
295 } 299 }
296 return; 300 return;