Merge branch 'master' into httptests

httptests
UbitUmarov 2016-09-03 07:51:53 +01:00
commit 9aec227767
93 changed files with 2221 additions and 1646 deletions

View File

@ -486,7 +486,7 @@ namespace OpenSim.Groups
// check permissions
bool limited = HasPower(RequestingAgentID, GroupID, GroupPowers.AssignMemberLimited);
bool unlimited = HasPower(RequestingAgentID, GroupID, GroupPowers.AssignMember) | IsOwner(RequestingAgentID, GroupID);
if (!limited || !unlimited)
if (!limited && !unlimited)
{
m_log.DebugFormat("[Groups]: ({0}) Attempt at assigning {1} to role {2} denied because of lack of permission", RequestingAgentID, AgentID, RoleID);
return false;

View File

@ -354,9 +354,9 @@ namespace OpenSim.Capabilities.Handlers
byte[] data = new byte[0];
MemoryStream imgstream = new MemoryStream();
Bitmap mTexture = new Bitmap(1, 1);
ManagedImage managedImage;
Image image = (Image)mTexture;
Bitmap mTexture = null;
ManagedImage managedImage = null;
Image image = null;
try
{
@ -365,25 +365,26 @@ namespace OpenSim.Capabilities.Handlers
imgstream = new MemoryStream();
// Decode image to System.Drawing.Image
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image))
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
{
// Save to bitmap
mTexture = new Bitmap(image);
EncoderParameters myEncoderParameters = new EncoderParameters();
myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L);
// Save bitmap to stream
ImageCodecInfo codec = GetEncoderInfo("image/" + format);
if (codec != null)
using(EncoderParameters myEncoderParameters = new EncoderParameters())
{
mTexture.Save(imgstream, codec, myEncoderParameters);
// Write the stream to a byte array for output
data = imgstream.ToArray();
}
else
m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format);
myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality,95L);
// Save bitmap to stream
ImageCodecInfo codec = GetEncoderInfo("image/" + format);
if (codec != null)
{
mTexture.Save(imgstream, codec, myEncoderParameters);
// Write the stream to a byte array for output
data = imgstream.ToArray();
}
else
m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format);
}
}
}
catch (Exception e)
@ -399,7 +400,9 @@ namespace OpenSim.Capabilities.Handlers
if (image != null)
image.Dispose();
if(managedImage != null)
managedImage.Clear();
if (imgstream != null)
{
imgstream.Close();

View File

@ -359,9 +359,9 @@ namespace OpenSim.Capabilities.Handlers
byte[] data = new byte[0];
MemoryStream imgstream = new MemoryStream();
Bitmap mTexture = new Bitmap(1, 1);
ManagedImage managedImage;
Image image = (Image)mTexture;
Bitmap mTexture = null;
ManagedImage managedImage = null;
Image image = null;
try
{
@ -370,25 +370,26 @@ namespace OpenSim.Capabilities.Handlers
imgstream = new MemoryStream();
// Decode image to System.Drawing.Image
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image))
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
{
// Save to bitmap
mTexture = new Bitmap(image);
EncoderParameters myEncoderParameters = new EncoderParameters();
myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L);
// Save bitmap to stream
ImageCodecInfo codec = GetEncoderInfo("image/" + format);
if (codec != null)
using(EncoderParameters myEncoderParameters = new EncoderParameters())
{
mTexture.Save(imgstream, codec, myEncoderParameters);
// Write the stream to a byte array for output
data = imgstream.ToArray();
}
else
m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format);
myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality,95L);
// Save bitmap to stream
ImageCodecInfo codec = GetEncoderInfo("image/" + format);
if (codec != null)
{
mTexture.Save(imgstream, codec, myEncoderParameters);
// Write the stream to a byte array for output
data = imgstream.ToArray();
}
else
m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format);
}
}
}
catch (Exception e)
@ -405,6 +406,9 @@ namespace OpenSim.Capabilities.Handlers
if (image != null)
image.Dispose();
if(managedImage != null)
managedImage.Clear();
if (imgstream != null)
{
imgstream.Close();

View File

@ -61,6 +61,9 @@ namespace OpenSim.Framework.Capabilities
// OpenMetaverse.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request));
Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request);
if(hash == null)
return new byte[0];
TRequest llsdRequest = new TRequest();
LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest);

View File

@ -316,15 +316,16 @@ namespace OpenSim.Data.MySQL
return 0;
}
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table);
using (IDataReader reader = cmd.ExecuteReader())
using(MySqlCommand cmd = conn.CreateCommand())
{
reader.Read();
cmd.CommandText = String.Format("select count(*) as count from {0}",m_Table);
count = Convert.ToInt32(reader["count"]);
using (IDataReader reader = cmd.ExecuteReader())
{
reader.Read();
count = Convert.ToInt32(reader["count"]);
}
}
}
@ -333,15 +334,15 @@ namespace OpenSim.Data.MySQL
public bool Delete(string id)
{
MySqlCommand cmd = new MySqlCommand();
using(MySqlCommand cmd = new MySqlCommand())
{
cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table);
cmd.CommandText = String.Format("delete from {0} where id = ?id",m_Table);
cmd.Parameters.AddWithValue("?id", id);
cmd.Parameters.AddWithValue("?id", id);
ExecuteNonQuery(cmd);
cmd.Dispose();
ExecuteNonQuery(cmd);
}
return true;
}

View File

@ -440,37 +440,39 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon);
cmd.Parameters.AddWithValue("?start", start);
cmd.Parameters.AddWithValue("?count", count);
try
using(MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count",dbcon))
{
using (MySqlDataReader dbReader = cmd.ExecuteReader())
cmd.Parameters.AddWithValue("?start",start);
cmd.Parameters.AddWithValue("?count", count);
try
{
while (dbReader.Read())
using (MySqlDataReader dbReader = cmd.ExecuteReader())
{
AssetMetadata metadata = new AssetMetadata();
metadata.Name = (string)dbReader["Name"];
metadata.Description = (string)dbReader["Description"];
metadata.Type = (sbyte)dbReader["AssetType"];
metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
metadata.CreatorID = dbReader["CreatorID"].ToString();
while (dbReader.Read())
{
AssetMetadata metadata = new AssetMetadata();
metadata.Name = (string)dbReader["Name"];
metadata.Description = (string)dbReader["Description"];
metadata.Type = (sbyte)dbReader["AssetType"];
metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
metadata.CreatorID = dbReader["CreatorID"].ToString();
// We'll ignore this for now - it appears unused!
// metadata.SHA1 = dbReader["hash"]);
// We'll ignore this for now - it appears unused!
// metadata.SHA1 = dbReader["hash"]);
UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
retList.Add(metadata);
retList.Add(metadata);
}
}
}
}
catch (Exception e)
{
m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
catch (Exception e)
{
m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
}
}
}

View File

@ -518,40 +518,42 @@ namespace OpenSim.Data.PGSQL
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
{
dbcon.Open();
NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid
using(NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid
FROM XAssetsMeta
LIMIT :start, :count", dbcon);
cmd.Parameters.Add(m_database.CreateParameter("start", start));
cmd.Parameters.Add(m_database.CreateParameter("count", count));
try
LIMIT :start, :count",dbcon))
{
using (NpgsqlDataReader dbReader = cmd.ExecuteReader())
cmd.Parameters.Add(m_database.CreateParameter("start",start));
cmd.Parameters.Add(m_database.CreateParameter("count", count));
try
{
while (dbReader.Read())
using (NpgsqlDataReader dbReader = cmd.ExecuteReader())
{
AssetMetadata metadata = new AssetMetadata();
metadata.Name = (string)dbReader["name"];
metadata.Description = (string)dbReader["description"];
metadata.Type = Convert.ToSByte(dbReader["AssetType"]);
metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]);
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
metadata.FullID = DBGuid.FromDB(dbReader["id"]);
metadata.CreatorID = dbReader["creatorid"].ToString();
while (dbReader.Read())
{
AssetMetadata metadata = new AssetMetadata();
metadata.Name = (string)dbReader["name"];
metadata.Description = (string)dbReader["description"];
metadata.Type = Convert.ToSByte(dbReader["AssetType"]);
metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]);
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
metadata.FullID = DBGuid.FromDB(dbReader["id"]);
metadata.CreatorID = dbReader["creatorid"].ToString();
// We'll ignore this for now - it appears unused!
// metadata.SHA1 = dbReader["hash"]);
// We'll ignore this for now - it appears unused!
// metadata.SHA1 = dbReader["hash"]);
UpdateAccessTime(metadata, (int)dbReader["access_time"]);
UpdateAccessTime(metadata, (int)dbReader["access_time"]);
retList.Add(metadata);
retList.Add(metadata);
}
}
}
}
catch (Exception e)
{
m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString());
}
catch (Exception e)
{
m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString());
}
}
}
}

View File

@ -117,7 +117,7 @@ namespace OpenSim.Framework
public delegate void ObjectExtraParams(UUID agentID, uint localID, ushort type, bool inUse, byte[] data);
public delegate void ObjectSelect(uint localID, IClientAPI remoteClient);
public delegate void ObjectSelect(List<uint> localID, IClientAPI remoteClient);
public delegate void ObjectRequest(uint localID, IClientAPI remoteClient);
@ -1382,6 +1382,8 @@ namespace OpenSim.Framework
void SendObjectPropertiesReply(ISceneEntity Entity);
void SendSelectedPartsProprieties(List<ISceneEntity> parts);
void SendPartPhysicsProprieties(ISceneEntity Entity);
void SendAgentOffline(UUID[] agentIDs);

View File

@ -132,8 +132,8 @@ namespace OpenSim.Framework.Monitoring
/// <returns></returns>
public static bool RegisterCheck(Check check)
{
SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory;
SortedDictionary<string, Check> container = null, newContainer;
SortedDictionary<string, SortedDictionary<string, Check>> category = null;
SortedDictionary<string, Check> container = null;
lock (RegisteredChecks)
{
@ -146,19 +146,15 @@ namespace OpenSim.Framework.Monitoring
// We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
// This means that we don't need to lock or copy them on iteration, which will be a much more
// common operation after startup.
if (container != null)
newContainer = new SortedDictionary<string, Check>(container);
else
newContainer = new SortedDictionary<string, Check>();
if (container == null)
container = new SortedDictionary<string, Check>();
if (category != null)
newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category);
else
newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>();
if (category == null)
category = new SortedDictionary<string, SortedDictionary<string, Check>>();
newContainer[check.ShortName] = check;
newCategory[check.Container] = newContainer;
RegisteredChecks[check.Category] = newCategory;
container[check.ShortName] = check;
category[check.Container] = container;
RegisteredChecks[check.Category] = category;
}
return true;
@ -171,23 +167,24 @@ namespace OpenSim.Framework.Monitoring
/// <returns></returns>
public static bool DeregisterCheck(Check check)
{
SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory;
SortedDictionary<string, Check> container = null, newContainer;
SortedDictionary<string, SortedDictionary<string, Check>> category = null;
SortedDictionary<string, Check> container = null;
lock (RegisteredChecks)
{
if (!TryGetCheckParents(check, out category, out container))
return false;
newContainer = new SortedDictionary<string, Check>(container);
newContainer.Remove(check.ShortName);
newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category);
newCategory.Remove(check.Container);
newCategory[check.Container] = newContainer;
RegisteredChecks[check.Category] = newCategory;
if(container != null)
{
container.Remove(check.ShortName);
if(category != null && container.Count == 0)
{
category.Remove(check.Container);
if(category.Count == 0)
RegisteredChecks.Remove(check.Category);
}
}
return true;
}
}

View File

@ -80,8 +80,7 @@ namespace OpenSim.Framework.Monitoring
+ "'all' will show all statistics.\n"
+ "A <category> name will show statistics from that category.\n"
+ "A <category>.<container> name will show statistics from that category in that container.\n"
+ "More than one name can be given separated by spaces.\n"
+ "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS",
+ "More than one name can be given separated by spaces.\n",
HandleShowStatsCommand);
console.Commands.AddCommand(
@ -91,7 +90,6 @@ namespace OpenSim.Framework.Monitoring
"show stats [list|all|(<category>[.<container>])+",
"Alias for 'stats show' command",
HandleShowStatsCommand);
StatsLogger.RegisterConsoleCommands(console);
}
@ -361,8 +359,8 @@ namespace OpenSim.Framework.Monitoring
/// <returns></returns>
public static bool RegisterStat(Stat stat)
{
SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory;
SortedDictionary<string, Stat> container = null, newContainer;
SortedDictionary<string, SortedDictionary<string, Stat>> category = null;
SortedDictionary<string, Stat> container = null;
lock (RegisteredStats)
{
@ -372,22 +370,15 @@ namespace OpenSim.Framework.Monitoring
if (TryGetStatParents(stat, out category, out container))
return false;
// We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
// This means that we don't need to lock or copy them on iteration, which will be a much more
// common operation after startup.
if (container != null)
newContainer = new SortedDictionary<string, Stat>(container);
else
newContainer = new SortedDictionary<string, Stat>();
if (container == null)
container = new SortedDictionary<string, Stat>();
if (category != null)
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category);
else
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>();
if (category == null)
category = new SortedDictionary<string, SortedDictionary<string, Stat>>();
newContainer[stat.ShortName] = stat;
newCategory[stat.Container] = newContainer;
RegisteredStats[stat.Category] = newCategory;
container[stat.ShortName] = stat;
category[stat.Container] = container;
RegisteredStats[stat.Category] = category;
}
return true;
@ -400,23 +391,24 @@ namespace OpenSim.Framework.Monitoring
/// <returns></returns>
public static bool DeregisterStat(Stat stat)
{
SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory;
SortedDictionary<string, Stat> container = null, newContainer;
SortedDictionary<string, SortedDictionary<string, Stat>> category = null;
SortedDictionary<string, Stat> container = null;
lock (RegisteredStats)
{
if (!TryGetStatParents(stat, out category, out container))
return false;
newContainer = new SortedDictionary<string, Stat>(container);
newContainer.Remove(stat.ShortName);
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category);
newCategory.Remove(stat.Container);
newCategory[stat.Container] = newContainer;
RegisteredStats[stat.Category] = newCategory;
if(container != null)
{
container.Remove(stat.ShortName);
if(category != null && container.Count == 0)
{
category.Remove(stat.Container);
if(category.Count == 0)
RegisteredStats.Remove(stat.Category);
}
}
return true;
}
}

View File

@ -332,18 +332,18 @@ namespace OpenSim.Framework.Monitoring
if (callback != null)
{
List<ThreadWatchdogInfo> callbackInfos = null;
List<ThreadWatchdogInfo> threadsInfo;
List<ThreadWatchdogInfo> threadsToRemove = null;
lock (m_threads)
{
// get a copy since we may change m_threads
threadsInfo = m_threads.Values.ToList();
foreach(ThreadWatchdogInfo threadInfo in threadsInfo)
foreach(ThreadWatchdogInfo threadInfo in m_threads.Values)
{
if(threadInfo.Thread.ThreadState == ThreadState.Stopped)
{
RemoveThread(threadInfo.Thread.ManagedThreadId);
if(threadsToRemove == null)
threadsToRemove = new List<ThreadWatchdogInfo>();
threadsToRemove.Add(threadInfo);
if(callbackInfos == null)
callbackInfos = new List<ThreadWatchdogInfo>();
@ -365,6 +365,10 @@ namespace OpenSim.Framework.Monitoring
}
}
}
if(threadsToRemove != null)
foreach(ThreadWatchdogInfo twi in threadsToRemove)
RemoveThread(twi.Thread.ManagedThreadId);
}
if(callbackInfos != null)

View File

@ -461,8 +461,8 @@ namespace OpenSim.Framework.Servers.HttpServer
}
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
// resp.ReuseContext = true;
resp.ReuseContext = false;
resp.ReuseContext = true;
// resp.ReuseContext = false;
HandleRequest(req, resp);
// !!!HACK ALERT!!!

View File

@ -842,7 +842,7 @@ namespace OpenSim.Framework.Servers
{
StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
buildVersion = RevisionFile.ReadLine();
buildVersion.Trim();
buildVersion = buildVersion.Trim();
RevisionFile.Close();
}

View File

@ -705,8 +705,10 @@ namespace OpenSim.Framework
private static byte[] ComputeSHA1Hash(byte[] src)
{
SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
return SHA1.ComputeHash(src);
byte[] ret;
using(SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider())
ret = SHA1.ComputeHash(src);
return ret;
}
public static int fast_distance2d(int x, int y)

View File

