From f21aca428fc3b03411982f9ec6cfb4819ce0eff0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 10 Jan 2024 13:30:14 +0000 Subject: [PATCH] do not auto set reflection_probe_ambiance on old skies, so a viewer can decide to fix for pbr (ofc seems tha currently they just set it 0 and do nothing showing broke skies in same cases); a few changes on notecards uuid detection --- OpenSim/Framework/SLUtil.cs | 4 +- OpenSim/Framework/Util.cs | 29 ++++++- OpenSim/Framework/ViewerSky.cs | 10 ++- .../Region/Framework/Scenes/UuidGatherer.cs | 2 +- .../Region/PhysicsModules/ubOde/ODEPrim.cs | 3 +- .../Region/PhysicsModules/ubOde/ODEScene.cs | 77 +++++++++++-------- 6 files changed, 86 insertions(+), 39 deletions(-) diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index fd539a3e42..0983c2f4d5 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -615,8 +615,8 @@ namespace OpenSim.Framework if(indx > 0) { indx += 14; - List textIDs = Util.GetUUIDsOnString(ref note, indx, note.Length - indx); - if(textIDs.Count > 0) + List textIDs = Util.GetUUIDsOnString(note.AsSpan(indx, note.Length - indx)); + if (textIDs.Count > 0) ids.AddRange(textIDs); } if (ids.Count == 0) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 56ec2b08d6..f95f573bf8 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -928,7 +928,7 @@ namespace OpenSim.Framework if (indx != next) continue; - if (UUID.TryParse(s.Substring(idbase, 36), out UUID u)) + if (UUID.TryParse(s.AsSpan(idbase, 36), out UUID u)) { ids.Add(u); } @@ -937,7 +937,33 @@ namespace OpenSim.Framework return ids; } + public static List GetUUIDsOnString(ReadOnlySpan s) + { + var ids = new List(); + if (s.Length < 36) + return ids; + int indx = 8; + while (indx < s.Length - 28) + { + if (s[indx] == '-') + { + if (UUID.TryParse(s.Slice(indx - 8, 36), out UUID id)) + { + if (id.IsNotZero()) + ids.Add(id); + indx += 37; + } + else + indx += 9; + } + else + indx++; + } + return ids; + } + + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] static bool IsHexa(byte c) { @@ -1061,6 +1087,7 @@ namespace OpenSim.Framework return ids; } + */ /// /// Is the platform Windows? diff --git a/OpenSim/Framework/ViewerSky.cs b/OpenSim/Framework/ViewerSky.cs index 7da44cd63c..2fd412ab14 100644 --- a/OpenSim/Framework/ViewerSky.cs +++ b/OpenSim/Framework/ViewerSky.cs @@ -158,6 +158,8 @@ namespace OpenSim.Framework public float dome_radius = 15000f; public float droplet_radius = 800.0f; public float ice_level = 0f; + + public bool HasRefProbe = false; public float reflectionProbeAmbiance = 0f; public float moisture_level = 0; @@ -222,8 +224,6 @@ namespace OpenSim.Framework sunlight_color = map["sunlight_color"]; - reflectionProbeAmbiance = 0f; - ViewerEnvironment.convertFromAngles(this, map["sun_angle"], map["east_angle"]); Name = name; } @@ -318,7 +318,8 @@ namespace OpenSim.Framework ["type"] = "sky" }; - map["reflection_probe_ambiance"] = reflectionProbeAmbiance; + if(HasRefProbe) + map["reflection_probe_ambiance"] = reflectionProbeAmbiance; return map; } @@ -369,7 +370,10 @@ namespace OpenSim.Framework ice_level = otmp; if (map.TryGetValue("reflection_probe_ambiance", out otmp)) + { reflectionProbeAmbiance = otmp; + HasRefProbe = true; + } if (map.TryGetValue("legacy_haze", out OSD tmp) && tmp is OSDMap lHaze) { diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 7c9e7b94d2..a59e1e071b 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -816,7 +816,7 @@ namespace OpenSim.Region.Framework.Scenes } } - private unsafe void RecordEmbeddedAssetDataUuids(ReadOnlySpan data) + private void RecordEmbeddedAssetDataUuids(ReadOnlySpan data) { if (data.Length < 36) return; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 5c300f052d..dcd24d58e4 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -4060,6 +4060,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde changeOrientation((Quaternion)arg); break; + /* case changes.PosOffset: donullchange(); break; @@ -4067,7 +4068,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde case changes.OriOffset: donullchange(); break; - + */ case changes.Velocity: changevelocity((Vector3)arg); break; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index b311804a79..3c7487cd94 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -103,11 +103,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde // or removes from a object if arg is null DeLink, Position, // arg Vector3 new position in world coords. Changes prim position. Prim must know if it is root or child - Orientation, // arg Quaternion new orientation in world coords. Changes prim position. Prim must know it it is root or child + Orientation, // arg Quaternion new orientation in world coords. Changes prim orientation. Prim must know it it is root or child PosOffset, // not in use // arg Vector3 new position in local coords. Changes prim position in object OriOffset, // not in use - // arg Vector3 new position in local coords. Changes prim position in object + // arg Vector3 new orientation in local coords. Changes prim orientation in object Velocity, TargetVelocity, AngVelocity, @@ -156,11 +156,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde Null //keep this last used do dim the methods array. does nothing but pulsing the prim } - public struct ODEchangeitem + public readonly struct ODEchangeitem { - public PhysicsActor actor; - public changes what; - public Object arg; + public readonly PhysicsActor actor; + public readonly changes what; + public readonly Object arg; + + public ODEchangeitem(PhysicsActor _actor, changes _what, Object _arg) + { + actor = _actor; + what = _what; + arg = _arg; + } } public partial class ODEScene : PhysicsScene @@ -1533,20 +1540,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// /// Called to queue a change to a actor - /// to use in place of old taint mechanism so changes do have a time sequence /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AddChange(PhysicsActor _actor, changes _what, Object _arg) + internal void AddChange(PhysicsActor _actor, changes _what, Object _arg) { if (world == IntPtr.Zero) return; - ODEchangeitem item = new() - { - actor = _actor, - what = _what, - arg = _arg - }; - ChangesQueue.Enqueue(item); + ChangesQueue.Enqueue(new ODEchangeitem(_actor, _what, _arg)); } // does all pending changes generated during region load process @@ -1567,22 +1567,28 @@ namespace OpenSim.Region.PhysicsModule.ubOde while (ChangesQueue.TryDequeue(out ODEchangeitem item)) { - if (item.actor != null) + try + { + lock (SimulationLock) + { + if (item.actor is OdePrim prim) + { + if (prim.DoAChange(item.what, item.arg)) + RemovePrimThreadLocked((OdePrim)item.actor); + } + else + ((OdeCharacter)item.actor).DoAChange(item.what, item.arg); + } + } + catch { try { - lock (SimulationLock) - { - if (item.actor is OdeCharacter character) - character.DoAChange(item.what, item.arg); - else if (((OdePrim)item.actor).DoAChange(item.what, item.arg)) - RemovePrimThreadLocked((OdePrim)item.actor); - } + m_log.WarnFormat($"[PHYSICS]: Operation failed for a actor {item.actor.Name} {item.what}"); } catch { - m_log.WarnFormat("[PHYSICS]: Operation failed for a actor {0} {1}", - item.actor.Name, item.what.ToString()); + m_log.WarnFormat("[PHYSICS]: Operation failed for a unknown actor"); } } donechanges++; @@ -1657,16 +1663,25 @@ namespace OpenSim.Region.PhysicsModule.ubOde { lock (SimulationLock) { - if (item.actor is OdeCharacter ch) - ch.DoAChange(item.what, item.arg); - else if (((OdePrim)item.actor).DoAChange(item.what, item.arg)) - RemovePrimThreadLocked((OdePrim)item.actor); + if (item.actor is OdePrim prim) + { + if (prim.DoAChange(item.what, item.arg)) + RemovePrimThreadLocked((OdePrim)item.actor); + } + else + ((OdeCharacter)item.actor).DoAChange(item.what, item.arg); } } catch { - m_log.WarnFormat("[PHYSICS]: doChange failed for a actor {0} {1}", - item.actor.Name, item.what.ToString()); + try + { + m_log.WarnFormat($"[PHYSICS]: Operation failed for a actor {item.actor.Name} {item.what}"); + } + catch + { + m_log.WarnFormat("[PHYSICS]: Operation failed for a unknown actor"); + } } if (maxChangestime < Util.GetTimeStampMS()) break;