aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-11-29 14:36:09 +0000
committerUbitUmarov2015-11-29 14:36:09 +0000
commit302d28625d86de33ff9c98ad27b2f31cd2841879 (patch)
treed6c10c52741f717357c91dea466b46f5b67df5b5 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
parentfix the default shape type on upload, it is always convex (diff)
downloadopensim-SC-302d28625d86de33ff9c98ad27b2f31cd2841879.zip
opensim-SC-302d28625d86de33ff9c98ad27b2f31cd2841879.tar.gz
opensim-SC-302d28625d86de33ff9c98ad27b2f31cd2841879.tar.bz2
opensim-SC-302d28625d86de33ff9c98ad27b2f31cd2841879.tar.xz
change llLookAt math to master cleaner solution, assuming lAxis2rot does work
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs31
1 files changed, 18 insertions, 13 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 61397cd..38cbdbc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3550,19 +3550,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3550 m_host.AddScriptLPS(1); 3550 m_host.AddScriptLPS(1);
3551 3551
3552 // Get the normalized vector to the target 3552 // Get the normalized vector to the target
3553 LSL_Vector d1 = llVecNorm(target - llGetPos()); 3553 LSL_Vector from = llGetPos();
3554 3554
3555 // Get the bearing (yaw) 3555 // normalized direction to target
3556 LSL_Vector a1 = new LSL_Vector(0,0,0); 3556 LSL_Vector dir = llVecNorm(target - from);
3557 a1.z = llAtan2(d1.y, d1.x);
3558 3557
3559 // Get the elevation (pitch) 3558 // use vertical to help compute left axis
3560 LSL_Vector a2 = new LSL_Vector(0,0,0); 3559// LSL_Vector up = new LSL_Vector(0.0, 0.0, 1.0);
3561 a2.y= -llAtan2(d1.z, llSqrt((d1.x * d1.x) + (d1.y * d1.y))); 3560 // find normalized left axis parallel to horizon
3561// LSL_Vector left = llVecNorm(LSL_Vector.Cross(up, dir));
3562
3563 LSL_Vector left = new LSL_Vector(-dir.y, dir.x, 0.0f);
3564 left = llVecNorm(left);
3565 // make up orthogonal to left and dir
3566 LSL_Vector up = LSL_Vector.Cross(dir, left);
3562 3567
3563 LSL_Rotation r1 = llEuler2Rot(a1); 3568 // compute rotation based on orthogonal axes
3564 LSL_Rotation r2 = llEuler2Rot(a2); 3569 // and rotate so Z points to target with X below horizont
3565 LSL_Rotation r3 = new LSL_Rotation(0.000000, 0.707107, 0.000000, 0.707107); 3570 LSL_Rotation rot = new LSL_Rotation(0.0, 0.707107, 0.0, 0.707107) * llAxes2Rot(dir, left, up);
3566 3571
3567 if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) 3572 if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
3568 { 3573 {
@@ -3570,17 +3575,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3570 if (strength <= 0.0 || damping <= 0.0) 3575 if (strength <= 0.0 || damping <= 0.0)
3571 return; 3576 return;
3572 3577
3573 llSetRot(r3 * r2 * r1); 3578 llSetRot(rot);
3574 } 3579 }
3575 else 3580 else
3576 { 3581 {
3577 if (strength == 0) 3582 if (strength == 0)
3578 { 3583 {
3579 llSetRot(r3 * r2 * r1); 3584 llSetRot(rot);
3580 return; 3585 return;
3581 } 3586 }
3582 3587
3583 m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping); 3588 m_host.StartLookAt(rot, (float)strength, (float)damping);
3584 } 3589 }
3585 } 3590 }
3586 3591