diff options
Merge branch 'master' into careminster
Conflicts:
OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
OpenSim/Region/Framework/Scenes/Scene.cs
OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
OpenSim/Region/Framework/Scenes/ScenePresence.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
OpenSim/Services/HypergridService/UserAgentService.cs
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | 103 |
1 files changed, 31 insertions, 72 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 308cf13..1d94142 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -35,62 +35,6 @@ using OMV = OpenMetaverse; | |||
35 | namespace OpenSim.Region.Physics.BulletSPlugin | 35 | namespace OpenSim.Region.Physics.BulletSPlugin |
36 | { | 36 | { |
37 | 37 | ||
38 | /* | ||
39 | // When a child is linked, the relationship position of the child to the parent | ||
40 | // is remembered so the child's world position can be recomputed when it is | ||
41 | // removed from the linkset. | ||
42 | sealed class BSLinksetCompoundInfo : BSLinksetInfo | ||
43 | { | ||
44 | public int Index; | ||
45 | public OMV.Vector3 OffsetFromRoot; | ||
46 | public OMV.Vector3 OffsetFromCenterOfMass; | ||
47 | public OMV.Quaternion OffsetRot; | ||
48 | public BSLinksetCompoundInfo(int indx, OMV.Vector3 p, OMV.Quaternion r) | ||
49 | { | ||
50 | Index = indx; | ||
51 | OffsetFromRoot = p; | ||
52 | OffsetFromCenterOfMass = p; | ||
53 | OffsetRot = r; | ||
54 | } | ||
55 | // 'centerDisplacement' is the distance from the root the the center-of-mass (Bullet 'zero' of the shape) | ||
56 | public BSLinksetCompoundInfo(int indx, BSPrimLinkable root, BSPrimLinkable child, OMV.Vector3 centerDisplacement) | ||
57 | { | ||
58 | // Each child position and rotation is given relative to the center-of-mass. | ||
59 | OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(root.RawOrientation); | ||
60 | OMV.Vector3 displacementFromRoot = (child.RawPosition - root.RawPosition) * invRootOrientation; | ||
61 | OMV.Vector3 displacementFromCOM = displacementFromRoot - centerDisplacement; | ||
62 | OMV.Quaternion displacementRot = child.RawOrientation * invRootOrientation; | ||
63 | |||
64 | // Save relative position for recomputing child's world position after moving linkset. | ||
65 | Index = indx; | ||
66 | OffsetFromRoot = displacementFromRoot; | ||
67 | OffsetFromCenterOfMass = displacementFromCOM; | ||
68 | OffsetRot = displacementRot; | ||
69 | } | ||
70 | public override void Clear() | ||
71 | { | ||
72 | Index = 0; | ||
73 | OffsetFromRoot = OMV.Vector3.Zero; | ||
74 | OffsetFromCenterOfMass = OMV.Vector3.Zero; | ||
75 | OffsetRot = OMV.Quaternion.Identity; | ||
76 | } | ||
77 | public override string ToString() | ||
78 | { | ||
79 | StringBuilder buff = new StringBuilder(); | ||
80 | buff.Append("<i="); | ||
81 | buff.Append(Index.ToString()); | ||
82 | buff.Append(",p="); | ||
83 | buff.Append(OffsetFromRoot.ToString()); | ||
84 | buff.Append(",m="); | ||
85 | buff.Append(OffsetFromCenterOfMass.ToString()); | ||
86 | buff.Append(",r="); | ||
87 | buff.Append(OffsetRot.ToString()); | ||
88 | buff.Append(">"); | ||
89 | return buff.ToString(); | ||
90 | } | ||
91 | }; | ||
92 | */ | ||
93 | |||
94 | public sealed class BSLinksetCompound : BSLinkset | 38 | public sealed class BSLinksetCompound : BSLinkset |
95 | { | 39 | { |
96 | private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]"; | 40 | private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]"; |
@@ -151,7 +95,9 @@ public sealed class BSLinksetCompound : BSLinkset | |||
151 | public override bool MakeStatic(BSPrimLinkable child) | 95 | public override bool MakeStatic(BSPrimLinkable child) |
152 | { | 96 | { |
153 | bool ret = false; | 97 | bool ret = false; |
98 | |||
154 | DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); | 99 | DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); |
100 | child.ClearDisplacement(); | ||
155 | if (IsRoot(child)) | 101 | if (IsRoot(child)) |
156 | { | 102 | { |
157 | // Schedule a rebuild to verify that the root shape is set to the real shape. | 103 | // Schedule a rebuild to verify that the root shape is set to the real shape. |
@@ -315,7 +261,6 @@ public sealed class BSLinksetCompound : BSLinkset | |||
315 | // Note that this works for rebuilding just the root after a linkset is taken apart. | 261 | // Note that this works for rebuilding just the root after a linkset is taken apart. |
316 | // Called at taint time!! | 262 | // Called at taint time!! |
317 | private bool UseBulletSimRootOffsetHack = false; // Attempt to have Bullet track the coords of root compound shape | 263 | private bool UseBulletSimRootOffsetHack = false; // Attempt to have Bullet track the coords of root compound shape |
318 | private bool disableCOM = true; // For basic linkset debugging, turn off the center-of-mass setting | ||
319 | private void RecomputeLinksetCompound() | 264 | private void RecomputeLinksetCompound() |
320 | { | 265 | { |
321 | try | 266 | try |
@@ -326,55 +271,70 @@ public sealed class BSLinksetCompound : BSLinkset | |||
326 | // to what they should be as if the root was not in a linkset. | 271 | // to what they should be as if the root was not in a linkset. |
327 | // Not that bad since we only get into this routine if there are children in the linkset and | 272 | // Not that bad since we only get into this routine if there are children in the linkset and |
328 | // something has been updated/changed. | 273 | // something has been updated/changed. |
274 | // Have to do the rebuild before checking for physical because this might be a linkset | ||
275 | // being destructed and going non-physical. | ||
329 | LinksetRoot.ForceBodyShapeRebuild(true); | 276 | LinksetRoot.ForceBodyShapeRebuild(true); |
330 | 277 | ||
331 | // There is no reason to build all this physical stuff for a non-physical linkset. | 278 | // There is no reason to build all this physical stuff for a non-physical linkset. |
332 | if (!LinksetRoot.IsPhysicallyActive) | 279 | if (!LinksetRoot.IsPhysicallyActive) |
333 | { | 280 | { |
334 | // Clean up any old linkset shape and make sure the root shape is set to the root object. | ||
335 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); | 281 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); |
336 | |||
337 | return; // Note the 'finally' clause at the botton which will get executed. | 282 | return; // Note the 'finally' clause at the botton which will get executed. |
338 | } | 283 | } |
339 | 284 | ||
340 | // Get a new compound shape to build the linkset shape in. | 285 | // Get a new compound shape to build the linkset shape in. |
341 | BSShape linksetShape = BSShapeCompound.GetReference(m_physicsScene); | 286 | BSShape linksetShape = BSShapeCompound.GetReference(m_physicsScene); |
342 | 287 | ||
343 | // The center of mass for the linkset is the geometric center of the group. | ||
344 | // Compute a displacement for each component so it is relative to the center-of-mass. | 288 | // Compute a displacement for each component so it is relative to the center-of-mass. |
345 | // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass | 289 | // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass |
346 | OMV.Vector3 centerOfMassW = ComputeLinksetCenterOfMass(); | 290 | OMV.Vector3 centerOfMassW = ComputeLinksetCenterOfMass(); |
347 | 291 | ||
348 | OMV.Quaternion invRootOrientation = OMV.Quaternion.Normalize(OMV.Quaternion.Inverse(LinksetRoot.RawOrientation)); | 292 | OMV.Quaternion invRootOrientation = OMV.Quaternion.Normalize(OMV.Quaternion.Inverse(LinksetRoot.RawOrientation)); |
293 | OMV.Vector3 origRootPosition = LinksetRoot.RawPosition; | ||
349 | 294 | ||
350 | // 'centerDisplacement' is the value to subtract from children to give physical offset position | 295 | // 'centerDisplacementV' is the vehicle relative distance from the simulator root position to the center-of-mass |
351 | OMV.Vector3 centerDisplacementV = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation; | 296 | OMV.Vector3 centerDisplacementV = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation; |
352 | if (UseBulletSimRootOffsetHack || disableCOM) | 297 | if (UseBulletSimRootOffsetHack || !BSParam.LinksetOffsetCenterOfMass) |
353 | { | 298 | { |
299 | // Zero everything if center-of-mass displacement is not being done. | ||
354 | centerDisplacementV = OMV.Vector3.Zero; | 300 | centerDisplacementV = OMV.Vector3.Zero; |
355 | LinksetRoot.ClearDisplacement(); | 301 | LinksetRoot.ClearDisplacement(); |
356 | } | 302 | } |
357 | else | 303 | else |
358 | { | 304 | { |
359 | LinksetRoot.SetEffectiveCenterOfMassDisplacement(centerDisplacementV); | 305 | // The actual center-of-mass could have been set by the user. |
306 | centerDisplacementV = LinksetRoot.SetEffectiveCenterOfMassDisplacement(centerDisplacementV); | ||
360 | } | 307 | } |
308 | |||
361 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,rootPos={1},com={2},comDisp={3}", | 309 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,rootPos={1},com={2},comDisp={3}", |
362 | LinksetRoot.LocalID, LinksetRoot.RawPosition, centerOfMassW, centerDisplacementV); | 310 | LinksetRoot.LocalID, origRootPosition, centerOfMassW, centerDisplacementV); |
363 | 311 | ||
364 | // Add the shapes of all the components of the linkset | 312 | // Add the shapes of all the components of the linkset |
365 | int memberIndex = 1; | 313 | int memberIndex = 1; |
366 | ForEachMember(delegate(BSPrimLinkable cPrim) | 314 | ForEachMember(delegate(BSPrimLinkable cPrim) |
367 | { | 315 | { |
368 | // Root shape is always index zero. | 316 | if (IsRoot(cPrim)) |
369 | cPrim.LinksetChildIndex = IsRoot(cPrim) ? 0 : memberIndex; | 317 | { |
318 | // Root shape is always index zero. | ||
319 | cPrim.LinksetChildIndex = 0; | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | cPrim.LinksetChildIndex = memberIndex; | ||
324 | memberIndex++; | ||
325 | } | ||
370 | 326 | ||
371 | // Get a reference to the shape of the child and add that shape to the linkset compound shape | 327 | // Get a reference to the shape of the child for adding of that shape to the linkset compound shape |
372 | BSShape childShape = cPrim.PhysShape.GetReference(m_physicsScene, cPrim); | 328 | BSShape childShape = cPrim.PhysShape.GetReference(m_physicsScene, cPrim); |
373 | OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacementV; | 329 | |
330 | // Offset the child shape from the center-of-mass and rotate it to vehicle relative. | ||
331 | OMV.Vector3 offsetPos = (cPrim.RawPosition - origRootPosition) * invRootOrientation - centerDisplacementV; | ||
374 | OMV.Quaternion offsetRot = OMV.Quaternion.Normalize(cPrim.RawOrientation) * invRootOrientation; | 332 | OMV.Quaternion offsetRot = OMV.Quaternion.Normalize(cPrim.RawOrientation) * invRootOrientation; |
333 | |||
334 | // Add the child shape to the compound shape being built | ||
375 | m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); | 335 | m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); |
376 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}", | 336 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}", |
377 | LinksetRoot.LocalID, memberIndex, childShape, offsetPos, offsetRot); | 337 | LinksetRoot.LocalID, cPrim.LinksetChildIndex, childShape, offsetPos, offsetRot); |
378 | 338 | ||
379 | // Since we are borrowing the shape of the child, disable the origional child body | 339 | // Since we are borrowing the shape of the child, disable the origional child body |
380 | if (!IsRoot(cPrim)) | 340 | if (!IsRoot(cPrim)) |
@@ -386,8 +346,6 @@ public sealed class BSLinksetCompound : BSLinkset | |||
386 | cPrim.PhysBody.collisionType = CollisionType.LinksetChild; | 346 | cPrim.PhysBody.collisionType = CollisionType.LinksetChild; |
387 | } | 347 | } |
388 | 348 | ||
389 | memberIndex++; | ||
390 | |||
391 | return false; // 'false' says to move onto the next child in the list | 349 | return false; // 'false' says to move onto the next child in the list |
392 | }); | 350 | }); |
393 | 351 | ||
@@ -409,8 +367,9 @@ public sealed class BSLinksetCompound : BSLinkset | |||
409 | { | 367 | { |
410 | // Enable the physical position updator to return the position and rotation of the root shape. | 368 | // Enable the physical position updator to return the position and rotation of the root shape. |
411 | // This enables a feature in the C++ code to return the world coordinates of the first shape in the | 369 | // This enables a feature in the C++ code to return the world coordinates of the first shape in the |
412 | // compound shape. This eleviates the need to offset the returned physical position by the | 370 | // compound shape. This aleviates the need to offset the returned physical position by the |
413 | // center-of-mass offset. | 371 | // center-of-mass offset. |
372 | // TODO: either debug this feature or remove it. | ||
414 | m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE); | 373 | m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE); |
415 | } | 374 | } |
416 | } | 375 | } |