@ -2801,6 +2801,48 @@ namespace OpenSim.Region.ClientStack.LindenUDP
SendAgentGroupDataUpdate(AgentId,GroupMembership);
}
public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
{
// udp part
ObjectPropertiesPacket packet =
(ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
ObjectPropertiesPacket.ObjectDataBlock[] ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[parts.Count];
int i = 0;
foreach(SceneObjectPart sop in parts)
ObjectData[i++] = CreateObjectPropertiesBlock(sop);
packet.ObjectData = ObjectData;
packet.Header.Zerocoded = true;
// udp send splits this mega packets correctly
// mb later will avoid that to reduce gc stress
OutPacket(packet, ThrottleOutPacketType.Task, true);
// caps physics part
IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
if(eq == null)
return;
OSDArray array = new OSDArray();
foreach(SceneObjectPart sop in parts)
{
OSDMap physinfo = new OSDMap(6);
physinfo["LocalID"] = sop.LocalId;
physinfo["Density"] = sop.Density;
physinfo["Friction"] = sop.Friction;
physinfo["GravityMultiplier"] = sop.GravityModifier;
physinfo["Restitution"] = sop.Restitution;
physinfo["PhysicsShapeType"] = (int)sop.PhysicsShapeType;
array.Add(physinfo);
}
OSDMap llsdBody = new OSDMap(1);
llsdBody.Add("ObjectData", array);
eq.Enqueue(BuildEvent("ObjectPhysicsProperties", llsdBody),AgentId);
}
public void SendPartPhysicsProprieties(ISceneEntity entity)
{
SceneObjectPart part = (SceneObjectPart)entity;
@ -2882,18 +2924,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendAsset(AssetRequestToClient req)
{
if (req.AssetInf == null)
{
m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset is null",
LogHeader);
return;
}
if (req.AssetInf.Data == null)
{
m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset data is null",
LogHeader, req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
return;
}
int WearableOut = 0;
bool isWearable = false;
if (req.AssetInf != null)
isWearable =
((AssetType) req.AssetInf.Type ==
isWearable = ((AssetType) req.AssetInf.Type ==
AssetType.Bodypart || (AssetType) req.AssetInf.Type == AssetType.Clothing);
@ -3013,7 +3061,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
reply.Data.ParcelID = parcelID;
reply.Data.OwnerID = land.OwnerID;
reply.Data.Name = Utils.StringToBytes(land.Name);
if (land != null && land.Description != null && land.Description != String.Empty)
if (land.Description != null && land.Description != String.Empty)
reply.Data.Desc = Utils.StringToBytes(land.Description.Substring(0, land.Description.Length > 254 ? 254: land.Description.Length));
else
reply.Data.Desc = new Byte[0];
@ -4221,46 +4269,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!canUseImproved && !canUseCompressed)
{
ObjectUpdatePacket.ObjectDataBlock ablock;
if (update.Entity is ScenePresence)
{
ObjectUpdatePacket.ObjectDataBlock ablock =
CreateAvatarUpdateBlock((ScenePresence)update.Entity);
objectUpdateBlocks.Value.Add(ablock);
maxUpdatesBytes -= ablock.Length;
}
ablock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
else
{
ObjectUpdatePacket.ObjectDataBlock ablock =
CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId);
objectUpdateBlocks.Value.Add(ablock);
maxUpdatesBytes -= ablock.Length;
}
ablock = CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId);
objectUpdateBlocks.Value.Add(ablock);
objectUpdates.Value.Add(update);
maxUpdatesBytes -= ablock.Length;
}
else if (!canUseImproved)
{
ObjectUpdateCompressedPacket.ObjectDataBlock ablock =
CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags);
compressedUpdateBlocks.Value.Add(ablock);
compressedUpdates.Value.Add(update);
maxUpdatesBytes -= ablock.Length;
}
else
{
ImprovedTerseObjectUpdatePacket.ObjectDataBlock ablock;
if (update.Entity is ScenePresence)
{
// ALL presence updates go into a special list
ImprovedTerseObjectUpdatePacket.ObjectDataBlock ablock =
CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
ablock = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
terseAgentUpdateBlocks.Value.Add(ablock);
maxUpdatesBytes -= ablock.Length;
terseAgentUpdates.Value.Add(update);
}
else
{
// Everything else goes here
ImprovedTerseObjectUpdatePacket.ObjectDataBlock ablock =
CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
ablock = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
terseUpdateBlocks.Value.Add(ablock);
maxUpdatesBytes -= ablock.Length;
terseUpdates.Value.Add(update);
}
maxUpdatesBytes -= ablock.Length;
}
#endregion Block Construction
@ -4290,7 +4334,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
for (int i = 0; i < blocks.Count; i++)
packet.ObjectData[i] = blocks[i];
OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
}
if (objectUpdateBlocks.IsValueCreated)
@ -4305,7 +4349,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
for (int i = 0; i < blocks.Count; i++)
packet.ObjectData[i] = blocks[i];
OutPacket(packet, ThrottleOutPacketType.Task, true);
OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
}
if (compressedUpdateBlocks.IsValueCreated)
@ -4320,7 +4364,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
for (int i = 0; i < blocks.Count; i++)
packet.ObjectData[i] = blocks[i];
OutPacket(packet, ThrottleOutPacketType.Task, true);
OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
}
if (terseUpdateBlocks.IsValueCreated)
@ -5444,22 +5488,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Quaternion rotation;
byte[] textureEntry;
if (entity is ScenePresence)
if (avatar)
{
ScenePresence presence = (ScenePresence)entity;
position = presence.OffsetPosition;
velocity = presence.Velocity;
acceleration = Vector3.Zero;
rotation = presence.Rotation;
angularVelocity = presence.AngularVelocity;
rotation = presence.Rotation;
// m_log.DebugFormat(
// "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
attachPoint = presence.State;
collisionPlane = presence.CollisionPlane;
velocity = presence.Velocity;
acceleration = Vector3.Zero;
if (sendTexture)
{
@ -7710,20 +7753,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return true;
}
#endregion
List<uint> thisSelection = new List<uint>();
ObjectSelect handlerObjectSelect = null;
uint objID;
for (int i = 0; i < incomingselect.ObjectData.Length; i++)
handlerObjectSelect = OnObjectSelect;
if (handlerObjectSelect != null)
{
objID = incomingselect.ObjectData[i].ObjectLocalID;
if (!SelectedObjects.Contains(objID))
SelectedObjects.Add(objID);
handlerObjectSelect = OnObjectSelect;
if (handlerObjectSelect != null)
for (int i = 0; i < incomingselect.ObjectData.Length; i++)
{
handlerObjectSelect(objID, this);
objID = incomingselect.ObjectData[i].ObjectLocalID;
thisSelection.Add(objID);
}
handlerObjectSelect(thisSelection, this);
}
return true;
}
@ -7746,8 +7788,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
{
objID = incomingdeselect.ObjectData[i].ObjectLocalID;
if (SelectedObjects.Contains(objID))
SelectedObjects.Remove(objID);
handlerObjectDeselect = OnObjectDeselect;
if (handlerObjectDeselect != null)
@ -7969,6 +8009,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
touchArgs.Add(arg);
}
}
handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
grabUpdate.ObjectData.GrabPosition, this, touchArgs);
}
@ -12409,72 +12450,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="simclient"></param>
/// <param name="packet"></param>
/// <returns></returns>
// TODO: Convert old handler to use new method
/*
protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
{
AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
if (cachedtex.AgentData.SessionID != SessionId)
return false;
// TODO: don't create new blocks if recycling an old packet
cachedresp.AgentData.AgentID = AgentId;
cachedresp.AgentData.SessionID = m_sessionId;
cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
m_cachedTextureSerial++;
cachedresp.WearableData =
new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
int maxWearablesLoop = cachedtex.WearableData.Length;
if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
// Find the cached baked textures for this user, if they're available
IAssetService cache = m_scene.AssetService;
IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
WearableCacheItem[] cacheItems = null;
if (bakedTextureModule != null && cache != null)
{
ScenePresence p = m_scene.GetScenePresence(AgentId);
if (p.Appearance != null)
{
if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
{
try
{
cacheItems = bakedTextureModule.Get(AgentId);
p.Appearance.WearableCacheItems = cacheItems;
p.Appearance.WearableCacheItemsDirty = false;
}
catch (Exception)
{
cacheItems = null;
}
}
else if (p.Appearance.WearableCacheItems != null)
{
cacheItems = p.Appearance.WearableCacheItems;
}
}
}
CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
if (handlerCachedTextureRequest != null)
{
handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
}
return true;
}
*/
protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
{

View File

@ -124,20 +124,26 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
double now = Util.GetTimeStampMS();
if(now - lastTimeTick > 1750.0)
{
inTimeTick = true;
//don't overload busy heartbeat
WorkManager.RunInThread(
delegate
{
transfersTimeTick(now);
expireFiles(now);
if(Transfers.Count == 0 && NewFiles.Count == 0)
lastTimeTick = now;
inTimeTick = false;
},
null,
"XferTimeTick");
else
{
inTimeTick = true;
//don't overload busy heartbeat
WorkManager.RunInThreadPool(
delegate
{
transfersTimeTick(now);
expireFiles(now);
lastTimeTick = now;
inTimeTick = false;
},
null,
"XferTimeTick");
}
}
}
Monitor.Exit(timeTickLock);

View File

@ -594,8 +594,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
group.ResumeScripts();
}
else
// Do this last so that event listeners have access to all the effects of the attachment
m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID);
// this can't be done when creating scripts:
// scripts do internal enqueue of attach event
// and not all scripts are loaded at this point
m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID);
}
return true;
@ -1053,7 +1057,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (fireDetachEvent)
{
m_scene.EventManager.TriggerOnAttach(grp.LocalId, grp.FromItemID, UUID.Zero);
// Allow detach event time to do some work before stopping the script
Thread.Sleep(2);
}
@ -1115,13 +1118,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
SceneObjectGroup objatt;
UUID rezGroupID = sp.ControllingClient.ActiveGroupId;
if (itemID != UUID.Zero)
objatt = m_invAccessModule.RezObject(sp.ControllingClient,
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
itemID, rezGroupID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, sp.UUID, true);
else
objatt = m_invAccessModule.RezObject(sp.ControllingClient,
null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
objatt = m_invAccessModule.RezObject(sp.ControllingClient,
null, rezGroupID, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, sp.UUID, true);
if (objatt == null)
@ -1318,7 +1323,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
AttachmentPt &= 0x7f;
// Calls attach with a Zero position
if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, append))
SceneObjectGroup group = part.ParentGroup;
if (AttachObject(sp, group , AttachmentPt, false, true, append))
{
if (DebugLevel > 0)
m_log.Debug(
@ -1377,7 +1383,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (sp != null)
DetachSingleAttachmentToGround(sp, soLocalId);
}
#endregion
}
}

View File

@ -55,6 +55,7 @@ using OpenSim.Tests.Common;
namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
{
/*
/// <summary>
/// Attachment tests
/// </summary>
@ -804,7 +805,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
}
/*
[Test]
public void TestSameSimulatorNeighbouringRegionsTeleportV1()
{
@ -844,7 +845,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());
// FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
lscm.ServiceVersion = 0.1f;
//lscm.ServiceVersion = 0.1f;
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
@ -912,7 +913,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
// Check events
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
}
*/
[Test]
public void TestSameSimulatorNeighbouringRegionsTeleportV2()
@ -1025,4 +1026,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
}
}
*/
}

View File

@ -324,15 +324,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
if (destinationFolderID != UUID.Zero)
{
InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId);
if (destinationFolder == null)
{
m_log.WarnFormat(
"[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist",
client.Name, scene.Name, destinationFolderID);
return;
}
IInventoryService invService = scene.InventoryService;
UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip

View File

@ -31,6 +31,7 @@ using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
@ -458,36 +459,43 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
int queryclassifiedPrice, IClientAPI remoteClient)
{
Scene s = (Scene)remoteClient.Scene;
IMoneyModule money = s.RequestModuleInterface<IMoneyModule>();
Vector3 pos = remoteClient.SceneAgent.AbsolutePosition;
ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y);
UUID creatorId = remoteClient.AgentId;
ScenePresence p = FindPresence(creatorId);
if (money != null)
string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}};
OSD Params = (OSD)parameters;
if (!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString()))
{
if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice))
remoteClient.SendAgentAlertMessage("Error fetching classifieds", false);
return;
}
parameters = (OSDMap)Params;
OSDArray list = (OSDArray)parameters["result"];
bool exists = list.Cast<OSDMap>().Where(map => map.ContainsKey("classifieduuid"))
.Any(map => map["classifieduuid"].AsUUID().Equals(queryclassifiedID));
if (!exists)
{
IMoneyModule money = s.RequestModuleInterface<IMoneyModule>();
if (money != null)
{
remoteClient.SendAgentAlertMessage("You do not have enough money to create requested classified.", false);
return;
if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice))
{
remoteClient.SendAgentAlertMessage("You do not have enough money to create this classified.", false);
return;
}
money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);
}
money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);
}
UserClassifiedAdd ad = new UserClassifiedAdd();
Vector3 pos = remoteClient.SceneAgent.AbsolutePosition;
ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y);
ScenePresence p = FindPresence(remoteClient.AgentId);
string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if (land == null)
{
ad.ParcelName = string.Empty;
}
else
{
ad.ParcelName = land.LandData.Name;
}
ad.ParcelName = land == null ? string.Empty : land.LandData.Name;
ad.CreatorId = remoteClient.AgentId;
ad.ClassifiedId = queryclassifiedID;
ad.Category = Convert.ToInt32(queryCategory);
@ -507,9 +515,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString()))
{
remoteClient.SendAgentAlertMessage(
"Error updating classified", false);
return;
remoteClient.SendAgentAlertMessage("Error updating classified", false);
}
}

View File

@ -478,9 +478,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
sp.ControllingClient.SendTeleportStart(teleportFlags);
lookAt.Z = 0f;
if(Math.Abs(lookAt.X) < 0.01f && Math.Abs(lookAt.Y) < 0.01f)
{
lookAt.X = 1.0f;
lookAt.Y = 0;
}
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags;
sp.RotateToLookAt(lookAt);
sp.Velocity = Vector3.Zero;
sp.Teleport(position);

View File

@ -261,64 +261,60 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{
InventoryItemBase item = m_Scene.InventoryService.GetItem(remoteClient.AgentId, itemID);
if (item == null)
{
m_log.ErrorFormat(
"[INVENTORY ACCESS MODULE]: Could not find item {0} for caps inventory update", itemID);
return UUID.Zero;
}
if (item.Owner != remoteClient.AgentId)
return UUID.Zero;
if (item != null)
if ((InventoryType)item.InvType == InventoryType.Notecard)
{
if ((InventoryType)item.InvType == InventoryType.Notecard)
if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
{
if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
return UUID.Zero;
}
remoteClient.SendAlertMessage("Notecard saved");
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
return UUID.Zero;
}
else if ((InventoryType)item.InvType == InventoryType.LSL)
{
if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
return UUID.Zero;
}
remoteClient.SendAlertMessage("Script saved");
}
else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet)
remoteClient.SendAlertMessage("Notecard saved");
}
else if ((InventoryType)item.InvType == InventoryType.LSL)
{
if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
{
AnimationSet animSet = new AnimationSet(data);
if (!animSet.Validate(x => {
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
return UUID.Zero;
}
remoteClient.SendAlertMessage("Script saved");
}
else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet)
{
AnimationSet animSet = new AnimationSet(data);
if (!animSet.Validate(x => {
int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x);
int required = (int)(PermissionMask.Transfer | PermissionMask.Copy);
if ((perms & required) != required)
return false;
return true;
}))
{
data = animSet.ToBytes();
}
{
data = animSet.ToBytes();
}
AssetBase asset =
CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString());
item.AssetID = asset.FullID;
m_Scene.AssetService.Store(asset);
m_Scene.InventoryService.UpdateItem(item);
// remoteClient.SendInventoryItemCreateUpdate(item);
return (asset.FullID);
}
else
{
m_log.ErrorFormat(
"[INVENTORY ACCESS MODULE]: Could not find item {0} for caps inventory update",
itemID);
}
return UUID.Zero;
AssetBase asset =
CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString());
item.AssetID = asset.FullID;
m_Scene.AssetService.Store(asset);
m_Scene.InventoryService.UpdateItem(item);
// remoteClient.SendInventoryItemCreateUpdate(item);
return (asset.FullID);
}
public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset)

View File

@ -553,37 +553,44 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
ManagedImage managedImage;
Image image;
if (OpenJPEG.DecodeToImage(frontImage, out managedImage, out image))
if (!OpenJPEG.DecodeToImage(frontImage, out managedImage, out image) || image == null)
return null;
Bitmap image1 = new Bitmap(image);
image.Dispose();
if (!OpenJPEG.DecodeToImage(backImage, out managedImage, out image) || image == null)
{
Bitmap image1 = new Bitmap(image);
if (OpenJPEG.DecodeToImage(backImage, out managedImage, out image))
{
Bitmap image2 = new Bitmap(image);
if (setNewAlpha)
SetAlpha(ref image1, newAlpha);
Bitmap joint = MergeBitMaps(image1, image2);
byte[] result = new byte[0];
try
{
result = OpenJPEG.EncodeFromImage(joint, true);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[DYNAMICTEXTUREMODULE]: OpenJpeg Encode Failed. Exception {0}{1}",
e.Message, e.StackTrace);
}
return result;
}
image1.Dispose();
return null;
}
return null;
Bitmap image2 = new Bitmap(image);
image.Dispose();
if (setNewAlpha)
SetAlpha(ref image1, newAlpha);
using(Bitmap joint = MergeBitMaps(image1, image2))
{
image1.Dispose();
image2.Dispose();
byte[] result = new byte[0];
try
{
result = OpenJPEG.EncodeFromImage(joint, true);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[DYNAMICTEXTUREMODULE]: OpenJpeg Encode Failed. Exception {0}{1}",
e.Message, e.StackTrace);
}
return result;
}
}
public Bitmap MergeBitMaps(Bitmap front, Bitmap back)
@ -592,12 +599,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
Graphics jG;
joint = new Bitmap(back.Width, back.Height, PixelFormat.Format32bppArgb);
jG = Graphics.FromImage(joint);
jG.DrawImage(back, 0, 0, back.Width, back.Height);
jG.DrawImage(front, 0, 0, back.Width, back.Height);
return joint;
using(jG = Graphics.FromImage(joint))
{
jG.DrawImage(back, 0, 0, back.Width, back.Height);
jG.DrawImage(front, 0, 0, back.Width, back.Height);
return joint;
}
}
private void SetAlpha(ref Bitmap b, byte alpha)

View File

@ -559,9 +559,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
return coll[0].GetHandle();
}
if (m_curlisteners < m_maxlisteners)
lock (m_listeners)
{
lock (m_listeners)
if (m_curlisteners < m_maxlisteners)
{
int newHandle = GetNewHandle(itemID);

View File

@ -126,13 +126,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land
public LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess)
{
m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {1}",
regionHandle, m_Scenes.Count);
// m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {1}",
// regionHandle, m_Scenes.Count);
uint rx = 0, ry = 0;
Util.RegionHandleToWorldLoc(regionHandle, out rx, out ry);
foreach (Scene s in m_Scenes)
{
if (s.RegionInfo.RegionHandle == regionHandle)
uint t = s.RegionInfo.WorldLocX;
if( rx < t)
continue;
t += s.RegionInfo.RegionSizeX;
if( rx >= t)
continue;
t = s.RegionInfo.WorldLocY;
if( ry < t)
continue;
t += s.RegionInfo.RegionSizeY;
if( ry < t)
{
m_log.Debug("[LAND IN CONNECTOR]: Found region to GetLandData from");
// m_log.Debug("[LAND IN CONNECTOR]: Found region to GetLandData from");
regionAccess = s.RegionInfo.AccessLevel;
return s.GetLandData(x, y);
}

View File

@ -367,12 +367,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
if (String.IsNullOrEmpty(id))
return string.Empty;
asset.ID = id;
if(asset.ID != id)
{
asset.ID = id;
if (m_Cache != null)
m_Cache.Cache(asset);
}
if (isHG && m_Cache != null)
m_Cache.Cache(asset);
return id;
return id;
}
public bool UpdateContent(string id, byte[] data)

View File

@ -121,12 +121,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
public LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess)
{
regionAccess = 2;
m_log.DebugFormat("[LAND CONNECTOR]: request for land data in {0} at {1}, {2}",
regionHandle, x, y);
// m_log.DebugFormat("[LAND CONNECTOR]: request for land data in {0} at {1}, {2}",
// regionHandle, x, y);
uint rx = 0, ry = 0;
Util.RegionHandleToWorldLoc(regionHandle, out rx, out ry);
foreach (Scene s in m_Scenes)
{
if (s.RegionInfo.RegionHandle == regionHandle)
uint t = s.RegionInfo.WorldLocX;
if( rx < t)
continue;
t += s.RegionInfo.RegionSizeX;
if( rx >= t)
continue;
t = s.RegionInfo.WorldLocY;
if( ry < t)
continue;
t += s.RegionInfo.RegionSizeY;
if( ry < t)
{
LandData land = s.GetLandData(x, y);
regionAccess = s.RegionInfo.AccessLevel;

View File

@ -1193,6 +1193,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
ControlFileLoaded = true;
if(xtr != null)
xtr.Close();
return dearchivedScenes;
}

View File

@ -1229,15 +1229,24 @@ namespace OpenSim.Region.CoreModules.World.Estate
}
terr.SaveToFile(Util.dataDir() + "/terrain.raw");
FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.Open);
byte[] bdata = new byte[input.Length];
input.Read(bdata, 0, (int)input.Length);
byte[] bdata;
using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open))
{
bdata = new byte[input.Length];
input.Read(bdata, 0, (int)input.Length);
}
if(bdata == null || bdata.Length == 0)
{
remote_client.SendAlertMessage("Terrain error");
return;
}
remote_client.SendAlertMessage("Terrain file written, starting download...");
Scene.XferManager.AddNewFile("terrain.raw", bdata);
string xfername = (UUID.Random()).ToString();
Scene.XferManager.AddNewFile(xfername, bdata);
m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
remote_client.SendInitiateDownload("terrain.raw", clientFileName);
remote_client.SendInitiateDownload(xfername, clientFileName);
}
}

View File

