diff options
author | Tedd Hansen | 2007-08-20 10:58:51 +0000 |
---|---|---|
committer | Tedd Hansen | 2007-08-20 10:58:51 +0000 |
commit | 33326c1a70815b9746eb2780655fa8be3620908a (patch) | |
tree | 919a266ac9b9674691b437f27b048b0b01d55319 | |
parent | Added "StopScriot()" to ScriptManager. Stops Executor from executing events i... (diff) | |
download | opensim-SC-33326c1a70815b9746eb2780655fa8be3620908a.zip opensim-SC-33326c1a70815b9746eb2780655fa8be3620908a.tar.gz opensim-SC-33326c1a70815b9746eb2780655fa8be3620908a.tar.bz2 opensim-SC-33326c1a70815b9746eb2780655fa8be3620908a.tar.xz |
Some minor changes + krinkec's updates to ll* functions.
3 files changed, 68 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs index 1218b19..2898bee 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | |||
@@ -160,7 +160,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
160 | /// Increase "dead script" counter for an AppDomain | 160 | /// Increase "dead script" counter for an AppDomain |
161 | /// </summary> | 161 | /// </summary> |
162 | /// <param name="ad"></param> | 162 | /// <param name="ad"></param> |
163 | [Obsolete("Needs fixing, needs a real purpose in life!!!")] | 163 | //[Obsolete("Needs fixing, needs a real purpose in life!!!")] |
164 | public void StopScript(AppDomain ad) | 164 | public void StopScript(AppDomain ad) |
165 | { | 165 | { |
166 | lock (FreeLock) | 166 | lock (FreeLock) |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 8982bb6..03f9462 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
41 | } | 41 | } |
42 | 42 | ||
43 | //These are the implementations of the various ll-functions used by the LSL scripts. | 43 | //These are the implementations of the various ll-functions used by the LSL scripts. |
44 | //starting out, we use the System.Math library for trig functions. - CFK 8-14-07 | 44 | //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 |
45 | public double llSin(double f) { return (double)Math.Sin(f); } | 45 | public double llSin(double f) { return (double)Math.Sin(f); } |
46 | public double llCos(double f) { return (double)Math.Cos(f); } | 46 | public double llCos(double f) { return (double)Math.Cos(f); } |
47 | public double llTan(double f) { return (double)Math.Tan(f); } | 47 | public double llTan(double f) { return (double)Math.Tan(f); } |
@@ -60,12 +60,71 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
60 | } | 60 | } |
61 | public int llFloor(double f) { return (int)Math.Floor(f); } | 61 | public int llFloor(double f) { return (int)Math.Floor(f); } |
62 | public int llCeil(double f) { return (int)Math.Ceiling(f); } | 62 | public int llCeil(double f) { return (int)Math.Ceiling(f); } |
63 | public int llRound(double f) { return (int)Math.Round(f, 1); } | 63 | public int llRound(double f) { return (int)Math.Round(f, 3); } |
64 | public double llVecMag(LSL_Types.Vector3 v) { return 0; } | 64 | |
65 | public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) { return new LSL_Types.Vector3(); } | 65 | //This next group are vector operations involving squaring and square root. ckrinke |
66 | public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) { return 0; } | 66 | public double llVecMag(LSL_Types.Vector3 v) { return (v.X*v.X + v.Y*v.Y + v.Z*v.Z); } |
67 | public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } | 67 | public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) |
68 | public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) { return new LSL_Types.Quaternion(); } | 68 | { |
69 | double mag = v.X * v.X + v.Y * v.Y + v.Z * v.Z; | ||
70 | LSL_Types.Vector3 nor = new LSL_Types.Vector3(); | ||
71 | nor.X = v.X / mag; nor.Y = v.Y / mag; nor.Z = v.Z / mag; | ||
72 | return nor; | ||
73 | } | ||
74 | |||
75 | public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) | ||
76 | { | ||
77 | double dx = a.X - b.X; double dy = a.Y - b.Y; double dz = a.Z - b.Z; | ||
78 | return Math.Sqrt(dx * dx + dy * dy + dz * dz); | ||
79 | } | ||
80 | |||
81 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | ||
82 | public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) | ||
83 | { | ||
84 | //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke | ||
85 | LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X * r.X, r.Y * r.Y, r.Z * r.Z, r.R * r.R); | ||
86 | double m = (t.X + t.Y + t.Z + t.R); | ||
87 | if (m == 0) return new LSL_Types.Vector3(); | ||
88 | double n = 2 * (r.Y * r.R + r.X * r.Z); | ||
89 | double p = m * m - n * n; | ||
90 | if (p > 0) | ||
91 | return new LSL_Types.Vector3(Math.Atan2(2.0 * (r.X*r.R - r.Y*r.Z),(-t.X - t.Y + t.Z + t.R)), | ||
92 | Math.Atan2(n,Math.Sqrt(p)), Math.Atan2(2.0 * (r.Z*r.R - r.X*r.Y),( t.X - t.Y - t.Z + t.R))); | ||
93 | else if(n>0) | ||
94 | return new LSL_Types.Vector3( 0.0, Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); | ||
95 | else | ||
96 | return new LSL_Types.Vector3( 0.0, -Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); | ||
97 | } | ||
98 | |||
99 | public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) | ||
100 | { //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07 | ||
101 | float err = 0.00001f; | ||
102 | double ax = Math.Sin(v.X / 2); double aw = Math.Cos(v.X / 2); | ||
103 | double by = Math.Sin(v.Y / 2); double bw = Math.Cos(v.Y / 2); | ||
104 | double cz = Math.Sin(v.Z / 2); double cw = Math.Cos(v.Z / 2); | ||
105 | LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw); | ||
106 | LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw); | ||
107 | LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw); | ||
108 | LSL_Types.Quaternion a = new LSL_Types.Quaternion(); | ||
109 | //This multiplication doesnt compile, yet. a = a1 * a2 * a3; | ||
110 | LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax * bw * cw + aw * by * cz, | ||
111 | aw * by * cw - ax * bw * cz, aw * bw * cz + ax * by * cw, aw * bw * cw - ax * by * cz); | ||
112 | LSL_Types.Quaternion c = new LSL_Types.Quaternion(); | ||
113 | //This addition doesnt compile yet c = a + b; | ||
114 | LSL_Types.Quaternion d = new LSL_Types.Quaternion(); | ||
115 | //This addition doesnt compile yet d = a - b; | ||
116 | if ((Math.Abs(c.X) > err && Math.Abs(d.X) > err) || | ||
117 | (Math.Abs(c.Y) > err && Math.Abs(d.Y) > err) || | ||
118 | (Math.Abs(c.Z) > err && Math.Abs(d.Z) > err) || | ||
119 | (Math.Abs(c.R) > err && Math.Abs(d.R) > err)) | ||
120 | { | ||
121 | //return a new Quaternion that is null until I figure this out | ||
122 | // return b; | ||
123 | // return a; | ||
124 | } | ||
125 | return new LSL_Types.Quaternion(); | ||
126 | } | ||
127 | |||
69 | public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return new LSL_Types.Quaternion(); } | 128 | public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return new LSL_Types.Quaternion(); } |
70 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } | 129 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } |
71 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } | 130 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } |
@@ -85,7 +144,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
85 | //public void llSay(int channelID, string text) | 144 | //public void llSay(int channelID, string text) |
86 | public void llSay(int channelID, string text) | 145 | public void llSay(int channelID, string text) |
87 | { | 146 | { |
88 | //TODO: DO SOMETHING USEFUL HERE | ||
89 | //Common.SendToDebug("INTERNAL FUNCTION llSay(" + (int)channelID + ", \"" + (string)text + "\");"); | 147 | //Common.SendToDebug("INTERNAL FUNCTION llSay(" + (int)channelID + ", \"" + (string)text + "\");"); |
90 | //Console.WriteLine("llSay Channel " + channelID + ", Text: \"" + text + "\""); | 148 | //Console.WriteLine("llSay Channel " + channelID + ", Text: \"" + text + "\""); |
91 | //type for say is 1 | 149 | //type for say is 1 |
@@ -436,7 +494,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
436 | { | 494 | { |
437 | Int64 tmp = 0; | 495 | Int64 tmp = 0; |
438 | Int64 val = Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); | 496 | Int64 val = Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); |
439 | |||
440 | return Convert.ToInt32(tmp); | 497 | return Convert.ToInt32(tmp); |
441 | } | 498 | } |
442 | 499 | ||
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 7f78790..2be65e3 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
60 | private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) | 60 | private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) |
61 | { | 61 | { |
62 | 62 | ||
63 | //Console.WriteLine("CurrentDomain_AssemblyResolve: " + args.Name); | 63 | //Console.WriteLine("ScriptManager.CurrentDomain_AssemblyResolve: " + args.Name); |
64 | return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null; | 64 | return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null; |
65 | 65 | ||
66 | } | 66 | } |