From 042c9ed4d82e4389ec929f5438e82defad251235 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 25 May 2008 11:22:05 +0000 Subject: [PATCH] * Adds Top Colliders when using ODE. Access it from the estate tools/debug tab. --- OpenSim/Framework/IClientAPI.cs | 6 ++ OpenSim/Framework/LandStatReportItem.cs | 54 ++++++++++++++++++ .../ClientStack/LindenUDP/LLClientView.cs | 56 +++++++++++++++++++ .../World/Estate/EstateManagementModule.cs | 39 +++++++++++++ .../Modules/World/NPC/NPCAvatar.cs | 6 +- .../Examples/SimpleModule/MyNpcCharacter.cs | 7 +++ .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 6 ++ .../Physics/BulletXPlugin/BulletXPlugin.cs | 7 +++ .../Region/Physics/Manager/PhysicsActor.cs | 5 +- .../Region/Physics/Manager/PhysicsScene.cs | 9 +++ .../Region/Physics/OdePlugin/ODECharacter.cs | 1 + OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 5 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 30 ++++++++++ OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 8 +++ .../Region/Physics/PhysXPlugin/PhysXPlugin.cs | 8 +++ 15 files changed, 243 insertions(+), 4 deletions(-) create mode 100644 OpenSim/Framework/LandStatReportItem.cs diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f260245239..0823b0d3bc 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -610,6 +610,8 @@ namespace OpenSim.Framework public delegate void ForceReleaseControls(IClientAPI remoteClient, LLUUID agentID); + public delegate void GodLandStatRequest(int parcelID, uint reportType, uint requestflags, string filter, IClientAPI remoteClient); + //Estate Requests public delegate void DetailedEstateDataRequest(IClientAPI remoteClient, LLUUID invoice); public delegate void SetEstateFlagsRequest(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor, int matureLevel, bool restrictPushObject, bool allowParcelChanges); @@ -626,6 +628,7 @@ namespace OpenSim.Framework public delegate void EstateDebugRegionRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, bool scripted, bool collisionEvents, bool physics); public delegate void EstateTeleportOneUserHomeRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, LLUUID prey); + public interface IClientAPI { LLVector3 StartPos { get; set; } @@ -801,6 +804,7 @@ namespace OpenSim.Framework event AgentSit OnUndo; event ForceReleaseControls OnForceReleaseControls; + event GodLandStatRequest OnLandStatRequest; event DetailedEstateDataRequest OnDetailedEstateDataRequest; event SetEstateFlagsRequest OnSetEstateFlagsRequest; @@ -989,6 +993,8 @@ namespace OpenSim.Framework void SendGroupNameReply(LLUUID groupLLUID, string GroupName); + void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia); + byte[] GetThrottlesPacked(float multiplier); diff --git a/OpenSim/Framework/LandStatReportItem.cs b/OpenSim/Framework/LandStatReportItem.cs new file mode 100644 index 0000000000..3a92253fc7 --- /dev/null +++ b/OpenSim/Framework/LandStatReportItem.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + + +namespace OpenSim.Framework +{ + public class LandStatReportItem + { + public float LocationX; + public float LocationY; + public float LocationZ; + public string OwnerName; + public float Score; + public LLUUID TaskID; + public uint TaskLocalID; + public string TaskName; + + public LandStatReportItem() + { + + } + + } +} diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 9bef65fc01..484518aee8 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -250,6 +250,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private ForceReleaseControls handlerForceReleaseControls = null; + private GodLandStatRequest handlerLandStatRequest = null; + private UUIDNameRequest handlerUUIDGroupNameRequest = null; private RequestObjectPropertiesFamily handlerObjectGroupRequest = null; @@ -842,6 +844,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event ForceReleaseControls OnForceReleaseControls; + public event GodLandStatRequest OnLandStatRequest; + public event RequestObjectPropertiesFamily OnObjectGroupRequest; public event DetailedEstateDataRequest OnDetailedEstateDataRequest; @@ -5641,11 +5645,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP OnEstateTeleportOneUserHomeRequest(this,invoice,SenderID,Prey); } break; + case "colliders": + handlerLandStatRequest = OnLandStatRequest; + if (handlerLandStatRequest != null) + { + handlerLandStatRequest(0, 1, 0, "", this); + } + break; default: m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString()); break; } break; + case PacketType.LandStatRequest: + LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack; + + handlerLandStatRequest = OnLandStatRequest; + if (handlerLandStatRequest != null) + { + handlerLandStatRequest(lsrp.RequestData.ParcelLocalID,lsrp.RequestData.ReportType,lsrp.RequestData.RequestFlags,Helpers.FieldToUTF8String(lsrp.RequestData.Filter),this); + } + //int parcelID, uint reportType, uint requestflags, string filter + + //lsrp.RequestData.ParcelLocalID; + //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts + //lsrp.RequestData.RequestFlags; + //lsrp.RequestData.Filter; + + break; + case PacketType.RequestRegionInfo: RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; @@ -5982,6 +6010,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP pack.UUIDNameBlock = uidnameblock; OutPacket(pack, ThrottleOutPacketType.Task); } + + public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) + { + LandStatReplyPacket lsrp = new LandStatReplyPacket(); + LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock(); + LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length]; + //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); + // lsrepdb. + lsrp.RequestData.ReportType = reportType; + lsrp.RequestData.RequestFlags = requestFlags; + lsrp.RequestData.TotalObjectCount = resultCount; + for (int i = 0; i < lsrpia.Length; i++) + { + LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); + lsrepdb.LocationX = lsrpia[i].LocationX; + lsrepdb.LocationY = lsrpia[i].LocationY; + lsrepdb.LocationZ = lsrpia[i].LocationZ; + lsrepdb.Score = lsrpia[i].Score; + lsrepdb.TaskID = lsrpia[i].TaskID; + lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID; + lsrepdb.TaskName = Helpers.StringToField(lsrpia[i].TaskName); + lsrepdb.OwnerName = Helpers.StringToField(lsrpia[i].OwnerName); + lsrepdba[i] = lsrepdb; + } + lsrp.ReportData = lsrepdba; + OutPacket(lsrp, ThrottleOutPacketType.Task); + } + public ClientInfo GetClientInfo() { //MainLog.Instance.Verbose("CLIENT", "GetClientInfo BGN"); diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index fcdec5dbc2..d3aa4aaeb5 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs @@ -311,6 +311,44 @@ namespace OpenSim.Region.Environment.Modules.World.Estate { remote_client.sendEstateCovenantInformation(); } + private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient) + { + Dictionary colliders = m_scene.PhysicsScene.GetTopColliders(); + + List collidera = new List(); + lock (colliders) + { + foreach (uint obj in colliders.Keys) + { + SceneObjectPart prt = m_scene.GetSceneObjectPart(obj); + if (prt != null) + { + if (prt.ParentGroup != null) + { + SceneObjectGroup sog = prt.ParentGroup; + if (sog != null) + { + LandStatReportItem lsri = new LandStatReportItem(); + lsri.LocationX = sog.AbsolutePosition.X; + lsri.LocationY = sog.AbsolutePosition.Y; + lsri.LocationZ = sog.AbsolutePosition.Z; + lsri.Score = colliders[obj]; + lsri.TaskID = sog.UUID; + lsri.TaskLocalID = sog.LocalId; + lsri.TaskName = sog.GetPartName(obj); + lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID); + + + collidera.Add(lsri); + } + } + } + + } + } + remoteClient.SendLandStatReply(reportType, requestFlags, (uint)collidera.Count,collidera.ToArray()); + + } #endregion @@ -435,6 +473,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate client.OnRegionInfoRequest += HandleRegionInfoRequest; client.OnEstateCovenantRequest += HandleEstateCovenantRequest; + client.OnLandStatRequest += HandleLandStatRequest; sendRegionHandshake(client); } } diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index cd5ca61dfc..09069a9059 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -271,7 +271,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public event AgentSit OnUndo; public event ForceReleaseControls OnForceReleaseControls; - + public event GodLandStatRequest OnLandStatRequest; public event RequestObjectPropertiesFamily OnObjectGroupRequest; public event DetailedEstateDataRequest OnDetailedEstateDataRequest; @@ -764,6 +764,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public void SendGroupNameReply(LLUUID groupLLUID, string GroupName) { } + + public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) + { + } #endregion } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 032579e5b8..0410e1c898 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -175,6 +175,8 @@ namespace OpenSim.Region.Examples.SimpleModule public event AgentSit OnUndo; public event ForceReleaseControls OnForceReleaseControls; + + public event GodLandStatRequest OnLandStatRequest; public event RequestObjectPropertiesFamily OnObjectGroupRequest; public event DetailedEstateDataRequest OnDetailedEstateDataRequest; @@ -761,5 +763,10 @@ namespace OpenSim.Region.Examples.SimpleModule public void SendGroupNameReply(LLUUID groupLLUID, string GroupName) { } + + public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) + { + + } } } diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index d7c4013651..ee30e54e4b 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -198,6 +198,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override void DeleteTerrain() { } + public override Dictionary GetTopColliders() + { + Dictionary returncolliders = new Dictionary(); + return returncolliders; + } } public class BasicActor : PhysicsActor @@ -348,6 +353,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override float CollisionScore { get { return 0f; } + set { } } public override Quaternion Orientation diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index fcff04e1ec..1fa759cf72 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -549,6 +549,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin } + public override Dictionary GetTopColliders() + { + Dictionary returncolliders = new Dictionary(); + return returncolliders; + } + public override void SetWaterLevel(float baseheight) { @@ -917,6 +923,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override float CollisionScore { get { return 0f; } + set { } } public override PhysicsVector Size { diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 3cf264679f..c87e748905 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -176,7 +176,7 @@ namespace OpenSim.Region.Physics.Manager public abstract PhysicsVector GeometricCenter { get; } public abstract PhysicsVector CenterOfMass { get; } public abstract PhysicsVector Velocity { get; set; } - public abstract float CollisionScore { get;} + public abstract float CollisionScore { get; set;} public abstract PhysicsVector Acceleration { get; } public abstract Quaternion Orientation { get; set; } public abstract int PhysicsActorType { get; set; } @@ -208,8 +208,10 @@ namespace OpenSim.Region.Physics.Manager public override bool Stopped { get{ return false; } + } + public override PhysicsVector Position { get { return PhysicsVector.Zero; } @@ -300,6 +302,7 @@ namespace OpenSim.Region.Physics.Manager public override float CollisionScore { get { return 0f; } + set { } } public override void CrossingFailure() diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index de93f22184..f9d990bc5b 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; using System.Reflection; using Axiom.Math; using log4net; @@ -86,6 +87,8 @@ namespace OpenSim.Region.Physics.Manager public abstract void Dispose(); + public abstract Dictionary GetTopColliders(); + public abstract bool IsThreaded { get; } private class NullPhysicsScene : PhysicsScene @@ -170,6 +173,12 @@ namespace OpenSim.Region.Physics.Manager public override void Dispose() { } + + public override Dictionary GetTopColliders() + { + Dictionary returncolliders = new Dictionary(); + return returncolliders; + } } } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 5024b5ddc3..89162a08f0 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -570,6 +570,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override float CollisionScore { get { return 0f; } + set { } } public override bool Kinematic diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 4c8eb20fd9..6ade6388b6 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -124,7 +124,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_throttleUpdates = false; private int throttleCounter = 0; public int m_interpenetrationcount = 0; - public int m_collisionscore = 0; + public float m_collisionscore = 0; public int m_roundsUnderMotionThreshold = 0; private int m_crossingfailures = 0; @@ -243,7 +243,7 @@ namespace OpenSim.Region.Physics.OdePlugin // is physical or the object is modified somehow *IN THE FUTURE* // without this, if an avatar selects prim, they can walk right // through it while it's selected - + m_collisionscore = 0; if ((m_isphysical && !_zeroFlag) || !value) { m_taintselected = value; @@ -1783,6 +1783,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override float CollisionScore { get { return m_collisionscore; } + set { m_collisionscore = value; } } public override bool Kinematic diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index fef0c4e31a..e43a1ac298 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -555,6 +555,13 @@ namespace OpenSim.Region.Physics.OdePlugin } float max_collision_depth = 0f; + if (p1.CollisionScore + count >= float.MaxValue) + p1.CollisionScore = 0; + p1.CollisionScore += count; + + if (p2.CollisionScore + count >= float.MaxValue) + p2.CollisionScore = 0; + p2.CollisionScore += count; for (int i = 0; i < count; i++) { @@ -585,6 +592,7 @@ namespace OpenSim.Region.Physics.OdePlugin p2.CollidingGround = true; break; } + // we don't want prim or avatar to explode @@ -2162,5 +2170,27 @@ namespace OpenSim.Region.Physics.OdePlugin //d.CloseODE(); } } + public override Dictionary GetTopColliders() + { + Dictionary returncolliders = new Dictionary(); + int cnt = 0; + lock (_prims) + { + foreach (OdePrim prm in _prims) + { + if (prm.CollisionScore > 0) + { + returncolliders.Add(prm.m_localID, prm.CollisionScore); + cnt++; + prm.CollisionScore = 0f; + if (cnt > 25) + { + break; + } + } + } + } + return returncolliders; + } } } diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 82ce144e62..c14a80a999 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -326,6 +326,12 @@ namespace OpenSim.Region.Physics.POSPlugin public override void DeleteTerrain() { } + + public override Dictionary GetTopColliders() + { + Dictionary returncolliders = new Dictionary(); + return returncolliders; + } } public class POSCharacter : PhysicsActor @@ -476,6 +482,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override float CollisionScore { get { return 0f; } + set { } } public override Quaternion Orientation @@ -663,6 +670,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override float CollisionScore { get { return 0f; } + set { } } public override Quaternion Orientation diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 175d749a85..c9e1e3038f 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -200,6 +200,12 @@ namespace OpenSim.Region.Physics.PhysXPlugin { scene.DeleteTerrain(); } + + public override Dictionary GetTopColliders() + { + Dictionary returncolliders = new Dictionary(); + return returncolliders; + } } public class PhysXCharacter : PhysicsActor @@ -355,6 +361,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin public override float CollisionScore { get { return 0f; } + set { } } public override bool Kinematic @@ -593,6 +600,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin public override float CollisionScore { get { return 0f; } + set { } } public override bool Kinematic