aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs65
1 files changed, 45 insertions, 20 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fff807a..ab7abbe 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -493,8 +493,8 @@ namespace OpenSim.Region.Framework.Scenes
493 493
494 public Vector3 GroupScale() 494 public Vector3 GroupScale()
495 { 495 {
496 Vector3 minScale = new Vector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); 496 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
497 Vector3 maxScale = new Vector3(0f,0f,0f); 497 Vector3 maxScale = Vector3.Zero;
498 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); 498 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
499 499
500 lock (m_parts) 500 lock (m_parts)
@@ -577,7 +577,6 @@ namespace OpenSim.Region.Framework.Scenes
577 { 577 {
578 foreach (SceneObjectPart part in m_parts.Values) 578 foreach (SceneObjectPart part in m_parts.Values)
579 { 579 {
580
581 Vector3 worldPos = part.GetWorldPosition(); 580 Vector3 worldPos = part.GetWorldPosition();
582 Vector3 offset = worldPos - AbsolutePosition; 581 Vector3 offset = worldPos - AbsolutePosition;
583 Quaternion worldRot; 582 Quaternion worldRot;
@@ -1182,8 +1181,8 @@ namespace OpenSim.Region.Framework.Scenes
1182 { 1181 {
1183// part.Inventory.RemoveScriptInstances(); 1182// part.Inventory.RemoveScriptInstances();
1184 1183
1185 List<ScenePresence> avatars = Scene.GetScenePresences(); 1184 ScenePresence[] avatars = Scene.GetScenePresences();
1186 for (int i = 0; i < avatars.Count; i++) 1185 for (int i = 0; i < avatars.Length; i++)
1187 { 1186 {
1188 if (avatars[i].ParentID == LocalId) 1187 if (avatars[i].ParentID == LocalId)
1189 { 1188 {
@@ -1335,7 +1334,7 @@ namespace OpenSim.Region.Framework.Scenes
1335 (parcel.LandData.GroupID != GroupID || 1334 (parcel.LandData.GroupID != GroupID ||
1336 parcel.LandData.GroupID == UUID.Zero)) 1335 parcel.LandData.GroupID == UUID.Zero))
1337 { 1336 {
1338 if ((DateTime.Now - RootPart.Rezzed).TotalMinutes > 1337 if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes >
1339 parcel.LandData.OtherCleanTime) 1338 parcel.LandData.OtherCleanTime)
1340 { 1339 {
1341 DetachFromBackup(); 1340 DetachFromBackup();
@@ -1480,8 +1479,8 @@ namespace OpenSim.Region.Framework.Scenes
1480 dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( 1479 dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
1481 dupe.RootPart.Name, 1480 dupe.RootPart.Name,
1482 pbs, 1481 pbs,
1483 new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, dupe.RootPart.AbsolutePosition.Z), 1482 dupe.RootPart.AbsolutePosition,
1484 new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), 1483 dupe.RootPart.Scale,
1485 dupe.RootPart.RotationOffset, 1484 dupe.RootPart.RotationOffset,
1486 dupe.RootPart.PhysActor.IsPhysical); 1485 dupe.RootPart.PhysActor.IsPhysical);
1487 1486
@@ -1596,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes
1596 */ 1595 */
1597 } 1596 }
1598 1597
1599 public void applyImpulse(PhysicsVector impulse) 1598 public void applyImpulse(Vector3 impulse)
1600 { 1599 {
1601 // We check if rootpart is null here because scripts don't delete if you delete the host. 1600 // We check if rootpart is null here because scripts don't delete if you delete the host.
1602 // This means that unfortunately, we can pass a null physics actor to Simulate! 1601 // This means that unfortunately, we can pass a null physics actor to Simulate!
@@ -1623,7 +1622,7 @@ namespace OpenSim.Region.Framework.Scenes
1623 } 1622 }
1624 } 1623 }
1625 1624
1626 public void applyAngularImpulse(PhysicsVector impulse) 1625 public void applyAngularImpulse(Vector3 impulse)
1627 { 1626 {
1628 // We check if rootpart is null here because scripts don't delete if you delete the host. 1627 // We check if rootpart is null here because scripts don't delete if you delete the host.
1629 // This means that unfortunately, we can pass a null physics actor to Simulate! 1628 // This means that unfortunately, we can pass a null physics actor to Simulate!
@@ -1642,7 +1641,7 @@ namespace OpenSim.Region.Framework.Scenes
1642 } 1641 }
1643 } 1642 }
1644 1643
1645 public void setAngularImpulse(PhysicsVector impulse) 1644 public void setAngularImpulse(Vector3 impulse)
1646 { 1645 {
1647 // We check if rootpart is null here because scripts don't delete if you delete the host. 1646 // We check if rootpart is null here because scripts don't delete if you delete the host.
1648 // This means that unfortunately, we can pass a null physics actor to Simulate! 1647 // This means that unfortunately, we can pass a null physics actor to Simulate!
@@ -1673,8 +1672,8 @@ namespace OpenSim.Region.Framework.Scenes
1673 { 1672 {
1674 if (!IsAttachment) 1673 if (!IsAttachment)
1675 { 1674 {
1676 PhysicsVector torque = rootpart.PhysActor.Torque; 1675 Vector3 torque = rootpart.PhysActor.Torque;
1677 return new Vector3(torque.X, torque.Y, torque.Z); 1676 return torque;
1678 } 1677 }
1679 } 1678 }
1680 } 1679 }
@@ -1707,7 +1706,7 @@ namespace OpenSim.Region.Framework.Scenes
1707 { 1706 {
1708 if (rootpart.PhysActor != null) 1707 if (rootpart.PhysActor != null)
1709 { 1708 {
1710 rootpart.PhysActor.PIDTarget = new PhysicsVector(target.X, target.Y, target.Z); 1709 rootpart.PhysActor.PIDTarget = target;
1711 rootpart.PhysActor.PIDTau = tau; 1710 rootpart.PhysActor.PIDTau = tau;
1712 rootpart.PhysActor.PIDActive = true; 1711 rootpart.PhysActor.PIDActive = true;
1713 } 1712 }
@@ -2414,7 +2413,7 @@ namespace OpenSim.Region.Framework.Scenes
2414 if (m_rootPart.PhysActor.IsPhysical) 2413 if (m_rootPart.PhysActor.IsPhysical)
2415 { 2414 {
2416 Vector3 llmoveforce = pos - AbsolutePosition; 2415 Vector3 llmoveforce = pos - AbsolutePosition;
2417 PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z); 2416 Vector3 grabforce = llmoveforce;
2418 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; 2417 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass;
2419 m_rootPart.PhysActor.AddForce(grabforce,true); 2418 m_rootPart.PhysActor.AddForce(grabforce,true);
2420 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2419 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@@ -2519,7 +2518,7 @@ namespace OpenSim.Region.Framework.Scenes
2519 rotationAxis.Normalize(); 2518 rotationAxis.Normalize();
2520 2519
2521 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); 2520 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
2522 PhysicsVector spinforce = new PhysicsVector(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); 2521 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
2523 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor 2522 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor
2524 m_rootPart.PhysActor.AddAngularForce(spinforce,true); 2523 m_rootPart.PhysActor.AddAngularForce(spinforce,true);
2525 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2524 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@@ -2746,8 +2745,7 @@ namespace OpenSim.Region.Framework.Scenes
2746 if (scale.Z > m_scene.m_maxPhys) 2745 if (scale.Z > m_scene.m_maxPhys)
2747 scale.Z = m_scene.m_maxPhys; 2746 scale.Z = m_scene.m_maxPhys;
2748 } 2747 }
2749 part.PhysActor.Size = 2748 part.PhysActor.Size = scale;
2750 new PhysicsVector(scale.X, scale.Y, scale.Z);
2751 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2749 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2752 } 2750 }
2753 //if (part.UUID != m_rootPart.UUID) 2751 //if (part.UUID != m_rootPart.UUID)
@@ -2891,8 +2889,7 @@ namespace OpenSim.Region.Framework.Scenes
2891 2889
2892 if (part.PhysActor != null) 2890 if (part.PhysActor != null)
2893 { 2891 {
2894 part.PhysActor.Size = 2892 part.PhysActor.Size = prevScale;
2895 new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z);
2896 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2893 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2897 } 2894 }
2898 2895
@@ -3405,6 +3402,8 @@ namespace OpenSim.Region.Framework.Scenes
3405 return GetPriorityByDistance(client); 3402 return GetPriorityByDistance(client);
3406 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3403 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3407 return GetPriorityBySimpleAngularDistance(client); 3404 return GetPriorityBySimpleAngularDistance(client);
3405 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3406 return GetPriorityByFrontBack(client);
3408 default: 3407 default:
3409 throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); 3408 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3410 } 3409 }
@@ -3437,6 +3436,16 @@ namespace OpenSim.Region.Framework.Scenes
3437 return double.NaN; 3436 return double.NaN;
3438 } 3437 }
3439 3438
3439 private double GetPriorityByFrontBack(IClientAPI client)
3440 {
3441 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3442 if (presence != null)
3443 {
3444 return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
3445 }
3446 return double.NaN;
3447 }
3448
3440 public double GetPriorityByDistance(Vector3 position) 3449 public double GetPriorityByDistance(Vector3 position)
3441 { 3450 {
3442 return Vector3.Distance(AbsolutePosition, position); 3451 return Vector3.Distance(AbsolutePosition, position);
@@ -3466,5 +3475,21 @@ namespace OpenSim.Region.Framework.Scenes
3466 else 3475 else
3467 return double.MinValue; 3476 return double.MinValue;
3468 } 3477 }
3478
3479 public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
3480 {
3481 // Distance
3482 double priority = Vector3.Distance(camPosition, AbsolutePosition);
3483
3484 // Scale
3485 //priority -= GroupScale().Length();
3486
3487 // Plane equation
3488 float d = -Vector3.Dot(camPosition, camAtAxis);
3489 float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
3490 if (p < 0.0f) priority *= 2.0f;
3491
3492 return priority;
3493 }
3469 } 3494 }
3470} 3495}