@ -382,7 +382,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
Vector3 pos = part.GetWorldPosition();
// skip prim outside of retion
// skip prim outside of region
if (!m_scene.PositionIsInCurrentRegion(pos))
continue;
@ -406,12 +406,13 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{
// Translate scale by rotation so scale is represented properly when object is rotated
Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
lscale *= 0.5f;
Vector3 scale = new Vector3();
Vector3 tScale = new Vector3();
Vector3 axPos = new Vector3(pos.X, pos.Y, pos.Z);
Quaternion llrot = part.GetWorldRotation();
Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
Quaternion rot = part.GetWorldRotation();
scale = lscale * rot;
// negative scales don't work in this situation
@ -470,7 +471,6 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[2].x = pos.X + vertexes[2].x;

View File

@ -47,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public override void SaveFile(string filename, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(filename, ImageFormat.Bmp);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(filename,ImageFormat.Bmp);
}
/// <summary>
@ -59,9 +58,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public override void SaveStream(Stream stream, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(stream, ImageFormat.Png);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(stream,ImageFormat.Bmp);
}
/// <summary>

View File

@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
public override void SaveFile(string filename, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(filename, ImageFormat.Gif);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(filename,ImageFormat.Gif);
}
/// <summary>
@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public override void SaveStream(Stream stream, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(stream, ImageFormat.Gif);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(stream,ImageFormat.Gif);
}
public override string ToString()

View File

@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <returns>A terrain channel generated from the image.</returns>
public virtual ITerrainChannel LoadFile(string filename)
{
using (Bitmap b = new Bitmap(filename))
using(Bitmap b = new Bitmap(filename))
return LoadBitmap(b);
}
@ -111,9 +111,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public virtual void SaveFile(string filename, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(filename, ImageFormat.Png);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(filename,ImageFormat.Png);
}
/// <summary>
@ -123,9 +122,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public virtual void SaveStream(Stream stream, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(stream, ImageFormat.Png);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(stream,ImageFormat.Png);
}
public virtual void SaveFile(ITerrainChannel m_channel, string filename,

View File

@ -59,9 +59,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
public void SaveFile(string filename, ITerrainChannel map)
{
Bitmap colours = CreateBitmapFromMap(map);
colours.Save(filename, ImageFormat.Jpeg);
using(Bitmap colours = CreateBitmapFromMap(map))
colours.Save(filename,ImageFormat.Jpeg);
}
/// <summary>
@ -71,9 +70,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public void SaveStream(Stream stream, ITerrainChannel map)
{
Bitmap colours = CreateBitmapFromMap(map);
colours.Save(stream, ImageFormat.Jpeg);
using(Bitmap colours = CreateBitmapFromMap(map))
colours.Save(stream,ImageFormat.Jpeg);
}
public virtual void SaveFile(ITerrainChannel m_channel, string filename,

View File

@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
public override void SaveFile(string filename, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(filename, ImageFormat.Png);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(filename,ImageFormat.Png);
}
/// <summary>
@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public override void SaveStream(Stream stream, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(stream, ImageFormat.Png);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(stream,ImageFormat.Png);
}
public override string ToString()

View File

@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
public override void SaveFile(string filename, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(filename, ImageFormat.Tiff);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(filename,ImageFormat.Tiff);
}
/// <summary>
@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
/// <param name="map">The terrain channel being saved</param>
public override void SaveStream(Stream stream, ITerrainChannel map)
{
Bitmap colours = CreateGrayscaleBitmapFromMap(map);
colours.Save(stream, ImageFormat.Tiff);
using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
colours.Save(stream,ImageFormat.Tiff);
}
public override string ToString()

View File

@ -963,6 +963,27 @@ namespace OpenSim.Region.CoreModules.World.Terrain
return wasLimited;
}
private bool EnforceEstateLimits(int startX, int startY, int endX, int endY)
{
TerrainData terrData = m_channel.GetTerrainData();
bool wasLimited = false;
for (int x = startX; x <= endX; x += Constants.TerrainPatchSize)
{
for (int y = startX; y <= endY; y += Constants.TerrainPatchSize)
{
if (terrData.IsTaintedAt(x, y, false /* clearOnTest */))
{
// If we should respect the estate settings then
// fixup and height deltas that don't respect them.
// Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values.
wasLimited |= LimitChannelChanges(terrData, x, y);
}
}
}
return wasLimited;
}
/// <summary>
/// Checks to see height deltas in the tainted terrain patch at xStart ,yStart
/// are all within the current estate limits
@ -1341,7 +1362,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
//block changes outside estate limits
if (!god)
EnforceEstateLimits();
EnforceEstateLimits(startX, endX, startY, endY);
}
}
else
@ -1404,7 +1425,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
//block changes outside estate limits
if (!god)
EnforceEstateLimits();
EnforceEstateLimits(startX, endX, startY, endY);
}
}
else

View File

@ -35,7 +35,7 @@ using System.Reflection;
using CSJ2K;
using Nini.Config;
using log4net;
using Rednettle.Warp3D;
using Warp3D;
using Mono.Addins;
using OpenSim.Framework;
@ -76,11 +76,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
private bool m_texturePrims = true; // true if should texture the rendered prims
private float m_texturePrimSize = 48f; // size of prim before we consider texturing it
private bool m_renderMeshes = false; // true if to render meshes rather than just bounding boxes
private bool m_useAntiAliasing = false; // true if to anti-alias the rendered image
private bool m_Enabled = false;
private Bitmap lastImage = null;
// private Bitmap lastImage = null;
private DateTime lastImageTime = DateTime.MinValue;
#region Region Module interface
@ -107,10 +106,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
= Util.GetConfigVarFromSections<float>(m_config, "TexturePrimSize", configSections, m_texturePrimSize);
m_renderMeshes
= Util.GetConfigVarFromSections<bool>(m_config, "RenderMeshes", configSections, m_renderMeshes);
m_useAntiAliasing
= Util.GetConfigVarFromSections<bool>(m_config, "UseAntiAliasing", configSections, m_useAntiAliasing);
}
}
public void AddRegion(Scene scene)
{
@ -201,21 +197,14 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
int width = viewport.Width;
int height = viewport.Height;
if (m_useAntiAliasing)
{
width *= 2;
height *= 2;
}
WarpRenderer renderer = new WarpRenderer();
renderer.CreateScene(width, height);
renderer.Scene.autoCalcNormals = false;
if(!renderer.CreateScene(width, height))
return new Bitmap(width,height);
#region Camera
warp_Vector pos = ConvertVector(viewport.Position);
pos.z -= 0.001f; // Works around an issue with the Warp3D camera
warp_Vector lookat = warp_Vector.add(ConvertVector(viewport.Position), ConvertVector(viewport.LookDirection));
renderer.Scene.defaultCamera.setPos(pos);
@ -223,9 +212,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
if (viewport.Orthographic)
{
renderer.Scene.defaultCamera.isOrthographic = true;
renderer.Scene.defaultCamera.orthoViewWidth = viewport.OrthoWindowWidth;
renderer.Scene.defaultCamera.orthoViewHeight = viewport.OrthoWindowHeight;
renderer.Scene.defaultCamera.setOrthographic(true,viewport.OrthoWindowWidth, viewport.OrthoWindowHeight);
}
else
{
@ -247,24 +234,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
renderer.Render();
Bitmap bitmap = renderer.Scene.getImage();
if (m_useAntiAliasing)
{
using (Bitmap origBitmap = bitmap)
bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height);
}
// XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly
// afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory
// then this may be some issue with the Warp3D code itself, though it's also quite possible that generating
// this map tile simply takes a lot of memory.
foreach (var o in renderer.Scene.objectData.Values)
{
warp_Object obj = (warp_Object)o;
obj.vertexData = null;
obj.triangleData = null;
}
renderer.Scene.removeAllObjects();
renderer.Scene.destroy();
renderer.Reset();
renderer = null;
viewport = null;
@ -301,9 +272,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f);
renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX / 2 - 0.5f,
renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX * 0.5f - 0.5f,
waterHeight,
m_scene.RegionInfo.RegionSizeY / 2 - 0.5f);
m_scene.RegionInfo.RegionSizeY * 0.5f - 0.5f);
warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR));
waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif
@ -319,53 +290,53 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
{
ITerrainChannel terrain = m_scene.Heightmap;
float regionsx = m_scene.RegionInfo.RegionSizeX;
float regionsy = m_scene.RegionInfo.RegionSizeY;
// 'diff' is the difference in scale between the real region size and the size of terrain we're buiding
float diff = (float)m_scene.RegionInfo.RegionSizeX / 256f;
float diff = regionsx / 256f;
warp_Object obj = new warp_Object(256 * 256, 255 * 255 * 2);
int npointsx =(int)(regionsx / diff);
int npointsy =(int)(regionsy / diff);
float invsx = 1.0f / regionsx;
float invsy = 1.0f / (float)m_scene.RegionInfo.RegionSizeY;
// Create all the vertices for the terrain
for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff)
warp_Object obj = new warp_Object();
for (float y = 0; y < regionsy; y += diff)
{
for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff)
for (float x = 0; x < regionsx; x += diff)
{
warp_Vector pos = ConvertVector(x, y, (float)terrain[(int)x, (int)y]);
obj.addVertex(new warp_Vertex(pos,
x / (float)m_scene.RegionInfo.RegionSizeX,
(((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY));
warp_Vector pos = ConvertVector(x , y , (float)terrain[(int)x, (int)y]);
obj.addVertex(new warp_Vertex(pos, x * invsx, 1.0f - y * invsy));
}
}
// Now that we have all the vertices, make another pass and create
// the normals for each of the surface triangles and
// create the list of triangle indices.
for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff)
// Now that we have all the vertices, make another pass and
// create the list of triangle indices.
float invdiff = 1.0f / diff;
int limx = npointsx - 1;
int limy = npointsy - 1;
for (float y = 0; y < regionsy; y += diff)
{
for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff)
for (float x = 0; x < regionsx; x += diff)
{
float newX = x / diff;
float newY = y / diff;
if (newX < 255 && newY < 255)
float newX = x * invdiff;
float newY = y * invdiff;
if (newX < limx && newY < limy)
{
int v = (int)newY * 256 + (int)newX;
// Normal for a triangle made up of three adjacent vertices
Vector3 v1 = new Vector3(newX, newY, (float)terrain[(int)x, (int)y]);
Vector3 v2 = new Vector3(newX + 1, newY, (float)terrain[(int)(x + 1), (int)y]);
Vector3 v3 = new Vector3(newX, newY + 1, (float)terrain[(int)x, ((int)(y + 1))]);
warp_Vector norm = ConvertVector(SurfaceNormal(v1, v2, v3));
norm = norm.reverse();
obj.vertex(v).n = norm;
int v = (int)newY * npointsx + (int)newX;
// Make two triangles for each of the squares in the grid of vertices
obj.addTriangle(
v,
v + 1,
v + 256);
v + npointsx);
obj.addTriangle(
v + 256 + 1,
v + 256,
v + npointsx + 1,
v + npointsx,
v + 1);
}
}
@ -398,14 +369,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);
warp_Texture texture;
using (
Bitmap image
= TerrainSplat.Splat(
using (Bitmap image = TerrainSplat.Splat(
terrain, textureIDs, startHeights, heightRanges,
new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain))
{
texture = new warp_Texture(image);
}
warp_Material material = new warp_Material(texture);
material.setReflectivity(50);
@ -431,11 +398,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
private void CreatePrim(WarpRenderer renderer, SceneObjectPart prim,
bool useTextures)
{
const float MIN_SIZE = 2f;
const float MIN_SIZE_SQUARE = 4f;
if ((PCode)prim.Shape.PCode != PCode.Prim)
return;
if (prim.Scale.LengthSquared() < MIN_SIZE * MIN_SIZE)
float primScaleLenSquared = prim.Scale.LengthSquared();
if (primScaleLenSquared < MIN_SIZE_SQUARE)
return;
FacetedMesh renderMesh = null;
@ -459,13 +428,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
else // It's sculptie
{
IJ2KDecoder imgDecoder = m_scene.RequestModuleInterface<IJ2KDecoder>();
if (imgDecoder != null)
if(imgDecoder != null)
{
Image sculpt = imgDecoder.DecodeToImage(sculptAsset);
if (sculpt != null)
if(sculpt != null)
{
renderMesh = m_primMesher.GenerateFacetedSculptMesh(omvPrim, (Bitmap)sculpt,
DetailLevel.Medium);
renderMesh = m_primMesher.GenerateFacetedSculptMesh(omvPrim,(Bitmap)sculpt,
DetailLevel.Medium);
sculpt.Dispose();
}
}
@ -483,20 +452,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
if (renderMesh == null)
return;
warp_Vector primPos = ConvertVector(prim.GetWorldPosition());
warp_Quaternion primRot = ConvertQuaternion(prim.RotationOffset);
warp_Matrix m = warp_Matrix.quaternionMatrix(primRot);
if (prim.ParentID != 0)
{
SceneObjectGroup group = m_scene.SceneGraph.GetGroupByPrim(prim.LocalId);
if (group != null)
m.transform(warp_Matrix.quaternionMatrix(ConvertQuaternion(group.RootPart.RotationOffset)));
}
warp_Vector primScale = ConvertVector(prim.Scale);
string primID = prim.UUID.ToString();
// Create the prim faces
@ -504,27 +459,18 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
for (int i = 0; i < renderMesh.Faces.Count; i++)
{
Face face = renderMesh.Faces[i];
string meshName = primID + "-Face-" + i.ToString();
string meshName = primID + i.ToString();
// Avoid adding duplicate meshes to the scene
if (renderer.Scene.objectData.ContainsKey(meshName))
{
continue;
}
warp_Object faceObj = new warp_Object(face.Vertices.Count, face.Indices.Count / 3);
warp_Object faceObj = new warp_Object();
for (int j = 0; j < face.Vertices.Count; j++)
{
Vertex v = face.Vertices[j];
warp_Vector pos = ConvertVector(v.Position);
warp_Vector norm = ConvertVector(v.Normal);
if (prim.Shape.SculptTexture == UUID.Zero)
norm = norm.reverse();
warp_Vertex vert = new warp_Vertex(pos, norm, v.TexCoord.X, v.TexCoord.Y);
warp_Vertex vert = new warp_Vertex(pos, v.TexCoord.X, v.TexCoord.Y);
faceObj.addVertex(vert);
}
@ -539,17 +485,19 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace((uint)i);
Color4 faceColor = GetFaceColor(teFace);
string materialName = String.Empty;
if (m_texturePrims && prim.Scale.LengthSquared() > m_texturePrimSize*m_texturePrimSize)
if (m_texturePrims && primScaleLenSquared > m_texturePrimSize*m_texturePrimSize)
materialName = GetOrCreateMaterial(renderer, faceColor, teFace.TextureID);
else
materialName = GetOrCreateMaterial(renderer, faceColor);
warp_Vector primPos = ConvertVector(prim.GetWorldPosition());
warp_Quaternion primRot = ConvertQuaternion(prim.GetWorldRotation());
warp_Matrix m = warp_Matrix.quaternionMatrix(primRot);
faceObj.transform(m);
faceObj.setPos(primPos);
faceObj.scaleSelf(primScale.x, primScale.y, primScale.z);
faceObj.scaleSelf(prim.Scale.X, prim.Scale.Z, prim.Scale.Y);
renderer.Scene.addObject(meshName, faceObj);
renderer.SetObjectMaterial(meshName, materialName);
}
}

View File

@ -1428,6 +1428,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
mapTexture.Save(exportPath, ImageFormat.Jpeg);
g.Dispose();
mapTexture.Dispose();
sea.Dispose();
m_log.InfoFormat(
"[WORLD MAP]: Successfully exported world map for {0} to {1}",
m_scene.RegionInfo.RegionName, exportPath);
@ -1613,9 +1617,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
int mb = bx;
if(mb < by)
mb = by;
if(mb > 2 * Constants.RegionSize && mb > 0)
if(mb > Constants.RegionSize && mb > 0)
{
float scale = 2.0f * (float)Constants.RegionSize/(float)mb;
float scale = (float)Constants.RegionSize/(float)mb;
Size newsize = new Size();
newsize.Width = (int)(bx * scale);
newsize.Height = (int)(by * scale);

View File

@ -52,6 +52,7 @@ namespace OpenSim.Region.Framework.Scenes
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private object MAOLock = new object();
private Dictionary<string, UUID> m_overrides = new Dictionary<string, UUID>();
public void SetOverride(string state, UUID animID)
{
@ -66,13 +67,13 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("Setting override for {0} to {1}", state, animID);
lock (m_overrides)
lock (MAOLock)
m_overrides[state] = animID;
}
public UUID GetOverriddenAnimation(string state)
{
lock (m_overrides)
lock (MAOLock)
{
if (m_overrides.ContainsKey(state))
return m_overrides[state];
@ -83,7 +84,7 @@ namespace OpenSim.Region.Framework.Scenes
public Dictionary<string, UUID> CloneAOPairs()
{
lock (m_overrides)
lock (MAOLock)
{
return new Dictionary<string, UUID>(m_overrides);
}
@ -91,7 +92,7 @@ namespace OpenSim.Region.Framework.Scenes
public void CopyAOPairsFrom(Dictionary<string, UUID> src)
{
lock (m_overrides)
lock (MAOLock)
{
m_overrides.Clear();
m_overrides = new Dictionary<string, UUID>(src);

View File

@ -128,20 +128,29 @@ namespace OpenSim.Region.Framework.Scenes
if (part.CollisionSoundType < 0)
return;
float volume = 0.0f;
bool HaveSound = false;
float volume = part.CollisionSoundVolume;
UUID soundID = part.CollisionSound;
if (part.CollisionSoundType > 0)
bool HaveSound = false;
switch (part.CollisionSoundType)
{
// soundID = part.CollisionSound;
volume = part.CollisionSoundVolume;
if (volume == 0.0f)
return;
HaveSound = true;
case 0: // default sounds
volume = 1.0f;
break;
case 1: // selected sound
if(soundID == part.invalidCollisionSoundUUID)
return;
HaveSound = true;
break;
case 2: // default sounds with volume set by script
default:
break;
}
if (volume == 0.0f)
return;
bool doneownsound = false;
int thisMaterial = (int)part.Material;
@ -152,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes
CollisionForSoundInfo colInfo;
uint id;
for(int i = 0; i< collidersinfolist.Count; i++)
for(int i = 0; i < collidersinfolist.Count; i++)
{
colInfo = collidersinfolist[i];
@ -163,15 +172,16 @@ namespace OpenSim.Region.Framework.Scenes
{
if (!HaveSound)
{
volume = Math.Abs(colInfo.relativeVel);
if (volume < 0.2f)
float vol = Math.Abs(colInfo.relativeVel);
if (vol < 0.2f)
continue;
volume *= volume * .0625f; // 4m/s == full volume
if (volume > 1.0f)
volume = 1.0f;
vol *= vol * .0625f; // 4m/s == full volume
if (vol > 1.0f)
vol = 1.0f;
soundID = m_TerrainPart[thisMaterial];
volume *= vol;
}
part.SendCollisionSound(soundID, volume, colInfo.position);
doneownsound = true;
@ -187,7 +197,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!HaveSound)
{
if (otherPart.CollisionSoundType > 0)
if (otherPart.CollisionSoundType == 1)
{
soundID = otherPart.CollisionSound;
volume = otherPart.CollisionSoundVolume;
@ -196,19 +206,27 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
volume = Math.Abs(colInfo.relativeVel);
if (volume < 0.2f)
if (otherPart.CollisionSoundType == 2)
{
volume = otherPart.CollisionSoundVolume;
if (volume == 0.0f)
continue;
}
float vol = Math.Abs(colInfo.relativeVel);
if (vol < 0.2f)
continue;
volume *= volume * .0625f; // 4m/s == full volume
if (volume > 1.0f)
volume = 1.0f;
vol *= vol * .0625f; // 4m/s == full volume
if (vol > 1.0f)
vol = 1.0f;
int otherMaterial = (int)otherPart.Material;
if (otherMaterial >= MaxMaterials)
otherMaterial = 3;
soundID = m_PartPart[thisMatScaled + otherMaterial];
volume *= vol;
}
}
@ -261,10 +279,17 @@ namespace OpenSim.Region.Framework.Scenes
{
if (otherPart.CollisionSoundType < 0)
continue;
if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f)
if (otherPart.CollisionSoundType == 1 && otherPart.CollisionSoundVolume > 0f)
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
else
{
float volmod = 1.0f;
if (otherPart.CollisionSoundType == 2)
{
volmod = otherPart.CollisionSoundVolume;
if(volmod == 0.0)
continue;
}
volume = Math.Abs(colInfo.relativeVel);
// Most noral collisions (running into walls, stairs)
// should never be heard.
@ -281,6 +306,7 @@ namespace OpenSim.Region.Framework.Scenes
if (otherMaterial >= MaxMaterials)
otherMaterial = 3;
volume *= volmod;
soundID = m_PartPart[thisMatScaled + otherMaterial];
otherPart.SendCollisionSound(soundID, volume, colInfo.position);
}

View File

@ -406,6 +406,16 @@ namespace OpenSim.Region.Framework.Scenes
ph.SetVehicle(vd);
}
public bool CameraDecoupled
{
get
{
if((vd.m_flags & VehicleFlag.CAMERA_DECOUPLED) != 0)
return true;
return false;
}
}
private XmlTextWriter writer;
private void XWint(string name, int i)

View File

@ -164,55 +164,39 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="primLocalID"></param>
/// <param name="remoteClient"></param>
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
public void SelectPrim(List<uint> primIDs, IClientAPI remoteClient)
{
/*
SceneObjectPart part = GetSceneObjectPart(primLocalID);
List<ISceneEntity> needUpdates = new List<ISceneEntity>();
if (null == part)
return;
if (part.IsRoot)
{
SceneObjectGroup sog = part.ParentGroup;
sog.SendPropertiesToClient(remoteClient);
// A prim is only tainted if it's allowed to be edited by the person clicking it.
if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)
|| Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId))
{
sog.IsSelected = true;
EventManager.TriggerParcelPrimCountTainted();
}
}
else
{
part.SendPropertiesToClient(remoteClient);
}
*/
SceneObjectPart part = GetSceneObjectPart(primLocalID);
if (null == part)
return;
SceneObjectGroup sog = part.ParentGroup;
if (sog == null)
return;
part.SendPropertiesToClient(remoteClient);
// waste of time because properties do not send prim flags as they should
// if a friend got or lost edit rights after login, a full update is needed
if(sog.OwnerID != remoteClient.AgentId)
part.SendFullUpdate(remoteClient);
// A prim is only tainted if it's allowed to be edited by the person clicking it.
if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)
|| Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId))
foreach(uint primLocalID in primIDs)
{
part.IsSelected = true;
EventManager.TriggerParcelPrimCountTainted();
SceneObjectPart part = GetSceneObjectPart(primLocalID);
if (part == null)
continue;
SceneObjectGroup sog = part.ParentGroup;
if (sog == null)
continue;
needUpdates.Add((ISceneEntity)part);
// waste of time because properties do not send prim flags as they should
// if a friend got or lost edit rights after login, a full update is needed
if(sog.OwnerID != remoteClient.AgentId)
part.SendFullUpdate(remoteClient);
// A prim is only tainted if it's allowed to be edited by the person clicking it.
if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)
|| Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId))
{
part.IsSelected = true;
EventManager.TriggerParcelPrimCountTainted();
}
}
if(needUpdates.Count > 0)
remoteClient.SendSelectedPartsProprieties(needUpdates);
}
/// <summary>
@ -377,8 +361,21 @@ namespace OpenSim.Region.Framework.Scenes
if (part == null)
return;
SceneObjectGroup obj = part.ParentGroup;
SceneObjectGroup group = part.ParentGroup;
if(group == null || group.IsDeleted)
return;
if (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();
SurfaceTouchEventArgs surfaceArg = null;
if (surfaceArgs != null && surfaceArgs.Count > 0)
surfaceArg = surfaceArgs[0];
@ -391,9 +388,9 @@ namespace OpenSim.Region.Framework.Scenes
// 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
if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
(part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
(part.PassTouches && (part.LocalId != group.RootPart.LocalId)))
{
EventManager.TriggerObjectGrabbing(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
EventManager.TriggerObjectGrabbing(group.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
}
}

View File

@ -2780,13 +2780,6 @@ namespace OpenSim.Region.Framework.Scenes
else
group.StopScriptInstances();
List<ScenePresence> avatars = group.GetSittingAvatars();
foreach (ScenePresence av in avatars)
{
if(av.ParentUUID == UUID.Zero)
av.StandUp();
}
SceneObjectPart[] partList = group.Parts;
foreach (SceneObjectPart part in partList)
@ -3336,7 +3329,6 @@ namespace OpenSim.Region.Framework.Scenes
client.OnObjectRequest += RequestPrim;
client.OnObjectSelect += SelectPrim;
client.OnObjectDeselect += DeselectPrim;
client.OnGrabUpdate += m_sceneGraph.MoveObject;
client.OnSpinStart += m_sceneGraph.SpinStart;
client.OnSpinUpdate += m_sceneGraph.SpinObject;
client.OnDeRezObject += DeRezObjects;
@ -3464,7 +3456,6 @@ namespace OpenSim.Region.Framework.Scenes
client.OnObjectRequest -= RequestPrim;
client.OnObjectSelect -= SelectPrim;
client.OnObjectDeselect -= DeselectPrim;
client.OnGrabUpdate -= m_sceneGraph.MoveObject;
client.OnSpinStart -= m_sceneGraph.SpinStart;
client.OnSpinUpdate -= m_sceneGraph.SpinObject;
client.OnDeRezObject -= DeRezObjects;
@ -3479,6 +3470,7 @@ namespace OpenSim.Region.Framework.Scenes
client.OnRequestObjectPropertiesFamily -= m_sceneGraph.RequestObjectPropertiesFamily;
client.OnObjectPermissions -= HandleObjectPermissionsUpdate;
client.OnGrabObject -= ProcessObjectGrab;
client.OnGrabUpdate -= ProcessObjectGrabUpdate;
client.OnDeGrabObject -= ProcessObjectDeGrab;
client.OnUndo -= m_sceneGraph.HandleUndo;
client.OnRedo -= m_sceneGraph.HandleRedo;
@ -5036,7 +5028,7 @@ Label_GroupsDone:
public LandData GetLandData(uint x, uint y)
{
m_log.DebugFormat("[SCENE]: returning land for {0},{1}", x, y);
// m_log.DebugFormat("[SCENE]: returning land for {0},{1}", x, y);
ILandObject parcel = LandChannel.GetLandObject((int)x, (int)y);
if (parcel == null)
return null;
@ -5439,7 +5431,6 @@ Label_GroupsDone:
}
}
}
}
public void DeleteFromStorage(UUID uuid)

View File

@ -1674,7 +1674,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
/* moved to scene ProcessObjectGrabUpdate
/// <summary>
/// Move the given object
/// </summary>
@ -1699,7 +1699,7 @@ namespace OpenSim.Region.Framework.Scenes
group.SendGroupTerseUpdate();
}
}
*/
/// <summary>
/// Start spinning the given object
/// </summary>

View File

@ -2078,7 +2078,7 @@ namespace OpenSim.Region.Framework.Scenes
Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
if (!avatar.IsChildAgent && avatar.ParentID == LocalId)
if (!avatar.IsChildAgent && avatar.ParentID == part.LocalId && avatar.ParentUUID == UUID.Zero)
avatar.StandUp();
if (!silent)
@ -2092,6 +2092,8 @@ namespace OpenSim.Region.Framework.Scenes
{
// Send a kill object immediately
avatar.ControllingClient.SendKillObject(new List<uint> { part.LocalId });
//direct enqueue another delayed kill
avatar.ControllingClient.SendEntityUpdate(part,PrimUpdateFlags.Kill);
}
}
}
@ -2110,6 +2112,12 @@ namespace OpenSim.Region.Framework.Scenes
d.AddActiveScripts(count);
}
private const scriptEvents PhysicsNeeedSubsEvents = (
scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end |
scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end);
private scriptEvents lastRootPartPhysEvents = 0;
public void aggregateScriptEvents()
{
PrimFlags objectflagupdate = (PrimFlags)RootPart.GetEffectiveObjectFlags();
@ -2146,6 +2154,20 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.RemoveGroupTarget(this);
}
scriptEvents rootPartPhysEvents = RootPart.AggregateScriptEvents;
rootPartPhysEvents &= PhysicsNeeedSubsEvents;
if (rootPartPhysEvents != lastRootPartPhysEvents)
{
lastRootPartPhysEvents = rootPartPhysEvents;
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart part = parts[i];
if (part == null)
continue;
part.UpdatePhysicsSubscribedEvents();
}
}
ScheduleGroupForFullUpdate();
}
@ -2174,7 +2196,6 @@ namespace OpenSim.Region.Framework.Scenes
// Apply physics to the root prim
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true);
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart part = parts[i];
@ -2242,10 +2263,10 @@ namespace OpenSim.Region.Framework.Scenes
// any exception propogate upwards.
try
{
if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart
!m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things
m_scene.LoadingPrims) // Land may not be valid yet
// if shutting down then there will be nothing to handle the return so leave till next restart
if (!m_scene.ShuttingDown &&
m_scene.LoginsEnabled && // We're starting up or doing maintenance, don't mess with things
!m_scene.LoadingPrims) // Land may not be valid yet
{
ILandObject parcel = m_scene.LandChannel.GetLandObject(
m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y);
@ -3345,7 +3366,10 @@ namespace OpenSim.Region.Framework.Scenes
// engine about the delink. Someday, linksets should be made first
// class objects in the physics engine interface).
if (linkPartPa != null)
{
m_scene.PhysicsScene.RemovePrim(linkPartPa);
linkPart.PhysActor = null;
}
// We need to reset the child part's position
// ready for life as a separate object after being a part of another object
@ -3397,10 +3421,11 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void DetachFromBackup()
{
if (m_scene != null)
{
m_scene.SceneGraph.FireDetachFromBackup(this);
if (Backup && Scene != null)
m_scene.EventManager.OnBackup -= ProcessBackup;
if (Backup)
m_scene.EventManager.OnBackup -= ProcessBackup;
}
Backup = false;
}

View File

@ -345,6 +345,7 @@ namespace OpenSim.Region.Framework.Scenes
private string m_text = String.Empty;
private string m_touchName = String.Empty;
private UndoRedoState m_UndoRedo = null;
private object m_UndoLock = new object();
private bool m_passTouches = false;
private bool m_passCollisions = false;
@ -399,13 +400,12 @@ namespace OpenSim.Region.Framework.Scenes
// 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound
private sbyte m_collisionSoundType;
private sbyte m_collisionSoundType = 0;
private UUID m_collisionSound;
private float m_collisionSoundVolume;
private int LastColSoundSentTime;
private SOPVehicle m_vehicleParams = null;
public KeyframeMotion KeyframeMotion
@ -1534,7 +1534,6 @@ namespace OpenSim.Region.Framework.Scenes
else
m_collisionSoundType = 1;
aggregateScriptEvents();
}
}
@ -2164,7 +2163,10 @@ namespace OpenSim.Region.Framework.Scenes
UpdatePhysicsSubscribedEvents(); // not sure if appliable here
}
else
{
PhysActor = null; // just to be sure
RemFlag(PrimFlags.CameraDecoupled);
}
}
}
@ -3539,6 +3541,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
set
{
m_vehicleParams = value;
}
}
@ -3583,7 +3586,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
m_vehicleParams.ProcessVehicleFlags(param, remove);
if (_parentID ==0 && PhysActor != null)
if (_parentID == 0 && PhysActor != null)
{
PhysActor.VehicleFlags(param, remove);
}
@ -3932,11 +3935,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
public void StoreUndoState(ObjectChangeType change)
{
if (m_UndoRedo == null)
m_UndoRedo = new UndoRedoState(5);
lock (m_UndoRedo)
lock (m_UndoLock)
{
if (m_UndoRedo == null)
m_UndoRedo = new UndoRedoState(5);
if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended
{
m_UndoRedo.StoreUndo(this, change);
@ -3959,11 +3962,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
public void Undo()
{
if (m_UndoRedo == null || Undoing || ParentGroup == null)
return;
lock (m_UndoRedo)
lock (m_UndoLock)
{
if (m_UndoRedo == null || Undoing || ParentGroup == null)
return;
Undoing = true;
m_UndoRedo.Undo(this);
Undoing = false;
@ -3972,11 +3975,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
public void Redo()
{
if (m_UndoRedo == null || Undoing || ParentGroup == null)
return;
lock (m_UndoRedo)
lock (m_UndoLock)
{
if (m_UndoRedo == null || Undoing || ParentGroup == null)
return;
Undoing = true;
m_UndoRedo.Redo(this);
Undoing = false;
@ -3985,11 +3988,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
public void ClearUndoState()
{
if (m_UndoRedo == null || Undoing)
return;
lock (m_UndoRedo)
lock (m_UndoLock)
{
if (m_UndoRedo == null || Undoing)
return;
m_UndoRedo.Clear();
}
}
@ -4722,9 +4725,16 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
if (VolumeDetectActive) // change if not the default only
pa.SetVolumeDetect(1);
if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId)
if (m_vehicleParams != null && m_localId == ParentGroup.RootPart.LocalId)
{
m_vehicleParams.SetVehicle(pa);
if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled)
AddFlag(PrimFlags.CameraDecoupled);
else
RemFlag(PrimFlags.CameraDecoupled);
}
else
RemFlag(PrimFlags.CameraDecoupled);
// we are going to tell rest of code about physics so better have this here
PhysActor = pa;
@ -4800,6 +4810,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this);
}
RemFlag(PrimFlags.CameraDecoupled);
PhysActor = null;
}
@ -5021,7 +5032,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
}
private void UpdatePhysicsSubscribedEvents()
internal void UpdatePhysicsSubscribedEvents()
{
PhysicsActor pa = PhysActor;
if (pa == null)
@ -5095,8 +5106,6 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
}
UpdatePhysicsSubscribedEvents();
LocalFlags = (PrimFlags)objectflagupdate;
if (ParentGroup != null && ParentGroup.RootPart == this)
@ -5107,6 +5116,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
{
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
UpdatePhysicsSubscribedEvents();
ScheduleFullUpdate();
}
}
@ -5408,5 +5418,24 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
Acceleration = Vector3.Zero;
APIDActive = false;
}
// handle osVolumeDetect
public void ScriptSetVolumeDetect(bool makeVolumeDetect)
{
if(_parentID == 0)
{
// if root prim do it via SOG
ParentGroup.ScriptSetVolumeDetect(makeVolumeDetect);
return;
}
bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
if(PhysActor != null)
PhysActor.Building = true;
UpdatePrimFlags(wasUsingPhysics,wasTemporary,wasPhantom,makeVolumeDetect,false);
}
}
}

