Move KeyframeMotion from SOG to SOP because we can't persist it any

other way because SOG doesn't technically exist in the DB
avinationmerge
Melanie 2012-02-26 18:11:38 +01:00
parent 356603fff9
commit fca8c82232
8 changed files with 75 additions and 41 deletions

View File

@ -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]);
}
/// <summary>

View File

@ -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)

View File

@ -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))
{

View File

@ -1731,6 +1731,12 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="childPrims"></param>
protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> 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

View File

@ -114,12 +114,6 @@ namespace OpenSim.Region.Framework.Scenes
private Random m_rand;
private bool m_suspendUpdates;
private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>();
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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;