diff options
author | Dan Lake | 2012-02-01 16:25:35 -0800 |
---|---|---|
committer | Dan Lake | 2012-02-01 16:25:35 -0800 |
commit | c10193c72b1f029a958f04d2f5d7ee384e693aaa (patch) | |
tree | 052ec7e973c15b158310511197affad14eb9c64f /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | Trigger event when prims are scheduled for an update. This gives modules earl... (diff) | |
parent | Small optimization to last commit (diff) | |
download | opensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.zip opensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.gz opensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.bz2 opensim-SC_OLD-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 103 |
1 files changed, 48 insertions, 55 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8e59abf..9b660b6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -217,11 +217,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
217 | 217 | ||
218 | public Quaternion SpinOldOrientation = Quaternion.Identity; | 218 | public Quaternion SpinOldOrientation = Quaternion.Identity; |
219 | 219 | ||
220 | public Quaternion m_APIDTarget = Quaternion.Identity; | 220 | protected int m_APIDIterations = 0; |
221 | 221 | protected Quaternion m_APIDTarget = Quaternion.Identity; | |
222 | public float m_APIDDamp = 0; | 222 | protected float m_APIDDamp = 0; |
223 | 223 | protected float m_APIDStrength = 0; | |
224 | public float m_APIDStrength = 0; | ||
225 | 224 | ||
226 | /// <summary> | 225 | /// <summary> |
227 | /// This part's inventory | 226 | /// This part's inventory |
@@ -394,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
394 | 393 | ||
395 | private string m_creatorData = string.Empty; | 394 | private string m_creatorData = string.Empty; |
396 | /// <summary> | 395 | /// <summary> |
397 | /// Data about the creator in the form profile_url;name | 396 | /// Data about the creator in the form home_url;name |
398 | /// </summary> | 397 | /// </summary> |
399 | public string CreatorData | 398 | public string CreatorData |
400 | { | 399 | { |
@@ -405,7 +404,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
405 | /// <summary> | 404 | /// <summary> |
406 | /// Used by the DB layer to retrieve / store the entire user identification. | 405 | /// Used by the DB layer to retrieve / store the entire user identification. |
407 | /// The identification can either be a simple UUID or a string of the form | 406 | /// The identification can either be a simple UUID or a string of the form |
408 | /// uuid[;profile_url[;name]] | 407 | /// uuid[;home_url[;name]] |
409 | /// </summary> | 408 | /// </summary> |
410 | public string CreatorIdentification | 409 | public string CreatorIdentification |
411 | { | 410 | { |
@@ -563,22 +562,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
563 | } | 562 | } |
564 | } | 563 | } |
565 | 564 | ||
566 | 565 | protected Quaternion APIDTarget | |
567 | public Quaternion APIDTarget | ||
568 | { | 566 | { |
569 | get { return m_APIDTarget; } | 567 | get { return m_APIDTarget; } |
570 | set { m_APIDTarget = value; } | 568 | set { m_APIDTarget = value; } |
571 | } | 569 | } |
572 | 570 | ||
573 | 571 | ||
574 | public float APIDDamp | 572 | protected float APIDDamp |
575 | { | 573 | { |
576 | get { return m_APIDDamp; } | 574 | get { return m_APIDDamp; } |
577 | set { m_APIDDamp = value; } | 575 | set { m_APIDDamp = value; } |
578 | } | 576 | } |
579 | 577 | ||
580 | 578 | ||
581 | public float APIDStrength | 579 | protected float APIDStrength |
582 | { | 580 | { |
583 | get { return m_APIDStrength; } | 581 | get { return m_APIDStrength; } |
584 | set { m_APIDStrength = value; } | 582 | set { m_APIDStrength = value; } |
@@ -1946,19 +1944,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1946 | public Vector3 GetWorldPosition() | 1944 | public Vector3 GetWorldPosition() |
1947 | { | 1945 | { |
1948 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; | 1946 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; |
1949 | |||
1950 | Vector3 axPos = OffsetPosition; | 1947 | Vector3 axPos = OffsetPosition; |
1951 | |||
1952 | axPos *= parentRot; | 1948 | axPos *= parentRot; |
1953 | Vector3 translationOffsetPosition = axPos; | 1949 | Vector3 translationOffsetPosition = axPos; |
1954 | 1950 | if(_parentID == 0) | |
1955 | // m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); | 1951 | return GroupPosition; |
1956 | 1952 | else | |
1957 | Vector3 worldPos = GroupPosition + translationOffsetPosition; | 1953 | return ParentGroup.AbsolutePosition + translationOffsetPosition; |
1958 | |||
1959 | // m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); | ||
1960 | |||
1961 | return worldPos; | ||
1962 | } | 1954 | } |
1963 | 1955 | ||
1964 | /// <summary> | 1956 | /// <summary> |
@@ -2689,11 +2681,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2689 | 2681 | ||
2690 | public void RotLookAt(Quaternion target, float strength, float damping) | 2682 | public void RotLookAt(Quaternion target, float strength, float damping) |
2691 | { | 2683 | { |
2692 | rotLookAt(target, strength, damping); | ||
2693 | } | ||
2694 | |||
2695 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2696 | { | ||
2697 | if (ParentGroup.IsAttachment) | 2684 | if (ParentGroup.IsAttachment) |
2698 | { | 2685 | { |
2699 | /* | 2686 | /* |
@@ -2708,17 +2695,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2708 | APIDDamp = damping; | 2695 | APIDDamp = damping; |
2709 | APIDStrength = strength; | 2696 | APIDStrength = strength; |
2710 | APIDTarget = target; | 2697 | APIDTarget = target; |
2698 | |||
2699 | if (APIDStrength <= 0) | ||
2700 | { | ||
2701 | m_log.WarnFormat("[SceneObjectPart] Invalid rotation strength {0}",APIDStrength); | ||
2702 | return; | ||
2703 | } | ||
2704 | |||
2705 | m_APIDIterations = 1 + (int)(Math.PI * APIDStrength); | ||
2711 | } | 2706 | } |
2707 | |||
2708 | // Necessary to get the lookat deltas applied | ||
2709 | ParentGroup.QueueForUpdateCheck(); | ||
2712 | } | 2710 | } |
2713 | 2711 | ||
2714 | public void startLookAt(Quaternion rot, float damp, float strength) | 2712 | public void StartLookAt(Quaternion target, float strength, float damping) |
2715 | { | 2713 | { |
2716 | APIDDamp = damp; | 2714 | RotLookAt(target,strength,damping); |
2717 | APIDStrength = strength; | ||
2718 | APIDTarget = rot; | ||
2719 | } | 2715 | } |
2720 | 2716 | ||
2721 | public void stopLookAt() | 2717 | public void StopLookAt() |
2722 | { | 2718 | { |
2723 | APIDTarget = Quaternion.Identity; | 2719 | APIDTarget = Quaternion.Identity; |
2724 | } | 2720 | } |
@@ -3413,13 +3409,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3413 | } | 3409 | } |
3414 | } | 3410 | } |
3415 | 3411 | ||
3416 | public void StopLookAt() | ||
3417 | { | ||
3418 | ParentGroup.stopLookAt(); | ||
3419 | |||
3420 | ParentGroup.ScheduleGroupForTerseUpdate(); | ||
3421 | } | ||
3422 | |||
3423 | /// <summary> | 3412 | /// <summary> |
3424 | /// Set the text displayed for this part. | 3413 | /// Set the text displayed for this part. |
3425 | /// </summary> | 3414 | /// </summary> |
@@ -4521,10 +4510,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4521 | /// <summary> | 4510 | /// <summary> |
4522 | /// Update the texture entry for this part. | 4511 | /// Update the texture entry for this part. |
4523 | /// </summary> | 4512 | /// </summary> |
4524 | /// <param name="textureEntry"></param> | 4513 | /// <param name="serializedTextureEntry"></param> |
4525 | public void UpdateTextureEntry(byte[] textureEntry) | 4514 | public void UpdateTextureEntry(byte[] serializedTextureEntry) |
4515 | { | ||
4516 | UpdateTextureEntry(new Primitive.TextureEntry(serializedTextureEntry, 0, serializedTextureEntry.Length)); | ||
4517 | } | ||
4518 | |||
4519 | /// <summary> | ||
4520 | /// Update the texture entry for this part. | ||
4521 | /// </summary> | ||
4522 | /// <param name="newTex"></param> | ||
4523 | public void UpdateTextureEntry(Primitive.TextureEntry newTex) | ||
4526 | { | 4524 | { |
4527 | Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length); | ||
4528 | Primitive.TextureEntry oldTex = Shape.Textures; | 4525 | Primitive.TextureEntry oldTex = Shape.Textures; |
4529 | 4526 | ||
4530 | Changed changeFlags = 0; | 4527 | Changed changeFlags = 0; |
@@ -4556,7 +4553,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4556 | break; | 4553 | break; |
4557 | } | 4554 | } |
4558 | 4555 | ||
4559 | m_shape.TextureEntry = textureEntry; | 4556 | m_shape.TextureEntry = newTex.GetBytes(); |
4560 | if (changeFlags != 0) | 4557 | if (changeFlags != 0) |
4561 | TriggerScriptChangedEvent(changeFlags); | 4558 | TriggerScriptChangedEvent(changeFlags); |
4562 | UpdateFlag = UpdateRequired.FULL; | 4559 | UpdateFlag = UpdateRequired.FULL; |
@@ -4727,24 +4724,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4727 | { | 4724 | { |
4728 | if (APIDTarget != Quaternion.Identity) | 4725 | if (APIDTarget != Quaternion.Identity) |
4729 | { | 4726 | { |
4730 | if (Single.IsNaN(APIDTarget.W) == true) | 4727 | if (m_APIDIterations <= 1) |
4731 | { | 4728 | { |
4729 | UpdateRotation(APIDTarget); | ||
4732 | APIDTarget = Quaternion.Identity; | 4730 | APIDTarget = Quaternion.Identity; |
4733 | return; | 4731 | return; |
4734 | } | 4732 | } |
4735 | Quaternion rot = RotationOffset; | 4733 | |
4736 | Quaternion dir = (rot - APIDTarget); | 4734 | Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations); |
4737 | float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f)); | ||
4738 | if (dir.Z > speed) | ||
4739 | { | ||
4740 | rot.Z -= speed; | ||
4741 | } | ||
4742 | if (dir.Z < -speed) | ||
4743 | { | ||
4744 | rot.Z += speed; | ||
4745 | } | ||
4746 | rot.Normalize(); | ||
4747 | UpdateRotation(rot); | 4735 | UpdateRotation(rot); |
4736 | |||
4737 | m_APIDIterations--; | ||
4738 | |||
4739 | // This ensures that we'll check this object on the next iteration | ||
4740 | ParentGroup.QueueForUpdateCheck(); | ||
4748 | } | 4741 | } |
4749 | } | 4742 | } |
4750 | catch (Exception ex) | 4743 | catch (Exception ex) |