remove terraindata abstraction layer, since we only have heightmap type

0.9.1.0-post-fixes
UbitUmarov 2019-01-21 06:05:21 +00:00
parent a287a8e121
commit 33a062612f
13 changed files with 125 additions and 196 deletions

View File

@ -598,7 +598,7 @@ namespace OpenSim.Data.MySQL
// Legacy entry point for when terrain was always a 256x256 hieghtmap // Legacy entry point for when terrain was always a 256x256 hieghtmap
public void StoreTerrain(double[,] ter, UUID regionID) public void StoreTerrain(double[,] ter, UUID regionID)
{ {
StoreTerrain(new HeightmapTerrainData(ter), regionID); StoreTerrain(new TerrainData(ter), regionID);
} }
public void StoreTerrain(TerrainData terrData, UUID regionID) public void StoreTerrain(TerrainData terrData, UUID regionID)
@ -1463,7 +1463,7 @@ namespace OpenSim.Data.MySQL
if (!(row["DynAttrs"] is System.DBNull)) if (!(row["DynAttrs"] is System.DBNull))
prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
else else
prim.DynAttrs = new DAMap(); prim.DynAttrs = null;
if (!(row["KeyframeMotion"] is DBNull)) if (!(row["KeyframeMotion"] is DBNull))
{ {
@ -1880,7 +1880,7 @@ namespace OpenSim.Data.MySQL
else else
cmd.Parameters.AddWithValue("Vehicle", String.Empty); cmd.Parameters.AddWithValue("Vehicle", String.Empty);
if (prim.DynAttrs.CountNamespaces > 0) if (prim.DynAttrs != null && prim.DynAttrs.CountNamespaces > 0)
cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml());
else else
cmd.Parameters.AddWithValue("DynAttrs", null); cmd.Parameters.AddWithValue("DynAttrs", null);

View File

@ -151,7 +151,7 @@ namespace OpenSim.Data.Null
// Legacy. Just don't do this. // Legacy. Just don't do this.
public void StoreTerrain(double[,] ter, UUID regionID) public void StoreTerrain(double[,] ter, UUID regionID)
{ {
TerrainData terrData = new HeightmapTerrainData(ter); TerrainData terrData = new TerrainData(ter);
StoreTerrain(terrData, regionID); StoreTerrain(terrData, regionID);
} }

View File

@ -610,7 +610,7 @@ namespace OpenSim.Data.PGSQL
// Legacy entry point for when terrain was always a 256x256 heightmap // Legacy entry point for when terrain was always a 256x256 heightmap
public void StoreTerrain(double[,] terrain, UUID regionID) public void StoreTerrain(double[,] terrain, UUID regionID)
{ {
StoreTerrain(new HeightmapTerrainData(terrain), regionID); StoreTerrain(new TerrainData(terrain), regionID);
} }
/// <summary> /// <summary>
@ -1797,7 +1797,7 @@ namespace OpenSim.Data.PGSQL
if (!(primRow["DynAttrs"] is System.DBNull) && (string)primRow["DynAttrs"] != "") if (!(primRow["DynAttrs"] is System.DBNull) && (string)primRow["DynAttrs"] != "")
prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]); prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]);
else else
prim.DynAttrs = new DAMap(); prim.DynAttrs = null;
prim.PhysicsShapeType = Convert.ToByte(primRow["PhysicsShapeType"]); prim.PhysicsShapeType = Convert.ToByte(primRow["PhysicsShapeType"]);
prim.Density = Convert.ToSingle(primRow["Density"]); prim.Density = Convert.ToSingle(primRow["Density"]);
@ -2245,7 +2245,7 @@ namespace OpenSim.Data.PGSQL
else else
parameters.Add(_Database.CreateParameter("PhysInertia", String.Empty)); parameters.Add(_Database.CreateParameter("PhysInertia", String.Empty));
if (prim.DynAttrs.CountNamespaces > 0) if (prim.DynAttrs != null && prim.DynAttrs.CountNamespaces > 0)
parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml()));
else else
parameters.Add(_Database.CreateParameter("DynAttrs", null)); parameters.Add(_Database.CreateParameter("DynAttrs", null));

