diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 69b3ded..38a0cff 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 | } |
@@ -2375,7 +2374,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2375 | if (m_rootPart.PhysActor.IsPhysical) | 2374 | if (m_rootPart.PhysActor.IsPhysical) |
2376 | { | 2375 | { |
2377 | Vector3 llmoveforce = pos - AbsolutePosition; | 2376 | Vector3 llmoveforce = pos - AbsolutePosition; |
2378 | PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z); | 2377 | Vector3 grabforce = llmoveforce; |
2379 | grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; | 2378 | grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; |
2380 | m_rootPart.PhysActor.AddForce(grabforce,true); | 2379 | m_rootPart.PhysActor.AddForce(grabforce,true); |
2381 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 2380 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); |
@@ -2480,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2480 | rotationAxis.Normalize(); | 2479 | rotationAxis.Normalize(); |
2481 | 2480 | ||
2482 | //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); | 2481 | //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); |
2483 | PhysicsVector spinforce = new PhysicsVector(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); | 2482 | Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); |
2484 | spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor | 2483 | spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor |
2485 | m_rootPart.PhysActor.AddAngularForce(spinforce,true); | 2484 | m_rootPart.PhysActor.AddAngularForce(spinforce,true); |
2486 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 2485 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); |
@@ -2707,8 +2706,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2707 | if (scale.Z > m_scene.m_maxPhys) | 2706 | if (scale.Z > m_scene.m_maxPhys) |
2708 | scale.Z = m_scene.m_maxPhys; | 2707 | scale.Z = m_scene.m_maxPhys; |
2709 | } | 2708 | } |
2710 | part.PhysActor.Size = | 2709 | part.PhysActor.Size = scale; |
2711 | new PhysicsVector(scale.X, scale.Y, scale.Z); | ||
2712 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); | 2710 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); |
2713 | } | 2711 | } |
2714 | //if (part.UUID != m_rootPart.UUID) | 2712 | //if (part.UUID != m_rootPart.UUID) |
@@ -2852,8 +2850,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2852 | 2850 | ||
2853 | if (part.PhysActor != null) | 2851 | if (part.PhysActor != null) |
2854 | { | 2852 | { |
2855 | part.PhysActor.Size = | 2853 | part.PhysActor.Size = prevScale; |
2856 | new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z); | ||
2857 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); | 2854 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); |
2858 | } | 2855 | } |
2859 | 2856 | ||
@@ -3366,6 +3363,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3366 | return GetPriorityByDistance(client); | 3363 | return GetPriorityByDistance(client); |
3367 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | 3364 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: |
3368 | return GetPriorityBySimpleAngularDistance(client); | 3365 | return GetPriorityBySimpleAngularDistance(client); |
3366 | case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: | ||
3367 | return GetPriorityByFrontBack(client); | ||
3369 | default: | 3368 | default: |
3370 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | 3369 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); |
3371 | } | 3370 | } |
@@ -3398,6 +3397,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3398 | return double.NaN; | 3397 | return double.NaN; |
3399 | } | 3398 | } |
3400 | 3399 | ||
3400 | private double GetPriorityByFrontBack(IClientAPI client) | ||
3401 | { | ||
3402 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3403 | if (presence != null) | ||
3404 | { | ||
3405 | return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis); | ||
3406 | } | ||
3407 | return double.NaN; | ||
3408 | } | ||
3409 | |||
3401 | public double GetPriorityByDistance(Vector3 position) | 3410 | public double GetPriorityByDistance(Vector3 position) |
3402 | { | 3411 | { |
3403 | return Vector3.Distance(AbsolutePosition, position); | 3412 | return Vector3.Distance(AbsolutePosition, position); |
@@ -3427,5 +3436,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3427 | else | 3436 | else |
3428 | return double.MinValue; | 3437 | return double.MinValue; |
3429 | } | 3438 | } |
3439 | |||
3440 | public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis) | ||
3441 | { | ||
3442 | // Distance | ||
3443 | double priority = Vector3.Distance(camPosition, AbsolutePosition); | ||
3444 | |||
3445 | // Scale | ||
3446 | //priority -= GroupScale().Length(); | ||
3447 | |||
3448 | // Plane equation | ||
3449 | float d = -Vector3.Dot(camPosition, camAtAxis); | ||
3450 | float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d; | ||
3451 | if (p < 0.0f) priority *= 2.0f; | ||
3452 | |||
3453 | return priority; | ||
3454 | } | ||
3430 | } | 3455 | } |
3431 | } | 3456 | } |