a few more changes for hypothetical terrain PBR

This commit is contained in:
UbitUmarov
2024-06-10 21:02:31 +01:00
parent 183350b617
commit 65738b3766
11 changed files with 167 additions and 57 deletions

View File

@@ -59,7 +59,7 @@ namespace OpenSim.Framework
public const float MinWaterHeight = 0;
public const float MaxWaterHeight = 8000f;
public const int MaxTextureResolution = 1024;
public const int MaxTextureResolution = 2048;
public static readonly string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; //plywood
public static readonly UUID DefaultTextureID = new UUID(DefaultTexture);

View File

@@ -598,6 +598,18 @@ namespace OpenSim.Framework
public int Price;
}
[Flags]
public enum ViewerFlags:uint
{
SentSeeds = 0x1000,
ObjectAnim = 0x2000,
WLEnv = 0x4000,
AdvEnv = 0x8000,
PBR = 0x10000,
TPBR = 0x20000,
SentTPBR = 0x40000,
}
/// <summary>
/// Specifies the fields that have been changed when sending a prim or
/// avatar update
@@ -671,6 +683,8 @@ namespace OpenSim.Framework
ulong ActiveGroupPowers { get; set;}
ViewerFlags ViewerFlags { get;}
Dictionary<UUID, ulong> GetGroupPowers();
void SetGroupPowers(Dictionary<UUID, ulong> powers);

View File

@@ -357,10 +357,14 @@ namespace OpenSim.Region.ClientStack.Linden
if (m_Scene.RegionInfo.RegionSizeX == Constants.RegionSize &&
m_Scene.RegionInfo.RegionSizeY == Constants.RegionSize &&
m_Scene.RegionInfo.RegionSizeZ == Constants.RegionSize)
m_HostCapsObj.Flags |= Caps.CapsFlags.TPBR;
{
m_HostCapsObj.Flags |= Caps.CapsFlags.PBR | Caps.CapsFlags.TPBR;
}
else
m_HostCapsObj.Flags |= Caps.CapsFlags.PBR;
continue;
case "VETPBR":
m_HostCapsObj.Flags |= Caps.CapsFlags.TPBR;
m_HostCapsObj.Flags |= Caps.CapsFlags.PBR | Caps.CapsFlags.TPBR;
continue;
case "ObjectAnimation":
m_HostCapsObj.Flags |= Caps.CapsFlags.ObjectAnim;
@@ -379,7 +383,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
validCaps.Add(cstr);
}
osUTF8 sb = LLSDxmlEncode2.Start();
LLSDxmlEncode2.AddMap(sb);
m_HostCapsObj.GetCapsDetailsLLSDxml(validCaps, sb);

View File

@@ -158,12 +158,6 @@ namespace OpenSim.Region.ClientStack.Linden
m_features["MeshUploadEnabled"] = true;
m_features["MeshXferEnabled"] = true;
/*
m_features["MirrorsEnabled"] = false;
m_features["PBRMaterialSwatchEnabled"] = false;
m_features["PBRTerrainEnabled"] = false;
*/
m_features["PhysicsMaterialsEnabled"] = true;
m_features["PhysicsShapeTypes"] = new OSDMap()
@@ -196,7 +190,7 @@ namespace OpenSim.Region.ClientStack.Linden
new SimpleStreamHandler("/" + UUID.Random(),
delegate (IOSHttpRequest request, IOSHttpResponse response)
{
HandleSimulatorFeaturesRequest(request, response, agentID);
HandleSimulatorFeaturesRequest(request, response, caps);
}));
if (m_doScriptSyntax && !m_scriptSyntaxID.IsZero() && m_scriptSyntaxXML != null)
@@ -276,7 +270,7 @@ namespace OpenSim.Region.ClientStack.Linden
return (OSDMap)copy;
}
private void HandleSimulatorFeaturesRequest(IOSHttpRequest request, IOSHttpResponse response, UUID agentID)
private void HandleSimulatorFeaturesRequest(IOSHttpRequest request, IOSHttpResponse response, Caps caps)
{
// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request");
@@ -286,24 +280,21 @@ namespace OpenSim.Region.ClientStack.Linden
return;
}
/*
ScenePresence sp = m_scene.GetScenePresence(agentID);
if (sp == null)
{
response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
response.AddHeader("Retry-After", "5");
return;
}
*/
OSDMap copy = DeepCopy();
if ((caps.Flags & Caps.CapsFlags.TPBR) != 0)
{
copy["PBRMaterialSwatchEnabled"] = true;
copy["PBRTerrainEnabled"] = true;
copy["MirrorsEnabled"] = true;
}
// Let's add the agentID to the destination guide, if it is expecting that.
if(copy.TryGetValue("OpenSimExtras", out OSD oe))
{
if(((OSDMap)oe).TryGetValue("destination-guide-url", out OSD dgl))
{
((OSDMap)oe)["destination-guide-url"] = Replace(dgl.AsString(), "[USERID]", agentID.ToString());
((OSDMap)oe)["destination-guide-url"] = Replace(dgl.AsString(), "[USERID]", caps.AgentID.ToString());
}
}
@@ -312,7 +303,7 @@ namespace OpenSim.Region.ClientStack.Linden
foreach(SimulatorFeaturesRequestDelegate sd in OnSimulatorFeaturesRequest.GetInvocationList())
try
{
sd?.Invoke(agentID, ref copy);
sd?.Invoke(caps.AgentID, ref copy);
}
catch { }
}

