store as llsd notation on region db, plus a few more changes

master
UbitUmarov 2020-06-14 20:45:09 +01:00
parent dfa69b1869
commit 3a5d5fd50e
2 changed files with 53 additions and 54 deletions

View File

@ -680,6 +680,8 @@ namespace OpenSim.Framework
track = new TrackEntry(-1f, "WLWater"); track = new TrackEntry(-1f, "WLWater");
waterTrack.Add(track); waterTrack.Add(track);
Name = "WLDaycycle";
if (skyTrack0.Count == 1 && skyTrack0[0].time == -1f) if (skyTrack0.Count == 1 && skyTrack0[0].time == -1f)
IsStaticDayCycle = true; IsStaticDayCycle = true;
} }
@ -912,7 +914,6 @@ namespace OpenSim.Framework
{ {
Cycle = new DayCycle(); Cycle = new DayCycle();
Cycle.FromWLOSD(array); Cycle.FromWLOSD(array);
IsLegacy = true;
} }
} }
@ -938,16 +939,16 @@ namespace OpenSim.Framework
return new Quaternion(0, -(float)Math.Sin(al), 0, (float)Math.Cos(al)); return new Quaternion(0, -(float)Math.Sin(al), 0, (float)Math.Cos(al));
} }
float sT = (float)Math.Sin(az); az *= 0.5f;
float cT = (float)Math.Cos(az); float sz = (float)Math.Sin(az);
float sP = (float)Math.Sin(al); float cz = (float)Math.Cos(az);
float cP = (float)Math.Cos(al); al *= 0.5f;
float sl = (float)Math.Sin(al);
float cl = (float)Math.Cos(al);
float angle = (float)Math.Acos(cT * cP); Quaternion rot = new Quaternion(sl * sz, -sl * cz, cl * sz, cl * cz);
Vector3 axis = new Vector3( 0, -sP, sT * cP); rot.Normalize();
axis.Normalize(); return rot;
return Quaternion.CreateFromAxisAngle(axis, angle);
} }
public static void convertFromAngles(SkyData sky, float sun_angle, float east_angle) public static void convertFromAngles(SkyData sky, float sun_angle, float east_angle)

View File

