aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorCharles Krinke2008-07-10 03:13:29 +0000
committerCharles Krinke2008-07-10 03:13:29 +0000
commit38da8960e98c12a16bf8a25e9fe7e03ee251933c (patch)
tree2e54441d2bedee44a3a9f0a083dc56e9a290349a /OpenSim
parentMantis#1673. Thank you kindly, Matth for a patch that: (diff)
downloadopensim-SC_OLD-38da8960e98c12a16bf8a25e9fe7e03ee251933c.zip
opensim-SC_OLD-38da8960e98c12a16bf8a25e9fe7e03ee251933c.tar.gz
opensim-SC_OLD-38da8960e98c12a16bf8a25e9fe7e03ee251933c.tar.bz2
opensim-SC_OLD-38da8960e98c12a16bf8a25e9fe7e03ee251933c.tar.xz
Mantis#1707. Thank you, Melanie for a patch that:
This patch limits the maximum size of prims that can be created using libsl bots or modified clients to 65536mper side. It also limits LSL functions to that size. If a prim is already physical, the enforced constraint is 10m. A prim that is larger than 10m cannot be turned physical, either via script or UI. Linksets are handled correctly, so scaling of physical linksets is constrained by the size of it's largest component prim. Also, turning linksets physical is based on the size of it's largest ptim.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs121
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs36
3 files changed, 191 insertions, 2 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index ebefdce..eafb882 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -2012,6 +2012,15 @@ namespace OpenSim.Region.Environment.Scenes
2012 // If we have children 2012 // If we have children
2013 lock (m_parts) 2013 lock (m_parts)
2014 { 2014 {
2015 foreach (SceneObjectPart parts in m_parts.Values)
2016 {
2017 if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
2018 {
2019 data[47] = 0; // Reset physics
2020 break;
2021 }
2022 }
2023
2015 if (m_parts.Count > 1) 2024 if (m_parts.Count > 1)
2016 { 2025 {
2017 foreach (SceneObjectPart parts in m_parts.Values) 2026 foreach (SceneObjectPart parts in m_parts.Values)
@@ -2100,12 +2109,28 @@ namespace OpenSim.Region.Environment.Scenes
2100 /// <param name="localID"></param> 2109 /// <param name="localID"></param>
2101 public void Resize(LLVector3 scale, uint localID) 2110 public void Resize(LLVector3 scale, uint localID)
2102 { 2111 {
2112 if(scale.X > 65536.0f)
2113 scale.X = 65536.0f;
2114 if(scale.Y > 65536.0f)
2115 scale.Y = 65536.0f;
2116 if(scale.Z > 65536.0f)
2117 scale.Z = 65536.0f;
2118
2103 SceneObjectPart part = GetChildPart(localID); 2119 SceneObjectPart part = GetChildPart(localID);
2104 if (part != null) 2120 if (part != null)
2105 { 2121 {
2106 part.Resize(scale); 2122 part.Resize(scale);
2107 if (part.PhysActor != null) 2123 if (part.PhysActor != null)
2108 { 2124 {
2125 if(part.PhysActor.IsPhysical)
2126 {
2127 if(scale.X > 10.0f)
2128 scale.X = 10.0f;
2129 if(scale.Y > 10.0f)
2130 scale.Y = 10.0f;
2131 if(scale.Z > 10.0f)
2132 scale.Z = 10.0f;
2133 }
2109 part.PhysActor.Size = 2134 part.PhysActor.Size =
2110 new PhysicsVector(scale.X, scale.Y, scale.Z); 2135 new PhysicsVector(scale.X, scale.Y, scale.Z);
2111 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2136 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
@@ -2132,10 +2157,102 @@ namespace OpenSim.Region.Environment.Scenes
2132 SceneObjectPart part = GetChildPart(localID); 2157 SceneObjectPart part = GetChildPart(localID);
2133 if (part != null) 2158 if (part != null)
2134 { 2159 {
2160 if(scale.X > 65536.0f)
2161 scale.X = 65536.0f;
2162 if(scale.Y > 65536.0f)
2163 scale.Y = 65536.0f;
2164 if(scale.Z > 65536.0f)
2165 scale.Z = 65536.0f;
2166 if(part.PhysActor != null && part.PhysActor.IsPhysical)
2167 {
2168 if(scale.X > 10.0f)
2169 scale.X = 10.0f;
2170 if(scale.Y > 10.0f)
2171 scale.Y = 10.0f;
2172 if(scale.Z > 10.0f)
2173 scale.Z = 10.0f;
2174 }
2135 float x = (scale.X / part.Scale.X); 2175 float x = (scale.X / part.Scale.X);
2136 float y = (scale.Y / part.Scale.Y); 2176 float y = (scale.Y / part.Scale.Y);
2137 float z = (scale.Z / part.Scale.Z); 2177 float z = (scale.Z / part.Scale.Z);
2138 part.Resize(scale); 2178
2179 lock (m_parts)
2180 {
2181 if(x > 1.0f || y > 1.0f || z > 1.0f)
2182 {
2183 foreach (SceneObjectPart obPart in m_parts.Values)
2184 {
2185 if (obPart.UUID != m_rootPart.UUID)
2186 {
2187 LLVector3 oldSize = new LLVector3(obPart.Scale);
2188
2189 float f = 1.0f;
2190 float a = 1.0f;
2191
2192 if(part.PhysActor != null && part.PhysActor.IsPhysical)
2193 {
2194 if(oldSize.X*x > 10.0f)
2195 {
2196 f = 10.0f / oldSize.X;
2197 a = f / x;
2198 x *= a;
2199 y *= a;
2200 z *= a;
2201 }
2202 if(oldSize.Y*y > 10.0f)
2203 {
2204 f = 10.0f / oldSize.Y;
2205 a = f / y;
2206 x *= a;
2207 y *= a;
2208 z *= a;
2209 }
2210 if(oldSize.Z*z > 10.0f)
2211 {
2212 f = 10.0f / oldSize.Z;
2213 a = f / z;
2214 x *= a;
2215 y *= a;
2216 z *= a;
2217 }
2218 }
2219 else
2220 {
2221 if(oldSize.X*x > 65536.0f)
2222 {
2223 f = 65536.0f / oldSize.X;
2224 a = f / x;
2225 x *= a;
2226 y *= a;
2227 z *= a;
2228 }
2229 if(oldSize.Y*y > 65536.0f)
2230 {
2231 f = 65536.0f / oldSize.Y;
2232 a = f / y;
2233 x *= a;
2234 y *= a;
2235 z *= a;
2236 }
2237 if(oldSize.Z*z > 65536.0f)
2238 {
2239 f = 65536.0f / oldSize.Z;
2240 a = f / z;
2241 x *= a;
2242 y *= a;
2243 z *= a;
2244 }
2245 }
2246 }
2247 }
2248 }
2249 }
2250
2251 LLVector3 prevScale = part.Scale;
2252 prevScale.X *= x;
2253 prevScale.Y *= y;
2254 prevScale.Z *= z;
2255 part.Resize(prevScale);
2139 2256
2140 lock (m_parts) 2257 lock (m_parts)
2141 { 2258 {
@@ -2160,7 +2277,7 @@ namespace OpenSim.Region.Environment.Scenes
2160 if (part.PhysActor != null) 2277 if (part.PhysActor != null)
2161 { 2278 {
2162 part.PhysActor.Size = 2279 part.PhysActor.Size =
2163 new PhysicsVector(scale.X, scale.Y, scale.Z); 2280 new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z);
2164 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2281 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2165 } 2282 }
2166 2283
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 2b986be..2538246 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -831,7 +831,24 @@ namespace OpenSim.Region.ScriptEngine.Common
831 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHYSICS) == BuiltIn_Commands_BaseClass.STATUS_PHYSICS) 831 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHYSICS) == BuiltIn_Commands_BaseClass.STATUS_PHYSICS)
832 { 832 {
833 if (value == 1) 833 if (value == 1)
834 {
835 SceneObjectGroup group = m_host.ParentGroup;
836 if(group == null)
837 return;
838 bool allow = true;
839 foreach(SceneObjectPart part in group.Children.Values)
840 {
841 if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
842 {
843 allow = false;
844 break;
845 }
846 }
847
848 if(!allow)
849 return;
834 m_host.ScriptSetPhysicsStatus(true); 850 m_host.ScriptSetPhysicsStatus(true);
851 }
835 else 852 else
836 m_host.ScriptSetPhysicsStatus(false); 853 m_host.ScriptSetPhysicsStatus(false);
837 854
@@ -948,6 +965,25 @@ namespace OpenSim.Region.ScriptEngine.Common
948 private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale) 965 private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale)
949 { 966 {
950 // TODO: this needs to trigger a persistance save as well 967 // TODO: this needs to trigger a persistance save as well
968
969 if(part == null || part.ParentGroup == null || part.ParentGroup.RootPart == null)
970 return;
971
972 if(part.ParentGroup.RootPart.PhysActor != null && part.ParentGroup.RootPart.PhysActor.IsPhysical)
973 {
974 if(scale.x > 10.0)
975 scale.x = 10.0;
976 if(scale.y > 10.0)
977 scale.y = 10.0;
978 if(scale.z > 10.0)
979 scale.z = 10.0;
980 }
981 if(scale.x > 65536.0)
982 scale.x = 65536.0;
983 if(scale.y > 65536.0)
984 scale.y = 65536.0;
985 if(scale.z > 65536.0)
986 scale.z = 65536.0;
951 LLVector3 tmp = part.Scale; 987 LLVector3 tmp = part.Scale;
952 tmp.X = (float)scale.x; 988 tmp.X = (float)scale.x;
953 tmp.Y = (float)scale.y; 989 tmp.Y = (float)scale.y;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 57f9141..4bf3e93 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -671,7 +671,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
671 if ((status & ScriptBaseClass.STATUS_PHYSICS) == ScriptBaseClass.STATUS_PHYSICS) 671 if ((status & ScriptBaseClass.STATUS_PHYSICS) == ScriptBaseClass.STATUS_PHYSICS)
672 { 672 {
673 if (value == 1) 673 if (value == 1)
674 {
675 SceneObjectGroup group = m_host.ParentGroup;
676 if(group == null)
677 return;
678 bool allow = true;
679 foreach(SceneObjectPart part in group.Children.Values)
680 {
681 if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
682 {
683 allow = false;
684 break;
685 }
686 }
687
688 if(!allow)
689 return;
674 m_host.ScriptSetPhysicsStatus(true); 690 m_host.ScriptSetPhysicsStatus(true);
691 }
675 else 692 else
676 m_host.ScriptSetPhysicsStatus(false); 693 m_host.ScriptSetPhysicsStatus(false);
677 } 694 }
@@ -802,6 +819,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
802 private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale) 819 private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale)
803 { 820 {
804 // TODO: this needs to trigger a persistance save as well 821 // TODO: this needs to trigger a persistance save as well
822
823 if(part == null || part.ParentGroup == null || part.ParentGroup.RootPart == null)
824 return;
825
826 if(part.ParentGroup.RootPart.PhysActor != null && part.ParentGroup.RootPart.PhysActor.IsPhysical)
827 {
828 if(scale.x > 10.0)
829 scale.x = 10.0;
830 if(scale.y > 10.0)
831 scale.y = 10.0;
832 if(scale.z > 10.0)
833 scale.z = 10.0;
834 }
835 if(scale.x > 65536.0)
836 scale.x = 65536.0;
837 if(scale.y > 65536.0)
838 scale.y = 65536.0;
839 if(scale.z > 65536.0)
840 scale.z = 65536.0;
805 LLVector3 tmp = part.Scale; 841 LLVector3 tmp = part.Scale;
806 tmp.X = (float)scale.x; 842 tmp.X = (float)scale.x;
807 tmp.Y = (float)scale.y; 843 tmp.Y = (float)scale.y;