From e5beb480eaf23fa7454728724de80b2a67ded1e8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Feb 2013 08:03:04 +0000 Subject: Partial port of Avination's support for the new physics parameters. Implements the parameters as properties, the serialization and database storage (MySQL only). Implements llSetPrimitiveParams for prim physics shape and the other 4 extra params. Only the prim shape type "None" is currently functional. No support for the Viewer UI (yet), that will be ported in due course. Lots more to port, this is a large-ish changeset. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 56 +++++++++++++++------- .../Data/MySQL/Resources/RegionStore.migrations | 13 +++++ 2 files changed, 51 insertions(+), 18 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index c95311e..2f471a0 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -52,7 +52,7 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); - protected virtual Assembly Assembly + protected Assembly Assembly { get { return GetType().Assembly; } } @@ -119,8 +119,10 @@ namespace OpenSim.Data.MySQL // Eligibility check // - if ((flags & (uint)PrimFlags.Temporary) != 0) - return; + // PrimFlags.Temporary is not used in OpenSim code and cannot + // be guaranteed to always be clear. Don't check it. +// if ((flags & (uint)PrimFlags.Temporary) != 0) +// return; if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) return; @@ -135,7 +137,7 @@ namespace OpenSim.Data.MySQL foreach (SceneObjectPart prim in obj.Parts) { cmd.Parameters.Clear(); - + cmd.CommandText = "replace into prims (" + "UUID, CreationDate, " + "Name, Text, Description, " + @@ -171,8 +173,10 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber, MediaURL, DynAttrs) " + - "values (?UUID, " + + "LinkNumber, MediaURL, " + + "PhysicsShapeType, Density, GravityModifier, " + + "Friction, Restitution, DynAttrs " + + ") values (" + "?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + @@ -203,15 +207,17 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, " + - "?MediaURL, ?DynAttrs)"; - + "?CollisionSoundVolume, ?PassTouches, " + + "?LinkNumber, ?MediaURL, " + + "?PhysicsShapeType, ?Density, ?GravityModifier, " + + "?Friction, ?Restitution, ?DynAttrs)"; + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - + ExecuteNonQuery(cmd); - + cmd.Parameters.Clear(); - + cmd.CommandText = "replace into primshapes (" + "UUID, Shape, ScaleX, ScaleY, " + "ScaleZ, PCode, PathBegin, PathEnd, " + @@ -234,9 +240,9 @@ namespace OpenSim.Data.MySQL "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + "?State, ?Media)"; - + FillShapeCommand(cmd, prim); - + ExecuteNonQuery(cmd); } } @@ -582,7 +588,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "insert into terrain (RegionUUID, " + "Revision, Heightfield) values (?RegionUUID, " + "1, ?Heightfield)"; - + cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); ExecuteNonQuery(cmd); @@ -741,7 +747,7 @@ namespace OpenSim.Data.MySQL { //No result, so store our default windlight profile and return it nWP.regionID = regionUUID; - StoreRegionWindlightSettings(nWP); +// StoreRegionWindlightSettings(nWP); return nWP; } else @@ -1097,7 +1103,8 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; + "?TerrainImageID, " + + "?TelehubObject, ?ParcelImageID)"; FillRegionSettingsCommand(cmd, rs); @@ -1300,6 +1307,12 @@ namespace OpenSim.Data.MySQL else prim.DynAttrs = new DAMap(); + prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString()); + prim.Density = (float)(double)row["Density"]; + prim.GravityModifier = (float)(double)row["GravityModifier"]; + prim.Friction = (float)(double)row["Friction"]; + prim.Bounciness = (float)(double)row["Restitution"]; + return prim; } @@ -1499,7 +1512,7 @@ namespace OpenSim.Data.MySQL for (int x = 0; x < (int)Constants.RegionSize; x++) for (int y = 0; y < (int)Constants.RegionSize; y++) { - double height = val[x, y]; + double height = 20.0; if (height == 0.0) height = double.Epsilon; @@ -1646,6 +1659,12 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType); + cmd.Parameters.AddWithValue("Density", (double)prim.Density); + cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); + cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); + cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness); + if (prim.DynAttrs.Count > 0) cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); else @@ -1728,6 +1747,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); + cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); } diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index c48aec2..48cd60b 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -910,3 +910,16 @@ BEGIN; ALTER TABLE prims ADD COLUMN DynAttrs TEXT; COMMIT; + +:VERSION 47 #---------------- Extra prim params + +BEGIN; + +ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; +ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000'; +ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1'; +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; + -- cgit v1.1