Merge branch 'master' into careminster

This commit is contained in:
Melanie
2010-02-02 03:56:29 +00:00
14 changed files with 474 additions and 282 deletions

View File

@@ -54,8 +54,8 @@ using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using OpenSim.Services.Interfaces;
using PrimType = OpenSim.Region.Framework.Scenes.PrimType;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using AssetLandmark = OpenSim.Framework.AssetLandmark;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
@@ -1442,6 +1442,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.UpdateTexture(tex);
return;
}
if (face == ScriptBaseClass.ALL_SIDES)
face = SceneObjectPart.ALL_SIDES;
m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
}
public void SetTexGen(SceneObjectPart part, int face,int style)
@@ -1599,7 +1604,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
int i;
double sum = 0.0;
for (i = 0 ; i < GetNumberOfSides(part) ; i++)
for (i = 0 ; i < GetNumberOfSides(part); i++)
sum += (double)tex.GetFace((uint)i).RGBA.A;
return sum;
}
@@ -1749,7 +1754,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
int i;
for (i = 0 ; i < GetNumberOfSides(part) ; i++)
for (i = 0 ; i < GetNumberOfSides(part); i++)
{
texcolor = tex.GetFace((uint)i).RGBA;
rgb.x += texcolor.R;
@@ -3568,7 +3573,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List<SceneObjectPart> parts = GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
SetColor(part, color, face);
part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
}
public void llCreateLink(string target, int parent)
@@ -4423,63 +4428,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return result;
}
// this function to understand which shape it is (taken from meshmerizer)
// quite useful can be used by meshmerizer to have a centralized point of understanding the shape
// except that it refers to scripting constants
public int getScriptPrimType(PrimitiveBaseShape primShape)
{
if (primShape.SculptEntry)
return ScriptBaseClass.PRIM_TYPE_SCULPT;
if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
{
if (primShape.PathCurve == (byte)Extrusion.Straight)
return ScriptBaseClass.PRIM_TYPE_BOX;
else if (primShape.PathCurve == (byte)Extrusion.Curve1)
return ScriptBaseClass.PRIM_TYPE_TUBE;
}
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
{
if (primShape.PathCurve == (byte)Extrusion.Straight)
return ScriptBaseClass.PRIM_TYPE_CYLINDER;
// ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
else if (primShape.PathCurve == (byte)Extrusion.Curve1)
return ScriptBaseClass.PRIM_TYPE_TORUS;
}
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
{
if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte)Extrusion.Curve2)
return ScriptBaseClass.PRIM_TYPE_SPHERE;
}
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
{
if (primShape.PathCurve == (byte)Extrusion.Straight)
return ScriptBaseClass.PRIM_TYPE_PRISM;
else if (primShape.PathCurve == (byte)Extrusion.Curve1)
return ScriptBaseClass.PRIM_TYPE_RING;
}
return ScriptBaseClass.PRIM_TYPE_BOX;
}
// Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces
protected void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
out bool hasDimple, out bool hasProfileCut)
{
if (primType == ScriptBaseClass.PRIM_TYPE_BOX
||
primType == ScriptBaseClass.PRIM_TYPE_CYLINDER
||
primType == ScriptBaseClass.PRIM_TYPE_PRISM)
hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
else
hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
hasHollow = shape.ProfileHollow > 0;
hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
hasProfileCut = hasDimple; // is it the same thing?
}
public LSL_Integer llGetNumberOfSides()
{
m_host.AddScriptLPS(1);
@@ -4489,63 +4437,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected int GetNumberOfSides(SceneObjectPart part)
{
int ret = 0;
bool hasCut;
bool hasHollow;
bool hasDimple;
bool hasProfileCut;
int sides = part.GetNumberOfSides();
int primType = getScriptPrimType(part.Shape);
hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
switch (primType)
if (part.GetPrimType() == PrimType.SPHERE && part.Shape.ProfileHollow > 0)
{
case ScriptBaseClass.PRIM_TYPE_BOX:
ret = 6;
if (hasCut) ret += 2;
if (hasHollow) ret += 1;
break;
case ScriptBaseClass.PRIM_TYPE_CYLINDER:
ret = 3;
if (hasCut) ret += 2;
if (hasHollow) ret += 1;
break;
case ScriptBaseClass.PRIM_TYPE_PRISM:
ret = 5;
if (hasCut) ret += 2;
if (hasHollow) ret += 1;
break;
case ScriptBaseClass.PRIM_TYPE_SPHERE:
ret = 1;
if (hasCut) ret += 2;
if (hasDimple) ret += 2;
if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1)
break;
case ScriptBaseClass.PRIM_TYPE_TORUS:
ret = 1;
if (hasCut) ret += 2;
if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1;
break;
case ScriptBaseClass.PRIM_TYPE_TUBE:
ret = 4;
if (hasCut) ret += 2;
if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1;
break;
case ScriptBaseClass.PRIM_TYPE_RING:
ret = 3;
if (hasCut) ret += 2;
if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1;
break;
case ScriptBaseClass.PRIM_TYPE_SCULPT:
ret = 1;
break;
// Make up for a bug where LSL shows 4 sides rather than 2
sides += 2;
}
return ret;
}
return sides;
}
/* The new / changed functions were tested with the following LSL script:
@@ -4570,8 +4472,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
*/
// Xantor 29/apr/2008
// Returns rotation described by rotating angle radians about axis.
// q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2))
@@ -7203,10 +7103,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(idx++);
double alpha=(double)rules.GetLSLFloatItem(idx++);
SetColor(part, color, face);
part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
SetAlpha(part, alpha, face);
break;
case (int)ScriptBaseClass.PRIM_FLEXIBLE:
if (remain < 7)
return;
@@ -7222,6 +7123,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force);
break;
case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
if (remain < 5)
return;
@@ -7234,6 +7136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SetPointLight(part, light, lightcolor, intensity, radius, falloff);
break;
case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 2)
return;
@@ -7243,6 +7146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SetGlow(part, face, glow);
break;
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 3)
return;
@@ -7253,6 +7157,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SetShiny(part, face, shiny, bump);
break;
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 2)
return;
@@ -7260,6 +7165,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool st = rules.GetLSLIntegerItem(idx++);
SetFullBright(part, face , st);
break;
case (int)ScriptBaseClass.PRIM_MATERIAL:
if (remain < 1)
return;
@@ -7269,6 +7175,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.Material = Convert.ToByte(mat);
break;
case (int)ScriptBaseClass.PRIM_PHANTOM:
if (remain < 1)
return;
@@ -7283,6 +7190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.ScriptSetPhantomStatus(phantom);
break;
case (int)ScriptBaseClass.PRIM_PHYSICS:
if (remain < 1)
return;
@@ -7296,6 +7204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.ScriptSetPhysicsStatus(physics);
break;
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
if (remain < 1)
return;
@@ -7563,7 +7472,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules)
{
LSL_List res = new LSL_List();
int idx=0;
while (idx < rules.Length)
@@ -7625,7 +7533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE:
// implementing box
PrimitiveBaseShape Shape = part.Shape;
int primType = getScriptPrimType(part.Shape);
int primType = (int)part.GetPrimType();
res.Add(new LSL_Integer(primType));
double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX
double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY.
@@ -7705,7 +7613,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Primitive.TextureEntry tex = part.Shape.Textures;
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0 ; face < GetNumberOfSides(part) ; face++)
for (face = 0 ; face < GetNumberOfSides(part); face++)
{
Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
@@ -7747,7 +7655,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Color4 texcolor;
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0 ; face < GetNumberOfSides(part) ; face++)
for (face = 0 ; face < GetNumberOfSides(part); face++)
{
texcolor = tex.GetFace((uint)face).RGBA;
res.Add(new LSL_Vector(texcolor.R,

View File

@@ -55,6 +55,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_log.Info("[XEngine] Hooking up to server events");
myScriptEngine.World.EventManager.OnAttach += attach;
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
myScriptEngine.World.EventManager.OnObjectGrabbing += touch;
myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target;
@@ -148,7 +149,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
public void touch(uint localID, uint originalID, Vector3 offsetPos,
IClientAPI remoteClient)
IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
{
// Add to queue for all scripts in ObjectID object
DetectParams[] det = new DetectParams[1];
@@ -172,6 +173,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
det[0].LinkNum = originalPart.LinkNum;
}
if (surfaceArgs != null)
{
det[0].SurfaceTouchArgs = surfaceArgs;
}
myScriptEngine.PostObjectEvent(localID, new EventParams(
"touch", new Object[] { new LSL_Types.LSLInteger(1) },