refactor: Push all part resize code down into SceneObjectPart.Resize()

bulletsim
Justin Clark-Casey (justincc) 2011-07-16 04:22:57 +01:00
parent 4b5a6b655b
commit 2b68ac4ba3
4 changed files with 32 additions and 56 deletions

View File

@ -1217,12 +1217,13 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="remoteClient"></param>
protected internal void UpdatePrimScale(uint localID, Vector3 scale, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
SceneObjectPart part = GetSceneObjectPart(localID);
if (part != null)
{
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId))
if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId))
{
group.Resize(scale, localID);
part.Resize(scale);
}
}
}

View File

@ -2611,56 +2611,6 @@ namespace OpenSim.Region.Framework.Scenes
#region Resize
/// <summary>
/// Resize the given part
/// </summary>
/// <param name="scale"></param>
/// <param name="localID"></param>
public void Resize(Vector3 scale, uint localID)
{
if (scale.X > m_scene.m_maxNonphys)
scale.X = m_scene.m_maxNonphys;
if (scale.Y > m_scene.m_maxNonphys)
scale.Y = m_scene.m_maxNonphys;
if (scale.Z > m_scene.m_maxNonphys)
scale.Z = m_scene.m_maxNonphys;
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
part.Resize(scale);
if (part.PhysActor != null)
{
if (part.PhysActor.IsPhysical)
{
if (scale.X > m_scene.m_maxPhys)
scale.X = m_scene.m_maxPhys;
if (scale.Y > m_scene.m_maxPhys)
scale.Y = m_scene.m_maxPhys;
if (scale.Z > m_scene.m_maxPhys)
scale.Z = m_scene.m_maxPhys;
}
part.PhysActor.Size = scale;
m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
}
//if (part.UUID != m_rootPart.UUID)
HasGroupChanged = true;
part.TriggerScriptChangedEvent(Changed.SCALE);
ScheduleGroupForFullUpdate();
//if (part.UUID == m_rootPart.UUID)
//{
//if (m_rootPart.PhysActor != null)
//{
//m_rootPart.PhysActor.Size =
//new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
//m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
//}
//}
}
}
/// <summary>
/// Resize the entire group of prims.
/// </summary>

View File

@ -2846,6 +2846,13 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="scale"></param>
public void Resize(Vector3 scale)
{
if (scale.X > ParentGroup.Scene.m_maxNonphys)
scale.X = ParentGroup.Scene.m_maxNonphys;
if (scale.Y > ParentGroup.Scene.m_maxNonphys)
scale.Y = ParentGroup.Scene.m_maxNonphys;
if (scale.Z > ParentGroup.Scene.m_maxNonphys)
scale.Z = ParentGroup.Scene.m_maxNonphys;
// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
StoreUndoState();
@ -2855,9 +2862,27 @@ namespace OpenSim.Region.Framework.Scenes
// need to reinsert the sculpt data into the shape, since the physics engine deletes it when done to
// save memory
if (PhysActor != null)
CheckSculptAndLoad();
{
if (PhysActor.IsPhysical)
{
if (scale.X > ParentGroup.Scene.m_maxPhys)
scale.X = ParentGroup.Scene.m_maxPhys;
if (scale.Y > ParentGroup.Scene.m_maxPhys)
scale.Y = ParentGroup.Scene.m_maxPhys;
if (scale.Z > ParentGroup.Scene.m_maxPhys)
scale.Z = ParentGroup.Scene.m_maxPhys;
}
PhysActor.Size = scale;
if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
CheckSculptAndLoad();
else
ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
}
ParentGroup.HasGroupChanged = true;
TriggerScriptChangedEvent(Changed.SCALE);
ScheduleFullUpdate();
}

View File

@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID);
g1Post.Resize(new Vector3(8, 9, 10), g1Post.Parts[1].LocalId);
g1Post.Parts[1].Resize(new Vector3(8, 9, 10));
SceneObjectGroup g1PostPost = scene.GetSceneObjectGroup(g1.UUID);