aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs85
1 files changed, 55 insertions, 30 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index b524a18..4ba0e64 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -371,6 +371,31 @@ namespace OpenSim.Region.ScriptEngine.Shared
371 371
372 #endregion 372 #endregion
373 373
374 #region Methods
375 public Quaternion Normalize()
376 {
377 double length = Math.Sqrt(x * x + y * y + z * z + s * s);
378 if (length < float.Epsilon)
379 {
380 x = 0;
381 y = 0;
382 z = 0;
383 s = 1;
384 }
385 else
386 {
387
388 double invLength = 1.0 / length;
389 x *= invLength;
390 y *= invLength;
391 z *= invLength;
392 s *= invLength;
393 }
394
395 return this;
396 }
397 #endregion
398
374 #region Overriders 399 #region Overriders
375 400
376 public override int GetHashCode() 401 public override int GetHashCode()
@@ -546,21 +571,33 @@ namespace OpenSim.Region.ScriptEngine.Shared
546 571
547 set {m_data = value; } 572 set {m_data = value; }
548 } 573 }
549 // Function to obtain LSL type from an index. This is needed 574
550 // because LSL lists allow for multiple types, and safely 575 /// <summary>
551 // iterating in them requires a type check. 576 /// Obtain LSL type from an index.
577 /// </summary>
578 /// <remarks>
579 /// This is needed because LSL lists allow for multiple types, and safely
580 /// iterating in them requires a type check.
581 /// </remarks>
582 /// <returns></returns>
583 /// <param name='itemIndex'></param>
552 public Type GetLSLListItemType(int itemIndex) 584 public Type GetLSLListItemType(int itemIndex)
553 { 585 {
554 return m_data[itemIndex].GetType(); 586 return m_data[itemIndex].GetType();
555 } 587 }
556 588
557 // Member functions to obtain item as specific types. 589 /// <summary>
558 // For cases where implicit conversions would apply if items 590 /// Obtain float from an index.
559 // were not in a list (e.g. integer to float, but not float 591 /// </summary>
560 // to integer) functions check for alternate types so as to 592 /// <remarks>
561 // down-cast from Object to the correct type. 593 /// For cases where implicit conversions would apply if items
562 // Note: no checks for item index being valid are performed 594 /// were not in a list (e.g. integer to float, but not float
563 595 /// to integer) functions check for alternate types so as to
596 /// down-cast from Object to the correct type.
597 /// Note: no checks for item index being valid are performed
598 /// </remarks>
599 /// <returns></returns>
600 /// <param name='itemIndex'></param>
564 public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex) 601 public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex)
565 { 602 {
566 if (m_data[itemIndex] is LSL_Types.LSLInteger) 603 if (m_data[itemIndex] is LSL_Types.LSLInteger)
@@ -591,26 +628,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
591 628
592 public LSL_Types.LSLString GetLSLStringItem(int itemIndex) 629 public LSL_Types.LSLString GetLSLStringItem(int itemIndex)
593 { 630 {
594 if (m_data[itemIndex] is LSL_Types.key) 631 if (m_data[itemIndex] is LSL_Types.key)
595 { 632 {
596 return (LSL_Types.key)m_data[itemIndex]; 633 return (LSL_Types.key)m_data[itemIndex];
597 } 634 }
598 else if (m_data[itemIndex] is String) 635 else
599 { 636 {
600 return new LSL_Types.LSLString((string)m_data[itemIndex]); 637 return new LSL_Types.LSLString(m_data[itemIndex].ToString());
601 } 638 }
602 else if (m_data[itemIndex] is LSL_Types.LSLFloat)
603 {
604 return new LSL_Types.LSLString((LSLFloat)m_data[itemIndex]);
605 }
606 else if (m_data[itemIndex] is LSL_Types.LSLInteger)
607 {
608 return new LSL_Types.LSLString((LSLInteger)m_data[itemIndex]);
609 }
610 else
611 {
612 return (LSL_Types.LSLString)m_data[itemIndex];
613 }
614 } 639 }
615 640
616 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) 641 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)