Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
	OpenSim/Region/CoreModules/World/Land/LandObject.cs
	OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
	OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
	OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
This commit is contained in:
Melanie
2012-04-07 04:52:14 +01:00
27 changed files with 963 additions and 376 deletions

View File

@@ -506,6 +506,12 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void PrimsLoaded(Scene s);
public event PrimsLoaded OnPrimsLoaded;
public delegate void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout);
public event TeleportStart OnTeleportStart;
public delegate void TeleportFail(IClientAPI client, bool gridLogout);
public event TeleportFail OnTeleportFail;
public class MoneyTransferArgs : EventArgs
{
public UUID sender;
@@ -2487,5 +2493,48 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
public void TriggerTeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout)
{
TeleportStart handler = OnTeleportStart;
if (handler != null)
{
foreach (TeleportStart d in handler.GetInvocationList())
{
try
{
d(client, destination, finalDestination, teleportFlags, gridLogout);
}
catch (Exception e)
{
m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TeleportStart failed - continuing {0} - {1}",
e.Message, e.StackTrace);
}
}
}
}
public void TriggerTeleportFail(IClientAPI client, bool gridLogout)
{
TeleportFail handler = OnTeleportFail;
if (handler != null)
{
foreach (TeleportFail d in handler.GetInvocationList())
{
try
{
d(client, gridLogout);
}
catch (Exception e)
{
m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TeleportFail failed - continuing {0} - {1}",
e.Message, e.StackTrace);
}
}
}
}
}
}

View File

@@ -36,6 +36,7 @@ using OpenMetaverse.Packets;
using log4net;
using OpenSim.Framework;
using OpenSim.Region.Framework;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Serialization;
@@ -117,20 +118,43 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="item"></param>
public bool AddInventoryItem(InventoryItemBase item)
{
InventoryFolderBase folder;
if (item.Folder == UUID.Zero)
if (item.Folder != UUID.Zero && InventoryService.AddItem(item))
{
folder = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType);
if (folder == null)
int userlevel = 0;
if (Permissions.IsGod(item.Owner))
{
folder = InventoryService.GetRootFolder(item.Owner);
if (folder == null)
return false;
userlevel = 1;
}
EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel);
item.Folder = folder.ID;
return true;
}
// OK so either the viewer didn't send a folderID or AddItem failed
UUID originalFolder = item.Folder;
InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType);
if (f != null)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Found folder {0} type {1} for item {2}",
f.Name, (AssetType)f.Type, item.Name);
item.Folder = f.ID;
}
else
{
f = InventoryService.GetRootFolder(item.Owner);
if (f != null)
{
item.Folder = f.ID;
}
else
{
m_log.WarnFormat(
"[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified",
item.Owner, item.Name);
return false;
}
}
if (InventoryService.AddItem(item))
@@ -141,7 +165,13 @@ namespace OpenSim.Region.Framework.Scenes
userlevel = 1;
}
EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel);
if (originalFolder != UUID.Zero)
{
// Tell the viewer that the item didn't go there
ChangePlacement(item, f);
}
return true;
}
else
@@ -153,7 +183,32 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
}
private void ChangePlacement(InventoryItemBase item, InventoryFolderBase f)
{
ScenePresence sp = GetScenePresence(item.Owner);
if (sp != null)
{
if (sp.ControllingClient is IClientCore)
{
IClientCore core = (IClientCore)sp.ControllingClient;
IClientInventory inv;
if (core.TryGet<IClientInventory>(out inv))
{
InventoryFolderBase parent = new InventoryFolderBase(f.ParentID, f.Owner);
parent = InventoryService.GetFolder(parent);
inv.SendRemoveInventoryItems(new UUID[] { item.ID });
inv.SendBulkUpdateInventory(new InventoryFolderBase[0], new InventoryItemBase[] { item });
string message = "The item was placed in folder " + f.Name;
if (parent != null)
message += " under " + parent.Name;
sp.ControllingClient.SendAgentAlertMessage(message, false);
}
}
}
}
/// <summary>
/// Add the given inventory item to a user's inventory.
/// </summary>
@@ -2085,7 +2140,7 @@ namespace OpenSim.Region.Framework.Scenes
item.CreationDate = Util.UnixTimeSinceEpoch();
// sets itemID so client can show item as 'attached' in inventory
grp.SetFromItemID(item.ID);
grp.FromItemID = item.ID;
if (AddInventoryItem(item))
remoteClient.SendInventoryItemCreateUpdate(item, 0);

View File

