aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs107
1 files changed, 105 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2428bc4..c461d3d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3330,11 +3330,114 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3330 3330
3331 } 3331 }
3332 3332
3333 // this function to understand which shape it is (taken from meshmerizer)
3334 // quite useful can be used by meshmerizer to have a centralized point of understanding the shape
3335 // except that it refers to scripting constants
3336 private int getScriptPrimType(PrimitiveBaseShape primShape)
3337 {
3338
3339 if (primShape.SculptEntry && primShape.SculptType != (byte)0 && primShape.SculptData.Length > 0)
3340 return ScriptBaseClass.PRIM_TYPE_SCULPT;
3341 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
3342 {
3343 if (primShape.PathCurve == (byte)Extrusion.Straight)
3344 return ScriptBaseClass.PRIM_TYPE_BOX;
3345 else if (primShape.PathCurve == (byte)Extrusion.Curve1)
3346 return ScriptBaseClass.PRIM_TYPE_TUBE;
3347 }
3348 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
3349 {
3350 if (primShape.PathCurve == (byte)Extrusion.Straight)
3351 return ScriptBaseClass.PRIM_TYPE_CYLINDER;
3352 // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
3353 else if (primShape.PathCurve == (byte)Extrusion.Curve1)
3354 return ScriptBaseClass.PRIM_TYPE_TORUS;
3355 }
3356 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
3357 {
3358 if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte)Extrusion.Curve2)
3359 return ScriptBaseClass.PRIM_TYPE_SPHERE;
3360 }
3361 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
3362 {
3363 if (primShape.PathCurve == (byte)Extrusion.Straight)
3364 return ScriptBaseClass.PRIM_TYPE_PRISM;
3365 else if (primShape.PathCurve == (byte)Extrusion.Curve1)
3366 return ScriptBaseClass.PRIM_TYPE_RING;
3367 }
3368 return ScriptBaseClass.PRIM_TYPE_BOX;
3369
3370
3371 }
3372 // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces
3373 private void hasCutHollowDimpleProfileCut(PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
3374 out bool hasDimple, out bool hasProfileCut)
3375 {
3376 hasCut = (shape.PathBegin > 0) || (shape.PathEnd < 1);
3377 hasHollow = shape.ProfileHollow > 0;
3378 hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd < 1); // taken from llSetPrimitiveParms
3379 hasProfileCut = hasDimple; // is it the same thing?
3380
3381 }
3382
3333 public LSL_Types.LSLInteger llGetNumberOfSides() 3383 public LSL_Types.LSLInteger llGetNumberOfSides()
3334 { 3384 {
3335 m_host.AddScriptLPS(1); 3385 m_host.AddScriptLPS(1);
3336 NotImplemented("llGetNumberOfSides"); 3386 int ret = 0;
3337 return 0; 3387 bool hasCut;
3388 bool hasHollow;
3389 bool hasDimple;
3390 bool hasProfileCut;
3391
3392 hasCutHollowDimpleProfileCut(m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
3393
3394 switch (getScriptPrimType(m_host.Shape))
3395 {
3396 case ScriptBaseClass.PRIM_TYPE_BOX:
3397 ret = 6;
3398 if (hasCut) ret += 2;
3399 if (hasHollow) ret += 1;
3400 break;
3401 case ScriptBaseClass.PRIM_TYPE_CYLINDER:
3402 ret = 3;
3403 if (hasCut) ret += 2;
3404 if (hasHollow) ret += 1;
3405 break;
3406 case ScriptBaseClass.PRIM_TYPE_PRISM:
3407 ret = 5;
3408 if (hasCut) ret += 2;
3409 if (hasHollow) ret += 1;
3410 break;
3411 case ScriptBaseClass.PRIM_TYPE_SPHERE:
3412 ret = 1;
3413 if (hasCut) ret += 2;
3414 if (hasDimple) ret += 2;
3415 if (hasHollow) ret += 1; // actually lsl adds 4!!!!!! is that a great mistake?
3416 break;
3417 case ScriptBaseClass.PRIM_TYPE_TORUS:
3418 ret = 1;
3419 if (hasCut) ret += 2;
3420 if (hasProfileCut) ret += 2;
3421 if (hasHollow) ret += 1;
3422 break;
3423 case ScriptBaseClass.PRIM_TYPE_TUBE:
3424 ret = 4;
3425 if (hasCut) ret += 2;
3426 if (hasProfileCut) ret += 2;
3427 if (hasHollow) ret += 1;
3428 break;
3429 case ScriptBaseClass.PRIM_TYPE_RING:
3430 ret = 3;
3431 if (hasCut) ret += 2;
3432 if (hasProfileCut) ret += 2;
3433 if (hasHollow) ret += 1;
3434 break;
3435 case ScriptBaseClass.PRIM_TYPE_SCULPT:
3436 ret = 1;
3437 break;
3438 }
3439
3440 return ret;
3338 } 3441 }
3339 3442
3340 3443