more on SendViewerTime()

master
UbitUmarov 2020-06-13 15:48:35 +01:00
parent 3bf0f6c407
commit b37141182a
6 changed files with 95 additions and 173 deletions

View File

@ -1286,21 +1286,8 @@ namespace OpenSim.Framework
void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch,
string[] buttonlabels); string[] buttonlabels);
/// <summary> void SendViewerTime(Vector3 sunDir, float sunphase);
/// Update the client as to where the sun is currently located.
/// </summary>
/// <param name="sunPos"></param>
/// <param name="sunVel"></param>
/// <param name="CurrentTime">Seconds since Unix Epoch 01/01/1970 00:00:00</param>
/// <param name="SecondsPerSunCycle"></param>
/// <param name="SecondsPerYear"></param>
/// <param name="OrbitalPosition">The orbital position is given in radians, and must be "adjusted" for the linden client, see LLClientView</param>
//void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear,
// float OrbitalPosition);
void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle);
void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks); void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks);
void SendViewerTime(int phase);
void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, string flAbout, void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, string flAbout,
uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID); uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID);

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
@ -1208,46 +1209,40 @@ namespace OpenSim.Framework
return top; return top;
} }
public bool getPositions(float altitude, float dayfrac, out Vector3 sundir, out Vector3 moondir, [MethodImpl(MethodImplOptions.AggressiveInlining)]
out Quaternion sunrot, out Quaternion moonrot) public List<DayCycle.TrackEntry> FindTrack(float altitude)
{ {
sundir = Vector3.Zero;
moondir = Vector3.Zero;
sunrot = Quaternion.Identity;
moonrot = Quaternion.Identity;
List<DayCycle.TrackEntry> track = null;
if (altitude < Altitudes[0]) if (altitude < Altitudes[0])
track = Cycle.skyTrack0; return Cycle.skyTrack0;
else
{
int altindx = 2;
for (; altindx > 0; --altindx)
{
if (Altitudes[altindx] < altitude)
break;
}
while (altindx >= 0) int altindx = 1;
{ for (; altindx < Altitudes.Length; ++altindx)
track = Cycle.skyTracks[altindx]; {
if (track != null && track.Count > 0) if (Altitudes[altindx] > altitude)
break; break;
--altindx;
}
} }
if (track == null || track.Count == 0) List<DayCycle.TrackEntry> track = null;
return false; while (--altindx >= 0)
{
track = Cycle.skyTracks[altindx];
if (track != null && track.Count > 0)
break;
}
return track;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool FindSkies(List<DayCycle.TrackEntry> track, float dayfrac, out float skyfrac, out SkyData sky1, out SkyData sky2)
{
sky1 = null;
sky2 = null;
skyfrac = dayfrac;
if (track.Count == 1 || track[0].time < 0) if (track.Count == 1 || track[0].time < 0)
{ {
if (!Cycle.skyframes.TryGetValue(track[0].frameName, out SkyData sky) || sky == null) if (!Cycle.skyframes.TryGetValue(track[0].frameName, out sky1) || sky1 == null)
return false; return false;
moonrot = sky.moon_rotation;
moondir = Xrot(moonrot);
sunrot = sky.sun_rotation;
sundir = Xrot(sunrot);
return true; return true;
} }
@ -1263,6 +1258,7 @@ namespace OpenSim.Framework
float secondFrac; float secondFrac;
string first; string first;
string second; string second;
int ntracks = track.Count; int ntracks = track.Count;
if (i == 0 || i == ntracks) if (i == 0 || i == ntracks)
{ {
@ -1281,22 +1277,50 @@ namespace OpenSim.Framework
first = track[i].frameName; first = track[i].frameName;
} }
if (!Cycle.skyframes.TryGetValue(first, out SkyData sky1) || sky1 == null) if (!Cycle.skyframes.TryGetValue(first, out sky1) || sky1 == null)
firstFrac = -1; firstFrac = -1;
if (!Cycle.skyframes.TryGetValue(second, out SkyData sky2) || sky2 == null) if (!Cycle.skyframes.TryGetValue(second, out sky2) || sky2 == null)
secondFrac = -1; secondFrac = -1;
if (firstFrac < 0) if (firstFrac < 0)
{ {
if (secondFrac < 0) if (secondFrac < 0)
return false; return false;
moonrot = sky2.moon_rotation;
moondir = Xrot(moonrot); sky1 = sky2;
sunrot = sky2.sun_rotation; sky2 = null;
sundir = Xrot(sunrot);
return true; return true;
} }
if (secondFrac < 0 || secondFrac == firstFrac) if (secondFrac < 0 || secondFrac == firstFrac)
{
sky2 = null;
return true;
}
dayfrac -= firstFrac;
secondFrac -= firstFrac;
dayfrac /= secondFrac;
skyfrac = Utils.Clamp(dayfrac, 0, 1f);
return true;
}
public bool getPositions(float altitude, float dayfrac, out Vector3 sundir, out Vector3 moondir,
out Quaternion sunrot, out Quaternion moonrot)
{
sundir = Vector3.Zero;
moondir = Vector3.Zero;
sunrot = Quaternion.Identity;
moonrot = Quaternion.Identity;
List<DayCycle.TrackEntry> track = FindTrack(altitude);
if (track == null || track.Count == 0)
return false;
if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2))
return false;
if (sky2 == null)
{ {
moonrot = sky1.moon_rotation; moonrot = sky1.moon_rotation;
moondir = Xrot(moonrot); moondir = Xrot(moonrot);
@ -1305,10 +1329,6 @@ namespace OpenSim.Framework
return true; return true;
} }
dayfrac -= firstFrac;
secondFrac -= firstFrac;
dayfrac /= secondFrac;
moonrot = Quaternion.Slerp(sky1.moon_rotation, sky2.moon_rotation, dayfrac); moonrot = Quaternion.Slerp(sky1.moon_rotation, sky2.moon_rotation, dayfrac);
moondir = Xrot(moonrot); moondir = Xrot(moonrot);
@ -1321,93 +1341,21 @@ namespace OpenSim.Framework
{ {
sundir = Vector3.Zero; sundir = Vector3.Zero;
List<DayCycle.TrackEntry> track = null; List<DayCycle.TrackEntry> track = track = FindTrack(altitude);
if (altitude < Altitudes[0])
track = Cycle.skyTrack0;
else
{
int altindx = 2;
for (; altindx > 0; --altindx)
{
if (Altitudes[altindx] < altitude)
break;
}
while (altindx >= 0)
{
track = Cycle.skyTracks[altindx];
if (track != null && track.Count > 0)
break;
--altindx;
}
}
if (track == null || track.Count == 0) if (track == null || track.Count == 0)
return false; return false;
if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2))
return false;
Quaternion sunrot; Quaternion sunrot;
if (track.Count == 1 || track[0].time < 0) if (sky2 == null)
{
if (!Cycle.skyframes.TryGetValue(track[0].frameName, out SkyData sky) || sky == null)
return false;
sunrot = sky.sun_rotation;
sundir = Xrot(sunrot);
return true;
}
int i = 0;
while (i < track.Count)
{
if (track[i].time > dayfrac)
break;
++i;
}
float firstFrac;
float secondFrac;
string first;
string second;
int ntracks = track.Count;
if (i == 0 || i == ntracks)
{
--ntracks;
firstFrac = track[ntracks].time;
first = track[ntracks].frameName;
secondFrac = track[0].time + 1f;
second = track[0].frameName;
}
else
{
secondFrac = track[i].time;
second = track[i].frameName;
--i;
firstFrac = track[i].time;
first = track[i].frameName;
}
if (!Cycle.skyframes.TryGetValue(first, out SkyData sky1) || sky1 == null)
firstFrac = -1;
if (!Cycle.skyframes.TryGetValue(second, out SkyData sky2) || sky2 == null)
secondFrac = -1;
if (firstFrac < 0)
{
if (secondFrac < 0)
return false;
sunrot = sky2.sun_rotation;
sundir = Xrot(sunrot);
return true;
}
if (secondFrac < 0 || secondFrac == firstFrac)
{ {
sunrot = sky1.sun_rotation; sunrot = sky1.sun_rotation;
sundir = Xrot(sunrot); sundir = Xrot(sunrot);
return true; return true;
} }
dayfrac -= firstFrac;
secondFrac -= firstFrac;
dayfrac /= secondFrac;
sunrot = Quaternion.Slerp(sky1.sun_rotation, sky2.sun_rotation, dayfrac); sunrot = Quaternion.Slerp(sky1.sun_rotation, sky2.sun_rotation, dayfrac);
sundir = Xrot(sunrot); sundir = Xrot(sunrot);
return true; return true;

View File

@ -46,6 +46,8 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
using OSDArray = OpenMetaverse.StructuredData.OSDArray; using OSDArray = OpenMetaverse.StructuredData.OSDArray;
using OSDMap = OpenMetaverse.StructuredData.OSDMap; using OSDMap = OpenMetaverse.StructuredData.OSDMap;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
namespace OpenSim.Region.CoreModules.World.LightShare namespace OpenSim.Region.CoreModules.World.LightShare
{ {
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EnvironmentModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EnvironmentModule")]
@ -539,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
// Name, agentID, caps.RegionName); // Name, agentID, caps.RegionName);
ViewerEnviroment VEnv = GetRegionEnviroment(); ViewerEnviroment VEnv = GetRegionEnviroment();
OSD d = VEnv.ToWLOSD(UUID.Zero, regionID); OSD d = VEnv.ToWLOSD(UUID.Zero, regionID);
string env = OSDParser.SerializeLLSDXmlString(d); string env = OSDParser.SerializeLLSDXmlString(d);
@ -750,24 +752,27 @@ namespace OpenSim.Region.CoreModules.World.LightShare
private void UpdateClientsSunTime() private void UpdateClientsSunTime()
{ {
if(m_scene.GetNumberOfClients() == 0)
return;
ViewerEnviroment env = GetRegionEnviroment(); ViewerEnviroment env = GetRegionEnviroment();
float dayFrac = GetDayFractionTime(env); float dayFrac = GetDayFractionTime(env);
// don't ask me what this mess is, just is
float wldayFrac = dayFrac; float wldayFrac = dayFrac;
if (wldayFrac < 0.25f)
wldayFrac += 1.5f;
else if (wldayFrac > 0.75)
wldayFrac += 0.5f;
else if (wldayFrac > 0.33)
wldayFrac = 3 * wldayFrac - 1;
else
wldayFrac = 3 * wldayFrac + 1;
wldayFrac = Utils.Clamp(wldayFrac, 0, 2); if (wldayFrac <= 0.25f)
wldayFrac += 1.5f;
else if (wldayFrac > 0.75f)
wldayFrac += 0.5f;
else if (wldayFrac >= 0.333333f)
wldayFrac = 3f * wldayFrac - 1f;
else
wldayFrac = 3f * wldayFrac + 1f;
wldayFrac = Utils.Clamp(wldayFrac, 0, 2f);
wldayFrac *= Utils.PI; wldayFrac *= Utils.PI;
dayFrac *= Utils.TWO_PI; float eepDayFrac = dayFrac * Utils.TWO_PI;
m_scene.ForEachRootScenePresence(delegate (ScenePresence sp) m_scene.ForEachRootScenePresence(delegate (ScenePresence sp)
{ {
@ -779,12 +784,12 @@ namespace OpenSim.Region.CoreModules.World.LightShare
if ((vflags & 0x8000) != 0) if ((vflags & 0x8000) != 0)
{ {
client.SendSunPos(Vector3.Zero, Vector3.Zero, dayFrac); client.SendViewerTime(Vector3.Zero, eepDayFrac);
return; return;
} }
env.getWLPositions(sp.AbsolutePosition.Z, dayFrac, out Vector3 m_sunDir); env.getWLPositions(sp.AbsolutePosition.Z, dayFrac, out Vector3 m_sunDir);
client.SendSunPos(m_sunDir, Vector3.Zero, wldayFrac); client.SendViewerTime(m_sunDir, wldayFrac);
}); });
} }
@ -848,37 +853,37 @@ namespace OpenSim.Region.CoreModules.World.LightShare
return moonrot; return moonrot;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetRegionDayLength() public int GetRegionDayLength()
{ {
return GetRegionEnviroment().DayLength; return GetRegionEnviroment().DayLength;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetRegionDayOffset() public int GetRegionDayOffset()
{ {
return GetRegionEnviroment().DayOffset; return GetRegionEnviroment().DayOffset;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector3 GetRegionSunDir(float altitude) public Vector3 GetRegionSunDir(float altitude)
{ {
return GetSunDir(GetRegionEnviroment(), altitude); return GetSunDir(GetRegionEnviroment(), altitude);
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Quaternion GetRegionSunRot(float altitude) public Quaternion GetRegionSunRot(float altitude)
{ {
return GetSunRot(GetRegionEnviroment(), altitude); return GetSunRot(GetRegionEnviroment(), altitude);
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector3 GetRegionMoonDir(float altitude) public Vector3 GetRegionMoonDir(float altitude)
{ {
return GetMoonDir(GetRegionEnviroment(), altitude); return GetMoonDir(GetRegionEnviroment(), altitude);
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Quaternion GetRegionMoonRot(float altitude) public Quaternion GetRegionMoonRot(float altitude)
{ {
return GetMoonRot(GetRegionEnviroment(), altitude); return GetMoonRot(GetRegionEnviroment(), altitude);

View File

@ -1235,8 +1235,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
{ {
} }
//public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition) public void SendViewerTime(Vector3 sunDir, float sunphase)
public void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle)
{ {
} }
@ -1244,11 +1243,6 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
{ {
} }
public void SendViewerTime(int phase)
{
}
public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] membershipType, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID) public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] membershipType, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID)
{ {

View File

@ -988,8 +988,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{ {
} }
//public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) public void SendViewerTime(Vector3 sunDir, float sunphase)
public void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle)
{ {
} }
@ -997,10 +996,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{ {
} }
public void SendViewerTime(int phase)
{
}
public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType,
string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
UUID partnerID) UUID partnerID)

View File

@ -981,16 +981,13 @@ namespace OpenSim.Tests.Common
public void SendAdminResponse(UUID Token, uint AdminLevel) public void SendAdminResponse(UUID Token, uint AdminLevel)
{ {
} }
public void SendGroupMembership(GroupMembershipData[] GroupMembership) public void SendGroupMembership(GroupMembershipData[] GroupMembership)
{ {
} }
//public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) public void SendViewerTime(Vector3 sunDir, float sunphase)
public void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle)
{ {
} }
@ -998,10 +995,6 @@ namespace OpenSim.Tests.Common
{ {
} }
public void SendViewerTime(int phase)
{
}
public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType,
string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
UUID partnerID) UUID partnerID)