View File

@ -37,56 +37,6 @@ using log4net;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public abstract class TerrainData
{
// Terrain always is a square
public int SizeX { get; protected set; }
public int SizeY { get; protected set; }
public int SizeZ { get; protected set; }
// A height used when the user doesn't specify anything
public const float DefaultTerrainHeight = 21f;
public abstract float this[int x, int y] { get; set; }
// Someday terrain will have caves
// at most holes :p
public abstract float this[int x, int y, int z] { get; set; }
public abstract bool IsTaintedAt(int xx, int yy);
public abstract bool IsTaintedAt(int xx, int yy, bool clearOnTest);
public abstract void TaintAllTerrain();
public abstract void ClearTaint();
public abstract void ClearLand();
public abstract void ClearLand(float height);
// Return a representation of this terrain for storing as a blob in the database.
// Returns 'true' to say blob was stored in the 'out' locations.
public abstract bool GetDatabaseBlob(out int DBFormatRevisionCode, out Array blob);
// Given a revision code and a blob from the database, create and return the right type of TerrainData.
// The sizes passed are the expected size of the region. The database info will be used to
// initialize the heightmap of that sized region with as much data is in the blob.
// Return created TerrainData or 'null' if unsuccessful.
public static TerrainData CreateFromDatabaseBlobFactory(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob)
{
// For the moment, there is only one implementation class
return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob);
}
// return a special compressed representation of the heightmap in ushort
public abstract float[] GetCompressedMap();
public abstract float CompressionFactor { get; }
public abstract float[] GetFloatsSerialized();
public abstract double[,] GetDoubles();
public abstract void GetPatchMinMax(int px, int py, out float zmin, out float zmax);
public abstract void GetPatchBlock(float[] block, int px, int py, float sub, float premult);
public abstract TerrainData Clone();
}
// The terrain is stored in the database as a blob with a 'revision' field. // The terrain is stored in the database as a blob with a 'revision' field.
// Some implementations of terrain storage would fill the revision field with // Some implementations of terrain storage would fill the revision field with
// the time the terrain was stored. When real revisions were added and this // the time the terrain was stored. When real revisions were added and this
@ -116,18 +66,37 @@ namespace OpenSim.Framework
RevisionHigh = 1234 RevisionHigh = 1234
} }
// Version of terrain that is a heightmap. public class TerrainData
// This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge
// of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer.
// The heighmap is kept as an array of ushorts. The ushort values are converted to
// and from floats by TerrainCompressionFactor.
public class HeightmapTerrainData : TerrainData
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static string LogHeader = "[HEIGHTMAP TERRAIN DATA]"; private static string LogHeader = "[TERRAIN DATA]";
// TerrainData.this[x, y] private float[,] m_heightmap;
public override float this[int x, int y] // Remember subregions of the heightmap that has changed.
private bool[,] m_taint;
// legacy CompressionFactor
public float CompressionFactor { get; private set; }
// Terrain always is a square
public int SizeX { get; protected set; }
public int SizeY { get; protected set; }
public int SizeZ { get; protected set; }
// A height used when the user doesn't specify anything
public const float DefaultTerrainHeight = 21f;
// Given a revision code and a blob from the database, create and return the right type of TerrainData.
// The sizes passed are the expected size of the region. The database info will be used to
// initialize the heightmap of that sized region with as much data is in the blob.
// Return created TerrainData or 'null' if unsuccessful.
public static TerrainData CreateFromDatabaseBlobFactory(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob)
{
// For the moment, there is only one implementation class
return new TerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob);
}
public float this[int x, int y]
{ {
get { return m_heightmap[x, y]; } get { return m_heightmap[x, y]; }
set set
@ -140,21 +109,18 @@ namespace OpenSim.Framework
} }
} }
// TerrainData.this[x, y, z] public float this[int x, int y, int z]
public override float this[int x, int y, int z]
{ {
get { return this[x, y]; } get { return this[x, y]; }
set { this[x, y] = value; } set { this[x, y] = value; }
} }
// TerrainData.ClearTaint public void ClearTaint()
public override void ClearTaint()
{ {
SetAllTaint(false); SetAllTaint(false);
} }
// TerrainData.TaintAllTerrain public void TaintAllTerrain()
public override void TaintAllTerrain()
{ {
SetAllTaint(true); SetAllTaint(true);
} }
@ -166,13 +132,12 @@ namespace OpenSim.Framework
m_taint[ii, jj] = setting; m_taint[ii, jj] = setting;
} }
// TerrainData.ClearLand public void ClearLand()
public override void ClearLand()
{ {
ClearLand(DefaultTerrainHeight); ClearLand(DefaultTerrainHeight);
} }
// TerrainData.ClearLand(float)
public override void ClearLand(float pHeight) public void ClearLand(float pHeight)
{ {
for (int xx = 0; xx < SizeX; xx++) for (int xx = 0; xx < SizeX; xx++)
for (int yy = 0; yy < SizeY; yy++) for (int yy = 0; yy < SizeY; yy++)
@ -182,7 +147,7 @@ namespace OpenSim.Framework
// Return 'true' of the patch that contains these region coordinates has been modified. // Return 'true' of the patch that contains these region coordinates has been modified.
// Note that checking the taint clears it. // Note that checking the taint clears it.
// There is existing code that relies on this feature. // There is existing code that relies on this feature.
public override bool IsTaintedAt(int xx, int yy, bool clearOnTest) public bool IsTaintedAt(int xx, int yy, bool clearOnTest)
{ {
int tx = xx / Constants.TerrainPatchSize; int tx = xx / Constants.TerrainPatchSize;
int ty = yy / Constants.TerrainPatchSize; int ty = yy / Constants.TerrainPatchSize;
@ -195,41 +160,22 @@ namespace OpenSim.Framework
// Old form that clears the taint flag when we check it. // Old form that clears the taint flag when we check it.
// ubit: this dangerus naming should be only check without clear // ubit: this dangerus naming should be only check without clear
// keeping for old modules outthere // keeping for old modules outthere
public override bool IsTaintedAt(int xx, int yy) public bool IsTaintedAt(int xx, int yy)
{ {
return IsTaintedAt(xx, yy, true /* clearOnTest */); return IsTaintedAt(xx, yy, true /* clearOnTest */);
} }
// TerrainData.GetDatabaseBlob // TerrainData.GetDatabaseBlob
// The user wants something to store in the database. // The user wants something to store in the database.
public override bool GetDatabaseBlob(out int DBRevisionCode, out Array blob) public bool GetDatabaseBlob(out int DBRevisionCode, out Array blob)
{ {
bool ret = false; DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip;
/* save all as Variable2DGzip blob = ToCompressedTerrainSerializationV2DGzip();
if (SizeX == Constants.RegionSize && SizeY == Constants.RegionSize) return true;
{
DBRevisionCode = (int)DBTerrainRevision.Legacy256;
blob = ToLegacyTerrainSerialization();
ret = true;
}
else
{
*/
DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip;
// DBRevisionCode = (int)DBTerrainRevision.Variable2D;
blob = ToCompressedTerrainSerializationV2DGzip();
// blob = ToCompressedTerrainSerializationV2D();
ret = true;
// }
return ret;
} }
// TerrainData.CompressionFactor
private float m_compressionFactor = 100.0f;
public override float CompressionFactor { get { return m_compressionFactor; } }
// TerrainData.GetCompressedMap // TerrainData.GetCompressedMap
public override float[] GetCompressedMap() public float[] GetCompressedMap()
{ {
float[] newMap = new float[SizeX * SizeY]; float[] newMap = new float[SizeX * SizeY];
@ -241,19 +187,18 @@ namespace OpenSim.Framework
return newMap; return newMap;
} }
// TerrainData.Clone
public override TerrainData Clone() public TerrainData Clone()
{ {
HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ); TerrainData ret = new TerrainData(SizeX, SizeY, SizeZ);
ret.m_heightmap = (float[,])this.m_heightmap.Clone(); ret.m_heightmap = (float[,])this.m_heightmap.Clone();
return ret; return ret;
} }
// TerrainData.GetFloatsSerialized
// This one dimensional version is ordered so height = map[y*sizeX+x]; // This one dimensional version is ordered so height = map[y*sizeX+x];
// DEPRECATED: don't use this function as it does not retain the dimensions of the terrain // DEPRECATED: don't use this function as it does not retain the dimensions of the terrain
// and the caller will probably do the wrong thing if the terrain is not the legacy 256x256. // and the caller will probably do the wrong thing if the terrain is not the legacy 256x256.
public override float[] GetFloatsSerialized() public float[] GetFloatsSerialized()
{ {
int points = SizeX * SizeY; int points = SizeX * SizeY;
float[] heights = new float[points]; float[] heights = new float[points];
@ -269,7 +214,7 @@ namespace OpenSim.Framework
} }
// TerrainData.GetDoubles // TerrainData.GetDoubles
public override double[,] GetDoubles() public double[,] GetDoubles()
{ {
double[,] ret = new double[SizeX, SizeY]; double[,] ret = new double[SizeX, SizeY];
for (int xx = 0; xx < SizeX; xx++) for (int xx = 0; xx < SizeX; xx++)
@ -279,7 +224,7 @@ namespace OpenSim.Framework
return ret; return ret;
} }
public override unsafe void GetPatchMinMax(int px, int py, out float zmin, out float zmax) public unsafe void GetPatchMinMax(int px, int py, out float zmin, out float zmax)
{ {
zmax = float.MinValue; zmax = float.MinValue;
zmin = float.MaxValue; zmin = float.MaxValue;
@ -304,7 +249,7 @@ namespace OpenSim.Framework
} }
} }
public override unsafe void GetPatchBlock(float[] _block, int px, int py, float sub, float premult) public unsafe void GetPatchBlock(float[] _block, int px, int py, float sub, float premult)
{ {
int k = 0; int k = 0;
int stride = m_heightmap.GetLength(1); int stride = m_heightmap.GetLength(1);
@ -324,13 +269,8 @@ namespace OpenSim.Framework
} }
} }
// ============================================================= /*
// that is coded as the float height times the compression factor (usually '100'
private float[,] m_heightmap;
// Remember subregions of the heightmap that has changed.
private bool[,] m_taint;
// that is coded as the float height times the compression factor (usually '100'
// to make for two decimal points). // to make for two decimal points).
public short ToCompressedHeightshort(float pHeight) public short ToCompressedHeightshort(float pHeight)
{ {
@ -353,6 +293,7 @@ namespace OpenSim.Framework
return ushort.MaxValue; return ushort.MaxValue;
return (ushort)pHeight; return (ushort)pHeight;
} }
*/
public float FromCompressedHeight(short pHeight) public float FromCompressedHeight(short pHeight)
{ {
@ -366,12 +307,12 @@ namespace OpenSim.Framework
// To keep with the legacy theme, create an instance of this class based on the // To keep with the legacy theme, create an instance of this class based on the
// way terrain used to be passed around. // way terrain used to be passed around.
public HeightmapTerrainData(double[,] pTerrain) public TerrainData(double[,] pTerrain)
{ {
SizeX = pTerrain.GetLength(0); SizeX = pTerrain.GetLength(0);
SizeY = pTerrain.GetLength(1); SizeY = pTerrain.GetLength(1);
SizeZ = (int)Constants.RegionHeight; SizeZ = (int)Constants.RegionHeight;
m_compressionFactor = 100.0f; CompressionFactor = 100.0f;
m_heightmap = new float[SizeX, SizeY]; m_heightmap = new float[SizeX, SizeY];
for (int ii = 0; ii < SizeX; ii++) for (int ii = 0; ii < SizeX; ii++)
@ -389,12 +330,12 @@ namespace OpenSim.Framework
} }
// Create underlying structures but don't initialize the heightmap assuming the caller will immediately do that // Create underlying structures but don't initialize the heightmap assuming the caller will immediately do that
public HeightmapTerrainData(int pX, int pY, int pZ) public TerrainData(int pX, int pY, int pZ)
{ {
SizeX = pX; SizeX = pX;
SizeY = pY; SizeY = pY;
SizeZ = pZ; SizeZ = pZ;
m_compressionFactor = 100.0f; CompressionFactor = 100.0f;
m_heightmap = new float[SizeX, SizeY]; m_heightmap = new float[SizeX, SizeY];
m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize];
// m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ);
@ -402,10 +343,10 @@ namespace OpenSim.Framework
ClearLand(0f); ClearLand(0f);
} }
public HeightmapTerrainData(float[] cmap, float pCompressionFactor, int pX, int pY, int pZ) public TerrainData(float[] cmap, float pCompressionFactor, int pX, int pY, int pZ)
: this(pX, pY, pZ) : this(pX, pY, pZ)
{ {
m_compressionFactor = pCompressionFactor; CompressionFactor = pCompressionFactor;
int ind = 0; int ind = 0;
for (int xx = 0; xx < SizeX; xx++) for (int xx = 0; xx < SizeX; xx++)
for (int yy = 0; yy < SizeY; yy++) for (int yy = 0; yy < SizeY; yy++)
@ -414,7 +355,7 @@ namespace OpenSim.Framework
} }
// Create a heighmap from a database blob // Create a heighmap from a database blob
public HeightmapTerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) public TerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob)
: this(pSizeX, pSizeY, pSizeZ) : this(pSizeX, pSizeY, pSizeZ)
{ {
switch ((DBTerrainRevision)pFormatCode) switch ((DBTerrainRevision)pFormatCode)
@ -589,7 +530,7 @@ namespace OpenSim.Framework
hmSizeY = br.ReadInt32(); hmSizeY = br.ReadInt32();
hmCompressionFactor = br.ReadInt32(); hmCompressionFactor = br.ReadInt32();
m_compressionFactor = hmCompressionFactor; CompressionFactor = hmCompressionFactor;
// In case database info doesn't match real terrain size, initialize the whole terrain. // In case database info doesn't match real terrain size, initialize the whole terrain.
ClearLand(); ClearLand();

View File

@ -176,7 +176,7 @@ namespace OpenSim.Framework
LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), input); LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), input);
} }
public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc) public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc, bool keepalive = false)
{ {
int reqnum = RequestNumber++; int reqnum = RequestNumber++;
@ -197,7 +197,7 @@ namespace OpenSim.Framework
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = method; request.Method = method;
request.Timeout = timeout; request.Timeout = timeout;
request.KeepAlive = false; request.KeepAlive = keepalive;
request.MaximumAutomaticRedirections = 10; request.MaximumAutomaticRedirections = 10;
request.ReadWriteTimeout = timeout / 2; request.ReadWriteTimeout = timeout / 2;
request.Headers[OSHeaderRequestID] = reqnum.ToString(); request.Headers[OSHeaderRequestID] = reqnum.ToString();

View File

@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
OSDMap attrs = null; OSDMap attrs = null;
SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId);
if (sop == null) if (sop == null || sop.DynAttrs == null)
return true; return true;
if (!sop.DynAttrs.TryGetStore(Namespace, StoreName, out attrs)) if (!sop.DynAttrs.TryGetStore(Namespace, StoreName, out attrs))

View File

@ -99,6 +99,8 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
private void OnObjectAddedToScene(SceneObjectGroup so) private void OnObjectAddedToScene(SceneObjectGroup so)
{ {
SceneObjectPart rootPart = so.RootPart; SceneObjectPart rootPart = so.RootPart;
if(rootPart.DynAttrs == null)
return;
OSDMap attrs; OSDMap attrs;

View File

@ -410,7 +410,6 @@ namespace OpenSim.Region.Framework.Scenes
m_particleSystem = Utils.EmptyBytes; m_particleSystem = Utils.EmptyBytes;
Rezzed = DateTime.UtcNow; Rezzed = DateTime.UtcNow;
Description = String.Empty; Description = String.Empty;
DynAttrs = new DAMap();
// Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
// this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
@ -3476,6 +3475,28 @@ namespace OpenSim.Region.Framework.Scenes
private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
private const double TIME_MS_TOLERANCE = 200.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds. private const double TIME_MS_TOLERANCE = 200.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
private Vector3 ClampVectorForTerseUpdate(Vector3 v, float max)
{
float a, b;
a = Math.Abs(v.X);
b = Math.Abs(v.Y);
if (b > a)
a = b;
b = Math.Abs(v.Z);
if (b > a)
a = b;
if (a > max)
{
a = max / a;
v.X *= a;
v.Y *= a;
v.Z *= a;
}
return v;
}
/// <summary> /// <summary>
/// Tell all the prims which have had updates scheduled /// Tell all the prims which have had updates scheduled
/// </summary> /// </summary>
@ -3491,73 +3512,43 @@ namespace OpenSim.Region.Framework.Scenes
if(current == PrimUpdateFlags.TerseUpdate) if(current == PrimUpdateFlags.TerseUpdate)
{ {
Vector3 curvel = Velocity;
Vector3 curacc = Acceleration;
Vector3 angvel = AngularVelocity;
while(true) // just to avoid ugly goto while(true) // just to avoid ugly goto
{ {
double elapsed = now - m_lastUpdateSentTime; double elapsed = now - m_lastUpdateSentTime;
if (elapsed > TIME_MS_TOLERANCE) if (elapsed > TIME_MS_TOLERANCE)
break; break;
if( Math.Abs(curacc.X - m_lastAcceleration.X) > VELOCITY_TOLERANCE || if ( !Acceleration.ApproxEquals(m_lastAcceleration, VELOCITY_TOLERANCE))
Math.Abs(curacc.Y - m_lastAcceleration.Y) > VELOCITY_TOLERANCE ||
Math.Abs(curacc.Z - m_lastAcceleration.Z) > VELOCITY_TOLERANCE)
break; break;
if( Math.Abs(curvel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE || Vector3 curvel = ClampVectorForTerseUpdate(Velocity, 128f);
Math.Abs(curvel.Y - m_lastVelocity.Y) > VELOCITY_TOLERANCE || Vector3 tmp = ClampVectorForTerseUpdate(m_lastVelocity, 128f);
Math.Abs(curvel.Z - m_lastVelocity.Z) > VELOCITY_TOLERANCE) if (!curvel.ApproxEquals(tmp, VELOCITY_TOLERANCE))
break; break;
float vx = Math.Abs(curvel.X); if (Math.Abs(curvel.X) < 1e-4 && Math.Abs(curvel.Y) < 1e-4 && Math.Abs(curvel.Z) < 1e-4)
if(vx > 128.0)
break;
float vy = Math.Abs(curvel.Y);
if(vy > 128.0)
break;
float vz = Math.Abs(curvel.Z);
if(vz > 128.0)
break;
if(vx < VELOCITY_TOLERANCE && vy < VELOCITY_TOLERANCE && vz < VELOCITY_TOLERANCE
)
{ {
if(!AbsolutePosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) if (!AbsolutePosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
break; break;
if(vx < 1e-4 && vy < 1e-4 && vz < 1e-4 && if ( Math.Abs(m_lastVelocity.X) > 1e-4 ||
(
Math.Abs(m_lastVelocity.X) > 1e-4 ||
Math.Abs(m_lastVelocity.Y) > 1e-4 || Math.Abs(m_lastVelocity.Y) > 1e-4 ||
Math.Abs(m_lastVelocity.Z) > 1e-4 Math.Abs(m_lastVelocity.Z) > 1e-4
)) )
break; break;
} }
if( Math.Abs(angvel.X - m_lastAngularVelocity.X) > ANGVELOCITY_TOLERANCE || Vector3 angvel = ClampVectorForTerseUpdate(AngularVelocity, 64f);
Math.Abs(angvel.Y - m_lastAngularVelocity.Y) > ANGVELOCITY_TOLERANCE || tmp = ClampVectorForTerseUpdate(m_lastAngularVelocity, 64f);
Math.Abs(angvel.Z - m_lastAngularVelocity.Z) > ANGVELOCITY_TOLERANCE) if (!angvel.ApproxEquals(tmp, ANGVELOCITY_TOLERANCE))
break; break;
// viewer interpolators have a limit of 64rad/s if ( Math.Abs(AngularVelocity.X) < 1e-4 &&
float ax = Math.Abs(angvel.X); Math.Abs(AngularVelocity.Y) < 1e-4 &&
if(ax > 64.0) Math.Abs(AngularVelocity.Z) < 1e-4 &&
break;
float ay = Math.Abs(angvel.Y);
if(ay > 64.0)
break;
float az = Math.Abs(angvel.Z);
if(az > 64.0)
break;
if (
ax < ANGVELOCITY_TOLERANCE &&
ay < ANGVELOCITY_TOLERANCE &&
az < ANGVELOCITY_TOLERANCE &&
!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) !RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)
) )
break; break;
return; return;
} }
} }

View File

@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes
// Default, not-often-used builder // Default, not-often-used builder
public TerrainChannel() public TerrainChannel()
{ {
m_terrainData = new HeightmapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); m_terrainData = new TerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
FlatLand(); FlatLand();
// PinHeadIsland(); // PinHeadIsland();
} }
@ -69,14 +69,14 @@ namespace OpenSim.Region.Framework.Scenes
// Create terrain of given size // Create terrain of given size
public TerrainChannel(int pX, int pY) public TerrainChannel(int pX, int pY)
{ {
m_terrainData = new HeightmapTerrainData(pX, pY, (int)Constants.RegionHeight); m_terrainData = new TerrainData(pX, pY, (int)Constants.RegionHeight);
} }
// Create terrain of specified size and initialize with specified terrain. // Create terrain of specified size and initialize with specified terrain.
// TODO: join this with the terrain initializers. // TODO: join this with the terrain initializers.
public TerrainChannel(String type, int pX, int pY, int pZ) public TerrainChannel(String type, int pX, int pY, int pZ)
{ {
m_terrainData = new HeightmapTerrainData(pX, pY, pZ); m_terrainData = new TerrainData(pX, pY, pZ);
if (type.Equals("flat")) if (type.Equals("flat"))
FlatLand(); FlatLand();
else else
@ -90,7 +90,7 @@ namespace OpenSim.Region.Framework.Scenes
int hmSizeX = pM.GetLength(0); int hmSizeX = pM.GetLength(0);
int hmSizeY = pM.GetLength(1); int hmSizeY = pM.GetLength(1);
m_terrainData = new HeightmapTerrainData(pSizeX, pSizeY, pAltitude); m_terrainData = new TerrainData(pSizeX, pSizeY, pAltitude);
for (int xx = 0; xx < pSizeX; xx++) for (int xx = 0; xx < pSizeX; xx++)
for (int yy = 0; yy < pSizeY; yy++) for (int yy = 0; yy < pSizeY; yy++)
@ -309,7 +309,7 @@ namespace OpenSim.Region.Framework.Scenes
int tmpY = baseY + baseY / 2; int tmpY = baseY + baseY / 2;
int centreX = tmpX / 2; int centreX = tmpX / 2;
int centreY = tmpY / 2; int centreY = tmpY / 2;
TerrainData terrain_tmp = new HeightmapTerrainData(tmpX, tmpY, (int)Constants.RegionHeight); TerrainData terrain_tmp = new TerrainData(tmpX, tmpY, (int)Constants.RegionHeight);
for (int xx = 0; xx < tmpX; xx++) for (int xx = 0; xx < tmpX; xx++)
for (int yy = 0; yy < tmpY; yy++) for (int yy = 0; yy < tmpY; yy++)
terrain_tmp[xx, yy] = -65535f; //use this height like an 'alpha' mask channel terrain_tmp[xx, yy] = -65535f; //use this height like an 'alpha' mask channel
@ -483,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes
byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); byte[] dataArray = (byte[])serializer.Deserialize(xmlReader);
int index = 0; int index = 0;
m_terrainData = new HeightmapTerrainData(Height, Width, (int)Constants.RegionHeight); m_terrainData = new TerrainData(Height, Width, (int)Constants.RegionHeight);
for (int y = 0; y < Height; y++) for (int y = 0; y < Height; y++)
{ {
@ -530,7 +530,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage));
TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader); TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader);
m_terrainData = new HeightmapTerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ); m_terrainData = new TerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ);
} }
// Fill the heightmap with the center bump terrain // Fill the heightmap with the center bump terrain

