Patch llCastRay fully-simplified to V2.

Signed-off-by: Michael Cerquoni <nebadon2025@gmail.com>
inv-download
Magnuz Binder 2015-05-04 10:51:04 +02:00 committed by Michael Cerquoni
parent df12fbb0d2
commit c96ee68953
2 changed files with 23 additions and 22 deletions

View File

@ -221,6 +221,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected float m_primSafetyCoeffX = 2.414214f;
protected float m_primSafetyCoeffY = 2.414214f;
protected float m_primSafetyCoeffZ = 1.618034f;
protected bool m_useCastRayV2 = false;
protected int RC_USE_V2 = 512;
protected float m_floatToleranceInCastRay = 0.000001f;
protected float m_floatTolerance2InCastRay = 0.0001f;
protected int m_maxHitsInCastRay = 16;
@ -229,7 +231,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected bool m_detectExitsInCastRay = false;
protected bool m_filterPartsInCastRay = false;
protected bool m_doAttachmentsInCastRay = false;
protected bool m_useCastRayV1 = true;
//An array of HTTP/1.1 headers that are not allowed to be used
//as custom headers by llHTTPRequest.
@ -336,6 +337,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_primSafetyCoeffX = lslConfig.GetFloat("PrimBoundingBoxSafetyCoefficientX", m_primSafetyCoeffX);
m_primSafetyCoeffY = lslConfig.GetFloat("PrimBoundingBoxSafetyCoefficientY", m_primSafetyCoeffY);
m_primSafetyCoeffZ = lslConfig.GetFloat("PrimBoundingBoxSafetyCoefficientZ", m_primSafetyCoeffZ);
m_useCastRayV2 = lslConfig.GetBoolean("UseLlCastRayV2", m_useCastRayV2);
RC_USE_V2 = lslConfig.GetInt("RC_USE_V2", RC_USE_V2);
m_floatToleranceInCastRay = lslConfig.GetFloat("FloatToleranceInLlCastRay", m_floatToleranceInCastRay);
m_floatTolerance2InCastRay = lslConfig.GetFloat("FloatTolerance2InLlCastRay", m_floatTolerance2InCastRay);
m_maxHitsInCastRay = lslConfig.GetInt("MaxHitsInLlCastRay", m_maxHitsInCastRay);
@ -344,7 +347,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_detectExitsInCastRay = lslConfig.GetBoolean("DetectExitHitsInLlCastRay", m_detectExitsInCastRay);
m_filterPartsInCastRay = lslConfig.GetBoolean("FilterPartsInLlCastRay", m_filterPartsInCastRay);
m_doAttachmentsInCastRay = lslConfig.GetBoolean("DoAttachmentsInLlCastRay", m_doAttachmentsInCastRay);
m_useCastRayV1 = lslConfig.GetBoolean("UseLlCastRayV1", m_useCastRayV1);
}
IConfig smtpConfig = seConfigSource.Configs["SMTP"];
@ -13763,7 +13765,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return contacts[0];
}
public LSL_List llCastRayV1(LSL_Vector start, LSL_Vector end, LSL_List options)
public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
{
LSL_List list = new LSL_List();
@ -13792,6 +13794,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
rejectTypes = options.GetLSLIntegerItem(i + 1);
}
// Use llCastRay v2 if configured or requested
if (m_useCastRayV2 || (dataFlags & RC_USE_V2) == RC_USE_V2)
return llCastRayV2(start, end, options);
if (count > 16)
count = 16;
@ -13955,25 +13961,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
/// <summary>
/// Full implementation of llCastRay similar to SL 2015-04-21.
/// Implementation of llCastRay similar to SL 2015-04-21.
/// http://wiki.secondlife.com/wiki/LlCastRay
/// Uses pure geometry, bounding shapes, meshing and no physics
/// for prims, sculpts, meshes, avatars and terrain.
/// Implements all flags, reject types and data flags.
/// Can handle both objects/groups and prims/parts, by config.
/// May give poor results with multi-part meshes where "root"
/// part doesn't dominate, owing to "guessed" bounding boxes.
/// May sometimes be inaccurate owing to calculation precision
/// and a bug in libopenmetaverse PrimMesher.
/// </summary>
public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
public LSL_List llCastRayV2(LSL_Vector start, LSL_Vector end, LSL_List options)
{
// Use llCastRay v1 if configured
if (m_useCastRayV1)
return llCastRayV1(start, end, options);
// Initialize
m_host.AddScriptLPS(1);
// Keep AddScriptLPS commented while called from llCastRay
// m_host.AddScriptLPS(1);
List<RayHit> rayHits = new List<RayHit>();
LSL_List result = new LSL_List();
float tol = m_floatToleranceInCastRay;
@ -14009,10 +14010,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Vector3 ray = end - start;
float rayLength = ray.Length();
// Try to get a mesher and return failure if none or degenerate ray
// Try to get a mesher and return failure if none, degenerate ray, or max 0 hits
IRendering primMesher = null;
List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory());
if (renderers.Count < 1 || rayLength < tol)
if (renderers.Count < 1 || rayLength < tol || m_maxHitsInCastRay < 1)
{
result.Add(new LSL_Integer(ScriptBaseClass.RCERR_UNKNOWN));
return result;

View File

@ -1397,11 +1397,6 @@
; Maximum number of external urls that scripts can set up in this simulator (e.g. via llRequestURL())
max_external_urls_per_simulator = 100
; Use version 1 of llCastRay as default if true. If set to false, the new
; version of llCastRay will be used. This gives better accuracy but
; uses more CPU and may may be slow on some servers
UseLlCastRayV1 = true
; Use size boxes instead of meshed prims, sculpts and mesh when calculating bounding boxes.
; Speeds up calculations but can make them inaccurate, in some cases very inaccurate.
UseSimpleBoxesInGetBoundingBox = false
@ -1494,6 +1489,14 @@
; Worst case is twisted tube, 0.5+sqrt(1.25)
PrimBoundingBoxSafetyCoefficientZ = 1.618034
; Use new version 2 of llCastRay as default if true
; This gives better accuracy and speed on some servers, but may be slower on other servers
UseLlCastRayV2 = false
; Irregular bit flag to use after RC_DATA_FLAGS in calls to llCastRay to use version 2
; Bit flags RC_GET_NORMAL = 1, RC_GET_ROOT_KEY = 2 and RC_GET_LINK_NUM = 4 are already in regular use
RC_USE_V2 = 512
; Accepted calculation precision error in calculations in llCastRay
FloatToleranceInLlCastRay = 0.000001
@ -1518,9 +1521,6 @@
; Detect attachments in llCastRay if true
DoAttachmentsInLlCastRay = false
; Use legacy version 1 of llCastRay if true
UseLlCastRayV1 = true
[DataSnapshot]
; The following set of configs pertains to search.
; Set index_sims to true to enable search engines to index your searchable data