View File

@@ -341,8 +341,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private readonly Prioritizer m_prioritizer;
private bool m_disableFacelights;
// needs optimization
private HashSet<SceneObjectGroup> GroupsInView = new();
private HashSet<SceneObjectGroup> GroupsInView = [];
#pragma warning disable 0414
private bool m_VelocityInterpolate;
#pragma warning restore 0414
@@ -350,6 +349,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private bool m_SupportObjectAnimations;
private bool m_SupportPBR;
public bool SupportTerrainPBR { get; private set; }
public ViewerFlags ViewerFlags { get; private set; }
/// <value>
/// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
@@ -877,6 +878,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendRegionHandshake()
{
GetViewerCaps(); // make sure this is up to date
RegionInfo regionInfo = m_scene.RegionInfo;
RegionSettings regionSettings = regionInfo.RegionSettings;
EstateSettings es = regionInfo.EstateSettings;
@@ -915,14 +918,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// this seem now obsolete, sending zero uuids
// we should send the basic low resolution default ?
zc.AddZeros(16 * 4);
//TerrainDetail0
zc.AddUUID(regionSettings.TerrainTexture1);
//TerrainDetail1
zc.AddUUID(regionSettings.TerrainTexture2);
//TerrainDetail2
zc.AddUUID(regionSettings.TerrainTexture3);
//TerrainDetail3
zc.AddUUID(regionSettings.TerrainTexture4);
if(SupportTerrainPBR)
{
//TerrainDetail0
zc.AddUUID(regionSettings.TerrainPBR1);
//TerrainDetail1
zc.AddUUID(regionSettings.TerrainPBR2);
//TerrainDetail2
zc.AddUUID(regionSettings.TerrainPBR3);
//TerrainDetail3
zc.AddUUID(regionSettings.TerrainPBR4);
ViewerFlags |= ViewerFlags.SentTPBR;
}
else
{
//TerrainDetail0
zc.AddUUID(regionSettings.TerrainTexture1);
//TerrainDetail1
zc.AddUUID(regionSettings.TerrainTexture2);
//TerrainDetail2
zc.AddUUID(regionSettings.TerrainTexture3);
//TerrainDetail3
zc.AddUUID(regionSettings.TerrainTexture4);
}
//TerrainStartHeight00
zc.AddFloat((float)regionSettings.Elevation1SW);
//TerrainStartHeight01
@@ -13435,21 +13453,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if(cap != null)
{
if((cap.Flags & Caps.CapsFlags.SentSeeds) != 0)
ret |= 0x1000;
ret |= (uint)ViewerFlags.SentSeeds;
if ((cap.Flags & Caps.CapsFlags.ObjectAnim) != 0)
{
m_SupportObjectAnimations = true;
ret |= 0x2000;
ret |= (uint)ViewerFlags.ObjectAnim;
}
if ((cap.Flags & Caps.CapsFlags.WLEnv) != 0)
ret |= 0x4000;
ret |= (uint)ViewerFlags.WLEnv;
if ((cap.Flags & Caps.CapsFlags.AdvEnv) != 0)
ret |= 0x8000;
ret |= (uint)ViewerFlags.AdvEnv;
if ((cap.Flags & Caps.CapsFlags.PBR) != 0)
{
ret |= (uint)ViewerFlags.PBR;
m_SupportPBR = true;
}
if ((cap.Flags & Caps.CapsFlags.TPBR) != 0)
{
ret |= (uint)ViewerFlags.TPBR;
SupportTerrainPBR = true;
}
}
}
ViewerFlags = (ViewerFlags)ret;
return ret;
}
}

View File

