aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-15 14:39:35 +0000
committerTeravus Ovares2008-01-15 14:39:35 +0000
commit0a783e444255d53ece9bbd95e5cc44110062d67f (patch)
tree677587f51c35b888b4253706968d4c4ca6527e96 /OpenSim
parent* Some morw work on specializing the database framework for OpenSim (diff)
downloadopensim-SC_OLD-0a783e444255d53ece9bbd95e5cc44110062d67f.zip
opensim-SC_OLD-0a783e444255d53ece9bbd95e5cc44110062d67f.tar.gz
opensim-SC_OLD-0a783e444255d53ece9bbd95e5cc44110062d67f.tar.bz2
opensim-SC_OLD-0a783e444255d53ece9bbd95e5cc44110062d67f.tar.xz
* Added some comments to the linkset positioning code
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs24
1 files changed, 20 insertions, 4 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 468e2d0..60ea480 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -153,6 +153,11 @@ 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 /// <summary>
157 /// Method for a prim to get it's world position from the group.
158 /// Remember, the Group Position simply gives the position of the group itself
159 /// </summary>
160 /// <returns>A Linked Child Prim objects position in world</returns>
156 public LLVector3 GetWorldPosition() 161 public LLVector3 GetWorldPosition()
157 { 162 {
158 163
@@ -175,6 +180,10 @@ namespace OpenSim.Region.Environment.Scenes
175 //return (new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z) + AbsolutePosition); 180 //return (new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z) + AbsolutePosition);
176 } 181 }
177 182
183 /// <summary>
184 /// Gets the rotation of this prim offset by the group rotation
185 /// </summary>
186 /// <returns></returns>
178 public LLQuaternion GetWorldRotation() 187 public LLQuaternion GetWorldRotation()
179 { 188 {
180 Quaternion newRot; 189 Quaternion newRot;
@@ -211,6 +220,7 @@ namespace OpenSim.Region.Environment.Scenes
211 { 220 {
212 get 221 get
213 { 222 {
223 // If this is a linkset, we don't want the physics engine mucking up our group position here.
214 if (PhysActor != null && ParentID == 0) 224 if (PhysActor != null && ParentID == 0)
215 { 225 {
216 m_groupPosition.X = PhysActor.Position.X; 226 m_groupPosition.X = PhysActor.Position.X;
@@ -228,6 +238,7 @@ namespace OpenSim.Region.Environment.Scenes
228 try 238 try
229 { 239 {
230 240
241 // Root prim actually goes at Position
231 if (ParentID == 0) 242 if (ParentID == 0)
232 { 243 {
233 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); 244 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
@@ -235,12 +246,16 @@ namespace OpenSim.Region.Environment.Scenes
235 } 246 }
236 else 247 else
237 { 248 {
249
250 // To move the child prim in respect to the group position and rotation we have to calculate
251
238 LLVector3 resultingposition = GetWorldPosition(); 252 LLVector3 resultingposition = GetWorldPosition();
239 PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); 253 PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z);
240 LLQuaternion resultingrot = GetWorldRotation(); 254 LLQuaternion resultingrot = GetWorldRotation();
241 PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z); 255 PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z);
242 } 256 }
243 257
258 // Tell the physics engines that this prim changed.
244 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 259 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
245 } 260 }
246 catch (Exception e) 261 catch (Exception e)
@@ -260,7 +275,7 @@ namespace OpenSim.Region.Environment.Scenes
260 set { m_offsetPosition = value; 275 set { m_offsetPosition = value;
261 try 276 try
262 { 277 {
263 // Hack to get the child prim to update positions in the physics engine 278 // Hack to get the child prim to update world positions in the physics engine
264 ParentGroup.ResetChildPrimPhysicsPositions(); 279 ParentGroup.ResetChildPrimPhysicsPositions();
265 } 280 }
266 catch (System.NullReferenceException) 281 catch (System.NullReferenceException)
@@ -282,6 +297,7 @@ namespace OpenSim.Region.Environment.Scenes
282 { 297 {
283 get 298 get
284 { 299 {
300 // We don't want the physics engine mucking up the rotations in a linkset
285 if (PhysActor != null && ParentID == 0) 301 if (PhysActor != null && ParentID == 0)
286 { 302 {
287 if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 303 if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0
@@ -303,8 +319,7 @@ namespace OpenSim.Region.Environment.Scenes
303 { 319 {
304 try 320 try
305 { 321 {
306 //lock (Scene.SyncRoot) 322 // Root prim gets value directly
307 //{
308 if (ParentID == 0) 323 if (ParentID == 0)
309 { 324 {
310 PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z); 325 PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z);
@@ -312,6 +327,7 @@ namespace OpenSim.Region.Environment.Scenes
312 } 327 }
313 else 328 else
314 { 329 {
330 // Child prim we have to calculate it's world rotation
315 LLQuaternion resultingrotation = GetWorldRotation(); 331 LLQuaternion resultingrotation = GetWorldRotation();
316 PhysActor.Orientation = new Quaternion(resultingrotation.W, resultingrotation.X, resultingrotation.Y, resultingrotation.Z); 332 PhysActor.Orientation = new Quaternion(resultingrotation.W, resultingrotation.X, resultingrotation.Y, resultingrotation.Z);
317 //MainLog.Instance.Verbose("PART", "RO2:" + PhysActor.Orientation.ToString()); 333 //MainLog.Instance.Verbose("PART", "RO2:" + PhysActor.Orientation.ToString());