Merge branch 'master' of /home/opensim/var/repo/opensim

integration
BlueWall 2012-07-11 19:41:17 -04:00
commit e28e2ef3ac
23 changed files with 149 additions and 107 deletions

View File

@ -50,7 +50,7 @@ namespace OpenSim.ConsoleClient
request.ContentType = "application/x-www-form-urlencoded"; request.ContentType = "application/x-www-form-urlencoded";
byte[] buffer = new System.Text.ASCIIEncoding().GetBytes(data); byte[] buffer = Encoding.ASCII.GetBytes(data);
int length = (int) buffer.Length; int length = (int) buffer.Length;
request.ContentLength = length; request.ContentLength = length;

View File

@ -44,8 +44,6 @@ namespace OpenSim.Framework.Serialization.External
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors
= new Dictionary<string, Action<LandData, XmlTextReader>>(); = new Dictionary<string, Action<LandData, XmlTextReader>>();
@ -163,7 +161,7 @@ namespace OpenSim.Framework.Serialization.External
/// <exception cref="System.Xml.XmlException"></exception> /// <exception cref="System.Xml.XmlException"></exception>
public static LandData Deserialize(byte[] serializedLandData) public static LandData Deserialize(byte[] serializedLandData)
{ {
return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length)); return Deserialize(Encoding.UTF8.GetString(serializedLandData, 0, serializedLandData.Length));
} }
/// <summary> /// <summary>

View File

@ -40,8 +40,6 @@ namespace OpenSim.Framework.Serialization.External
/// </summary> /// </summary>
public class RegionSettingsSerializer public class RegionSettingsSerializer
{ {
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
/// <summary> /// <summary>
/// Deserialize settings /// Deserialize settings
/// </summary> /// </summary>
@ -50,7 +48,7 @@ namespace OpenSim.Framework.Serialization.External
/// <exception cref="System.Xml.XmlException"></exception> /// <exception cref="System.Xml.XmlException"></exception>
public static RegionSettings Deserialize(byte[] serializedSettings) public static RegionSettings Deserialize(byte[] serializedSettings)
{ {
return Deserialize(m_asciiEncoding.GetString(serializedSettings, 0, serializedSettings.Length)); return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length));
} }
/// <summary> /// <summary>

View File

@ -53,8 +53,6 @@ namespace OpenSim.Framework.Serialization
TYPE_CONTIGUOUS_FILE = 8, TYPE_CONTIGUOUS_FILE = 8,
} }
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
/// <summary> /// <summary>
/// Binary reader for the underlying stream /// Binary reader for the underlying stream
/// </summary> /// </summary>
@ -120,13 +118,13 @@ namespace OpenSim.Framework.Serialization
if (header[156] == (byte)'L') if (header[156] == (byte)'L')
{ {
int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11);
tarHeader.FilePath = m_asciiEncoding.GetString(ReadData(longNameLength)); tarHeader.FilePath = Encoding.ASCII.GetString(ReadData(longNameLength));
//m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); //m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath);
header = m_br.ReadBytes(512); header = m_br.ReadBytes(512);
} }
else else
{ {
tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); tarHeader.FilePath = Encoding.ASCII.GetString(header, 0, 100);
tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
//m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath); //m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath);
} }
@ -205,7 +203,7 @@ namespace OpenSim.Framework.Serialization
{ {
// Trim leading white space: ancient tars do that instead // Trim leading white space: ancient tars do that instead
// of leading 0s :-( don't ask. really. // of leading 0s :-( don't ask. really.
string oString = m_asciiEncoding.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray); string oString = Encoding.ASCII.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray);
int d = 0; int d = 0;

View File