@@ -68,6 +68,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
" that coordinate.",
consoleSetTerrainTexture);
m_module.Scene.AddCommand("Regions", m_module, "set terrain pbr",
"set terrain pbr <number> <uuid> [<x>] [<y>]",
"Sets the pbr <number> to <uuid>, if <x> or <y> are specified, it will only " +
"set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
" that coordinate.",
consoleSetTerrainPBR);
m_module.Scene.AddCommand("Regions", m_module, "set terrain heights",
"set terrain heights <corner> <min> <max> [<x>] [<y>]",
"Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
@@ -127,6 +134,44 @@ namespace OpenSim.Region.CoreModules.World.Estate
}
}
}
protected void consoleSetTerrainPBR(string module, string[] args)
{
string num = args[3];
string uuid = args[4];
int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
{
if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
{
int corner = int.Parse(num);
UUID texture = UUID.Parse(uuid);
m_log.Debug($"[ESTATEMODULE]: Setting terrain PBR asset for {m_module.Scene.RegionInfo.RegionName} to {texture}");
switch (corner)
{
case 0:
m_module.Scene.RegionInfo.RegionSettings.TerrainPBR1 = texture;
break;
case 1:
m_module.Scene.RegionInfo.RegionSettings.TerrainPBR2 = texture;
break;
case 2:
m_module.Scene.RegionInfo.RegionSettings.TerrainPBR3 = texture;
break;
case 3:
m_module.Scene.RegionInfo.RegionSettings.TerrainPBR4 = texture;
break;
}
m_module.Scene.RegionInfo.RegionSettings.Save();
m_module.TriggerRegionInfoChange();
m_module.sendRegionHandshakeToAll();
}
}
}
protected void consoleSetWaterHeight(string module, string[] args)
{
string heightstring = args[3];

View File

@@ -541,22 +541,45 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (texture.IsZero())
return;
switch (level)
if((remoteClient.ViewerFlags & ViewerFlags.TPBR) != 0)
{
case 0:
Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
break;
case 1:
Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
break;
case 2:
Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
break;
case 3:
Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
break;
default:
return;
switch (level)
{
case 0:
Scene.RegionInfo.RegionSettings.TerrainPBR1 = texture;
break;
case 1:
Scene.RegionInfo.RegionSettings.TerrainPBR2 = texture;
break;
case 2:
Scene.RegionInfo.RegionSettings.TerrainPBR3 = texture;
break;
case 3:
Scene.RegionInfo.RegionSettings.TerrainPBR4 = texture;
break;
default:
return;
}
}
else
{
switch (level)
{
case 0:
Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
break;
case 1:
Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
break;
case 2:
Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
break;
case 3:
Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
break;
default:
return;
}
}
Scene.RegionInfo.RegionSettings.Save();

View File

@@ -3998,7 +3998,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
uint flags = ControllingClient.GetViewerCaps();
if ((flags & 0x1000) == 0) // wait for seeds sending
if ((flags & (uint)ViewerFlags.SentSeeds) == 0) // wait for seeds sending
return;
// give some extra time to make sure viewers did process seeds
@@ -4058,6 +4058,10 @@ namespace OpenSim.Region.Framework.Scenes
m_agentTransfer?.CloseOldChildAgents(this);
}
uint flags = ControllingClient.GetViewerCaps();
if ((flags & (uint)(ViewerFlags.TPBR | ViewerFlags.SentSeeds)) == (uint)ViewerFlags.TPBR)
ControllingClient.SendRegionHandshake();
m_log.DebugFormat("[SCENE PRESENCE({0})]: SendInitialData for {1}", m_scene.RegionInfo.RegionName, UUID);
if (m_teleportFlags <= 0)
{

View File

@@ -57,6 +57,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
private UUID m_agentID = UUID.Random();
public ISceneAgent SceneAgent { get; set; }
public ViewerFlags ViewerFlags { get; private set; } = 0;
public int PingTimeMS { get { return 0; } }

View File

@@ -57,6 +57,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
/// </summary>
public event ChatToNPC OnChatToNPC;
public ViewerFlags ViewerFlags { get; private set; }
/// <summary>
/// Fired when the NPC receives an instant message.
/// </summary>

View File

@@ -731,8 +731,8 @@ namespace OpenSim.Services.LLLoginService
else
{
position = pinfo.LastPosition;
position.X = Util.Clamp(position.X, 0.5f, region.RegionSizeX - 0.5f);
position.Y = Util.Clamp(position.Y, 0.5f, region.RegionSizeY - 0.5f);
position.X = Math.Clamp(position.X, 0.5f, region.RegionSizeX - 0.5f);
position.Y = Math.Clamp(position.Y, 0.5f, region.RegionSizeY - 0.5f);
lookAt = pinfo.LastLookAt;
}