@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
byte[] envData = defEnv.Data; byte[] envData = defEnv.Data;
try try
{ {
OSD oenv = OSDParser.DeserializeLLSDXml(envData); OSD oenv = OSDParser.Deserialize(envData);
m_DefaultEnv = new ViewerEnviroment(); m_DefaultEnv = new ViewerEnviroment();
m_DefaultEnv.CycleFromOSD(oenv); m_DefaultEnv.CycleFromOSD(oenv);
} }
@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
{ {
try try
{ {
OSD oenv = OSDParser.DeserializeLLSDXml(senv); OSD oenv = OSDParser.Deserialize(senv);
ViewerEnviroment VEnv = new ViewerEnviroment(); ViewerEnviroment VEnv = new ViewerEnviroment();
if(oenv is OSDArray) if(oenv is OSDArray)
VEnv.FromWLOSD(oenv); VEnv.FromWLOSD(oenv);
@ -206,6 +206,34 @@ namespace OpenSim.Region.CoreModules.World.LightShare
#endregion #endregion
#region IEnvironmentModule #region IEnvironmentModule
private void StoreOnRegion(ViewerEnviroment VEnv)
{
try
{
if (VEnv == null)
{
m_scene.SimulationDataService.RemoveRegionEnvironmentSettings(regionID);
m_scene.RegionEnviroment = null;
m_regionEnvVersion = -1;
}
else
{
m_regionEnvVersion++;
VEnv.version = m_regionEnvVersion;
OSD env = VEnv.ToOSD();
//m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, OSDParser.SerializeLLSDXmlString(env));
m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, OSDParser.SerializeLLSDNotationFull(env));
m_scene.RegionEnviroment = VEnv;
}
m_framets = 0;
UpdateEnvTime();
}
catch (Exception e)
{
m_log.ErrorFormat("[Enviroment {0}] failed to store enviroment {1}", m_scene.Name, e.Message);
}
}
public void ResetEnvironmentSettings(UUID regionUUID) public void ResetEnvironmentSettings(UUID regionUUID)
{ {
if (!Enabled) if (!Enabled)
@ -375,17 +403,17 @@ namespace OpenSim.Region.CoreModules.World.LightShare
Int32.TryParse((string)httpRequest.Query["parcelid"], out parcel); Int32.TryParse((string)httpRequest.Query["parcelid"], out parcel);
} }
OSD oenv = ViewerEnviroment.DefaultToOSD(regionID, parcel); OSD oenv = ViewerEnviroment.DefaultToOSD(regionID, parcel);
httpResponse.RawBuffer = Util.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(oenv)); httpResponse.RawBuffer = Util.UTF8NBGetbytes(OSDParser.SerializeLLSDXmlString(oenv));
httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.StatusCode = (int)HttpStatusCode.OK;
} }
ViewerEnviroment VEnv = GetRegionEnviroment(); ViewerEnviroment VEnv = GetRegionEnviroment();
OSDMap map = new OpenMetaverse.StructuredData.OSDMap(); OSDMap map = new OSDMap();
map["environment"] = VEnv.ToOSD(); map["environment"] = VEnv.ToOSD();
string env = OSDParser.SerializeLLSDXmlString(map); string env = OSDParser.SerializeLLSDXmlString(map);
// only the presence of enviroment seems to matter
if (String.IsNullOrEmpty(env)) if (String.IsNullOrEmpty(env))
{ {
StringBuilder sb = LLSDxmlEncode.Start(); StringBuilder sb = LLSDxmlEncode.Start();
@ -439,7 +467,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
{ {
try try
{ {
OSD req = OSDParser.DeserializeLLSDXml(httpRequest.InputStream); OSD req = OSDParser.Deserialize(httpRequest.InputStream);
if(req is OpenMetaverse.StructuredData.OSDMap) if(req is OpenMetaverse.StructuredData.OSDMap)
{ {
OpenMetaverse.StructuredData.OSDMap map = req as OpenMetaverse.StructuredData.OSDMap; OpenMetaverse.StructuredData.OSDMap map = req as OpenMetaverse.StructuredData.OSDMap;
@ -451,8 +479,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare
// need a proper clone // need a proper clone
VEnv = new ViewerEnviroment(); VEnv = new ViewerEnviroment();
OSD otmp = m_DefaultEnv.ToOSD(); OSD otmp = m_DefaultEnv.ToOSD();
byte[] btmp = OSDParser.SerializeLLSDXmlToBytes(otmp); string tmpstr = OSDParser.SerializeLLSDXmlString(otmp);
otmp = OSDParser.DeserializeLLSDXml(btmp); otmp = OSDParser.DeserializeLLSDXml(tmpstr);
VEnv.FromOSD(otmp); VEnv.FromOSD(otmp);
} }
OSDMap evmap = (OSDMap)env; OSDMap evmap = (OSDMap)env;
@ -488,10 +516,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
} }
else if (req is OSDArray) else if (req is OSDArray)
{ {
ViewerEnviroment VEnv = m_scene.RegionEnviroment; ViewerEnviroment VEnv = new ViewerEnviroment();
if (VEnv == null)
VEnv = new ViewerEnviroment();
VEnv.FromWLOSD(req); VEnv.FromWLOSD(req);
StoreOnRegion(VEnv); StoreOnRegion(VEnv);
success = true; success = true;
@ -506,7 +531,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
LLSDxmlEncode.AddElem("regionID", regionID, sb); LLSDxmlEncode.AddElem("regionID", regionID, sb);
LLSDxmlEncode.AddElem("success", success, sb); LLSDxmlEncode.AddElem("success", success, sb);
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
httpResponse.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(sb)); httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDxmlEncode.End(sb));
httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.StatusCode = (int)HttpStatusCode.OK;
return; return;
} }
@ -531,7 +556,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
response = LLSDxmlEncode.End(sb); response = LLSDxmlEncode.End(sb);
httpResponse.RawBuffer = Util.UTF8.GetBytes(response); httpResponse.RawBuffer = Util.UTF8NBGetbytes(response);
httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.StatusCode = (int)HttpStatusCode.OK;
} }
@ -561,32 +586,6 @@ namespace OpenSim.Region.CoreModules.World.LightShare
response.StatusCode = (int)HttpStatusCode.OK; response.StatusCode = (int)HttpStatusCode.OK;
} }
private void StoreOnRegion(ViewerEnviroment VEnv)
{
try
{
if (VEnv == null)
{
m_scene.SimulationDataService.RemoveRegionEnvironmentSettings(regionID);
m_scene.RegionEnviroment = null;
m_regionEnvVersion = -1;
}
else
{
m_regionEnvVersion++;
VEnv.version = m_regionEnvVersion;
OSD env = VEnv.ToOSD();
m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, OSDParser.SerializeLLSDXmlString(env));
m_scene.RegionEnviroment = VEnv;
}
m_framets = 0;
UpdateEnvTime();
}
catch (Exception e)
{
m_log.ErrorFormat("[Enviroment {0}] failed to store enviroment {1}", m_scene.Name, e.Message);
}
}
private void SetEnvironmentSettings(IOSHttpRequest request, IOSHttpResponse response, UUID agentID) private void SetEnvironmentSettings(IOSHttpRequest request, IOSHttpResponse response, UUID agentID)
{ {
@ -605,7 +604,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
try try
{ {
ViewerEnviroment VEnv = new ViewerEnviroment(); ViewerEnviroment VEnv = new ViewerEnviroment();
OSD env = OSDParser.DeserializeLLSDXml(request.InputStream); OSD env = OSDParser.Deserialize(request.InputStream);
VEnv.FromWLOSD(env); VEnv.FromWLOSD(env);
StoreOnRegion(VEnv); StoreOnRegion(VEnv);
success = true; success = true;
@ -633,7 +632,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
if(!success) if(!success)
LLSDxmlEncode.AddElem("fail_reason", fail_reason, sb); LLSDxmlEncode.AddElem("fail_reason", fail_reason, sb);
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
response.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(sb)); response.RawBuffer = Util.UTF8NBGetbytes(LLSDxmlEncode.End(sb));
response.StatusCode = (int)HttpStatusCode.OK; response.StatusCode = (int)HttpStatusCode.OK;
} }
@ -676,8 +675,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
default: default:
return null; return null;
} }
string sdata = OSDParser.SerializeLLSDXmlString(osddata); return OSDParser.SerializeLLSDNotationToBytes(osddata,true);
return Util.UTF8NBGetbytes(sdata);
} }
public List<byte[]> MakeLightShareData() public List<byte[]> MakeLightShareData()