View File

@ -542,10 +542,7 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 CameraPosition { get; set; }
public Quaternion CameraRotation
{
get { return Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); }
}
public Quaternion CameraRotation { get; private set; }
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
@ -1242,6 +1239,14 @@ namespace OpenSim.Region.Framework.Scenes
ParentPart = part;
m_pos = PrevSitOffset;
pos = part.GetWorldPosition();
PhysicsActor partPhysActor = part.PhysActor;
if(partPhysActor != null)
{
partPhysActor.OnPhysicsRequestingCameraData -=
physActor_OnPhysicsRequestingCameraData;
partPhysActor.OnPhysicsRequestingCameraData +=
physActor_OnPhysicsRequestingCameraData;
}
}
ParentUUID = UUID.Zero;
}
@ -1922,6 +1927,31 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
public void RotateToLookAt(Vector3 lookAt)
{
if(ParentID == 0)
{
float n = lookAt.X * lookAt.X + lookAt.Y * lookAt.Y;
if(n < 0.0001f)
{
Rotation = Quaternion.Identity;
return;
}
n = lookAt.X/(float)Math.Sqrt(n);
float angle = (float)Math.Acos(n);
angle *= 0.5f;
float s = (float)Math.Sin(angle);
if(lookAt.Y < 0)
s = -s;
Rotation = new Quaternion(
0f,
0f,
s,
(float)Math.Cos(angle)
);
}
}
/// <summary>
/// Complete Avatar's movement into the region.
/// </summary>
@ -1958,10 +1988,10 @@ namespace OpenSim.Region.Framework.Scenes
bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
Vector3 look = Lookat;
look.Z = 0f;
if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01))
{
look = Velocity;
look.Z = 0;
look.Normalize();
if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) )
look = new Vector3(0.99f, 0.042f, 0);
@ -1995,11 +2025,12 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF);
}
if(!gotCrossUpdate)
RotateToLookAt(look);
// Tell the client that we're totally ready
ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
if (!string.IsNullOrEmpty(m_callbackURI))
@ -2696,9 +2727,13 @@ namespace OpenSim.Region.Framework.Scenes
CameraPosition = agentData.CameraCenter;
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
// this my need lock
CameraAtAxis = agentData.CameraAtAxis;
CameraLeftAxis = agentData.CameraLeftAxis;
CameraUpAxis = agentData.CameraUpAxis;
Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis);
CameraRotation = camRot;
// The Agent's Draw distance setting
// When we get to the point of re-computing neighbors everytime this
@ -3171,9 +3206,9 @@ namespace OpenSim.Region.Framework.Scenes
offset = offset * part.RotationOffset;
offset += part.OffsetPosition;
if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
if (cameraAtOffset == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
{
CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset();
cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset();
cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
}
else
@ -3304,7 +3339,6 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
bool forceMouselook = part.GetForceMouselook();
m_bodyRot = Orientation;
if (!part.IsRoot)
{
@ -3312,9 +3346,9 @@ namespace OpenSim.Region.Framework.Scenes
offset = offset * part.RotationOffset;
offset += part.OffsetPosition;
if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
if (cameraAtOffset == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
{
CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset();
cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset();
cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
}
else
@ -3326,6 +3360,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
m_bodyRot = Orientation;
m_pos = offset;
ControllingClient.SendSitResponse(
@ -4571,6 +4606,11 @@ namespace OpenSim.Region.Framework.Scenes
CameraAtAxis = cAgent.AtAxis;
CameraLeftAxis = cAgent.LeftAxis;
CameraUpAxis = cAgent.UpAxis;
Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis);
CameraRotation = camRot;
ParentUUID = cAgent.ParentPart;
PrevSitOffset = cAgent.SitOffset;
@ -5429,10 +5469,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
CameraData physActor_OnPhysicsRequestingCameraData()
{
return new CameraData
{
Valid = true,
MouseLook = this.m_mouseLook,
CameraRotation = this.CameraRotation,
CameraAtAxis = this.CameraAtAxis
};
}
public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
{
SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID);
if (p == null)
SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
if (part == null)
return;
ControllingClient.SendTakeControls(controls, false, false);
@ -5442,7 +5493,7 @@ namespace OpenSim.Region.Framework.Scenes
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = ScriptControlled.CONTROL_ZERO;
obj.objectID = p.ParentGroup.UUID;
obj.objectID = part.ParentGroup.UUID;
obj.itemID = Script_item_UUID;
if (pass_on == 0 && accept == 0)
{
@ -5470,17 +5521,43 @@ namespace OpenSim.Region.Framework.Scenes
{
IgnoredControls &= ~(ScriptControlled)controls;
if (scriptedcontrols.ContainsKey(Script_item_UUID))
scriptedcontrols.Remove(Script_item_UUID);
RemoveScriptFromControlNotifications(Script_item_UUID, part);
}
else
{
scriptedcontrols[Script_item_UUID] = obj;
AddScriptToControlNotifications(Script_item_UUID, part, ref obj);
}
}
ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
}
private void AddScriptToControlNotifications(OpenMetaverse.UUID Script_item_UUID, SceneObjectPart part, ref ScriptControllers obj)
{
scriptedcontrols[Script_item_UUID] = obj;
PhysicsActor physActor = part.ParentGroup.RootPart.PhysActor;
if (physActor != null)
{
physActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
physActor.OnPhysicsRequestingCameraData += physActor_OnPhysicsRequestingCameraData;
}
}
private void RemoveScriptFromControlNotifications(OpenMetaverse.UUID Script_item_UUID, SceneObjectPart part)
{
scriptedcontrols.Remove(Script_item_UUID);
if (part != null)
{
PhysicsActor physActor = part.ParentGroup.RootPart.PhysActor;
if (physActor != null)
{
physActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
}
}
}
public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
@ -5518,6 +5595,7 @@ namespace OpenSim.Region.Framework.Scenes
public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID)
{
ScriptControllers takecontrols;
SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
lock (scriptedcontrols)
{
@ -5528,7 +5606,7 @@ namespace OpenSim.Region.Framework.Scenes
ControllingClient.SendTakeControls((int)sctc, false, false);
ControllingClient.SendTakeControls((int)sctc, true, false);
scriptedcontrols.Remove(Script_item_UUID);
RemoveScriptFromControlNotifications(Script_item_UUID, part);
IgnoredControls = ScriptControlled.CONTROL_ZERO;
foreach (ScriptControllers scData in scriptedcontrols.Values)
{
@ -5947,6 +6025,7 @@ namespace OpenSim.Region.Framework.Scenes
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
{
pos = land.LandData.UserLocation;
positionChanged = true;
}
}

View File

@ -1753,6 +1753,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
{
}
public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
{
}
public void SendPartPhysicsProprieties(ISceneEntity entity)
{
}

View File

@ -270,7 +270,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
public void Close()
{
m_log.InfoFormat("[IRC-Connector-{0}] Closing", idn);
lock (msyncConnect)
@ -295,7 +294,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
}
catch (Exception) { }
m_connected = false;
try { m_writer.Close(); }
@ -308,10 +306,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
catch (Exception) { }
}
lock (m_connectors)
m_connectors.Remove(this);
}
}
@ -327,25 +323,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
public void Connect()
{
if (!m_enabled)
return;
// Delay until next WD cycle if this is too close to the last start attempt
while (_icc_ < ICCD_PERIOD)
if(_icc_ < ICCD_PERIOD)
return;
m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel);
_icc_ = 0;
lock (msyncConnect)
{
_icc_ = 0;
try
{
if (m_connected) return;
m_connected = true;
@ -379,11 +371,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
// expires. By leaving them as they are, the connection will be retried
// when the login timeout expires. Which is preferred.
}
}
return;
}
// Reconnect is used to force a re-cycle of the IRC connection. Should generally

