cosmetics

This commit is contained in:
UbitUmarov
2023-02-24 12:35:12 +00:00
parent 7b23e2fe08
commit 833cd468ff
7 changed files with 267 additions and 507 deletions

View File

@@ -177,11 +177,11 @@ namespace OpenSim.Framework
"[SHAPE]: Attempt to set a ProfileCurve with a hollow shape value of {0}, which isn't a valid enum. Replacing with default shape.",
hollowShapeByte);
this._hollowShape = HollowShape.Same;
_hollowShape = HollowShape.Same;
}
else
{
this._hollowShape = (HollowShape)hollowShapeByte;
_hollowShape = (HollowShape)hollowShapeByte;
}
// Handle profile shape component
@@ -193,11 +193,11 @@ namespace OpenSim.Framework
"[SHAPE]: Attempt to set a ProfileCurve with a profile shape value of {0}, which isn't a valid enum. Replacing with square.",
profileShapeByte);
this._profileShape = ProfileShape.Square;
_profileShape = ProfileShape.Square;
}
else
{
this._profileShape = (ProfileShape)profileShapeByte;
_profileShape = (ProfileShape)profileShapeByte;
}
}
}
@@ -305,55 +305,56 @@ namespace OpenSim.Framework
public static PrimitiveBaseShape Create()
{
PrimitiveBaseShape shape = new PrimitiveBaseShape();
return shape;
return new PrimitiveBaseShape();
}
public static PrimitiveBaseShape CreateBox()
{
PrimitiveBaseShape shape = Create();
shape._pathCurve = (byte) Extrusion.Straight;
shape._profileShape = ProfileShape.Square;
shape._pathScaleX = 100;
shape._pathScaleY = 100;
PrimitiveBaseShape shape = new()
{
_pathCurve = (byte)Extrusion.Straight,
_profileShape = ProfileShape.Square,
_pathScaleX = 100,
_pathScaleY = 100
};
return shape;
}
public static PrimitiveBaseShape CreateSphere()
{
PrimitiveBaseShape shape = Create();
shape._pathCurve = (byte) Extrusion.Curve1;
shape._profileShape = ProfileShape.HalfCircle;
shape._pathScaleX = 100;
shape._pathScaleY = 100;
PrimitiveBaseShape shape = new()
{
_pathCurve = (byte)Extrusion.Curve1,
_profileShape = ProfileShape.HalfCircle,
_pathScaleX = 100,
_pathScaleY = 100
};
return shape;
}
public static PrimitiveBaseShape CreateCylinder()
{
PrimitiveBaseShape shape = Create();
shape._pathCurve = (byte) Extrusion.Curve1;
shape._profileShape = ProfileShape.Square;
shape._pathScaleX = 100;
shape._pathScaleY = 100;
PrimitiveBaseShape shape = new()
{
_pathCurve = (byte)Extrusion.Curve1,
_profileShape = ProfileShape.Square,
_pathScaleX = 100,
_pathScaleY = 100
};
return shape;
}
public static PrimitiveBaseShape CreateMesh(int numberOfFaces, UUID meshAssetID)
{
PrimitiveBaseShape shape = new PrimitiveBaseShape();
PrimitiveBaseShape shape = new()
{
_pathScaleX = 100,
_pathScaleY = 100
};
shape._pathScaleX = 100;
shape._pathScaleY = 100;
if(numberOfFaces <= 0) // oops ?
if (numberOfFaces <= 0) // oops ?
numberOfFaces = 1;
switch(numberOfFaces)
@@ -1025,20 +1026,20 @@ namespace OpenSim.Framework
return hash;
}
private ulong djb2(ulong hash, byte c)
private static ulong djb2(ulong hash, byte c)
{
//return ((hash << 5) + hash) + (ulong)c;
return 33 * hash + (ulong)c;
}
private ulong djb2(ulong hash, ushort c)
private static ulong djb2(ulong hash, ushort c)
{
//hash = ((hash << 5) + hash) + (ulong)((byte)c);
//return ((hash << 5) + hash) + (ulong)(c >> 8);
return 33 * hash + c;
}
private ulong djb2(ulong hash, float c)
private static ulong djb2(ulong hash, float c)
{
//hash = ((hash << 5) + hash) + (ulong)((byte)c);
//return ((hash << 5) + hash) + (ulong)(c >> 8);
@@ -1427,7 +1428,7 @@ namespace OpenSim.Framework
if (data.Length - pos >= 16)
{
_lightEntry = true;
Color4 lColor = new Color4(data, pos, false);
Color4 lColor = new(data, pos, false);
_lightIntensity = lColor.A;
_lightColorA = 1f;
_lightColorR = lColor.R;
@@ -1547,80 +1548,89 @@ namespace OpenSim.Framework
/// <returns></returns>
public Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation)
{
OpenMetaverse.Primitive prim = new OpenMetaverse.Primitive();
prim.Scale = this.Scale;
prim.Position = position;
prim.Rotation = rotation;
OpenMetaverse.Primitive prim = new()
{
Scale = this.Scale,
Position = position,
Rotation = rotation
};
if (this.SculptEntry)
{
prim.Sculpt = new Primitive.SculptData();
prim.Sculpt.Type = (OpenMetaverse.SculptType)this.SculptType;
prim.Sculpt.SculptTexture = this.SculptTexture;
prim.Sculpt = new Primitive.SculptData
{
Type = (OpenMetaverse.SculptType)SculptType,
SculptTexture = SculptTexture
};
}
prim.PrimData.PathShearX = this.PathShearX < 128 ? (float)this.PathShearX * 0.01f : (float)(this.PathShearX - 256) * 0.01f;
prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (float)(this.PathShearY - 256) * 0.01f;
prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f;
prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f;
prim.PrimData.PathShearX = PathShearX < 128 ? (float)PathShearX * 0.01f : (float)(PathShearX - 256) * 0.01f;
prim.PrimData.PathShearY = PathShearY < 128 ? (float)PathShearY * 0.01f : (float)(PathShearY - 256) * 0.01f;
prim.PrimData.PathBegin = (float)PathBegin * 2.0e-5f;
prim.PrimData.PathEnd = 1.0f - (float)PathEnd * 2.0e-5f;
prim.PrimData.PathScaleX = (200 - this.PathScaleX) * 0.01f;
prim.PrimData.PathScaleY = (200 - this.PathScaleY) * 0.01f;
prim.PrimData.PathScaleX = (200 - PathScaleX) * 0.01f;
prim.PrimData.PathScaleY = (200 - PathScaleY) * 0.01f;
prim.PrimData.PathTaperX = this.PathTaperX * 0.01f;
prim.PrimData.PathTaperY = this.PathTaperY * 0.01f;
prim.PrimData.PathTaperX = PathTaperX * 0.01f;
prim.PrimData.PathTaperY = PathTaperY * 0.01f;
prim.PrimData.PathTwistBegin = this.PathTwistBegin * 0.01f;
prim.PrimData.PathTwist = this.PathTwist * 0.01f;
prim.PrimData.PathTwistBegin = PathTwistBegin * 0.01f;
prim.PrimData.PathTwist = PathTwist * 0.01f;
prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f;
prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f;
prim.PrimData.ProfileHollow = (float)this.ProfileHollow * 2.0e-5f;
prim.PrimData.ProfileBegin = (float)ProfileBegin * 2.0e-5f;
prim.PrimData.ProfileEnd = 1.0f - (float)ProfileEnd * 2.0e-5f;
prim.PrimData.ProfileHollow = (float)ProfileHollow * 2.0e-5f;
prim.PrimData.profileCurve = this.ProfileCurve;
prim.PrimData.ProfileHole = (HoleType)this.HollowShape;
prim.PrimData.profileCurve = ProfileCurve;
prim.PrimData.ProfileHole = (HoleType)HollowShape;
prim.PrimData.PathCurve = (PathCurve)this.PathCurve;
prim.PrimData.PathRadiusOffset = 0.01f * this.PathRadiusOffset;
prim.PrimData.PathRevolutions = 1.0f + 0.015f * this.PathRevolutions;
prim.PrimData.PathSkew = 0.01f * this.PathSkew;
prim.PrimData.PathCurve = (PathCurve)PathCurve;
prim.PrimData.PathRadiusOffset = 0.01f * PathRadiusOffset;
prim.PrimData.PathRevolutions = 1.0f + 0.015f * PathRevolutions;
prim.PrimData.PathSkew = 0.01f * PathSkew;
prim.PrimData.PCode = OpenMetaverse.PCode.Prim;
prim.PrimData.State = 0;
if (this.FlexiEntry)
if (FlexiEntry)
{
prim.Flexible = new Primitive.FlexibleData();
prim.Flexible.Drag = this.FlexiDrag;
prim.Flexible.Force = new Vector3(this.FlexiForceX, this.FlexiForceY, this.FlexiForceZ);
prim.Flexible.Gravity = this.FlexiGravity;
prim.Flexible.Softness = this.FlexiSoftness;
prim.Flexible.Tension = this.FlexiTension;
prim.Flexible.Wind = this.FlexiWind;
prim.Flexible = new Primitive.FlexibleData
{
Drag = FlexiDrag,
Force = new Vector3(FlexiForceX, FlexiForceY, FlexiForceZ),
Gravity = FlexiGravity,
Softness = FlexiSoftness,
Tension = FlexiTension,
Wind = FlexiWind
};
}
if (this.LightEntry)
if (LightEntry)
{
prim.Light = new Primitive.LightData();
prim.Light.Color = new Color4(this.LightColorR, this.LightColorG, this.LightColorB, this.LightColorA);
prim.Light.Cutoff = this.LightCutoff;
prim.Light.Falloff = this.LightFalloff;
prim.Light.Intensity = this.LightIntensity;
prim.Light.Radius = this.LightRadius;
prim.Light = new Primitive.LightData
{
Color = new Color4(LightColorR, LightColorG, LightColorB, LightColorA),
Cutoff = LightCutoff,
Falloff = LightFalloff,
Intensity = LightIntensity,
Radius = LightRadius
};
}
prim.Textures = this.Textures;
prim.Textures = Textures;
prim.Properties = new Primitive.ObjectProperties();
prim.Properties.Name = "Object";
prim.Properties.Description = "";
prim.Properties.CreatorID = UUID.Zero;
prim.Properties.GroupID = UUID.Zero;
prim.Properties.OwnerID = UUID.Zero;
prim.Properties.Permissions = new Permissions();
prim.Properties.SalePrice = 10;
prim.Properties.SaleType = new SaleType();
prim.Properties = new Primitive.ObjectProperties
{
Name = "Object",
Description = "",
CreatorID = UUID.Zero,
GroupID = UUID.Zero,
OwnerID = UUID.Zero,
Permissions = new Permissions(),
SalePrice = 10,
SaleType = new SaleType()
};
return prim;
}
@@ -1647,15 +1657,15 @@ namespace OpenSim.Framework
{
lock (this)
{
using (StringWriter sw = new StringWriter())
using (StringWriter sw = new())
{
using (XmlTextWriter xtw = new XmlTextWriter(sw))
using (XmlTextWriter xtw = new(sw))
{
xtw.WriteStartElement("OSMedia");
xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE);
xtw.WriteAttributeString("version", "0.1");
OSDArray meArray = new OSDArray();
OSDArray meArray = new();
foreach (MediaEntry me in this)
{
OSD osd = (null == me ? new OSD() : me.GetOSD());
@@ -1684,7 +1694,7 @@ namespace OpenSim.Framework
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static MediaList FromXml(string rawXml)
{
MediaList ml = new MediaList();
MediaList ml = new();
ml.ReadXml(rawXml);
if(ml.Count == 0)
return null;
@@ -1695,9 +1705,9 @@ namespace OpenSim.Framework
{
try
{
using (StringReader sr = new StringReader(rawXml))
using (StringReader sr = new(rawXml))
{
using (XmlTextReader xtr = new XmlTextReader(sr))
using (XmlTextReader xtr = new(sr))
{
xtr.DtdProcessing = DtdProcessing.Ignore;
xtr.MoveToContent();
@@ -1710,10 +1720,9 @@ namespace OpenSim.Framework
xtr.ReadStartElement("OSMedia");
OSD osdp = OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
if(osdp == null || !(osdp is OSDArray))
if(osdp is not OSDArray osdMeArray)
return;
OSDArray osdMeArray = osdp as OSDArray;
if(osdMeArray.Count == 0)
return;