aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-07-12 22:13:15 +0100
committerJustin Clark-Casey (justincc)2011-07-12 22:13:15 +0100
commit3e456163dd284fa04ab17465041a1a27f7b632b9 (patch)
treebaaa8a470f4afa7637e8919d41e161ec4215ce21 /OpenSim/Region/ScriptEngine
parenttemporarily fix the build break with building the OdePlugin tests assembly. (diff)
downloadopensim-SC_OLD-3e456163dd284fa04ab17465041a1a27f7b632b9.zip
opensim-SC_OLD-3e456163dd284fa04ab17465041a1a27f7b632b9.tar.gz
opensim-SC_OLD-3e456163dd284fa04ab17465041a1a27f7b632b9.tar.bz2
opensim-SC_OLD-3e456163dd284fa04ab17465041a1a27f7b632b9.tar.xz
Port implementation of llCastRay() from Aurora.
I haven't been able to test this since the viewer won't parse the llCastRay() function. Maybe some activation cap is missing. Could wait until it is activated by default in the viewer.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs166
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs16
3 files changed, 172 insertions, 15 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fd6d64c..c8bce60 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10309,51 +10309,191 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10309 return rq.ToString(); 10309 return rq.ToString();
10310 } 10310 }
10311 10311
10312 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
10313 {
10314 m_host.AddScriptLPS(1);
10315
10316 Vector3 dir = new Vector3((float)(end-start).x, (float)(end-start).y, (float)(end-start).z);
10317 Vector3 startvector = new Vector3((float)start.x, (float)start.y, (float)start.z);
10318 Vector3 endvector = new Vector3((float)end.x, (float)end.y, (float)end.z);
10319
10320 int count = 0;
10321// int detectPhantom = 0;
10322 int dataFlags = 0;
10323 int rejectTypes = 0;
10324
10325 for (int i = 0; i < options.Length; i += 2)
10326 {
10327 if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS)
10328 {
10329 count = options.GetLSLIntegerItem(i + 1);
10330 }
10331// else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM)
10332// {
10333// detectPhantom = options.GetLSLIntegerItem(i + 1);
10334// }
10335 else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS)
10336 {
10337 dataFlags = options.GetLSLIntegerItem(i + 1);
10338 }
10339 else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES)
10340 {
10341 rejectTypes = options.GetLSLIntegerItem(i + 1);
10342 }
10343 }
10344
10345 LSL_List list = new LSL_List();
10346 List<ContactResult> results = World.PhysicsScene.RaycastWorld(startvector, dir, dir.Length(), count);
10347
10348 double distance = Util.GetDistanceTo(startvector, endvector);
10349
10350 if (distance == 0)
10351 distance = 0.001;
10352
10353 Vector3 posToCheck = startvector;
10354 ITerrainChannel channel = World.RequestModuleInterface<ITerrainChannel>();
10355
10356 bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND);
10357 bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS);
10358 bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL);
10359 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
10360
10361 for (float i = 0; i <= distance; i += 0.1f)
10362 {
10363 posToCheck = startvector + (dir * (i / (float)distance));
10364
10365 if (checkTerrain && channel[(int)(posToCheck.X + startvector.X), (int)(posToCheck.Y + startvector.Y)] < posToCheck.Z)
10366 {
10367 ContactResult result = new ContactResult();
10368 result.ConsumerID = 0;
10369 result.Depth = 0;
10370 result.Normal = Vector3.Zero;
10371 result.Pos = posToCheck;
10372 results.Add(result);
10373 checkTerrain = false;
10374 }
10375
10376 if (checkAgents)
10377 {
10378 World.ForEachScenePresence(delegate(ScenePresence sp)
10379 {
10380 if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X))
10381 {
10382 ContactResult result = new ContactResult ();
10383 result.ConsumerID = sp.LocalId;
10384 result.Depth = 0;
10385 result.Normal = Vector3.Zero;
10386 result.Pos = posToCheck;
10387 results.Add(result);
10388 }
10389 });
10390 }
10391 }
10392
10393 int refcount = 0;
10394 foreach (ContactResult result in results)
10395 {
10396 if ((rejectTypes & ScriptBaseClass.RC_REJECT_LAND)
10397 == ScriptBaseClass.RC_REJECT_LAND && result.ConsumerID == 0)
10398 continue;
10399
10400 ISceneEntity entity = World.GetSceneObjectPart(result.ConsumerID);
10401
10402 if (entity == null && (rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) != ScriptBaseClass.RC_REJECT_AGENTS)
10403 entity = World.GetScenePresence(result.ConsumerID); //Only check if we should be looking for agents
10404
10405 if (entity == null)
10406 {
10407 list.Add(UUID.Zero);
10408
10409 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM)
10410 list.Add(0);
10411
10412 list.Add(result.Pos);
10413
10414 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
10415 list.Add(result.Normal);
10416
10417 continue; //Can't find it, so add UUID.Zero
10418 }
10419
10420 /*if (detectPhantom == 0 && intersection.obj is ISceneChildEntity &&
10421 ((ISceneChildEntity)intersection.obj).PhysActor == null)
10422 continue;*/ //Can't do this ATM, physics engine knows only of non phantom objects
10423
10424 if (entity is SceneObjectPart)
10425 {
10426 if (((SceneObjectPart)entity).PhysActor != null && ((SceneObjectPart)entity).PhysActor.IsPhysical)
10427 {
10428 if (!checkPhysical)
10429 continue;
10430 }
10431 else
10432 {
10433 if (!checkNonPhysical)
10434 continue;
10435 }
10436 }
10437
10438 refcount++;
10439 if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY && entity is SceneObjectPart)
10440 list.Add(((SceneObjectPart)entity).ParentGroup.UUID);
10441 else
10442 list.Add(entity.UUID);
10443
10444 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM)
10445 {
10446 if (entity is SceneObjectPart)
10447 list.Add(((SceneObjectPart)entity).LinkNum);
10448 else
10449 list.Add(0);
10450 }
10451
10452 list.Add(result.Pos);
10453
10454 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
10455 list.Add(result.Normal);
10456 }
10457
10458 list.Add(refcount); //The status code, either the # of contacts, RCERR_SIM_PERF_LOW, or RCERR_CAST_TIME_EXCEEDED
10459
10460 return list;
10461 }
10462
10312 #region Not Implemented 10463 #region Not Implemented
10313 // 10464 //
10314 // Listing the unimplemented lsl functions here, please move 10465 // Listing the unimplemented lsl functions here, please move
10315 // them from this region as they are completed 10466 // them from this region as they are completed
10316 // 10467 //
10317 public void llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
10318 {
10319 m_host.AddScriptLPS(1);
10320 NotImplemented("llCastRay");
10321
10322 }
10323 10468
10324 public void llGetEnv(LSL_String name) 10469 public void llGetEnv(LSL_String name)
10325 { 10470 {
10326 m_host.AddScriptLPS(1); 10471 m_host.AddScriptLPS(1);
10327 NotImplemented("llGetEnv"); 10472 NotImplemented("llGetEnv");
10328
10329 } 10473 }
10330 10474
10331 public void llGetSPMaxMemory() 10475 public void llGetSPMaxMemory()
10332 { 10476 {
10333 m_host.AddScriptLPS(1); 10477 m_host.AddScriptLPS(1);
10334 NotImplemented("llGetSPMaxMemory"); 10478 NotImplemented("llGetSPMaxMemory");
10335
10336 } 10479 }
10337 10480
10338 public void llGetUsedMemory() 10481 public void llGetUsedMemory()
10339 { 10482 {
10340 m_host.AddScriptLPS(1); 10483 m_host.AddScriptLPS(1);
10341 NotImplemented("llGetUsedMemory"); 10484 NotImplemented("llGetUsedMemory");
10342
10343 } 10485 }
10344 10486
10345 public void llRegionSayTo( LSL_Key target, LSL_Integer channel, LSL_String msg ) 10487 public void llRegionSayTo(LSL_Key target, LSL_Integer channel, LSL_String msg)
10346 { 10488 {
10347 m_host.AddScriptLPS(1); 10489 m_host.AddScriptLPS(1);
10348 NotImplemented("llRegionSayTo"); 10490 NotImplemented("llRegionSayTo");
10349
10350 } 10491 }
10351 10492
10352 public void llScriptProfiler( LSL_Integer flags ) 10493 public void llScriptProfiler(LSL_Integer flags)
10353 { 10494 {
10354 m_host.AddScriptLPS(1); 10495 m_host.AddScriptLPS(1);
10355 NotImplemented("llScriptProfiler"); 10496 NotImplemented("llScriptProfiler");
10356
10357 } 10497 }
10358 10498
10359 public void llSetSoundQueueing(int queue) 10499 public void llSetSoundQueueing(int queue)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 654ea81..27f9c84 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
60 LSL_String llBase64ToString(string str); 60 LSL_String llBase64ToString(string str);
61 void llBreakAllLinks(); 61 void llBreakAllLinks();
62 void llBreakLink(int linknum); 62 void llBreakLink(int linknum);
63 LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options);
63 LSL_Integer llCeil(double f); 64 LSL_Integer llCeil(double f);
64 void llClearCameraParams(); 65 void llClearCameraParams();
65 LSL_Integer llClearPrimMedia(LSL_Integer face); 66 LSL_Integer llClearPrimMedia(LSL_Integer face);
@@ -404,7 +405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
404 LSL_String llXorBase64StringsCorrect(string str1, string str2); 405 LSL_String llXorBase64StringsCorrect(string str1, string str2);
405 void print(string str); 406 void print(string str);
406 407
407 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 408 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
408 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 409 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
409 } 410 }
410} 411}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 9377cda..3f90788 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -593,5 +593,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
593 593
594 public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; 594 public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
595 public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; 595 public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";
596
597 public static readonly LSLInteger RC_REJECT_TYPES = 2;
598 public static readonly LSLInteger RC_DATA_FLAGS = 4;
599 public static readonly LSLInteger RC_MAX_HITS = 8;
600 public static readonly LSLInteger RC_DETECT_PHANTOM = 16;
601
602 public static readonly LSLInteger RC_REJECT_AGENTS = 2;
603 public static readonly LSLInteger RC_REJECT_PHYSICAL = 4;
604 public static readonly LSLInteger RC_REJECT_NONPHYSICAL = 8;
605 public static readonly LSLInteger RC_REJECT_LAND = 16;
606
607 public static readonly LSLInteger RC_GET_NORMAL = 2;
608 public static readonly LSLInteger RC_GET_ROOT_KEY = 4;
609 public static readonly LSLInteger RC_GET_LINK_NUM = 8;
610
611 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 1;
596 } 612 }
597} 613}