@@ -2248,12 +2248,6 @@ namespace OpenSim.Region.Framework.Scenes
part.RemoveFromPhysics();
}
}
// if (rootPart.PhysActor != null)
// {
// PhysicsScene.RemovePrim(rootPart.PhysActor);
// rootPart.PhysActor = null;
// }
if (UnlinkSceneObject(group, false))
{
@@ -2668,7 +2662,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup grp = sceneObject;
m_log.DebugFormat(
"[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.GetFromItemID(), grp.UUID);
"[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
m_log.DebugFormat(
"[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);

View File

@@ -775,7 +775,9 @@ namespace OpenSim.Region.Framework.Scenes
set { m_LoopSoundSlavePrims = value; }
}
// The UUID for the Region this Object is in.
/// <summary>
/// The UUID for the region this object is in.
/// </summary>
public UUID RegionUUID
{
get
@@ -788,6 +790,22 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// The item ID that this object was rezzed from, if applicable.
/// </summary>
/// <remarks>
/// If not applicable will be UUID.Zero
/// </remarks>
public UUID FromItemID { get; set; }
/// <summary>
/// The folder ID that this object was rezzed from, if applicable.
/// </summary>
/// <remarks>
/// If not applicable will be UUID.Zero
/// </remarks>
public UUID FromFolderID { get; set; }
#endregion
// ~SceneObjectGroup()
@@ -851,18 +869,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void SetFromItemID(UUID AssetId)
{
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].FromItemID = AssetId;
}
public UUID GetFromItemID()
{
return m_rootPart.FromItemID;
}
/// <summary>
/// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes.
/// </summary>
@@ -1498,7 +1504,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
detachedpos = avatar.AbsolutePosition;
RootPart.FromItemID = UUID.Zero;
FromItemID = UUID.Zero;
AbsolutePosition = detachedpos;
AttachedAvatar = UUID.Zero;
@@ -3379,6 +3385,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_rootPart.AttachedPos = pos;
}
if (RootPart.GetStatusSandbox())
{
if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10)
@@ -3389,8 +3396,8 @@ namespace OpenSim.Region.Framework.Scenes
ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
}
}
AbsolutePosition = pos;
AbsolutePosition = pos;
HasGroupChanged = true;
}
@@ -4032,7 +4039,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual string ExtraToXmlString()
{
return "<ExtraFromItemID>" + GetFromItemID().ToString() + "</ExtraFromItemID>";
return "<ExtraFromItemID>" + FromItemID.ToString() + "</ExtraFromItemID>";
}
public virtual void ExtraFromXmlString(string xmlstr)
@@ -4044,7 +4051,7 @@ namespace OpenSim.Region.Framework.Scenes
UUID uuid = UUID.Zero;
UUID.TryParse(id, out uuid);
SetFromItemID(uuid);
FromItemID = uuid;
}
public void ResetOwnerChangeFlag()

View File

@@ -126,12 +126,14 @@ namespace OpenSim.Region.Framework.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <value>
/// Is this sop a root part?
/// Is this a root part?
/// </value>
/// <remarks>
/// This will return true even if the whole object is attached to an avatar.
/// </remarks>
public bool IsRoot
{
get { return ParentGroup.RootPart == this; }
get { return ParentGroup.RootPart == this; }
}
#region Fields
@@ -160,15 +162,7 @@ namespace OpenSim.Region.Framework.Scenes
/// If another thread is simultaneously turning physics off on this part then this refernece could become
/// null at any time.
/// </remarks>
public PhysicsActor PhysActor
{
get { return m_physActor; }
set
{
// m_log.DebugFormat("[SOP]: PhysActor set to {0} for {1} {2}", value, Name, UUID);
m_physActor = value;
}
}
public PhysicsActor PhysActor { get; set; }
//Xantor 20080528 Sound stuff:
// Note: This isn't persisted in the database right now, as the fields for that aren't just there yet.
@@ -188,10 +182,6 @@ namespace OpenSim.Region.Framework.Scenes
public uint TimeStampLastActivity; // Will be used for AutoReturn
public uint TimeStampTerse;
public UUID FromItemID;
public UUID FromFolderID;
// The following two are to hold the attachment data
// while an object is inworld
@@ -275,7 +265,6 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_passTouches;
private PhysicsActor m_physActor;
protected Vector3 m_acceleration;
protected Vector3 m_angularVelocity;
@@ -1149,6 +1138,14 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// The parent ID of this part.
/// </summary>
/// <remarks>
/// If this is a root part which is not attached to an avatar then the value will be 0.
/// If this is a root part which is attached to an avatar then the value is the local id of that avatar.
/// If this is a child part then the value is the local ID of the root part.
/// </remarks>
public uint ParentID
{
get { return _parentID; }
@@ -1847,9 +1844,6 @@ namespace OpenSim.Region.Framework.Scenes
// if (VolumeDetectActive)
// isPhantom = false;
// Added clarification.. since A rigid body is an object that you can kick around, etc.
// bool RigidBody = isPhysical && !isPhantom;
// The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition
// or flexible
// if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
@@ -1876,7 +1870,6 @@ namespace OpenSim.Region.Framework.Scenes
PhysActor = null;
}
// Basic Physics can also return null as well as an exception catch.
PhysicsActor pa = PhysActor;
if (pa != null)
@@ -4859,7 +4852,52 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
/// This removes the part from physics
/// Adds this part to the physics scene.
/// </summary>
/// <remarks>This method also sets the PhysActor property.</remarks>
/// <param name="rigidBody">Add this prim with a rigid body.</param>
/// <returns>
/// The physics actor. null if there was a failure.
/// </returns>
private PhysicsActor AddToPhysics(bool rigidBody)
{
PhysicsActor pa;
try
{
pa = ParentGroup.Scene.PhysicsScene.AddPrimShape(
string.Format("{0}/{1}", Name, UUID),
Shape,
AbsolutePosition,
Scale,
RotationOffset,
rigidBody,
m_localId);
}
catch
{
m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid);
pa = null;
}
// FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical
// properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor
// being set.
PhysActor = pa;
// Basic Physics can also return null as well as an exception catch.
if (pa != null)
{
pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
pa.SetMaterial(Material);
DoPhysicsPropertyUpdate(rigidBody, true);
}
return pa;
}
/// <summary>
/// This removes the part from the physics scene.
/// </summary>
/// <remarks>
/// This isn't the same as turning off physical, since even without being physical the prim has a physics

View File

@@ -3617,6 +3617,22 @@ namespace OpenSim.Region.Framework.Scenes
});
}
/// <summary>
/// Gets the mass.
/// </summary>
/// <returns>
/// The mass.
/// </returns>
public float GetMass()
{
PhysicsActor pa = PhysicsActor;
if (pa != null)
return pa.Mass;
else
return 0;
}
internal void PushForce(Vector3 impulse)
{
if (PhysicsActor != null)