diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 04b91ef5c8..5dafc0beb3 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -170,7 +170,7 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber, MediaURL) values (" + "?UUID, " + + "LinkNumber, MediaURL, KeyframeMotion) values (" + "?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + @@ -201,7 +201,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL, ?KeyframeMotion)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -446,7 +446,11 @@ namespace OpenSim.Data.MySQL foreach (SceneObjectPart prim in prims.Values) { if (prim.ParentUUID == UUID.Zero) + { objects[prim.UUID] = new SceneObjectGroup(prim); + if (prim.KeyframeMotion != null) + prim.KeyframeMotion.UpdateSceneObject(objects[prim.UUID]); + } } // Add all of the children objects to the SOGs @@ -1227,6 +1231,18 @@ namespace OpenSim.Data.MySQL if (!(row["MediaURL"] is System.DBNull)) prim.MediaUrl = (string)row["MediaURL"]; + if (!(row["KeyframeMotion"] is DBNull)) + { + Byte[] data = (byte[])row["KeyframeMotion"]; + if (data.Length > 0) + prim.KeyframeMotion = KeyframeMotion.FromData(null, data); + else + prim.KeyframeMotion = null; + } + else + { + prim.KeyframeMotion = null; + } return prim; } @@ -1579,6 +1595,11 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + + if (prim.KeyframeMotion != null) + cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize()); + else + cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); } /// diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 098123a244..192d55fd90 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -355,11 +355,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess foreach (SceneObjectGroup objectGroup in objlist) { - if (objectGroup.KeyframeMotion != null) - objectGroup.KeyframeMotion.Stop(); + if (objectGroup.RootPart.KeyframeMotion != null) + objectGroup.RootPart.KeyframeMotion.Stop(); objectGroup.RootPart.SetForce(Vector3.Zero); objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false); - objectGroup.KeyframeMotion = null; + objectGroup.RootPart.KeyframeMotion = null; Vector3 inventoryStoredPosition = new Vector3 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c20da4beaf..11a41aa98b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2421,8 +2421,8 @@ namespace OpenSim.Region.Framework.Scenes if (newPosition != Vector3.Zero) newObject.RootPart.GroupPosition = newPosition; - if (newObject.KeyframeMotion != null) - newObject.KeyframeMotion.UpdateSceneObject(newObject); + if (newObject.RootPart.KeyframeMotion != null) + newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); if (!AddSceneObject(newObject)) { diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 5a7f12417f..a3206015c2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1731,6 +1731,12 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void LinkObjects(SceneObjectPart root, List children) { + if (root.KeyframeMotion != null) + { + root.KeyframeMotion.Stop(); + root.KeyframeMotion = null; + } + SceneObjectGroup parentGroup = root.ParentGroup; if (parentGroup == null) return; @@ -1823,6 +1829,11 @@ namespace OpenSim.Region.Framework.Scenes { if (part != null) { + if (part.KeyframeMotion != null) + { + part.KeyframeMotion.Stop(); + part.KeyframeMotion = null; + } if (part.ParentGroup.PrimCount != 1) // Skip single { if (part.LinkNum < 2) // Root diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e509d4e36f..fefae9d100 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -114,12 +114,6 @@ namespace OpenSim.Region.Framework.Scenes private Random m_rand; private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - private KeyframeMotion m_keyframeMotion = null; - - public KeyframeMotion KeyframeMotion - { - get; set; - } public bool areUpdatesSuspended { @@ -726,8 +720,8 @@ namespace OpenSim.Region.Framework.Scenes child.PhysActor.Selected = value; } } - if (KeyframeMotion != null) - KeyframeMotion.Selected = value; + if (RootPart.KeyframeMotion != null) + RootPart.KeyframeMotion.Selected = value; } } @@ -1829,11 +1823,6 @@ namespace OpenSim.Region.Framework.Scenes // Name, UUID, m_scene.RegionInfo.RegionName); SceneObjectGroup backup_group = Copy(false); - if (KeyframeMotion != null) - { - backup_group.KeyframeMotion = KeyframeMotion.FromData(backup_group, KeyframeMotion.Serialize()); - KeyframeMotion.UpdateSceneObject(this); - } backup_group.RootPart.Velocity = RootPart.Velocity; backup_group.RootPart.Acceleration = RootPart.Acceleration; backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; @@ -1846,6 +1835,11 @@ namespace OpenSim.Region.Framework.Scenes backup_group.ForEachPart(delegate(SceneObjectPart part) { + if (part.KeyframeMotion != null) + { + part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); + part.KeyframeMotion.UpdateSceneObject(this); + } part.Inventory.ProcessInventoryBackup(datastore); }); @@ -2001,9 +1995,9 @@ namespace OpenSim.Region.Framework.Scenes { if (usePhysics) { - if (KeyframeMotion != null) - KeyframeMotion.Stop(); - KeyframeMotion = null; + if (RootPart.KeyframeMotion != null) + RootPart.KeyframeMotion.Stop(); + RootPart.KeyframeMotion = null; } UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0728042be9..ea3d716157 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -315,6 +315,14 @@ namespace OpenSim.Region.Framework.Scenes private SOPVehicle m_vehicle = null; + private KeyframeMotion m_keyframeMotion = null; + + public KeyframeMotion KeyframeMotion + { + get; set; + } + + #endregion Fields // ~SceneObjectPart() @@ -1924,9 +1932,9 @@ namespace OpenSim.Region.Framework.Scenes { if (UsePhysics) { - if (ParentGroup.KeyframeMotion != null) - ParentGroup.KeyframeMotion.Stop(); - ParentGroup.KeyframeMotion = null; + if (ParentGroup.RootPart.KeyframeMotion != null) + ParentGroup.RootPart.KeyframeMotion.Stop(); + ParentGroup.RootPart.KeyframeMotion = null; ParentGroup.Scene.AddPhysicalPrim(1); PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 118a63acc5..51a3320090 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -246,9 +246,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion"); if (keymotion.Count > 0) - sceneObject.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); + sceneObject.RootPart.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); else - sceneObject.KeyframeMotion = null; + sceneObject.RootPart.KeyframeMotion = null; // Script state may, or may not, exist. Not having any, is NOT // ever a problem. @@ -1174,9 +1174,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteEndElement(); - if (sog.KeyframeMotion != null) + if (sog.RootPart.KeyframeMotion != null) { - Byte[] data = sog.KeyframeMotion.Serialize(); + Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); writer.WriteBase64(data, 0, data.Length); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e4ab14f477..e9f9c2ddb8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -11908,9 +11908,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (frames.Data.Length > 0) // We are getting a new motion { - if (group.KeyframeMotion != null) - group.KeyframeMotion.Stop(); - group.KeyframeMotion = null; + if (group.RootPart.KeyframeMotion != null) + group.RootPart.KeyframeMotion.Stop(); + group.RootPart.KeyframeMotion = null; int idx = 0; @@ -11953,7 +11953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - group.KeyframeMotion = new KeyframeMotion(group, mode, data); + group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data); idx = 0; @@ -11990,17 +11990,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api keyframes.Add(frame); } - group.KeyframeMotion.SetKeyframes(keyframes.ToArray()); - group.KeyframeMotion.Start(); + group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray()); + group.RootPart.KeyframeMotion.Start(); } else { - if (group.KeyframeMotion == null) + if (group.RootPart.KeyframeMotion == null) return; if (options.Data.Length == 0) { - group.KeyframeMotion.Stop(); + group.RootPart.KeyframeMotion.Stop(); return; } @@ -12020,13 +12020,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (cmd) { case ScriptBaseClass.KFM_CMD_PLAY: - group.KeyframeMotion.Start(); + group.RootPart.KeyframeMotion.Start(); break; case ScriptBaseClass.KFM_CMD_STOP: - group.KeyframeMotion.Stop(); + group.RootPart.KeyframeMotion.Stop(); break; case ScriptBaseClass.KFM_CMD_PAUSE: - group.KeyframeMotion.Pause(); + group.RootPart.KeyframeMotion.Pause(); break; } break;