allow the use of Sky or water from a asset, not just full daycycle. This may need more work

master
UbitUmarov 2020-07-15 22:56:09 +01:00
parent f7104a66a5
commit 1f822c6077
3 changed files with 107 additions and 10 deletions

View File

@ -137,6 +137,59 @@ namespace OpenSim.Framework
array[3] = new OSDMap();
}
public bool replaceWaterFromOSD(string name, OSDMap map)
{
WaterData water = new WaterData();
if(string.IsNullOrWhiteSpace(name))
name = "Water";
try
{
water.FromOSD(name, map);
}
catch
{
return false;
}
waterframes.Clear();
waterframes[name] = water;
waterTrack.Clear();
TrackEntry t = new TrackEntry()
{
time = -1,
frameName = name
};
waterTrack.Add(t);
return true;
}
public bool replaceSkyFromOSD(string name, OSDMap map)
{
SkyData sky = new SkyData();
if (string.IsNullOrWhiteSpace(name))
name = "Sky";
try
{
sky.FromOSD(name, map);
}
catch
{
return false;
}
skyframes.Clear();
skyframes[name] = sky;
TrackEntry t = new TrackEntry()
{
time = -1,
frameName = name
};
skyTrack0.Clear();
skyTrack0.Add(t);
skyTracks = new List<TrackEntry>[3];
return true;
}
public void FromOSD(OSDMap map)
{
CompareTrackEntries cte = new CompareTrackEntries();
@ -188,9 +241,11 @@ namespace OpenSim.Framework
{
if (d.TryGetValue("key_name", out OSD dname))
{
TrackEntry t = new TrackEntry();
t.time = dtime;
t.frameName = dname;
TrackEntry t = new TrackEntry()
{
time = dtime,
frameName = dname
};
waterTrack.Add(t);
}
}

View File

@ -383,6 +383,42 @@ namespace OpenSim.Framework
return true;
}
public bool FromAssetOSD(string name, OSD osd)
{
OSDMap map = osd as OSDMap;
if (map == null)
return false;
if (!map.TryGetValue("type", out OSD tmp))
return false;
string type = tmp.AsString();
bool ok = false;
if (type == "water")
{
if (Cycle == null)
Cycle = new DayCycle();
ok = Cycle.replaceWaterFromOSD(name, map);
}
else
{
if (type == "daycycle")
{
Cycle = new DayCycle();
Cycle.FromOSD(map);
ok = true;
}
else if(type == "sky")
{
if (Cycle == null)
Cycle = new DayCycle();
ok = Cycle.replaceSkyFromOSD(name, map);
}
}
if(ok && !string.IsNullOrWhiteSpace(name))
Cycle.Name = name;
return ok;
}
public OSD ToOSD()
{
OSDMap env = new OSDMap();

View File

@ -594,16 +594,16 @@ namespace OpenSim.Region.CoreModules.World.LightShare
try
{
OSD req = OSDParser.Deserialize(httpRequest.InputStream);
if(req is OpenMetaverse.StructuredData.OSDMap)
if(req is OSDMap)
{
OSDMap map = req as OpenMetaverse.StructuredData.OSDMap;
OSDMap map = req as OSDMap;
if(map.TryGetValue("environment", out OSD env))
{
if (VEnv == null)
// need a proper clone
VEnv = m_DefaultEnv.Clone();
OSDMap evmap = (OSDMap)env;
OSDMap evmap = env as OSDMap;
if(evmap.TryGetValue("day_asset", out OSD tmp) && !evmap.ContainsKey("day_cycle"))
{
string id = tmp.AsString();
@ -616,7 +616,11 @@ namespace OpenSim.Region.CoreModules.World.LightShare
try
{
OSD oenv = OSDParser.Deserialize(asset.Data);
VEnv.CycleFromOSD(oenv);
evmap.TryGetValue("day_name", out tmp);
if(tmp is OSDString)
VEnv.FromAssetOSD(tmp.AsString(), oenv);
else
VEnv.FromAssetOSD(null, oenv);
}
catch
{
@ -624,7 +628,9 @@ namespace OpenSim.Region.CoreModules.World.LightShare
return;
}
}
else
VEnv.FromOSD(env);
if(lchannel == null)
{
StoreOnRegion(VEnv);