diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations index c6f4b48e18..bff039d75d 100644 --- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations +++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations @@ -592,3 +592,11 @@ ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6'; ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; COMMIT; + +:VERSION 29 #---------------- Keyframes + +BEGIN; + +ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; + +COMMIT; diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 99a6598bd2..c8e48fd882 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -732,6 +732,8 @@ namespace OpenSim.Data.SQLite } SceneObjectGroup group = new SceneObjectGroup(prim); + if (prim.KeyframeMotion != null) + prim.KeyframeMotion.UpdateSceneObject(group); createdObjects.Add(group.UUID, group); retvals.Add(group); LoadItems(prim); @@ -1241,6 +1243,7 @@ namespace OpenSim.Data.SQLite createCol(prims, "Friction", typeof(Double)); createCol(prims, "Restitution", typeof(Double)); + createCol(prims, "KeyframeMotion", typeof(Byte[])); // Add in contraints prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; @@ -1736,6 +1739,20 @@ namespace OpenSim.Data.SQLite prim.Friction = Convert.ToSingle(row["Friction"]); prim.Restitution = Convert.ToSingle(row["Restitution"]); + + 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; } @@ -2168,6 +2185,13 @@ namespace OpenSim.Data.SQLite row["GravityModifier"] = (double)prim.GravityModifier; row["Friction"] = (double)prim.Friction; row["Restitution"] = (double)prim.Restitution; + + if (prim.KeyframeMotion != null) + row["KeyframeMotion"] = prim.KeyframeMotion.Serialize(); + else + row["KeyframeMotion"] = new Byte[0]; + + } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8c6450d512..f13f7abde3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -822,7 +822,8 @@ namespace OpenSim.Region.Framework.Scenes } // Tell the physics engines that this prim changed. - ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); + if (ParentGroup != null && ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) + ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } catch (Exception e) { @@ -940,7 +941,7 @@ namespace OpenSim.Region.Framework.Scenes //m_log.Info("[PART]: RO2:" + actor.Orientation.ToString()); } - if (ParentGroup != null) + if (ParentGroup != null && ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); //} } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c315d03d1d..97445269ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5136,6 +5136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { double invS = 1.0 / s; + if (rot.s < 0) invS = -invS; return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS); } } @@ -5146,19 +5147,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (rot.s > 1) // normalization needed - { - double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y + - rot.z * rot.z + rot.s * rot.s); - - rot.x /= length; - rot.y /= length; - rot.z /= length; - rot.s /= length; - } + if (Math.Abs(rot.s) > 1) // normalization needed + rot.Normalize(); double angle = 2 * Math.Acos(rot.s); - if ((double.IsNaN(angle)) || double.IsInfinity(angle)) angle = 0; + if (angle > Math.PI) + angle = 2 * Math.PI - angle; + return angle; } diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index c685afbe31..4ba0e64328 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -377,10 +377,10 @@ namespace OpenSim.Region.ScriptEngine.Shared double length = Math.Sqrt(x * x + y * y + z * z + s * s); if (length < float.Epsilon) { - x = 1; + x = 0; y = 0; z = 0; - s = 0; + s = 1; } else {