From d3efb6a7f7b0205379da37f40bf233d70fb12c45 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 21 Aug 2013 16:02:42 -0700 Subject: [PATCH] BulletSim: add position and rotation update for child prim physics update events. Normally, physics engines do not return updates for child prims so, under normal operation, this code should never execute. Will only be used when using flexible linkset linkages. --- .../Framework/Scenes/SceneObjectPart.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2e11162a4b..b30c024c4c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2502,6 +2502,26 @@ namespace OpenSim.Region.Framework.Scenes //ParentGroup.RootPart.m_groupPosition = newpos; } + if (pa != null && ParentID != 0 && ParentGroup != null) + { + // RA: Special case where a child object is requesting property updates. + // This happens when linksets are modified to use flexible links rather than + // the default links. + // The simulator code presumes that child parts are only modified by scripts + // so the logic for changing position/rotation/etc does not take into + // account the physical object actually moving. + // This code updates the offset position and rotation of the child and then + // lets the update code push the update to the viewer. + // Since physics engines do not normally generate this event for linkset children, + // this code will not be active unless you have a specially configured + // physics engine. + Quaternion invRootRotation = Quaternion.Normalize(Quaternion.Inverse(ParentGroup.RootPart.RotationOffset)); + m_offsetPosition = pa.Position - m_groupPosition; + RotationOffset = pa.Orientation * invRootRotation; + m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", + "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); + } + ScheduleTerseUpdate(); }