diff options
author | Melanie Thielker | 2008-08-24 14:04:02 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-08-24 14:04:02 +0000 |
commit | ec9137c4fa0228fcc218e54d18707e51cbec9738 (patch) | |
tree | 0c9e5d64e3bb84749baf109594d2d07289bd4e89 /OpenSim/Region | |
parent | Selling a copy of a prim (prim vendor) now works. (diff) | |
download | opensim-SC_OLD-ec9137c4fa0228fcc218e54d18707e51cbec9738.zip opensim-SC_OLD-ec9137c4fa0228fcc218e54d18707e51cbec9738.tar.gz opensim-SC_OLD-ec9137c4fa0228fcc218e54d18707e51cbec9738.tar.bz2 opensim-SC_OLD-ec9137c4fa0228fcc218e54d18707e51cbec9738.tar.xz |
Mantis #2028
Thank you, salahzar, for a patch that implements llGetNumberOfSides()
for the DotNetEngine.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 106 |
1 files changed, 104 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index be337e7..2b06e3d 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -3321,12 +3321,114 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3321 | return result; | 3321 | return result; |
3322 | 3322 | ||
3323 | } | 3323 | } |
3324 | // this function to understand which shape it is (taken from meshmerizer) | ||
3325 | // quite useful can be used by meshmerizer to have a centralized point of understanding the shape | ||
3326 | // except that it refers to scripting constants | ||
3327 | private int getScriptPrimType(PrimitiveBaseShape primShape) | ||
3328 | { | ||
3329 | |||
3330 | if (primShape.SculptEntry) | ||
3331 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_SCULPT; | ||
3332 | if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) | ||
3333 | { | ||
3334 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
3335 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_BOX; | ||
3336 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
3337 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_TUBE; | ||
3338 | } | ||
3339 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) | ||
3340 | { | ||
3341 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
3342 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_CYLINDER; | ||
3343 | // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits | ||
3344 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
3345 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_TORUS; | ||
3346 | } | ||
3347 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) | ||
3348 | { | ||
3349 | if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte)Extrusion.Curve2) | ||
3350 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_SPHERE; | ||
3351 | } | ||
3352 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) | ||
3353 | { | ||
3354 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
3355 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_PRISM; | ||
3356 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
3357 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_RING; | ||
3358 | } | ||
3359 | return BuiltIn_Commands_BaseClass.PRIM_TYPE_BOX; | ||
3360 | |||
3361 | |||
3362 | } | ||
3363 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces | ||
3364 | private void hasCutHollowDimpleProfileCut(PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, | ||
3365 | out bool hasDimple, out bool hasProfileCut) | ||
3366 | { | ||
3367 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | ||
3368 | hasHollow = shape.ProfileHollow > 0; | ||
3369 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms | ||
3370 | hasProfileCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); // is it the same thing? | ||
3371 | |||
3372 | } | ||
3324 | 3373 | ||
3325 | public LSL_Types.LSLInteger llGetNumberOfSides() | 3374 | public LSL_Types.LSLInteger llGetNumberOfSides() |
3326 | { | 3375 | { |
3327 | m_host.AddScriptLPS(1); | 3376 | m_host.AddScriptLPS(1); |
3328 | NotImplemented("llGetNumberOfSides"); | 3377 | int ret = 0; |
3329 | return 0; | 3378 | bool hasCut; |
3379 | bool hasHollow; | ||
3380 | bool hasDimple; | ||
3381 | bool hasProfileCut; | ||
3382 | |||
3383 | hasCutHollowDimpleProfileCut(m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | ||
3384 | |||
3385 | switch (getScriptPrimType(m_host.Shape)) | ||
3386 | { | ||
3387 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_BOX: | ||
3388 | ret = 6; | ||
3389 | if (hasCut) ret += 2; | ||
3390 | if (hasHollow) ret += 1; | ||
3391 | break; | ||
3392 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_CYLINDER: | ||
3393 | ret = 3; | ||
3394 | if (hasCut) ret += 2; | ||
3395 | if (hasHollow) ret += 1; | ||
3396 | break; | ||
3397 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_PRISM: | ||
3398 | ret = 5; | ||
3399 | if (hasCut) ret += 2; | ||
3400 | if (hasHollow) ret += 1; | ||
3401 | break; | ||
3402 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_SPHERE: | ||
3403 | ret = 1; | ||
3404 | if (hasProfileCut) ret += 2; | ||
3405 | if (hasDimple) ret += 2; | ||
3406 | if (hasHollow) ret += 1; // actually lsl adds 4!!!!!! is that a great mistake? | ||
3407 | break; | ||
3408 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_TORUS: | ||
3409 | ret = 1; | ||
3410 | if (hasCut) ret += 2; | ||
3411 | if (hasProfileCut) ret += 2; | ||
3412 | if (hasHollow) ret += 1; | ||
3413 | break; | ||
3414 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_TUBE: | ||
3415 | ret = 4; | ||
3416 | if (hasCut) ret += 2; | ||
3417 | if (hasProfileCut) ret += 2; | ||
3418 | if (hasHollow) ret += 1; | ||
3419 | break; | ||
3420 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_RING: | ||
3421 | ret = 3; | ||
3422 | if (hasCut) ret += 2; | ||
3423 | if (hasProfileCut) ret += 2; | ||
3424 | if (hasHollow) ret += 1; | ||
3425 | break; | ||
3426 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_SCULPT: | ||
3427 | ret = 1; | ||
3428 | break; | ||
3429 | } | ||
3430 | |||
3431 | return ret; | ||
3330 | } | 3432 | } |
3331 | 3433 | ||
3332 | 3434 | ||