View File

@ -1177,18 +1177,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
}
GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, ejecteeID);
if ((groupInfo == null) || (account == null))
{
if (groupInfo == null)
return;
}
IClientAPI ejecteeClient = GetActiveRootClient(ejecteeID);
// Send Message to Ejectee
GridInstantMessage msg = new GridInstantMessage();
string ejecteeName = "Unknown member";
// if local send a normal message
if(ejecteeClient != null)
{
@ -1197,6 +1195,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// also execute and send update
ejecteeClient.SendAgentDropGroup(groupID);
SendAgentGroupDataUpdate(ejecteeClient,true);
ejecteeName = ejecteeClient.Name;
}
else // send
{
@ -1208,6 +1207,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.imSessionID = groupInfo.GroupID.Guid;
msg.dialog = (byte)210; //interop
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, ejecteeID);
if (account != null)
ejecteeName = account.FirstName + " " + account.LastName;
}
msg.fromAgentID = agentID.Guid;
@ -1234,14 +1236,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.toAgentID = agentID.Guid;
msg.timestamp = 0;
msg.fromAgentName = agentName;
if (account != null)
{
msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, account.FirstName + " " + account.LastName);
}
else
{
msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member");
}
msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, ejecteeName);
// msg.dialog = (byte)210; //interop
msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent;
msg.fromGroup = false;

View File

@ -97,9 +97,8 @@ namespace OpenSim.Region.UserStatistics
sdr.Read();
totalregions = Convert.ToInt32(sdr["regcnt"]);
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
sql =
"select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;";
@ -120,7 +119,7 @@ namespace OpenSim.Region.UserStatistics
}
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
if (totalregions > 1)
{
@ -143,11 +142,8 @@ namespace OpenSim.Region.UserStatistics
}
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
}
}
foreach (ClientVersionData cvd in cliRegData)
@ -163,9 +159,6 @@ namespace OpenSim.Region.UserStatistics
{
regionTotals.Add(cvd.region_id, cvd.count);
}
}
modeldata["ClientData"] = clidata;

View File

@ -227,7 +227,10 @@ TD.align_top { vertical-align: top; }
returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
}
sdr.Close();
cmd.Dispose();
}
return returnstruct;
}

View File

@ -145,8 +145,7 @@ namespace OpenSim.Region.UserStatistics
}
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
}
modeldata["SessionData"] = lstSessions;
return modeldata;

View File

@ -1337,6 +1337,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
}
public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
{
}
public void SendPartPhysicsProprieties(ISceneEntity entity)
{
}

View File

@ -954,25 +954,6 @@ namespace OpenSim.Region.PhysicsModule.BulletS
// m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
}
// Although no one seems to check this, I do support combining.
public override bool SupportsCombining()
{
return TerrainManager.SupportsCombining();
}
// This call says I am a child to region zero in a mega-region. 'pScene' is that
// of region zero, 'offset' is my offset from regions zero's origin, and
// 'extents' is the largest XY that is handled in my region.
public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
{
TerrainManager.Combine(pScene, offset, extents);
}
// Unhook all the combining that I know about.
public override void UnCombine(PhysicsScene pScene)
{
TerrainManager.UnCombine(pScene);
}
#endregion // Terrain
public override Dictionary<uint, float> GetTopColliders()

View File

@ -1074,14 +1074,27 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
public static int maxdirfiltered(List<float3> p, int count, float3 dir, byte[] allow)
{
//Debug.Assert(count != 0);
int m = 0;
float currDotm = float3.dot(p[0], dir);
int m = -1;
float currDotm = 0;
float currDoti;
while (allow[m] == 0)
m++;
for (int i = 0; i < count; i++)
{
if (allow[i] != 0)
{
currDotm = float3.dot(p[i], dir);
m = i;
break;
}
}
for (int i = 1; i < count; i++)
if(m == -1)
{
Debug.Assert(false);
return m;
}
for (int i = m + 1; i < count; i++)
{
if (allow[i] != 0)
{
@ -1093,7 +1106,8 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
}
}
}
//Debug.Assert(m != -1);
// Debug.Assert(m != -1);
return m;
}
@ -1112,8 +1126,8 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
{
int mb;
{
float s = (float)Math.Sin((3.14159264f / 180.0f) * (x));
float c = (float)Math.Cos((3.14159264f / 180.0f) * (x));
float s = (float)Math.Sin(0.01745329f * x);
float c = (float)Math.Cos(0.01745329f * x);
mb = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow);
}
if (ma == m && mb == m)
@ -1126,8 +1140,8 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
int mc = ma;
for (float xx = x - 40.0f; xx <= x; xx += 5.0f)
{
float s = (float)Math.Sin((3.14159264f / 180.0f) * (xx));
float c = (float)Math.Cos((3.14159264f / 180.0f) * (xx));
float s = (float)Math.Sin(0.01745329f * xx);
float c = (float)Math.Cos(0.01745329f * xx);
int md = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow);
if (mc == m && md == m)
{
@ -1176,7 +1190,7 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
Debug.Assert(!(p0 == p1 || p0 == p2 || p0 == p3 || p1 == p2 || p1 == p3 || p2 == p3));
if (float3.dot(verts[p3] - verts[p0], float3.cross(verts[p1] - verts[p0], verts[p2] - verts[p0])) < 0)
{
Swap(ref p2, ref p3);
return new int4(p0, p1, p3, p2);
}
return new int4(p0, p1, p2, p3);
}
@ -1207,12 +1221,12 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
int j;
float3 bmin = new float3(verts[0]);
float3 bmax = new float3(verts[0]);
List<int> isextreme = new List<int>(verts.Count);
byte[] isextreme = new byte[verts.Count];
byte[] allow = new byte[verts.Count];
for (j = 0; j < verts.Count; j++)
{
allow[j] = 1;
isextreme.Add(0);
isextreme[j] = 0;
bmin = float3.VectorMin(bmin, verts[j]);
bmax = float3.VectorMax(bmax, verts[j]);
}
@ -1526,6 +1540,19 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
}
}
public static bool ComputeHull(List<float3> vertices, out List<int> indices)
{
List<HullTriangle> tris = new List<HullTriangle>();
bool ret = calchull(vertices, out indices, 0, tris);
if (ret == false)
{
indices = new List<int>();
return false;
}
return true;
}
private static bool CleanupVertices(List<float3> svertices, out List<float3> vertices, float normalepsilon, out float3 scale)
{
const float EPSILON = 0.000001f;

View File

@ -258,8 +258,6 @@ namespace OpenSim.Region.PhysicsModule.ODE
private Random fluidRandomizer = new Random(Environment.TickCount);
public bool m_suportCombine = true;
private uint m_regionWidth = Constants.RegionSize;
private uint m_regionHeight = Constants.RegionSize;
@ -542,8 +540,6 @@ namespace OpenSim.Region.PhysicsModule.ODE
WorldExtents.Y = regionExtent.Y;
m_regionHeight = (uint)regionExtent.Y;
m_suportCombine = false;
nearCallback = near;
m_rayCastManager = new ODERayCastRequestManager(this);
@ -1627,15 +1623,6 @@ namespace OpenSim.Region.PhysicsModule.ODE
#endregion
public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
{
if (!m_suportCombine)
return;
m_worldOffset = offset;
WorldExtents = new Vector2(extents.X, extents.Y);
m_parentScene = pScene;
}
// Recovered for use by fly height. Kitto Flora
internal float GetTerrainHeightAtXY(float x, float y)
{
@ -1643,12 +1630,6 @@ namespace OpenSim.Region.PhysicsModule.ODE
int offsetX = 0;
int offsetY = 0;
if (m_suportCombine)
{
offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
}
if(RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom))
{
if (heightFieldGeom != IntPtr.Zero)
@ -3387,11 +3368,6 @@ namespace OpenSim.Region.PhysicsModule.ODE
return waterlevel;
}
public override bool SupportsCombining()
{
return m_suportCombine;
}
public override void SetWaterLevel(float baseheight)
{
waterlevel = baseheight;
@ -3452,6 +3428,11 @@ namespace OpenSim.Region.PhysicsModule.ODE
}
}
private int compareByCollisionsDesc(OdePrim A, OdePrim B)
{
return -A.CollisionScore.CompareTo(B.CollisionScore);
}
public override Dictionary<uint, float> GetTopColliders()
{
Dictionary<uint, float> topColliders;
@ -3459,7 +3440,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
lock (_prims)
{
List<OdePrim> orderedPrims = new List<OdePrim>(_prims);
orderedPrims.OrderByDescending(p => p.CollisionScore);
orderedPrims.Sort(compareByCollisionsDesc);
topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
foreach (OdePrim p in _prims)

View File

@ -55,6 +55,14 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
Absolute
}
public struct CameraData
{
public Quaternion CameraRotation;
public Vector3 CameraAtAxis;
public bool MouseLook;
public bool Valid;
}
public struct ContactPoint
{
public Vector3 Position;
@ -159,13 +167,15 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
public delegate void RequestTerseUpdate();
public delegate void CollisionUpdate(EventArgs e);
public delegate void OutOfBounds(Vector3 pos);
public delegate CameraData GetCameraData();
// disable warning: public events
// disable warning: public events
#pragma warning disable 67
public event PositionUpdate OnPositionUpdate;
public event VelocityUpdate OnVelocityUpdate;
public event OrientationUpdate OnOrientationUpdate;
public event RequestTerseUpdate OnRequestTerseUpdate;
public event GetCameraData OnPhysicsRequestingCameraData;
/// <summary>
/// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event
@ -176,6 +186,17 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
public event OutOfBounds OnOutOfBounds;
#pragma warning restore 67
public CameraData TryGetCameraData()
{
GetCameraData handler = OnPhysicsRequestingCameraData;
if (handler != null)
{
return handler();
}
return new CameraData { Valid = false };
}
public static PhysicsActor Null
{
get { return new NullPhysicsActor(); }

View File

@ -332,15 +332,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
return false;
}
public virtual bool SupportsCombining()
{
return false;
}
public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {}
public virtual void CombineTerrain(float[] heightMap, Vector3 pOffset) {}
public virtual void UnCombine(PhysicsScene pScene) {}
/// <summary>
/// Queue a raycast against the physics scene.
/// The provided callback method will be called when the raycast is complete

View File

@ -122,8 +122,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private float m_buoyancy = 0f;
private bool m_freemove = false;
// private CollisionLocker ode;
// private string m_name = String.Empty;
// other filter control
int m_colliderfilter = 0;
@ -1571,11 +1570,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
if (CollisionEventsThisFrame != null)
{
lock (CollisionEventsThisFrame)
{
CollisionEventsThisFrame.Clear();
CollisionEventsThisFrame = null;
}
CollisionEventsThisFrame.Clear();
CollisionEventsThisFrame = null;
}
m_eventsubscription = 0;
_parent_scene.RemoveCollisionEventReporting(this);
@ -1585,11 +1581,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
lock (CollisionEventsThisFrame)
{
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
_parent_scene.AddCollisionEventReporting(this);
}
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
_parent_scene.AddCollisionEventReporting(this);
}
public void SendCollisions(int timestep)
@ -1600,28 +1593,25 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (CollisionEventsThisFrame == null)
return;
lock (CollisionEventsThisFrame)
if (m_cureventsubscription < m_eventsubscription)
return;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (!SentEmptyCollisionsEvent || ncolisions > 0)
{
if (m_cureventsubscription < m_eventsubscription)
return;
base.SendCollisionUpdate(CollisionEventsThisFrame);
m_cureventsubscription = 0;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (!SentEmptyCollisionsEvent || ncolisions > 0)
if (ncolisions == 0)
{
base.SendCollisionUpdate(CollisionEventsThisFrame);
m_cureventsubscription = 0;
if (ncolisions == 0)
{
SentEmptyCollisionsEvent = true;
// _parent_scene.RemoveCollisionEventReporting(this);
}
else
{
SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear();
}
SentEmptyCollisionsEvent = true;
// _parent_scene.RemoveCollisionEventReporting(this);
}
else
{
SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear();
}
}
}

View File

@ -648,6 +648,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
break;
}
// disable mouse steering
m_flags &= ~(VehicleFlag.MOUSELOOK_STEER |
VehicleFlag.MOUSELOOK_BANK |
VehicleFlag.CAMERA_DECOUPLED);
m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale);
m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
@ -794,6 +798,28 @@ namespace OpenSim.Region.PhysicsModule.ubOde
float ldampZ = 0;
bool mousemode = false;
bool mousemodebank = false;
float bankingEfficiency;
float verticalAttractionTimescale = m_verticalAttractionTimescale;
if((m_flags & (VehicleFlag.MOUSELOOK_STEER | VehicleFlag.MOUSELOOK_BANK)) != 0 )
{
mousemode = true;
mousemodebank = (m_flags & VehicleFlag.MOUSELOOK_BANK) != 0;
if(mousemodebank)
{
bankingEfficiency = m_bankingEfficiency;
if(verticalAttractionTimescale < 149.9)
verticalAttractionTimescale *= 2.0f; // reduce current instability
}
else
bankingEfficiency = 0;
}
else
bankingEfficiency = m_bankingEfficiency;
// linear motor
if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000)
{
@ -930,12 +956,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
// vertical atractor
if (m_verticalAttractionTimescale < 300)
if (verticalAttractionTimescale < 300)
{
float roll;
float pitch;
float ftmp = m_invtimestep / m_verticalAttractionTimescale / m_verticalAttractionTimescale;
float ftmp = m_invtimestep / verticalAttractionTimescale / verticalAttractionTimescale;
float ftmp2;
ftmp2 = 0.5f * m_verticalAttractionEfficiency * m_invtimestep;
@ -967,7 +993,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
torque.Y += effpitch * ftmp;
}
if (m_bankingEfficiency != 0 && Math.Abs(effroll) > 0.01)
if (bankingEfficiency != 0 && Math.Abs(effroll) > 0.01)
{
float broll = effroll;
@ -1018,57 +1044,128 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_amdampZ = 1 / m_angularFrictionTimescale.Z;
}
// angular motor
if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000)
if(mousemode)
{
tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error
tmpV *= m_amEfect / m_angularMotorTimescale; // error to correct in this timestep
torque.X += tmpV.X * m_ampwr;
torque.Y += tmpV.Y * m_ampwr;
torque.Z += tmpV.Z;
CameraData cam = rootPrim.TryGetCameraData();
if(cam.Valid && cam.MouseLook)
{
Vector3 dirv = cam.CameraAtAxis * irotq;
m_amEfect *= m_amDecay;
}
else
m_amEfect = 0;
float invamts = 1.0f/m_angularMotorTimescale;
float tmp;
// angular deflection
if (m_angularDeflectionEfficiency > 0)
{
Vector3 dirv;
if (curLocalVel.X > 0.01f)
dirv = curLocalVel;
else if (curLocalVel.X < -0.01f)
// use oposite
dirv = -curLocalVel;
// get out of x == 0 plane
if(Math.Abs(dirv.X) < 0.001f)
dirv.X = 0.001f;
if (Math.Abs(dirv.Z) > 0.01)
{
tmp = -(float)Math.Atan2(dirv.Z, dirv.X) * m_angularMotorDirection.Y;
if(tmp < -4f)
tmp = -4f;
else if(tmp > 4f)
tmp = 4f;
torque.Y += (tmp - curLocalAngVel.Y) * invamts;
torque.Y -= curLocalAngVel.Y * m_amdampY;
}
else
torque.Y -= curLocalAngVel.Y * m_invtimestep;
if (Math.Abs(dirv.Y) > 0.01)
{
if(mousemodebank)
{
tmp = -(float)Math.Atan2(dirv.Y, dirv.X) * m_angularMotorDirection.X;
if(tmp < -4f)
tmp = -4f;
else if(tmp > 4f)
tmp = 4f;
torque.X += (tmp - curLocalAngVel.X) * invamts;
}
else
{
tmp = (float)Math.Atan2(dirv.Y, dirv.X) * m_angularMotorDirection.Z;
tmp *= invamts;
if(tmp < -4f)
tmp = -4f;
else if(tmp > 4f)
tmp = 4f;
torque.Z += (tmp - curLocalAngVel.Z) * invamts;
}
torque.X -= curLocalAngVel.X * m_amdampX;
torque.Z -= curLocalAngVel.Z * m_amdampZ;
}
else
{
if(mousemodebank)
torque.X -= curLocalAngVel.X * m_invtimestep;
else
torque.Z -= curLocalAngVel.Z * m_invtimestep;
}
}
else
{
// make it fall into small positive x case
dirv.X = 0.01f;
dirv.Y = curLocalVel.Y;
dirv.Z = curLocalVel.Z;
}
float ftmp = m_angularDeflectionEfficiency / m_angularDeflectionTimescale;
if (Math.Abs(dirv.Z) > 0.01)
{
torque.Y += - (float)Math.Atan2(dirv.Z, dirv.X) * ftmp;
}
if (Math.Abs(dirv.Y) > 0.01)
{
torque.Z += (float)Math.Atan2(dirv.Y, dirv.X) * ftmp;
if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
{
torque.X -= curLocalAngVel.X * 10f;
torque.Y -= curLocalAngVel.Y * 10f;
torque.Z -= curLocalAngVel.Z * 10f;
}
}
}
// angular friction
if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
else
{
torque.X -= curLocalAngVel.X * m_amdampX;
torque.Y -= curLocalAngVel.Y * m_amdampY;
torque.Z -= curLocalAngVel.Z * m_amdampZ;
// angular motor
if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000)
{
tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error
tmpV *= m_amEfect / m_angularMotorTimescale; // error to correct in this timestep
torque.X += tmpV.X * m_ampwr;
torque.Y += tmpV.Y * m_ampwr;
torque.Z += tmpV.Z;
m_amEfect *= m_amDecay;
}
else
m_amEfect = 0;
// angular deflection
if (m_angularDeflectionEfficiency > 0)
{
Vector3 dirv;
if (curLocalVel.X > 0.01f)
dirv = curLocalVel;
else if (curLocalVel.X < -0.01f)
// use oposite
dirv = -curLocalVel;
else
{
// make it fall into small positive x case
dirv.X = 0.01f;
dirv.Y = curLocalVel.Y;
dirv.Z = curLocalVel.Z;
}
float ftmp = m_angularDeflectionEfficiency / m_angularDeflectionTimescale;
if (Math.Abs(dirv.Z) > 0.01)
{
torque.Y += - (float)Math.Atan2(dirv.Z, dirv.X) * ftmp;
}
if (Math.Abs(dirv.Y) > 0.01)
{
torque.Z += (float)Math.Atan2(dirv.Y, dirv.X) * ftmp;
}
}
if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
{
torque.X -= curLocalAngVel.X * m_amdampX;
torque.Y -= curLocalAngVel.Y * m_amdampY;
torque.Z -= curLocalAngVel.Z * m_amdampZ;
}
}
force *= dmass.mass;

View File