View File

@ -155,7 +155,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return iout; return iout;
} }
static double tt;
// new using terrain data and patchs indexes // new using terrain data and patchs indexes
public static List<LayerDataPacket> CreateLayerDataPackets(TerrainData terrData, int[] map) public static List<LayerDataPacket> CreateLayerDataPackets(TerrainData terrData, int[] map)
{ {
@ -180,15 +179,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
bitpack.PackBitsFromByte(16); bitpack.PackBitsFromByte(16);
bitpack.PackBitsFromByte(landPacketType); bitpack.PackBitsFromByte(landPacketType);
tt = 0;
int s; int s;
for (int i = 0; i < numberPatchs; i++) for (int i = 0; i < numberPatchs; i++)
{ {
s = 2 * i; s = 2 * i;
tt -= Util.GetTimeStampMS();
CreatePatchFromTerrainData(bitpack, terrData, map[s], map[s + 1]); CreatePatchFromTerrainData(bitpack, terrData, map[s], map[s + 1]);
tt += Util.GetTimeStampMS();
if (bitpack.BytePos > 980 && i != numberPatchs - 1) if (bitpack.BytePos > 980 && i != numberPatchs - 1)
{ {

View File

@ -736,7 +736,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
get get
{ {
SceneObjectPart sop = m_scene.GetSceneObjectPart(m_objectID); SceneObjectPart sop = m_scene.GetSceneObjectPart(m_objectID);
if (sop == null) if (sop == null || sop.DynAttrs == null)
{ {
// This is bad // This is bad
return null; return null;

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.RGBA = new Color4(value.R,value.G,value.B,value.A); texface.RGBA = new Color4(value.R,value.G,value.B,value.A);
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTextureEntry(tex.GetBytes()); m_parent.UpdateTextureEntry(tex);
} }
} }
@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.TextureID = value; texface.TextureID = value;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTextureEntry(tex.GetBytes()); m_parent.UpdateTextureEntry(tex);
} }
} }
@ -97,7 +97,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.Fullbright = value; texface.Fullbright = value;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTextureEntry(tex.GetBytes()); m_parent.UpdateTextureEntry(tex);
} }
} }
@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.Glow = (float) value; texface.Glow = (float) value;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTextureEntry(tex.GetBytes()); m_parent.UpdateTextureEntry(tex);
} }
} }
@ -123,7 +123,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.Shiny = value ? Shininess.High : Shininess.None; texface.Shiny = value ? Shininess.High : Shininess.None;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTextureEntry(tex.GetBytes()); m_parent.UpdateTextureEntry(tex);
} }
} }

View File

@ -323,7 +323,7 @@ namespace OpenSim.Services.Connectors.Simulation
try try
{ {
OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false); OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false, true);
bool success = result["success"].AsBoolean(); bool success = result["success"].AsBoolean();
if (result.ContainsKey("_Result")) if (result.ContainsKey("_Result"))
{ {