Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

slimupdates
John Hurliman 2010-03-15 15:38:55 -07:00
commit 4e180e84e2
10 changed files with 2966 additions and 2927 deletions

View File

@ -169,6 +169,81 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return true;
}
public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true);
}
public UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
{
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt);
if (updateInventoryStatus)
{
if (att == null)
{
ShowDetachInUserInventory(itemID, remoteClient);
}
SetAttachmentInventoryStatus(att, remoteClient, itemID, AttachmentPt);
}
if (null == att)
return UUID.Zero;
else
return att.UUID;
}
protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null)
{
SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, remoteClient.AgentId, true);
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
// objatt.Name, remoteClient.Name, AttachmentPt);
if (objatt != null)
{
bool tainted = false;
if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
tainted = true;
AttachObject(
remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
//objatt.ScheduleGroupForFullUpdate();
if (tainted)
objatt.HasGroupChanged = true;
// Fire after attach, so we don't get messy perms dialogs
// 3 == AttachedRez
objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3);
// Do this last so that event listeners have access to all the effects of the attachment
m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
}
else
{
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
itemID, remoteClient.Name, AttachmentPt);
}
return objatt;
}
return null;
}
public UUID SetAttachmentInventoryStatus(
SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{

View File

@ -58,6 +58,29 @@ namespace OpenSim.Region.Framework.Interfaces
bool AttachObject(
IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent);
/// <summary>
/// Rez an attachment from user inventory and change inventory status to match.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="AttachmentPt"></param>
/// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
/// <summary>
/// Rez an attachment from user inventory
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="AttachmentPt"></param>
/// <param name="updateinventoryStatus">
/// If true, we also update the user's inventory to show that the attachment is set. If false, we do not.
/// False is required so that we don't attempt to update information when a user enters a scene with the
/// attachment already correctly set up in inventory.
/// <returns>The uuid of the scene object that was attached. Null if the scene object could not be found</returns>
UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus);
/// <summary>
/// Update the user inventory to the attachment of an item
/// </summary>

View File

@ -1842,35 +1842,12 @@ namespace OpenSim.Region.Framework.Scenes
EventManager.TriggerOnAttach(localID, itemID, avatarID);
}
/// <summary>
/// Called when the client receives a request to rez a single attachment on to the avatar from inventory
/// (RezSingleAttachmentFromInv packet).
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="AttachmentPt"></param>
/// <returns></returns>
public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt);
if (att == null)
{
AttachmentsModule.ShowDetachInUserInventory(itemID, remoteClient);
return UUID.Zero;
}
return AttachmentsModule.SetAttachmentInventoryStatus(att, remoteClient, itemID, AttachmentPt);
}
public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
{
foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
{
RezSingleAttachment(remoteClient, obj.ItemID, obj.AttachmentPt);
AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
}
}

View File