@ -306,7 +306,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public override uint LocalID
{
get { return m_localID; }
set { m_localID = value; }
set
{
uint oldid = m_localID;
m_localID = value;
_parent_scene.changePrimID(this, oldid);
}
}
public override PhysicsActor ParentActor
@ -1066,8 +1071,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public OdePrim(String primName, ODEScene parent_scene, Vector3 pos, Vector3 size,
Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical,bool pisPhantom,byte _shapeType,uint plocalID)
{
_parent_scene = parent_scene;
Name = primName;
LocalID = plocalID;
m_localID = plocalID;
m_vehicle = null;
@ -1113,7 +1120,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
_pbs = pbs;
_parent_scene = parent_scene;
m_targetSpace = IntPtr.Zero;
if (pos.Z < 0)
@ -1159,6 +1165,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_OBBOffset = repData.OBBOffset;
UpdatePrimBodyData();
AddChange(changes.Add, null);
}
private void resetCollisionAccounting()
@ -2441,6 +2449,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private void changeadd()
{
_parent_scene.addToPrims(this);
}
private void changeAngularLock(byte newLocks)

View File

@ -30,6 +30,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
@ -170,7 +171,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public bool m_OSOdeLib = false;
public bool m_suportCombine = false; // mega suport not tested
public Scene m_frameWorkScene = null;
// private int threadid = 0;
@ -258,9 +258,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public ContactData[] m_materialContactsData = new ContactData[8];
private Dictionary<Vector3, IntPtr> RegionTerrain = new Dictionary<Vector3, IntPtr>();
private Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
private Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
private IntPtr TerrainGeom;
private float[] TerrainHeightFieldHeight;
private GCHandle TerrainHeightFieldHeightsHandler = new GCHandle();
private int m_physicsiterations = 15;
private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
@ -302,9 +302,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public int physics_logging_interval = 0;
public bool physics_logging_append_existing_logfile = false;
private Vector3 m_worldOffset = Vector3.Zero;
public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
private PhysicsScene m_parentScene = null;
private ODERayCastRequestManager m_rayCastManager;
public ODEMeshWorker m_meshWorker;
@ -379,8 +377,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
WorldExtents.Y = m_frameWorkScene.RegionInfo.RegionSizeY;
m_regionHeight = (uint)WorldExtents.Y;
m_suportCombine = false;
lock (OdeLock)
{
// Create the world and the first space
@ -803,14 +799,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return;
}
// update actors collision score
if (p1.CollisionScore >= float.MaxValue - count)
p1.CollisionScore = 0;
p1.CollisionScore += count;
if (p2.CollisionScore >= float.MaxValue - count)
p2.CollisionScore = 0;
p2.CollisionScore += count;
// get first contact
d.ContactGeom curContact = new d.ContactGeom();
@ -1056,6 +1044,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
uint obj2LocalID = 0;
// update actors collision score
if (p1.CollisionScore < float.MaxValue)
p1.CollisionScore += 1.0f;
if (p2.CollisionScore < float.MaxValue)
p2.CollisionScore += 1.0f;
bool p1events = p1.SubscribedEvents();
bool p2events = p2.SubscribedEvents();
@ -1328,8 +1322,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID);
lock (_prims)
_prims[newPrim.LocalID] = newPrim;
}
return newPrim;
}
@ -1350,7 +1342,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapeType, uint localid)
{
return AddPrim(primName, position, size, rotation, pbs, isPhysical,isPhantom, shapeType, localid);
}
@ -1396,6 +1387,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
public void addToPrims(OdePrim prim)
{
lock (_prims)
_prims[prim.LocalID] = prim;
}
public OdePrim getPrim(uint id)
{
lock (_prims)
@ -1413,6 +1410,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return _prims.ContainsKey(prm.LocalID);
}
public void changePrimID(OdePrim prim,uint oldID)
{
lock (_prims)
{
if(_prims.ContainsKey(oldID))
_prims.Remove(oldID);
_prims[prim.LocalID] = prim;
}
}
public bool haveActor(PhysicsActor actor)
{
if (actor is OdePrim)
@ -1922,30 +1929,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public float GetTerrainHeightAtXY(float x, float y)
{
int offsetX = 0;
int offsetY = 0;
if (m_suportCombine)
{
offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
}
// get region map
IntPtr heightFieldGeom = IntPtr.Zero;
if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
if (TerrainGeom == IntPtr.Zero)
return 0f;
if (heightFieldGeom == IntPtr.Zero)
return 0f;
if (!TerrainHeightFieldHeights.ContainsKey(heightFieldGeom))
if (TerrainHeightFieldHeight == null || TerrainHeightFieldHeight.Length == 0)
return 0f;
// TerrainHeightField for ODE as offset 1m
x += 1f - offsetX;
y += 1f - offsetY;
x += 1f;
y += 1f;
// make position fit into array
if (x < 0)
@ -2024,7 +2016,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
iy *= regsize;
iy += ix; // all indexes have iy + ix
float[] heights = TerrainHeightFieldHeights[heightFieldGeom];
float[] heights = TerrainHeightFieldHeight;
/*
if ((dx + dy) <= 1.0f)
{
@ -2061,31 +2053,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public Vector3 GetTerrainNormalAtXY(float x, float y)
{
int offsetX = 0;
int offsetY = 0;
if (m_suportCombine)
{
offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
}
// get region map
IntPtr heightFieldGeom = IntPtr.Zero;
Vector3 norm = new Vector3(0, 0, 1);
if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
return norm; ;
if (heightFieldGeom == IntPtr.Zero)
if (TerrainGeom == IntPtr.Zero)
return norm;
if (!TerrainHeightFieldHeights.ContainsKey(heightFieldGeom))
if (TerrainHeightFieldHeight == null || TerrainHeightFieldHeight.Length == 0)
return norm;
// TerrainHeightField for ODE as offset 1m
x += 1f - offsetX;
y += 1f - offsetY;
x += 1f;
y += 1f;
// make position fit into array
if (x < 0)
@ -2172,7 +2150,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
iy *= regsize;
iy += ix; // all indexes have iy + ix
float[] heights = TerrainHeightFieldHeights[heightFieldGeom];
float[] heights = TerrainHeightFieldHeight;
if (firstTri)
{
@ -2198,35 +2176,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
public override void SetTerrain(float[] heightMap)
{
if (m_worldOffset != Vector3.Zero && m_parentScene != null)
{
if (m_parentScene is ODEScene)
{
((ODEScene)m_parentScene).SetTerrain(heightMap, m_worldOffset);
}
}
else
{
SetTerrain(heightMap, m_worldOffset);
}
}
public override void CombineTerrain(float[] heightMap, Vector3 pOffset)
{
if(m_suportCombine)
SetTerrain(heightMap, pOffset);
}
public void SetTerrain(float[] heightMap, Vector3 pOffset)
{
if (m_OSOdeLib)
OSSetTerrain(heightMap, pOffset);
OSSetTerrain(heightMap);
else
OriSetTerrain(heightMap, pOffset);
OriSetTerrain(heightMap);
}
public void OriSetTerrain(float[] heightMap, Vector3 pOffset)
public void OriSetTerrain(float[] heightMap)
{
// assumes 1m size grid and constante size square regions
// needs to know about sims around in future
@ -2291,45 +2248,40 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
d.AllocateODEDataForThread(~0U);
IntPtr GroundGeom = IntPtr.Zero;
if (RegionTerrain.TryGetValue(pOffset, out GroundGeom))
if (TerrainGeom != IntPtr.Zero)
{
RegionTerrain.Remove(pOffset);
if (GroundGeom != IntPtr.Zero)
{
actor_name_map.Remove(GroundGeom);
d.GeomDestroy(GroundGeom);
actor_name_map.Remove(TerrainGeom);
d.GeomDestroy(TerrainGeom);
if (TerrainHeightFieldHeights.ContainsKey(GroundGeom))
{
TerrainHeightFieldHeightsHandlers[GroundGeom].Free();
TerrainHeightFieldHeightsHandlers.Remove(GroundGeom);
TerrainHeightFieldHeights.Remove(GroundGeom);
}
}
}
if (TerrainHeightFieldHeightsHandler.IsAllocated)
TerrainHeightFieldHeightsHandler.Free();
IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
GCHandle _heightmaphandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned);
GC.Collect(1);
d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmaphandler.AddrOfPinnedObject(), 0,
TerrainHeightFieldHeightsHandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned);
d.GeomHeightfieldDataBuildSingle(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0,
heightmapHeight, heightmapWidth ,
(int)heightmapHeightSamples, (int)heightmapWidthSamples, scale,
offset, thickness, wrap);
d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
GroundGeom = d.CreateHeightfield(GroundSpace, HeightmapData, 1);
TerrainGeom = d.CreateHeightfield(GroundSpace, HeightmapData, 1);
if (GroundGeom != IntPtr.Zero)
if (TerrainGeom != IntPtr.Zero)
{
d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land));
d.GeomSetCollideBits(GroundGeom, 0);
d.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
d.GeomSetCollideBits(TerrainGeom, 0);
PhysicsActor pa = new NullPhysicsActor();
pa.Name = "Terrain";
pa.PhysicsActorType = (int)ActorTypes.Ground;
actor_name_map[GroundGeom] = pa;
actor_name_map[TerrainGeom] = pa;
// geom_name_map[GroundGeom] = "Terrain";
@ -2339,16 +2291,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
q.Z = 0.5f;
q.W = 0.5f;
d.GeomSetQuaternion(GroundGeom, ref q);
d.GeomSetPosition(GroundGeom, pOffset.X + m_regionWidth * 0.5f, pOffset.Y + m_regionHeight * 0.5f, 0.0f);
RegionTerrain.Add(pOffset, GroundGeom);
TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
d.GeomSetQuaternion(TerrainGeom, ref q);
d.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f);
TerrainHeightFieldHeight = _heightmap;
}
else
TerrainHeightFieldHeightsHandler.Free();
}
}
public void OSSetTerrain(float[] heightMap, Vector3 pOffset)
public void OSSetTerrain(float[] heightMap)
{
// assumes 1m size grid and constante size square regions
// needs to know about sims around in future
@ -2402,26 +2354,20 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
yt += heightmapWidthSamples;
}
lock (OdeLock)
{
IntPtr GroundGeom = IntPtr.Zero;
if (RegionTerrain.TryGetValue(pOffset, out GroundGeom))
if (TerrainGeom != IntPtr.Zero)
{
RegionTerrain.Remove(pOffset);
if (GroundGeom != IntPtr.Zero)
{
actor_name_map.Remove(GroundGeom);
d.GeomDestroy(GroundGeom);
if (TerrainHeightFieldHeights.ContainsKey(GroundGeom))
{
if (TerrainHeightFieldHeightsHandlers[GroundGeom].IsAllocated)
TerrainHeightFieldHeightsHandlers[GroundGeom].Free();
TerrainHeightFieldHeightsHandlers.Remove(GroundGeom);
TerrainHeightFieldHeights.Remove(GroundGeom);
}
}
actor_name_map.Remove(TerrainGeom);
d.GeomDestroy(TerrainGeom);
}
if (TerrainHeightFieldHeightsHandler.IsAllocated)
TerrainHeightFieldHeightsHandler.Free();
TerrainHeightFieldHeight = null;
IntPtr HeightmapData = d.GeomOSTerrainDataCreate();
const int wrap = 0;
@ -2429,32 +2375,31 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (thickness < 0)
thickness = 1;
GCHandle _heightmaphandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned);
TerrainHeightFieldHeightsHandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned);
d.GeomOSTerrainDataBuild(HeightmapData, _heightmaphandler.AddrOfPinnedObject(), 0, 1.0f,
d.GeomOSTerrainDataBuild(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0, 1.0f,
(int)heightmapWidthSamples, (int)heightmapHeightSamples,
thickness, wrap);
// d.GeomOSTerrainDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
GroundGeom = d.CreateOSTerrain(GroundSpace, HeightmapData, 1);
if (GroundGeom != IntPtr.Zero)
TerrainGeom = d.CreateOSTerrain(GroundSpace, HeightmapData, 1);
if (TerrainGeom != IntPtr.Zero)
{
d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land));
d.GeomSetCollideBits(GroundGeom, 0);
d.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
d.GeomSetCollideBits(TerrainGeom, 0);
PhysicsActor pa = new NullPhysicsActor();
pa.Name = "Terrain";
pa.PhysicsActorType = (int)ActorTypes.Ground;
actor_name_map[GroundGeom] = pa;
actor_name_map[TerrainGeom] = pa;
// geom_name_map[GroundGeom] = "Terrain";
d.GeomSetPosition(GroundGeom, pOffset.X + m_regionWidth * 0.5f, pOffset.Y + m_regionHeight * 0.5f, 0.0f);
RegionTerrain.Add(pOffset, GroundGeom);
TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
}
d.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f);
TerrainHeightFieldHeight = _heightmap;
}
else
TerrainHeightFieldHeightsHandler.Free();
}
}
@ -2467,11 +2412,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return waterlevel;
}
public override bool SupportsCombining()
{
return m_suportCombine;
}
public override void SetWaterLevel(float baseheight)
{
waterlevel = baseheight;
@ -2518,26 +2458,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
foreach (OdeCharacter ch in chtorem)
ch.DoAChange(changes.Remove, null);
if (TerrainGeom != IntPtr.Zero)
d.GeomDestroy(TerrainGeom);
TerrainGeom = IntPtr.Zero;
foreach (IntPtr GroundGeom in RegionTerrain.Values)
{
if (GroundGeom != IntPtr.Zero)
d.GeomDestroy(GroundGeom);
}
if (TerrainHeightFieldHeightsHandler.IsAllocated)
TerrainHeightFieldHeightsHandler.Free();
RegionTerrain.Clear();
if (TerrainHeightFieldHeightsHandlers.Count > 0)
{
foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values)
{
if (gch.IsAllocated)
gch.Free();
}
}
TerrainHeightFieldHeightsHandlers.Clear();
TerrainHeightFieldHeights.Clear();
TerrainHeightFieldHeight = null;
if (ContactgeomsArray != IntPtr.Zero)
{
@ -2556,27 +2484,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
}
private int compareByCollisionsDesc(OdePrim A, OdePrim B)
{
return -A.CollisionScore.CompareTo(B.CollisionScore);
}
public override Dictionary<uint, float> GetTopColliders()
{
Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
int cnt = 0;
lock (_prims)
{
foreach (OdePrim prm in _prims.Values)
{
if (prm.CollisionScore > 0)
{
returncolliders.Add(prm.LocalID, prm.CollisionScore);
cnt++;
prm.CollisionScore = 0f;
if (cnt > 25)
{
break;
}
}
}
}
return returncolliders;
Dictionary<uint, float> topColliders;
List<OdePrim> orderedPrims;
lock (_activeprims)
orderedPrims = new List<OdePrim>(_activeprims);
orderedPrims.Sort(compareByCollisionsDesc);
topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
return topColliders;
}
public override bool SupportsRayCast()

View File

@ -121,9 +121,9 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
CacheExpire = TimeSpan.FromHours(fcache);
if(doMeshFileCache && cachePath != "")
lock (diskLock)
{
lock (diskLock)
if(doMeshFileCache && cachePath != "")
{
try
{
@ -619,7 +619,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
vs.Clear();
continue;
}
/*
if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f))
{
vs.Clear();
@ -657,6 +657,45 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3);
faces.Add(f);
}
*/
List<int> indices;
if (!HullUtils.ComputeHull(vs, out indices))
{
vs.Clear();
continue;
}
nverts = vs.Count;
nindexs = indices.Count;
if (nindexs % 3 != 0)
{
vs.Clear();
continue;
}
for (i = 0; i < nverts; i++)
{
c.X = vs[i].x;
c.Y = vs[i].y;
c.Z = vs[i].z;
coords.Add(c);
}
for (i = 0; i < nindexs; i += 3)
{
t1 = indices[i];
if (t1 > nverts)
break;
t2 = indices[i + 1];
if (t2 > nverts)
break;
t3 = indices[i + 2];
if (t3 > nverts)
break;
f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3);
faces.Add(f);
}
vertsoffset += nverts;
vs.Clear();
}
@ -686,13 +725,15 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
vs.Add(f3);
}
if (vs.Count < 3)
nverts = vs.Count;
if (nverts < 3)
{
vs.Clear();
return false;
}
if (vs.Count < 5)
if (nverts < 5)
{
foreach (float3 point in vs)
{
@ -701,10 +742,11 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
c.Z = point.z;
coords.Add(c);
}
f = new Face(0, 1, 2);
faces.Add(f);
if (vs.Count == 4)
if (nverts == 4)
{
f = new Face(0, 2, 3);
faces.Add(f);
@ -716,7 +758,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
vs.Clear();
return true;
}
/*
if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f))
return false;
@ -747,7 +789,38 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
f = new Face(t1, t2, t3);
faces.Add(f);
}
*/
List<int> indices;
if (!HullUtils.ComputeHull(vs, out indices))
return false;
nindexs = indices.Count;
if (nindexs % 3 != 0)
return false;
for (i = 0; i < nverts; i++)
{
c.X = vs[i].x;
c.Y = vs[i].y;
c.Z = vs[i].z;
coords.Add(c);
}
for (i = 0; i < nindexs; i += 3)
{
t1 = indices[i];
if (t1 > nverts)
break;
t2 = indices[i + 1];
if (t2 > nverts)
break;
t3 = indices[i + 2];
if (t3 > nverts)
break;
f = new Face(t1, t2, t3);
faces.Add(f);
}
vs.Clear();
if (coords.Count > 0 && faces.Count > 0)
return true;
}

View File

@ -57,7 +57,7 @@ namespace PrimMesher
int numLodPixels = lod * lod; // (32 * 2)^2 = 64^2 pixels for default sculpt map image
bool needsScaling = false;
bool smallMap = false;
bool smallMap = false;
width = bmW;
height = bmH;
@ -69,16 +69,8 @@ namespace PrimMesher
needsScaling = true;
}
try
{
if (needsScaling)
bm = ScaleImage(bm, width, height);
}
catch (Exception e)
{
throw new Exception("Exception in ScaleImage(): e: " + e.ToString());
}
if (needsScaling)
bm = ScaleImage(bm, width, height);
if (width * height > numLodPixels)
{
@ -129,11 +121,15 @@ namespace PrimMesher
}
catch (Exception e)
{
if (needsScaling)
bm.Dispose();
throw new Exception("Caught exception processing byte arrays in SculptMap(): e: " + e.ToString());
}
width++;
height++;
if(needsScaling)
bm.Dispose();
}
public List<List<Coord>> ToRows(bool mirror)
@ -168,11 +164,9 @@ namespace PrimMesher
private Bitmap ScaleImage(Bitmap srcImage, int destWidth, int destHeight)
{
Bitmap scaledImage = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
Color c;
// will let last step to be eventually diferent, as seems to be in sl

View File

@ -4323,6 +4323,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
SceneObjectPart targetPart = World.GetSceneObjectPart((UUID)targetID);
if (targetPart == null)
return;
if (targetPart.ParentGroup.AttachmentPoint != 0)
return; // Fail silently if attached
@ -4332,23 +4334,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SceneObjectGroup parentPrim = null, childPrim = null;
if (targetPart != null)
if (parent != 0)
{
if (parent != 0)
{
parentPrim = m_host.ParentGroup;
childPrim = targetPart.ParentGroup;
}
else
{
parentPrim = targetPart.ParentGroup;
childPrim = m_host.ParentGroup;
}
// Required for linking
childPrim.RootPart.ClearUpdateSchedule();
parentPrim.LinkToGroup(childPrim, true);
parentPrim = m_host.ParentGroup;
childPrim = targetPart.ParentGroup;
}
else
{
parentPrim = targetPart.ParentGroup;
childPrim = m_host.ParentGroup;
}
// Required for linking
childPrim.RootPart.ClearUpdateSchedule();
parentPrim.LinkToGroup(childPrim, true);
parentPrim.TriggerScriptChangedEvent(Changed.LINK);
parentPrim.RootPart.CreateSelected = true;
@ -4741,20 +4741,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
Vector3 av3 = Util.Clip(color, 0.0f, 1.0f);
if (text.Length > 254)
text = text.Remove(254);
byte[] data;
do
{
data = Util.UTF8.GetBytes(text);
if (data.Length > 254)
text = text.Substring(0, text.Length - 1);
} while (data.Length > 254);
data = Util.StringToBytes256(text);
text = Util.UTF8.GetString(data);
m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
//m_host.ParentGroup.HasGroupChanged = true;
//m_host.ParentGroup.ScheduleGroupForFullUpdate();
}
public LSL_Float llWater(LSL_Vector offset)
@ -5118,13 +5108,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.CollisionSoundVolume = (float)impact_volume;
m_host.CollisionSound = m_host.invalidCollisionSoundUUID;
m_host.CollisionSoundType = 0;
m_host.CollisionSoundType = -1; // disable all sounds
m_host.aggregateScriptEvents();
return;
}
// TODO: Parameter check logic required.
m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound);
m_host.CollisionSoundVolume = (float)impact_volume;
m_host.CollisionSoundType = 1;
UUID soundId = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound);
if(soundId != UUID.Zero)
{
m_host.CollisionSound = soundId;
m_host.CollisionSoundVolume = (float)impact_volume;
m_host.CollisionSoundType = 1;
}
else
m_host.CollisionSoundType = -1;
m_host.aggregateScriptEvents();
}
public LSL_String llGetAnimation(string id)
@ -14679,13 +14679,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
msAvailable -= m_castRayCalls[i].UsedMs;
}
}
}
// Return failure if not enough available time
if (msAvailable < m_msMinInCastRay)
{
result.Add(new LSL_Integer(ScriptBaseClass.RCERR_CAST_TIME_EXCEEDED));
return result;
// Return failure if not enough available time
if (msAvailable < m_msMinInCastRay)
{
result.Add(new LSL_Integer(ScriptBaseClass.RCERR_CAST_TIME_EXCEEDED));
return result;
}
}
// Initialize
@ -15073,13 +15073,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// Add to throttle data
stopWatch.Stop();
CastRayCall castRayCall = new CastRayCall();
castRayCall.RegionId = regionId;
castRayCall.UserId = userId;
castRayCall.CalledMs = calledMs;
castRayCall.UsedMs = (int)stopWatch.ElapsedMilliseconds;
lock (m_castRayCalls)
{
CastRayCall castRayCall = new CastRayCall();
castRayCall.RegionId = regionId;
castRayCall.UserId = userId;
castRayCall.CalledMs = calledMs;
castRayCall.UsedMs = (int)stopWatch.ElapsedMilliseconds;
m_castRayCalls.Add(castRayCall);
}

