From 4e64445c39c3de1941e071ff32d06702a3440d5d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Nov 2016 05:18:06 +0000 Subject: replace datetime.now on just timming by faster utcnow --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e643db7..0cd738d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -153,9 +153,9 @@ namespace OpenSim.Region.Framework.Scenes { m_scene.SceneGraph.FireChangeBackup(this); } - timeLastChanged = DateTime.Now.Ticks; + timeLastChanged = DateTime.UtcNow.Ticks; if (!m_hasGroupChanged) - timeFirstChanged = DateTime.Now.Ticks; + timeFirstChanged = DateTime.UtcNow.Ticks; if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) { /* @@ -233,7 +233,7 @@ namespace OpenSim.Region.Framework.Scenes m_minPersistTime = m_scene.m_dontPersistBefore; } - long currentTime = DateTime.Now.Ticks; + long currentTime = DateTime.UtcNow.Ticks; if (timeLastChanged == 0) timeLastChanged = currentTime; if (timeFirstChanged == 0) timeFirstChanged = currentTime; -- cgit v1.1 From b82a41d2606dfaf42455e0030b5640752167162b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 25 Nov 2016 17:34:19 +0000 Subject: change llScaleByFactor (sorry Mandarinka). --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0cd738d..739d23d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -4161,6 +4161,103 @@ namespace OpenSim.Region.Framework.Scenes } + public bool GroupResize(double fscale) + { +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, fscale); + + if (Scene == null || IsDeleted || inTransit || fscale < 0) + return false; + + // ignore lsl restrictions. let them be done a LSL + PhysicsActor pa = m_rootPart.PhysActor; + + if(RootPart.KeyframeMotion != null) + RootPart.KeyframeMotion.Suspend(); + + float minsize = Scene.m_minNonphys; + float maxsize = Scene.m_maxNonphys; + + // assuming physics is more restrictive + if (pa != null && pa.IsPhysical) + { + minsize = Scene.m_minPhys; + maxsize = Scene.m_maxPhys; + } + + SceneObjectPart[] parts = m_parts.GetArray(); + float tmp; + // check scaling factor so parts don't violate dimensions + for(int i = 0; i < parts.Length; i++) + { + SceneObjectPart obPart = parts[i]; + Vector3 oldSize = new Vector3(obPart.Scale); + tmp = (float)(oldSize.X * fscale); + if(tmp > maxsize) + return false; + if(tmp < minsize) + return false; + + tmp = (float)(oldSize.Y * fscale); + if(tmp > maxsize) + return false; + if(tmp < minsize) + return false; + + tmp = (float)(oldSize.Z * fscale); + if(tmp > maxsize) + return false; + if(tmp < minsize) + return false; + } + + Vector3 newSize = RootPart.Scale; + newSize.X = (float)(newSize.X * fscale); + newSize.Y = (float)(newSize.Y * fscale); + newSize.Z = (float)(newSize.Z * fscale); + + if(pa != null) + pa.Building = true; + + RootPart.Scale = newSize; + + Vector3 currentpos; + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart obPart = parts[i]; + + if (obPart.UUID != m_rootPart.UUID) + { + currentpos = obPart.OffsetPosition; + currentpos.X = (float)(currentpos.X * fscale); + currentpos.Y = (float)(currentpos.Y * fscale); + currentpos.Z = (float)(currentpos.Z * fscale); + + newSize = obPart.Scale; + newSize.X = (float)(newSize.X * fscale); + newSize.Y = (float)(newSize.Y * fscale); + newSize.Z = (float)(newSize.Z * fscale); + + obPart.Scale = newSize; + obPart.UpdateOffSet(currentpos); + } + } + + if(pa != null) + pa.Building = false; + + InvalidBoundsRadius(); + + HasGroupChanged = true; + m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); + ScheduleGroupForFullUpdate(); + + if(RootPart.KeyframeMotion != null) + RootPart.KeyframeMotion.Resume(); + + return true; + } + #endregion #region Position -- cgit v1.1 From 935510d87956f080f1425982b3da918009c32feb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 25 Nov 2016 18:35:23 +0000 Subject: add llGetMaxScaleFactor and llGetMinScaleFactor --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 739d23d..6cdbac5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -4258,6 +4258,83 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public float GetMaxGroupResizeScale() + { + if (Scene == null || IsDeleted || inTransit) + return 1.0f; + + float maxsize = Scene.m_maxNonphys; + PhysicsActor pa = m_rootPart.PhysActor; + // assuming physics is more restrictive + if (pa != null && pa.IsPhysical) + maxsize = Scene.m_maxPhys; + + SceneObjectPart[] parts = m_parts.GetArray(); + float larger = float.MinValue; + + for(int i = 0; i < parts.Length; i++) + { + SceneObjectPart obPart = parts[i]; + Vector3 oldSize = new Vector3(obPart.Scale); + if(larger < oldSize.X) + larger = oldSize.X; + + if(larger < oldSize.Y) + larger = oldSize.Y; + + if(larger < oldSize.Z) + larger = oldSize.Z; + } + + if(larger >= maxsize) + return 1.0f; + + larger += 1e-3f; + float fscale = maxsize / larger; + + return fscale; + } + + public float GetMinGroupResizeScale() + { + if (Scene == null || IsDeleted || inTransit) + return 1.0f; + + float minsize = Scene.m_minNonphys; + PhysicsActor pa = m_rootPart.PhysActor; + // assuming physics is more restrictive + if (pa != null && pa.IsPhysical) + minsize = Scene.m_minPhys; + + SceneObjectPart[] parts = m_parts.GetArray(); + float smaller = float.MaxValue; + + for(int i = 0; i < parts.Length; i++) + { + SceneObjectPart obPart = parts[i]; + Vector3 oldSize = new Vector3(obPart.Scale); + if(smaller > oldSize.X) + smaller = oldSize.X; + + if(smaller > oldSize.Y) + smaller = oldSize.Y; + + if(smaller > oldSize.Z) + smaller = oldSize.Z; + } + + if(smaller <= minsize) + return 1.0f; + + if(smaller > 2e-3f) + smaller -= 1e-3f; + float fscale = minsize / smaller; + if(fscale < 1e-8f) + fscale = 1e-8f; + + return fscale; + } + #endregion #region Position -- cgit v1.1