mirror of https://github.com/opensim/opensim.git
Compare commits
4 Commits
2ffa845af4
...
52bd793120
Author | SHA1 | Date |
---|---|---|
UbitUmarov | 52bd793120 | |
UbitUmarov | 6ca32cb8ef | |
UbitUmarov | ece71a6aa3 | |
UbitUmarov | 3e54b78668 |
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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[] {',', ']', '}'});
|
||||
|
|
|
@ -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;
|
||||
|
@ -149,30 +147,30 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_PrimScaleMin = m_ModelCost.PrimScaleMin;
|
||||
|
||||
IConfigSource config = m_Scene.Config;
|
||||
if (config != null)
|
||||
if (config is not null)
|
||||
{
|
||||
IConfig sconfig = config.Configs["Startup"];
|
||||
if (sconfig != null)
|
||||
if (sconfig is not null)
|
||||
{
|
||||
m_levelUpload = sconfig.GetInt("LevelUpload", 0);
|
||||
}
|
||||
if (m_levelUpload == 0)
|
||||
{
|
||||
IConfig pconfig = config.Configs["Permissions"];
|
||||
if (pconfig != null)
|
||||
if (pconfig is not null)
|
||||
{
|
||||
m_levelUpload = pconfig.GetInt("LevelUpload", 0);
|
||||
}
|
||||
}
|
||||
|
||||
IConfig appearanceConfig = config.Configs["Appearance"];
|
||||
if (appearanceConfig != null)
|
||||
if (appearanceConfig is not null)
|
||||
{
|
||||
m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
|
||||
}
|
||||
// economy for model upload
|
||||
IConfig EconomyConfig = config.Configs["Economy"];
|
||||
if (EconomyConfig != null)
|
||||
if (EconomyConfig is not null)
|
||||
{
|
||||
m_ModelCost.Econfig(EconomyConfig);
|
||||
|
||||
|
@ -190,23 +188,19 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
|
||||
IConfig CapsConfig = config.Configs["ClientStack.LindenCaps"];
|
||||
if (CapsConfig != null)
|
||||
if (CapsConfig is not null)
|
||||
{
|
||||
string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost");
|
||||
if(homeLocationUrl.Length == 0)
|
||||
m_AllowCapHomeLocation = false;
|
||||
m_AllowCapHomeLocation = !string.IsNullOrEmpty(homeLocationUrl);
|
||||
|
||||
string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost");
|
||||
if(GroupMemberDataUrl.Length == 0)
|
||||
m_AllowCapGroupMemberData = false;
|
||||
m_AllowCapGroupMemberData = !string.IsNullOrEmpty(GroupMemberDataUrl);
|
||||
|
||||
string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost");
|
||||
if (LandResourcesUrl.Length == 0)
|
||||
m_AllowCapLandResources = false;
|
||||
m_AllowCapLandResources = !string.IsNullOrEmpty(LandResourcesUrl);
|
||||
|
||||
string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost");
|
||||
if (AttachmentResourcesUrl.Length == 0)
|
||||
m_AllowCapAttachmentResources = false;
|
||||
m_AllowCapAttachmentResources = !string.IsNullOrEmpty(AttachmentResourcesUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,11 +209,11 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_UserManager = m_Scene.RequestModuleInterface<IUserManagement>();
|
||||
m_userAccountService = m_Scene.RequestModuleInterface<IUserAccountService>();
|
||||
m_moneyModule = m_Scene.RequestModuleInterface<IMoneyModule>();
|
||||
if (m_UserManager == null)
|
||||
if (m_UserManager is null)
|
||||
m_log.Error("[CAPS]: GetDisplayNames disabled because user management component not found");
|
||||
|
||||
UserAccount account = m_userAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, m_AgentID);
|
||||
if (account == null) // Hypergrid?
|
||||
if (account is null) // Hypergrid?
|
||||
m_scopeID = m_Scene.RegionInfo.ScopeID;
|
||||
else
|
||||
m_scopeID = account.ScopeID;
|
||||
|
@ -295,7 +289,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[CAPS]: " + e.ToString());
|
||||
m_log.Error("[CAPS]: Error " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +302,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
"POST", GetNewCapPath(), NewAgentInventoryRequest, "NewFileAgentInventory", null));
|
||||
|
||||
SimpleOSDMapHandler oreq;
|
||||
if (ItemUpdatedCall != null)
|
||||
if (ItemUpdatedCall is not null)
|
||||
{
|
||||
// first sets the http handler, others only register the cap, using it
|
||||
oreq = new SimpleOSDMapHandler("POST", GetNewCapPath(), UpdateNotecardItemAsset);
|
||||
|
@ -336,7 +330,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_HostCapsObj.RegisterSimpleHandler("UpdateGestureTaskInventory", oreq, false);
|
||||
}
|
||||
|
||||
if (TaskScriptUpdatedCall != null)
|
||||
if (TaskScriptUpdatedCall is not null)
|
||||
{
|
||||
oreq = new SimpleOSDMapHandler("POST", GetNewCapPath(), UpdateScriptTaskInventory);
|
||||
m_HostCapsObj.RegisterSimpleHandler("UpdateScriptTask", oreq, true);
|
||||
|
@ -362,7 +356,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
{
|
||||
try
|
||||
{
|
||||
if (m_UserManager != null)
|
||||
if (m_UserManager is not null)
|
||||
{
|
||||
m_HostCapsObj.RegisterSimpleHandler("GetDisplayNames",
|
||||
new SimpleStreamHandler(GetNewCapPath(), GetDisplayNames));
|
||||
|
@ -370,7 +364,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[CAPS]: " + e.ToString());
|
||||
m_log.Error("[CAPS]: Error " + e.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -385,8 +379,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
public void SeedCapRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
UUID agentID = m_HostCapsObj.AgentID;
|
||||
m_log.DebugFormat(
|
||||
"[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, agentID);
|
||||
m_log.Debug(
|
||||
$"[CAPS]: Received SEED caps request in {m_regionName} for agent {agentID}");
|
||||
|
||||
if(httpRequest.HttpMethod != "POST" || httpRequest.ContentType != "application/llsd+xml")
|
||||
{
|
||||
|
@ -421,7 +415,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
return;
|
||||
}
|
||||
|
||||
List<string> validCaps = new List<string>();
|
||||
HashSet<string> validCaps = new();
|
||||
|
||||
foreach (OSD c in capsRequested)
|
||||
{
|
||||
|
@ -432,13 +426,14 @@ 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")) // will not work if a viewer has no edit features
|
||||
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);
|
||||
|
||||
m_HostCapsObj.Flags |= Caps.CapsFlags.SentSeeds;
|
||||
}
|
||||
|
@ -505,7 +500,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar);
|
||||
|
||||
// check user level
|
||||
if (avatar != null)
|
||||
if (avatar is not null)
|
||||
{
|
||||
if (avatar.GodController.UserLevel < m_levelUpload)
|
||||
{
|
||||
|
@ -524,12 +519,12 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
|
||||
// check test upload and funds
|
||||
if (client != null)
|
||||
if (client is not null)
|
||||
{
|
||||
IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>();
|
||||
|
||||
int baseCost = 0;
|
||||
if (mm != null)
|
||||
if (mm is not null)
|
||||
baseCost = mm.UploadCharge;
|
||||
|
||||
string warning = String.Empty;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1042,7 +1042,7 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
entries = null;
|
||||
else
|
||||
{
|
||||
var newentries = new Primitive.RenderMaterials.RenderMaterialEntry[entries.Length - 1];
|
||||
var newentries = new RenderMaterialEntry[entries.Length - 1];
|
||||
if (indx > 0)
|
||||
Array.Copy(entries, newentries, indx);
|
||||
int left = newentries.Length - indx;
|
||||
|
@ -1068,7 +1068,7 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
overrides = null;
|
||||
else
|
||||
{
|
||||
var entries = new Primitive.RenderMaterials.RenderMaterialOverrideEntry[overrides.Length - 1];
|
||||
var entries = new RenderMaterialOverrideEntry[overrides.Length - 1];
|
||||
if (indx > 0)
|
||||
Array.Copy(overrides, entries, indx);
|
||||
int left = entries.Length - indx;
|
||||
|
@ -1078,8 +1078,43 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool AddMaterialOverride(ref RenderMaterials.RenderMaterialOverrideEntry[] overrides, string data, int side)
|
||||
|
||||
private static bool GetExtentionTransform(OSDMap Inmap, out OSDMap outmap)
|
||||
{
|
||||
OSD tmposd;
|
||||
if (Inmap.TryGetValue("extensions", out tmposd) && tmposd is OSDMap extmap)
|
||||
{
|
||||
if (extmap.TryGetValue("KHR_texture_transform", out tmposd) && tmposd is OSDMap trmap)
|
||||
{
|
||||
OSDMap tmpmap = new OSDMap();
|
||||
if (trmap.TryGetValue("offset", out tmposd) && tmposd is OSDArray offset)
|
||||
{
|
||||
tmpmap["o"] = new OSDArray()
|
||||
{
|
||||
Math.Round((double) offset[0], 3),
|
||||
Math.Round((double) offset[1], 3)
|
||||
};
|
||||
}
|
||||
if (trmap.TryGetValue("rotation", out tmposd) && tmposd is OSDReal rotation)
|
||||
{
|
||||
tmpmap["r"] = Math.Round((double)rotation, 6);
|
||||
}
|
||||
if (trmap.TryGetValue("scale", out tmposd) && tmposd is OSDArray scale)
|
||||
{
|
||||
tmpmap["s"] = new OSDArray()
|
||||
{
|
||||
Math.Round((double) scale[0], 3),
|
||||
Math.Round((double) scale[1], 3)
|
||||
};
|
||||
}
|
||||
outmap = tmpmap;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
outmap = null;
|
||||
return false;
|
||||
}
|
||||
private static bool AddMaterialOverride(ref RenderMaterialOverrideEntry[] overrides, string data, int side)
|
||||
{
|
||||
OSD tst;
|
||||
try
|
||||
|
@ -1127,7 +1162,8 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
bool hasTexURIS = texturesURIs is not null;
|
||||
|
||||
OSDMap outosd = new();
|
||||
OSDArray ti = new OSDArray(4);
|
||||
OSDArray ti = new(4);
|
||||
OSDMap tmpmap;
|
||||
|
||||
bool texturesChanged = false;
|
||||
Span<UUID> textureIDs = stackalloc UUID[4];
|
||||
|
@ -1147,25 +1183,9 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
texturesChanged = true;
|
||||
}
|
||||
}
|
||||
if (pmrMapbct.TryGetValue("extensions", out tmposd) && tmposd is OSDMap bcext)
|
||||
if (GetExtentionTransform(pmrMapbct, out tmpmap))
|
||||
{
|
||||
if (bcext.TryGetValue("KHR_texture_transform", out tmposd) && tmposd is OSDMap bctr)
|
||||
{
|
||||
OSDMap tmpmap = new OSDMap();
|
||||
if (bctr.TryGetValue("offset", out tmposd) && tmposd is OSDArray bcoffset)
|
||||
{
|
||||
tmpmap["o"] = bcoffset;
|
||||
}
|
||||
if (bctr.TryGetValue("rotation", out tmposd) && tmposd is OSDReal bcrotation)
|
||||
{
|
||||
tmpmap["r"] = bcrotation;
|
||||
}
|
||||
if (bctr.TryGetValue("scale", out tmposd) && tmposd is OSDArray bcscale)
|
||||
{
|
||||
tmpmap["s"] = bcscale;
|
||||
}
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
}
|
||||
if (pmrMap.TryGetValue("metallicRoughnessTexture", out tmposd) && tmposd is OSDMap pmrMapmrt && pmrMapmrt.Count > 0)
|
||||
|
@ -1180,40 +1200,30 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
texturesChanged = true;
|
||||
}
|
||||
}
|
||||
if (pmrMapmrt.TryGetValue("extensions", out tmposd) && tmposd is OSDMap bcext)
|
||||
if (GetExtentionTransform(pmrMapmrt, out tmpmap))
|
||||
{
|
||||
if (bcext.TryGetValue("KHR_texture_transform", out tmposd) && tmposd is OSDMap bctr)
|
||||
{
|
||||
OSDMap tmpmap = new OSDMap();
|
||||
if (bctr.TryGetValue("offset", out tmposd) && tmposd is OSDArray bcoffset)
|
||||
{
|
||||
tmpmap["o"] = bcoffset;
|
||||
}
|
||||
if (bctr.TryGetValue("rotation", out tmposd) && tmposd is OSDReal bcrotation)
|
||||
{
|
||||
tmpmap["r"] = bcrotation;
|
||||
}
|
||||
if (bctr.TryGetValue("scale", out tmposd) && tmposd is OSDArray bcscale)
|
||||
{
|
||||
tmpmap["s"] = bcscale;
|
||||
}
|
||||
while(ti.Count < 2)
|
||||
while (ti.Count < 2)
|
||||
ti.Add(new OSD());
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pmrMap.TryGetValue("baseColorFactor", out tmposd) && tmposd is OSDArray baseColorFactor)
|
||||
{
|
||||
outosd["bc"] = baseColorFactor;
|
||||
outosd["bc"] = new OSDArray()
|
||||
{
|
||||
Math.Round((double) baseColorFactor[0], 4),
|
||||
Math.Round((double) baseColorFactor[1], 4),
|
||||
Math.Round((double) baseColorFactor[2], 4),
|
||||
Math.Round((double) baseColorFactor[3], 4)
|
||||
};
|
||||
}
|
||||
if (pmrMap.TryGetValue("metallicFactor", out tmposd) && tmposd is OSDReal metallicFactor)
|
||||
{
|
||||
outosd["mf"] = metallicFactor;
|
||||
outosd["mf"] = Math.Round((double)metallicFactor, 3);
|
||||
}
|
||||
if (pmrMap.TryGetValue("roughnessFactor", out tmposd) && tmposd is OSDReal roughnessFactor)
|
||||
{
|
||||
outosd["rf"] = roughnessFactor;
|
||||
outosd["rf"] = Math.Round((double)roughnessFactor, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1229,32 +1239,16 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
texturesChanged = true;
|
||||
}
|
||||
}
|
||||
if (ntMap.TryGetValue("extensions", out tmposd) && tmposd is OSDMap bcext)
|
||||
if (GetExtentionTransform(ntMap, out tmpmap))
|
||||
{
|
||||
if (bcext.TryGetValue("KHR_texture_transform", out tmposd) && tmposd is OSDMap bctr)
|
||||
if (ti.Count < 2)
|
||||
{
|
||||
OSDMap tmpmap = new OSDMap();
|
||||
if (bctr.TryGetValue("offset", out tmposd) && tmposd is OSDArray bcoffset)
|
||||
{
|
||||
tmpmap["o"] = bcoffset;
|
||||
}
|
||||
if (bctr.TryGetValue("rotation", out tmposd) && tmposd is OSDReal bcrotation)
|
||||
{
|
||||
tmpmap["r"] = bcrotation;
|
||||
}
|
||||
if (bctr.TryGetValue("scale", out tmposd) && tmposd is OSDArray bcscale)
|
||||
{
|
||||
tmpmap["s"] = bcscale;
|
||||
}
|
||||
if (ti.Count < 2)
|
||||
{
|
||||
if (ti.Count == 0)
|
||||
ti.Add(new OSD());
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
else
|
||||
ti[1] = tmpmap;
|
||||
if (ti.Count == 0)
|
||||
ti.Add(new OSD());
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
else
|
||||
ti[1] = tmpmap;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1270,31 +1264,15 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
texturesChanged = true;
|
||||
}
|
||||
}
|
||||
if (otMap.TryGetValue("extensions", out tmposd) && tmposd is OSDMap bcext)
|
||||
if (GetExtentionTransform(otMap, out tmpmap))
|
||||
{
|
||||
if (bcext.TryGetValue("KHR_texture_transform", out tmposd) && tmposd is OSDMap bctr)
|
||||
if (ti.Count > 2)
|
||||
ti[2] = tmpmap;
|
||||
else
|
||||
{
|
||||
OSDMap tmpmap = new OSDMap();
|
||||
if (bctr.TryGetValue("offset", out tmposd) && tmposd is OSDArray bcoffset)
|
||||
{
|
||||
tmpmap["o"] = bcoffset;
|
||||
}
|
||||
if (bctr.TryGetValue("rotation", out tmposd) && tmposd is OSDReal bcrotation)
|
||||
{
|
||||
tmpmap["r"] = bcrotation;
|
||||
}
|
||||
if (bctr.TryGetValue("scale", out tmposd) && tmposd is OSDArray bcscale)
|
||||
{
|
||||
tmpmap["s"] = bcscale;
|
||||
}
|
||||
if (ti.Count > 2)
|
||||
ti[2] = tmpmap;
|
||||
else
|
||||
{
|
||||
while (ti.Count < 2)
|
||||
ti.Add(new OSD());
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
while (ti.Count < 2)
|
||||
ti.Add(new OSD());
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1311,31 +1289,15 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
texturesChanged = true;
|
||||
}
|
||||
}
|
||||
if (etMap.TryGetValue("extensions", out tmposd) && tmposd is OSDMap bcext)
|
||||
if (GetExtentionTransform(etMap, out tmpmap))
|
||||
{
|
||||
if (bcext.TryGetValue("KHR_texture_transform", out tmposd) && tmposd is OSDMap bctr)
|
||||
if (ti.Count > 3)
|
||||
ti[3] = tmpmap;
|
||||
else
|
||||
{
|
||||
OSDMap tmpmap = new OSDMap();
|
||||
if (bctr.TryGetValue("offset", out tmposd) && tmposd is OSDArray bcoffset)
|
||||
{
|
||||
tmpmap["o"] = bcoffset;
|
||||
}
|
||||
if (bctr.TryGetValue("rotation", out tmposd) && tmposd is OSDReal bcrotation)
|
||||
{
|
||||
tmpmap["r"] = bcrotation;
|
||||
}
|
||||
if (bctr.TryGetValue("scale", out tmposd) && tmposd is OSDArray bcscale)
|
||||
{
|
||||
tmpmap["s"] = bcscale;
|
||||
}
|
||||
if (ti.Count > 3)
|
||||
ti[3] = tmpmap;
|
||||
else
|
||||
{
|
||||
while (ti.Count < 3)
|
||||
ti.Add(new OSD());
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
while (ti.Count < 3)
|
||||
ti.Add(new OSD());
|
||||
ti.Add(tmpmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1352,12 +1314,17 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
|
||||
if (material.TryGetValue("alphaCutoff", out tmposd) && tmposd is OSDReal alphaCutoff)
|
||||
{
|
||||
outosd["ac"] = alphaCutoff;
|
||||
outosd["ac"] = Math.Round((double)alphaCutoff, 3);
|
||||
}
|
||||
|
||||
if (material.TryGetValue("emissiveFactor", out tmposd) && tmposd is OSDArray emissiveFactor)
|
||||
{
|
||||
outosd["ec"] = emissiveFactor;
|
||||
outosd["ec"] = new OSDArray()
|
||||
{
|
||||
Math.Round((double) emissiveFactor[0], 4),
|
||||
Math.Round((double) emissiveFactor[1], 4),
|
||||
Math.Round((double) emissiveFactor[2], 4)
|
||||
};
|
||||
}
|
||||
if (material.TryGetValue("doubleSided", out tmposd) && tmposd is OSDBoolean doubleSided)
|
||||
{
|
||||
|
@ -1393,7 +1360,7 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
|
||||
if (overrides is null)
|
||||
{
|
||||
var entries = new RenderMaterials.RenderMaterialOverrideEntry[1];
|
||||
var entries = new RenderMaterialOverrideEntry[1];
|
||||
entries[0].te_index = (byte)side;
|
||||
entries[0].data = data;
|
||||
overrides = entries;
|
||||
|
|
Loading…
Reference in New Issue