View File

@ -45,6 +45,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Scripting;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
@ -4250,5 +4251,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, opts).ToString();
return UUID.Zero.ToString();
}
public void osCollisionSound(string impact_sound, double impact_volume)
{
m_host.AddScriptLPS(1);
if(impact_sound == "")
{
m_host.CollisionSoundVolume = (float)impact_volume;
m_host.CollisionSound = m_host.invalidCollisionSoundUUID;
if(impact_volume == 0.0)
m_host.CollisionSoundType = -1; // disable all sounds
else if(impact_volume == 1.0f)
m_host.CollisionSoundType = 0; // full return to default sounds
else
m_host.CollisionSoundType = 2; // default sounds with volume
m_host.aggregateScriptEvents();
return;
}
// TODO: Parameter check logic required.
UUID soundId = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound);
if(soundId != UUID.Zero)
{
m_host.CollisionSound = soundId;
m_host.CollisionSoundVolume = (float)impact_volume;
m_host.CollisionSoundType = 1;
}
else
m_host.CollisionSoundType = -1;
m_host.aggregateScriptEvents();
}
// still not very usefull, detector is lost on rez, restarts, etc
public void osVolumeDetect(int detect)
{
m_host.AddScriptLPS(1);
if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted || m_host.ParentGroup.IsAttachment)
return;
m_host.ScriptSetVolumeDetect(detect != 0);
}
}
}

View File

@ -476,5 +476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_String osRequestURL(LSL_List options);
LSL_String osRequestSecureURL(LSL_List options);
void osCollisionSound(string impact_sound, double impact_volume);
void osVolumeDetect(int detect);
}
}

View File

@ -1089,5 +1089,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osRequestSecureURL(options);
}
public void osCollisionSound(string impact_sound, double impact_volume)
{
m_OSSL_Functions.osCollisionSound(impact_sound, impact_volume);
}
public void osVolumeDetect(int detect)
{
m_OSSL_Functions.osVolumeDetect(detect);
}
}
}

View File

@ -81,8 +81,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// private object m_syncy = new object();
private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
// private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
// private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
// private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files
private static UInt64 scriptCompileCounter = 0; // And a counter
@ -356,14 +356,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
throw new Exception(errtext);
}
string compileScript = source;
string compileScript = string.Empty;
if (language == enumCompileType.lsl)
{
// Its LSL, convert it to C#
LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls);
compileScript = LSL_Converter.Convert(source);
StringBuilder sb = new StringBuilder(16394);
LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls);
AddCSScriptHeader(
m_scriptEngine.ScriptClassName,
m_scriptEngine.ScriptBaseClassName,
m_scriptEngine.ScriptBaseClassParameters,
sb);
LSL_Converter.Convert(source,sb);
AddCSScriptTail(sb);
compileScript = sb.ToString();
// copy converter warnings into our warnings.
foreach (string warning in LSL_Converter.GetWarnings())
{
@ -374,22 +384,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// Write the linemap to a file and save it in our dictionary for next time.
m_lineMaps[assembly] = linemap;
WriteMapFile(assembly + ".map", linemap);
LSL_Converter.Clear();
}
switch (language)
{
case enumCompileType.cs:
case enumCompileType.lsl:
compileScript = CreateCSCompilerScript(
compileScript,
m_scriptEngine.ScriptClassName,
m_scriptEngine.ScriptBaseClassName,
m_scriptEngine.ScriptBaseClassParameters);
break;
case enumCompileType.vb:
compileScript = CreateVBCompilerScript(
compileScript, m_scriptEngine.ScriptClassName, m_scriptEngine.ScriptBaseClassName);
break;
else
{
switch (language)
{
case enumCompileType.cs:
compileScript = CreateCSCompilerScript(
compileScript,
m_scriptEngine.ScriptClassName,
m_scriptEngine.ScriptBaseClassName,
m_scriptEngine.ScriptBaseClassParameters);
break;
case enumCompileType.vb:
compileScript = CreateVBCompilerScript(
compileScript, m_scriptEngine.ScriptClassName, m_scriptEngine.ScriptBaseClassName);
break;
}
}
assembly = CompileFromDotNetText(compileScript, language, asset, assembly);
@ -419,6 +431,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// return compileScript;
// }
public static void AddCSScriptHeader(string className, string baseClassName, ParameterInfo[] constructorParameters, StringBuilder sb)
{
sb.Append(string.Format(
@"using OpenSim.Region.ScriptEngine.Shared;
using System.Collections.Generic;
namespace SecondLife
{{
public class {0} : {1}
{{
public {0}({2}) : base({3}) {{}}
",
className,
baseClassName,
constructorParameters != null
? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString()))
: "",
constructorParameters != null
? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.Name))
: ""
));
}
public static void AddCSScriptTail(StringBuilder sb)
{
sb.Append(string.Format(" }}\n}}\n"));
}
public static string CreateCSCompilerScript(
string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters)
{
@ -511,8 +551,6 @@ namespace SecondLife
// Do actual compile
CompilerParameters parameters = new CompilerParameters();
parameters.IncludeDebugInformation = true;
string rootPath = AppDomain.CurrentDomain.BaseDirectory;
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
@ -532,26 +570,44 @@ namespace SecondLife
parameters.IncludeDebugInformation = CompileWithDebugInformation;
//parameters.WarningLevel = 1; // Should be 4?
parameters.TreatWarningsAsErrors = false;
parameters.GenerateInMemory = false;
CompilerResults results;
CodeDomProvider provider;
switch (lang)
{
case enumCompileType.vb:
results = VBcodeProvider.CompileAssemblyFromSource(
parameters, Script);
// results = VBcodeProvider.CompileAssemblyFromSource(
// parameters, Script);
provider = CodeDomProvider.CreateProvider("VisualBasic");
break;
case enumCompileType.cs:
case enumCompileType.lsl:
provider = CodeDomProvider.CreateProvider("CSharp");
break;
default:
throw new Exception("Compiler is not able to recongnize " +
"language type \"" + lang.ToString() + "\"");
}
if(provider == null)
throw new Exception("Compiler failed to load ");
bool complete = false;
bool retried = false;
do
{
lock (CScodeProvider)
{
results = CScodeProvider.CompileAssemblyFromSource(
// lock (CScodeProvider)
// {
// results = CScodeProvider.CompileAssemblyFromSource(
// parameters, Script);
// }
results = provider.CompileAssemblyFromSource(
parameters, Script);
}
// Deal with an occasional segv in the compiler.
// Rarely, if ever, occurs twice in succession.
// Line # == 0 and no file name are indications that
@ -575,11 +631,11 @@ namespace SecondLife
complete = true;
}
} while (!complete);
break;
default:
throw new Exception("Compiler is not able to recongnize " +
"language type \"" + lang.ToString() + "\"");
}
// break;
// default:
// throw new Exception("Compiler is not able to recongnize " +
// "language type \"" + lang.ToString() + "\"");
// }
// foreach (Type type in results.CompiledAssembly.GetTypes())
// {
@ -628,6 +684,8 @@ namespace SecondLife
}
}
provider.Dispose();
if (hadErrors)
{
throw new Exception(errtext);
@ -785,15 +843,16 @@ namespace SecondLife
private static void WriteMapFile(string filename, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
{
string mapstring = String.Empty;
StringBuilder mapbuilder = new StringBuilder(1024);
foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> kvp in linemap)
{
KeyValuePair<int, int> k = kvp.Key;
KeyValuePair<int, int> v = kvp.Value;
mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value);
mapbuilder.Append(String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value));
}
Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring);
Byte[] mapbytes = Encoding.ASCII.GetBytes(mapbuilder.ToString());
using (FileStream mfs = File.Create(filename))
mfs.Write(mapbytes, 0, mapbytes.Length);

View File

@ -27,12 +27,15 @@
*/
using System;
using System.Text;
namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{
public interface ICodeConverter
{
string Convert(string script);
void Convert(string script, StringBuilder sb);
string[] GetWarnings();
void Clear();
}
}

View File

@ -191,7 +191,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
Constant rca = new Constant(p, "float", "0.0");
Constant rcb = new Constant(p, "float", "0.0");
Constant rcc = new Constant(p, "float", "0.0");
Constant rcd = new Constant(p, "float", "0.0");
Constant rcd = new Constant(p, "float", "1.0");
ConstantExpression rcea = new ConstantExpression(p, rca);
ConstantExpression rceb = new ConstantExpression(p, rcb);
ConstantExpression rcec = new ConstantExpression(p, rcc);

View File

@ -1388,7 +1388,7 @@ default
"\n LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3));" +
"\n LSL_Types.Vector3 v = new LSL_Types.Vector3(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" +
"\n LSL_Types.Vector3 w = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(0.5));" +
"\n LSL_Types.Quaternion r = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" +
"\n LSL_Types.Quaternion r = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(1.0));" +
"\n LSL_Types.Quaternion u = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.8), new LSL_Types.LSLFloat(0.7), new LSL_Types.LSLFloat(0.6), llSomeFunc());" +
"\n LSL_Types.LSLString k = new LSL_Types.LSLString(\"\");" +
"\n LSL_Types.LSLString n = new LSL_Types.LSLString(\"ping\");" +

View File

@ -37,6 +37,7 @@ using OpenSim.Tests.Common;
namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
{
/// <summary>
/// Tests the LSL compiler. Among other things, test that error messages
/// generated by the C# compiler can be mapped to prper lines/columns in
@ -132,7 +133,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
return compilerResults;
}
/* test too depedent on counting lines and columns maping code generation changes
erros position is better tested on viewers
/// <summary>
/// Test that line number errors are resolved as expected when preceding code contains a jump.
/// </summary>
@ -159,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
positionMap[new KeyValuePair<int, int>(compilerResults.Errors[0].Line, compilerResults.Errors[0].Column)]);
}
/// <summary>
/// Test the C# compiler error message can be mapped to the correct
/// line/column in the LSL source when an undeclared variable is used.
@ -183,7 +186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
new KeyValuePair<int, int>(5, 21),
positionMap[new KeyValuePair<int, int>(compilerResults.Errors[0].Line, compilerResults.Errors[0].Column)]);
}
*/
/// <summary>
/// Test that a string can be cast to string and another string
/// concatenated.

View File

@ -416,7 +416,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
PostEvent(new EventParams("on_rez",
new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0]));
}
if (m_stateSource == StateSource.AttachedRez)
{
PostEvent(new EventParams("attach",
@ -457,7 +456,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
PostEvent(new EventParams("attach",
new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0]));
}
}
}
@ -807,9 +805,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
lock (EventQueue)
{
data = (EventParams)EventQueue.Dequeue();
if (data == null) // Shouldn't happen
if (data == null)
{
if (EventQueue.Count > 0 && Running && !ShuttingDown)
// check if a null event was enqueued or if its really empty
if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete)
{
m_CurrentWorkItem = Engine.QueueEventHandler(this);
}
@ -870,13 +869,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
else
{
Exception e = null;
if (Engine.World.PipeEventsForScript(LocalID) ||
data.EventName == "control") // Don't freeze avies!
{
// m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
// PrimName, ScriptName, data.EventName, State);
try
{
m_CurrentEvent = data.EventName;
@ -891,6 +891,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
m_InEvent = false;
m_CurrentEvent = String.Empty;
lock (EventQueue)
m_CurrentWorkItem = null; // no longer in a event that can be canceled
}
if (m_SaveState)
@ -903,7 +905,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_SaveState = false;
}
}
catch (Exception e)
catch (Exception exx)
{
e = exx;
}
if(e != null)
{
// m_log.DebugFormat(
// "[SCRIPT] Exception in script {0} {1}: {2}{3}",
@ -979,7 +986,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
ScriptTask.ItemID, ScriptTask.AssetID, data.EventName, EventsProcessed);
}
if (EventQueue.Count > 0 && Running && !ShuttingDown)
if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete)
{
m_CurrentWorkItem = Engine.QueueEventHandler(this);
}

View File

@ -339,7 +339,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
y = (float)Quat.y;
z = (float)Quat.z;
s = (float)Quat.s;
if (x == 0 && y == 0 && z == 0 && s == 0)
if (s == 0 && x == 0 && y == 0 && z == 0)
s = 1;
}
@ -349,7 +349,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
y = Y;
z = Z;
s = S;
if (x == 0 && y == 0 && z == 0 && s == 0)
if (s == 0 && x == 0 && y == 0 && z == 0)
s = 1;
}
@ -368,7 +368,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
res = res & Double.TryParse(tmps[1], NumberStyles.Float, Culture.NumberFormatInfo, out y);
res = res & Double.TryParse(tmps[2], NumberStyles.Float, Culture.NumberFormatInfo, out z);
res = res & Double.TryParse(tmps[3], NumberStyles.Float, Culture.NumberFormatInfo, out s);
if (x == 0 && y == 0 && z == 0 && s == 0)
if (s == 0 && x == 0 && y == 0 && z == 0)
s = 1;
}

View File

