Merge branch 'master' into httptests

httptests
UbitUmarov 2016-09-17 12:44:52 +01:00
commit e5383604cb
21 changed files with 701 additions and 426 deletions

View File

@ -524,8 +524,7 @@ namespace OpenSim.Data.MySQL
query += "SELECT `notes` FROM usernotes WHERE ";
query += "useruuid = ?Id AND ";
query += "targetuuid = ?TargetId";
OSDArray data = new OSDArray();
try
{
using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@ -904,8 +903,6 @@ namespace OpenSim.Data.MySQL
query += "usersettings WHERE ";
query += "useruuid = ?Id";
OSDArray data = new OSDArray();
try
{
using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))

View File

@ -1354,7 +1354,7 @@ namespace OpenSim.Data.SQLite
createCol(land, "Name", typeof(String));
createCol(land, "Desc", typeof(String));
createCol(land, "OwnerUUID", typeof(String));
createCol(land, "IsGroupOwned", typeof(Boolean));
createCol(land, "IsGroupOwned", typeof(String));
createCol(land, "Area", typeof(Int32));
createCol(land, "AuctionID", typeof(Int32)); //Unemplemented
createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory
@ -1387,6 +1387,9 @@ namespace OpenSim.Data.SQLite
createCol(land, "MediaLoop", typeof(Boolean));
createCol(land, "ObscureMedia", typeof(Boolean));
createCol(land, "ObscureMusic", typeof(Boolean));
createCol(land, "SeeAVs", typeof(Boolean));
createCol(land, "AnyAVSounds", typeof(Boolean));
createCol(land, "GroupAVSounds", typeof(Boolean));
land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] };
@ -1829,7 +1832,7 @@ namespace OpenSim.Data.SQLite
newData.Name = (String)row["Name"];
newData.Description = (String)row["Desc"];
newData.OwnerID = (UUID)(String)row["OwnerUUID"];
newData.IsGroupOwned = (Boolean)row["IsGroupOwned"];
newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
newData.Area = Convert.ToInt32(row["Area"]);
newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented
newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]);
@ -2245,7 +2248,7 @@ namespace OpenSim.Data.SQLite
row["Name"] = land.Name;
row["Desc"] = land.Description;
row["OwnerUUID"] = land.OwnerID.ToString();
row["IsGroupOwned"] = land.IsGroupOwned;
row["IsGroupOwned"] = land.IsGroupOwned.ToString();
row["Area"] = land.Area;
row["AuctionID"] = land.AuctionID; //Unemplemented
row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory
@ -2939,6 +2942,9 @@ namespace OpenSim.Data.SQLite
{
return DbType.Binary;
}
else if (type == typeof(Boolean)) {
return DbType.Boolean;
}
else
{
return DbType.String;

View File

@ -6108,7 +6108,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
AddLocalPacketHandler(PacketType.ChangeInventoryItemFlags, HandleChangeInventoryItemFlags);
AddLocalPacketHandler(PacketType.RevokePermissions, HandleRevokePermissions);
AddGenericPacketHandler("autopilot", HandleAutopilot);
}
@ -10997,6 +10997,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return true;
}
private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
{
return true;
@ -12371,6 +12372,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return true;
}
private bool HandleRevokePermissions(IClientAPI sender, Packet Pack)
{
RevokePermissionsPacket pkt = (RevokePermissionsPacket)Pack;
if (pkt.AgentData.SessionID != SessionId ||
pkt .AgentData.AgentID != AgentId)
return true;
// don't use multidelegate "event"
ScenePresence sp = (ScenePresence)SceneAgent;
if(sp != null && !sp.IsDeleted && !sp.IsInTransit)
{
UUID objectID = pkt.Data.ObjectID;
uint permissions = pkt.Data.ObjectPermissions;
sp.HandleRevokePermissions(objectID , permissions);
}
return true;
}
private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
{
PlacesQueryPacket placesQueryPacket =

View File

@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
}
catch (Exception e)
{
m_log.Error("[EMAIL] DefaultEmailModule not configured: " + e.Message);
m_log.Error("[EMAIL]: DefaultEmailModule not configured: " + e.Message);
m_Enabled = false;
return;
}
@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
}
}
m_log.Info("[EMAIL] Activated DefaultEmailModule");
m_log.Info("[EMAIL]: Activated DefaultEmailModule");
}
public void RemoveRegion(Scene scene)
@ -268,12 +268,12 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
bool isEMailStrictMatch = EMailreStrict.IsMatch(address);
if (!isEMailStrictMatch)
{
m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address);
m_log.Error("[EMAIL]: REGEX Problem in EMail Address: "+address);
return;
}
if ((subject.Length + body.Length) > m_MaxEmailSize)
{
m_log.Error("[EMAIL] subject + body larger than limit of " + m_MaxEmailSize + " bytes");
m_log.Error("[EMAIL]: subject + body larger than limit of " + m_MaxEmailSize + " bytes");
return;
}
@ -318,11 +318,11 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
emailMessage.Send(smtpServer);
//Log
m_log.Info("[EMAIL] EMail sent to: " + address + " from object: " + objectID.ToString() + "@" + m_HostName);
m_log.Info("[EMAIL]: EMail sent to: " + address + " from object: " + objectID.ToString() + "@" + m_HostName);
}
catch (Exception e)
{
m_log.Error("[EMAIL] DefaultEmailModule Exception: " + e.Message);
m_log.Error("[EMAIL]: DefaultEmailModule Exception: " + e.Message);
}
}
else

View File

