From cf9ebd301c32fa7cd991e78647ce011b0aefc796 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 14 Mar 2012 18:24:04 +0000 Subject: bug fixs, added a default physics shape estimator based on being a mesh or not and use it on unlink if new root part as type none. Viewer doesn't get updated even with fullupdates we are missing something still --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 2 + .../Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 84 ++++++++++++++++++---- .../Scenes/Serialization/SceneObjectSerializer.cs | 10 +-- 4 files changed, 82 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 23beaec..160a5d1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -7029,7 +7029,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP physdata.Bounce = phsblock.Restitution; physdata.Density = phsblock.Density; physdata.Friction = phsblock.Friction; + physdata.GravitationModifier = phsblock.GravityMultiplier; } + handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this); } return true; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6feb333..5507aa0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2723,6 +2723,10 @@ namespace OpenSim.Region.Framework.Scenes // When we delete a group, we currently have to force persist to the database if the object id has changed // (since delete works by deleting all rows which have a given object id) + // this is as it seems to be in sl now + if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) + linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now + if (m_rootPart.PhysActor != null) m_rootPart.PhysActor.Building = false; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a68b3eb..84ed40c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -986,7 +986,11 @@ namespace OpenSim.Region.Framework.Scenes public PrimitiveBaseShape Shape { get { return m_shape; } - set { m_shape = value;} + set + { + m_shape = value; + m_physicsShapeType = DefaultPhysicsShapeType(); + } } /// @@ -1377,31 +1381,68 @@ namespace OpenSim.Region.Framework.Scenes { if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) { - m_material = (Material)value; - m_friction = SOPMaterialData.friction(m_material); - m_bounce = SOPMaterialData.bounce(m_material); - if (PhysActor != null) + bool update = false; + + if (m_material != (Material)value) + { + update = true; + m_material = (Material)value; + } + + if (m_friction != SOPMaterialData.friction(m_material)) + { + update = true; + m_friction = SOPMaterialData.friction(m_material); + } + + if (m_bounce != SOPMaterialData.bounce(m_material)) { - PhysActor.SetMaterial((int)value); + update = true; + m_bounce = SOPMaterialData.bounce(m_material); + } + + if (update) + { + if (PhysActor != null) + { + PhysActor.SetMaterial((int)value); + } + if(ParentGroup != null) + ParentGroup.HasGroupChanged = true; + ScheduleFullUpdateIfNone(); } } } } + // not a propriety to move to methods place later + public byte DefaultPhysicsShapeType() + { + byte type; + + if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) + type = (byte)PhysShapeType.convex; + else + type = (byte)PhysShapeType.prim; + + return type; + } + public byte PhysicsShapeType { get { return m_physicsShapeType; } set { - if (value < 0 || value >= (byte)PhysShapeType.convex) - value = (byte)PhysShapeType.prim; //convex not supported ? - - else if (value == (byte)PhysShapeType.none) + if (value >= 0 && value <= (byte)PhysShapeType.convex) { - if (ParentGroup == null || ParentGroup.RootPart == this) - value = (byte)PhysShapeType.prim; + if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this) + m_physicsShapeType = DefaultPhysicsShapeType(); + else + m_physicsShapeType = value; + ScheduleFullUpdateIfNone(); } - m_physicsShapeType = value; + else + m_physicsShapeType = DefaultPhysicsShapeType(); } } @@ -1413,6 +1454,7 @@ namespace OpenSim.Region.Framework.Scenes if (value >=1 && value <= 22587.0) { m_density = value; + ScheduleFullUpdateIfNone(); } } } @@ -1423,6 +1465,7 @@ namespace OpenSim.Region.Framework.Scenes set { if( value >= -1 && value <=28.0f) m_gravitymod = value; + ScheduleFullUpdateIfNone(); } } @@ -1434,6 +1477,7 @@ namespace OpenSim.Region.Framework.Scenes if (value >= 0 && value <= 255.0f) { m_friction = value; + ScheduleFullUpdateIfNone(); } } } @@ -1446,6 +1490,7 @@ namespace OpenSim.Region.Framework.Scenes if (value >= 0 && value <= 1.0f) { m_bounce = value; + ScheduleFullUpdateIfNone(); } } } @@ -2942,6 +2987,19 @@ namespace OpenSim.Region.Framework.Scenes APIDTarget = Quaternion.Identity; } + + + public void ScheduleFullUpdateIfNone() + { + if (ParentGroup == null) + return; + +// ??? ParentGroup.HasGroupChanged = true; + + if (UpdateFlag != UpdateRequired.FULL) + ScheduleFullUpdate(); + } + /// /// Schedules this prim for a full update /// diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index dfa24e5..1cd8189 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -597,22 +597,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader) { - obj.Density = (byte)reader.ReadElementContentAsInt("Density", String.Empty); + obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty); } private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader) { - obj.Friction = (byte)reader.ReadElementContentAsInt("Friction", String.Empty); + obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty); } private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) { - obj.Bounciness = (byte)reader.ReadElementContentAsInt("Bounce", String.Empty); + obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty); } private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) { - obj.GravityModifier = (byte)reader.ReadElementContentAsInt("GravityModifier", String.Empty); + obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); } private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) @@ -1321,7 +1321,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (sop.sopVehicle != null) sop.sopVehicle.ToXml2(writer); - if(sop.PhysicsShapeType != (byte)PhysShapeType.prim) + if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); if (sop.Density != 1000.0f) writer.WriteElementString("Density", sop.Density.ToString().ToLower()); -- cgit v1.1 From 84ca09f7c5cec051014181853083e52691bb7e07 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 15 Mar 2012 02:24:13 +0000 Subject: added ObjectPhysicsProperties http event message to send viewer that data. For now on caps/EventQueue, and still only used on a material change... --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 +++++++ .../Linden/Caps/EventQueue/EventQueueHelper.cs | 20 ++++++++++++++++ .../Region/ClientStack/Linden/UDP/LLClientView.cs | 28 ++++++++++++++++++++++ OpenSim/Region/Framework/Interfaces/IEventQueue.cs | 2 ++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- .../Server/IRCClientView.cs | 5 ++++ .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 5 ++++ 8 files changed, 70 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 7c07c56..a91b02c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -805,5 +805,13 @@ namespace OpenSim.Region.ClientStack.Linden { return EventQueueHelper.BuildEvent(eventName, eventBody); } + + public void partPhysicsProperties(uint localID, byte physhapetype, + float density, float friction, float bounce, float gravmod,UUID avatarID) + { + OSD item = EventQueueHelper.partPhysicsProperties(localID, physhapetype, + density, friction, bounce, gravmod); + Enqueue(item, avatarID); + } } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 3f49aba..b9222e3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -395,5 +395,25 @@ namespace OpenSim.Region.ClientStack.Linden return message; } + public static OSD partPhysicsProperties(uint localID, byte physhapetype, + float density, float friction, float bounce, float gravmod) + { + + OSDMap physinfo = new OSDMap(6); + physinfo["LocalID"] = localID; + physinfo["Density"] = density; + physinfo["Friction"] = friction; + physinfo["GravityMultiplier"] = gravmod; + physinfo["Restitution"] = bounce; + physinfo["PhysicsShapeType"] = (int)physhapetype; + + OSDArray array = new OSDArray(1); + array.Add(physinfo); + + OSDMap llsdBody = new OSDMap(1); + llsdBody.Add("ObjectData", array); + + return BuildEvent("ObjectPhysicsProperties", llsdBody); + } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 160a5d1..dd3b8aa 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -2609,6 +2609,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + public void SendPartPhysicsProprieties(ISceneEntity entity) + { + SceneObjectPart part = (SceneObjectPart)entity; + if (part != null && AgentId != UUID.Zero) + { + try + { + IEventQueue eq = Scene.RequestModuleInterface(); + if (eq != null) + { + uint localid = part.LocalId; + byte physshapetype = part.PhysicsShapeType; + float density = part.Density; + float friction = part.Friction; + float bounce = part.Bounciness; + float gravmod = part.GravityModifier; + + eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId); + } + } + catch (Exception ex) + { + m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString()); + } + } + } + + public void SendGroupNameReply(UUID groupLLUID, string GroupName) { diff --git a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs index bfa5d17..5512642 100644 --- a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs +++ b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs @@ -59,5 +59,7 @@ namespace OpenSim.Region.Framework.Interfaces void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID); OSD ScriptRunningEvent(UUID objectID, UUID itemID, bool running, bool mono); OSD BuildEvent(string eventName, OSD eventBody); + void partPhysicsProperties(uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID); + } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 7b77ea0..4e9a8f8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1695,6 +1695,7 @@ namespace OpenSim.Region.Framework.Scenes { part.Material = Convert.ToByte(material); group.HasGroupChanged = true; + remoteClient.SendPartPhysicsProprieties(part); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 84ed40c..f188e8d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4730,7 +4730,7 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.HasGroupChanged = true; ScheduleFullUpdate(); } - + // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 18f8f34..1e87eed 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1703,5 +1703,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) { } + + public void SendPartPhysicsProprieties(ISceneEntity entity) + { + } + } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 5b9b071..7bd5590 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1195,5 +1195,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) { } + + public void SendPartPhysicsProprieties(ISceneEntity entity) + { + } + } } -- cgit v1.1 From 15ad5f492b8150ff81d969a389e32edb35227b19 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 15 Mar 2012 10:25:18 +0000 Subject: Playing with object costs CAPS ... --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 120 ++++++++++++++++++++- 1 file changed, 118 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index df65af9..5542680 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -97,7 +97,9 @@ namespace OpenSim.Region.ClientStack.Linden private static readonly string m_copyFromNotecardPath = "0007/"; // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. private static readonly string m_getObjectPhysicsDataPath = "0101/"; - + private static readonly string m_getObjectCostPath = "0102/"; + private static readonly string m_ResourceCostSelectedPath = "0103/"; + // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls @@ -185,7 +187,12 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", new RestStreamHandler("POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard)); IRequestHandler getObjectPhysicsDataHandler = new RestStreamHandler("POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData); m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); - + IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); + m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); + IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); + m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); + + // As of RC 1.22.9 of the Linden client this is // supported @@ -834,6 +841,115 @@ namespace OpenSim.Region.ClientStack.Linden Console.WriteLine(response); return response; } + + public string GetObjectCost(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + // see being triggered but see no efect .. have something wrong ?? + // + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + OSDArray object_ids = (OSDArray)req["object_ids"]; + + for (int i = 0; i < object_ids.Count; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + // only see root parts .. so guess should go by SOG only + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + OSDMap object_data = new OSDMap(); + + object_data["linked_set_resource_cost"] = 1.0f; + object_data["resource_cost"] = 1.0f; + object_data["physics_cost"] = 1.0f; + object_data["linked_set_physics_cost"] = 1.0f; + + resp[uuid.ToString()] = object_data; + } + } + + string response = OSDParser.SerializeLLSDXmlString(resp); + Console.WriteLine(response); + return response; + } + + public string ResourceCostSelected(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + + float phys=0; + float stream=0; + float simul=0; + + if (req.ContainsKey("selected_roots")) + { + OSDArray object_ids = (OSDArray)req["selected_roots"]; + + // should go by SOG suming costs for all parts + // ll v3 works ok with several objects select we get the list and adds ok + // FS calls per object so results are wrong guess fs bug + for (int i = 0; i < object_ids.Count; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + phys += 0.1f; // just to see... + stream += 0.2f; + simul += 0.5f; + } + } + } + else if (req.ContainsKey("selected_prims")) + { + OSDArray object_ids = (OSDArray)req["selected_prims"]; + + // don't see in use in any of the 2 viewers + // guess it should be for edit linked but... nothing + // should go to SOP per part + for (int i = 0; i < object_ids.Count; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + phys += 0.1f; + stream += 0.2f; + simul += 0.5f; + } + } + } + + if (simul != 0) + { + OSDMap object_data = new OSDMap(); + + object_data["physics"] = phys; + object_data["streaming"] = stream; + object_data["simulation"] = simul; + + resp["selected"] = object_data; + } + + string response = OSDParser.SerializeLLSDXmlString(resp); + Console.WriteLine(response); + return response; + } + + + + + } public class AssetUploader -- cgit v1.1