@ -41,7 +41,6 @@ namespace OpenSim.Framework.Serialization
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
/// <summary> /// <summary>
@ -85,7 +84,7 @@ namespace OpenSim.Framework.Serialization
public void WriteFile(string filePath, byte[] data) public void WriteFile(string filePath, byte[] data)
{ {
if (filePath.Length > 100) if (filePath.Length > 100)
WriteEntry("././@LongLink", m_asciiEncoding.GetBytes(filePath), 'L'); WriteEntry("././@LongLink", Encoding.ASCII.GetBytes(filePath), 'L');
char fileType; char fileType;
@ -137,7 +136,7 @@ namespace OpenSim.Framework.Serialization
oString = "0" + oString; oString = "0" + oString;
} }
byte[] oBytes = m_asciiEncoding.GetBytes(oString); byte[] oBytes = Encoding.ASCII.GetBytes(oString);
return oBytes; return oBytes;
} }
@ -156,20 +155,20 @@ namespace OpenSim.Framework.Serialization
byte[] header = new byte[512]; byte[] header = new byte[512];
// file path field (100) // file path field (100)
byte[] nameBytes = m_asciiEncoding.GetBytes(filePath); byte[] nameBytes = Encoding.ASCII.GetBytes(filePath);
int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length; int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
Array.Copy(nameBytes, header, nameSize); Array.Copy(nameBytes, header, nameSize);
// file mode (8) // file mode (8)
byte[] modeBytes = m_asciiEncoding.GetBytes("0000777"); byte[] modeBytes = Encoding.ASCII.GetBytes("0000777");
Array.Copy(modeBytes, 0, header, 100, 7); Array.Copy(modeBytes, 0, header, 100, 7);
// owner user id (8) // owner user id (8)
byte[] ownerIdBytes = m_asciiEncoding.GetBytes("0000764"); byte[] ownerIdBytes = Encoding.ASCII.GetBytes("0000764");
Array.Copy(ownerIdBytes, 0, header, 108, 7); Array.Copy(ownerIdBytes, 0, header, 108, 7);
// group user id (8) // group user id (8)
byte[] groupIdBytes = m_asciiEncoding.GetBytes("0000764"); byte[] groupIdBytes = Encoding.ASCII.GetBytes("0000764");
Array.Copy(groupIdBytes, 0, header, 116, 7); Array.Copy(groupIdBytes, 0, header, 116, 7);
// file size in bytes (12) // file size in bytes (12)
@ -181,17 +180,17 @@ namespace OpenSim.Framework.Serialization
Array.Copy(fileSizeBytes, 0, header, 124, 11); Array.Copy(fileSizeBytes, 0, header, 124, 11);
// last modification time (12) // last modification time (12)
byte[] lastModTimeBytes = m_asciiEncoding.GetBytes("11017037332"); byte[] lastModTimeBytes = Encoding.ASCII.GetBytes("11017037332");
Array.Copy(lastModTimeBytes, 0, header, 136, 11); Array.Copy(lastModTimeBytes, 0, header, 136, 11);
// entry type indicator (1) // entry type indicator (1)
header[156] = m_asciiEncoding.GetBytes(new char[] { fileType })[0]; header[156] = Encoding.ASCII.GetBytes(new char[] { fileType })[0];
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7); Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 329, 7);
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7); Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 337, 7);
// check sum for header block (8) [calculated last] // check sum for header block (8) [calculated last]
Array.Copy(m_asciiEncoding.GetBytes(" "), 0, header, 148, 8); Array.Copy(Encoding.ASCII.GetBytes(" "), 0, header, 148, 8);
int checksum = 0; int checksum = 0;
foreach (byte b in header) foreach (byte b in header)

View File

@ -591,8 +591,8 @@ namespace OpenSim.Framework.Servers
{ {
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
FileStream fs = File.Create(path); FileStream fs = File.Create(path);
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
Byte[] buf = enc.GetBytes(pidstring); Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length); fs.Write(buf, 0, buf.Length);
fs.Close(); fs.Close();
m_pidFile = path; m_pidFile = path;

View File

@ -1236,8 +1236,7 @@ namespace OpenSim.Framework
public static string Base64ToString(string str) public static string Base64ToString(string str)
{ {
UTF8Encoding encoder = new UTF8Encoding(); Decoder utf8Decode = Encoding.UTF8.GetDecoder();
Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(str); byte[] todecode_byte = Convert.FromBase64String(str);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);

View File

@ -46,8 +46,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
/// <summary> /// <summary>
/// Store for asset data we received before we get the metadata /// Store for asset data we received before we get the metadata
/// </summary> /// </summary>

View File

@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
if (horizontalScale < 0.01d) if (horizontalScale < 0.01d)
horizontalScale = 0.01d; horizontalScale = 0.01d;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); Encoding enc = Encoding.ASCII;
bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); bs.Write(enc.GetBytes("TERRAGENTERRAIN "));

