mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
Merge branch 'master' into presence-refactor
This was a large, heavily conflicted merge and things MAY have got broken. Please check!
This commit is contained in:
@@ -55,7 +55,7 @@ using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
|
||||
|
||||
using PrimType = OpenSim.Region.Framework.Scenes.PrimType;
|
||||
using AssetLandmark = OpenSim.Framework.AssetLandmark;
|
||||
|
||||
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
|
||||
@@ -1331,44 +1331,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
SetColor(m_host, color, face);
|
||||
}
|
||||
|
||||
protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
|
||||
{
|
||||
Primitive.TextureEntry tex = part.Shape.Textures;
|
||||
Color4 texcolor;
|
||||
if (face >= 0 && face < GetNumberOfSides(part))
|
||||
{
|
||||
texcolor = tex.CreateFace((uint)face).RGBA;
|
||||
texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
|
||||
texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
|
||||
texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
|
||||
tex.FaceTextures[face].RGBA = texcolor;
|
||||
part.UpdateTexture(tex);
|
||||
return;
|
||||
}
|
||||
else if (face == ScriptBaseClass.ALL_SIDES)
|
||||
{
|
||||
for (uint i = 0; i < GetNumberOfSides(part); i++)
|
||||
{
|
||||
if (tex.FaceTextures[i] != null)
|
||||
{
|
||||
texcolor = tex.FaceTextures[i].RGBA;
|
||||
texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
|
||||
texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
|
||||
texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
|
||||
tex.FaceTextures[i].RGBA = texcolor;
|
||||
}
|
||||
texcolor = tex.DefaultTexture.RGBA;
|
||||
texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
|
||||
texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
|
||||
texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
|
||||
tex.DefaultTexture.RGBA = texcolor;
|
||||
}
|
||||
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)
|
||||
@@ -1515,7 +1481,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;
|
||||
}
|
||||
@@ -1662,7 +1628,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;
|
||||
@@ -3415,7 +3381,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)
|
||||
@@ -4262,7 +4228,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
if (item.Type == 10 && item.ItemID == m_itemID)
|
||||
{
|
||||
result = item.Name!=null?item.Name:String.Empty;
|
||||
result = item.Name != null ? item.Name : String.Empty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4271,63 +4237,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);
|
||||
@@ -4337,63 +4246,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:
|
||||
|
||||
@@ -4418,8 +4281,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))
|
||||
@@ -7020,10 +6881,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;
|
||||
@@ -7039,6 +6901,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;
|
||||
@@ -7051,6 +6914,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
SetPointLight(part, light, lightcolor, intensity, radius, falloff);
|
||||
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_GLOW:
|
||||
if (remain < 2)
|
||||
return;
|
||||
@@ -7060,6 +6924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
SetGlow(part, face, glow);
|
||||
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
|
||||
if (remain < 3)
|
||||
return;
|
||||
@@ -7070,6 +6935,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
SetShiny(part, face, shiny, bump);
|
||||
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
|
||||
if (remain < 2)
|
||||
return;
|
||||
@@ -7077,6 +6943,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;
|
||||
@@ -7086,6 +6953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
part.Material = Convert.ToByte(mat);
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_PHANTOM:
|
||||
if (remain < 1)
|
||||
return;
|
||||
@@ -7100,6 +6968,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
part.ScriptSetPhantomStatus(phantom);
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_PHYSICS:
|
||||
if (remain < 1)
|
||||
return;
|
||||
@@ -7113,6 +6982,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
part.ScriptSetPhysicsStatus(physics);
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
|
||||
if (remain < 1)
|
||||
return;
|
||||
@@ -7380,7 +7250,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)
|
||||
@@ -7442,7 +7311,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.
|
||||
@@ -7522,7 +7391,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);
|
||||
|
||||
@@ -7564,7 +7433,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,
|
||||
|
||||
Reference in New Issue
Block a user