avoid sending pbr lludp messages to older viewers

This commit is contained in:
UbitUmarov 2024-01-31 13:06:53 +00:00
parent 2ffa845af4
commit 3e54b78668
7 changed files with 142 additions and 62 deletions

View File

@ -115,14 +115,15 @@ namespace OpenSim.Framework.Capabilities
}
[Flags]
public enum CapsFlags:uint
public enum CapsFlags: uint
{
None = 0,
SentSeeds = 1,
ObjectAnim = 0x100,
WLEnv = 0x200,
AdvEnv = 0x400
AdvEnv = 0x400,
PBR = 0x800
}
public CapsFlags Flags { get; set;}
@ -268,22 +269,22 @@ namespace OpenSim.Framework.Capabilities
lock (m_pollServiceHandlers)
{
foreach (KeyValuePair <string, PollServiceEventArgs> kvp in m_pollServiceHandlers)
foreach (KeyValuePair<string, PollServiceEventArgs> kvp in m_pollServiceHandlers)
{
if (!requestedCaps.Contains(kvp.Key))
continue;
string hostName = m_httpListenerHostName;
uint port = (MainServer.Instance is null) ? 0 : MainServer.Instance.Port;
string protocol = "http";
string hostName = m_httpListenerHostName;
uint port = (MainServer.Instance is null) ? 0 : MainServer.Instance.Port;
string protocol = "http";
if (MainServer.Instance.UseSSL)
{
hostName = MainServer.Instance.SSLCommonName;
port = MainServer.Instance.SSLPort;
protocol = "https";
}
caps[kvp.Key] = string.Format("{0}://{1}:{2}{3}", protocol, hostName, port, kvp.Value.Url);
if (MainServer.Instance.UseSSL)
{
hostName = MainServer.Instance.SSLCommonName;
port = MainServer.Instance.SSLPort;
protocol = "https";
}
caps[kvp.Key] = string.Format("{0}://{1}:{2}{3}", protocol, hostName, port, kvp.Value.Url);
}
}
@ -300,6 +301,39 @@ namespace OpenSim.Framework.Capabilities
return caps;
}
public Hashtable GetCapsDetails2(bool excludeSeed, HashSet<string> requestedCaps)
{
Hashtable caps = CapsHandlers.GetCapsDetails2(excludeSeed, requestedCaps);
lock (m_pollServiceHandlers)
{
foreach (KeyValuePair<string, PollServiceEventArgs> kvp in m_pollServiceHandlers)
{
if (!requestedCaps.Contains(kvp.Key))
continue;
if (MainServer.Instance.UseSSL)
caps[kvp.Key] = $"https://{MainServer.Instance.SSLCommonName}:{MainServer.Instance.SSLPort}{kvp.Value.Url}";
else
{
if(MainServer.Instance is null)
caps[kvp.Key] = $"http://{m_httpListenerHostName}:0{kvp.Value.Url}";
else
caps[kvp.Key] = $"http://{m_httpListenerHostName}:{MainServer.Instance.Port}{kvp.Value.Url}";
}
}
}
// Add the external too
foreach (KeyValuePair<string, string> kvp in ExternalCapsHandlers)
{
if (requestedCaps.Contains(kvp.Key))
caps[kvp.Key] = kvp.Value;
}
return caps;
}
public void Activate()
{
m_capsActive.Set();

View File

@ -40,8 +40,8 @@ namespace OpenSim.Framework.Capabilities
/// </summary>
public class CapsHandlers
{
private Dictionary<string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
private ConcurrentDictionary<string, ISimpleStreamHandler> m_capsSimpleHandlers = new ConcurrentDictionary<string, ISimpleStreamHandler>();
private readonly Dictionary<string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
private readonly ConcurrentDictionary<string, ISimpleStreamHandler> m_capsSimpleHandlers = new ConcurrentDictionary<string, ISimpleStreamHandler>();
private IHttpServer m_httpListener;
private string m_httpListenerHostName;
private uint m_httpListenerPort;
@ -188,7 +188,7 @@ namespace OpenSim.Framework.Capabilities
lock (m_capsHandlers)
{
for(int i = 0; i < requestedCaps.Count; ++i)
for (int i = 0; i < requestedCaps.Count; ++i)
{
string capsName = requestedCaps[i];
if (excludeSeed && "SEED" == capsName)
@ -209,6 +209,47 @@ namespace OpenSim.Framework.Capabilities
return caps;
}
public Hashtable GetCapsDetails2(bool excludeSeed, HashSet<string> requestedCaps)
{
Hashtable caps = new Hashtable();
string protocol = m_useSSL ? "https://" : "http://";
string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString();
if (requestedCaps is null)
{
lock (m_capsHandlers)
{
foreach (KeyValuePair<string, ISimpleStreamHandler> kvp in m_capsSimpleHandlers)
caps[kvp.Key] = baseUrl + kvp.Value.Path;
foreach (KeyValuePair<string, IRequestHandler> kvp in m_capsHandlers)
caps[kvp.Key] = baseUrl + kvp.Value.Path;
}
return caps;
}
lock (m_capsHandlers)
{
foreach(string capsName in requestedCaps)
{
if (excludeSeed && "SEED".Equals(capsName))
continue;
if (m_capsSimpleHandlers.TryGetValue(capsName, out ISimpleStreamHandler shdr))
{
caps[capsName] = baseUrl + shdr.Path;
continue;
}
if (m_capsHandlers.TryGetValue(capsName, out IRequestHandler chdr))
{
caps[capsName] = baseUrl + chdr.Path;
}
}
}
return caps;
}
/// <summary>
/// Returns a copy of the dictionary of all the HTTP cap handlers
/// </summary>

View File

@ -27,6 +27,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography;
@ -136,10 +137,10 @@ namespace OpenSim.Framework.Capabilities
return;
}
if (obj is string)
if (obj is string s)
{
writer.WriteStartElement(String.Empty, "string", String.Empty);
writer.WriteString((string) obj);
writer.WriteString(s);
writer.WriteEndElement();
}
else if (obj is int)
@ -154,9 +155,8 @@ namespace OpenSim.Framework.Capabilities
writer.WriteString(obj.ToString());
writer.WriteEndElement();
}
else if (obj is bool)
else if (obj is bool b)
{
bool b = (bool) obj;
writer.WriteStartElement(String.Empty, "boolean", String.Empty);
writer.WriteString(b ? "1" : "0");
writer.WriteEndElement();
@ -165,29 +165,38 @@ namespace OpenSim.Framework.Capabilities
{
throw new Exception("ulong in LLSD is currently not implemented, fix me!");
}
else if (obj is UUID)
else if (obj is UUID u)
{
UUID u = (UUID) obj;
writer.WriteStartElement(String.Empty, "uuid", String.Empty);
writer.WriteString(u.ToString());
writer.WriteEndElement();
}
else if (obj is Hashtable)
else if (obj is Hashtable h)
{
Hashtable h = obj as Hashtable;
writer.WriteStartElement(String.Empty, "map", String.Empty);
foreach (string key in h.Keys)
writer.WriteStartElement(string.Empty, "map", string.Empty);
foreach (DictionaryEntry de in h)
{
writer.WriteStartElement(String.Empty, "key", String.Empty);
writer.WriteString(key);
writer.WriteStartElement(string.Empty, "key", string.Empty);
writer.WriteString((string)de.Key);
writer.WriteEndElement();
LLSDWriteOne(writer, h[key]);
LLSDWriteOne(writer, de.Value);
}
writer.WriteEndElement();
}
else if (obj is ArrayList)
else if (obj is Dictionary<string,object> dict)
{
writer.WriteStartElement(String.Empty, "map", String.Empty);
foreach (KeyValuePair<string,object> kvp in dict)
{
writer.WriteStartElement(String.Empty, "key", String.Empty);
writer.WriteString(kvp.Key);
writer.WriteEndElement();
LLSDWriteOne(writer, kvp.Value);
}
writer.WriteEndElement();
}
else if (obj is ArrayList a)
{
ArrayList a = obj as ArrayList;
writer.WriteStartElement(String.Empty, "array", String.Empty);
foreach (object item in a)
{
@ -195,26 +204,24 @@ namespace OpenSim.Framework.Capabilities
}
writer.WriteEndElement();
}
else if (obj is byte[])
else if (obj is List<object> lsto)
{
byte[] b = obj as byte[];
writer.WriteStartElement(String.Empty, "binary", String.Empty);
writer.WriteStartElement(string.Empty, "array", string.Empty);
foreach (object item in lsto)
{
LLSDWriteOne(writer, item);
}
writer.WriteEndElement();
}
else if (obj is byte[] bytes)
{
writer.WriteStartElement(string.Empty, "binary", string.Empty);
writer.WriteStartAttribute(String.Empty, "encoding", String.Empty);
writer.WriteString("base64");
writer.WriteEndAttribute();
//// Calculate the length of the base64 output
//long length = (long)(4.0d * b.Length / 3.0d);
//if (length % 4 != 0) length += 4 - (length % 4);
//// Create the char[] for base64 output and fill it
//char[] tmp = new char[length];
//int i = Convert.ToBase64CharArray(b, 0, b.Length, tmp, 0);
//writer.WriteString(new String(tmp));
writer.WriteString(Convert.ToBase64String(b));
writer.WriteString(Convert.ToBase64String(bytes));
writer.WriteEndElement();
}
else
@ -455,7 +462,7 @@ namespace OpenSim.Framework.Capabilities
private static string GetSpaces(int count)
{
StringBuilder b = new StringBuilder();
for (int i = 0; i < count; i++) b.Append(" ");
for (int i = 0; i < count; i++) b.Append(' ');
return b.ToString();
}
@ -465,6 +472,7 @@ namespace OpenSim.Framework.Capabilities
/// <param name="obj"></param>
/// <param name="indent"></param>
/// <returns></returns>
/*
public static String LLSDDump(object obj, int indent)
{
if (obj == null)
@ -659,7 +667,7 @@ namespace OpenSim.Framework.Capabilities
throw new Exception("Unknown value type");
}
}
*/
private static int FindEnd(string llsd, int start)
{
int end = llsd.IndexOfAny(new char[] {',', ']', '}'});

View File

@ -35,7 +35,6 @@ using System.Net;
using System.Threading;
using System.Reflection;
using System.Text;
using System.Web;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@ -82,8 +81,7 @@ namespace OpenSim.Region.ClientStack.Linden
public partial class BunchOfCaps
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_Scene;
private UUID m_AgentID;
@ -421,7 +419,7 @@ namespace OpenSim.Region.ClientStack.Linden
return;
}
List<string> validCaps = new List<string>();
HashSet<string> validCaps = new();
foreach (OSD c in capsRequested)
{
@ -432,10 +430,12 @@ namespace OpenSim.Region.ClientStack.Linden
m_HostCapsObj.Flags |= Caps.CapsFlags.WLEnv;
else if (cstr.Equals("ExtEnvironment"))
m_HostCapsObj.Flags |= Caps.CapsFlags.AdvEnv;
else if(cstr.Equals("ModifyMaterialParams"))
m_HostCapsObj.Flags |= Caps.CapsFlags.PBR;
validCaps.Add(cstr);
}
string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(true, validCaps));
string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails2(true, validCaps));
httpResponse.RawBuffer = Util.UTF8NBGetbytes(result);
httpResponse.StatusCode = (int)HttpStatusCode.OK;
//m_log.DebugFormat("[CAPS] CapsRequest {0}", result);