@ -408,10 +408,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void attach(uint localID, UUID itemID, UUID avatar)
{
myScriptEngine.PostObjectEvent(localID, new EventParams(
SceneObjectGroup grp = myScriptEngine.World.GetSceneObjectGroup(localID);
if(grp == null)
return;
foreach(SceneObjectPart part in grp.Parts)
{
myScriptEngine.PostObjectEvent(part.LocalId, new EventParams(
"attach",new object[] {
new LSL_Types.LSLString(avatar.ToString()) },
new DetectParams[0]));
}
}
// dataserver: not handled here

View File

@ -1024,18 +1024,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// m_log.DebugFormat("[XEngine]: Added script {0} to compile queue", itemID);
if (m_CurrentCompile == null)
// NOTE: Although we use a lockless queue, the lock here
// is required. It ensures that there are never two
// compile threads running, which, due to a race
// conndition, might otherwise happen
//
lock (m_CompileQueue)
{
// NOTE: Although we use a lockless queue, the lock here
// is required. It ensures that there are never two
// compile threads running, which, due to a race
// conndition, might otherwise happen
//
lock (m_CompileQueue)
{
if (m_CurrentCompile == null)
m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null);
}
if (m_CurrentCompile == null)
m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null);
}
}
}
@ -1281,6 +1278,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
// do not load a assembly on top of a lot of to release memory
// also yield a bit
// only if logins disable since causes a lot of rubber banding
if(!m_Scene.LoginsEnabled)
GC.Collect(2);
ScriptInstance instance = null;
lock (m_Scripts)
{
@ -1288,26 +1291,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if ((!m_Scripts.ContainsKey(itemID)) ||
(m_Scripts[itemID].AssetID != assetID))
{
UUID appDomain = assetID;
// UUID appDomain = assetID;
if (part.ParentGroup.IsAttachment)
appDomain = part.ParentGroup.RootPart.UUID;
// if (part.ParentGroup.IsAttachment)
// appDomain = part.ParentGroup.RootPart.UUID;
UUID appDomain = part.ParentGroup.RootPart.UUID;
if (!m_AppDomains.ContainsKey(appDomain))
{
try
{
AppDomainSetup appSetup = new AppDomainSetup();
appSetup.PrivateBinPath = Path.Combine(
m_ScriptEnginesPath,
m_Scene.RegionInfo.RegionID.ToString());
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
Evidence evidence = new Evidence(baseEvidence);
AppDomain sandbox;
if (m_AppDomainLoading)
{
AppDomainSetup appSetup = new AppDomainSetup();
appSetup.PrivateBinPath = Path.Combine(
m_ScriptEnginesPath,
m_Scene.RegionInfo.RegionID.ToString());
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
Evidence evidence = new Evidence(baseEvidence);
sandbox = AppDomain.CreateDomain(
m_Scene.RegionInfo.RegionID.ToString(),
evidence, appSetup);
@ -1472,9 +1476,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
startParam, postOnRez,
m_MaxScriptQueue);
if (
!instance.Load(
scriptObj, coopSleepHandle, assemblyPath,
if(!instance.Load(scriptObj, coopSleepHandle, assemblyPath,
Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript))
return false;
@ -1506,11 +1508,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_PrimObjects[localID].Add(itemID);
}
if (!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assemblyPath;
lock (m_AddingAssemblies)
{
if (!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assemblyPath;
m_AddingAssemblies[assemblyPath]--;
}

View File

@ -139,10 +139,12 @@ namespace OpenSim.Server.Base
startupConfig = Config.Configs["Startup"];
}
ConfigDirectory = startupConfig.GetString("ConfigDirectory", ".");
prompt = startupConfig.GetString("Prompt", prompt);
if (startupConfig != null)
{
ConfigDirectory = startupConfig.GetString("ConfigDirectory", ".");
prompt = startupConfig.GetString("Prompt", prompt);
}
// Allow derived classes to load config before the console is opened.
ReadConfig();

View File

@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Land
ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
uint x = Convert.ToUInt32(requestData["x"]);
uint y = Convert.ToUInt32(requestData["y"]);
m_log.DebugFormat("[LAND HANDLER]: Got request for land data at {0}, {1} for region {2}", x, y, regionHandle);
// m_log.DebugFormat("[LAND HANDLER]: Got request for land data at {0}, {1} for region {2}", x, y, regionHandle);
byte regionAccess;
LandData landData = m_LocalService.GetLandData(UUID.Zero, regionHandle, x, y, out regionAccess);

View File

@ -328,12 +328,16 @@ namespace OpenSim.Server.Handlers.UserAccounts
if (request.ContainsKey("Email"))
email = request["Email"].ToString();
string model = "";
if (request.ContainsKey("Model"))
model = request["Model"].ToString();
UserAccount createdUserAccount = null;
if (m_UserAccountService is UserAccountService)
createdUserAccount
= ((UserAccountService)m_UserAccountService).CreateUser(
scopeID, principalID, firstName, lastName, password, email);
scopeID, principalID, firstName, lastName, password, email, model);
if (createdUserAccount == null)
return FailureResult();
@ -393,4 +397,4 @@ namespace OpenSim.Server.Handlers.UserAccounts
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
}
}
}
}

View File

@ -46,10 +46,13 @@ namespace OpenSim.Services.Connectors
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
const int MAXSENDRETRIESLEN = 30;
private string m_ServerURI = String.Empty;
private IImprovedAssetCache m_Cache = null;
private int m_retryCounter;
private Dictionary<int, List<AssetBase>> m_retryQueue = new Dictionary<int, List<AssetBase>>();
private bool m_inRetries;
private List<AssetBase>[] m_sendRetries = new List<AssetBase>[MAXSENDRETRIESLEN];
private System.Timers.Timer m_retryTimer;
private int m_maxAssetRequestConcurrency = 30;
@ -110,9 +113,9 @@ namespace OpenSim.Services.Connectors
throw new Exception("Asset connector init error");
}
m_retryTimer = new System.Timers.Timer();
m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck);
m_retryTimer.AutoReset = true;
m_retryTimer.Interval = 60000;
Uri serverUri = new Uri(m_ServerURI);
@ -166,48 +169,67 @@ namespace OpenSim.Services.Connectors
protected void retryCheck(object source, ElapsedEventArgs e)
{
m_retryCounter++;
if (m_retryCounter > 60)
m_retryCounter -= 60;
List<int> keys = new List<int>();
foreach (int a in m_retryQueue.Keys)
lock(m_sendRetries)
{
keys.Add(a);
if(m_inRetries)
return;
m_inRetries = true;
}
foreach (int a in keys)
m_retryCounter++;
if(m_retryCounter >= 61 ) // avoid overflow 60 is max in use below
m_retryCounter = 1;
int inUse = 0;
int nextlevel;
int timefactor;
List<AssetBase> retrylist;
// we need to go down
for(int i = MAXSENDRETRIESLEN - 1; i >= 0; i--)
{
lock(m_sendRetries)
retrylist = m_sendRetries[i];
if(retrylist == null)
continue;
inUse++;
nextlevel = i + 1;
//We exponentially fall back on frequency until we reach one attempt per hour
//The net result is that we end up in the queue for roughly 24 hours..
//24 hours worth of assets could be a lot, so the hope is that the region admin
//will have gotten the asset connector back online quickly!
int timefactor = a ^ 2;
if (timefactor > 60)
if(i == 0)
timefactor = 1;
else
{
timefactor = 60;
timefactor = 1 << nextlevel;
if (timefactor > 60)
timefactor = 60;
}
//First, find out if we care about this timefactor
if (timefactor % a == 0)
{
//Yes, we do!
List<AssetBase> retrylist = m_retryQueue[a];
m_retryQueue.Remove(a);
if(m_retryCounter < timefactor)
continue; // to update inUse;
foreach(AssetBase ass in retrylist)
{
Store(ass); //Store my ass. This function will put it back in the dictionary if it fails
}
}
if (m_retryCounter % timefactor != 0)
continue;
// a list to retry
lock(m_sendRetries)
m_sendRetries[i] = null;
// we are the only ones with a copy of this retrylist now
foreach(AssetBase ass in retrylist)
retryStore(ass, nextlevel);
}
if (m_retryQueue.Count == 0)
{
//It might only be one tick per minute, but I have
//repented and abandoned my wasteful ways
m_retryCounter = 0;
m_retryTimer.Stop();
lock(m_sendRetries)
{
if(inUse == 0 )
m_retryTimer.Stop();
m_inRetries = false;
}
}
@ -237,8 +259,9 @@ namespace OpenSim.Services.Connectors
asset = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, m_Auth);
if (m_Cache != null)
m_Cache.Cache(asset);
if (asset != null && m_Cache != null)
m_Cache.Cache(asset);
}
return asset;
}
@ -340,25 +363,18 @@ namespace OpenSim.Services.Connectors
m_AssetHandlers.Remove(id);
}
Util.FireAndForget(x =>
if(handlers != null)
{
Util.FireAndForget(x =>
{
foreach (AssetRetrievedEx h in handlers)
{
// Util.FireAndForget(x =>
// {
try { h.Invoke(a); }
catch { }
// });
}
if (handlers != null)
handlers.Clear();
handlers.Clear();
});
// if (handlers != null)
// handlers.Clear();
}
success = true;
}
}
@ -393,29 +409,24 @@ namespace OpenSim.Services.Connectors
{
AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
// AssetRetrievedEx handlers;
List<AssetRetrievedEx> handlers;
if (m_AssetHandlers.TryGetValue(id, out handlers))
{
// Someone else is already loading this asset. It will notify our handler when done.
// handlers += handlerEx;
handlers.Add(handlerEx);
return true;
}
// Load the asset ourselves
// handlers += handlerEx;
handlers = new List<AssetRetrievedEx>();
handlers.Add(handlerEx);
m_AssetHandlers.Add(id, handlers);
QueuedAssetRequest request = new QueuedAssetRequest();
request.id = id;
request.uri = uri;
m_requestQueue.Enqueue(request);
}
QueuedAssetRequest request = new QueuedAssetRequest();
request.id = id;
request.uri = uri;
m_requestQueue.Enqueue(request);
}
else
{
@ -495,43 +506,34 @@ namespace OpenSim.Services.Connectors
newID = SynchronousRestObjectRequester.
MakeRequest<AssetBase, string>("POST", uri, asset, 100000, m_Auth);
}
catch {}
catch
{
newID = null;
}
if (newID == null || newID == String.Empty || newID == stringUUIDZero)
{
//The asset upload failed, put it in a queue for later
asset.UploadAttempts++;
if (asset.UploadAttempts > 30)
//The asset upload failed, try later
lock(m_sendRetries)
{
//By this stage we've been in the queue for a good few hours;
//We're going to drop the asset.
m_log.ErrorFormat("[Assets] Dropping asset {0} - Upload has been in the queue for too long.", asset.ID.ToString());
}
else
{
if (!m_retryQueue.ContainsKey(asset.UploadAttempts))
{
m_retryQueue.Add(asset.UploadAttempts, new List<AssetBase>());
}
List<AssetBase> m_queue = m_retryQueue[asset.UploadAttempts];
if (m_sendRetries[0] == null)
m_sendRetries[0] = new List<AssetBase>();
List<AssetBase> m_queue = m_sendRetries[0];
m_queue.Add(asset);
m_log.WarnFormat("[Assets] Upload failed: {0} - Requeuing asset for another run.", asset.ID.ToString());
m_log.WarnFormat("[Assets] Upload failed: {0} type {1} will retry later",
asset.ID.ToString(), asset.Type.ToString());
m_retryTimer.Start();
}
}
else
{
if (asset.UploadAttempts > 0)
{
m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), asset.UploadAttempts.ToString());
}
if (newID != asset.ID)
{
// Placing this here, so that this work with old asset servers that don't send any reply back
// SynchronousRestObjectRequester returns somethins that is not an empty string
asset.ID = newID;
// what about FullID ????
if (m_Cache != null)
m_Cache.Cache(asset);
}
@ -539,6 +541,62 @@ namespace OpenSim.Services.Connectors
return asset.ID;
}
public void retryStore(AssetBase asset, int nextRetryLevel)
{
/* this may be bad, so excluding
if (m_Cache != null && !m_Cache.Check(asset.ID))
{
m_log.WarnFormat("[Assets] Upload giveup asset bc no longer in local cache: {0}",
asset.ID.ToString();
return; // if no longer in cache, it was deleted or expired
}
*/
string uri = MapServer(asset.FullID.ToString()) + "/assets/";
string newID = null;
try
{
newID = SynchronousRestObjectRequester.
MakeRequest<AssetBase, string>("POST", uri, asset, 100000, m_Auth);
}
catch
{
newID = null;
}
if (newID == null || newID == String.Empty || newID == stringUUIDZero)
{
if(nextRetryLevel >= MAXSENDRETRIESLEN)
m_log.WarnFormat("[Assets] Upload giveup after several retries id: {0} type {1}",
asset.ID.ToString(), asset.Type.ToString());
else
{
lock(m_sendRetries)
{
if (m_sendRetries[nextRetryLevel] == null)
{
m_sendRetries[nextRetryLevel] = new List<AssetBase>();
}
List<AssetBase> m_queue = m_sendRetries[nextRetryLevel];
m_queue.Add(asset);
m_log.WarnFormat("[Assets] Upload failed: {0} type {1} will retry later",
asset.ID.ToString(), asset.Type.ToString());
}
}
}
else
{
m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), nextRetryLevel.ToString());
if (newID != asset.ID)
{
asset.ID = newID;
if (m_Cache != null)
m_Cache.Cache(asset);
}
}
}
public bool UpdateContent(string id, byte[] data)
{
AssetBase asset = null;
@ -569,6 +627,7 @@ namespace OpenSim.Services.Connectors
return false;
}
public bool Delete(string id)
{
string uri = MapServer(id) + "/assets/" + id;

View File

@ -159,8 +159,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
string filename = string.Empty;
try
{
WebClient c = new WebClient();
{
//m_log.Debug("JPEG: " + imageURL);
string name = regionID.ToString();
filename = Path.Combine(storagePath, name + ".jpg");
@ -168,7 +167,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
if (!File.Exists(filename))
{
m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading...");
c.DownloadFile(imageURL, filename);
using(WebClient c = new WebClient())
c.DownloadFile(imageURL, filename);
}
else
{

View File

@ -106,17 +106,18 @@ namespace OpenSim.Services.Connectors.Simulation
public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string myipaddress, out string reason)
{
m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
reason = String.Empty;
myipaddress = String.Empty;
if (destination == null)
{
reason = "Destination not found";
m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null");
m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Create agent destination is null");
return false;
}
m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
try

View File

@ -512,8 +512,8 @@ namespace OpenSim.Services.LLLoginService
//
if (m_MessageUrl != String.Empty)
{
WebClient client = new WebClient();
processedMessage = client.DownloadString(m_MessageUrl);
using(WebClient client = new WebClient())
processedMessage = client.DownloadString(m_MessageUrl);
}
else
{

View File

@ -92,7 +92,7 @@ namespace OpenSim.Services.UserAccountService
m_RootInstance = this;
MainConsole.Instance.Commands.AddCommand("Users", false,
"create user",
"create user [<first> [<last> [<pass> [<email> [<user id>]]]]]",
"create user [<first> [<last> [<pass> [<email> [<user id> [<model>]]]]]]",
"Create a new user", HandleCreateUser);
MainConsole.Instance.Commands.AddCommand("Users", false,
@ -353,7 +353,7 @@ namespace OpenSim.Services.UserAccountService
/// <summary>
/// Handle the create user command from the console.
/// </summary>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email, userID, model name </param>
protected void HandleCreateUser(string module, string[] cmdparams)
{
string firstName;
@ -361,6 +361,7 @@ namespace OpenSim.Services.UserAccountService
string password;
string email;
string rawPrincipalId;
string model;
List<char> excluded = new List<char>(new char[]{' '});
@ -385,11 +386,16 @@ namespace OpenSim.Services.UserAccountService
else
rawPrincipalId = cmdparams[6];
if (cmdparams.Length < 8)
model = MainConsole.Instance.CmdPrompt("Model name","");
else
model = cmdparams[7];
UUID principalId = UUID.Zero;
if (!UUID.TryParse(rawPrincipalId, out principalId))
throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId));
CreateUser(UUID.Zero, principalId, firstName, lastName, password, email);
CreateUser(UUID.Zero, principalId, firstName, lastName, password, email, model);
}
protected void HandleShowAccount(string module, string[] cmdparams)
@ -544,7 +550,8 @@ namespace OpenSim.Services.UserAccountService
/// <param name="lastName"></param>
/// <param name="password"></param>
/// <param name="email"></param>
public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email)
/// <param name="model"></param>
public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email, string model = "")
{
UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
if (null == account)
@ -603,7 +610,12 @@ namespace OpenSim.Services.UserAccountService
}
if (m_CreateDefaultAvatarEntries)
CreateDefaultAppearanceEntries(account.PrincipalID);
{
if (String.IsNullOrEmpty(model))
CreateDefaultAppearanceEntries(account.PrincipalID);
else
EstablishAppearance(account.PrincipalID, model);
}
}
m_log.InfoFormat(
@ -734,6 +746,7 @@ namespace OpenSim.Services.UserAccountService
wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID);
AvatarAppearance ap = new AvatarAppearance();
// this loop works, but is questionable
for (int i = 0; i < 6; i++)
{
ap.SetWearable(i, wearables[i]);
@ -742,5 +755,205 @@ namespace OpenSim.Services.UserAccountService
m_AvatarService.SetAppearance(principalID, ap);
}
}
protected void EstablishAppearance(UUID destinationAgent, string model)
{
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Establishing new appearance for {0} - {1}",
destinationAgent.ToString(), model);
string[] modelSpecifiers = model.Split();
if (modelSpecifiers.Length != 2)
{
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Invalid model name \'{0}\'. Falling back to Ruth for {1}",
model, destinationAgent);
CreateDefaultAppearanceEntries(destinationAgent);
return;
}
// Does the source model exist?
UserAccount modelAccount = GetUserAccount(UUID.Zero, modelSpecifiers[0], modelSpecifiers[1]);
if (modelAccount == null)
{
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Requested model \'{0}\' not found. Falling back to Ruth for {1}",
model, destinationAgent);
CreateDefaultAppearanceEntries(destinationAgent);
return;
}
// Does the source model have an established appearance herself?
AvatarAppearance modelAppearance = m_AvatarService.GetAppearance(modelAccount.PrincipalID);
if (modelAppearance == null)
{
m_log.WarnFormat("USER ACCOUNT SERVICE]: Requested model \'{0}\' does not have an established appearance. Falling back to Ruth for {1}",
model, destinationAgent);
CreateDefaultAppearanceEntries(destinationAgent);
return;
}
try
{
CopyWearablesAndAttachments(destinationAgent, modelAccount.PrincipalID, modelAppearance);
m_AvatarService.SetAppearance(destinationAgent, modelAppearance);
}
catch (Exception e)
{
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring appearance for {0} : {1}",
destinationAgent, e.Message);
}
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Finished establishing appearance for {0}",
destinationAgent.ToString());
}
/// <summary>
/// This method is called by EstablishAppearance to do a copy all inventory items
/// worn or attached to the Clothing inventory folder of the receiving avatar.
/// In parallel the avatar wearables and attachments are updated.
/// </summary>
private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
{
// Get Clothing folder of receiver
InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing);
if (destinationFolder == null)
throw new Exception("Cannot locate folder(s)");
// Missing destination folder? This should *never* be the case
if (destinationFolder.Type != (short)FolderType.Clothing)
{
destinationFolder = new InventoryFolderBase();
destinationFolder.ID = UUID.Random();
destinationFolder.Name = "Clothing";
destinationFolder.Owner = destination;
destinationFolder.Type = (short)AssetType.Clothing;
destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID;
destinationFolder.Version = 1;
m_InventoryService.AddFolder(destinationFolder); // store base record
m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0}", source);
}
// Wearables
AvatarWearable[] wearables = avatarAppearance.Wearables;
AvatarWearable wearable;
for (int i = 0; i < wearables.Length; i++)
{
wearable = wearables[i];
if (wearable[0].ItemID != UUID.Zero)
{
// Get inventory item and copy it
InventoryItemBase item = m_InventoryService.GetItem(source, wearable[0].ItemID);
if (item != null)
{
InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
destinationItem.Name = item.Name;
destinationItem.Owner = destination;
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
destinationItem.CreatorData = item.CreatorData;
destinationItem.NextPermissions = item.NextPermissions;
destinationItem.CurrentPermissions = item.CurrentPermissions;
destinationItem.BasePermissions = item.BasePermissions;
destinationItem.EveryOnePermissions = item.EveryOnePermissions;
destinationItem.GroupPermissions = item.GroupPermissions;
destinationItem.AssetType = item.AssetType;
destinationItem.AssetID = item.AssetID;
destinationItem.GroupID = item.GroupID;
destinationItem.GroupOwned = item.GroupOwned;
destinationItem.SalePrice = item.SalePrice;
destinationItem.SaleType = item.SaleType;
destinationItem.Flags = item.Flags;
destinationItem.CreationDate = item.CreationDate;
destinationItem.Folder = destinationFolder.ID;
ApplyNextOwnerPermissions(destinationItem);
m_InventoryService.AddItem(destinationItem);
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
// Wear item
AvatarWearable newWearable = new AvatarWearable();
newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
avatarAppearance.SetWearable(i, newWearable);
}
else
{
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID);
}
}
}
// Attachments
List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
foreach (AvatarAttachment attachment in attachments)
{
int attachpoint = attachment.AttachPoint;
UUID itemID = attachment.ItemID;
if (itemID != UUID.Zero)
{
// Get inventory item and copy it
InventoryItemBase item = m_InventoryService.GetItem(source, itemID);
if (item != null)
{
InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
destinationItem.Name = item.Name;
destinationItem.Owner = destination;
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
destinationItem.CreatorData = item.CreatorData;
destinationItem.NextPermissions = item.NextPermissions;
destinationItem.CurrentPermissions = item.CurrentPermissions;
destinationItem.BasePermissions = item.BasePermissions;
destinationItem.EveryOnePermissions = item.EveryOnePermissions;
destinationItem.GroupPermissions = item.GroupPermissions;
destinationItem.AssetType = item.AssetType;
destinationItem.AssetID = item.AssetID;
destinationItem.GroupID = item.GroupID;
destinationItem.GroupOwned = item.GroupOwned;
destinationItem.SalePrice = item.SalePrice;
destinationItem.SaleType = item.SaleType;
destinationItem.Flags = item.Flags;
destinationItem.CreationDate = item.CreationDate;
destinationItem.Folder = destinationFolder.ID;
ApplyNextOwnerPermissions(destinationItem);
m_InventoryService.AddItem(destinationItem);
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
// Attach item
avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Attached {0}", destinationItem.ID);
}
else
{
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID);
}
}
}
}
/// <summary>
/// Apply next owner permissions.
/// </summary>
private void ApplyNextOwnerPermissions(InventoryItemBase item)
{
if (item.InvType == (int)InventoryType.Object)
{
uint perms = item.CurrentPermissions;
PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
item.CurrentPermissions = perms;
}
item.CurrentPermissions &= item.NextPermissions;
item.BasePermissions &= item.NextPermissions;
item.EveryOnePermissions &= item.NextPermissions;
}
}
}

View File

@ -1384,6 +1384,10 @@ namespace OpenSim.Tests.Common
{
}
public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
{
}
public void SendPartPhysicsProprieties(ISceneEntity entity)
{
}

View File

@ -1485,6 +1485,9 @@ namespace Amib.Threading
_isIdleWaitHandle = null;
}
if (_stpStartInfo.EnableLocalPerformanceCounters)
_localPCs.Dispose();
_isDisposed = true;
}
}
@ -1684,6 +1687,7 @@ namespace Amib.Threading
}
workItemsGroup.Start();
anActionCompleted.WaitOne();
anActionCompleted.Dispose();
return choiceIndex._index;
}

View File

@ -192,15 +192,6 @@
;; YOU HAVE BEEN WARNED!!!
; TrustBinaries = false
;# {CombineContiguousRegions} {} {Create megaregions where possible? (Do not use with existing content or varregions!)} {true false} false
;; Combine all contiguous regions into one large megaregion
;; Order your regions from South to North, West to East in your regions.ini
;; and then set this to true
;; Warning! Don't use this with regions that have existing content!,
;; This will likely break them
;; Also, this setting should be set to false for varregions as they are proper larger single regions rather than combined smaller regions.
; CombineContiguousRegions = false
;# {InworldRestartShutsDown} {} {Shutdown instance on region restart?} {true false} false
;; If you have only one region in an instance, or to avoid the many bugs
;; that you can trigger in modules by restarting a region, set this to

View File

@ -156,11 +156,6 @@
; YOU HAVE BEEN WARNED!!!
TrustBinaries = false
; Combine all contiguous regions into one large megaregion
; Order your regions from South to North, West to East in your regions.ini and then set this to true
; Warning! Don't use this with regions that have existing content!, This will likely break them
CombineContiguousRegions = false
; the default view range. Viewers override this ( no major effect still )
DefaultDrawDistance = 255.0

Binary file not shown.