@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private IGridService m_GridService;
private RegionInfoCache m_RegionInfoCache;
private HashSet<Scene> m_scenes = new HashSet<Scene>();
private bool m_Enabled;
@ -68,7 +69,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public LocalGridServicesConnector(IConfigSource source, RegionInfoCache regionInfoCache)
{
m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly witj cache.", LogHeader);
m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly with cache.", LogHeader);
InitialiseService(source, regionInfoCache);
}
@ -137,11 +138,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void PostInitialise()
{
// FIXME: We will still add this command even if we aren't enabled since RemoteGridServiceConnector
// will have instantiated us directly.
MainConsole.Instance.Commands.AddCommand("Regions", false, "show neighbours",
"show neighbours",
"Shows the local regions' neighbours", HandleShowNeighboursCommand);
}
public void Close()
@ -153,6 +149,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (!m_Enabled)
return;
lock(m_scenes)
{
if(!m_scenes.Contains(scene))
m_scenes.Add(scene);
}
scene.RegisterModuleInterface<IGridService>(this);
GridRegion r = new GridRegion(scene.RegionInfo);
@ -166,6 +167,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (!m_Enabled)
return;
lock(m_scenes)
{
if(m_scenes.Contains(scene))
m_scenes.Remove(scene);
}
m_RegionInfoCache.Remove(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionHandle);
scene.EventManager.OnRegionUp -= OnRegionUp;
}
@ -221,14 +228,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{
// try in cache by handler first
// ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
bool inCache = false;
// GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
// if (inCache)
// return rinfo;
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, (uint)x, (uint)y, out inCache);
if (inCache)
return rinfo;
@ -295,24 +295,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#endregion
public void HandleShowNeighboursCommand(string module, string[] cmdparams)
{
System.Text.StringBuilder caps = new System.Text.StringBuilder();
/* temporary broken
lock (m_LocalCache)
{
foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
{
caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
List<GridRegion> regions = kvp.Value.GetNeighbours();
foreach (GridRegion r in regions)
caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
}
}
MainConsole.Instance.Output(caps.ToString());
*/
MainConsole.Instance.Output("Neighbours list not avaiable in this version\n");
}
}
}

View File

@ -210,7 +210,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
return;
}
m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name);
// mapTile.Save( // DEBUG DEBUG
// String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY),
@ -218,12 +217,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
// If the region/maptile is legacy sized, just upload the one tile like it has always been done
if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
{
m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name);
ConvertAndUploadMaptile(scene, mapTile,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
scene.RegionInfo.RegionName);
}
else
{
m_log.DebugFormat("{0} Upload {1} maptiles for {2}", LogHeader,
(mapTile.Width * mapTile.Height) / (Constants.RegionSize * Constants.RegionSize),
scene.Name);
// For larger regions (varregion) we must cut the region image into legacy sized
// pieces since that is how the maptile system works.
// Note the assumption that varregions are always a multiple of legacy size.

View File

@ -1435,6 +1435,9 @@ namespace OpenSim.Region.CoreModules.World.Land
land.LandData.IsGroupOwned = false;
land.LandData.SalePrice = 0;
land.LandData.AuthBuyerID = UUID.Zero;
land.LandData.SeeAVs = true;
land.LandData.AnyAVSounds = true;
land.LandData.GroupAVSounds = true;
land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
m_scene.ForEachClient(SendParcelOverlay);
land.SendLandUpdateToClient(true, remote_client);

View File

@ -40,6 +40,7 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.Objects.Commands
{
@ -107,6 +108,15 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
+ "max-agent-limit <int> - Maximum root agent limit. agent-limit cannot exceed this."
+ " This is not persisted over restart - to set it every time you must add a MaxAgents entry to your regions file.",
HandleRegionSet);
m_console.Commands.AddCommand("Regions", false, "show neighbours",
"show neighbours",
"Shows the local region neighbours", HandleShowNeighboursCommand);
m_console.Commands.AddCommand("Regions", false, "show regionsinview",
"show regionsinview",
"Shows regions that can be seen from a region", HandleShowRegionsInViewCommand);
}
public void RemoveRegion(Scene scene)
@ -309,5 +319,60 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
MainConsole.Instance.Output(sb.ToString());
}
public void HandleShowNeighboursCommand(string module, string[] cmdparams)
{
if(m_scene == null)
return;
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
return;
System.Text.StringBuilder caps = new System.Text.StringBuilder();
RegionInfo sr = m_scene.RegionInfo;
caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", sr.RegionName, sr.RegionID);
List<GridRegion> regions = m_scene.GridService.GetNeighbours(sr.ScopeID, sr.RegionID);
foreach (GridRegion r in regions)
caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
MainConsole.Instance.Output(caps.ToString());
}
public void HandleShowRegionsInViewCommand(string module, string[] cmdparams)
{
if(m_scene == null)
return;
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
return;
System.Text.StringBuilder caps = new System.Text.StringBuilder();
int maxview = (int)m_scene.MaxRegionViewDistance;
RegionInfo sr = m_scene.RegionInfo;
caps.AppendFormat("*** Regions that can be seen from {0} ({1}) (MaxRegionViewDistance {2}m) ***\n", sr.RegionName, sr.RegionID, maxview);
int startX = (int)sr.WorldLocX;
int endX = startX + (int)sr.RegionSizeX;
int startY = (int)sr.WorldLocY;
int endY = startY + (int)sr.RegionSizeY;
startX -= maxview;
if(startX < 0 )
startX = 0;
startY -= maxview;
if(startY < 0)
startY = 0;
endX += maxview;
endY += maxview;
List<GridRegion> regions = m_scene.GridService.GetRegionRange(sr.ScopeID, startX, endX, startY, endY);
foreach (GridRegion r in regions)
{
if(r.RegionHandle == sr.RegionHandle)
continue;
caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
}
MainConsole.Instance.Output(caps.ToString());
}
}
}
}

View File

@ -1122,8 +1122,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
}
*/
int[] xPieces = new int[toSend.Count];
int[] yPieces = new int[toSend.Count];
float[] patchPieces = new float[toSend.Count * 2];
int pieceIndex = 0;
foreach (PatchesToSend pts in toSend)

View File

