From cf16ca9bdaad75d42213089e18c0ee8f8422bbd6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Aug 2012 22:36:24 +0100 Subject: Create the ability for physics modules to request assets on demand by themselves. For that, the physics module simply calls RequestAssetMethod, which in turn points to Scene.PhysicsRequestAsset. This gives physics access to the asset system without introducing unwanted knowledge of the scene class. --- OpenSim/Region/Application/OpenSimBase.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.cs | 16 ++++++++++++++++ OpenSim/Region/Physics/Manager/PhysicsScene.cs | 5 +++++ 3 files changed, 22 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 4084741..37cfe1d 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -700,6 +700,7 @@ namespace OpenSim scene.LoadWorldMap(); scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName); + scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset; scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eb4ba41..c77457c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5421,5 +5421,21 @@ namespace OpenSim.Region.Framework.Scenes m_SpawnPoint = 1; return m_SpawnPoint - 1; } + + // Wrappers to get physics modules retrieve assets. Has to be done this way + // because we can't assign the asset service to physics directly - at the + // time physics are instantiated it's not registered but it will be by + // the time the first prim exists. + public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback) + { + AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived); + } + + private void PhysicsAssetReceived(string id, Object sender, AssetBase asset) + { + AssetReceivedDelegate callback = (AssetReceivedDelegate)sender; + + callback(asset); + } } } diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index b32cd30..6a0558a 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -43,6 +43,9 @@ namespace OpenSim.Region.Physics.Manager public delegate void JointDeactivated(PhysicsJoint joint); public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation" + public delegate void RequestAssetDelegate(UUID assetID, AssetReceivedDelegate callback); + public delegate void AssetReceivedDelegate(AssetBase asset); + /// /// Contact result from a raycast. /// @@ -73,6 +76,8 @@ namespace OpenSim.Region.Physics.Manager get { return new NullPhysicsScene(); } } + public RequestAssetDelegate RequestAssetMethod { private get; set; } + public virtual void TriggerPhysicsBasedRestart() { physicsCrash handler = OnPhysicsCrash; -- cgit v1.1 From cd2c5843a86af5b6b49b6675e90b702b479fd258 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Thu, 2 Aug 2012 11:19:33 +0100 Subject: reduced-complexity implementation of function to get rezzing object key Signed-off-by: Melanie --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 ++- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++++ OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 8 ++++++++ OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 6 ++++++ OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 5 files changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index d18fffd..a2016da 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2131,7 +2131,8 @@ namespace OpenSim.Region.Framework.Scenes if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) sourcePart.Inventory.RemoveInventoryItem(item.ItemID); } - + + group.RezzingObjectID = sourcePart.UUID; AddNewSceneObject(group, true, pos, rot, vel); // We can only call this after adding the scene object, since the scene object references the scene diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 52469a2..c9345e5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -611,6 +611,14 @@ namespace OpenSim.Region.Framework.Scenes public UUID FromItemID { get; set; } /// + /// Refers to the SceneObjectPart.UUID property of the object that this object was rezzed from, if applicable. + /// + /// + /// If not applicable will be UUID.Zero + /// + public UUID RezzingObjectID { get; set; } + + /// /// The folder ID that this object was rezzed from, if applicable. /// /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 44de176..e5a4fe8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3314,5 +3314,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return Math.Max(a, b); } + + public LSL_Key osGetRezzingObject() + { + CheckThreatLevel(ThreatLevel.None, "osGetRezzingObject"); + m_host.AddScriptLPS(1); + + return new LSL_Key(m_host.ParentGroup.RezzingObjectID.ToString()); + } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index f73a85e..1f000a3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -299,5 +299,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// /// LSL_Float osMax(double a, double b); + + /// + /// Get the key of the object that rezzed this object. + /// + /// Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown. + LSL_Key osGetRezzingObject(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 53daa13..94405d2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -945,5 +945,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osMax(a, b); } + + public LSL_Key osGetRezzingObject() + { + return m_OSSL_Functions.osGetRezzingObject(); + } } } -- cgit v1.1 From 68406ab8f9fad40636a9e3576e80c1086b1f48f2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Aug 2012 22:34:46 +0100 Subject: Initialize the Rezzing object to UUID.Zero --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c9345e5..13cc5cd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -26,6 +26,7 @@ */ using System; +using System.ComponentModel; using System.Collections.Generic; using System.Drawing; using System.IO; @@ -641,6 +642,7 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup() { + RezzingObjectID = UUID.Zero; } /// @@ -648,7 +650,7 @@ namespace OpenSim.Region.Framework.Scenes /// The original SceneObjectPart will be used rather than a copy, preserving /// its existing localID and UUID. /// - public SceneObjectGroup(SceneObjectPart part) + public SceneObjectGroup(SceneObjectPart part) : this() { SetRootPart(part); } @@ -656,9 +658,8 @@ namespace OpenSim.Region.Framework.Scenes /// /// Constructor. This object is added to the scene later via AttachToScene() /// - public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) + public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) :this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)) { - SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); } /// -- cgit v1.1