diff options
author | Robert Adams | 2012-12-16 21:18:32 -0800 |
---|---|---|
committer | Robert Adams | 2012-12-16 21:19:13 -0800 |
commit | 2b8efa24dd816fda23fe3aed5822af1d50febf5d (patch) | |
tree | 287352bc66cf34ce25ee86a59099af43d2d23cb4 /OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |
parent | BulletSim: add even more to the TODO list. (diff) | |
download | opensim-SC-2b8efa24dd816fda23fe3aed5822af1d50febf5d.zip opensim-SC-2b8efa24dd816fda23fe3aed5822af1d50febf5d.tar.gz opensim-SC-2b8efa24dd816fda23fe3aed5822af1d50febf5d.tar.bz2 opensim-SC-2b8efa24dd816fda23fe3aed5822af1d50febf5d.tar.xz |
BulletSim: add parameter to UpdateProperties call into the linkset so changes from the physics engine can be differentiated from changes made by the user. This eliminates a linkset rebuild loop. Also add logic to not rebuild or freak out when the object/linkset crosses a terrain boundry.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 8359607..4d4f712 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -28,6 +28,8 @@ using System; | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Text; | 29 | using System.Text; |
30 | 30 | ||
31 | using OpenSim.Framework; | ||
32 | |||
31 | using OMV = OpenMetaverse; | 33 | using OMV = OpenMetaverse; |
32 | 34 | ||
33 | namespace OpenSim.Region.Physics.BulletSPlugin | 35 | namespace OpenSim.Region.Physics.BulletSPlugin |
@@ -87,25 +89,22 @@ public sealed class BSLinksetCompound : BSLinkset | |||
87 | // its internal properties. | 89 | // its internal properties. |
88 | public override void Refresh(BSPhysObject requestor) | 90 | public override void Refresh(BSPhysObject requestor) |
89 | { | 91 | { |
90 | if (!IsRoot(requestor)) | ||
91 | { | ||
92 | } | ||
93 | // Something changed so do the rebuilding thing | 92 | // Something changed so do the rebuilding thing |
94 | InternalRefresh(requestor); | 93 | // ScheduleRebuild(); |
95 | } | 94 | } |
96 | 95 | ||
97 | // Schedule a refresh to happen after all the other taint processing. | 96 | // Schedule a refresh to happen after all the other taint processing. |
98 | private void InternalRefresh(BSPhysObject requestor) | 97 | private void ScheduleRebuild() |
99 | { | 98 | { |
100 | DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,requestor={1},rebuilding={2}", | 99 | DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,rebuilding={1}", |
101 | LinksetRoot.LocalID, requestor.LocalID, Rebuilding); | 100 | LinksetRoot.LocalID, Rebuilding); |
102 | // 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. |
103 | // If already rebuilding, don't request another rebuild. | 102 | // If already rebuilding, don't request another rebuild. |
104 | if (!Rebuilding) | 103 | if (!Rebuilding) |
105 | { | 104 | { |
106 | PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", requestor.LocalID, delegate() | 105 | PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", LinksetRoot.LocalID, delegate() |
107 | { | 106 | { |
108 | if (IsRoot(requestor) && HasAnyChildren) | 107 | if (HasAnyChildren) |
109 | RecomputeLinksetCompound(); | 108 | RecomputeLinksetCompound(); |
110 | }); | 109 | }); |
111 | } | 110 | } |
@@ -125,8 +124,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
125 | { | 124 | { |
126 | // The root is going dynamic. Make sure mass is properly set. | 125 | // The root is going dynamic. Make sure mass is properly set. |
127 | m_mass = ComputeLinksetMass(); | 126 | m_mass = ComputeLinksetMass(); |
128 | if (HasAnyChildren) | 127 | ScheduleRebuild(); |
129 | InternalRefresh(LinksetRoot); | ||
130 | } | 128 | } |
131 | else | 129 | else |
132 | { | 130 | { |
@@ -155,8 +153,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
155 | DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); | 153 | DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); |
156 | if (IsRoot(child)) | 154 | if (IsRoot(child)) |
157 | { | 155 | { |
158 | if (HasAnyChildren) | 156 | ScheduleRebuild(); |
159 | InternalRefresh(LinksetRoot); | ||
160 | } | 157 | } |
161 | else | 158 | else |
162 | { | 159 | { |
@@ -172,10 +169,21 @@ public sealed class BSLinksetCompound : BSLinkset | |||
172 | return ret; | 169 | return ret; |
173 | } | 170 | } |
174 | 171 | ||
175 | // Called at taint-time!! | 172 | public override void UpdateProperties(BSPhysObject updated, bool physicalUpdate) |
176 | public override void UpdateProperties(BSPhysObject updated) | ||
177 | { | 173 | { |
178 | // Nothing to do for compound linksets on property updates | 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 | } | ||
179 | } | 187 | } |
180 | 188 | ||
181 | // 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. |
@@ -257,8 +265,8 @@ public sealed class BSLinksetCompound : BSLinkset | |||
257 | 265 | ||
258 | DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); | 266 | DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); |
259 | 267 | ||
260 | // Cause constraints and assorted properties to be recomputed before the next simulation step. | 268 | // Rebuild the compound shape with the new child shape included |
261 | InternalRefresh(LinksetRoot); | 269 | ScheduleRebuild(); |
262 | } | 270 | } |
263 | return; | 271 | return; |
264 | } | 272 | } |
@@ -285,8 +293,8 @@ public sealed class BSLinksetCompound : BSLinkset | |||
285 | } | 293 | } |
286 | else | 294 | else |
287 | { | 295 | { |
288 | // Schedule a rebuild of the linkset before the next simulation tick. | 296 | // Rebuild the compound shape with the child removed |
289 | InternalRefresh(LinksetRoot); | 297 | ScheduleRebuild(); |
290 | } | 298 | } |
291 | } | 299 | } |
292 | return; | 300 | return; |