aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs97
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs39
2 files changed, 106 insertions, 30 deletions
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
4161 4161
4162 } 4162 }
4163 4163
4164 public bool GroupResize(double fscale)
4165 {
4166// m_log.DebugFormat(
4167// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, fscale);
4168
4169 if (Scene == null || IsDeleted || inTransit || fscale < 0)
4170 return false;
4171
4172 // ignore lsl restrictions. let them be done a LSL
4173 PhysicsActor pa = m_rootPart.PhysActor;
4174
4175 if(RootPart.KeyframeMotion != null)
4176 RootPart.KeyframeMotion.Suspend();
4177
4178 float minsize = Scene.m_minNonphys;
4179 float maxsize = Scene.m_maxNonphys;
4180
4181 // assuming physics is more restrictive
4182 if (pa != null && pa.IsPhysical)
4183 {
4184 minsize = Scene.m_minPhys;
4185 maxsize = Scene.m_maxPhys;
4186 }
4187
4188 SceneObjectPart[] parts = m_parts.GetArray();
4189 float tmp;
4190 // check scaling factor so parts don't violate dimensions
4191 for(int i = 0; i < parts.Length; i++)
4192 {
4193 SceneObjectPart obPart = parts[i];
4194 Vector3 oldSize = new Vector3(obPart.Scale);
4195 tmp = (float)(oldSize.X * fscale);
4196 if(tmp > maxsize)
4197 return false;
4198 if(tmp < minsize)
4199 return false;
4200
4201 tmp = (float)(oldSize.Y * fscale);
4202 if(tmp > maxsize)
4203 return false;
4204 if(tmp < minsize)
4205 return false;
4206
4207 tmp = (float)(oldSize.Z * fscale);
4208 if(tmp > maxsize)
4209 return false;
4210 if(tmp < minsize)
4211 return false;
4212 }
4213
4214 Vector3 newSize = RootPart.Scale;
4215 newSize.X = (float)(newSize.X * fscale);
4216 newSize.Y = (float)(newSize.Y * fscale);
4217 newSize.Z = (float)(newSize.Z * fscale);
4218
4219 if(pa != null)
4220 pa.Building = true;
4221
4222 RootPart.Scale = newSize;
4223
4224 Vector3 currentpos;
4225 for (int i = 0; i < parts.Length; i++)
4226 {
4227 SceneObjectPart obPart = parts[i];
4228
4229 if (obPart.UUID != m_rootPart.UUID)
4230 {
4231 currentpos = obPart.OffsetPosition;
4232 currentpos.X = (float)(currentpos.X * fscale);
4233 currentpos.Y = (float)(currentpos.Y * fscale);
4234 currentpos.Z = (float)(currentpos.Z * fscale);
4235
4236 newSize = obPart.Scale;
4237 newSize.X = (float)(newSize.X * fscale);
4238 newSize.Y = (float)(newSize.Y * fscale);
4239 newSize.Z = (float)(newSize.Z * fscale);
4240
4241 obPart.Scale = newSize;
4242 obPart.UpdateOffSet(currentpos);
4243 }
4244 }
4245
4246 if(pa != null)
4247 pa.Building = false;
4248
4249 InvalidBoundsRadius();
4250
4251 HasGroupChanged = true;
4252 m_rootPart.TriggerScriptChangedEvent(Changed.SCALE);
4253 ScheduleGroupForFullUpdate();
4254
4255 if(RootPart.KeyframeMotion != null)
4256 RootPart.KeyframeMotion.Resume();
4257
4258 return true;
4259 }
4260
4164 #endregion 4261 #endregion
4165 4262
4166 #region Position 4263 #region Position
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b5abdb5..c43aef5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1808,45 +1808,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1808 m_host.AddScriptLPS(1); 1808 m_host.AddScriptLPS(1);
1809 SceneObjectGroup group = m_host.ParentGroup; 1809 SceneObjectGroup group = m_host.ParentGroup;
1810 1810
1811 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) 1811 if(scaling_factor < 1e-6)
1812 return ScriptBaseClass.FALSE; 1812 return ScriptBaseClass.FALSE;
1813 1813 if(scaling_factor > 1e6)
1814 if (group.RootPart.KeyframeMotion != null)
1815 return ScriptBaseClass.FALSE; 1814 return ScriptBaseClass.FALSE;
1816 1815
1817 List<SceneObjectPart> prims = GetLinkParts(ScriptBaseClass.LINK_SET); 1816 if (group == null || group.IsDeleted || group.inTransit)
1818 if (prims.Count > 0) 1817 return ScriptBaseClass.FALSE;
1819 {
1820 foreach (SceneObjectPart prim in prims)
1821 {
1822 LSL_Vector size = new LSL_Vector(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);
1823 LSL_Vector new_size = new LSL_Vector(scaling_factor * size);
1824
1825 new_size.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, new_size.x));
1826 new_size.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, new_size.y));
1827 new_size.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, new_size.z));
1828
1829 if (new_size.x != scaling_factor * size.x || new_size.y != scaling_factor * size.y || new_size.z != scaling_factor * size.z)
1830 return ScriptBaseClass.FALSE;
1831
1832 LSL_Vector position = new LSL_Vector(GetPartLocalPos(prim));
1833 1818
1834 if (!prim.IsRoot) 1819 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical)
1835 { 1820 return ScriptBaseClass.FALSE;
1836 position = GetSetPosTarget(prim, scaling_factor * position, position, true);
1837 prim.OffsetPosition = position;
1838 prim.ScheduleTerseUpdate();
1839 }
1840 1821
1841 SetScale(prim, new_size); 1822 if (group.RootPart.KeyframeMotion != null)
1842 } 1823 return ScriptBaseClass.FALSE;
1843 1824
1825 if(group.GroupResize(scaling_factor))
1844 return ScriptBaseClass.TRUE; 1826 return ScriptBaseClass.TRUE;
1845 }
1846 else 1827 else
1847 {
1848 return ScriptBaseClass.FALSE; 1828 return ScriptBaseClass.FALSE;
1849 }
1850 } 1829 }
1851 1830
1852 public void llSetScale(LSL_Vector scale) 1831 public void llSetScale(LSL_Vector scale)