@ -2338,10 +2338,10 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID);
ScenePresence sp = GetScenePresence(userID);
if (sp != null)
if (sp != null && AttachmentsModule != null)
{
uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt);
AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt);
}
return false;
@ -2643,12 +2643,12 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
{
client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
client.OnObjectDetach += m_sceneGraph.DetachObject;
if (AttachmentsModule != null)
{
client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
client.OnObjectAttach += AttachmentsModule.AttachObject;
client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
}
@ -2800,11 +2800,11 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
{
client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
client.OnRezSingleAttachmentFromInv -= RezSingleAttachment;
client.OnObjectDetach -= m_sceneGraph.DetachObject;
if (AttachmentsModule != null)
{
client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
client.OnObjectAttach -= AttachmentsModule.AttachObject;
client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
}

View File

@ -486,59 +486,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Rez an attachment
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="AttachmentPt"></param>
/// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null)
{
SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, remoteClient.AgentId, true);
// m_log.DebugFormat(
// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}",
// objatt.Name, remoteClient.Name, AttachmentPt);
if (objatt != null)
{
bool tainted = false;
if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
tainted = true;
m_parentScene.AttachmentsModule.AttachObject(
remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
//objatt.ScheduleGroupForFullUpdate();
if (tainted)
objatt.HasGroupChanged = true;
// Fire after attach, so we don't get messy perms dialogs
// 3 == AttachedRez
objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
// Do this last so that event listeners have access to all the effects of the attachment
m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
}
else
{
m_log.WarnFormat(
"[SCENE GRAPH]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
itemID, remoteClient.Name, AttachmentPt);
}
return objatt;
}
return null;
}
protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
{
ScenePresence newAvatar = null;

View File

@ -676,6 +676,7 @@ namespace OpenSim.Region.Framework.Scenes
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
if (account != null)
m_userLevel = account.UserLevel;
IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
@ -3738,7 +3739,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (null == m_appearance)
{
m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID);
m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID);
return;
}
@ -3762,12 +3763,12 @@ namespace OpenSim.Region.Framework.Scenes
try
{
// Rez from inventory
UUID asset = m_scene.RezSingleAttachment(ControllingClient,
itemID, (uint)p);
UUID asset
= m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p);
m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
m_log.InfoFormat(
"[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
p, itemID, assetID, asset);
}
catch (Exception e)
{

View File

@ -827,15 +827,16 @@ namespace PrimMesher
if (createFaces)
{
int numOuterVerts = this.coords.Count;
int numHollowVerts = hollowCoords.Count;
int numTotalVerts = numOuterVerts + numHollowVerts;
//int numOuterVerts = this.coords.Count;
//numOuterVerts = this.coords.Count;
//int numHollowVerts = hollowCoords.Count;
int numTotalVerts = this.numOuterVerts + this.numHollowVerts;
if (numOuterVerts == numHollowVerts)
if (this.numOuterVerts == this.numHollowVerts)
{
Face newFace = new Face();
for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++)
for (int coordIndex = 0; coordIndex < this.numOuterVerts - 1; coordIndex++)
{
newFace.v1 = coordIndex;
newFace.v2 = coordIndex + 1;
@ -850,12 +851,12 @@ namespace PrimMesher
}
else
{
if (numOuterVerts < numHollowVerts)
if (this.numOuterVerts < this.numHollowVerts)
{
Face newFace = new Face();
int j = 0; // j is the index for outer vertices
int maxJ = numOuterVerts - 1;
for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
int maxJ = this.numOuterVerts - 1;
for (int i = 0; i < this.numHollowVerts; i++) // i is the index for inner vertices
{
if (j < maxJ)
if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle < hollowAngles.angles[i].angle - angles.angles[j].angle + 0.000001f)
@ -879,8 +880,8 @@ namespace PrimMesher
{
Face newFace = new Face();
int j = 0; // j is the index for inner vertices
int maxJ = numHollowVerts - 1;
for (int i = 0; i < numOuterVerts; i++)
int maxJ = this.numHollowVerts - 1;
for (int i = 0; i < this.numOuterVerts; i++)
{
if (j < maxJ)
if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[j].angle + 0.000001f)
@ -981,7 +982,7 @@ namespace PrimMesher
int startVert = hasProfileCut && !hasHollow ? 1 : 0;
if (startVert > 0)
this.faceNumbers.Add(-1);
for (int i = 0; i < numOuterVerts - 1; i++)
for (int i = 0; i < this.numOuterVerts - 1; i++)
this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum);
//if (!hasHollow && !hasProfileCut)
@ -994,7 +995,7 @@ namespace PrimMesher
if (hasHollow)
{
for (int i = 0; i < numHollowVerts; i++)
for (int i = 0; i < this.numHollowVerts; i++)
this.faceNumbers.Add(faceNum);
faceNum++;
@ -1019,7 +1020,7 @@ namespace PrimMesher
{
this.faceUVs = new List<UVCoord>();
foreach (Coord c in this.coords)
this.faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y)));
this.faceUVs.Add(new UVCoord(0.5f + c.X, 0.5f - c.Y));
}
internal Profile Copy()
@ -1348,7 +1349,6 @@ namespace PrimMesher
float stepSize = twoPi / this.stepsPerRevolution;
int step = (int)(startAngle / stepSize);
// int firstStep = step;
float angle = startAngle;
bool done = false;
@ -1738,7 +1738,6 @@ namespace PrimMesher
// append this layer
int coordsLen = this.coords.Count;
// int lastCoordsLen = coordsLen;
newLayer.AddValue2FaceVertexIndices(coordsLen);
this.coords.AddRange(newLayer.coords);

View File

@ -53,42 +53,49 @@ namespace PrimMesher
public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 };
#if SYSTEM_DRAWING
// private Bitmap ScaleImage(Bitmap srcImage, float scale)
// {
// int sourceWidth = srcImage.Width;
// int sourceHeight = srcImage.Height;
// int sourceX = 0;
// int sourceY = 0;
private Bitmap ScaleImage(Bitmap srcImage, float scale, bool removeAlpha)
{
int sourceWidth = srcImage.Width;
int sourceHeight = srcImage.Height;
int sourceX = 0;
int sourceY = 0;
// int destX = 0;
// int destY = 0;
// int destWidth = (int)(srcImage.Width * scale);
// int destHeight = (int)(srcImage.Height * scale);
int destX = 0;
int destY = 0;
int destWidth = (int)(srcImage.Width * scale);
int destHeight = (int)(srcImage.Height * scale);
// if (srcImage.PixelFormat == PixelFormat.Format32bppArgb)
// for (int y = 0; y < srcImage.Height; y++)
// for (int x = 0; x < srcImage.Width; x++)
// {
// Color c = srcImage.GetPixel(x, y);
// srcImage.SetPixel(x, y, Color.FromArgb(255, c.R, c.G, c.B));
// }
Bitmap scaledImage;
// Bitmap scaledImage = new Bitmap(destWidth, destHeight,
// PixelFormat.Format24bppRgb);
if (removeAlpha)
{
if (srcImage.PixelFormat == PixelFormat.Format32bppArgb)
for (int y = 0; y < srcImage.Height; y++)
for (int x = 0; x < srcImage.Width; x++)
{
Color c = srcImage.GetPixel(x, y);
srcImage.SetPixel(x, y, Color.FromArgb(255, c.R, c.G, c.B));
}
// scaledImage.SetResolution(96.0f, 96.0f);
scaledImage = new Bitmap(destWidth, destHeight,
PixelFormat.Format24bppRgb);
}
else
scaledImage = new Bitmap(srcImage, destWidth, destHeight);
// Graphics grPhoto = Graphics.FromImage(scaledImage);
// grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
scaledImage.SetResolution(96.0f, 96.0f);
// grPhoto.DrawImage(srcImage,
// new Rectangle(destX, destY, destWidth, destHeight),
// new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
// GraphicsUnit.Pixel);
Graphics grPhoto = Graphics.FromImage(scaledImage);
grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
// grPhoto.Dispose();
// return scaledImage;
// }
grPhoto.DrawImage(srcImage,
new Rectangle(destX, destY, destWidth, destHeight),
new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
GraphicsUnit.Pixel);
grPhoto.Dispose();
return scaledImage;
}
public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode)
@ -268,6 +275,11 @@ namespace PrimMesher
for (imageY = imageYStart; imageY < imageYEnd; imageY++)
{
Color c = bitmap.GetPixel(imageX, imageY);
if (c.A != 255)
{
bitmap.SetPixel(imageX, imageY, Color.FromArgb(255, c.R, c.G, c.B));
c = bitmap.GetPixel(imageX, imageY);
}
rSum += c.R;
gSum += c.G;
bSum += c.B;
@ -298,12 +310,18 @@ namespace PrimMesher
if (sculptType == SculptType.plane)
invert = !invert;
float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
float sculptBitmapLod = (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
int scale = (int)(1.0f / sourceScaleFactor);
if (scale < 1) scale = 1;
float sourceScaleFactor = (float)(lod) / sculptBitmapLod;
_SculptMesh(bitmap2Coords(sculptBitmap, scale, mirror), sculptType, viewerMode, mirror, invert);
float fScale = 1.0f / sourceScaleFactor;
int iScale = (int)fScale;
if (iScale < 1) iScale = 1;
if (iScale > 2 && iScale % 2 == 0)
_SculptMesh(bitmap2Coords(ScaleImage(sculptBitmap, 64.0f / sculptBitmapLod, true), 64 / lod, mirror), sculptType, viewerMode, mirror, invert);
else
_SculptMesh(bitmap2Coords(sculptBitmap, iScale, mirror), sculptType, viewerMode, mirror, invert);
}
#endif

View File

@ -123,8 +123,7 @@ namespace OpenSim.Services.GridService
if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0)
{
// Regions reserved for the null key cannot be taken.
//
if (region.Data["PrincipalID"] == UUID.Zero.ToString())
if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString())
return "Region location us reserved";
// Treat it as an auth request
@ -132,7 +131,6 @@ namespace OpenSim.Services.GridService
// NOTE: Fudging the flags value here, so these flags
// should not be used elsewhere. Don't optimize
// this with the later retrieval of the same flags!
//
rflags |= OpenSim.Data.RegionFlags.Authenticate;
}
@ -489,7 +487,7 @@ namespace OpenSim.Services.GridService
f |= (OpenSim.Data.RegionFlags)val;
}
}
catch (Exception e)
catch (Exception)
{
MainConsole.Instance.Output("Error in flag specification: " + p);
}

View File

@ -168,10 +168,11 @@ namespace OpenSim.Services.GridService
}
// Sanity check.
IPAddress ipaddr = null;
//IPAddress ipaddr = null;
try
{
ipaddr = Util.GetHostFromDNS(host);
//ipaddr = Util.GetHostFromDNS(host);
Util.GetHostFromDNS(host);
}
catch
{