Make it possible to rescale SOGs when they are not in a scene.

connector_plugin
Justin Clark-Casey (justincc) 2012-09-26 23:17:21 +01:00
parent 327320d1a7
commit 36e3123069
2 changed files with 40 additions and 34 deletions

View File

@ -2703,29 +2703,32 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
RootPart.StoreUndoState(true);
scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X));
scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y));
scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z));
PhysicsActor pa = m_rootPart.PhysActor;
if (pa != null && pa.IsPhysical)
RootPart.StoreUndoState(true);
if (Scene != null)
{
scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X));
scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y));
scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z));
scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X));
scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y));
scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z));
if (pa != null && pa.IsPhysical)
{
scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X));
scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y));
scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z));
}
}
float x = (scale.X / RootPart.Scale.X);
float y = (scale.Y / RootPart.Scale.Y);
float z = (scale.Z / RootPart.Scale.Z);
SceneObjectPart[] parts;
if (x > 1.0f || y > 1.0f || z > 1.0f)
SceneObjectPart[] parts = m_parts.GetArray();
if (Scene != null & (x > 1.0f || y > 1.0f || z > 1.0f))
{
parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart obPart = parts[i];
@ -2739,7 +2742,7 @@ namespace OpenSim.Region.Framework.Scenes
if (pa != null && pa.IsPhysical)
{
if (oldSize.X * x > m_scene.m_maxPhys)
if (oldSize.X * x > Scene.m_maxPhys)
{
f = m_scene.m_maxPhys / oldSize.X;
a = f / x;
@ -2747,7 +2750,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
else if (oldSize.X * x < m_scene.m_minPhys)
else if (oldSize.X * x < Scene.m_minPhys)
{
f = m_scene.m_minPhys / oldSize.X;
a = f / x;
@ -2756,7 +2759,7 @@ namespace OpenSim.Region.Framework.Scenes
z *= a;
}
if (oldSize.Y * y > m_scene.m_maxPhys)
if (oldSize.Y * y > Scene.m_maxPhys)
{
f = m_scene.m_maxPhys / oldSize.Y;
a = f / y;
@ -2764,7 +2767,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
else if (oldSize.Y * y < m_scene.m_minPhys)
else if (oldSize.Y * y < Scene.m_minPhys)
{
f = m_scene.m_minPhys / oldSize.Y;
a = f / y;
@ -2773,7 +2776,7 @@ namespace OpenSim.Region.Framework.Scenes
z *= a;
}
if (oldSize.Z * z > m_scene.m_maxPhys)
if (oldSize.Z * z > Scene.m_maxPhys)
{
f = m_scene.m_maxPhys / oldSize.Z;
a = f / z;
@ -2781,7 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
else if (oldSize.Z * z < m_scene.m_minPhys)
else if (oldSize.Z * z < Scene.m_minPhys)
{
f = m_scene.m_minPhys / oldSize.Z;
a = f / z;
@ -2792,7 +2795,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
if (oldSize.X * x > m_scene.m_maxNonphys)
if (oldSize.X * x > Scene.m_maxNonphys)
{
f = m_scene.m_maxNonphys / oldSize.X;
a = f / x;
@ -2800,7 +2803,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
else if (oldSize.X * x < m_scene.m_minNonphys)
else if (oldSize.X * x < Scene.m_minNonphys)
{
f = m_scene.m_minNonphys / oldSize.X;
a = f / x;
@ -2809,7 +2812,7 @@ namespace OpenSim.Region.Framework.Scenes
z *= a;
}
if (oldSize.Y * y > m_scene.m_maxNonphys)
if (oldSize.Y * y > Scene.m_maxNonphys)
{
f = m_scene.m_maxNonphys / oldSize.Y;
a = f / y;
@ -2817,7 +2820,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
else if (oldSize.Y * y < m_scene.m_minNonphys)
else if (oldSize.Y * y < Scene.m_minNonphys)
{
f = m_scene.m_minNonphys / oldSize.Y;
a = f / y;
@ -2826,7 +2829,7 @@ namespace OpenSim.Region.Framework.Scenes
z *= a;
}
if (oldSize.Z * z > m_scene.m_maxNonphys)
if (oldSize.Z * z > Scene.m_maxNonphys)
{
f = m_scene.m_maxNonphys / oldSize.Z;
a = f / z;
@ -2834,7 +2837,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
else if (oldSize.Z * z < m_scene.m_minNonphys)
else if (oldSize.Z * z < Scene.m_minNonphys)
{
f = m_scene.m_minNonphys / oldSize.Z;
a = f / z;
@ -2858,7 +2861,6 @@ namespace OpenSim.Region.Framework.Scenes
RootPart.Resize(prevScale);
// RootPart.IgnoreUndoUpdate = false;
parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart obPart = parts[i];

View File

@ -2368,16 +2368,20 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="scale"></param>
public void Resize(Vector3 scale)
{
scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X));
scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y));
scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z));
PhysicsActor pa = PhysActor;
if (pa != null && pa.IsPhysical)
if (ParentGroup.Scene != null)
{
scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X));
scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y));
scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z));
scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X));
scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y));
scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z));
if (pa != null && pa.IsPhysical)
{
scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X));
scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y));
scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z));
}
}
// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);