diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 110 |
1 files changed, 99 insertions, 11 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 5a02ad4..4456182 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -153,12 +153,65 @@ namespace OpenSim.Region.Environment.Scenes | |||
153 | //unkown if this will be kept, added as a way of removing the group position from the group class | 153 | //unkown if this will be kept, added as a way of removing the group position from the group class |
154 | protected LLVector3 m_groupPosition; | 154 | protected LLVector3 m_groupPosition; |
155 | 155 | ||
156 | public LLVector3 GetWorldPosition() | ||
157 | { | ||
158 | |||
159 | Quaternion parentRot = new Quaternion( | ||
160 | ParentGroup.RootPart.RotationOffset.W, | ||
161 | ParentGroup.RootPart.RotationOffset.X, | ||
162 | ParentGroup.RootPart.RotationOffset.Y, | ||
163 | ParentGroup.RootPart.RotationOffset.Z); | ||
164 | |||
165 | Vector3 axPos | ||
166 | = new Vector3( | ||
167 | OffsetPosition.X, | ||
168 | OffsetPosition.Y, | ||
169 | OffsetPosition.Z); | ||
170 | |||
171 | axPos = parentRot * axPos; | ||
172 | LLVector3 translationOffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); | ||
173 | return GroupPosition + translationOffsetPosition; | ||
174 | |||
175 | //return (new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z) + AbsolutePosition); | ||
176 | } | ||
177 | |||
178 | public LLQuaternion GetWorldRotation() | ||
179 | { | ||
180 | Quaternion newRot; | ||
181 | |||
182 | if (this.LinkNum == 0) | ||
183 | { | ||
184 | newRot = new Quaternion(RotationOffset.W,RotationOffset.X,RotationOffset.Y,RotationOffset.Z); | ||
185 | |||
186 | } | ||
187 | else | ||
188 | { | ||
189 | Quaternion parentRot = new Quaternion( | ||
190 | ParentGroup.RootPart.RotationOffset.W, | ||
191 | ParentGroup.RootPart.RotationOffset.X, | ||
192 | ParentGroup.RootPart.RotationOffset.Y, | ||
193 | ParentGroup.RootPart.RotationOffset.Z); | ||
194 | |||
195 | Quaternion oldRot | ||
196 | = new Quaternion( | ||
197 | RotationOffset.W, | ||
198 | RotationOffset.X, | ||
199 | RotationOffset.Y, | ||
200 | RotationOffset.Z); | ||
201 | |||
202 | newRot = parentRot * oldRot; | ||
203 | } | ||
204 | return new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); | ||
205 | |||
206 | //return new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); | ||
207 | |||
208 | } | ||
156 | 209 | ||
157 | public LLVector3 GroupPosition | 210 | public LLVector3 GroupPosition |
158 | { | 211 | { |
159 | get | 212 | get |
160 | { | 213 | { |
161 | if (PhysActor != null) | 214 | if (PhysActor != null && ParentID == 0) |
162 | { | 215 | { |
163 | m_groupPosition.X = PhysActor.Position.X; | 216 | m_groupPosition.X = PhysActor.Position.X; |
164 | m_groupPosition.Y = PhysActor.Position.Y; | 217 | m_groupPosition.Y = PhysActor.Position.Y; |
@@ -167,23 +220,35 @@ namespace OpenSim.Region.Environment.Scenes | |||
167 | return m_groupPosition; | 220 | return m_groupPosition; |
168 | } | 221 | } |
169 | set | 222 | set |
170 | { | 223 | { |
224 | m_groupPosition = value; | ||
225 | |||
171 | if (PhysActor != null) | 226 | if (PhysActor != null) |
172 | { | 227 | { |
173 | try | 228 | try |
174 | { | 229 | { |
175 | //lock (m_parentGroup.Scene.SyncRoot) | 230 | |
176 | //{ | 231 | if (ParentID == 0) |
177 | PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | 232 | { |
233 | PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | ||
234 | |||
235 | } | ||
236 | else | ||
237 | { | ||
238 | LLVector3 resultingposition = GetWorldPosition(); | ||
239 | PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); | ||
240 | LLQuaternion resultingrot = GetWorldRotation(); | ||
241 | PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z); | ||
242 | } | ||
243 | |||
178 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 244 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
179 | //} | ||
180 | } | 245 | } |
181 | catch (Exception e) | 246 | catch (Exception e) |
182 | { | 247 | { |
183 | Console.WriteLine(e.Message); | 248 | Console.WriteLine(e.Message); |
184 | } | 249 | } |
185 | } | 250 | } |
186 | m_groupPosition = value; | 251 | |
187 | } | 252 | } |
188 | } | 253 | } |
189 | 254 | ||
@@ -192,7 +257,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
192 | public LLVector3 OffsetPosition | 257 | public LLVector3 OffsetPosition |
193 | { | 258 | { |
194 | get { return m_offsetPosition; } | 259 | get { return m_offsetPosition; } |
195 | set { m_offsetPosition = value; } | 260 | set { m_offsetPosition = value; |
261 | try | ||
262 | { | ||
263 | // Hack to get the child prim to update positions in the physics engine | ||
264 | ParentGroup.AbsolutePosition = ParentGroup.AbsolutePosition; | ||
265 | } | ||
266 | catch (System.NullReferenceException) | ||
267 | { | ||
268 | // Ignore, and skip over. | ||
269 | } | ||
270 | //MainLog.Instance.Verbose("PART", "OFFSET:" + m_offsetPosition, ToString()); | ||
271 | } | ||
196 | } | 272 | } |
197 | 273 | ||
198 | public LLVector3 AbsolutePosition | 274 | public LLVector3 AbsolutePosition |
@@ -206,7 +282,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
206 | { | 282 | { |
207 | get | 283 | get |
208 | { | 284 | { |
209 | if (PhysActor != null) | 285 | if (PhysActor != null && ParentID == 0) |
210 | { | 286 | { |
211 | if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 | 287 | if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 |
212 | || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) | 288 | || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) |
@@ -221,13 +297,25 @@ namespace OpenSim.Region.Environment.Scenes | |||
221 | } | 297 | } |
222 | set | 298 | set |
223 | { | 299 | { |
300 | m_rotationOffset = value; | ||
301 | |||
224 | if (PhysActor != null) | 302 | if (PhysActor != null) |
225 | { | 303 | { |
226 | try | 304 | try |
227 | { | 305 | { |
228 | //lock (Scene.SyncRoot) | 306 | //lock (Scene.SyncRoot) |
229 | //{ | 307 | //{ |
230 | PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z); | 308 | if (ParentID == 0) |
309 | { | ||
310 | PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z); | ||
311 | //MainLog.Instance.Verbose("PART", "RO1:" + PhysActor.Orientation.ToString()); | ||
312 | } | ||
313 | else | ||
314 | { | ||
315 | LLQuaternion resultingrotation = GetWorldRotation(); | ||
316 | PhysActor.Orientation = new Quaternion(resultingrotation.W, resultingrotation.X, resultingrotation.Y, resultingrotation.Z); | ||
317 | //MainLog.Instance.Verbose("PART", "RO2:" + PhysActor.Orientation.ToString()); | ||
318 | } | ||
231 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 319 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
232 | //} | 320 | //} |
233 | } | 321 | } |
@@ -236,7 +324,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
236 | Console.WriteLine(ex.Message); | 324 | Console.WriteLine(ex.Message); |
237 | } | 325 | } |
238 | } | 326 | } |
239 | m_rotationOffset = value; | 327 | |
240 | } | 328 | } |
241 | } | 329 | } |
242 | 330 | ||