View File

@ -451,6 +451,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
// Restuff the new GroupPosition into each SOP of the linkset.
// This has the affect of resetting and tainting the physics actors.
SceneObjectPart[] parts = m_parts.GetArray(); SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++) for (int i = 0; i < parts.Length; i++)
parts[i].GroupPosition = val; parts[i].GroupPosition = val;
@ -1133,6 +1135,9 @@ namespace OpenSim.Region.Framework.Scenes
public void ResetChildPrimPhysicsPositions() public void ResetChildPrimPhysicsPositions()
{ {
// Setting this SOG's absolute position also loops through and sets the positions
// of the SOP's in this SOG's linkset. This has the side affect of making sure
// the physics world matches the simulated world.
AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works?
// teravus: AbsolutePosition is NOT a normal property! // teravus: AbsolutePosition is NOT a normal property!
@ -1987,6 +1992,8 @@ namespace OpenSim.Region.Framework.Scenes
LinkToGroup(objectGroup, false); LinkToGroup(objectGroup, false);
} }
// Link an existing group to this group.
// The group being linked need not be a linkset -- it can have just one prim.
public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) public void LinkToGroup(SceneObjectGroup objectGroup, bool insert)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
@ -1997,35 +2004,51 @@ namespace OpenSim.Region.Framework.Scenes
if (objectGroup == this) if (objectGroup == this)
return; return;
// 'linkPart' == the root of the group being linked into this group
SceneObjectPart linkPart = objectGroup.m_rootPart; SceneObjectPart linkPart = objectGroup.m_rootPart;
// physics flags from group to be applied to linked parts // physics flags from group to be applied to linked parts
bool grpusephys = UsesPhysics; bool grpusephys = UsesPhysics;
bool grptemporary = IsTemporary; bool grptemporary = IsTemporary;
// Remember where the group being linked thought it was
Vector3 oldGroupPosition = linkPart.GroupPosition; Vector3 oldGroupPosition = linkPart.GroupPosition;
Quaternion oldRootRotation = linkPart.RotationOffset; Quaternion oldRootRotation = linkPart.RotationOffset;
linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; // A linked SOP remembers its location and rotation relative to the root of a group.
linkPart.ParentID = m_rootPart.LocalId; // Convert the root of the group being linked to be relative to the
linkPart.GroupPosition = AbsolutePosition; // root of the group being linked to.
Vector3 axPos = linkPart.OffsetPosition; // Note: Some of the assignments have complex side effects.
// First move the new group's root SOP's position to be relative to ours
// (radams1: Not sure if the multiple setting of OffsetPosition is required. If not,
// this code can be reordered to have a more logical flow.)
linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition;
// Assign the new parent to the root of the old group
linkPart.ParentID = m_rootPart.LocalId;
// Now that it's a child, it's group position is our root position
linkPart.GroupPosition = AbsolutePosition;
Vector3 axPos = linkPart.OffsetPosition;
// Rotate the linking root SOP's position to be relative to the new root prim
Quaternion parentRot = m_rootPart.RotationOffset; Quaternion parentRot = m_rootPart.RotationOffset;
axPos *= Quaternion.Inverse(parentRot); axPos *= Quaternion.Inverse(parentRot);
linkPart.OffsetPosition = axPos; linkPart.OffsetPosition = axPos;
// Make the linking root SOP's rotation relative to the new root prim
Quaternion oldRot = linkPart.RotationOffset; Quaternion oldRot = linkPart.RotationOffset;
Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
linkPart.RotationOffset = newRot; linkPart.RotationOffset = newRot;
linkPart.ParentID = m_rootPart.LocalId; // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset.
// Now that we know this SOG has at least two SOPs in it, the new root
// SOP becomes the first in the linkset.
if (m_rootPart.LinkNum == 0) if (m_rootPart.LinkNum == 0)
m_rootPart.LinkNum = 1; m_rootPart.LinkNum = 1;
lock (m_parts.SyncRoot) lock (m_parts.SyncRoot)
{ {
// Calculate the new link number for the old root SOP
int linkNum; int linkNum;
if (insert) if (insert)
{ {
@ -2041,6 +2064,7 @@ namespace OpenSim.Region.Framework.Scenes
linkNum = PrimCount + 1; linkNum = PrimCount + 1;
} }
// Add the old root SOP as a part in our group's list
m_parts.Add(linkPart.UUID, linkPart); m_parts.Add(linkPart.UUID, linkPart);
linkPart.SetParent(this); linkPart.SetParent(this);
@ -2048,6 +2072,8 @@ namespace OpenSim.Region.Framework.Scenes
// let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now
linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive);
// If the added SOP is physical, also tell the physics engine about the link relationship.
if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
{ {
linkPart.PhysActor.link(m_rootPart.PhysActor); linkPart.PhysActor.link(m_rootPart.PhysActor);
@ -2056,20 +2082,26 @@ namespace OpenSim.Region.Framework.Scenes
linkPart.LinkNum = linkNum++; linkPart.LinkNum = linkNum++;
// Get a list of the SOP's in the old group in order of their linknum's.
SceneObjectPart[] ogParts = objectGroup.Parts; SceneObjectPart[] ogParts = objectGroup.Parts;
Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
{ {
return a.LinkNum - b.LinkNum; return a.LinkNum - b.LinkNum;
}); });
// Add each of the SOP's from the old linkset to our linkset
for (int i = 0; i < ogParts.Length; i++) for (int i = 0; i < ogParts.Length; i++)
{ {
SceneObjectPart part = ogParts[i]; SceneObjectPart part = ogParts[i];
if (part.UUID != objectGroup.m_rootPart.UUID) if (part.UUID != objectGroup.m_rootPart.UUID)
{ {
LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
// let physics know
// Update the physics flags for the newly added SOP
// (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??)
part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive);
// If the added SOP is physical, also tell the physics engine about the link relationship.
if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
{ {
part.PhysActor.link(m_rootPart.PhysActor); part.PhysActor.link(m_rootPart.PhysActor);
@ -2080,6 +2112,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
// Now that we've aquired all of the old SOG's parts, remove the old SOG from the scene.
m_scene.UnlinkSceneObject(objectGroup, true); m_scene.UnlinkSceneObject(objectGroup, true);
objectGroup.IsDeleted = true; objectGroup.IsDeleted = true;
@ -2152,7 +2185,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <remarks> /// <remarks>
/// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
/// condition. But currently there is no /// condition. But currently there is no
/// alternative method that does take a lonk to delink a single prim. /// alternative method that does take a lock to delink a single prim.
/// </remarks> /// </remarks>
/// <param name="partID"></param> /// <param name="partID"></param>
/// <param name="sendEvents"></param> /// <param name="sendEvents"></param>
@ -2165,6 +2198,7 @@ namespace OpenSim.Region.Framework.Scenes
linkPart.ClearUndoState(); linkPart.ClearUndoState();
Vector3 worldPos = linkPart.GetWorldPosition();
Quaternion worldRot = linkPart.GetWorldRotation(); Quaternion worldRot = linkPart.GetWorldRotation();
// Remove the part from this object // Remove the part from this object
@ -2174,6 +2208,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart[] parts = m_parts.GetArray(); SceneObjectPart[] parts = m_parts.GetArray();
// Rejigger the linknum's of the remaining SOP's to fill any gap
if (parts.Length == 1 && RootPart != null) if (parts.Length == 1 && RootPart != null)
{ {
// Single prim left // Single prim left
@ -2195,22 +2230,31 @@ namespace OpenSim.Region.Framework.Scenes
PhysicsActor linkPartPa = linkPart.PhysActor; PhysicsActor linkPartPa = linkPart.PhysActor;
// Remove the SOP from the physical scene.
// If the new SOG is physical, it is re-created later.
// (There is a problem here in that we have not yet told the physics
// engine about the delink. Someday, linksets should be made first
// class objects in the physics engine interface).
if (linkPartPa != null) if (linkPartPa != null)
m_scene.PhysicsScene.RemovePrim(linkPartPa); m_scene.PhysicsScene.RemovePrim(linkPartPa);
// We need to reset the child part's position // We need to reset the child part's position
// ready for life as a separate object after being a part of another object // ready for life as a separate object after being a part of another object
/* This commented out code seems to recompute what GetWorldPosition already does.
* Replace with a call to GetWorldPosition (before unlinking)
Quaternion parentRot = m_rootPart.RotationOffset; Quaternion parentRot = m_rootPart.RotationOffset;
Vector3 axPos = linkPart.OffsetPosition; Vector3 axPos = linkPart.OffsetPosition;
axPos *= parentRot; axPos *= parentRot;
linkPart.OffsetPosition = new Vector3(axPos.X, axPos.Y, axPos.Z); linkPart.OffsetPosition = new Vector3(axPos.X, axPos.Y, axPos.Z);
linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition;
linkPart.OffsetPosition = new Vector3(0, 0, 0); linkPart.OffsetPosition = new Vector3(0, 0, 0);
*/
linkPart.GroupPosition = worldPos;
linkPart.OffsetPosition = Vector3.Zero;
linkPart.RotationOffset = worldRot; linkPart.RotationOffset = worldRot;
// Create a new SOG to go around this unlinked and unattached SOP
SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart);
m_scene.AddNewSceneObject(objectGroup, true); m_scene.AddNewSceneObject(objectGroup, true);
@ -2239,42 +2283,56 @@ namespace OpenSim.Region.Framework.Scenes
m_isBackedUp = false; m_isBackedUp = false;
} }
// This links an SOP from a previous linkset into my linkset.
// The trick is that the SOP's position and rotation are relative to the old root SOP's
// so we are passed in the position and rotation of the old linkset so this can
// unjigger this SOP's position and rotation from the previous linkset and
// then make them relative to my linkset root.
private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum) private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum)
{ {
Quaternion parentRot = oldGroupRotation; Quaternion parentRot = oldGroupRotation;
Quaternion oldRot = part.RotationOffset; Quaternion oldRot = part.RotationOffset;
Quaternion worldRot = parentRot * oldRot;
parentRot = oldGroupRotation;
// Move our position to not be relative to the old parent
Vector3 axPos = part.OffsetPosition; Vector3 axPos = part.OffsetPosition;
axPos *= parentRot; axPos *= parentRot;
part.OffsetPosition = axPos; part.OffsetPosition = axPos;
part.GroupPosition = oldGroupPosition + part.OffsetPosition; part.GroupPosition = oldGroupPosition + part.OffsetPosition;
part.OffsetPosition = Vector3.Zero; part.OffsetPosition = Vector3.Zero;
// Compution our rotation to be not relative to the old parent
Quaternion worldRot = parentRot * oldRot;
part.RotationOffset = worldRot; part.RotationOffset = worldRot;
// Add this SOP to our linkset
part.SetParent(this); part.SetParent(this);
part.ParentID = m_rootPart.LocalId; part.ParentID = m_rootPart.LocalId;
m_parts.Add(part.UUID, part); m_parts.Add(part.UUID, part);
part.LinkNum = linkNum; part.LinkNum = linkNum;
// Compute the new position of this SOP relative to the group position
part.OffsetPosition = part.GroupPosition - AbsolutePosition; part.OffsetPosition = part.GroupPosition - AbsolutePosition;
Quaternion rootRotation = m_rootPart.RotationOffset; // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times.
// It would have the affect of setting the physics engine position multiple
// times. In theory, that is not necessary but I don't have a good linkset
// test to know that cleaning up this code wouldn't break things.)
// Rotate the relative position by the rotation of the group
Quaternion rootRotation = m_rootPart.RotationOffset;
Vector3 pos = part.OffsetPosition; Vector3 pos = part.OffsetPosition;
pos *= Quaternion.Inverse(rootRotation); pos *= Quaternion.Inverse(rootRotation);
part.OffsetPosition = pos; part.OffsetPosition = pos;
// Compute the SOP's rotation relative to the rotation of the group.
parentRot = m_rootPart.RotationOffset; parentRot = m_rootPart.RotationOffset;
oldRot = part.RotationOffset; oldRot = part.RotationOffset;
Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot;
part.RotationOffset = newRot; part.RotationOffset = newRot;
// Since this SOP's state has changed, push those changes into the physics engine
// and the simulator.
part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
} }

View File

@ -693,9 +693,11 @@ namespace OpenSim.Region.Framework.Scenes
{ {
// If this is a linkset, we don't want the physics engine mucking up our group position here. // If this is a linkset, we don't want the physics engine mucking up our group position here.
PhysicsActor actor = PhysActor; PhysicsActor actor = PhysActor;
// If physical and the root prim of a linkset, the position of the group is what physics thinks.
if (actor != null && ParentID == 0) if (actor != null && ParentID == 0)
m_groupPosition = actor.Position; m_groupPosition = actor.Position;
// If I'm an attachment, my position is reported as the position of who I'm attached to
if (ParentGroup.IsAttachment) if (ParentGroup.IsAttachment)
{ {
ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
@ -721,7 +723,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
// To move the child prim in respect to the group position and rotation we have to calculate // The physics engine always sees all objects (root or linked) in world coordinates.
actor.Position = GetWorldPosition(); actor.Position = GetWorldPosition();
actor.Orientation = GetWorldRotation(); actor.Orientation = GetWorldRotation();
} }
@ -795,6 +797,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
// We don't want the physics engine mucking up the rotations in a linkset // We don't want the physics engine mucking up the rotations in a linkset
PhysicsActor actor = PhysActor; PhysicsActor actor = PhysActor;
// If this is a root of a linkset, the real rotation is what the physics engine thinks.
// If not a root prim, the offset rotation is computed by SOG and is relative to the root.
if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null)
{ {
if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
@ -1980,14 +1984,20 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>A Linked Child Prim objects position in world</returns> /// <returns>A Linked Child Prim objects position in world</returns>
public Vector3 GetWorldPosition() public Vector3 GetWorldPosition()
{ {
Quaternion parentRot = ParentGroup.RootPart.RotationOffset; Vector3 ret;
Vector3 axPos = OffsetPosition; if (_parentID == 0)
axPos *= parentRot; // if a root SOP, my position is what it is
Vector3 translationOffsetPosition = axPos; ret = GroupPosition;
if(_parentID == 0)
return GroupPosition;
else else
return ParentGroup.AbsolutePosition + translationOffsetPosition; {
// If a child SOP, my position is relative to the root SOP so take
// my info and add the root's position and rotation to
// get my world position.
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
Vector3 translationOffsetPosition = OffsetPosition * parentRot;
ret = ParentGroup.AbsolutePosition + translationOffsetPosition;
}
return ret;
} }
/// <summary> /// <summary>
@ -2004,6 +2014,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
// A child SOP's rotation is relative to the root SOP's rotation.
// Combine them to get my absolute rotation.
Quaternion parentRot = ParentGroup.RootPart.RotationOffset; Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
Quaternion oldRot = RotationOffset; Quaternion oldRot = RotationOffset;
newRot = parentRot * oldRot; newRot = parentRot * oldRot;

View File

@ -823,11 +823,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
landName, land.LocalID, landUUID); landName, land.LocalID, landUUID);
} }
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
// slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables
// the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator.
channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(Encoding.ASCII.GetBytes(landUUID)), m_freeSwitchRealm);
lock (m_ParcelAddress) lock (m_ParcelAddress)
{ {

View File

@ -1120,7 +1120,6 @@ namespace Nwc.XmlRpc
/// <summary>Class supporting the request side of an XML-RPC transaction.</summary> /// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest
{ {
private Encoding _encoding = new ASCIIEncoding();
private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
private bool _disableKeepAlive = true; private bool _disableKeepAlive = true;
@ -1153,7 +1152,7 @@ namespace Nwc.XmlRpc
request.KeepAlive = !_disableKeepAlive; request.KeepAlive = !_disableKeepAlive;
Stream stream = request.GetRequestStream(); Stream stream = request.GetRequestStream();
XmlTextWriter xml = new XmlTextWriter(stream, _encoding); XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII);
_serializer.Serialize(xml, this); _serializer.Serialize(xml, this);
xml.Flush(); xml.Flush();
xml.Close(); xml.Close();

View File

@ -425,10 +425,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
try try
{ {
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); string jsondata = SLUtil.ParseNotecardToString(Encoding.UTF8.GetString(a.Data));
string jsondata = SLUtil.ParseNotecardToString(enc.GetString(a.Data)); int result = m_store.SetValue(storeID, path, jsondata,true) ? 1 : 0;
int result = m_store.SetValue(storeID,path,jsondata,true) ? 1 : 0; m_comms.DispatchReply(scriptID,result, "", reqID.ToString());
m_comms.DispatchReply(scriptID,result,"",reqID.ToString());
return; return;
} }
catch (Exception e) catch (Exception e)

View File

@ -482,10 +482,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
// Convert to base64 // Convert to base64
// //
string filetext = Convert.ToBase64String(data); string filetext = Convert.ToBase64String(data);
Byte[] buf = Encoding.ASCII.GetBytes(filetext);
ASCIIEncoding enc = new ASCIIEncoding();
Byte[] buf = enc.GetBytes(filetext);
m_log.Info("MRM 9"); m_log.Info("MRM 9");

View File

@ -10536,9 +10536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
} }
System.Text.UTF8Encoding enc = string data = Encoding.UTF8.GetString(a.Data);
new System.Text.UTF8Encoding();
string data = enc.GetString(a.Data);
//m_log.Debug(data); //m_log.Debug(data);
NotecardCache.Cache(id, data); NotecardCache.Cache(id, data);
AsyncCommands. AsyncCommands.
@ -10591,9 +10589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
} }
System.Text.UTF8Encoding enc = string data = Encoding.UTF8.GetString(a.Data);
new System.Text.UTF8Encoding();
string data = enc.GetString(a.Data);
//m_log.Debug(data); //m_log.Debug(data);
NotecardCache.Cache(id, data); NotecardCache.Cache(id, data);
AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(),