@ -66,7 +66,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg";
private static readonly UUID STOP_UUID = UUID.Random();
private static readonly string m_mapLayerPath = "0001/";
private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>();
@ -177,6 +176,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
regionimage = regionimage.Replace("-", "");
m_log.Info("[WORLD MAP]: JPEG Map location: " + m_scene.RegionInfo.ServerURI + "index.php?method=" + regionimage);
/*
MainServer.Instance.AddHTTPHandler(regionimage,
new GenericHTTPDOSProtector(OnHTTPGetMapImage, OnHTTPThrottled, new BasicDosProtectorOptions()
{
@ -187,6 +187,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
RequestTimeSpan = TimeSpan.FromSeconds(10),
ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod
}).Process);
*/
MainServer.Instance.AddHTTPHandler(regionimage, OnHTTPGetMapImage);
MainServer.Instance.AddLLSDHandler(
"/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest);
@ -222,12 +225,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public void OnRegisterCaps(UUID agentID, Caps caps)
{
//m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
string capsBase = "/CAPS/" + caps.CapsObjectPath;
string capspath = "/CAPS/" + UUID.Random();
caps.RegisterHandler(
"MapLayer",
new RestStreamHandler(
"POST",
capsBase + m_mapLayerPath,
capspath,
(request, path, param, httpRequest, httpResponse)
=> MapLayerRequest(request, path, param, agentID, caps),
"MapLayer",
@ -1142,10 +1145,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
protected void MapBlockSendThread()
{
List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>();
while (true)
{
List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>();
m_mapBlockRequestEvent.WaitOne();
lock (m_mapBlockRequestEvent)
{
@ -1162,13 +1164,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_mapBlockRequestEvent.Reset();
}
foreach (MapBlockRequestData req in thisRunData)
if(thisRunData.Count > 0)
{
// Null client stops thread
if (req.client == null)
return;
foreach (MapBlockRequestData req in thisRunData)
{
// Null client stops thread
if (req.client == null)
return;
GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags);
GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags);
}
thisRunData.Clear();
}
Thread.Sleep(50);
@ -1590,6 +1597,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{
m_scene.AssetService.Delete(lastID.ToString());
m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Zero;
myMapImageJPEG = new byte[0];
needRegionSave = true;
}
@ -1648,7 +1656,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
asset.Flags = AssetFlags.Maptile;
// Store the new one
m_log.DebugFormat("[WORLD MAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
m_log.DebugFormat("[WORLD MAP]: Storing map image {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
m_scene.AssetService.Store(asset);

View File

@ -1881,7 +1881,7 @@ namespace OpenSim.Region.Framework.Scenes
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}",
"[EVENT MANAGER]: Delegate for TriggerGroupMove failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}

View File

@ -340,13 +340,11 @@ namespace OpenSim.Region.Framework.Scenes
obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
// If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
// Deliver to the root prim if the touched prim doesn't handle touches
// or if we're meant to pass on touches anyway. Don't send to root prim
// if prim touched is the root prim as we just did it
// or if we're meant to pass on touches anyway.
if (((part.ScriptEvents & scriptEvents.touch_start) == 0) ||
(part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
{
@ -381,12 +379,10 @@ namespace OpenSim.Region.Framework.Scenes
surfaceArg = surfaceArgs[0];
// If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ScriptEvents & scriptEvents.touch) != 0)
EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
// Deliver to the root prim if the touched prim doesn't handle touches
// or if we're meant to pass on touches anyway. Don't send to root prim
// if prim touched is the root prim as we just did it
// or if we're meant to pass on touches anyway.
if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
(part.PassTouches && (part.LocalId != group.RootPart.LocalId)))
{
@ -400,18 +396,77 @@ namespace OpenSim.Region.Framework.Scenes
if (part == null)
return;
SceneObjectGroup obj = part.ParentGroup;
SceneObjectGroup grp = part.ParentGroup;
SurfaceTouchEventArgs surfaceArg = null;
if (surfaceArgs != null && surfaceArgs.Count > 0)
surfaceArg = surfaceArgs[0];
// If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
else
EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
// if not or PassTouchs, send it also to root.
if (((part.ScriptEvents & scriptEvents.touch_end) == 0) ||
(part.PassTouches && (part.LocalId != grp.RootPart.LocalId)))
{
EventManager.TriggerObjectDeGrab(grp.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
}
}
/// <summary>
/// Start spinning the given object
/// </summary>
/// <param name="objectID"></param>
/// <param name="rotation"></param>
/// <param name="remoteClient"></param>
public virtual void ProcessSpinStart(UUID objectID, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
{
group.SpinStart(remoteClient);
}
}
}
/// <summary>
/// Spin the given object
/// </summary>
/// <param name="objectID"></param>
/// <param name="rotation"></param>
/// <param name="remoteClient"></param>
public virtual void ProcessSpinObject(UUID objectID, Quaternion rotation, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
{
group.SpinMovement(rotation, remoteClient);
}
// This is outside the above permissions condition
// so that if the object is locked the client moving the object
// get's it's position on the simulator even if it was the same as before
// This keeps the moving user's client in sync with the rest of the world.
group.SendGroupTerseUpdate();
}
}
public virtual void ProcessSpinObjectStop(UUID objectID, IClientAPI remoteClient)
{
/* no op for now
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
{
// group.SpinMovement(rotation, remoteClient);
}
group.SendGroupTerseUpdate();
}
*/
}
public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID,

View File

@ -3329,8 +3329,6 @@ namespace OpenSim.Region.Framework.Scenes
client.OnObjectRequest += RequestPrim;
client.OnObjectSelect += SelectPrim;
client.OnObjectDeselect += DeselectPrim;
client.OnSpinStart += m_sceneGraph.SpinStart;
client.OnSpinUpdate += m_sceneGraph.SpinObject;
client.OnDeRezObject += DeRezObjects;
client.OnObjectName += m_sceneGraph.PrimName;
@ -3346,6 +3344,9 @@ namespace OpenSim.Region.Framework.Scenes
client.OnGrabObject += ProcessObjectGrab;
client.OnGrabUpdate += ProcessObjectGrabUpdate;
client.OnDeGrabObject += ProcessObjectDeGrab;
client.OnSpinStart += ProcessSpinStart;
client.OnSpinUpdate += ProcessSpinObject;
client.OnSpinStop += ProcessSpinObjectStop;
client.OnUndo += m_sceneGraph.HandleUndo;
client.OnRedo += m_sceneGraph.HandleRedo;
client.OnObjectDescription += m_sceneGraph.PrimDescription;
@ -3456,8 +3457,6 @@ namespace OpenSim.Region.Framework.Scenes
client.OnObjectRequest -= RequestPrim;
client.OnObjectSelect -= SelectPrim;
client.OnObjectDeselect -= DeselectPrim;
client.OnSpinStart -= m_sceneGraph.SpinStart;
client.OnSpinUpdate -= m_sceneGraph.SpinObject;
client.OnDeRezObject -= DeRezObjects;
client.OnObjectName -= m_sceneGraph.PrimName;
client.OnObjectClickAction -= m_sceneGraph.PrimClickAction;
@ -3472,6 +3471,9 @@ namespace OpenSim.Region.Framework.Scenes
client.OnGrabObject -= ProcessObjectGrab;
client.OnGrabUpdate -= ProcessObjectGrabUpdate;
client.OnDeGrabObject -= ProcessObjectDeGrab;
client.OnSpinStart -= ProcessSpinStart;
client.OnSpinUpdate -= ProcessSpinObject;
client.OnSpinStop -= ProcessSpinObjectStop;
client.OnUndo -= m_sceneGraph.HandleUndo;
client.OnRedo -= m_sceneGraph.HandleRedo;
client.OnObjectDescription -= m_sceneGraph.PrimDescription;

View File

@ -1674,72 +1674,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
/* moved to scene ProcessObjectGrabUpdate
/// <summary>
/// Move the given object
/// </summary>
/// <param name="objectID"></param>
/// <param name="offset"></param>
/// <param name="pos"></param>
/// <param name="remoteClient"></param>
protected internal void MoveObject(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
{
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
{
group.GrabMovement(objectID, offset, pos, remoteClient);
}
// This is outside the above permissions condition
// so that if the object is locked the client moving the object
// get's it's position on the simulator even if it was the same as before
// This keeps the moving user's client in sync with the rest of the world.
group.SendGroupTerseUpdate();
}
}
*/
/// <summary>
/// Start spinning the given object
/// </summary>
/// <param name="objectID"></param>
/// <param name="rotation"></param>
/// <param name="remoteClient"></param>
protected internal void SpinStart(UUID objectID, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
{
group.SpinStart(remoteClient);
}
}
}
/// <summary>
/// Spin the given object
/// </summary>
/// <param name="objectID"></param>
/// <param name="rotation"></param>
/// <param name="remoteClient"></param>
protected internal void SpinObject(UUID objectID, Quaternion rotation, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
{
group.SpinMovement(rotation, remoteClient);
}
// This is outside the above permissions condition
// so that if the object is locked the client moving the object
// get's it's position on the simulator even if it was the same as before
// This keeps the moving user's client in sync with the rest of the world.
group.SendGroupTerseUpdate();
}
}
/// <summary>
///

View File

@ -79,7 +79,8 @@ namespace OpenSim.Region.Framework.Scenes
touch_end = 536870912,
touch_start = 2097152,
transaction_result = 33554432,
object_rez = 4194304
object_rez = 4194304,
anytouch = touch | touch_end | touch_start
}
public struct scriptPosTarget
@ -3497,34 +3498,26 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
{
if (BlockGrabOverride)
return;
SceneObjectPart part = GetPart(partID);
if (part == null)
return;
if (part.BlockGrab)
return;
PhysicsActor pa = m_rootPart.PhysActor;
if (pa != null)
if (pa != null && pa.IsPhysical)
{
if (pa.IsPhysical)
{
if (!BlockGrabOverride && !part.BlockGrab)
{
/* Vector3 llmoveforce = pos - AbsolutePosition;
Vector3 grabforce = llmoveforce;
grabforce = (grabforce / 10) * pa.Mass;
*/
// empirically convert distance diference to a impulse
Vector3 grabforce = pos - AbsolutePosition;
grabforce = grabforce * (pa.Mass/ 10.0f);
pa.AddForce(grabforce, false);
m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
}
}
else
{
NonPhysicalGrabMovement(pos);
}
// empirically convert distance diference to a impulse
Vector3 grabforce = pos - AbsolutePosition;
grabforce = grabforce * (pa.Mass * 0.1f);
pa.AddForce(grabforce, false);
m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
}
else
{
@ -3553,6 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="remoteClient"></param>
public void SpinStart(IClientAPI remoteClient)
{
if (BlockGrabOverride || m_rootPart.BlockGrab)
return;
if (m_scene.EventManager.TriggerGroupSpinStart(UUID))
{
PhysicsActor pa = m_rootPart.PhysActor;
@ -3600,46 +3595,48 @@ namespace OpenSim.Region.Framework.Scenes
// but it will result in over-shoot or under-shoot of the target orientation.
// For the end user, this means that ctrl+shift+drag can be used for relative,
// but not absolute, adjustments of orientation for physical prims.
if (BlockGrabOverride || m_rootPart.BlockGrab)
return;
if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation))
{
PhysicsActor pa = m_rootPart.PhysActor;
if (pa != null)
if (pa != null && pa.IsPhysical)
{
if (pa.IsPhysical)
if (m_rootPart.IsWaitingForFirstSpinUpdatePacket)
{
if (m_rootPart.IsWaitingForFirstSpinUpdatePacket)
{
// first time initialization of "old" orientation for calculation of delta rotations
m_rootPart.SpinOldOrientation = newOrientation;
m_rootPart.IsWaitingForFirstSpinUpdatePacket = false;
}
else
{
// save and update old orientation
Quaternion old = m_rootPart.SpinOldOrientation;
m_rootPart.SpinOldOrientation = newOrientation;
//m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old);
//m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation);
// compute difference between previous old rotation and new incoming rotation
Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation;
float rotationAngle;
Vector3 rotationAxis;
minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle);
rotationAxis.Normalize();
//m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor
pa.AddAngularForce(spinforce,true);
m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
}
// first time initialization of "old" orientation for calculation of delta rotations
m_rootPart.SpinOldOrientation = newOrientation;
m_rootPart.IsWaitingForFirstSpinUpdatePacket = false;
}
else
{
NonPhysicalSpinMovement(newOrientation);
// save and update old orientation
Quaternion old = m_rootPart.SpinOldOrientation;
m_rootPart.SpinOldOrientation = newOrientation;
//m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old);
//m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation);
// compute difference between previous old rotation and new incoming rotation
Quaternion minimalRotationFromQ1ToQ2 = newOrientation * Quaternion.Inverse(old);
float rotationAngle;
Vector3 spinforce;
minimalRotationFromQ1ToQ2.GetAxisAngle(out spinforce, out rotationAngle);
if(Math.Abs(rotationAngle)< 0.001)
return;
spinforce.Normalize();
//m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
if(rotationAngle > 0)
spinforce = spinforce * pa.Mass * 0.1f; // 0.1 is an arbitrary torque scaling factor
else
spinforce = spinforce * pa.Mass * -0.1f; // 0.1 is an arbitrary torque scaling
pa.AddAngularForce(spinforce,true);
m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
}
}
else

View File

@ -3335,11 +3335,16 @@ namespace OpenSim.Region.Framework.Scenes
Velocity = Vector3.Zero;
m_AngularVelocity = Vector3.Zero;
m_requestedSitTargetID = 0;
part.AddSittingAvatar(this);
ParentPart = part;
ParentID = part.LocalId;
Vector3 cameraAtOffset = part.GetCameraAtOffset();
Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
bool forceMouselook = part.GetForceMouselook();
if (!part.IsRoot)
{
Orientation = part.RotationOffset * Orientation;
@ -3365,13 +3370,7 @@ namespace OpenSim.Region.Framework.Scenes
ControllingClient.SendSitResponse(
part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook);
m_requestedSitTargetID = 0;
part.AddSittingAvatar(this);
ParentPart = part;
ParentID = part.LocalId;
SendAvatarDataToAllAgents();
@ -5560,6 +5559,13 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID)
{
foreach (ScriptControllers c in scriptedcontrols.Values)
{
SceneObjectGroup sog = m_scene.GetSceneObjectGroup(c.objectID);
if(sog != null && !sog.IsDeleted && sog.RootPart.PhysActor != null)
sog.RootPart.PhysActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
}
IgnoredControls = ScriptControlled.CONTROL_ZERO;
lock (scriptedcontrols)
{
@ -5568,6 +5574,26 @@ namespace OpenSim.Region.Framework.Scenes
ControllingClient.SendTakeControls(int.MaxValue, false, false);
}
public void HandleRevokePermissions(UUID objectID, uint permissions )
{
// still skeleton code
if((permissions & (16 | 0x8000 )) == 0) //PERMISSION_TRIGGER_ANIMATION | PERMISSION_OVERRIDE_ANIMATIONS
return;
if(objectID == m_scene.RegionInfo.RegionID) // for all objects
{
}
else
{
SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
if(part != null)
{
}
}
}
public void ClearControls()
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;

View File

@ -63,11 +63,16 @@ namespace OpenSim.Region.OptionalModules.Materials
public Type ReplaceableInterface { get { return null; } }
IImprovedAssetCache m_cache;
private Scene m_scene = null;
private bool m_enabled = false;
private int m_maxMaterialsPerTransaction = 50;
public Dictionary<UUID, OSDMap> m_regionMaterials = new Dictionary<UUID, OSDMap>();
public Dictionary<UUID, OSDMap> m_Materials = new Dictionary<UUID, OSDMap>();
public Dictionary<UUID, int> m_MaterialsRefCount = new Dictionary<UUID, int>();
private Dictionary<ulong, AssetBase> m_changes = new Dictionary<ulong, AssetBase>();
private Dictionary<ulong, double> m_changesTime = new Dictionary<ulong, double>();
public void Initialise(IConfigSource source)
{
@ -98,6 +103,56 @@ namespace OpenSim.Region.OptionalModules.Materials
m_scene = scene;
m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene;
m_scene.EventManager.OnBackup += EventManager_OnBackup;
}
private void EventManager_OnBackup(ISimulationDataService datastore, bool forcedBackup)
{
List<AssetBase> toStore;
List<ulong> hashlist;
lock (m_Materials)
{
if(m_changes.Count == 0)
return;
if(forcedBackup)
{
toStore = new List<AssetBase>(m_changes.Values);
m_changes.Clear();
m_changesTime.Clear();
}
else
{
toStore = new List<AssetBase>();
hashlist = new List<ulong>();
double storetime = Util.GetTimeStampMS() - 60000;
foreach(KeyValuePair<ulong,double> kvp in m_changesTime)
{
if(kvp.Value < storetime)
{
toStore.Add(m_changes[kvp.Key]);
hashlist.Add(kvp.Key);
}
}
foreach(ulong u in hashlist)
{
m_changesTime.Remove(u);
m_changes.Remove(u);
}
}
if(toStore.Count > 0)
Util.FireAndForget(delegate
{
foreach(AssetBase a in toStore)
{
a.Local = false;
m_scene.AssetService.Store(a);
}
});
}
}
private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj)
@ -133,7 +188,7 @@ namespace OpenSim.Region.OptionalModules.Materials
IRequestHandler renderMaterialsPutHandler
= new RestStreamHandler("PUT", capsBase + "/",
(request, path, param, httpRequest, httpResponse)
=> RenderMaterialsPostCap(request, agentID),
=> RenderMaterialsPutCap(request, agentID),
"RenderMaterials", null);
MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler);
}
@ -145,12 +200,14 @@ namespace OpenSim.Region.OptionalModules.Materials
m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene;
m_scene.EventManager.OnBackup -= EventManager_OnBackup;
}
public void RegionLoaded(Scene scene)
{
if (!m_enabled) return;
m_cache = scene.RequestModuleInterface<IImprovedAssetCache>();
ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface<ISimulatorFeaturesModule>();
if (featuresModule != null)
featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
@ -203,8 +260,17 @@ namespace OpenSim.Region.OptionalModules.Materials
{
try
{
lock (m_regionMaterials)
m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"];
lock (m_Materials)
{
UUID id = matMap["ID"].AsUUID();
if(m_Materials.ContainsKey(id))
m_MaterialsRefCount[id]++;
else
{
m_Materials[id] = (OSDMap)matMap["Material"];
m_MaterialsRefCount[id] = 1;
}
}
}
catch (Exception e)
{
@ -252,18 +318,22 @@ namespace OpenSim.Region.OptionalModules.Materials
if (id == UUID.Zero)
return;
lock (m_regionMaterials)
lock (m_Materials)
{
if (m_regionMaterials.ContainsKey(id))
if (m_Materials.ContainsKey(id))
{
m_MaterialsRefCount[id]++;
return;
byte[] data = m_scene.AssetService.GetData(id.ToString());
if (data == null)
}
AssetBase matAsset = m_scene.AssetService.Get(id.ToString());
if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0 )
{
m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
return;
}
byte[] data = matAsset.Data;
OSDMap mat;
try
{
@ -275,7 +345,8 @@ namespace OpenSim.Region.OptionalModules.Materials
return;
}
m_regionMaterials[id] = mat;
m_Materials[id] = mat;
m_MaterialsRefCount[id] = 1;
}
}
@ -284,8 +355,6 @@ namespace OpenSim.Region.OptionalModules.Materials
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
OSDMap resp = new OSDMap();
OSDMap materialsFromViewer = null;
OSDArray respArr = new OSDArray();
if (req.ContainsKey("Zipped"))
@ -298,150 +367,41 @@ namespace OpenSim.Region.OptionalModules.Materials
{
osd = ZDecompressBytesToOsd(inBytes);
if (osd != null)
if (osd != null && osd is OSDArray)
{
if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
foreach (OSD elem in (OSDArray)osd)
{
foreach (OSD elem in (OSDArray)osd)
try
{
try
{
UUID id = new UUID(elem.AsBinary(), 0);
UUID id = new UUID(elem.AsBinary(), 0);
lock (m_regionMaterials)
lock (m_Materials)
{
if (m_Materials.ContainsKey(id))
{
if (m_regionMaterials.ContainsKey(id))
{
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(id.GetBytes());
matMap["Material"] = m_regionMaterials[id];
respArr.Add(matMap);
}
else
{
m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
// Theoretically we could try to load the material from the assets service,
// but that shouldn't be necessary because the viewer should only request
// materials that exist in a prim on the region, and all of these materials
// are already stored in m_regionMaterials.
}
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(id.GetBytes());
matMap["Material"] = m_Materials[id];
respArr.Add(matMap);
}
else
{
m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
// Theoretically we could try to load the material from the assets service,
// but that shouldn't be necessary because the viewer should only request
// materials that exist in a prim on the region, and all of these materials
// are already stored in m_regionMaterials.
}
}
catch (Exception e)
{
m_log.Error("Error getting materials in response to viewer request", e);
continue;
}
}
}
else if (osd is OSDMap) // request to assign a material
{
materialsFromViewer = osd as OSDMap;
if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
catch (Exception e)
{
OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
if (matsOsd is OSDArray)
{
OSDArray matsArr = matsOsd as OSDArray;
try
{
foreach (OSDMap matsMap in matsArr)
{
uint primLocalID = 0;
try {
primLocalID = matsMap["ID"].AsUInteger();
}
catch (Exception e) {
m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
continue;
}
OSDMap mat = null;
try
{
mat = matsMap["Material"] as OSDMap;
}
catch (Exception e)
{
m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
continue;
}
SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
if (sop == null)
{
m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
continue;
}
if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
{
m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
continue;
}
Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
if (te == null)
{
m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
continue;
}
UUID id;
if (mat == null)
{
// This happens then the user removes a material from a prim
id = UUID.Zero;
}
else
{
id = StoreMaterialAsAsset(agentID, mat, sop);
}
int face = -1;
if (matsMap.ContainsKey("Face"))
{
face = matsMap["Face"].AsInteger();
Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
faceEntry.MaterialID = id;
}
else
{
if (te.DefaultTexture == null)
m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID);
else
te.DefaultTexture.MaterialID = id;
}
//m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
// We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
sop.Shape.TextureEntry = te.GetBytes();
if (sop.ParentGroup != null)
{
sop.TriggerScriptChangedEvent(Changed.TEXTURE);
sop.UpdateFlag = UpdateRequired.FULL;
sop.ParentGroup.HasGroupChanged = true;
sop.ScheduleFullUpdate();
}
}
}
catch (Exception e)
{
m_log.Warn("[Materials]: exception processing received material ", e);
}
}
m_log.Error("Error getting materials in response to viewer request", e);
continue;
}
}
}
}
catch (Exception e)
{
@ -449,7 +409,6 @@ namespace OpenSim.Region.OptionalModules.Materials
//return "";
}
}
resp["Zipped"] = ZCompressOSD(respArr, false);
string response = OSDParser.SerializeLLSDXmlString(resp);
@ -460,6 +419,219 @@ namespace OpenSim.Region.OptionalModules.Materials
return response;
}
public string RenderMaterialsPutCap(string request, UUID agentID)
{
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
OSDMap resp = new OSDMap();
OSDMap materialsFromViewer = null;
OSDArray respArr = new OSDArray();
HashSet<SceneObjectPart> parts = new HashSet<SceneObjectPart>();
if (req.ContainsKey("Zipped"))
{
OSD osd = null;
byte[] inBytes = req["Zipped"].AsBinary();
try
{
osd = ZDecompressBytesToOsd(inBytes);
if (osd != null && osd is OSDMap)
{
materialsFromViewer = osd as OSDMap;
if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
{
OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
if (matsOsd is OSDArray)
{
OSDArray matsArr = matsOsd as OSDArray;
try
{
foreach (OSDMap matsMap in matsArr)
{
uint primLocalID = 0;
try {
primLocalID = matsMap["ID"].AsUInteger();
}
catch (Exception e) {
m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
continue;
}
SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
if (sop == null)
{
m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
continue;
}
if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
{
m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
continue;
}
OSDMap mat = null;
try
{
mat = matsMap["Material"] as OSDMap;
}
catch (Exception e)
{
m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
continue;
}
Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
if (te == null)
{
m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
continue;
}
UUID id;
if (mat == null)
{
// This happens then the user removes a material from a prim
id = UUID.Zero;
}
else
{
id = getNewID(mat);
}
int face = -1;
UUID oldid = UUID.Zero;
if (matsMap.ContainsKey("Face"))
{
face = matsMap["Face"].AsInteger();
Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
oldid = faceEntry.MaterialID;
faceEntry.MaterialID = id;
}
else
{
if (te.DefaultTexture == null)
m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID);
else
{
oldid = te.DefaultTexture.MaterialID;
te.DefaultTexture.MaterialID = id;
}
}
//m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
// We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
sop.Shape.TextureEntry = te.GetBytes();
lock(m_Materials)
{
if(oldid != UUID.Zero)
{
m_MaterialsRefCount[oldid]--;
if(m_MaterialsRefCount[oldid] <= 0)
{
m_Materials.Remove(oldid);
m_MaterialsRefCount.Remove(oldid);
m_cache.Expire(oldid.ToString());
}
}
if(id != UUID.Zero)
{
AssetBase asset = CacheMaterialAsAsset(id, agentID, mat, sop);
if(asset != null)
{
ulong materialHash = (ulong)primLocalID << 32;
if(face < 0)
materialHash += 0xffffffff;
else
materialHash +=(ulong)face;
m_changes[materialHash] = asset;
m_changesTime[materialHash] = Util.GetTimeStampMS();
}
}
}
if(!parts.Contains(sop))
parts.Add(sop);
}
foreach(SceneObjectPart sop in parts)
{
if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted)
{
sop.TriggerScriptChangedEvent(Changed.TEXTURE);
sop.ScheduleFullUpdate();
sop.ParentGroup.HasGroupChanged = true;
}
}
}
catch (Exception e)
{
m_log.Warn("[Materials]: exception processing received material ", e);
}
}
}
}
}
catch (Exception e)
{
m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
//return "";
}
}
resp["Zipped"] = ZCompressOSD(respArr, false);
string response = OSDParser.SerializeLLSDXmlString(resp);
//m_log.Debug("[Materials]: cap request: " + request);
//m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
//m_log.Debug("[Materials]: cap response: " + response);
return response;
}
private UUID getNewID(OSDMap mat)
{
// ugly and done twice but keep compatibility for now
Byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat));
using (var md5 = MD5.Create())
return new UUID(md5.ComputeHash(data), 0);
}
private AssetBase CacheMaterialAsAsset(UUID id, UUID agentID, OSDMap mat, SceneObjectPart sop)
{
AssetBase asset = null;
lock (m_Materials)
{
if (!m_Materials.ContainsKey(id))
{
m_Materials[id] = mat;
m_MaterialsRefCount[id] = 1;
byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat));
// This asset might exist already, but it's ok to try to store it again
string name = "Material " + ChooseMaterialName(mat, sop);
name = name.Substring(0, Math.Min(64, name.Length)).Trim();
asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString());
asset.Data = data;
asset.Local = true;
m_cache.Cache(asset);
}
else
m_MaterialsRefCount[id]++;
}
return asset;
}
private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop)
{
UUID id;
@ -469,11 +641,12 @@ namespace OpenSim.Region.OptionalModules.Materials
using (var md5 = MD5.Create())
id = new UUID(md5.ComputeHash(data), 0);
lock (m_regionMaterials)
lock (m_Materials)
{
if (!m_regionMaterials.ContainsKey(id))
if (!m_Materials.ContainsKey(id))
{
m_regionMaterials[id] = mat;
m_Materials[id] = mat;
m_MaterialsRefCount[id] = 1;
// This asset might exist already, but it's ok to try to store it again
string name = "Material " + ChooseMaterialName(mat, sop);
@ -482,6 +655,8 @@ namespace OpenSim.Region.OptionalModules.Materials
asset.Data = data;
m_scene.AssetService.Store(asset);
}
else
m_MaterialsRefCount[id]++;
}
return id;
}
@ -523,9 +698,9 @@ namespace OpenSim.Region.OptionalModules.Materials
int matsCount = 0;
OSDArray allOsd = new OSDArray();
lock (m_regionMaterials)
lock (m_Materials)
{
foreach (KeyValuePair<UUID, OSDMap> kvp in m_regionMaterials)
foreach (KeyValuePair<UUID, OSDMap> kvp in m_Materials)
{
OSDMap matMap = new OSDMap();

View File

@ -112,7 +112,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private bool _zeroFlag = false;
private bool m_haveLastFallVel = false;
private uint m_localID = 0;
public bool m_returnCollisions = false;
// taints and their non-tainted counterparts
@ -149,7 +148,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public int m_eventsubscription = 0;
private int m_cureventsubscription = 0;
private CollisionEventUpdate CollisionEventsThisFrame = null;
private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
private bool SentEmptyCollisionsEvent;
// unique UUID of this character object
@ -1556,32 +1555,26 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public override float APIDDamping { set { return; } }
public override void SubscribeEvents(int ms)
{
m_eventsubscription = ms;
m_cureventsubscription = 0;
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
CollisionEventsThisFrame.Clear();
SentEmptyCollisionsEvent = false;
}
public override void UnSubscribeEvents()
{
if (CollisionEventsThisFrame != null)
{
CollisionEventsThisFrame.Clear();
CollisionEventsThisFrame = null;
}
m_eventsubscription = 0;
_parent_scene.RemoveCollisionEventReporting(this);
lock(CollisionEventsThisFrame)
CollisionEventsThisFrame.Clear();
}
public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
{
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
lock(CollisionEventsThisFrame)
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
_parent_scene.AddCollisionEventReporting(this);
}
@ -1590,28 +1583,28 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (m_cureventsubscription < 50000)
m_cureventsubscription += timestep;
if (CollisionEventsThisFrame == null)
return;
if (m_cureventsubscription < m_eventsubscription)
return;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (!SentEmptyCollisionsEvent || ncolisions > 0)
lock(CollisionEventsThisFrame)
{
base.SendCollisionUpdate(CollisionEventsThisFrame);
m_cureventsubscription = 0;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (ncolisions == 0)
if (!SentEmptyCollisionsEvent || ncolisions > 0)
{
SentEmptyCollisionsEvent = true;
// _parent_scene.RemoveCollisionEventReporting(this);
}
else
{
SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear();
base.SendCollisionUpdate(CollisionEventsThisFrame);
m_cureventsubscription = 0;
if (ncolisions == 0)
{
SentEmptyCollisionsEvent = true;
// _parent_scene.RemoveCollisionEventReporting(this);
}
else
{
SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear();
}
}
}
}

View File

@ -588,37 +588,36 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
Mesh mesh = new Mesh();
mesh.releaseBuildingMeshData();
BinaryReader br = new BinaryReader(st);
bool ok = true;
try
using(BinaryReader br = new BinaryReader(st))
{
mesh.m_vertexCount = br.ReadInt32();
mesh.m_indexCount = br.ReadInt32();
try
{
mesh.m_vertexCount = br.ReadInt32();
mesh.m_indexCount = br.ReadInt32();
int n = 3 * mesh.m_vertexCount;
mesh.vertices = new float[n];
for (int i = 0; i < n; i++)
mesh.vertices[i] = br.ReadSingle();
int n = 3 * mesh.m_vertexCount;
mesh.vertices = new float[n];
for (int i = 0; i < n; i++)
mesh.vertices[i] = br.ReadSingle();
mesh.indexes = new int[mesh.m_indexCount];
for (int i = 0; i < mesh.m_indexCount; i++)
mesh.indexes[i] = br.ReadInt32();
mesh.indexes = new int[mesh.m_indexCount];
for (int i = 0; i < mesh.m_indexCount; i++)
mesh.indexes[i] = br.ReadInt32();
mesh.m_obb.X = br.ReadSingle();
mesh.m_obb.Y = br.ReadSingle();
mesh.m_obb.Z = br.ReadSingle();
mesh.m_obb.X = br.ReadSingle();
mesh.m_obb.Y = br.ReadSingle();
mesh.m_obb.Z = br.ReadSingle();
mesh.m_obboffset.X = br.ReadSingle();
mesh.m_obboffset.Y = br.ReadSingle();
mesh.m_obboffset.Z = br.ReadSingle();
mesh.m_obboffset.X = br.ReadSingle();
mesh.m_obboffset.Y = br.ReadSingle();
mesh.m_obboffset.Z = br.ReadSingle();
}
catch
{
ok = false;
}
}
catch
{
ok = false;
}
br.Close();
if (ok)
{

View File

@ -60,7 +60,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
private bool m_Enabled = false;
public object diskLock = new object();
public static object diskLock = new object();
public bool doMeshFileCache = true;
@ -1426,13 +1426,13 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
{
if (File.Exists(filename))
{
FileStream stream = null;
try
{
stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryFormatter bformatter = new BinaryFormatter();
mesh = Mesh.FromStream(stream, key);
using(FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
{
// BinaryFormatter bformatter = new BinaryFormatter();
mesh = Mesh.FromStream(stream,key);
}
}
catch (Exception e)
@ -1443,13 +1443,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
filename, e.Message, e.StackTrace);
}
if (stream != null)
stream.Close();
try
{
if (mesh == null || !ok)
File.Delete(filename);
else
File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
}
catch
{
}
if (mesh == null || !ok)
File.Delete(filename);
else
File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
}
}
@ -1458,7 +1462,6 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
private void StoreToFileCache(AMeshKey key, Mesh mesh)
{
Stream stream = null;
bool ok = false;
// Make sure the target cache directory exists
@ -1476,8 +1479,8 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
Directory.CreateDirectory(dir);
}
stream = File.Open(filename, FileMode.Create);
ok = mesh.ToStream(stream);
using(Stream stream = File.Open(filename, FileMode.Create))
ok = mesh.ToStream(stream);
}
catch (IOException e)
{
@ -1487,15 +1490,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
ok = false;
}
if (stream != null)
stream.Close();
if (File.Exists(filename))
if (!ok && File.Exists(filename))
{
if (ok)
File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
else
try
{
File.Delete(filename);
}
catch (IOException e)
{
m_log.ErrorFormat(
"[MESH CACHE]: Failed to delete file {0}",filename);
}
}
}
}

View File

@ -588,6 +588,7 @@ namespace OpenSim.Services.LLLoginService
List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
if (defaults != null && defaults.Count > 0)
{
flags |= TeleportFlags.ViaRegionID;
region = defaults[0];
where = "safe";
}
@ -597,7 +598,10 @@ namespace OpenSim.Services.LLLoginService
account.FirstName, account.LastName);
region = FindAlternativeRegion(scopeID);
if (region != null)
{
flags |= TeleportFlags.ViaRegionID;
where = "safe";
}
}
}
@ -618,6 +622,7 @@ namespace OpenSim.Services.LLLoginService
List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
if (defaults != null && defaults.Count > 0)
{
flags |= TeleportFlags.ViaRegionID;
region = defaults[0];
where = "safe";
}
@ -626,7 +631,10 @@ namespace OpenSim.Services.LLLoginService
m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
region = FindAlternativeRegion(scopeID);
if (region != null)
{
flags |= TeleportFlags.ViaRegionID;
where = "safe";
}
}
}