View File

@ -334,8 +334,6 @@ namespace OpenSim.Region.ClientStack.Linden
obj.InvalidateDeepEffectivePerms();
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
httpResponse.StatusCode = (int)HttpStatusCode.OK;
httpResponse.RawBuffer = Util.UTF8NBGetbytes(String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(obj.LocalId)));
}
@ -348,7 +346,7 @@ namespace OpenSim.Region.ClientStack.Linden
return Utils.BytesToUInt(tmp);
}
private string ConvertUintToBytes(uint val)
private static string ConvertUintToBytes(uint val)
{
byte[] resultbytes = Utils.UIntToBytes(val);
if (BitConverter.IsLittleEndian)

View File

@ -27,8 +27,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime;
@ -348,6 +346,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private const uint MaxTransferBytesPerPacket = 600;
private bool m_SupportObjectAnimations;
private bool m_SupportPBR;
/// <value>
/// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
@ -4969,7 +4968,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
useCompressUpdate = grp.IsViewerCachable;
istree = (part.Shape.PCode == (byte)PCode.Grass || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Tree);
if((updateFlags & PrimUpdateFlags.MaterialOvr) != 0)
if((m_SupportPBR && (updateFlags & PrimUpdateFlags.MaterialOvr) != 0))
hasMaterialOverride = !istree && part.Shape.RenderMaterials is not null;
}
else if (update.Entity is ScenePresence presence)
@ -5490,8 +5489,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
if (needMaterials is not null && eq is not null)
if (needMaterials is not null)
{
foreach (SceneObjectPart sop in needMaterials)
{
@ -13993,6 +13991,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
ret |= 0x4000;
if ((cap.Flags & Caps.CapsFlags.AdvEnv) != 0)
ret |= 0x8000;
if ((cap.Flags & Caps.CapsFlags.PBR) != 0)
m_SupportPBR = true;
}
}

View File

@ -222,8 +222,7 @@ namespace OpenSim.Region.CoreModules.Framework
m_capsPaths[agent.AgentID] = agent.CapsPath;
lock (m_childrenSeeds)
m_childrenSeeds[agent.AgentID]
= ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
m_childrenSeeds[agent.AgentID] = (agent.ChildrenCapSeeds ?? new Dictionary<ulong, string>());
}
public string GetCapsPath(UUID agentId)