diff options
author | Melanie Thielker | 2008-08-25 11:58:55 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-08-25 11:58:55 +0000 |
commit | cf7020d73c238312e0d640fdf5fe795862f030f3 (patch) | |
tree | e37cb3c998aa84660314507d60bbeef9c460101d | |
parent | * Fix to OGP Region to Region teleports. Yay. (diff) | |
download | opensim-SC_OLD-cf7020d73c238312e0d640fdf5fe795862f030f3.zip opensim-SC_OLD-cf7020d73c238312e0d640fdf5fe795862f030f3.tar.gz opensim-SC_OLD-cf7020d73c238312e0d640fdf5fe795862f030f3.tar.bz2 opensim-SC_OLD-cf7020d73c238312e0d640fdf5fe795862f030f3.tar.xz |
Mantis #2044
Thank you, salahzar, for a patch that corrects the behavior
of PRIM_TYPE in llGetPrimitiveParams() and improves LSL
conformance in llGetNumberOfSides();
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 107 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 101 |
2 files changed, 187 insertions, 21 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 103ffff..786288b 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -3461,13 +3461,22 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3461 | 3461 | ||
3462 | } | 3462 | } |
3463 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces | 3463 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces |
3464 | private void hasCutHollowDimpleProfileCut(PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, | 3464 | private void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, |
3465 | out bool hasDimple, out bool hasProfileCut) | 3465 | out bool hasDimple, out bool hasProfileCut) |
3466 | { | 3466 | { |
3467 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | 3467 | if (primType == BuiltIn_Commands_BaseClass.PRIM_TYPE_BOX |
3468 | || | ||
3469 | primType == BuiltIn_Commands_BaseClass.PRIM_TYPE_CYLINDER | ||
3470 | || | ||
3471 | primType == BuiltIn_Commands_BaseClass.PRIM_TYPE_PRISM) | ||
3472 | |||
3473 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | ||
3474 | else | ||
3475 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); | ||
3476 | |||
3468 | hasHollow = shape.ProfileHollow > 0; | 3477 | hasHollow = shape.ProfileHollow > 0; |
3469 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms | 3478 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms |
3470 | hasProfileCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); // is it the same thing? | 3479 | hasProfileCut = hasDimple; // is it the same thing? |
3471 | 3480 | ||
3472 | } | 3481 | } |
3473 | 3482 | ||
@@ -3480,9 +3489,10 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3480 | bool hasDimple; | 3489 | bool hasDimple; |
3481 | bool hasProfileCut; | 3490 | bool hasProfileCut; |
3482 | 3491 | ||
3483 | hasCutHollowDimpleProfileCut(m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | 3492 | int primType = getScriptPrimType(m_host.Shape); |
3493 | hasCutHollowDimpleProfileCut(primType, m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | ||
3484 | 3494 | ||
3485 | switch (getScriptPrimType(m_host.Shape)) | 3495 | switch (primType) |
3486 | { | 3496 | { |
3487 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_BOX: | 3497 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_BOX: |
3488 | ret = 6; | 3498 | ret = 6; |
@@ -3501,9 +3511,9 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3501 | break; | 3511 | break; |
3502 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_SPHERE: | 3512 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_SPHERE: |
3503 | ret = 1; | 3513 | ret = 1; |
3504 | if (hasProfileCut) ret += 2; | 3514 | if (hasCut) ret += 2; |
3505 | if (hasDimple) ret += 2; | 3515 | if (hasDimple) ret += 2; |
3506 | if (hasHollow) ret += 1; // actually lsl adds 4!!!!!! is that a great mistake? | 3516 | if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1) |
3507 | break; | 3517 | break; |
3508 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_TORUS: | 3518 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_TORUS: |
3509 | ret = 1; | 3519 | ret = 1; |
@@ -3531,7 +3541,6 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3531 | return ret; | 3541 | return ret; |
3532 | } | 3542 | } |
3533 | 3543 | ||
3534 | |||
3535 | /* The new / changed functions were tested with the following LSL script: | 3544 | /* The new / changed functions were tested with the following LSL script: |
3536 | 3545 | ||
3537 | default | 3546 | default |
@@ -6267,15 +6276,89 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
6267 | break; | 6276 | break; |
6268 | 6277 | ||
6269 | case (int)BuiltIn_Commands_BaseClass.PRIM_TYPE: | 6278 | case (int)BuiltIn_Commands_BaseClass.PRIM_TYPE: |
6270 | // TODO-------------- | 6279 | |
6271 | res.Add(new LSL_Types.LSLInteger(0)); | 6280 | // implementing box |
6281 | PrimitiveBaseShape Shape=m_host.Shape; | ||
6282 | int primType=getScriptPrimType(m_host.Shape); | ||
6283 | res.Add(new LSL_Types.LSLInteger(primType)); | ||
6284 | switch(primType) | ||
6285 | { | ||
6286 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_BOX: | ||
6287 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_CYLINDER: | ||
6288 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_PRISM: | ||
6289 | |||
6290 | res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve)); | ||
6291 | res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); | ||
6292 | res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0)); | ||
6293 | res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0,Shape.PathTwist / 100.0,0)); | ||
6294 | res.Add(new LSL_Types.Vector3(1 - (Shape.PathScaleX / 100.0-1), 1 - (Shape.PathScaleY / 100.0-1), 0)); | ||
6295 | res.Add(new LSL_Types.Vector3(Shape.PathShearX / 100.0, Shape.PathShearY / 100.0, 0)); | ||
6296 | break; | ||
6297 | |||
6298 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_SPHERE: | ||
6299 | res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve)); | ||
6300 | res.Add(new LSL_Types.Vector3(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); | ||
6301 | res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0)); | ||
6302 | res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); | ||
6303 | res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); | ||
6304 | |||
6305 | break; | ||
6306 | |||
6307 | |||
6308 | |||
6309 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_SCULPT: | ||
6310 | res.Add(Shape.SculptTexture.ToString()); | ||
6311 | res.Add(new LSL_Types.LSLInteger(Shape.SculptType)); | ||
6312 | |||
6313 | break; | ||
6314 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_RING: | ||
6315 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_TUBE: | ||
6316 | case BuiltIn_Commands_BaseClass.PRIM_TYPE_TORUS: | ||
6317 | // holeshape | ||
6318 | res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve)); | ||
6319 | |||
6320 | // cut | ||
6321 | res.Add(new LSL_Types.Vector3(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); | ||
6322 | |||
6323 | // hollow | ||
6324 | res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0)); | ||
6325 | |||
6326 | // twist | ||
6327 | res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); | ||
6328 | |||
6329 | // vector holesize | ||
6330 | res.Add(new LSL_Types.Vector3(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0)); | ||
6331 | |||
6332 | // vector topshear | ||
6333 | res.Add(new LSL_Types.Vector3(Shape.PathShearX / 100.0, Shape.PathShearY / 100.0, 0)); | ||
6334 | |||
6335 | // vector profilecut | ||
6336 | res.Add(new LSL_Types.Vector3(Shape.ProfileBegin/ 50000.0, 1 - Shape.ProfileEnd / 50000.0,0)); | ||
6337 | |||
6338 | |||
6339 | // vector tapera | ||
6340 | res.Add(new LSL_Types.Vector3(Shape.PathTaperX / 100.0,Shape.PathTaperY / 100.0,0)); | ||
6341 | |||
6342 | // float revolutions, | ||
6343 | res.Add(new LSL_Types.LSLFloat(Shape.PathRevolutions/50.0)); // needs fixing :( | ||
6344 | |||
6345 | // float radiusoffset, | ||
6346 | res.Add(new LSL_Types.LSLFloat(Shape.PathRadiusOffset/100.0)); | ||
6347 | |||
6348 | // float skew | ||
6349 | res.Add(new LSL_Types.LSLFloat(Shape.PathSkew/100.0)); | ||
6350 | break; | ||
6351 | |||
6352 | |||
6353 | |||
6354 | } | ||
6272 | break; | 6355 | break; |
6273 | 6356 | ||
6274 | case (int)BuiltIn_Commands_BaseClass.PRIM_TEXTURE: | 6357 | case (int)BuiltIn_Commands_BaseClass.PRIM_TEXTURE: |
6275 | if (remain < 1) | 6358 | if (remain < 1) |
6276 | return res; | 6359 | return res; |
6277 | 6360 | ||
6278 | int face=Convert.ToInt32(rules.Data[idx++]); | 6361 | int face=Convert.ToInt32(""+rules.Data[idx++]); |
6279 | if (face == -1) | 6362 | if (face == -1) |
6280 | face = 0; | 6363 | face = 0; |
6281 | 6364 | ||
@@ -6296,7 +6379,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
6296 | if (remain < 1) | 6379 | if (remain < 1) |
6297 | return res; | 6380 | return res; |
6298 | 6381 | ||
6299 | face=Convert.ToInt32(rules.Data[idx++]); | 6382 | face=Convert.ToInt32(""+rules.Data[idx++]); |
6300 | 6383 | ||
6301 | tex = m_host.Shape.Textures; | 6384 | tex = m_host.Shape.Textures; |
6302 | LLColor texcolor; | 6385 | LLColor texcolor; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c461d3d..26a52f2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3370,12 +3370,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3370 | 3370 | ||
3371 | } | 3371 | } |
3372 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces | 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, | 3373 | private void hasCutHollowDimpleProfileCut(int primType,PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, |
3374 | out bool hasDimple, out bool hasProfileCut) | 3374 | out bool hasDimple, out bool hasProfileCut) |
3375 | { | 3375 | { |
3376 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd < 1); | 3376 | if (primType == ScriptBaseClass.PRIM_TYPE_BOX |
3377 | || | ||
3378 | primType == ScriptBaseClass.PRIM_TYPE_CYLINDER | ||
3379 | || | ||
3380 | primType == ScriptBaseClass.PRIM_TYPE_PRISM) | ||
3381 | |||
3382 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | ||
3383 | else | ||
3384 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); | ||
3385 | |||
3377 | hasHollow = shape.ProfileHollow > 0; | 3386 | hasHollow = shape.ProfileHollow > 0; |
3378 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd < 1); // taken from llSetPrimitiveParms | 3387 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms |
3379 | hasProfileCut = hasDimple; // is it the same thing? | 3388 | hasProfileCut = hasDimple; // is it the same thing? |
3380 | 3389 | ||
3381 | } | 3390 | } |
@@ -3389,9 +3398,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3389 | bool hasDimple; | 3398 | bool hasDimple; |
3390 | bool hasProfileCut; | 3399 | bool hasProfileCut; |
3391 | 3400 | ||
3392 | hasCutHollowDimpleProfileCut(m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | 3401 | int primType = getScriptPrimType(m_host.Shape); |
3402 | hasCutHollowDimpleProfileCut(primType, m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | ||
3393 | 3403 | ||
3394 | switch (getScriptPrimType(m_host.Shape)) | 3404 | switch (primType) |
3395 | { | 3405 | { |
3396 | case ScriptBaseClass.PRIM_TYPE_BOX: | 3406 | case ScriptBaseClass.PRIM_TYPE_BOX: |
3397 | ret = 6; | 3407 | ret = 6; |
@@ -3412,7 +3422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3412 | ret = 1; | 3422 | ret = 1; |
3413 | if (hasCut) ret += 2; | 3423 | if (hasCut) ret += 2; |
3414 | if (hasDimple) ret += 2; | 3424 | if (hasDimple) ret += 2; |
3415 | if (hasHollow) ret += 1; // actually lsl adds 4!!!!!! is that a great mistake? | 3425 | if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1) |
3416 | break; | 3426 | break; |
3417 | case ScriptBaseClass.PRIM_TYPE_TORUS: | 3427 | case ScriptBaseClass.PRIM_TYPE_TORUS: |
3418 | ret = 1; | 3428 | ret = 1; |
@@ -6013,15 +6023,88 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6013 | break; | 6023 | break; |
6014 | 6024 | ||
6015 | case (int)ScriptBaseClass.PRIM_TYPE: | 6025 | case (int)ScriptBaseClass.PRIM_TYPE: |
6016 | // TODO-------------- | 6026 | // implementing box |
6017 | res.Add(new LSL_Types.LSLInteger(0)); | 6027 | PrimitiveBaseShape Shape = m_host.Shape; |
6028 | int primType = getScriptPrimType(m_host.Shape); | ||
6029 | res.Add(new LSL_Types.LSLInteger(primType)); | ||
6030 | switch (primType) | ||
6031 | { | ||
6032 | case ScriptBaseClass.PRIM_TYPE_BOX: | ||
6033 | case ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
6034 | case ScriptBaseClass.PRIM_TYPE_PRISM: | ||
6035 | |||
6036 | res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve)); | ||
6037 | res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); | ||
6038 | res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0)); | ||
6039 | res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); | ||
6040 | res.Add(new LSL_Types.Vector3(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0)); | ||
6041 | res.Add(new LSL_Types.Vector3(Shape.PathShearX / 100.0, Shape.PathShearY / 100.0, 0)); | ||
6042 | break; | ||
6043 | |||
6044 | case ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
6045 | res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve)); | ||
6046 | res.Add(new LSL_Types.Vector3(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); | ||
6047 | res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0)); | ||
6048 | res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); | ||
6049 | res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); | ||
6050 | |||
6051 | break; | ||
6052 | |||
6053 | |||
6054 | |||
6055 | case ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
6056 | res.Add(Shape.SculptTexture.ToString()); | ||
6057 | res.Add(new LSL_Types.LSLInteger(Shape.SculptType)); | ||
6058 | |||
6059 | break; | ||
6060 | case ScriptBaseClass.PRIM_TYPE_RING: | ||
6061 | case ScriptBaseClass.PRIM_TYPE_TUBE: | ||
6062 | case ScriptBaseClass.PRIM_TYPE_TORUS: | ||
6063 | // holeshape | ||
6064 | res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve)); | ||
6065 | |||
6066 | // cut | ||
6067 | res.Add(new LSL_Types.Vector3(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); | ||
6068 | |||
6069 | // hollow | ||
6070 | res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0)); | ||
6071 | |||
6072 | // twist | ||
6073 | res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); | ||
6074 | |||
6075 | // vector holesize | ||
6076 | res.Add(new LSL_Types.Vector3(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0)); | ||
6077 | |||
6078 | // vector topshear | ||
6079 | res.Add(new LSL_Types.Vector3(Shape.PathShearX / 100.0, Shape.PathShearY / 100.0, 0)); | ||
6080 | |||
6081 | // vector profilecut | ||
6082 | res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); | ||
6083 | |||
6084 | |||
6085 | // vector tapera | ||
6086 | res.Add(new LSL_Types.Vector3(Shape.PathTaperX / 100.0, Shape.PathTaperY / 100.0, 0)); | ||
6087 | |||
6088 | // float revolutions, | ||
6089 | res.Add(new LSL_Types.LSLFloat(Shape.PathRevolutions / 50.0)); // needs fixing :( | ||
6090 | |||
6091 | // float radiusoffset, | ||
6092 | res.Add(new LSL_Types.LSLFloat(Shape.PathRadiusOffset / 100.0)); | ||
6093 | |||
6094 | // float skew | ||
6095 | res.Add(new LSL_Types.LSLFloat(Shape.PathSkew / 100.0)); | ||
6096 | break; | ||
6097 | |||
6098 | |||
6099 | |||
6100 | } | ||
6018 | break; | 6101 | break; |
6019 | 6102 | ||
6020 | case (int)ScriptBaseClass.PRIM_TEXTURE: | 6103 | case (int)ScriptBaseClass.PRIM_TEXTURE: |
6021 | if (remain < 1) | 6104 | if (remain < 1) |
6022 | return res; | 6105 | return res; |
6023 | 6106 | ||
6024 | int face=Convert.ToInt32(rules.Data[idx++]); | 6107 | int face = Convert.ToInt32("" + rules.Data[idx++]); |
6025 | if (face == -1) | 6108 | if (face == -1) |
6026 | face = 0; | 6109 | face = 0; |
6027 | 6110 | ||