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

user_profiles
Mic Bowman 2013-02-06 17:32:57 -08:00
commit 274d376c82
6 changed files with 43 additions and 13 deletions

View File

@ -176,6 +176,10 @@ namespace OpenSim.Framework
} }
} }
/// <summary>
/// Validate the key used for storing separate data stores.
/// </summary>
/// <param name='key'></param>
private static void ValidateKey(string key) private static void ValidateKey(string key)
{ {
if (key.Length < MIN_STORE_NAME_LENGTH) if (key.Length < MIN_STORE_NAME_LENGTH)
@ -196,7 +200,8 @@ namespace OpenSim.Framework
} }
public void Add(KeyValuePair<string, OSDMap> kvp) public void Add(KeyValuePair<string, OSDMap> kvp)
{ {
ValidateKey(kvp.Key);
lock (this) lock (this)
m_map.Add(kvp.Key, kvp.Value); m_map.Add(kvp.Key, kvp.Value);
} }

View File

@ -45,6 +45,7 @@ using System.Text.RegularExpressions;
using System.Xml; using System.Xml;
using System.Threading; using System.Threading;
using log4net; using log4net;
using log4net.Appender;
using Nini.Config; using Nini.Config;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenMetaverse; using OpenMetaverse;
@ -816,9 +817,22 @@ namespace OpenSim.Framework
return "."; return ".";
} }
public static string logFile()
{
foreach (IAppender appender in LogManager.GetRepository().GetAppenders())
{
if (appender is FileAppender)
{
return ((FileAppender)appender).File;
}
}
return "./OpenSim.log";
}
public static string logDir() public static string logDir()
{ {
return "."; return Path.GetDirectoryName(logFile());
} }
// From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html // From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html

View File

@ -220,7 +220,7 @@ public static class BSParam
(s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); }, (s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); },
(s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ), (s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ),
new ParameterDefn("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes", new ParameterDefn("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes",
ConfigurationParameters.numericFalse, ConfigurationParameters.numericTrue,
(s,cf,p,v) => { ShouldRemoveZeroWidthTriangles = cf.GetBoolean(p, BSParam.BoolNumeric(v)); }, (s,cf,p,v) => { ShouldRemoveZeroWidthTriangles = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
(s) => { return BSParam.NumericBool(ShouldRemoveZeroWidthTriangles); }, (s) => { return BSParam.NumericBool(ShouldRemoveZeroWidthTriangles); },
(s,p,l,v) => { ShouldRemoveZeroWidthTriangles = BSParam.BoolNumeric(v); } ), (s,p,l,v) => { ShouldRemoveZeroWidthTriangles = BSParam.BoolNumeric(v); } ),

View File

@ -75,6 +75,7 @@ public abstract class BSPhysObject : PhysicsActor
PhysicsScene = parentScene; PhysicsScene = parentScene;
LocalID = localID; LocalID = localID;
PhysObjectName = name; PhysObjectName = name;
Name = name; // PhysicsActor also has the name of the object. Someday consolidate.
TypeName = typeName; TypeName = typeName;
// We don't have any physical representation yet. // We don't have any physical representation yet.

View File

@ -608,7 +608,7 @@ public sealed class BSShapeCollection : IDisposable
// Since we're recreating new, get rid of the reference to the previous shape // Since we're recreating new, get rid of the reference to the previous shape
DereferenceShape(prim.PhysShape, shapeCallback); DereferenceShape(prim.PhysShape, shapeCallback);
newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod); newShape = CreatePhysicalMesh(prim, newMeshKey, prim.BaseShape, prim.Size, lod);
// Take evasive action if the mesh was not constructed. // Take evasive action if the mesh was not constructed.
newShape = VerifyMeshCreated(newShape, prim); newShape = VerifyMeshCreated(newShape, prim);
@ -619,7 +619,7 @@ public sealed class BSShapeCollection : IDisposable
return true; // 'true' means a new shape has been added to this prim return true; // 'true' means a new shape has been added to this prim
} }
private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) private BulletShape CreatePhysicalMesh(BSPhysObject prim, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
{ {
BulletShape newShape = new BulletShape(); BulletShape newShape = new BulletShape();
@ -631,7 +631,7 @@ public sealed class BSShapeCollection : IDisposable
} }
else else
{ {
IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, IMesh meshData = PhysicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod,
false, // say it is not physical so a bounding box is not built false, // say it is not physical so a bounding box is not built
false // do not cache the mesh and do not use previously built versions false // do not cache the mesh and do not use previously built versions
); );
@ -651,18 +651,20 @@ public sealed class BSShapeCollection : IDisposable
realIndicesIndex = 0; realIndicesIndex = 0;
for (int tri = 0; tri < indices.Length; tri += 3) for (int tri = 0; tri < indices.Length; tri += 3)
{ {
// Compute displacements into vertex array for each vertex of the triangle
int v1 = indices[tri + 0] * 3; int v1 = indices[tri + 0] * 3;
int v2 = indices[tri + 1] * 3; int v2 = indices[tri + 1] * 3;
int v3 = indices[tri + 2] * 3; int v3 = indices[tri + 2] * 3;
if (!((verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] // Check to see if any two of the vertices are the same
if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0]
&& verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1]
&& verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2]) && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2])
|| (verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] || ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0]
&& verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1]
&& verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2]) && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2])
|| (verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] || ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0]
&& verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1]
&& verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2])) && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2]) )
) )
{ {
// None of the vertices of the triangles are the same. This is a good triangle; // None of the vertices of the triangles are the same. This is a good triangle;
@ -676,8 +678,16 @@ public sealed class BSShapeCollection : IDisposable
DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}",
BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3);
newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, if (realIndicesIndex != 0)
realIndicesIndex, indices, verticesAsFloats.Length/3, verticesAsFloats); {
newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World,
realIndicesIndex, indices, verticesAsFloats.Length / 3, verticesAsFloats);
}
else
{
PhysicsScene.Logger.ErrorFormat("{0} All mesh triangles degenerate. Prim {1} at {2} in {3}",
LogHeader, prim.PhysObjectName, prim.RawPosition, PhysicsScene.Name);
}
} }
} }
newShape.shapeKey = newMeshKey; newShape.shapeKey = newMeshKey;

View File

@ -420,7 +420,7 @@ namespace OpenSim.Region.UserStatistics
Encoding encoding = Encoding.ASCII; Encoding encoding = Encoding.ASCII;
int sizeOfChar = encoding.GetByteCount("\n"); int sizeOfChar = encoding.GetByteCount("\n");
byte[] buffer = encoding.GetBytes("\n"); byte[] buffer = encoding.GetBytes("\n");
string logfile = Util.logDir() + "/" + "OpenSim.log"; string logfile = Util.logFile();
FileStream fs = new FileStream(logfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); FileStream fs = new FileStream(logfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Int64 tokenCount = 0; Int64 tokenCount = 0;
Int64 endPosition = fs.Length / sizeOfChar; Int64 endPosition = fs.Length / sizeOfChar;