diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs index f5ee671..9a05349 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs | |||
@@ -44,12 +44,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
44 | { | 44 | { |
45 | public class BSPrimDisplaced : BSPrim | 45 | public class BSPrimDisplaced : BSPrim |
46 | { | 46 | { |
47 | // The purpose of this module is to do any mapping between what the simulator thinks | 47 | // The purpose of this subclass is to do any mapping between what the simulator thinks |
48 | // the prim position and orientation is and what the physical position/orientation. | 48 | // the prim position and orientation is and what the physical position/orientation. |
49 | // This difference happens because Bullet assumes the center-of-mass is the <0,0,0> | 49 | // This difference happens because Bullet assumes the center-of-mass is the <0,0,0> |
50 | // of the prim/linkset. The simulator tracks the location of the prim/linkset by | 50 | // of the prim/linkset. The simulator, on the other hand, tracks the location of |
51 | // the location of the root prim. So, if center-of-mass is anywhere but the origin | 51 | // the prim/linkset by the location of the root prim. So, if center-of-mass is anywhere |
52 | // of the root prim, the physical origin is displaced from the simulator origin. | 52 | // but the origin of the root prim, the physical origin is displaced from the simulator origin. |
53 | // | 53 | // |
54 | // This routine works by capturing the Force* setting of position/orientation/... and | 54 | // This routine works by capturing the Force* setting of position/orientation/... and |
55 | // adjusting the simulator values (being set) into the physical values. | 55 | // adjusting the simulator values (being set) into the physical values. |
@@ -61,6 +61,7 @@ public class BSPrimDisplaced : BSPrim | |||
61 | 61 | ||
62 | public virtual OMV.Vector3 PositionDisplacement { get; set; } | 62 | public virtual OMV.Vector3 PositionDisplacement { get; set; } |
63 | public virtual OMV.Quaternion OrientationDisplacement { get; set; } | 63 | public virtual OMV.Quaternion OrientationDisplacement { get; set; } |
64 | public virtual OMV.Quaternion OrientationDisplacementOrigInv { get; set; } | ||
64 | 65 | ||
65 | public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, | 66 | public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, |
66 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) | 67 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) |
@@ -99,7 +100,8 @@ public class BSPrimDisplaced : BSPrim | |||
99 | // Remember the displacement from root as well as the origional rotation of the | 100 | // Remember the displacement from root as well as the origional rotation of the |
100 | // new center-of-mass. | 101 | // new center-of-mass. |
101 | PositionDisplacement = comDisp; | 102 | PositionDisplacement = comDisp; |
102 | OrientationDisplacement = OMV.Quaternion.Identity; | 103 | OrientationDisplacement = Quaternion.Normalize(RawOrientation); |
104 | OrientationDisplacementOrigInv = Quaternion.Inverse(OrientationDisplacement); | ||
103 | } | 105 | } |
104 | } | 106 | } |
105 | 107 | ||
@@ -110,7 +112,7 @@ public class BSPrimDisplaced : BSPrim | |||
110 | { | 112 | { |
111 | if (PositionDisplacement != OMV.Vector3.Zero) | 113 | if (PositionDisplacement != OMV.Vector3.Zero) |
112 | { | 114 | { |
113 | OMV.Vector3 displacedPos = value - (PositionDisplacement * RawOrientation); | 115 | OMV.Vector3 displacedPos = value - (PositionDisplacement * (OrientationDisplacementOrigInv * RawOrientation)); |
114 | DetailLog("{0},BSPrimDisplaced.ForcePosition,val={1},disp={2},newPos={3}", LocalID, value, PositionDisplacement, displacedPos); | 116 | DetailLog("{0},BSPrimDisplaced.ForcePosition,val={1},disp={2},newPos={3}", LocalID, value, PositionDisplacement, displacedPos); |
115 | base.ForcePosition = displacedPos; | 117 | base.ForcePosition = displacedPos; |
116 | } | 118 | } |
@@ -126,7 +128,8 @@ public class BSPrimDisplaced : BSPrim | |||
126 | get { return base.ForceOrientation; } | 128 | get { return base.ForceOrientation; } |
127 | set | 129 | set |
128 | { | 130 | { |
129 | // TODO: | 131 | // Changing orientation also changes the position of the center-of-mass since |
132 | // the orientation passed is for a rotation around the root prim's center. | ||
130 | base.ForceOrientation = value; | 133 | base.ForceOrientation = value; |
131 | } | 134 | } |
132 | } | 135 | } |
@@ -150,10 +153,13 @@ public class BSPrimDisplaced : BSPrim | |||
150 | // Undo any center-of-mass displacement that might have been done. | 153 | // Undo any center-of-mass displacement that might have been done. |
151 | if (PositionDisplacement != OMV.Vector3.Zero || OrientationDisplacement != OMV.Quaternion.Identity) | 154 | if (PositionDisplacement != OMV.Vector3.Zero || OrientationDisplacement != OMV.Quaternion.Identity) |
152 | { | 155 | { |
153 | // Correct for any rotation around the center-of-mass | 156 | // The origional shape was offset from 'zero' by PositionDisplacement and rotated by OrientationDisplacement. |
154 | // TODO!!! | 157 | // These physical locations and rotation must be back converted to be centered around the displaced |
158 | // root shape. | ||
159 | |||
160 | // The root position is the reported position displaced by the rotated displacement. | ||
161 | OMV.Vector3 displacedPos = entprop.Position + (PositionDisplacement * (entprop.Rotation * OrientationDisplacementOrigInv)); | ||
155 | 162 | ||
156 | OMV.Vector3 displacedPos = entprop.Position + (PositionDisplacement * entprop.Rotation); | ||
157 | DetailLog("{0},BSPrimDisplaced.ForcePosition,physPos={1},disp={2},newPos={3}", LocalID, entprop.Position, PositionDisplacement, displacedPos); | 163 | DetailLog("{0},BSPrimDisplaced.ForcePosition,physPos={1},disp={2},newPos={3}", LocalID, entprop.Position, PositionDisplacement, displacedPos); |
158 | entprop.Position = displacedPos; | 164 | entprop.Position = displacedPos; |
159 | // entprop.Rotation = something; | 165 | // entprop.Rotation = something; |