View File

@ -1811,8 +1811,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (a == null) if (a == null)
return UUID.Zero; return UUID.Zero;
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); string data = Encoding.UTF8.GetString(a.Data);
string data = enc.GetString(a.Data);
NotecardCache.Cache(assetID, data); NotecardCache.Cache(assetID, data);
}; };

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.IO; using System.IO;
using System.Text;
using Microsoft.CSharp; using Microsoft.CSharp;
//using Microsoft.JScript; //using Microsoft.JScript;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
@ -711,9 +712,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// //
string filetext = System.Convert.ToBase64String(data); string filetext = System.Convert.ToBase64String(data);
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); Byte[] buf = Encoding.ASCII.GetBytes(filetext);
Byte[] buf = enc.GetBytes(filetext);
FileStream sfs = File.Create(assembly + ".text"); FileStream sfs = File.Create(assembly + ".text");
sfs.Write(buf, 0, buf.Length); sfs.Write(buf, 0, buf.Length);
@ -804,8 +803,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value);
} }
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring);
Byte[] mapbytes = enc.GetBytes(mapstring);
FileStream mfs = File.Create(filename); FileStream mfs = File.Create(filename);
mfs.Write(mapbytes, 0, mapbytes.Length); mfs.Write(mapbytes, 0, mapbytes.Length);
mfs.Close(); mfs.Close();

View File

@ -26,15 +26,16 @@
*/ */
using System; using System;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Lifetime;
using System.Threading;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Policy;
using System.Reflection;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Lifetime;
using System.Security.Policy;
using System.Text;
using System.Threading;
using System.Xml; using System.Xml;
using OpenMetaverse; using OpenMetaverse;
using log4net; using log4net;
@ -298,13 +299,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
using (FileStream fs = File.Open(savedState, using (FileStream fs = File.Open(savedState,
FileMode.Open, FileAccess.Read, FileShare.None)) FileMode.Open, FileAccess.Read, FileShare.None))
{ {
System.Text.UTF8Encoding enc =
new System.Text.UTF8Encoding();
Byte[] data = new Byte[size]; Byte[] data = new Byte[size];
fs.Read(data, 0, size); fs.Read(data, 0, size);
xml = enc.GetString(data); xml = Encoding.UTF8.GetString(data);
ScriptSerializer.Deserialize(xml, this); ScriptSerializer.Deserialize(xml, this);
@ -954,8 +952,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
try try
{ {
FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state"));
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); Byte[] buf = (new UTF8Encoding()).GetBytes(xml);
Byte[] buf = enc.GetBytes(xml);
fs.Write(buf, 0, buf.Length); fs.Write(buf, 0, buf.Length);
fs.Close(); fs.Close();
} }

View File

@ -1763,7 +1763,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
tfs.Read(tdata, 0, tdata.Length); tfs.Read(tdata, 0, tdata.Length);
} }
assem = new System.Text.ASCIIEncoding().GetString(tdata); assem = Encoding.ASCII.GetString(tdata);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -27,9 +27,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Xml;
using System.Threading;
using System.Reflection; using System.Reflection;
using System.Threading;
using System.Text;
using System.Xml;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using log4net; using log4net;
@ -335,8 +336,7 @@ namespace OpenSim.Server.Base
{ {
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
FileStream fs = File.Create(path); FileStream fs = File.Create(path);
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
Byte[] buf = enc.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length); fs.Write(buf, 0, buf.Length);
fs.Close(); fs.Close();
m_pidFile = path; m_pidFile = path;

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using Microsoft.CSharp; using Microsoft.CSharp;
using OpenSim.Region.ScriptEngine.Shared.CodeTools; using OpenSim.Region.ScriptEngine.Shared.CodeTools;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
@ -201,12 +202,8 @@ namespace OpenSim.Tools.LSL.Compiler
// Convert to base64 // Convert to base64
// //
string filetext = System.Convert.ToBase64String(data); string filetext = System.Convert.ToBase64String(data);
Byte[] buf = Encoding.ASCII.GetBytes(filetext);
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); FileStream sfs = File.Create(OutFile + ".text");
Byte[] buf = enc.GetBytes(filetext);
FileStream sfs = File.Create(OutFile+".text");
sfs.Write(buf, 0, buf.Length); sfs.Write(buf, 0, buf.Length);
sfs.Close(); sfs.Close();
@ -222,9 +219,9 @@ namespace OpenSim.Tools.LSL.Compiler
// } // }
// } // }
buf = enc.GetBytes(posmap); buf = Encoding.ASCII.GetBytes(posmap);
FileStream mfs = File.Create(OutFile+".map"); FileStream mfs = File.Create(OutFile + ".map");
mfs.Write(buf, 0, buf.Length); mfs.Write(buf, 0, buf.Length);
mfs.Close(); mfs.Close();

View File

@ -2968,6 +2968,7 @@
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/> <Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.Physics.Manager"/> <Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
<Reference name="OpenSim.Region.ScriptEngine.XEngine"/> <Reference name="OpenSim.Region.ScriptEngine.XEngine"/>
<Reference name="OpenSim.Services.Interfaces"/> <Reference name="OpenSim.Services.Interfaces"/>