From ef4122213c440c55d32c097c08e52170f4b4346a Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Mon, 6 Aug 2012 15:35:40 +0100
Subject: enables configurable minimum sizes for physical & non-physical prims
---
OpenSim/Framework/RegionInfo.cs | 42 ++++++++++++++-
OpenSim/Region/Framework/Scenes/Scene.cs | 31 ++++++++++-
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 9 ++--
.../Region/Framework/Scenes/SceneObjectGroup.cs | 60 +++++++++++++++++++---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 +++--
.../Shared/Api/Implementation/LSL_Api.cs | 28 +++-------
bin/OpenSim.ini.example | 8 +++
7 files changed, 149 insertions(+), 42 deletions(-)
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 2080a16..8131089 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -120,7 +120,9 @@ namespace OpenSim.Framework
public UUID lastMapUUID = UUID.Zero;
public string lastMapRefresh = "0";
+ private float m_nonphysPrimMin = 0;
private int m_nonphysPrimMax = 0;
+ private float m_physPrimMin = 0;
private int m_physPrimMax = 0;
private bool m_clampPrimSize = false;
private int m_objectCapacity = 0;
@@ -285,11 +287,21 @@ namespace OpenSim.Framework
set { m_windlight = value; }
}
+ public float NonphysPrimMin
+ {
+ get { return m_nonphysPrimMin; }
+ }
+
public int NonphysPrimMax
{
get { return m_nonphysPrimMax; }
}
+ public float PhysPrimMin
+ {
+ get { return m_physPrimMin; }
+ }
+
public int PhysPrimMax
{
get { return m_physPrimMax; }
@@ -623,16 +635,28 @@ namespace OpenSim.Framework
m_regionType = config.GetString("RegionType", String.Empty);
allKeys.Remove("RegionType");
- // Prim stuff
- //
+ #region Prim stuff
+
+ m_nonphysPrimMin = config.GetFloat("NonphysicalPrimMin", 0);
+ allKeys.Remove("NonphysicalPrimMin");
+
m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0);
allKeys.Remove("NonphysicalPrimMax");
+
+ m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0);
+ allKeys.Remove("PhysicalPrimMin");
+
m_physPrimMax = config.GetInt("PhysicalPrimMax", 0);
allKeys.Remove("PhysicalPrimMax");
+
m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
allKeys.Remove("ClampPrimSize");
+
m_objectCapacity = config.GetInt("MaxPrims", 15000);
allKeys.Remove("MaxPrims");
+
+ #endregion
+
m_agentCapacity = config.GetInt("MaxAgents", 100);
allKeys.Remove("MaxAgents");
@@ -668,10 +692,18 @@ namespace OpenSim.Framework
config.Set("ExternalHostName", m_externalHostName);
+ if (m_nonphysPrimMin != 0)
+ config.Set("NonphysicalPrimMax", m_nonphysPrimMin);
+
if (m_nonphysPrimMax != 0)
config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
+
+ if (m_physPrimMin != 0)
+ config.Set("PhysicalPrimMax", m_physPrimMin);
+
if (m_physPrimMax != 0)
config.Set("PhysicalPrimMax", m_physPrimMax);
+
config.Set("ClampPrimSize", m_clampPrimSize.ToString());
if (m_objectCapacity != 0)
@@ -754,9 +786,15 @@ namespace OpenSim.Framework
configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
+ configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
+ "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true);
+
configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
"Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true);
+ configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
+ "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true);
+
configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
"Maximum size for physical prims", m_physPrimMax.ToString(), true);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0e5ddfd..d2d6aba 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -103,8 +103,26 @@ namespace OpenSim.Region.Framework.Scenes
///
public bool CollidablePrims { get; private set; }
+ ///
+ /// Minimum value of the size of a non-physical prim in each axis
+ ///
+ public float m_minNonphys = 0.01f;
+
+ ///
+ /// Maximum value of the size of a non-physical prim in each axis
+ ///
public float m_maxNonphys = 256;
+
+ ///
+ /// Minimum value of the size of a physical prim in each axis
+ ///
+ public float m_minPhys = 0.01f;
+
+ ///
+ /// Maximum value of the size of a physical prim in each axis
+ ///
public float m_maxPhys = 10;
+
public bool m_clampPrimSize;
public bool m_trustBinaries;
public bool m_allowScriptCrossings;
@@ -721,14 +739,25 @@ namespace OpenSim.Region.Framework.Scenes
PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
+ m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys);
+ if (RegionInfo.NonphysPrimMin > 0)
+ {
+ m_minNonphys = RegionInfo.NonphysPrimMin;
+ }
+
m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
if (RegionInfo.NonphysPrimMax > 0)
{
m_maxNonphys = RegionInfo.NonphysPrimMax;
}
- m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
+ m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
+ if (RegionInfo.PhysPrimMin > 0)
+ {
+ m_minPhys = RegionInfo.PhysPrimMin;
+ }
+ m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
if (RegionInfo.PhysPrimMax > 0)
{
m_maxPhys = RegionInfo.PhysPrimMax;
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 13842ad..b6339fb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -375,12 +375,9 @@ namespace OpenSim.Region.Framework.Scenes
{
Vector3 scale = part.Shape.Scale;
- if (scale.X > m_parentScene.m_maxNonphys)
- scale.X = m_parentScene.m_maxNonphys;
- if (scale.Y > m_parentScene.m_maxNonphys)
- scale.Y = m_parentScene.m_maxNonphys;
- if (scale.Z > m_parentScene.m_maxNonphys)
- scale.Z = m_parentScene.m_maxNonphys;
+ scale.X = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.X));
+ scale.Y = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Y));
+ scale.Z = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Z));
part.Shape.Scale = scale;
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5f90035..f6c725b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2674,17 +2674,17 @@ namespace OpenSim.Region.Framework.Scenes
RootPart.StoreUndoState(true);
- scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
- scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
- scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys);
+ scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X));
+ scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y));
+ scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z));
PhysicsActor pa = m_rootPart.PhysActor;
if (pa != null && pa.IsPhysical)
{
- scale.X = Math.Min(scale.X, Scene.m_maxPhys);
- scale.Y = Math.Min(scale.Y, Scene.m_maxPhys);
- scale.Z = Math.Min(scale.Z, Scene.m_maxPhys);
+ scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X));
+ scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y));
+ scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z));
}
float x = (scale.X / RootPart.Scale.X);
@@ -2716,6 +2716,14 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+ else if (oldSize.X * x < m_scene.m_minPhys)
+ {
+ f = m_scene.m_minPhys / oldSize.X;
+ a = f / x;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
if (oldSize.Y * y > m_scene.m_maxPhys)
{
@@ -2725,6 +2733,14 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+ else if (oldSize.Y * y < m_scene.m_minPhys)
+ {
+ f = m_scene.m_minPhys / oldSize.Y;
+ a = f / y;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
if (oldSize.Z * z > m_scene.m_maxPhys)
{
@@ -2734,6 +2750,14 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+ else if (oldSize.Z * z < m_scene.m_minPhys)
+ {
+ f = m_scene.m_minPhys / oldSize.Z;
+ a = f / z;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
}
else
{
@@ -2745,6 +2769,14 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+ else if (oldSize.X * x < m_scene.m_minNonphys)
+ {
+ f = m_scene.m_minNonphys / oldSize.X;
+ a = f / x;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
if (oldSize.Y * y > m_scene.m_maxNonphys)
{
@@ -2754,6 +2786,14 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+ else if (oldSize.Y * y < m_scene.m_minNonphys)
+ {
+ f = m_scene.m_minNonphys / oldSize.Y;
+ a = f / y;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
if (oldSize.Z * z > m_scene.m_maxNonphys)
{
@@ -2763,6 +2803,14 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+ else if (oldSize.Z * z < m_scene.m_minNonphys)
+ {
+ f = m_scene.m_minNonphys / oldSize.Z;
+ a = f / z;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
}
// obPart.IgnoreUndoUpdate = false;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4c87639..cd75224 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2368,17 +2368,16 @@ namespace OpenSim.Region.Framework.Scenes
///
public void Resize(Vector3 scale)
{
- scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxNonphys);
- scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys);
- scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys);
+ scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X));
+ scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y));
+ scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z));
PhysicsActor pa = PhysActor;
-
if (pa != null && pa.IsPhysical)
{
- scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys);
- scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys);
- scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxPhys);
+ scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X));
+ scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y));
+ scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z));
}
// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 55567d1..a7852ec 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1343,31 +1343,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part == null || part.ParentGroup.IsDeleted)
return;
- if (scale.x < 0.01)
- scale.x = 0.01;
- if (scale.y < 0.01)
- scale.y = 0.01;
- if (scale.z < 0.01)
- scale.z = 0.01;
-
+ // First we need to check whether or not we need to clamp the size of a physics-enabled prim
PhysicsActor pa = part.ParentGroup.RootPart.PhysActor;
-
if (pa != null && pa.IsPhysical)
{
- if (scale.x > World.m_maxPhys)
- scale.x = World.m_maxPhys;
- if (scale.y > World.m_maxPhys)
- scale.y = World.m_maxPhys;
- if (scale.z > World.m_maxPhys)
- scale.z = World.m_maxPhys;
+ scale.x = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.x));
+ scale.y = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.y));
+ scale.z = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.z));
}
- if (scale.x > World.m_maxNonphys)
- scale.x = World.m_maxNonphys;
- if (scale.y > World.m_maxNonphys)
- scale.y = World.m_maxNonphys;
- if (scale.z > World.m_maxNonphys)
- scale.z = World.m_maxNonphys;
+ // Next we clamp the scale to the non-physical min/max
+ scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x));
+ scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y));
+ scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z));
Vector3 tmp = part.Scale;
tmp.X = (float)scale.x;
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 9c68b65..bced817 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -87,10 +87,18 @@
;; from the selected region_info_source.
; allow_regionless = false
+ ;# {NonPhysicalPrimMin} {} {Minimum size of nonphysical prims?} {} 0.01
+ ;; Minimum size for non-physical prims. Affects resizing of existing prims. This can be overriden in the region config file (as NonphysicalPrimMin!).
+ ; NonphysicalPrimMin = 0.01
+
;# {NonPhysicalPrimMax} {} {Maximum size of nonphysical prims?} {} 256
;; Maximum size for non-physical prims. Affects resizing of existing prims. This can be overriden in the region config file (as NonphysicalPrimMax!).
; NonphysicalPrimMax = 256
+ ;# {PhysicalPrimMin} {} {Minimum size of physical prims?} {} 10
+ ;; Maximum size where a prim can be physical. Affects resizing of existing prims. This can be overriden in the region config file.
+ ; PhysicalPrimMin = 0.01
+
;# {PhysicalPrimMax} {} {Maximum size of physical prims?} {} 10
;; Maximum size where a prim can be physical. Affects resizing of existing prims. This can be overriden in the region config file.
; PhysicalPrimMax = 10
--
cgit v1.1
From ae5db637f29dbc3fda49580f5a0f869d1b0b4958 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 15 Aug 2012 15:14:58 -0700
Subject: BulletSim: update DLLs and SOs to fix the problem with avatars
jumping around at altitudes less than 25m.
---
bin/lib32/BulletSim.dll | Bin 550400 -> 553472 bytes
bin/lib32/libBulletSim.so | Bin 2387345 -> 2387051 bytes
bin/lib64/BulletSim.dll | Bin 706048 -> 709632 bytes
bin/lib64/libBulletSim.so | Bin 2599320 -> 2599546 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll
index 0f2d522..cc55f00 100755
Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ
diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so
index 783c9a2..26ad52b 100755
Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ
diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll
index c2a2bda..94dae95 100755
Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ
diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so
index 74d4f98..52e9960 100755
Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ
--
cgit v1.1
From 376441e5507052b36279279f64896542d44ec12a Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 15 Aug 2012 16:27:30 -0700
Subject: BulletSim: make it so objects in a linkset do not generate collisions
with each other.
---
OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 7 +++++++
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 10 ++++++++++
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 12 ++++++++++--
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 087b9bb..1b3ba3f 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -42,6 +42,9 @@ public class BSLinkset
private BSScene m_physicsScene;
public BSScene PhysicsScene { get { return m_physicsScene; } }
+ static int m_nextLinksetID = 1;
+ public int LinksetID { get; private set; }
+
// The children under the root in this linkset
private List m_children;
@@ -74,6 +77,10 @@ public class BSLinkset
public BSLinkset(BSScene scene, BSPrim parent)
{
// A simple linkset of one (no children)
+ LinksetID = m_nextLinksetID++;
+ // We create LOTS of linksets.
+ if (m_nextLinksetID < 0)
+ m_nextLinksetID = 1;
m_physicsScene = scene;
m_linksetRoot = parent;
m_children = new List();
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 9c20004..c157669 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -1353,6 +1353,7 @@ public sealed class BSPrim : PhysicsActor
}
// I've collided with something
+ // Called at taint time from within the Step() function
CollisionEventUpdate collisionCollection;
public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
{
@@ -1366,6 +1367,15 @@ public sealed class BSPrim : PhysicsActor
}
// DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith);
+ BSPrim collidingWithPrim;
+ if (_scene.Prims.TryGetValue(collidingWith, out collidingWithPrim))
+ {
+ // prims in the same linkset cannot collide with each other
+ if (this.Linkset.LinksetID == collidingWithPrim.Linkset.LinksetID)
+ {
+ return;
+ }
+ }
// if someone is subscribed to collision events....
if (_subscribedEventsMs != 0) {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index a31c578..0a0e27e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -78,10 +78,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public string BulletSimVersion = "?";
private Dictionary m_avatars = new Dictionary();
+ public Dictionary Characters { get { return m_avatars; } }
+
private Dictionary m_prims = new Dictionary();
+ public Dictionary Prims { get { return m_prims; } }
+
private HashSet m_avatarsWithCollisions = new HashSet();
private HashSet m_primsWithCollisions = new HashSet();
+
private List m_vehicles = new List();
+
private float[] m_heightMap;
private float m_waterLevel;
private uint m_worldID;
@@ -429,13 +435,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters
{
numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep,
out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr);
- // DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount);
+ DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount);
}
catch (Exception e)
{
m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e);
// DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount);
- // updatedEntityCount = 0;
+ updatedEntityCount = 0;
collidersCount = 0;
}
@@ -534,6 +540,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
else if (m_avatars.ContainsKey(collidingWith))
type = ActorTypes.Agent;
+ DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
+
BSPrim prim;
if (m_prims.TryGetValue(localID, out prim)) {
prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration);
--
cgit v1.1
From 57a98796693cdd34efefbc9235b5d0aa765db095 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 15 Aug 2012 16:39:00 -0700
Subject: Correct an exception report in SceneObjectPart so it outputs the
stack.
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index cd75224..bd6369c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -733,7 +733,7 @@ namespace OpenSim.Region.Framework.Scenes
}
catch (Exception e)
{
- m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
+ m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e);
}
}
--
cgit v1.1
From e9ea911563362c4766d34cd948a2915beac06124 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 17 Aug 2012 16:53:36 +0100
Subject: adding a clip method to handle Vector3 objects to enable a minor
amount of refactoring
---
OpenSim/Framework/Util.cs | 6 ++++++
.../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 11 +++++------
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 8cc29ee..38cb3a6 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -850,6 +850,12 @@ namespace OpenSim.Framework
return Math.Min(Math.Max(x, min), max);
}
+ public static Vector3 Clip(Vector3 vec, float min, float max)
+ {
+ return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max),
+ Clip(vec.Z, min, max));
+ }
+
///
/// Convert an UUID to a raw uuid string. Right now this is a string without hyphens.
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index a7852ec..b7b5e8e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -4019,9 +4019,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetText(string text, LSL_Vector color, double alpha)
{
m_host.AddScriptLPS(1);
- Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f),
- Util.Clip((float)color.y, 0.0f, 1.0f),
- Util.Clip((float)color.z, 0.0f, 1.0f));
+ Vector3 av3 = Util.Clip(new Vector3((float)color.x, (float)color.y,
+ (float)color.z), 0.0f, 1.0f);
m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
//m_host.ParentGroup.HasGroupChanged = true;
//m_host.ParentGroup.ScheduleGroupForFullUpdate();
@@ -7635,9 +7634,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primText = rules.GetLSLStringItem(idx++);
LSL_Vector primTextColor = rules.GetVector3Item(idx++);
LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
- Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f),
- Util.Clip((float)primTextColor.y, 0.0f, 1.0f),
- Util.Clip((float)primTextColor.z, 0.0f, 1.0f));
+ Vector3 av3 = Util.Clip(new Vector3((float)primTextColor.x,
+ (float)primTextColor.y,
+ (float)primTextColor.z), 0.0f, 1.0f);
part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f));
break;
--
cgit v1.1
From e31e23d68d9935457ad86559bea37b2b4a63a8dc Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 15 Aug 2012 16:49:05 -0700
Subject: BulletSim: in BSDynamics, merge 'flags' and 'hoverFlags' as they are
defined for the same bits and it makes the code less complicated.
---
OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 178 +++------------------
1 file changed, 20 insertions(+), 158 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 5a9f135..78bfa05 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -74,7 +74,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// HOVER_UP_ONLY
// LIMIT_MOTOR_UP
// LIMIT_ROLL_ONLY
- private VehicleFlag m_Hoverflags = (VehicleFlag)0;
private Vector3 m_BlockingEndPoint = Vector3.Zero;
private Quaternion m_RollreferenceFrame = Quaternion.Identity;
// Linear properties
@@ -281,157 +280,20 @@ namespace OpenSim.Region.Physics.BulletSPlugin
internal void ProcessVehicleFlags(int pParam, bool remove)
{
DetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove);
+ VehicleFlag parm = (VehicleFlag)pParam;
if (remove)
{
if (pParam == -1)
{
m_flags = (VehicleFlag)0;
- m_Hoverflags = (VehicleFlag)0;
- return;
}
- if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT)
- {
- if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != (VehicleFlag)0)
- m_Hoverflags &= ~(VehicleFlag.HOVER_GLOBAL_HEIGHT);
- }
- if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY)
- {
- if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != (VehicleFlag)0)
- m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY);
- }
- if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY)
- {
- if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != (VehicleFlag)0)
- m_Hoverflags &= ~(VehicleFlag.HOVER_UP_ONLY);
- }
- if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY)
- {
- if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != (VehicleFlag)0)
- m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY);
- }
- if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP)
- {
- if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.LIMIT_MOTOR_UP);
- }
- if ((pParam & (int)VehicleFlag.LIMIT_ROLL_ONLY) == (int)VehicleFlag.LIMIT_ROLL_ONLY)
- {
- if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY);
- }
- if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK)
- {
- if ((m_flags & VehicleFlag.MOUSELOOK_BANK) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.MOUSELOOK_BANK);
- }
- if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER)
- {
- if ((m_flags & VehicleFlag.MOUSELOOK_STEER) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.MOUSELOOK_STEER);
- }
- if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP)
- {
- if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP);
- }
- if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED)
- {
- if ((m_flags & VehicleFlag.CAMERA_DECOUPLED) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.CAMERA_DECOUPLED);
- }
- if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X)
- {
- if ((m_flags & VehicleFlag.NO_X) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.NO_X);
- }
- if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y)
- {
- if ((m_flags & VehicleFlag.NO_Y) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.NO_Y);
- }
- if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z)
- {
- if ((m_flags & VehicleFlag.NO_Z) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.NO_Z);
- }
- if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT)
- {
- if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != (VehicleFlag)0)
- m_Hoverflags &= ~(VehicleFlag.LOCK_HOVER_HEIGHT);
- }
- if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION)
- {
- if ((m_flags & VehicleFlag.NO_DEFLECTION) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.NO_DEFLECTION);
- }
- if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION)
+ else
{
- if ((m_flags & VehicleFlag.LOCK_ROTATION) != (VehicleFlag)0)
- m_flags &= ~(VehicleFlag.LOCK_ROTATION);
+ m_flags &= ~parm;
}
}
- else
- {
- if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT)
- {
- m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT | m_flags);
- }
- if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY)
- {
- m_Hoverflags |= (VehicleFlag.HOVER_TERRAIN_ONLY | m_flags);
- }
- if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY)
- {
- m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY | m_flags);
- }
- if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY)
- {
- m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY | m_flags);
- }
- if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP)
- {
- m_flags |= (VehicleFlag.LIMIT_MOTOR_UP | m_flags);
- }
- if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK)
- {
- m_flags |= (VehicleFlag.MOUSELOOK_BANK | m_flags);
- }
- if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER)
- {
- m_flags |= (VehicleFlag.MOUSELOOK_STEER | m_flags);
- }
- if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP)
- {
- m_flags |= (VehicleFlag.NO_DEFLECTION_UP | m_flags);
- }
- if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED)
- {
- m_flags |= (VehicleFlag.CAMERA_DECOUPLED | m_flags);
- }
- if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X)
- {
- m_flags |= (VehicleFlag.NO_X);
- }
- if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y)
- {
- m_flags |= (VehicleFlag.NO_Y);
- }
- if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z)
- {
- m_flags |= (VehicleFlag.NO_Z);
- }
- if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT)
- {
- m_Hoverflags |= (VehicleFlag.LOCK_HOVER_HEIGHT);
- }
- if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION)
- {
- m_flags |= (VehicleFlag.NO_DEFLECTION);
- }
- if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION)
- {
- m_flags |= (VehicleFlag.LOCK_ROTATION);
- }
+ else {
+ m_flags |= parm;
}
}//end ProcessVehicleFlags
@@ -478,10 +340,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// m_bankingMix = 1;
// m_bankingTimescale = 10;
// m_referenceFrame = Quaternion.Identity;
- m_Hoverflags &=
+ m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
+ m_flags &=
~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
- m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
break;
case Vehicle.TYPE_CAR:
m_linearFrictionTimescale = new Vector3(100, 2, 1000);
@@ -506,10 +368,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// m_bankingMix = 1;
// m_bankingTimescale = 1;
// m_referenceFrame = Quaternion.Identity;
- m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY |
VehicleFlag.LIMIT_MOTOR_UP);
- m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY);
+ m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
+ m_flags |= (VehicleFlag.HOVER_UP_ONLY);
break;
case Vehicle.TYPE_BOAT:
m_linearFrictionTimescale = new Vector3(10, 3, 2);
@@ -534,12 +396,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// m_bankingMix = 0.8f;
// m_bankingTimescale = 1;
// m_referenceFrame = Quaternion.Identity;
- m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY |
+ m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY |
VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY);
m_flags |= (VehicleFlag.NO_DEFLECTION_UP |
VehicleFlag.LIMIT_MOTOR_UP);
- m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY);
+ m_flags |= (VehicleFlag.HOVER_WATER_ONLY);
break;
case Vehicle.TYPE_AIRPLANE:
m_linearFrictionTimescale = new Vector3(200, 10, 5);
@@ -564,7 +426,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// m_bankingMix = 0.7f;
// m_bankingTimescale = 2;
// m_referenceFrame = Quaternion.Identity;
- m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
+ m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP);
m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
@@ -592,11 +454,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// m_bankingMix = 0.7f;
// m_bankingTimescale = 5;
// m_referenceFrame = Quaternion.Identity;
- m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
+ m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
VehicleFlag.HOVER_UP_ONLY);
m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP);
m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
- m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT);
+ m_flags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT);
break;
}
}//end SetDefaultsForType
@@ -736,28 +598,28 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
// Check if hovering
- if ((m_Hoverflags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0)
+ if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0)
{
// We should hover, get the target height
- if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != 0)
+ if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0)
{
m_VhoverTargetHeight = m_prim.Scene.GetWaterLevel() + m_VhoverHeight;
}
- if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
+ if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
{
m_VhoverTargetHeight = m_prim.Scene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight;
}
- if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0)
+ if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0)
{
m_VhoverTargetHeight = m_VhoverHeight;
}
- if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != 0)
+ if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0)
{
// If body is aready heigher, use its height as target height
if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z;
}
- if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0)
+ if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0)
{
if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2)
{
--
cgit v1.1
From 8eda290262bb7049aa55a7df2bdb1565bad85a99 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 17 Aug 2012 09:37:02 -0700
Subject: BulletSim: comments and parameter changes in dynamics engine.
---
OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 50 ++++++++++++----------
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 6 +--
2 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 78bfa05..d7213fc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
private int frcount = 0; // Used to limit dynamics debug output to
// every 100th frame
+ private BSScene m_physicsScene;
private BSPrim m_prim; // the prim this dynamic controller belongs to
// Vehicle properties
@@ -123,15 +124,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin
private float m_verticalAttractionEfficiency = 1.0f; // damped
private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
- public BSDynamics(BSPrim myPrim)
+ public BSDynamics(BSScene myScene, BSPrim myPrim)
{
+ m_physicsScene = myScene;
m_prim = myPrim;
m_type = Vehicle.TYPE_NONE;
}
internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep)
{
- DetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
+ VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
switch (pParam)
{
case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
@@ -230,7 +232,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep)
{
- DetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
+ VDetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
switch (pParam)
{
case Vehicle.ANGULAR_FRICTION_TIMESCALE:
@@ -265,7 +267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue)
{
- DetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
+ VDetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
switch (pParam)
{
case Vehicle.REFERENCE_FRAME:
@@ -279,7 +281,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
internal void ProcessVehicleFlags(int pParam, bool remove)
{
- DetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove);
+ VDetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove);
VehicleFlag parm = (VehicleFlag)pParam;
if (remove)
{
@@ -297,9 +299,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
}//end ProcessVehicleFlags
- internal void ProcessTypeChange(Vehicle pType)
+ internal void ProcessTypeChange(Vehicle pType, float stepSize)
{
- DetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType);
+ VDetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType);
// Set Defaults For Type
m_type = pType;
switch (pType)
@@ -475,7 +477,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
MoveAngular(pTimestep);
LimitRotation(pTimestep);
- DetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}",
+ VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}",
m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity);
}// end Step
@@ -519,7 +521,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
*/
- DetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}",
+ VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}",
m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector);
}
else
@@ -531,7 +533,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
m_lastLinearVelocityVector = Vector3.Zero;
}
- // convert requested object velocity to world-referenced vector
+ // convert requested object velocity to object relative vector
Quaternion rotq = m_prim.Orientation;
m_dir = m_lastLinearVelocityVector * rotq;
@@ -584,7 +586,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
if (changed)
{
m_prim.Position = pos;
- DetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}",
+ VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}",
m_prim.LocalID, m_BlockingEndPoint, posChange, pos);
}
}
@@ -594,7 +596,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2;
m_prim.Position = pos;
- DetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos);
+ VDetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos);
}
// Check if hovering
@@ -641,7 +643,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
}
- DetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight);
+ VDetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight);
// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped
// m_VhoverTimescale = 0f; // time to acheive height
@@ -677,7 +679,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
grav.Z = (float)(grav.Z * 1.037125);
}
- DetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav);
+ VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav);
//End Experimental Values
}
if ((m_flags & (VehicleFlag.NO_X)) != 0)
@@ -706,7 +708,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
- DetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}",
+ VDetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}",
m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount);
} // end MoveLinear()
@@ -732,13 +734,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// There are m_angularMotorApply steps.
Vector3 origAngularVelocity = m_angularMotorVelocity;
// ramp up to new value
- // current velocity += error / (time to get there / step interval)
+ // current velocity += error / (time to get there / step interval)
// requested speed - last motor speed
m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep);
m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep);
m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep);
- DetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}",
+ VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}",
m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity);
m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected
@@ -749,6 +751,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// No motor recently applied, keep the body velocity
// and decay the velocity
m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep);
+ if (m_angularMotorVelocity.LengthSquared() < 0.00001)
+ m_angularMotorVelocity = Vector3.Zero;
} // end motor section
// Vertical attractor section
@@ -786,7 +790,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
vertattr.X += bounce * angularVelocity.X;
vertattr.Y += bounce * angularVelocity.Y;
- DetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}",
+ VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}",
m_prim.LocalID, verterr, bounce, vertattr);
} // else vertical attractor is off
@@ -804,13 +808,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
m_lastAngularVelocity.X = 0;
m_lastAngularVelocity.Y = 0;
- DetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
+ VDetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
}
if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
{
m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
- DetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
+ VDetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
}
// apply friction
@@ -820,7 +824,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// Apply to the body
m_prim.RotationalVelocity = m_lastAngularVelocity;
- DetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity);
+ VDetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity);
} //end MoveAngular
internal void LimitRotation(float timestep)
@@ -867,11 +871,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
if (changed)
m_prim.Orientation = m_rot;
- DetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot);
+ VDetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot);
}
// Invoke the detailed logger and output something if it's enabled.
- private void DetailLog(string msg, params Object[] args)
+ private void VDetailLog(string msg, params Object[] args)
{
if (m_prim.Scene.VehicleLoggingEnabled)
m_prim.Scene.PhysicsLogging.Write(msg, args);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index c157669..b918f84 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -141,8 +141,8 @@ public sealed class BSPrim : PhysicsActor
_friction = _scene.Params.defaultFriction; // TODO: compute based on object material
_density = _scene.Params.defaultDensity; // TODO: compute based on object material
_restitution = _scene.Params.defaultRestitution;
- _linkset = new BSLinkset(_scene, this); // a linkset of one
- _vehicle = new BSDynamics(this); // add vehicleness
+ _linkset = new BSLinkset(Scene, this); // a linkset of one
+ _vehicle = new BSDynamics(Scene, this); // add vehicleness
_mass = CalculateMass();
// do the actual object creation at taint time
DetailLog("{0},BSPrim.constructor,call", LocalID);
@@ -354,7 +354,7 @@ public sealed class BSPrim : PhysicsActor
{
// Done at taint time so we're sure the physics engine is not using the variables
// Vehicle code changes the parameters for this vehicle type.
- _vehicle.ProcessTypeChange(type);
+ _vehicle.ProcessTypeChange(type, Scene.LastSimulatedTimestep);
// Tell the scene about the vehicle so it will get processing each frame.
_scene.VehicleInSceneTypeChanged(this, type);
});
--
cgit v1.1
From ccc69d66a135e149dbe9c6b70df0c8efe1265f65 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 17 Aug 2012 10:40:34 -0700
Subject: BulletSim: add parameters and functionality to specify the mesh
level of detail for large meshes. Remove parameter and code for DetailLog
(conditional logging into regular log file).
---
OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 14 ------
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 14 +++---
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 54 +++++++++++------------
bin/OpenSimDefaults.ini | 3 ++
4 files changed, 37 insertions(+), 48 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 1b3ba3f..a075995 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -265,7 +265,6 @@ public class BSLinkset
BSPrim childx = child;
m_physicsScene.TaintedObject("AddChildToLinkset", delegate()
{
- // DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID);
// DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
PhysicallyLinkAChildToRoot(rootx, childx); // build the physical binding between me and the child
});
@@ -294,7 +293,6 @@ public class BSLinkset
BSPrim childx = child;
m_physicsScene.TaintedObject("RemoveChildFromLinkset", delegate()
{
- // DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID);
// DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
PhysicallyUnlinkAChildFromRoot(rootx, childx);
@@ -326,7 +324,6 @@ public class BSLinkset
// create a constraint that allows no freedom of movement between the two objects
// http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818
- // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID);
DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2},rLoc={3},cLoc={4},midLoc={5}",
rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID, rootPrim.Position, childPrim.Position, midPoint);
BS6DofConstraint constrain = new BS6DofConstraint(
@@ -350,7 +347,6 @@ public class BSLinkset
// create a constraint that allows no freedom of movement between the two objects
// http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818
- // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID);
DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID);
BS6DofConstraint constrain = new BS6DofConstraint(
PhysicsScene.World, rootPrim.Body, childPrim.Body,
@@ -389,8 +385,6 @@ public class BSLinkset
// Called at taint time!
private void PhysicallyUnlinkAChildFromRoot(BSPrim rootPrim, BSPrim childPrim)
{
- // DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}",
- // LogHeader, rootPrim.LocalID, childPrim.LocalID);
DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID);
// Find the constraint for this link and get rid of it from the overall collection and from my list
@@ -404,20 +398,12 @@ public class BSLinkset
// Called at taint time!
private void PhysicallyUnlinkAllChildrenFromRoot(BSPrim rootPrim)
{
- // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader);
DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID);
m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body);
}
// Invoke the detailed logger and output something if it's enabled.
- private void DebugLog(string msg, params Object[] args)
- {
- if (m_physicsScene.ShouldDebugLog)
- m_physicsScene.Logger.DebugFormat(msg, args);
- }
-
- // Invoke the detailed logger and output something if it's enabled.
private void DetailLog(string msg, params Object[] args)
{
m_physicsScene.PhysicsLogging.Write(msg, args);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index b918f84..48cd89b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -42,8 +42,6 @@ public sealed class BSPrim : PhysicsActor
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[BULLETS PRIM]";
- private void DebugLog(string mm, params Object[] xx) { if (_scene.ShouldDebugLog) m_log.DebugFormat(mm, xx); }
-
private IMesh _mesh;
private PrimitiveBaseShape _pbs;
private ShapeData.PhysicsShapeType _shapeType;
@@ -232,7 +230,6 @@ public sealed class BSPrim : PhysicsActor
BSPrim parent = obj as BSPrim;
if (parent != null)
{
- DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID);
BSPrim parentBefore = _linkset.LinksetRoot;
int childrenBefore = _linkset.NumberOfChildren;
@@ -248,8 +245,6 @@ public sealed class BSPrim : PhysicsActor
public override void delink() {
// TODO: decide if this parent checking needs to happen at taint time
// Race condition here: if link() and delink() in same simulation tick, the delink will not happen
- DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID,
- _linkset.LinksetRoot._avName+"/"+_linkset.LinksetRoot.LocalID.ToString());
BSPrim parentBefore = _linkset.LinksetRoot;
int childrenBefore = _linkset.NumberOfChildren;
@@ -1042,7 +1037,14 @@ public sealed class BSPrim : PhysicsActor
// No locking here because this is done when we know physics is not simulating
private void CreateGeomMesh()
{
- float lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD;
+ // level of detail based on size and type of the object
+ float lod = _scene.MeshLOD;
+ if (_pbs.SculptEntry)
+ lod = _scene.SculptLOD;
+ float maxAxis = Math.Max(_size.X, Math.Max(_size.Y, _size.Z));
+ if (maxAxis > _scene.MeshMegaPrimThreshold)
+ lod = _scene.MeshMegaPrimLOD;
+
ulong newMeshKey = (ulong)_pbs.GetMeshKey(_size, lod);
// m_log.DebugFormat("{0}: CreateGeomMesh: lID={1}, oldKey={2}, newKey={3}", LogHeader, _localID, _meshKey, newMeshKey);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 0a0e27e..d901ff0 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -73,8 +73,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[BULLETS SCENE]";
- public void DebugLog(string mm, params Object[] xx) { if (ShouldDebugLog) m_log.DebugFormat(mm, xx); }
-
public string BulletSimVersion = "?";
private Dictionary m_avatars = new Dictionary();
@@ -101,16 +99,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private int m_detailedStatsStep = 0;
public IMesher mesher;
- private float m_meshLOD;
- public float MeshLOD
- {
- get { return m_meshLOD; }
- }
- private float m_sculptLOD;
- public float SculptLOD
- {
- get { return m_sculptLOD; }
- }
+ // Level of Detail values kept as float because that's what the Meshmerizer wants
+ public float MeshLOD { get; private set; }
+ public float MeshMegaPrimLOD { get; private set; }
+ public float MeshMegaPrimThreshold { get; private set; }
+ public float SculptLOD { get; private set; }
private BulletSim m_worldSim;
public BulletSim World
@@ -185,8 +178,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
ConfigurationParameters[] m_params;
GCHandle m_paramsHandle;
- public bool ShouldDebugLog { get; private set; }
-
+ // Handle to the callback used by the unmanaged code to call into the managed code.
+ // Used for debug logging.
+ // Need to store the handle in a persistant variable so it won't be freed.
private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle;
// Sometimes you just have to log everything.
@@ -905,16 +899,26 @@ public class BSScene : PhysicsScene, IPhysicsParameters
(s) => { return s.NumericBool(s._forceSimplePrimMeshing); },
(s,p,l,v) => { s._forceSimplePrimMeshing = s.BoolNumeric(v); } ),
- new ParameterDefn("MeshLOD", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
+ new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
8f,
- (s,cf,p,v) => { s.m_meshLOD = cf.GetInt(p, (int)v); },
- (s) => { return (float)s.m_meshLOD; },
- (s,p,l,v) => { s.m_meshLOD = (int)v; } ),
- new ParameterDefn("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)",
+ (s,cf,p,v) => { s.MeshLOD = (float)cf.GetInt(p, (int)v); },
+ (s) => { return s.MeshLOD; },
+ (s,p,l,v) => { s.MeshLOD = v; } ),
+ new ParameterDefn("MeshLevelOfDetailMegaPrim", "Level of detail to render meshes larger than threshold meters",
+ 16f,
+ (s,cf,p,v) => { s.MeshMegaPrimLOD = (float)cf.GetInt(p, (int)v); },
+ (s) => { return s.MeshMegaPrimLOD; },
+ (s,p,l,v) => { s.MeshMegaPrimLOD = v; } ),
+ new ParameterDefn("MeshLevelOfDetailMegaPrimThreshold", "Size (in meters) of a mesh before using MeshMegaPrimLOD",
+ 10f,
+ (s,cf,p,v) => { s.MeshMegaPrimThreshold = (float)cf.GetInt(p, (int)v); },
+ (s) => { return s.MeshMegaPrimThreshold; },
+ (s,p,l,v) => { s.MeshMegaPrimThreshold = v; } ),
+ new ParameterDefn("SculptLevelOfDetail", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)",
32f,
- (s,cf,p,v) => { s.m_sculptLOD = cf.GetInt(p, (int)v); },
- (s) => { return (float)s.m_sculptLOD; },
- (s,p,l,v) => { s.m_sculptLOD = (int)v; } ),
+ (s,cf,p,v) => { s.SculptLOD = (float)cf.GetInt(p, (int)v); },
+ (s) => { return s.SculptLOD; },
+ (s,p,l,v) => { s.SculptLOD = v; } ),
new ParameterDefn("MaxSubStep", "In simulation step, maximum number of substeps",
10f,
@@ -1145,12 +1149,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters
(s,cf,p,v) => { s.m_detailedStatsStep = cf.GetInt(p, (int)v); },
(s) => { return (float)s.m_detailedStatsStep; },
(s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ),
- new ParameterDefn("ShouldDebugLog", "Enables detailed DEBUG log statements",
- ConfigurationParameters.numericFalse,
- (s,cf,p,v) => { s.ShouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); },
- (s) => { return s.NumericBool(s.ShouldDebugLog); },
- (s,p,l,v) => { s.ShouldDebugLog = s.BoolNumeric(v); } ),
-
};
// Convert a boolean to our numeric true and false values
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini
index 96f1386..b2fca0c 100644
--- a/bin/OpenSimDefaults.ini
+++ b/bin/OpenSimDefaults.ini
@@ -931,6 +931,9 @@
; level of detail for physical meshes. 32,16,8 or 4 with 32 being full detail
MeshLevelOfDetail = 8
+ ; if mesh size is > threshold meters, we need to add more detail because people will notice
+ MeshLevelOfDetailMegaPrimThreshold = 10
+ MeshLevelOfDetailMegaPrim = 16
; number^2 non-physical level of detail of the sculpt texture. 32x32 - 1024 verticies
SculptLevelOfDetail = 32
--
cgit v1.1
From 5c192b9bab4eb3e921f54a94125215c3683f2eca Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 17 Aug 2012 13:26:18 -0700
Subject: Modify order of code so SOP doesn't set the physics actor flying
property multiple times every time Update is called. This eliminates zillions
of settings which is better for BulletSim. The should be no functionality
change.
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 548dfd3..98afb75 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1385,17 +1385,22 @@ namespace OpenSim.Region.Framework.Scenes
bool DCFlagKeyPressed = false;
Vector3 agent_control_v3 = Vector3.Zero;
- bool oldflying = Flying;
+ bool newFlying = actor.Flying;
if (ForceFly)
- actor.Flying = true;
+ newFlying = true;
else if (FlyDisabled)
- actor.Flying = false;
+ newFlying = false;
else
- actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
-
- if (actor.Flying != oldflying)
- update_movementflag = true;
+ newFlying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
+
+ if (actor.Flying != newFlying)
+ {
+ // Note: ScenePresence.Flying is actually fetched from the physical actor
+ // so setting PhysActor.Flying here also sets the ScenePresence's value.
+ actor.Flying = newFlying;
+ update_movementflag = true;
+ }
if (ParentID == 0)
{
--
cgit v1.1
From 03d76e94034bbaa82d1872284d1fadbaa263411d Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 17 Aug 2012 13:30:46 -0700
Subject: BulletSim: restore most of the Detail logging statements. Will have
no effect on non-logging running. Capture region name that is passed to the
physics engine and use it for detail logging file name prefix. Fix
problem with avatars dropping when flying across region boundries.
---
.../Region/Physics/BulletSPlugin/BSCharacter.cs | 21 +++++-----
OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 8 ++--
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 46 +++++++++++-----------
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 16 ++++++--
4 files changed, 51 insertions(+), 40 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index e2f7af9..1b23a36 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -124,10 +124,14 @@ public class BSCharacter : PhysicsActor
// do actual create at taint time
_scene.TaintedObject("BSCharacter.create", delegate()
{
+ DetailLog("{0},BSCharacter.create", _localID);
BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
+ // Set the buoyancy for flying. This will be refactored when all the settings happen in C#
+ BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
+
m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID));
- // avatars get all collisions no matter what
+ // avatars get all collisions no matter what (makes walking on ground and such work)
BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
});
@@ -137,7 +141,7 @@ public class BSCharacter : PhysicsActor
// called when this character is being destroyed and the resources should be released
public void Destroy()
{
- // DetailLog("{0},BSCharacter.Destroy", LocalID);
+ DetailLog("{0},BSCharacter.Destroy", LocalID);
_scene.TaintedObject("BSCharacter.destroy", delegate()
{
BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
@@ -319,14 +323,13 @@ public class BSCharacter : PhysicsActor
public override bool Flying {
get { return _flying; }
set {
- if (_flying != value)
- {
- _flying = value;
- // simulate flying by changing the effect of gravity
- this.Buoyancy = ComputeBuoyancyFromFlying(_flying);
- }
+ _flying = value;
+ // simulate flying by changing the effect of gravity
+ this.Buoyancy = ComputeBuoyancyFromFlying(_flying);
}
}
+ // Flying is implimented by changing the avatar's buoyancy.
+ // Would this be done better with a vehicle type?
private float ComputeBuoyancyFromFlying(bool ifFlying) {
return ifFlying ? 1f : 0f;
}
@@ -488,11 +491,9 @@ public class BSCharacter : PhysicsActor
// Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.
// base.RequestPhysicsterseUpdate();
- /*
DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
entprop.Acceleration, entprop.RotationalVelocity);
- */
}
// Called by the scene when a collision with this object is reported
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index a075995..9e3f0db 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -265,7 +265,7 @@ public class BSLinkset
BSPrim childx = child;
m_physicsScene.TaintedObject("AddChildToLinkset", delegate()
{
- // DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
+ DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
PhysicallyLinkAChildToRoot(rootx, childx); // build the physical binding between me and the child
});
}
@@ -293,7 +293,7 @@ public class BSLinkset
BSPrim childx = child;
m_physicsScene.TaintedObject("RemoveChildFromLinkset", delegate()
{
- // DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
+ DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
PhysicallyUnlinkAChildFromRoot(rootx, childx);
});
@@ -332,10 +332,10 @@ public class BSLinkset
true,
true
);
- /* NOTE: attempt to build constraint with full frame computation, etc.
+ /* NOTE: below is an attempt to build constraint with full frame computation, etc.
* Using the midpoint is easier since it lets the Bullet code use the transforms
* of the objects.
- * Code left here as an example.
+ * Code left as a warning to future programmers.
// ==================================================================================
// relative position normalized to the root prim
OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 48cd89b..a6bc8e2 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -191,7 +191,7 @@ public sealed class BSPrim : PhysicsActor
{
_mass = CalculateMass(); // changing size changes the mass
BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical);
- // DetailLog("{0}: BSPrim.setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical);
+ DetailLog("{0}: BSPrim.setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical);
RecreateGeomAndObject();
});
}
@@ -275,7 +275,7 @@ public sealed class BSPrim : PhysicsActor
public override void LockAngularMotion(OMV.Vector3 axis)
{
- // DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis);
+ DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis);
return;
}
@@ -294,7 +294,7 @@ public sealed class BSPrim : PhysicsActor
// TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
_scene.TaintedObject("BSPrim.setPosition", delegate()
{
- // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
+ DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
});
}
@@ -331,7 +331,7 @@ public sealed class BSPrim : PhysicsActor
_force = value;
_scene.TaintedObject("BSPrim.setForce", delegate()
{
- // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
+ DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
// BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
BulletSimAPI.SetObjectForce2(Body.Ptr, _force);
});
@@ -409,7 +409,7 @@ public sealed class BSPrim : PhysicsActor
_velocity = value;
_scene.TaintedObject("BSPrim.setVelocity", delegate()
{
- // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
+ DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity);
});
}
@@ -417,7 +417,7 @@ public sealed class BSPrim : PhysicsActor
public override OMV.Vector3 Torque {
get { return _torque; }
set { _torque = value;
- // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
+ DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
}
}
public override float CollisionScore {
@@ -444,7 +444,7 @@ public sealed class BSPrim : PhysicsActor
_scene.TaintedObject("BSPrim.setOrientation", delegate()
{
// _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
- // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
+ DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
});
}
@@ -496,13 +496,15 @@ public sealed class BSPrim : PhysicsActor
_linkset.Refresh(this);
CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr);
- // DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf);
+ DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf);
}
// prims don't fly
public override bool Flying {
get { return _flying; }
- set { _flying = value; }
+ set {
+ _flying = value;
+ }
}
public override bool SetAlwaysRun {
get { return _setAlwaysRun; }
@@ -553,7 +555,7 @@ public sealed class BSPrim : PhysicsActor
// m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
_scene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
{
- // DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
+ DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity);
});
}
@@ -570,7 +572,7 @@ public sealed class BSPrim : PhysicsActor
_buoyancy = value;
_scene.TaintedObject("BSPrim.setBuoyancy", delegate()
{
- // DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
+ DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
});
}
@@ -633,17 +635,17 @@ public sealed class BSPrim : PhysicsActor
}
m_accumulatedForces.Clear();
}
- // DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force);
+ DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force);
BulletSimAPI.AddObjectForce2(Body.Ptr, fSum);
});
}
public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
- // DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce);
+ DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce);
// m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce);
}
public override void SetMomentum(OMV.Vector3 momentum) {
- // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
+ DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
}
public override void SubscribeEvents(int ms) {
_subscribedEventsMs = ms;
@@ -987,7 +989,7 @@ public sealed class BSPrim : PhysicsActor
// m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size);
if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE))
{
- // DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild);
+ DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild);
_shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE;
// Bullet native objects are scaled by the Bullet engine so pass the size in
_scale = _size;
@@ -1001,7 +1003,7 @@ public sealed class BSPrim : PhysicsActor
// m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size);
if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX))
{
- // DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild);
+ DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild);
_shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX;
_scale = _size;
// TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
@@ -1051,12 +1053,12 @@ public sealed class BSPrim : PhysicsActor
// if this new shape is the same as last time, don't recreate the mesh
if (_meshKey == newMeshKey) return;
- // DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey);
+ DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey);
// Since we're recreating new, get rid of any previously generated shape
if (_meshKey != 0)
{
// m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey);
- // DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey);
+ DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey);
BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey);
_mesh = null;
_meshKey = 0;
@@ -1086,7 +1088,7 @@ public sealed class BSPrim : PhysicsActor
_shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH;
// meshes are already scaled by the meshmerizer
_scale = new OMV.Vector3(1f, 1f, 1f);
- // DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID);
+ DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID);
return;
}
@@ -1100,13 +1102,13 @@ public sealed class BSPrim : PhysicsActor
// if the hull hasn't changed, don't rebuild it
if (newHullKey == _hullKey) return;
- // DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey);
+ DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey);
// Since we're recreating new, get rid of any previously generated shape
if (_hullKey != 0)
{
// m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey);
- // DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey);
+ DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey);
BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey);
_hullKey = 0;
}
@@ -1200,7 +1202,7 @@ public sealed class BSPrim : PhysicsActor
_shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL;
// meshes are already scaled by the meshmerizer
_scale = new OMV.Vector3(1f, 1f, 1f);
- // DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID);
+ DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID);
return;
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index d901ff0..56924aa 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -73,6 +73,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[BULLETS SCENE]";
+ // The name of the region we're working for.
+ public string RegionName { get; private set; }
+
public string BulletSimVersion = "?";
private Dictionary m_avatars = new Dictionary();
@@ -196,6 +199,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public BSScene(string identifier)
{
m_initialized = false;
+ // we are passed the name of the region we're working for.
+ RegionName = identifier;
}
public override void Initialise(IMesher meshmerizer, IConfigSource config)
@@ -281,10 +286,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// Very detailed logging for physics debugging
m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false);
m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", ".");
- m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-");
+ m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
// Very detailed logging for vehicle debugging
m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
+
+ // Do any replacements in the parameters
+ m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
}
}
}
@@ -362,7 +370,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
BSPrim bsprim = prim as BSPrim;
if (bsprim != null)
{
- // DetailLog("{0},RemovePrim,call", bsprim.LocalID);
+ DetailLog("{0},RemovePrim,call", bsprim.LocalID);
// m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID);
try
{
@@ -388,7 +396,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
if (!m_initialized) return null;
- // DetailLog("{0},AddPrimShape,call", localID);
+ DetailLog("{0},AddPrimShape,call", localID);
BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical);
lock (m_prims) m_prims.Add(localID, prim);
@@ -534,7 +542,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
else if (m_avatars.ContainsKey(collidingWith))
type = ActorTypes.Agent;
- DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
+ // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
BSPrim prim;
if (m_prims.TryGetValue(localID, out prim)) {
--
cgit v1.1
From 0860a0d856ee667bf20db074b778f2518c4d061c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 17 Aug 2012 22:30:01 +0100
Subject: minor: Make xengine debug message on script load a scripting loading
message instead.
This is more useful if compilation fails due to an uncatchable exception since we know what was being compiled.
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 2dba029..1571fb4 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -982,10 +982,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return false;
}
- UUID assetID = item.AssetID;
+ m_log.DebugFormat(
+ "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
+ part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
+ part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
- //m_log.DebugFormat("[XEngine] Compiling script {0} ({1} on object {2})",
- // item.Name, itemID.ToString(), part.ParentGroup.RootPart.Name);
+ UUID assetID = item.AssetID;
ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
@@ -1164,10 +1166,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
stateSource, m_MaxScriptQueue);
// if (DebugLevel >= 1)
- m_log.DebugFormat(
- "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
- part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
- part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
+// m_log.DebugFormat(
+// "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
+// part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
+// part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
if (presence != null)
{
--
cgit v1.1
From 7243d4f84248092eb5fe4ebe3673501bc84ce250 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 17 Aug 2012 14:45:18 -0700
Subject: BulletSim: Properly regenerate hulls when objects made physical.
This fixes the problem of non-base shapes (cubes and spheres) falling
through the terrain.
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 +++++------
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 34 +++++++++++++++++-------
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 98afb75..65d526f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1392,14 +1392,14 @@ namespace OpenSim.Region.Framework.Scenes
else if (FlyDisabled)
newFlying = false;
else
- newFlying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
-
- if (actor.Flying != newFlying)
- {
- // Note: ScenePresence.Flying is actually fetched from the physical actor
- // so setting PhysActor.Flying here also sets the ScenePresence's value.
- actor.Flying = newFlying;
- update_movementflag = true;
+ newFlying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
+
+ if (actor.Flying != newFlying)
+ {
+ // Note: ScenePresence.Flying is actually fetched from the physical actor
+ // so setting PhysActor.Flying here also sets the ScenePresence's value.
+ actor.Flying = newFlying;
+ update_movementflag = true;
}
if (ParentID == 0)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index a6bc8e2..d3f1e9c 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -481,11 +481,8 @@ public sealed class BSPrim : PhysicsActor
// No locking here because only called when it is safe
private void SetObjectDynamic()
{
- // RA: remove this for the moment.
- // The problem is that dynamic objects are hulls so if we are becoming physical
- // the shape has to be checked and possibly built.
- // Maybe a VerifyCorrectPhysicalShape() routine?
- // RecreateGeomAndObject();
+ // If it's becoming dynamic, it will need hullness
+ VerifyCorrectPhysicalShape();
// Bullet wants static objects to have a mass of zero
float mass = IsStatic ? 0f : _mass;
@@ -1214,6 +1211,27 @@ public sealed class BSPrim : PhysicsActor
return;
}
+ private void VerifyCorrectPhysicalShape()
+ {
+ if (IsStatic)
+ {
+ // if static, we don't need a hull so, if there is one, rebuild without it
+ if (_hullKey != 0)
+ {
+ RecreateGeomAndObject();
+ }
+ }
+ else
+ {
+ // if not static, it will need a hull to efficiently collide with things
+ if (_hullKey == 0)
+ {
+ RecreateGeomAndObject();
+ }
+
+ }
+ }
+
// Create an object in Bullet if it has not already been created
// No locking here because this is done when the physics engine is not simulating
// Returns 'true' if an object was actually created.
@@ -1338,10 +1356,8 @@ public sealed class BSPrim : PhysicsActor
_acceleration = entprop.Acceleration;
_rotationalVelocity = entprop.RotationalVelocity;
- // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}",
- // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
- // DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
- // LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
+ DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
+ LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
base.RequestPhysicsterseUpdate();
}
--
cgit v1.1
From 56da78824352edfd8a6622f1667abf9a6c75261e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 17 Aug 2012 22:50:11 +0100
Subject: Add information to ThreadStackSize about possibly increasing if
suffering StackOverflowExceptions during script conversion/compilation (e.g.
on Windows 64-bit)
---
bin/OpenSim.ini.example | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index bced817..eac30b8 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -683,7 +683,9 @@
;; Maximum number of events to queue for a script (excluding timers)
; MaxScriptEventQueue = 300
- ;; Stack size per thread created
+ ;; Stack size per script engine thread in bytes.
+ ;; If you are experiencing StackOverflowExceptions you may want to increase this (e.g. double it).
+ ;; The trade-off may be increased memory usage by the script engine.
; ThreadStackSize = 262144
;# {DeleteScriptsOnStartup} {} {Delete previously compiled script DLLs on startup?} (true false) true
--
cgit v1.1
From 74f5253a366cefa5222a813f4ed349db93c08acc Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Thu, 16 Aug 2012 15:32:20 +0100
Subject: attempt to handle InvalidCastException in a manner similar to Second
Life
---
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++++
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 15 +++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b7b5e8e..255fc8e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7674,6 +7674,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
}
+ catch (InvalidCastException e)
+ {
+ ShoutError(e.Message);
+ }
finally
{
if (positionChanged)
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index d848b2a..562433d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -560,12 +560,23 @@ namespace OpenSim.Region.ScriptEngine.Shared
else if (m_data[itemIndex] is LSL_Types.LSLString)
return new LSLInteger(m_data[itemIndex].ToString());
else
- throw new InvalidCastException();
+ throw new InvalidCastException(string.Format(
+ "{0} expected but {1} given",
+ typeof(LSL_Types.LSLInteger).Name,
+ m_data[itemIndex] != null ?
+ m_data[itemIndex].GetType().Name : "null"));
}
public LSL_Types.Vector3 GetVector3Item(int itemIndex)
{
- return (LSL_Types.Vector3)m_data[itemIndex];
+ if(m_data[itemIndex] is LSL_Types.Vector3)
+ return (LSL_Types.Vector3)m_data[itemIndex];
+ else
+ throw new InvalidCastException(string.Format(
+ "{0} expected but {1} given",
+ typeof(LSL_Types.Vector3).Name,
+ m_data[itemIndex] != null ?
+ m_data[itemIndex].GetType().Name : "null"));
}
public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
--
cgit v1.1
From 466d684fbe26b4ea24a0003120d7a875fbbca037 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Wed, 1 Aug 2012 15:18:02 +0100
Subject: implemented
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 50 ++++++++++++++++++++++
.../Shared/Api/Implementation/LSL_Api.cs | 13 ++++++
.../Shared/Api/Runtime/LSL_Constants.cs | 1 +
3 files changed, 64 insertions(+)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index bd6369c..e84ab05 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4236,6 +4236,56 @@ namespace OpenSim.Region.Framework.Scenes
ScheduleFullUpdate();
}
+ public void UpdateSlice(float begin, float end)
+ {
+ if (end < begin)
+ {
+ float temp = begin;
+ begin = end;
+ end = temp;
+ }
+ end = Math.Min(1f, Math.Max(0f, end));
+ begin = Math.Min(Math.Min(1f, Math.Max(0f, begin)), end - 0.02f);
+ if (begin < 0.02f && end < 0.02f)
+ {
+ begin = 0f;
+ end = 0.02f;
+ }
+
+ ushort uBegin = (ushort)(50000.0 * begin);
+ ushort uEnd = (ushort)(50000.0 * (1f - end));
+ bool updatePossiblyNeeded = false;
+ if (GetPrimType() == PrimType.SPHERE)
+ {
+ if (m_shape.ProfileBegin != uBegin || m_shape.ProfileEnd != uEnd)
+ {
+ m_shape.ProfileBegin = uBegin;
+ m_shape.ProfileEnd = uEnd;
+ updatePossiblyNeeded = true;
+ }
+ }
+ else if (m_shape.PathBegin != uBegin || m_shape.PathEnd != uEnd)
+ {
+ m_shape.PathBegin = uBegin;
+ m_shape.PathEnd = uEnd;
+ updatePossiblyNeeded = true;
+ }
+
+ if (updatePossiblyNeeded && ParentGroup != null)
+ {
+ ParentGroup.HasGroupChanged = true;
+ }
+ if (updatePossiblyNeeded && PhysActor != null)
+ {
+ PhysActor.Shape = m_shape;
+ ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
+ }
+ if (updatePossiblyNeeded)
+ {
+ ScheduleFullUpdate();
+ }
+ }
+
///
/// If the part is a sculpt/mesh, retrieve the mesh data and reinsert it into the shape so that the physics
/// engine can use it.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 255fc8e..75491da 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7666,6 +7666,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Float gain = rules.GetLSLFloatItem(idx++);
TargetOmega(part, axis, (double)spinrate, (double)gain);
break;
+ case (int)ScriptBaseClass.PRIM_SLICE:
+ if (remain < 1)
+ return;
+ LSL_Vector slice = rules.GetVector3Item(idx++);
+ part.UpdateSlice((float)slice.x, (float)slice.y);
+ break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return null;
@@ -8340,6 +8346,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_POS_LOCAL:
res.Add(new LSL_Vector(GetPartLocalPos(part)));
break;
+ case (int)ScriptBaseClass.PRIM_SLICE:
+ res.Add(new LSL_Vector(
+ (part.GetPrimType() == PrimType.SPHERE ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0,
+ 1 - (part.GetPrimType() == PrimType.SPHERE ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0,
+ 0
+ ));
+ break;
}
}
return res;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index e1c054d..cad8518 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -328,6 +328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int PRIM_OMEGA = 32;
public const int PRIM_POS_LOCAL = 33;
public const int PRIM_LINK_TARGET = 34;
+ public const int PRIM_SLICE = 35;
public const int PRIM_TEXGEN_DEFAULT = 0;
public const int PRIM_TEXGEN_PLANAR = 1;
--
cgit v1.1
From 7068fddd2fffe356869171ed67be473f7a701470 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Thu, 2 Aug 2012 09:28:32 +0100
Subject: fixing bug that get/set the wrong property for prim types other than
sphere & box
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++-
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index e84ab05..53b4f7e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4255,7 +4255,8 @@ namespace OpenSim.Region.Framework.Scenes
ushort uBegin = (ushort)(50000.0 * begin);
ushort uEnd = (ushort)(50000.0 * (1f - end));
bool updatePossiblyNeeded = false;
- if (GetPrimType() == PrimType.SPHERE)
+ PrimType primType = GetPrimType();
+ if (primType == PrimType.SPHERE || primType == PrimType.TORUS || primType == PrimType.TUBE || primType == PrimType.RING)
{
if (m_shape.ProfileBegin != uBegin || m_shape.ProfileEnd != uEnd)
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 75491da..31d1660 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -8347,9 +8347,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
res.Add(new LSL_Vector(GetPartLocalPos(part)));
break;
case (int)ScriptBaseClass.PRIM_SLICE:
+ PrimType prim_type = part.GetPrimType();
+ bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING);
res.Add(new LSL_Vector(
- (part.GetPrimType() == PrimType.SPHERE ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0,
- 1 - (part.GetPrimType() == PrimType.SPHERE ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0,
+ (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0,
+ 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0,
0
));
break;
--
cgit v1.1
From 28d0aff2e395ae3ef85586cf65bd90395eb5c895 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Thu, 16 Aug 2012 09:35:27 +0100
Subject: adding null return to fix building
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 31d1660..6a2b829 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7668,7 +7668,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case (int)ScriptBaseClass.PRIM_SLICE:
if (remain < 1)
- return;
+ return null;
LSL_Vector slice = rules.GetVector3Item(idx++);
part.UpdateSlice((float)slice.x, (float)slice.y);
break;
--
cgit v1.1
From e4e5237086bd34a6649b687d3499a6795317f043 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 18 Aug 2012 00:46:34 +0100
Subject: When reporting a thread timeout, create a copy of the info rather
than passing the original ThreadWatchdogInfo structure.
This is to avoid the possibility of misleading reporting if a watchdog update outraces an alarm.
Should address any remaining issues from http://opensimulator.org/mantis/view.php?id=6012
---
OpenSim/Framework/Monitoring/Watchdog.cs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index 02f11fa..7964f28 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -89,6 +89,17 @@ namespace OpenSim.Framework.Monitoring
FirstTick = Environment.TickCount & Int32.MaxValue;
LastTick = FirstTick;
}
+
+ public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi)
+ {
+ Thread = previousTwi.Thread;
+ FirstTick = previousTwi.FirstTick;
+ LastTick = previousTwi.LastTick;
+ Timeout = previousTwi.Timeout;
+ IsTimedOut = previousTwi.IsTimedOut;
+ AlarmIfTimeout = previousTwi.AlarmIfTimeout;
+ AlarmMethod = previousTwi.AlarmMethod;
+ }
}
///
@@ -335,7 +346,9 @@ namespace OpenSim.Framework.Monitoring
if (callbackInfos == null)
callbackInfos = new List();
- callbackInfos.Add(threadInfo);
+ // Send a copy of the watchdog info to prevent race conditions where the watchdog
+ // thread updates the monitoring info after an alarm has been sent out.
+ callbackInfos.Add(new ThreadWatchdogInfo(threadInfo));
}
}
}
--
cgit v1.1
From 5d7751da891360c665622562f06a15e02fea4922 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 18 Aug 2012 01:17:01 +0100
Subject: refactoring for Vector3 operator & constructor tweaks
---
.../Shared/Api/Implementation/LSL_Api.cs | 107 +++++++++------------
.../Shared/Api/Implementation/LS_Api.cs | 8 +-
.../Shared/Api/Implementation/MOD_Api.cs | 7 +-
.../Shared/Api/Implementation/OSSL_Api.cs | 22 ++---
.../Api/Implementation/Plugins/SensorRepeat.cs | 9 +-
OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 28 ++----
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 39 ++++++++
.../Region/ScriptEngine/XEngine/EventManager.cs | 20 ++--
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 +-
9 files changed, 119 insertions(+), 125 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fceae02..bca9a75 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1097,9 +1097,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Float llGround(LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x,
- (float)offset.y,
- (float)offset.z);
+ Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
//Get the slope normal. This gives us the equation of the plane tangent to the slope.
LSL_Vector vsn = llGroundNormal(offset);
@@ -1387,7 +1385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face == ScriptBaseClass.ALL_SIDES)
face = SceneObjectPart.ALL_SIDES;
- m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
+ m_host.SetFaceColor(color, face);
}
public void SetTexGen(SceneObjectPart part, int face,int style)
@@ -1974,7 +1972,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool sameParcel = here.GlobalID == there.GlobalID;
- if (!sameParcel && !World.Permissions.CanRezObject(m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)))
+ if (!sameParcel && !World.Permissions.CanRezObject(
+ m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, pos))
{
return 0;
}
@@ -2034,13 +2033,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0)
targetPos.z = ground;
SceneObjectGroup parent = part.ParentGroup;
- LSL_Vector real_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos);
- parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
+ parent.UpdateGroupPosition(!adjust ? targetPos :
+ SetPosAdjust(currentPos, targetPos));
}
else
{
- LSL_Vector rel_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos);
- part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z);
+ part.OffsetPosition = !adjust ? targetPos : SetPosAdjust(
+ currentPos, targetPos);
SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate();
@@ -2084,7 +2083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos);
- return new LSL_Vector(pos.X, pos.Y, pos.Z);
+ return new LSL_Vector(pos);
}
public void llSetRot(LSL_Rotation rot)
@@ -2198,7 +2197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (local != 0)
force *= llGetRot();
- m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z));
+ m_host.ParentGroup.RootPart.SetForce(force);
}
}
@@ -2210,10 +2209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_host.ParentGroup.IsDeleted)
{
- Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce();
- force.x = tmpForce.X;
- force.y = tmpForce.Y;
- force.z = tmpForce.Z;
+ force = m_host.ParentGroup.RootPart.GetForce();
}
return force;
@@ -2222,8 +2218,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llTarget(LSL_Vector position, double range)
{
m_host.AddScriptLPS(1);
- return m_host.ParentGroup.registerTargetWaypoint(
- new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range);
+ return m_host.ParentGroup.registerTargetWaypoint(position,
+ (float)range);
}
public void llTargetRemove(int number)
@@ -2248,7 +2244,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llMoveToTarget(LSL_Vector target, double tau)
{
m_host.AddScriptLPS(1);
- m_host.MoveToTarget(new Vector3((float)target.x, (float)target.y, (float)target.z), (float)tau);
+ m_host.MoveToTarget(target, (float)tau);
}
public void llStopMoveToTarget()
@@ -2261,7 +2257,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
//No energy force yet
- Vector3 v = new Vector3((float)force.x, (float)force.y, (float)force.z);
+ Vector3 v = force;
if (v.Length() > 20000.0f)
{
v.Normalize();
@@ -2273,13 +2269,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llApplyRotationalImpulse(LSL_Vector force, int local)
{
m_host.AddScriptLPS(1);
- m_host.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0);
+ m_host.ApplyAngularImpulse(force, local != 0);
}
public void llSetTorque(LSL_Vector torque, int local)
{
m_host.AddScriptLPS(1);
- m_host.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0);
+ m_host.SetAngularImpulse(torque, local != 0);
}
public LSL_Vector llGetTorque()
@@ -2830,13 +2826,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
}
- Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
- Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
-
// need the magnitude later
// float velmag = (float)Util.GetMagnitude(llvel);
- SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param);
+ SceneObjectGroup new_group = World.RezObject(m_host, item, pos, Rot2Quaternion(rot), vel, param);
// If either of these are null, then there was an unknown error.
if (new_group == null)
@@ -2857,10 +2850,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
PhysicsActor pa = new_group.RootPart.PhysActor;
- if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
+ if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
{
//Recoil.
- llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
+ llApplyImpulse(vel * groupmass, 0);
}
// Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
});
@@ -3381,7 +3374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain)
{
- part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)));
+ part.UpdateAngularVelocity(axis * spinrate);
}
public LSL_Integer llGetStartParameter()
@@ -3588,7 +3581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
- part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
+ part.SetFaceColor(color, face);
}
public void llCreateLink(string target, int parent)
@@ -4019,8 +4012,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetText(string text, LSL_Vector color, double alpha)
{
m_host.AddScriptLPS(1);
- Vector3 av3 = Util.Clip(new Vector3((float)color.x, (float)color.y,
- (float)color.z), 0.0f, 1.0f);
+ Vector3 av3 = Util.Clip(color, 0.0f, 1.0f);
m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
//m_host.ParentGroup.HasGroupChanged = true;
//m_host.ParentGroup.ScheduleGroupForFullUpdate();
@@ -4217,14 +4209,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(5000);
}
- public void llTeleportAgent(string agent, string destination, LSL_Vector pos, LSL_Vector lookAt)
+ public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt)
{
m_host.AddScriptLPS(1);
UUID agentId = new UUID();
- Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
- Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
-
if (UUID.TryParse(agent, out agentId))
{
ScenePresence presence = World.GetScenePresence(agentId);
@@ -4253,15 +4242,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector pos, LSL_Vector lookAt)
+ public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector targetPos, LSL_Vector targetLookAt)
{
m_host.AddScriptLPS(1);
UUID agentId = new UUID();
ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y);
- Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
- Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
if (UUID.TryParse(agent, out agentId))
{
ScenePresence presence = World.GetScenePresence(agentId);
@@ -4545,7 +4532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
distance_attenuation = 1f / normalized_units;
}
- Vector3 applied_linear_impulse = new Vector3((float)impulse.x, (float)impulse.y, (float)impulse.z);
+ Vector3 applied_linear_impulse = impulse;
{
float impulse_length = applied_linear_impulse.Length();
@@ -6044,9 +6031,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Plug the x,y coordinates of the slope normal into the equation of the plane to get
//the height of that point on the plane. The resulting vector gives the slope.
- Vector3 vsl = new Vector3();
- vsl.X = (float)vsn.x;
- vsl.Y = (float)vsn.y;
+ Vector3 vsl = vsn;
vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z));
vsl.Normalize();
//Normalization might be overkill here
@@ -6057,9 +6042,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGroundNormal(LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x,
- (float)offset.y,
- (float)offset.z);
+ Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
// Clamp to valid position
if (pos.X < 0)
pos.X = 0;
@@ -6512,8 +6495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_host.ParentGroup.IsDeleted)
{
- m_host.ParentGroup.RootPart.SetVehicleVectorParam(param,
- new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
+ m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec);
}
}
@@ -6555,7 +6537,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
rot.z = 1; // ZERO_ROTATION = 0,0,0,1
- part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z);
+ part.SitTargetPosition = offset;
part.SitTargetOrientation = Rot2Quaternion(rot);
part.ParentGroup.HasGroupChanged = true;
}
@@ -6659,13 +6641,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetCameraEyeOffset(LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- m_host.SetCameraEyeOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z));
+ m_host.SetCameraEyeOffset(offset);
}
public void llSetCameraAtOffset(LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- m_host.SetCameraAtOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z));
+ m_host.SetCameraAtOffset(offset);
}
public LSL_String llDumpList2String(LSL_List src, string seperator)
@@ -6687,7 +6669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llScriptDanger(LSL_Vector pos)
{
m_host.AddScriptLPS(1);
- bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z));
+ bool result = World.ScriptDanger(m_host.LocalId, pos);
if (result)
{
return 1;
@@ -7515,7 +7497,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(idx++);
double alpha=(double)rules.GetLSLFloatItem(idx++);
- part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
+ part.SetFaceColor(color, face);
SetAlpha(part, alpha, face);
break;
@@ -7634,9 +7616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primText = rules.GetLSLStringItem(idx++);
LSL_Vector primTextColor = rules.GetVector3Item(idx++);
LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
- Vector3 av3 = Util.Clip(new Vector3((float)primTextColor.x,
- (float)primTextColor.y,
- (float)primTextColor.z), 0.0f, 1.0f);
+ Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f);
part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f));
break;
@@ -7691,11 +7671,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part.ParentGroup.RootPart == part)
{
SceneObjectGroup parent = part.ParentGroup;
- parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z));
+ parent.UpdateGroupPosition(currentPosition);
}
else
{
- part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z);
+ part.OffsetPosition = currentPosition;
SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate();
@@ -7932,8 +7912,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part != null)
{
Vector3 halfSize = part.Scale / 2.0f;
- LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f);
- LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z);
+ LSL_Vector lower = (new LSL_Vector(halfSize)) * -1.0f;
+ LSL_Vector upper = new LSL_Vector(halfSize);
result.Add(lower);
result.Add(upper);
return result;
@@ -9943,9 +9923,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
if (avatar != null)
{
- avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname,
- new Vector3((float)pos.x, (float)pos.y, (float)pos.z),
- new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
+ avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name,
+ simname, pos, lookAt);
}
ScriptSleep(1000);
}
@@ -11143,8 +11122,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
- Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z);
- Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z);
+ Vector3 rayStart = start;
+ Vector3 rayEnd = end;
Vector3 dir = rayEnd - rayStart;
float dist = Vector3.Mag(dir);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 795de80..ceb4660 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
- wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.cloudDetailXYDensity = iV;
break;
case (int)ScriptBaseClass.WL_CLOUD_SCALE:
idx++;
@@ -329,7 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
- wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.cloudXYDensity = iV;
break;
case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
idx++;
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
idx++;
iV = rules.GetVector3Item(idx);
- wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.reflectionWaveletScale = iV;
break;
case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
idx++;
@@ -422,7 +422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_WATER_COLOR:
idx++;
iV = rules.GetVector3Item(idx);
- wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.waterColor = iV;
break;
case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
idx++;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7844c75..929948b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -343,8 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (type == typeof(OpenMetaverse.Vector3))
{
- LSL_Vector vect = (LSL_Vector)lslparm;
- return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z);
+ return (OpenMetaverse.Vector3)((LSL_Vector)lslparm);
}
}
@@ -372,8 +371,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else if (plist[i] is LSL_Vector)
{
- LSL_Vector vect = (LSL_Vector)plist[i];
- result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z);
+ result[i] = (OpenMetaverse.Vector3)(
+ (LSL_Vector)plist[i]);
}
else
MODError("unknown LSL list element type");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 859ee93..eff1598 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -773,10 +773,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// We will launch the teleport on a new thread so that when the script threads are terminated
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
- Util.FireAndForget(
- o => World.RequestTeleportLocation(presence.ControllingClient, regionName,
- new Vector3((float)position.x, (float)position.y, (float)position.z),
- new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
+ Util.FireAndForget(o => World.RequestTeleportLocation(
+ presence.ControllingClient, regionName, position,
+ lookat, (uint)TPFlags.ViaLocation));
ScriptSleep(5000);
@@ -819,10 +818,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// We will launch the teleport on a new thread so that when the script threads are terminated
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
- Util.FireAndForget(
- o => World.RequestTeleportLocation(presence.ControllingClient, regionHandle,
- new Vector3((float)position.x, (float)position.y, (float)position.z),
- new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
+ Util.FireAndForget(o => World.RequestTeleportLocation(
+ presence.ControllingClient, regionHandle,
+ position, lookat, (uint)TPFlags.ViaLocation));
ScriptSleep(5000);
@@ -2329,7 +2327,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ownerID = m_host.OwnerID;
UUID x = module.CreateNPC(firstname,
lastname,
- new Vector3((float) position.x, (float) position.y, (float) position.z),
+ position,
ownerID,
senseAsAgent,
World,
@@ -2446,7 +2444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Vector(0, 0, 0);
}
- public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
+ public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
m_host.AddScriptLPS(1);
@@ -2461,7 +2459,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
- Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.MoveToTarget(npcId, World, pos, false, true, false);
}
}
@@ -2481,11 +2478,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
- Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
module.MoveToTarget(
new UUID(npc.m_string),
World,
- pos,
+ target,
(options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
(options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
(options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index a626be8..7162226 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -428,9 +428,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
try
{
Vector3 diff = toRegionPos - fromRegionPos;
- LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
- double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
- double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
+ double dot = LSL_Types.Vector3.Dot(forward_dir, diff);
+ double mag_obj = LSL_Types.Vector3.Mag(diff);
ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
}
catch
@@ -560,8 +559,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
double ang_obj = 0;
try
{
- Vector3 diff = toRegionPos - fromRegionPos;
- LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
+ LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(
+ toRegionPos - fromRegionPos);
double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
index 0108f44..5a58f73 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -160,11 +160,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
else
{
// Set the values from the touch data provided by the client
- touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z);
- touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z);
- touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z);
- touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z);
- touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z);
+ touchST = new LSL_Types.Vector3(value.STCoord);
+ touchUV = new LSL_Types.Vector3(value.UVCoord);
+ touchNormal = new LSL_Types.Vector3(value.Normal);
+ touchBinormal = new LSL_Types.Vector3(value.Binormal);
+ touchPos = new LSL_Types.Vector3(value.Position);
touchFace = value.FaceIndex;
}
}
@@ -181,19 +181,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
Name = presence.Firstname + " " + presence.Lastname;
Owner = Key;
- Position = new LSL_Types.Vector3(
- presence.AbsolutePosition.X,
- presence.AbsolutePosition.Y,
- presence.AbsolutePosition.Z);
+ Position = new LSL_Types.Vector3(presence.AbsolutePosition);
Rotation = new LSL_Types.Quaternion(
presence.Rotation.X,
presence.Rotation.Y,
presence.Rotation.Z,
presence.Rotation.W);
- Velocity = new LSL_Types.Vector3(
- presence.Velocity.X,
- presence.Velocity.Y,
- presence.Velocity.Z);
+ Velocity = new LSL_Types.Vector3(presence.Velocity);
if (presence.PresenceType != PresenceType.Npc)
{
@@ -241,16 +235,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
- Position = new LSL_Types.Vector3(part.AbsolutePosition.X,
- part.AbsolutePosition.Y,
- part.AbsolutePosition.Z);
+ Position = new LSL_Types.Vector3(part.AbsolutePosition);
Quaternion wr = part.ParentGroup.GroupRotation;
Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
- Velocity = new LSL_Types.Vector3(part.Velocity.X,
- part.Velocity.Y,
- part.Velocity.Z);
+ Velocity = new LSL_Types.Vector3(part.Velocity);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 562433d..d18efe0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -31,6 +31,11 @@ using System.Globalization;
using System.Text.RegularExpressions;
using OpenSim.Framework;
+using OpenMetaverse;
+using OMV_Vector3 = OpenMetaverse.Vector3;
+using OMV_Vector3d = OpenMetaverse.Vector3d;
+using OMV_Quaternion = OpenMetaverse.Quaternion;
+
namespace OpenSim.Region.ScriptEngine.Shared
{
[Serializable]
@@ -54,6 +59,20 @@ namespace OpenSim.Region.ScriptEngine.Shared
z = (float)vector.z;
}
+ public Vector3(OMV_Vector3 vector)
+ {
+ x = vector.X;
+ y = vector.Y;
+ z = vector.Z;
+ }
+
+ public Vector3(OMV_Vector3d vector)
+ {
+ x = vector.X;
+ y = vector.Y;
+ z = vector.Z;
+ }
+
public Vector3(double X, double Y, double Z)
{
x = X;
@@ -109,6 +128,26 @@ namespace OpenSim.Region.ScriptEngine.Shared
return new list(new object[] { vec });
}
+ public static implicit operator OMV_Vector3(Vector3 vec)
+ {
+ return new OMV_Vector3((float)vec.x, (float)vec.y, (float)vec.z);
+ }
+
+ public static implicit operator Vector3(OMV_Vector3 vec)
+ {
+ return new Vector3(vec);
+ }
+
+ public static implicit operator OMV_Vector3d(Vector3 vec)
+ {
+ return new OMV_Vector3d(vec.x, vec.y, vec.z);
+ }
+
+ public static implicit operator Vector3(OMV_Vector3d vec)
+ {
+ return new Vector3(vec);
+ }
+
public static bool operator ==(Vector3 lhs, Vector3 rhs)
{
return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 5c4174e..a1ad07d 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -152,9 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
det[0] = new DetectParams();
det[0].Key = remoteClient.AgentId;
det[0].Populate(myScriptEngine.World);
- det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
- offsetPos.Y,
- offsetPos.Z);
+ det[0].OffsetPos = offsetPos;
if (originalID == 0)
{
@@ -298,9 +296,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
- d.Position = new LSL_Types.Vector3(detobj.posVector.X,
- detobj.posVector.Y,
- detobj.posVector.Z);
+ d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -318,9 +314,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
- d.Position = new LSL_Types.Vector3(detobj.posVector.X,
- detobj.posVector.Y,
- detobj.posVector.Z);
+ d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -337,9 +331,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
- d.Position = new LSL_Types.Vector3(detobj.posVector.X,
- detobj.posVector.Y,
- detobj.posVector.Z);
+ d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -381,8 +373,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
myScriptEngine.PostObjectEvent(localID, new EventParams(
"at_target", new object[] {
new LSL_Types.LSLInteger(handle),
- new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
- new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
+ new LSL_Types.Vector3(targetpos),
+ new LSL_Types.Vector3(atpos) },
new DetectParams[0]));
}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 1571fb4..a05650a 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1467,7 +1467,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is string)
lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
else if (p[i] is Vector3)
- lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
+ lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
else if (p[i] is Quaternion)
lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
else if (p[i] is float)
@@ -1493,7 +1493,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is string)
lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
else if (p[i] is Vector3)
- lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
+ lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
else if (p[i] is Quaternion)
lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
else if (p[i] is float)
--
cgit v1.1
From 2a70afeca2a1ba452660ee2669aa4033a91143bb Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 18 Aug 2012 14:00:10 +0100
Subject: Fix the whitespace formatting error introduced by the last patch
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index bca9a75..7671e54 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2038,8 +2038,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
- part.OffsetPosition = !adjust ? targetPos : SetPosAdjust(
- currentPos, targetPos);
+ part.OffsetPosition = !adjust ? targetPos :
+ SetPosAdjust(currentPos, targetPos);
SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate();
--
cgit v1.1
From 2b0c8bc48008b8ce38c99d5c3135633b0d4f8e87 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 18 Aug 2012 14:49:10 +0100
Subject: Implementing operators & constructors for Quaternion
---
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index d18efe0..bdc7d70 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -361,6 +361,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
s = 1;
}
+ public Quaternion(OMV_Quaternion rot)
+ {
+ x = rot.X;
+ y = rot.Y;
+ z = rot.Z;
+ s = rot.W;
+ }
+
#endregion
#region Overriders
@@ -407,6 +415,16 @@ namespace OpenSim.Region.ScriptEngine.Shared
return new list(new object[] { r });
}
+ public static implicit operator OMV_Quaternion(Quaternion rot)
+ {
+ return new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
+ }
+
+ public static implicit operator Quaternion(OMV_Quaternion rot)
+ {
+ return new Quaternion(rot);
+ }
+
public static bool operator ==(Quaternion lhs, Quaternion rhs)
{
// Return true if the fields match:
--
cgit v1.1
From 52d7af05bcc5141eef42115e0ac5bca53163717f Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 18 Aug 2012 14:54:13 +0100
Subject: adding missing refactor for LSL_Vector
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7671e54..4d542d50 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10536,7 +10536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
break;
case ScriptBaseClass.OBJECT_VELOCITY:
- ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z));
+ ret.Add(new LSL_Vector(obj.Velocity));
break;
case ScriptBaseClass.OBJECT_OWNER:
ret.Add(new LSL_String(obj.OwnerID.ToString()));
--
cgit v1.1
From fb84ff96a9ac7df564fb8f8242e0ff0d2638b438 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 18 Aug 2012 15:04:07 +0100
Subject: implicit operators mean one does not need to instantiate new objects
manually
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 ++---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 7 +++----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4d542d50..87298e3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2231,8 +2231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
{
m_host.AddScriptLPS(1);
- return m_host.ParentGroup.registerRotTargetWaypoint(
- new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error);
+ return m_host.ParentGroup.registerRotTargetWaypoint(rot, (float)error);
}
public void llRotTargetRemove(int number)
@@ -10531,7 +10530,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
else
rot = obj.GetWorldRotation();
- LSL_Rotation objrot = new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
+ LSL_Rotation objrot = new LSL_Rotation(rot);
ret.Add(objrot);
}
break;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 929948b..84cf6ca 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -333,8 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (type == typeof(OpenMetaverse.Quaternion))
{
- LSL_Rotation rot = (LSL_Rotation)lslparm;
- return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s);
+ return (OpenMetaverse.Quaternion)((LSL_Rotation)lslparm);
}
}
@@ -366,8 +365,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
result[i] = new UUID((LSL_Key)plist[i]);
else if (plist[i] is LSL_Rotation)
{
- LSL_Rotation rot = (LSL_Rotation)plist[i];
- result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s);
+ result[i] = (OpenMetaverse.Quaternion)(
+ (LSL_Rotation)plist[i]);
}
else if (plist[i] is LSL_Vector)
{
--
cgit v1.1
From ffdde05bb7d3d2ca71807c3197411bf66c29aa45 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 18 Aug 2012 15:10:44 +0100
Subject: constructor means not having to manually refer to individual
properties
---
.../ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | 4 ++--
OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | 4 ++--
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 7162226..24cceea 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -351,7 +351,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
q = avatar.Rotation * q;
}
- LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
+ LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
@@ -478,7 +478,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
q = avatar.Rotation * q;
}
- LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
+ LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index a1ad07d..cee10df 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -391,8 +391,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
myScriptEngine.PostObjectEvent(localID, new EventParams(
"at_rot_target", new object[] {
new LSL_Types.LSLInteger(handle),
- new LSL_Types.Quaternion(targetrot.X,targetrot.Y,targetrot.Z,targetrot.W),
- new LSL_Types.Quaternion(atrot.X,atrot.Y,atrot.Z,atrot.W) },
+ new LSL_Types.Quaternion(targetrot),
+ new LSL_Types.Quaternion(atrot) },
new DetectParams[0]));
}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index a05650a..53f899a 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1469,7 +1469,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is Vector3)
lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
else if (p[i] is Quaternion)
- lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
+ lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]);
else if (p[i] is float)
lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
else
@@ -1495,7 +1495,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is Vector3)
lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
else if (p[i] is Quaternion)
- lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
+ lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]);
else if (p[i] is float)
lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
else
--
cgit v1.1
From ca33619e11d6b370793ffd70dd8a0baefa88f5d1 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 18 Aug 2012 15:18:31 +0100
Subject: Rot2Quaternion is now redundant
---
.../Shared/Api/Implementation/LSL_Api.cs | 21 ++++++++++-----------
.../Shared/Api/Implementation/OSSL_Api.cs | 2 +-
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 87298e3..7009548 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2094,7 +2094,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (m_host.ParentID == 0)
{
// special case: If we are root, rotate complete SOG to new rotation
- SetRot(m_host, Rot2Quaternion(rot));
+ SetRot(m_host, rot);
}
else
{
@@ -2102,7 +2102,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SceneObjectPart rootPart = m_host.ParentGroup.RootPart;
if (rootPart != null) // better safe than sorry
{
- SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot));
+ SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
}
}
@@ -2112,7 +2112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetLocalRot(LSL_Rotation rot)
{
m_host.AddScriptLPS(1);
- SetRot(m_host, Rot2Quaternion(rot));
+ SetRot(m_host, rot);
ScriptSleep(200);
}
@@ -2828,7 +2828,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// need the magnitude later
// float velmag = (float)Util.GetMagnitude(llvel);
- SceneObjectGroup new_group = World.RezObject(m_host, item, pos, Rot2Quaternion(rot), vel, param);
+ SceneObjectGroup new_group = World.RezObject(m_host, item, pos, rot, vel, param);
// If either of these are null, then there was an unknown error.
if (new_group == null)
@@ -2897,7 +2897,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
- m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping);
+ m_host.StartLookAt(rot, (float)strength, (float)damping);
}
}
@@ -3292,7 +3292,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
- m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
+ m_host.RotLookAt(target, (float)strength, (float)damping);
}
}
@@ -6506,7 +6506,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_host.ParentGroup.IsDeleted)
{
- m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot));
+ m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, rot);
}
}
@@ -7316,13 +7316,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part.ParentID == 0)
{
// special case: If we are root, rotate complete SOG to new rotation
- SetRot(part, Rot2Quaternion(q));
+ SetRot(part, q);
}
else
{
// we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
SceneObjectPart rootPart = part.ParentGroup.RootPart;
- SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q));
+ SetRot(part, rootPart.RotationOffset * (Quaternion)q);
}
break;
@@ -7634,8 +7634,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
if (remain < 1)
return null;
- LSL_Rotation lr = rules.GetQuaternionItem(idx++);
- SetRot(part, Rot2Quaternion(lr));
+ SetRot(part, rules.GetQuaternionItem(idx++));
break;
case (int)ScriptBaseClass.PRIM_OMEGA:
if (remain < 3)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index eff1598..8936cb2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2533,7 +2533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence sp = World.GetScenePresence(npcId);
if (sp != null)
- sp.Rotation = LSL_Api.Rot2Quaternion(rotation);
+ sp.Rotation = rotation;
}
}
--
cgit v1.1
From d72d59905668d881c98f35c7f0c9783d6744084d Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 18 Aug 2012 15:19:15 +0100
Subject: integrating redundant code into operator
---
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 14 +-------------
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 7 ++++++-
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7009548..4645e7a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -330,14 +330,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return key;
}
- // convert a LSL_Rotation to a Quaternion
- public static Quaternion Rot2Quaternion(LSL_Rotation r)
- {
- Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
- q.Normalize();
- return q;
- }
-
//These are the implementations of the various ll-functions used by the LSL scripts.
public LSL_Float llSin(double f)
{
@@ -6532,12 +6524,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot)
{
- // LSL quaternions can normalize to 0, normal Quaternions can't.
- if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
- rot.z = 1; // ZERO_ROTATION = 0,0,0,1
-
part.SitTargetPosition = offset;
- part.SitTargetOrientation = Rot2Quaternion(rot);
+ part.SitTargetOrientation = rot;
part.ParentGroup.HasGroupChanged = true;
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index bdc7d70..9d9df9c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -417,7 +417,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
public static implicit operator OMV_Quaternion(Quaternion rot)
{
- return new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
+ // LSL quaternions can normalize to 0, normal Quaternions can't.
+ if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
+ rot.z = 1; // ZERO_ROTATION = 0,0,0,1
+ OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
+ omvrot.Normalize();
+ return omvrot;
}
public static implicit operator Quaternion(OMV_Quaternion rot)
--
cgit v1.1
From 8769e4ee731cfc83afec7ca4994113c2b04d7ba4 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 18 Aug 2012 19:08:38 +0100
Subject: Add a reference to OpenMetaverseType.dll to compiled script
assemblies.
---
OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 17a0d69..03be2ab 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -546,6 +546,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
"OpenSim.Region.ScriptEngine.Shared.dll"));
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
"OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll"));
+ parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
+ "OpenMetaverseTypes.dll"));
if (lang == enumCompileType.yp)
{
--
cgit v1.1
From dd0556abc9a88121ac91cd86c60a51aac9c726e5 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 19 Aug 2012 22:05:38 +0100
Subject: Fix llDialog responses so that they can be heard throughout the
region. This now conforms to the behaviour in SL.
---
OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 01ceeed..22b3d35 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5810,7 +5810,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
args.Channel = ch;
args.From = String.Empty;
args.Message = Utils.BytesToString(msg);
- args.Type = ChatTypeEnum.Shout;
+ args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
args.Position = new Vector3();
args.Scene = Scene;
args.Sender = this;
--
cgit v1.1
From 9aec62f0ac7ce0e074ee77e687d26c5414190162 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 20 Aug 2012 15:35:06 +0200
Subject: Fix scripted detach of temp attachments
---
.../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index f107be1..d6ad07e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -458,10 +458,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
{
- // As per Linden spec, detach (take) is disabled for temp attachs
- if (so.FromItemID == UUID.Zero)
- return;
-
lock (sp.AttachmentsSyncLock)
{
// Save avatar attachment information
@@ -976,7 +972,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
- if (sp != null && group != null)
+ if (sp != null && group != null && group.FromItemID != UUID.Zero)
DetachSingleAttachmentToInv(sp, group);
}
@@ -994,7 +990,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
foreach (SceneObjectGroup group in attachments)
{
- if (group.FromItemID == itemID)
+ if (group.FromItemID == itemID && group.FromItemID != UUID.Zero)
{
DetachSingleAttachmentToInv(sp, group);
return;
--
cgit v1.1
From bcbd450fe441e94d6c0f547055b4e95f75a5b0d0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 20 Aug 2012 20:24:54 +0100
Subject: Add --force flag to "kick user" console command to allow bypassing of
recent race condition checks.
This is to allow a second attempt to remove an avatar even if "show connections" shows them as already inactive (i.e. close has already been attempted once).
You should only attempt --force if a normal kick fails.
This is partly for diagnostics as we have seen some connections occasionally remain on lbsa plaza even if they are registered as inactive.
This is not a permanent solution and may not work anyway - the ultimate solution is to stop this problem from happening in the first place.
---
OpenSim/Framework/IClientAPI.cs | 14 +++++++++++++
OpenSim/Region/Application/OpenSim.cs | 24 +++++++++++++++-------
.../Caps/EventQueue/Tests/EventQueueTests.cs | 2 +-
.../Region/ClientStack/Linden/UDP/LLClientView.cs | 14 ++++++++-----
.../Attachments/Tests/AttachmentsModuleTests.cs | 2 +-
.../EntityTransfer/EntityTransferModule.cs | 2 +-
.../Simulation/LocalSimulationConnector.cs | 2 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++---
.../Scenes/Tests/ScenePresenceAgentTests.cs | 2 +-
.../Server/IRCClientView.cs | 5 +++++
.../Region/OptionalModules/World/NPC/NPCAvatar.cs | 5 +++++
.../Shared/Api/Implementation/OSSL_Api.cs | 4 ++--
OpenSim/Tests/Common/Mock/TestClient.cs | 5 +++++
prebuild.xml | 1 +
14 files changed, 69 insertions(+), 22 deletions(-)
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index d5952c4..8a63bff 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1033,7 +1033,21 @@ namespace OpenSim.Framework
void InPacket(object NewPack);
void ProcessInPacket(Packet NewPack);
+
+ ///
+ /// Close this client
+ ///
void Close();
+
+ ///
+ /// Close this client
+ ///
+ ///
+ /// If true, attempts the close without checking active status. You do not want to try this except as a last
+ /// ditch attempt where Active == false but the ScenePresence still exists.
+ ///
+ void Close(bool force);
+
void Kick(string message);
///
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 6bbab35..1fc11f5 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -35,6 +35,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Timers;
using log4net;
+using NDesk.Options;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -310,8 +311,11 @@ namespace OpenSim
"Change the scale of a named prim", HandleEditScale);
m_console.Commands.AddCommand("Users", false, "kick user",
- "kick user [message]",
- "Kick a user off the simulator", KickUserCommand);
+ "kick user [--force] [message]",
+ "Kick a user off the simulator",
+ "The --force option will kick the user without any checks to see whether it's already in the process of closing\n"
+ + "Only use this option if you are sure the avatar is inactive and a normal kick user operation does not removed them",
+ KickUserCommand);
m_console.Commands.AddCommand("Users", false, "show users",
"show users [full]",
@@ -453,11 +457,17 @@ namespace OpenSim
/// name of avatar to kick
private void KickUserCommand(string module, string[] cmdparams)
{
- if (cmdparams.Length < 4)
+ bool force = false;
+
+ OptionSet options = new OptionSet().Add("f|force", delegate (string v) { force = v != null; });
+
+ List mainParams = options.Parse(cmdparams);
+
+ if (mainParams.Count < 4)
return;
string alert = null;
- if (cmdparams.Length > 4)
+ if (mainParams.Count > 4)
alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4));
IList agents = SceneManager.GetCurrentSceneAvatars();
@@ -466,8 +476,8 @@ namespace OpenSim
{
RegionInfo regionInfo = presence.Scene.RegionInfo;
- if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) &&
- presence.Lastname.ToLower().Contains(cmdparams[3].ToLower()))
+ if (presence.Firstname.ToLower().Contains(mainParams[2].ToLower()) &&
+ presence.Lastname.ToLower().Contains(mainParams[3].ToLower()))
{
MainConsole.Instance.Output(
String.Format(
@@ -480,7 +490,7 @@ namespace OpenSim
else
presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n");
- presence.Scene.IncomingCloseAgent(presence.UUID);
+ presence.Scene.IncomingCloseAgent(presence.UUID, force);
}
}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
index cd70410..d604cf6 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
UUID spId = TestHelpers.ParseTail(0x1);
SceneHelpers.AddScenePresence(m_scene, spId);
- m_scene.IncomingCloseAgent(spId);
+ m_scene.IncomingCloseAgent(spId, false);
// TODO: Add more assertions for the other aspects of event queues
Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0));
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 22b3d35..148d0e0 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -487,16 +487,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Client Methods
- ///
- /// Close down the client view
- ///
public void Close()
{
+ Close(false);
+ }
+
+ public void Close(bool force)
+ {
// We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
// a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
lock (CloseSyncLock)
{
- if (!IsActive)
+ // We still perform a force close inside the sync lock since this is intended to attempt close where
+ // there is some unidentified connection problem, not where we have issues due to deadlock
+ if (!IsActive && !force)
return;
IsActive = false;
@@ -11989,7 +11993,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
Kick(reason);
Thread.Sleep(1000);
- Close();
+ Disconnect();
}
public void Disconnect()
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 1d13f75..82c6390 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -461,7 +461,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
SceneObjectGroup rezzedAtt = presence.GetAttachments()[0];
- scene.IncomingCloseAgent(presence.UUID);
+ scene.IncomingCloseAgent(presence.UUID, false);
// Check that we can't retrieve this attachment from the scene.
Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 46738f6..c63b0a4 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -644,7 +644,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// an agent cannot teleport back to this region if it has teleported away.
Thread.Sleep(2000);
- sp.Scene.IncomingCloseAgent(sp.UUID);
+ sp.Scene.IncomingCloseAgent(sp.UUID, false);
}
else
{
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 09a3bd6..1e52d37 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -312,7 +312,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
// s.RegionInfo.RegionName, destination.RegionHandle);
- Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id); });
+ Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id, false); });
return true;
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d2d6aba..ad74189 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4116,16 +4116,19 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Tell a single agent to disconnect from the region.
///
- ///
///
- public bool IncomingCloseAgent(UUID agentID)
+ ///
+ /// Force the agent to close even if it might be in the middle of some other operation. You do not want to
+ /// force unless you are absolutely sure that the agent is dead and a normal close is not working.
+ ///
+ public bool IncomingCloseAgent(UUID agentID, bool force)
{
//m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
if (presence != null)
{
- presence.ControllingClient.Close();
+ presence.ControllingClient.Close(force);
return true;
}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index 5758869..5faf131 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
TestScene scene = new SceneHelpers().SetupScene();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
- scene.IncomingCloseAgent(sp.UUID);
+ scene.IncomingCloseAgent(sp.UUID, false);
Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index bae25cd..e93bd7c 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -886,6 +886,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public void Close()
{
+ Close(false);
+ }
+
+ public void Close(bool force)
+ {
Disconnect();
}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 67989ba..a8e4d90 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -901,6 +901,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public void Close()
{
+ Close(false);
+ }
+
+ public void Close(bool force)
+ {
// Remove ourselves from the scene
m_scene.RemoveClient(AgentId, false);
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8936cb2..1e8b51b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2877,7 +2877,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
avatar.SpeedModifier = (float)SpeedModifier;
}
- public void osKickAvatar(string FirstName,string SurName,string alert)
+ public void osKickAvatar(string FirstName, string SurName, string alert)
{
CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
m_host.AddScriptLPS(1);
@@ -2891,7 +2891,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
sp.ControllingClient.Kick(alert);
// ...and close on our side
- sp.Scene.IncomingCloseAgent(sp.UUID);
+ sp.Scene.IncomingCloseAgent(sp.UUID, false);
}
});
}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 89c4f11..bb8b935 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -934,6 +934,11 @@ namespace OpenSim.Tests.Common.Mock
public void Close()
{
+ Close(false);
+ }
+
+ public void Close(bool force)
+ {
// Fire the callback for this connection closing
// This is necesary to get the presence detector to notice that a client has logged out.
if (OnConnectionClosed != null)
diff --git a/prebuild.xml b/prebuild.xml
index b4f4464..1765899 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1760,6 +1760,7 @@
+
--
cgit v1.1
From 970727e57e2fd478685b5853c855d3b471d5325d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 20 Aug 2012 20:55:58 +0100
Subject: Tighten up OpenSim.Framework.Cache locking to avoid race conditions.
This is to resolve a reported issue in http://opensimulator.org/mantis/view.php?id=6232
Here, the land management module is using OpenSim.Framework.Cache (the only code to currently do so apart from the non-default CoreAssetCache).
---
OpenSim/Framework/Cache.cs | 83 +++++++++++++++++++++++++++++-----------------
1 file changed, 53 insertions(+), 30 deletions(-)
diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs
index 79e20fc..31cab4a 100644
--- a/OpenSim/Framework/Cache.cs
+++ b/OpenSim/Framework/Cache.cs
@@ -199,7 +199,14 @@ namespace OpenSim.Framework
//
public class Cache
{
+ ///
+ /// Must only be accessed under lock.
+ ///
private List m_Index = new List();
+
+ ///
+ /// Must only be accessed under m_Index lock.
+ ///
private Dictionary m_Lookup =
new Dictionary();
@@ -320,19 +327,19 @@ namespace OpenSim.Framework
{
if (m_Lookup.ContainsKey(index))
item = m_Lookup[index];
- }
- if (item == null)
- {
+ if (item == null)
+ {
+ Expire(true);
+ return null;
+ }
+
+ item.hits++;
+ item.lastUsed = DateTime.Now;
+
Expire(true);
- return null;
}
- item.hits++;
- item.lastUsed = DateTime.Now;
-
- Expire(true);
-
return item;
}
@@ -385,7 +392,10 @@ namespace OpenSim.Framework
//
public Object Find(Predicate d)
{
- CacheItemBase item = m_Index.Find(d);
+ CacheItemBase item;
+
+ lock (m_Index)
+ item = m_Index.Find(d);
if (item == null)
return null;
@@ -419,12 +429,12 @@ namespace OpenSim.Framework
public virtual void Store(string index, Object data, Type container,
Object[] parameters)
{
- Expire(false);
-
CacheItemBase item;
lock (m_Index)
{
+ Expire(false);
+
if (m_Index.Contains(new CacheItemBase(index)))
{
if ((m_Flags & CacheFlags.AllowUpdate) != 0)
@@ -450,9 +460,17 @@ namespace OpenSim.Framework
m_Index.Add(item);
m_Lookup[index] = item;
}
+
item.Store(data);
}
+ ///
+ /// Expire items as appropriate.
+ ///
+ ///
+ /// Callers must lock m_Index.
+ ///
+ ///
protected virtual void Expire(bool getting)
{
if (getting && (m_Strategy == CacheStrategy.Aggressive))
@@ -475,12 +493,10 @@ namespace OpenSim.Framework
switch (m_Strategy)
{
- case CacheStrategy.Aggressive:
- if (Count < Size)
- return;
+ case CacheStrategy.Aggressive:
+ if (Count < Size)
+ return;
- lock (m_Index)
- {
m_Index.Sort(new SortLRU());
m_Index.Reverse();
@@ -490,7 +506,7 @@ namespace OpenSim.Framework
ExpireDelegate doExpire = OnExpire;
- if (doExpire != null)
+ if (doExpire != null)
{
List candidates =
m_Index.GetRange(target, Count - target);
@@ -513,27 +529,34 @@ namespace OpenSim.Framework
foreach (CacheItemBase item in m_Index)
m_Lookup[item.uuid] = item;
}
- }
- break;
- default:
- break;
+
+ break;
+
+ default:
+ break;
}
}
public void Invalidate(string uuid)
{
- if (!m_Lookup.ContainsKey(uuid))
- return;
+ lock (m_Index)
+ {
+ if (!m_Lookup.ContainsKey(uuid))
+ return;
- CacheItemBase item = m_Lookup[uuid];
- m_Lookup.Remove(uuid);
- m_Index.Remove(item);
+ CacheItemBase item = m_Lookup[uuid];
+ m_Lookup.Remove(uuid);
+ m_Index.Remove(item);
+ }
}
public void Clear()
{
- m_Index.Clear();
- m_Lookup.Clear();
+ lock (m_Index)
+ {
+ m_Index.Clear();
+ m_Lookup.Clear();
+ }
}
}
-}
+}
\ No newline at end of file
--
cgit v1.1
From 812c498ef4da06d8c842e53e16e22c45e2fecbc2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 20 Aug 2012 21:58:18 +0100
Subject: When loading an OAR, validate any group UUIDs and properly
reconstruct parcel access lists.
If a group UUID is present that is not on this simulator then the object or parcel is no longer group owned.
This is a change from previous behaviour where such invalid UUIDs were kept.
This is an adaptation of patch 0002 from http://opensimulator.org/mantis/view.php?id=6105 by Oren Hurvitz of Kitely.
My adaptations are formatting only, apart from the notices about parcel owner IDs not being saved since this has now been fixed.
Thanks Oren.
---
.../World/Archiver/ArchiveReadRequest.cs | 63 +++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 2b61800..433166d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -97,6 +97,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
}
+ ///
+ /// Used to cache lookups for valid groups.
+ ///
+ private IDictionary m_validGroupUuids = new Dictionary();
+
+ private IGroupsModule m_groupsModule;
+
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
{
m_scene = scene;
@@ -120,6 +127,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false;
+
+ m_groupsModule = m_scene.RequestModuleInterface();
}
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
@@ -132,6 +141,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false;
+
+ m_groupsModule = m_scene.RequestModuleInterface();
}
///
@@ -302,6 +313,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if (!ResolveUserUuid(part.LastOwnerID))
part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
+ if (!ResolveGroupUuid(part.GroupID))
+ part.GroupID = UUID.Zero;
+
// And zap any troublesome sit target information
// part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
// part.SitTargetPosition = new Vector3(0, 0, 0);
@@ -318,13 +332,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
}
+
if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty)
{
if (!ResolveUserUuid(kvp.Value.CreatorID))
kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
}
+
if (UserManager != null)
UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
+
+ if (!ResolveGroupUuid(kvp.Value.GroupID))
+ kvp.Value.GroupID = UUID.Zero;
}
}
}
@@ -364,9 +383,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
foreach (string serialisedParcel in serialisedParcels)
{
LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
+
+ // Validate User and Group UUID's
+
if (!ResolveUserUuid(parcel.OwnerID))
parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
-
+
+ if (!ResolveGroupUuid(parcel.GroupID))
+ {
+ parcel.GroupID = UUID.Zero;
+ parcel.IsGroupOwned = false;
+ }
+
+ List accessList = new List();
+ foreach (LandAccessEntry entry in parcel.ParcelAccessList)
+ {
+ if (ResolveUserUuid(entry.AgentID))
+ accessList.Add(entry);
+ // else, drop this access rule
+ }
+ parcel.ParcelAccessList = accessList;
+
// m_log.DebugFormat(
// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}",
// parcel.Name, parcel.LocalID, parcel.Area);
@@ -401,6 +438,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
///
+ /// Look up the given group id to check whether it's one that is valid for this grid.
+ ///
+ ///
+ ///
+ private bool ResolveGroupUuid(UUID uuid)
+ {
+ if (uuid == UUID.Zero)
+ return true; // this means the object has no group
+
+ if (!m_validGroupUuids.ContainsKey(uuid))
+ {
+ bool exists;
+
+ if (m_groupsModule == null)
+ exists = false;
+ else
+ exists = (m_groupsModule.GetGroupRecord(uuid) != null);
+
+ m_validGroupUuids.Add(uuid, exists);
+ }
+
+ return m_validGroupUuids[uuid];
+ }
+
/// Load an asset
///
///
--
cgit v1.1
From e6fb45859775d0c53de0bcdfc48fad51866d318b Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 20 Aug 2012 22:18:29 +0100
Subject: no-op change for cia.vc test
---
OpenSim/Region/Application/OpenSim.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 1fc11f5..769eea8 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -420,6 +420,7 @@ namespace OpenSim
{
RunCommandScript(m_shutdownCommandsFile);
}
+
base.ShutdownSpecific();
}
--
cgit v1.1
From aee4353e9cf811bd66a17f292c6f17c9495831fc Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 17 Aug 2012 14:47:53 +0100
Subject: fix typo
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 53b4f7e..0535dcb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2858,7 +2858,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SetFaceColor(Vector3 color, int face)
{
// The only way to get a deep copy/ If we don't do this, we can
- // mever detect color changes further down.
+ // never detect color changes further down.
Byte[] buf = Shape.Textures.GetBytes();
Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
Color4 texcolor;
--
cgit v1.1
From b863a15a820be7c3b86b27ef24944d6a85fa5360 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 17 Aug 2012 15:09:52 +0100
Subject: single operation for PRIM_COLOR
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 49 ++++++++++++++++++++++
.../Shared/Api/Implementation/LSL_Api.cs | 3 +-
2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0535dcb..6741e5e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2896,6 +2896,55 @@ namespace OpenSim.Region.Framework.Scenes
}
///
+ /// Set the color & alpha of prim faces
+ ///
+ ///
+ ///
+ ///
+ public void SetFaceColorAlpha(int face, Vector3 color, double alpha)
+ {
+ // The only way to get a deep copy/ If we don't do this, we can
+ // never detect color changes further down.
+ Byte[] buf = Shape.Textures.GetBytes();
+ Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
+ Color4 texcolor;
+ if (face >= 0 && face < GetNumberOfSides())
+ {
+ texcolor = tex.CreateFace((uint)face).RGBA;
+ texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
+ texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
+ texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
+ texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
+ tex.FaceTextures[face].RGBA = texcolor;
+ UpdateTextureEntry(tex.GetBytes());
+ return;
+ }
+ else if (face == ALL_SIDES)
+ {
+ for (uint i = 0; i < GetNumberOfSides(); i++)
+ {
+ if (tex.FaceTextures[i] != null)
+ {
+ texcolor = tex.FaceTextures[i].RGBA;
+ texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
+ texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
+ texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
+ texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
+ tex.FaceTextures[i].RGBA = texcolor;
+ }
+ texcolor = tex.DefaultTexture.RGBA;
+ texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
+ texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
+ texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
+ texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
+ tex.DefaultTexture.RGBA = texcolor;
+ }
+ UpdateTextureEntry(tex.GetBytes());
+ return;
+ }
+ }
+
+ ///
/// Get the number of sides that this part has.
///
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4645e7a..dbbfbd3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7484,8 +7484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(idx++);
double alpha=(double)rules.GetLSLFloatItem(idx++);
- part.SetFaceColor(color, face);
- SetAlpha(part, alpha, face);
+ part.SetFaceColorAlpha(face, new Vector3((float)color.x, (float)color.y, (float)color.z), alpha);
break;
--
cgit v1.1
From ede3b9ab07dc1ed4a51684b7257cbb4d76e9bdfd Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Mon, 20 Aug 2012 09:26:26 +0100
Subject: making use of implicit operators and Util.Clip handling of Vector3
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 47 ++++++++++++----------
.../Shared/Api/Implementation/LSL_Api.cs | 2 +-
2 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 6741e5e..098b2d9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2857,6 +2857,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SetFaceColor(Vector3 color, int face)
{
+ Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
+
// The only way to get a deep copy/ If we don't do this, we can
// never detect color changes further down.
Byte[] buf = Shape.Textures.GetBytes();
@@ -2865,9 +2867,9 @@ namespace OpenSim.Region.Framework.Scenes
if (face >= 0 && face < GetNumberOfSides())
{
texcolor = tex.CreateFace((uint)face).RGBA;
- texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
- texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
- texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
+ texcolor.R = clippedColor.X;
+ texcolor.G = clippedColor.Y;
+ texcolor.B = clippedColor.Z;
tex.FaceTextures[face].RGBA = texcolor;
UpdateTextureEntry(tex.GetBytes());
return;
@@ -2879,15 +2881,15 @@ namespace OpenSim.Region.Framework.Scenes
if (tex.FaceTextures[i] != null)
{
texcolor = tex.FaceTextures[i].RGBA;
- texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
- texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
- texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
+ texcolor.R = clippedColor.X;
+ texcolor.G = clippedColor.Y;
+ texcolor.B = clippedColor.Z;
tex.FaceTextures[i].RGBA = texcolor;
}
texcolor = tex.DefaultTexture.RGBA;
- texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
- texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
- texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
+ texcolor.R = clippedColor.X;
+ texcolor.G = clippedColor.Y;
+ texcolor.B = clippedColor.Z;
tex.DefaultTexture.RGBA = texcolor;
}
UpdateTextureEntry(tex.GetBytes());
@@ -2903,6 +2905,9 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SetFaceColorAlpha(int face, Vector3 color, double alpha)
{
+ Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
+ float clippedAlpha = Util.Clip((float)alpha, 0.0f, 1.0f);
+
// The only way to get a deep copy/ If we don't do this, we can
// never detect color changes further down.
Byte[] buf = Shape.Textures.GetBytes();
@@ -2911,10 +2916,10 @@ namespace OpenSim.Region.Framework.Scenes
if (face >= 0 && face < GetNumberOfSides())
{
texcolor = tex.CreateFace((uint)face).RGBA;
- texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
- texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
- texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
- texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
+ texcolor.R = clippedColor.X;
+ texcolor.G = clippedColor.Y;
+ texcolor.B = clippedColor.Z;
+ texcolor.A = clippedAlpha;
tex.FaceTextures[face].RGBA = texcolor;
UpdateTextureEntry(tex.GetBytes());
return;
@@ -2926,17 +2931,17 @@ namespace OpenSim.Region.Framework.Scenes
if (tex.FaceTextures[i] != null)
{
texcolor = tex.FaceTextures[i].RGBA;
- texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
- texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
- texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
- texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
+ texcolor.R = clippedColor.X;
+ texcolor.G = clippedColor.Y;
+ texcolor.B = clippedColor.Z;
+ texcolor.A = clippedAlpha;
tex.FaceTextures[i].RGBA = texcolor;
}
texcolor = tex.DefaultTexture.RGBA;
- texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
- texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
- texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
- texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
+ texcolor.R = clippedColor.X;
+ texcolor.G = clippedColor.Y;
+ texcolor.B = clippedColor.Z;
+ texcolor.A = clippedAlpha;
tex.DefaultTexture.RGBA = texcolor;
}
UpdateTextureEntry(tex.GetBytes());
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index dbbfbd3..0cbb317 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7484,7 +7484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(idx++);
double alpha=(double)rules.GetLSLFloatItem(idx++);
- part.SetFaceColorAlpha(face, new Vector3((float)color.x, (float)color.y, (float)color.z), alpha);
+ part.SetFaceColorAlpha(face, color, alpha);
break;
--
cgit v1.1
From 481c00f50a1961ac77e800d64a68e9c30a4b69de Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Mon, 20 Aug 2012 09:31:29 +0100
Subject: refactoring out SetFaceColor
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 67 +++++-----------------
.../Shared/Api/Implementation/LSL_Api.cs | 4 +-
2 files changed, 17 insertions(+), 54 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 098b2d9..2a9ee3a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2851,62 +2851,16 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Set the color of prim faces
- ///
- ///
- ///
- public void SetFaceColor(Vector3 color, int face)
- {
- Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
-
- // The only way to get a deep copy/ If we don't do this, we can
- // never detect color changes further down.
- Byte[] buf = Shape.Textures.GetBytes();
- Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
- Color4 texcolor;
- if (face >= 0 && face < GetNumberOfSides())
- {
- texcolor = tex.CreateFace((uint)face).RGBA;
- texcolor.R = clippedColor.X;
- texcolor.G = clippedColor.Y;
- texcolor.B = clippedColor.Z;
- tex.FaceTextures[face].RGBA = texcolor;
- UpdateTextureEntry(tex.GetBytes());
- return;
- }
- else if (face == ALL_SIDES)
- {
- for (uint i = 0; i < GetNumberOfSides(); i++)
- {
- if (tex.FaceTextures[i] != null)
- {
- texcolor = tex.FaceTextures[i].RGBA;
- texcolor.R = clippedColor.X;
- texcolor.G = clippedColor.Y;
- texcolor.B = clippedColor.Z;
- tex.FaceTextures[i].RGBA = texcolor;
- }
- texcolor = tex.DefaultTexture.RGBA;
- texcolor.R = clippedColor.X;
- texcolor.G = clippedColor.Y;
- texcolor.B = clippedColor.Z;
- tex.DefaultTexture.RGBA = texcolor;
- }
- UpdateTextureEntry(tex.GetBytes());
- return;
- }
- }
-
- ///
/// Set the color & alpha of prim faces
///
///
///
///
- public void SetFaceColorAlpha(int face, Vector3 color, double alpha)
+ public void SetFaceColorAlpha(int face, Vector3 color, double ?alpha)
{
Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
- float clippedAlpha = Util.Clip((float)alpha, 0.0f, 1.0f);
+ float clippedAlpha = alpha.HasValue ?
+ Util.Clip((float)alpha.Value, 0.0f, 1.0f) : 0;
// The only way to get a deep copy/ If we don't do this, we can
// never detect color changes further down.
@@ -2919,7 +2873,10 @@ namespace OpenSim.Region.Framework.Scenes
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
- texcolor.A = clippedAlpha;
+ if (alpha.HasValue)
+ {
+ texcolor.A = clippedAlpha;
+ }
tex.FaceTextures[face].RGBA = texcolor;
UpdateTextureEntry(tex.GetBytes());
return;
@@ -2934,14 +2891,20 @@ namespace OpenSim.Region.Framework.Scenes
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
- texcolor.A = clippedAlpha;
+ if (alpha.HasValue)
+ {
+ texcolor.A = clippedAlpha;
+ }
tex.FaceTextures[i].RGBA = texcolor;
}
texcolor = tex.DefaultTexture.RGBA;
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
- texcolor.A = clippedAlpha;
+ if (alpha.HasValue)
+ {
+ texcolor.A = clippedAlpha;
+ }
tex.DefaultTexture.RGBA = texcolor;
}
UpdateTextureEntry(tex.GetBytes());
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0cbb317..8140416 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1377,7 +1377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face == ScriptBaseClass.ALL_SIDES)
face = SceneObjectPart.ALL_SIDES;
- m_host.SetFaceColor(color, face);
+ m_host.SetFaceColorAlpha(face, color, null);
}
public void SetTexGen(SceneObjectPart part, int face,int style)
@@ -3572,7 +3572,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
- part.SetFaceColor(color, face);
+ part.SetFaceColorAlpha(face, color, null);
}
public void llCreateLink(string target, int parent)
--
cgit v1.1
From 555edc4ef746d60ccbe1552805df67b36a780ec0 Mon Sep 17 00:00:00 2001
From: nebadon
Date: Mon, 20 Aug 2012 15:51:30 -0700
Subject: testing github commit bot
---
README.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.txt b/README.txt
index a5dec24..837cbcf 100644
--- a/README.txt
+++ b/README.txt
@@ -129,3 +129,4 @@ project can always be found at http://opensimulator.org.
Thanks for trying OpenSim, we hope it is a pleasant experience.
+
--
cgit v1.1
From 150748392ee55f147fbf105be355f0c232a84c39 Mon Sep 17 00:00:00 2001
From: nebadon
Date: Mon, 20 Aug 2012 15:57:28 -0700
Subject: testing github bot take 2
---
README.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.txt b/README.txt
index 837cbcf..a5dec24 100644
--- a/README.txt
+++ b/README.txt
@@ -129,4 +129,3 @@ project can always be found at http://opensimulator.org.
Thanks for trying OpenSim, we hope it is a pleasant experience.
-
--
cgit v1.1
From 9925317239b9b7cfe90d682aaf4657cb70ff3b7d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 21 Aug 2012 22:21:35 +0100
Subject: Fix bug in SoundModule.PlayAttachedSound() where every sound update
to an avatar would base its gain calculation on the previous avatar's gain,
instead of the original input gain
This is similar to commit d89faa which fixed the same kind of bug in TriggerSound()
---
OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 14c1a39..a2f0950 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -85,13 +85,15 @@ namespace OpenSim.Region.CoreModules.World.Sound
dis = 0;
}
+ float thisSpGain;
+
// Scale by distance
if (radius == 0)
- gain = (float)((double)gain * ((100.0 - dis) / 100.0));
+ thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
else
- gain = (float)((double)gain * ((radius - dis) / radius));
+ thisSpGain = (float)((double)gain * ((radius - dis) / radius));
- sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags);
+ sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags);
});
}
--
cgit v1.1
From 568de9313a9a9f04285a367cbad8c77a67f0d952 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 21 Aug 2012 20:55:48 -0700
Subject: BulletSim: update DLLs and SOs to eliminate terrain update crash
which manifested itself on Linux.
---
bin/lib32/BulletSim.dll | Bin 553472 -> 552960 bytes
bin/lib32/libBulletSim.so | Bin 2387051 -> 2387278 bytes
bin/lib64/BulletSim.dll | Bin 709632 -> 710144 bytes
bin/lib64/libBulletSim.so | Bin 2599546 -> 2599821 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll
index cc55f00..ce0dd9d 100755
Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ
diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so
index 26ad52b..d2d6540 100755
Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ
diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll
index 94dae95..67d3f1c 100755
Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ
diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so
index 52e9960..9a5c171 100755
Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ
--
cgit v1.1
From 1369058280c4cf399d46df1508b80cad99f1247e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 22 Aug 2012 23:04:17 +0100
Subject: Lock disposal of separate gdi+ objects under different threads since
this prevents malloc heap corruption seen under Ubuntu 10.04.1 and 11.04 -
probably a libcairo issue
In testing, it appears that if multiple threads dispose of separate GDI+ objects simultaneously,
the native malloc heap can become corrupted, possibly due to a double free(). This may be due to
bugs in the underlying libcairo used by mono's libgdiplus.dll on Linux/OSX. These problems were
seen with both libcario 1.10.2-6.1ubuntu3 and 1.8.10-2ubuntu1. They go away if disposal is perfomed
under lock.
---
.../Scripting/VectorRender/VectorRenderModule.cs | 68 +++++++++++++---------
1 file changed, 42 insertions(+), 26 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index ca320e1..c48a703 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -308,36 +308,44 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
try
{
- if (alpha == 256)
- bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
- else
- bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
-
- graph = Graphics.FromImage(bitmap);
-
- // this is really just to save people filling the
- // background color in their scripts, only do when fully opaque
- if (alpha >= 255)
+ // XXX: In testing, it appears that if multiple threads dispose of separate GDI+ objects simultaneously,
+ // the native malloc heap can become corrupted, possibly due to a double free(). This may be due to
+ // bugs in the underlying libcairo used by mono's libgdiplus.dll on Linux/OSX. These problems were
+ // seen with both libcario 1.10.2-6.1ubuntu3 and 1.8.10-2ubuntu1. They go away if disposal is perfomed
+ // under lock.
+ lock (this)
{
- using (SolidBrush bgFillBrush = new SolidBrush(bgColor))
+ if (alpha == 256)
+ bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
+ else
+ bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
+
+ graph = Graphics.FromImage(bitmap);
+
+ // this is really just to save people filling the
+ // background color in their scripts, only do when fully opaque
+ if (alpha >= 255)
{
- graph.FillRectangle(bgFillBrush, 0, 0, width, height);
+ using (SolidBrush bgFillBrush = new SolidBrush(bgColor))
+ {
+ graph.FillRectangle(bgFillBrush, 0, 0, width, height);
+ }
}
- }
-
- for (int w = 0; w < bitmap.Width; w++)
- {
- if (alpha <= 255)
+
+ for (int w = 0; w < bitmap.Width; w++)
{
- for (int h = 0; h < bitmap.Height; h++)
+ if (alpha <= 255)
{
- bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h)));
+ for (int h = 0; h < bitmap.Height; h++)
+ {
+ bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h)));
+ }
}
}
+
+ GDIDraw(data, graph, altDataDelim);
}
- GDIDraw(data, graph, altDataDelim);
-
byte[] imageJ2000 = new byte[0];
try
@@ -355,11 +363,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
}
finally
{
- if (graph != null)
- graph.Dispose();
-
- if (bitmap != null)
- bitmap.Dispose();
+ // XXX: In testing, it appears that if multiple threads dispose of separate GDI+ objects simultaneously,
+ // the native malloc heap can become corrupted, possibly due to a double free(). This may be due to
+ // bugs in the underlying libcairo used by mono's libgdiplus.dll on Linux/OSX. These problems were
+ // seen with both libcario 1.10.2-6.1ubuntu3 and 1.8.10-2ubuntu1. They go away if disposal is perfomed
+ // under lock.
+ lock (this)
+ {
+ if (graph != null)
+ graph.Dispose();
+
+ if (bitmap != null)
+ bitmap.Dispose();
+ }
}
}
--
cgit v1.1
From 4820dfd733a5b6dae54e120cfb1486643765bb3e Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 21 Aug 2012 12:30:47 +0100
Subject: this should be an if-else block in case the non-phys min/max are
smaller than the physical min/max
---
.../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8140416..0d275f7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1341,11 +1341,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
scale.y = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.y));
scale.z = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.z));
}
-
- // Next we clamp the scale to the non-physical min/max
- scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x));
- scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y));
- scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z));
+ else
+ {
+ // If not physical, then we clamp the scale to the non-physical min/max
+ scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x));
+ scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y));
+ scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z));
+ }
Vector3 tmp = part.Scale;
tmp.X = (float)scale.x;
--
cgit v1.1
From a533db7e279d533a6858a194fef5d913553c1bf9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 23 Aug 2012 22:30:14 +0100
Subject: Add an [HGAssetService] section to SQLiteStandalone.ini with the same
connection string as [AssetService].
This is necessary because commit 8131a24 (Tue Mar 27 10:08:13 2012) started passing the config section name rather than hardcoding "AssetService"
This meant that the HG external-facing asset service tried to read ConnectionString from [HGAssetService] rather than [AssetService].
On SQLite, not finding this meant that it fell back to [DatabaseService], which is set for OpenSim.db rather than Asset.db.
Therefore, all external asset requests returned null.
Solution taken here is to create an [HGAssetService] section with the same ConnectionString as [AssetService].
This bug does not affect normal MySQL/MSSQL config since they use the [DatabaseService] connection string anyway.
Addresses http://opensimulator.org/mantis/view.php?id=6200, many thanks to DanBanner for identifying the exact problem commit which was very helpful.
This was a regression from OpenSimulator 0.7.3.1 which did not contain this bug.
---
bin/config-include/storage/SQLiteStandalone.ini | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/bin/config-include/storage/SQLiteStandalone.ini b/bin/config-include/storage/SQLiteStandalone.ini
index c1de71a..67d98ff 100644
--- a/bin/config-include/storage/SQLiteStandalone.ini
+++ b/bin/config-include/storage/SQLiteStandalone.ini
@@ -7,6 +7,16 @@
[AssetService]
ConnectionString = "URI=file:Asset.db,version=3"
+; The HGAssetService section controls the connection given to the AssetService in a Hypergrid configuration.
+; This has to be separate from [AssetService] because the Hypergrid facing connector uses [HGAssetService] for its config data instead.
+; However, the internal asset service will still use the [AssetService] section.
+; Therefore, you will almost certainly want the ConnectionString in [HGAssetService] to be the same as in [AssetService]
+; so that they both access the same database.
+; This issue does not apply to normal MySQL/MSSQL configurations, since by default they use the settings in [DatabaseService] and
+; do not have separate connection strings for different services.
+[HGAssetService]
+ ConnectionString = "URI=file:Asset.db,version=3"
+
[InventoryService]
;ConnectionString = "URI=file:inventory.db,version=3"
; if you have a legacy inventory store use the connection string below
--
cgit v1.1
From aede42b87559aa1f8f3197b53b9bf5c2b547701a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 23 Aug 2012 23:13:53 +0100
Subject: If a script state save fails for some reason on shutdown/region
removal, get xengine to spit out some useful information and continue to save
other script states
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 27 ++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 53f899a..5a3f002 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -589,7 +589,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (m_Assemblies.ContainsKey(instance.AssetID))
{
string assembly = m_Assemblies[instance.AssetID];
- instance.SaveState(assembly);
+
+ try
+ {
+ instance.SaveState(assembly);
+ }
+ catch (Exception e)
+ {
+ m_log.Error(
+ string.Format(
+ "[XEngine]: Failed final state save for script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ",
+ instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name)
+ , e);
+ }
}
// Clear the event queue and abort the instance thread
@@ -707,7 +719,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
assembly = m_Assemblies[i.AssetID];
}
- i.SaveState(assembly);
+ try
+ {
+ i.SaveState(assembly);
+ }
+ catch (Exception e)
+ {
+ m_log.Error(
+ string.Format(
+ "[XEngine]: Failed to save state of script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ",
+ i.PrimName, i.ScriptName, i.ItemID, i.ObjectID, World.Name)
+ , e);
+ }
}
instances.Clear();
--
cgit v1.1
From 4f3fabae5bec8a71f9953ef9f4c247e086e4757f Mon Sep 17 00:00:00 2001
From: TBG Renfold
Date: Thu, 9 Aug 2012 18:03:26 +0100
Subject: Adds osGetHealth.
Returns the amount of health (in an integer) that an avatar has left in the scene.
If an avatar is not found or safe is enabled on a region, -1 is returned.
Example usage:
default
{
touch_end(integer _t)
{
key agentID = llDetectedKey(0);
osCauseDamage(agentID, 50);
llSay(0, llKey2Name(agentID) + " has " + (string)osGetHealth(agentID) + "% health left.");
}
}
---
.../Shared/Api/Implementation/OSSL_Api.cs | 21 +++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 +
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 7 ++++++-
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 1e8b51b..3d233d7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2895,6 +2895,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
});
}
+
+ public LSL_Float osGetHealth(string avatar)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osGetHealth");
+ m_host.AddScriptLPS(1);
+
+ UUID avatarId = new UUID(avatar);
+ Vector3 pos = m_host.GetWorldPosition();
+
+ LSL_Float health = new LSL_Float(-1);
+ ScenePresence presence = World.GetScenePresence(avatarId);
+ if (presence != null)
+ {
+ LandData land = World.GetLandData((float)pos.X, (float)pos.Y);
+ if ((land.Flags & (uint)ParcelFlags.AllowDamage) == (uint)ParcelFlags.AllowDamage)
+ {
+ health = presence.Health;
+ }
+ }
+ return health;
+ }
public void osCauseDamage(string avatar, double damage)
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 1f000a3..9ad1c22 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -258,6 +258,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
int osGetSimulatorMemory();
void osKickAvatar(string FirstName,string SurName,string alert);
void osSetSpeed(string UUID, LSL_Float SpeedModifier);
+ LSL_Float osGetHealth(string avatar);
void osCauseHealing(string avatar, double healing);
void osCauseDamage(string avatar, double damage);
LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 94405d2..e9131e4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -865,7 +865,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
m_OSSL_Functions.osSetSpeed(UUID, SpeedModifier);
}
-
+
+ public LSL_Float osGetHealth(string avatar)
+ {
+ return m_OSSL_Functions.osGetHealth(avatar);
+ }
+
public void osCauseDamage(string avatar, double damage)
{
m_OSSL_Functions.osCauseDamage(avatar, damage);
--
cgit v1.1
From a3cbda0d74a14c05acf04adaaa5b9ff30c6d9fa5 Mon Sep 17 00:00:00 2001
From: TBG Renfold
Date: Fri, 10 Aug 2012 01:29:41 +0100
Subject: Removed land checking as suggested by SignpostMarv.
Now whatever remaining health the avatar has is displayed (float).
This will be 100% (100.000000) if no damage has occurred (as what the viewer should really be seeing anyway).
Returns -1.000000 if the avatar is not found.
---
.../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 3d233d7..5e7c2d9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2901,19 +2901,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.None, "osGetHealth");
m_host.AddScriptLPS(1);
- UUID avatarId = new UUID(avatar);
- Vector3 pos = m_host.GetWorldPosition();
-
LSL_Float health = new LSL_Float(-1);
- ScenePresence presence = World.GetScenePresence(avatarId);
- if (presence != null)
- {
- LandData land = World.GetLandData((float)pos.X, (float)pos.Y);
- if ((land.Flags & (uint)ParcelFlags.AllowDamage) == (uint)ParcelFlags.AllowDamage)
- {
- health = presence.Health;
- }
- }
+ ScenePresence presence = World.GetScenePresence(new UUID(avatar));
+ if (presence != null) health = presence.Health;
return health;
}
--
cgit v1.1
From c55768466626336849c650349b335365c41359e5 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 24 Aug 2012 00:15:30 +0100
Subject: Fix bad child prim permissions that can make objects change perms
after rezzing
Port from Avination
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 +++
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 18 +++++++++++++++---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 21 +++++++++++++++++++++
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 7e31d60..675c64d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1943,6 +1943,9 @@ namespace OpenSim.Region.Framework.Scenes
deleteIDs.Add(localID);
deleteGroups.Add(grp);
+ // If child prims have invalid perms, fix them
+ grp.AdjustChildPrimPermissions();
+
if (remoteClient == null)
{
// Autoreturn has a null client. Nothing else does. So
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index f6c725b..b4a155e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2131,6 +2131,9 @@ namespace OpenSim.Region.Framework.Scenes
// Can't do this yet since backup still makes use of the root part without any synchronization
// objectGroup.m_rootPart = null;
+ // If linking prims with different permissions, fix them
+ AdjustChildPrimPermissions();
+
AttachToBackup();
// Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
@@ -2622,12 +2625,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public void AdjustChildPrimPermissions()
+ {
+ ForEachPart(part =>
+ {
+ if (part != RootPart)
+ part.ClonePermissions(RootPart);
+ });
+ }
+
public void UpdatePermissions(UUID AgentID, byte field, uint localID,
uint mask, byte addRemTF)
{
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].UpdatePermissions(AgentID, field, localID, mask, addRemTF);
+ RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF);
+
+ AdjustChildPrimPermissions();
HasGroupChanged = true;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2a9ee3a..411dcc7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3890,6 +3890,27 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public void ClonePermissions(SceneObjectPart source)
+ {
+ bool update = false;
+
+ if (BaseMask != source.BaseMask ||
+ OwnerMask != source.OwnerMask ||
+ GroupMask != source.GroupMask ||
+ EveryoneMask != source.EveryoneMask ||
+ NextOwnerMask != source.NextOwnerMask)
+ update = true;
+
+ BaseMask = source.BaseMask;
+ OwnerMask = source.OwnerMask;
+ GroupMask = source.GroupMask;
+ EveryoneMask = source.EveryoneMask;
+ NextOwnerMask = source.NextOwnerMask;
+
+ if (update)
+ SendFullUpdateToAllClients();
+ }
+
public bool IsHingeJoint()
{
// For now, we use the NINJA naming scheme for identifying joints.
--
cgit v1.1
From 2ad9d656b3a1a0c519c9599d7680f98eba7e82b8 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 10 Aug 2012 15:58:29 +0100
Subject: implementing function to allow scripts to self-replicate as if the
owner duplicated them, using the same script delay as llRezObject()
---
.../Shared/Api/Implementation/OSSL_Api.cs | 50 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 7 +++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++
3 files changed, 62 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 5e7c2d9..119c2ac 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3344,5 +3344,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
}
+
+ public void osRezDuplicate(LSL_Vector offset, LSL_Rotation rot)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osRezDuplicate");
+ m_host.AddScriptLPS(1);
+
+ Vector3 v = new Vector3((float)offset.x, (float)offset.y, (float)offset.z);
+ Quaternion r = new Quaternion(
+ (float)rot.x,
+ (float)rot.y,
+ (float)rot.z,
+ (float)rot.s
+ );
+
+ Vector3 destination = m_host.ParentGroup.AbsolutePosition + v;
+
+ if (!World.Permissions.CanRezObject(
+ m_host.ParentGroup.PrimCount,
+ m_host.OwnerID,
+ destination
+ ))
+ {
+ OSSLShoutError("Cannot duplicate object to destination, owner cannot rez objects at destination parcel.");
+
+ ScriptSleep(100);
+ }
+ else
+ {
+ SceneObjectGroup duplicate = World.SceneGraph.DuplicateObject(
+ m_host.ParentGroup.LocalId,
+ v,
+ m_host.ParentGroup.RootPart.GetEffectiveObjectFlags(),
+ m_host.OwnerID,
+ m_host.GroupID,
+ r
+ );
+
+ m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
+ "object_rez", new Object[] {
+ new LSL_String(
+ duplicate.RootPart.UUID.ToString()) },
+ new DetectParams[0]));
+
+ ScriptSleep(100);
+ m_ScriptEngine.PostObjectEvent(duplicate.LocalId, new EventParams(
+ "on_rez", new Object[]{
+ new LSL_Integer(0)},
+ new DetectParams[0]));
+ }
+ }
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 9ad1c22..8c90df4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -306,5 +306,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
///
/// Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.
LSL_Key osGetRezzingObject();
+
+ ///
+ /// Duplicates an object as if the owner duplicated it.
+ ///
+ ///
+ ///
+ void osRezDuplicate(vector offset, rotation rot);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index e9131e4..9a2f859 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -955,5 +955,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRezzingObject();
}
+
+ public void osRezDuplicate(vector offset, rotation rot)
+ {
+ m_OSSL_Functions.osRezDuplicate(offset, rot);
+ }
}
}
--
cgit v1.1
From a08687aef35079f6c2884d3ae6fd8307ca8a6b0d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 24 Aug 2012 01:18:35 +0100
Subject: Revert "implementing function to allow scripts to self-replicate as
if the owner duplicated them, using the same script delay as llRezObject()"
This reverts commit 2ad9d656b3a1a0c519c9599d7680f98eba7e82b8.
Reverted pending consideration of associated issues.
---
.../Shared/Api/Implementation/OSSL_Api.cs | 50 ----------------------
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 7 ---
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 ---
3 files changed, 62 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 119c2ac..5e7c2d9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3344,55 +3344,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
}
-
- public void osRezDuplicate(LSL_Vector offset, LSL_Rotation rot)
- {
- CheckThreatLevel(ThreatLevel.High, "osRezDuplicate");
- m_host.AddScriptLPS(1);
-
- Vector3 v = new Vector3((float)offset.x, (float)offset.y, (float)offset.z);
- Quaternion r = new Quaternion(
- (float)rot.x,
- (float)rot.y,
- (float)rot.z,
- (float)rot.s
- );
-
- Vector3 destination = m_host.ParentGroup.AbsolutePosition + v;
-
- if (!World.Permissions.CanRezObject(
- m_host.ParentGroup.PrimCount,
- m_host.OwnerID,
- destination
- ))
- {
- OSSLShoutError("Cannot duplicate object to destination, owner cannot rez objects at destination parcel.");
-
- ScriptSleep(100);
- }
- else
- {
- SceneObjectGroup duplicate = World.SceneGraph.DuplicateObject(
- m_host.ParentGroup.LocalId,
- v,
- m_host.ParentGroup.RootPart.GetEffectiveObjectFlags(),
- m_host.OwnerID,
- m_host.GroupID,
- r
- );
-
- m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
- "object_rez", new Object[] {
- new LSL_String(
- duplicate.RootPart.UUID.ToString()) },
- new DetectParams[0]));
-
- ScriptSleep(100);
- m_ScriptEngine.PostObjectEvent(duplicate.LocalId, new EventParams(
- "on_rez", new Object[]{
- new LSL_Integer(0)},
- new DetectParams[0]));
- }
- }
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 8c90df4..9ad1c22 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -306,12 +306,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
///
/// Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.
LSL_Key osGetRezzingObject();
-
- ///
- /// Duplicates an object as if the owner duplicated it.
- ///
- ///
- ///
- void osRezDuplicate(vector offset, rotation rot);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 9a2f859..e9131e4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -955,10 +955,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRezzingObject();
}
-
- public void osRezDuplicate(vector offset, rotation rot)
- {
- m_OSSL_Functions.osRezDuplicate(offset, rot);
- }
}
}
--
cgit v1.1
From 632908db9e4810a7f181e23b7188e81ec2f88bc3 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Mon, 20 Aug 2012 09:46:41 +0100
Subject: adding sqlite journal files to .gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 36a1757..bf3ac37 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@
bin/Debug/*.dll
bin/*.dll.mdb
bin/*.db
+bin/*.db-journal
bin/addin-db-*
bin/*.dll
bin/OpenSim.vshost.exe.config
--
cgit v1.1
From d188272462f2c8d3e67aead26bb5b15ab243cdab Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 13:52:30 +0100
Subject: refactoring using List.ConvertAll
---
.../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0d275f7..a98fb04 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5170,17 +5170,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
string ret = String.Empty;
- int x = 0;
m_host.AddScriptLPS(1);
if (src.Data.Length > 0)
{
- ret = src.Data[x++].ToString();
- for (; x < src.Data.Length; x++)
- {
- ret += ", "+src.Data[x].ToString();
- }
+ ret = string.Join(", ",
+ (new List
public void StartScripts()
{
- m_log.InfoFormat("[SCENE]: Starting scripts in {0}, please wait.", RegionInfo.RegionName);
+// m_log.InfoFormat("[SCENE]: Starting scripts in {0}, please wait.", RegionInfo.RegionName);
IScriptModule[] engines = RequestModuleInterfaces();
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 5a3f002..0460f22 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -923,6 +923,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// This delay exists to stop mono problems where script compilation and startup would stop the sim
// working properly for the session.
System.Threading.Thread.Sleep(m_StartDelay);
+
+ m_log.InfoFormat("[XEngine]: Performing initial script startup on {0}", m_Scene.Name);
}
object[] o;
@@ -938,13 +940,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (m_InitialStartup)
if (scriptsStarted % 50 == 0)
m_log.InfoFormat(
- "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
+ "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.Name);
}
}
if (m_InitialStartup)
m_log.InfoFormat(
- "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
+ "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.Name);
// NOTE: Despite having a lockless queue, this lock is required
// to make sure there is never no compile thread while there
--
cgit v1.1
From e04047152f2d3ea7f52f746ab2ddac3328c8e97d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 25 Aug 2012 00:49:38 +0100
Subject: minor: Fix bad log message for failure to create an inventory folder
---
OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 2701d6e..6e53951 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -468,7 +468,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!InventoryService.AddFolder(folder))
{
m_log.WarnFormat(
- "[AGENT INVENTORY]: Failed to move create folder for user {0} {1}",
+ "[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
remoteClient.Name, remoteClient.AgentId);
}
}
--
cgit v1.1
From f8a89a79eb8ae8cc2bfdcbbf2cb498e5293162c3 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 25 Aug 2012 01:09:12 +0100
Subject: Allow multiple calling card type inventory folders to be created.
Modern viewers want to create Friends and All folders of this type inside the root Calling Cards folder.
---
OpenSim/Services/InventoryService/XInventoryService.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index 7518b86..e10e0be 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -311,6 +311,7 @@ namespace OpenSim.Services.InventoryService
if (folder.Type == (short)AssetType.Folder
|| folder.Type == (short)AssetType.Unknown
|| folder.Type == (short)AssetType.OutfitFolder
+ || folder.Type == (short)AssetType.CallingCard
|| GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null)
{
XInventoryFolder xFolder = ConvertFromOpenSim(folder);
--
cgit v1.1
From a0d178b284050df64d0eb5b9728565fd72615c22 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 25 Aug 2012 02:00:17 +0100
Subject: Following on from f8a89a79, do not allow more than one 'type' folder
(e.g. calling cards) to be created in the base "My Inventory" user folder.
This is to accomodate situations where viewers will create more than one 'type' subfolder (e.g. calling cards)
But at the same time to prevent multiple such 'system' folders (those in the base "My Inventory" user folder).
This also makes GetFolderForType() only return a folder in the base "My Inventory" folder, if such a type folder exists
---
.../Services/InventoryService/XInventoryService.cs | 65 ++++++++++++++++------
1 file changed, 49 insertions(+), 16 deletions(-)
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index e10e0be..deacd5a 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -229,10 +229,28 @@ namespace OpenSim.Services.InventoryService
public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
{
// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
+
+ InventoryFolderBase rootFolder = GetRootFolder(principalID);
+
+ if (rootFolder == null)
+ {
+ m_log.WarnFormat(
+ "[XINVENTORY]: Found no root folder for {0} in GetFolderForType() when looking for {1}",
+ principalID, type);
+
+ return null;
+ }
+
+ return GetSystemFolderForType(rootFolder, type);
+ }
+
+ private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type)
+ {
+// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
XInventoryFolder[] folders = m_Database.GetFolders(
- new string[] { "agentID", "type"},
- new string[] { principalID.ToString(), ((int)type).ToString() });
+ new string[] { "agentID", "parentFolderID", "type"},
+ new string[] { rootFolder.Owner.ToString(), rootFolder.ID.ToString(), ((int)type).ToString() });
if (folders.Length == 0)
{
@@ -308,23 +326,38 @@ namespace OpenSim.Services.InventoryService
if (check != null)
return false;
- if (folder.Type == (short)AssetType.Folder
- || folder.Type == (short)AssetType.Unknown
- || folder.Type == (short)AssetType.OutfitFolder
- || folder.Type == (short)AssetType.CallingCard
- || GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null)
- {
- XInventoryFolder xFolder = ConvertFromOpenSim(folder);
- return m_Database.StoreFolder(xFolder);
- }
- else
+ if (folder.Type != (short)AssetType.Folder || folder.Type != (short)AssetType.Unknown)
{
- m_log.WarnFormat(
- "[XINVENTORY]: Folder of type {0} already exists when tried to add {1} to {2} for {3}",
- folder.Type, folder.Name, folder.ParentID, folder.Owner);
+ InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
+
+ if (rootFolder == null)
+ {
+ m_log.WarnFormat(
+ "[XINVENTORY]: Found no root folder for {0} in AddFolder() when looking for {1}",
+ folder.Owner, folder.Type);
+
+ return false;
+ }
+
+ // Check we're not trying to add this as a system folder.
+ if (folder.ParentID == rootFolder.ID)
+ {
+ InventoryFolderBase existingSystemFolder
+ = GetSystemFolderForType(rootFolder, (AssetType)folder.Type);
+
+ if (existingSystemFolder != null)
+ {
+ m_log.WarnFormat(
+ "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}",
+ folder.Type, folder.Name, folder.ParentID, folder.Owner);
+
+ return false;
+ }
+ }
}
- return false;
+ XInventoryFolder xFolder = ConvertFromOpenSim(folder);
+ return m_Database.StoreFolder(xFolder);
}
public virtual bool UpdateFolder(InventoryFolderBase folder)
--
cgit v1.1
From 3d504261b0e189f8111912a3fff9d45579c04eed Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 16:35:59 +0100
Subject: renaming to be similar to equivalent Set command
---
.../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 10 +++++-----
.../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++--
OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2bfb9b3..c706f48 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7910,7 +7910,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List llGetPrimitiveParams(LSL_List rules)
{
m_host.AddScriptLPS(1);
- return GetLinkPrimitiveParams(m_host, rules);
+ return GetPrimParams(m_host, rules);
}
public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules)
@@ -7923,14 +7923,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
foreach (var part in parts)
{
- LSL_List partRes = GetLinkPrimitiveParams(part, rules);
+ LSL_List partRes = GetPrimParams(part, rules);
res += partRes;
}
return res;
}
- public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules)
+ public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules)
{
LSL_List res = new LSL_List();
int idx=0;
@@ -10752,7 +10752,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
+ public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
{
SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
if (obj == null)
@@ -10761,7 +10761,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj.OwnerID != m_host.OwnerID)
return new LSL_List();
- return GetLinkPrimitiveParams(obj, rules);
+ return GetPrimParams(obj, rules);
}
public void print(string str)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 5e7c2d9..c277708 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2250,7 +2250,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
- retVal += ((LSL_Api)m_LSL_Api).GetLinkPrimitiveParams(part, rules);
+ retVal += ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules);
}
return retVal;
}
@@ -2965,7 +2965,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
InitLSL();
- return m_LSL_Api.GetLinkPrimitiveParamsEx(prim, rules);
+ return m_LSL_Api.GetPrimitiveParamsEx(prim, rules);
}
public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 3fb463b..cd58614 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -425,6 +425,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void print(string str);
void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
- LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
+ LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
}
}
--
cgit v1.1
From 6e86b230120776a7da4727dd1aedeca6b91e3169 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 17:44:39 +0100
Subject: implementing PRIM_LINK_TARGET on GetPrimParams ala SetPrimParams
---
.../Shared/Api/Implementation/LSL_Api.cs | 58 ++++++++++++++++++----
.../Shared/Api/Implementation/OSSL_Api.cs | 13 ++++-
2 files changed, 60 insertions(+), 11 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0f0eac6..b001c51 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7913,7 +7913,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_List result = new LSL_List();
- GetPrimParams(m_host, rules, ref result);
+ LSL_List remaining = GetPrimParams(m_host, rules, ref result);
+
+ while (remaining != null && remaining.Length > 2)
+ {
+ int linknumber = remaining.GetLSLIntegerItem(0);
+ rules = remaining.GetSublist(1, -1);
+ List parts = GetLinkParts(linknumber);
+
+ foreach (SceneObjectPart part in parts)
+ remaining = GetPrimParams(part, rules, ref result);
+ }
return result;
}
@@ -7925,16 +7935,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = GetLinkParts(linknumber);
LSL_List res = new LSL_List();
+ LSL_List remaining = null;
foreach (SceneObjectPart part in parts)
{
- GetPrimParams(part, rules, ref res);
+ remaining = GetPrimParams(part, rules, ref res);
+ }
+
+ while (remaining != null && remaining.Length > 2)
+ {
+ linknumber = remaining.GetLSLIntegerItem(0);
+ rules = remaining.GetSublist(1, -1);
+ parts = GetLinkParts(linknumber);
+
+ foreach (SceneObjectPart part in parts)
+ remaining = GetPrimParams(part, rules, ref res);
}
return res;
}
- public void GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res)
+ public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res)
{
int idx=0;
while (idx < rules.Length)
@@ -8080,7 +8101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 1)
- return;
+ return null;
int face = (int)rules.GetLSLIntegerItem(idx++);
Primitive.TextureEntry tex = part.Shape.Textures;
@@ -8120,7 +8141,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_COLOR:
if (remain < 1)
- return;
+ return null;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8149,7 +8170,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 1)
- return;
+ return null;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8180,7 +8201,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 1)
- return;
+ return null;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8222,7 +8243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXGEN:
if (remain < 1)
- return;
+ return null;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8263,7 +8284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 1)
- return;
+ return null;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8315,8 +8336,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
0
));
break;
+ case (int)ScriptBaseClass.PRIM_LINK_TARGET:
+ if(remain < 3)
+ return null;
+
+ return rules.GetSublist(idx, -1);
}
}
+
+ return null;
}
public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
@@ -10762,7 +10790,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj != null && obj.OwnerID != m_host.OwnerID)
{
- GetPrimParams(obj, rules, ref result);
+ LSL_List remaining = GetPrimParams(obj, rules, ref result);
+
+ while (remaining != null && remaining.Length > 2)
+ {
+ int linknumber = remaining.GetLSLIntegerItem(0);
+ rules = remaining.GetSublist(1, -1);
+ List parts = GetLinkParts(linknumber);
+
+ foreach (SceneObjectPart part in parts)
+ remaining = GetPrimParams(part, rules, ref result);
+ }
}
return result;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 927f37c..1afa4fb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2250,10 +2250,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// on the ILSL_Api interface.
LSL_Api LSL_Api = (LSL_Api)m_LSL_Api;
LSL_List retVal = new LSL_List();
+ LSL_List remaining = null;
List parts = LSL_Api.GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
- LSL_Api.GetPrimParams(part, rules, ref retVal);
+ remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
+ }
+
+ while (remaining != null && remaining.Length > 2)
+ {
+ linknumber = remaining.GetLSLIntegerItem(0);
+ rules = remaining.GetSublist(1, -1);
+ parts = LSL_Api.GetLinkParts(linknumber);
+
+ foreach (SceneObjectPart part in parts)
+ remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
}
return retVal;
}
--
cgit v1.1
From a8044999fb056de0a815093953f82b33d540dd6f Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 16:41:43 +0100
Subject: use SceneObjectPart instead of var
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c706f48..03b5982 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5828,7 +5828,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = GetLinkParts(linknumber);
- foreach (var part in parts)
+ foreach (SceneObjectPart part in parts)
{
SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
}
@@ -6190,7 +6190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = GetLinkParts(linknumber);
- foreach (var part in parts)
+ foreach (SceneObjectPart part in parts)
{
SetParticleSystem(part, rules);
}
@@ -7921,7 +7921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_List res = new LSL_List();
- foreach (var part in parts)
+ foreach (SceneObjectPart part in parts)
{
LSL_List partRes = GetPrimParams(part, rules);
res += partRes;
--
cgit v1.1
From 2a2e120470ea530ea0a6f035c5cf28247f94532c Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 17:02:13 +0100
Subject: since we will be making the Get return type the remaining ruleset as
with the Set return type, we need to move the original return type to a ref
param
---
.../Shared/Api/Implementation/LSL_Api.cs | 38 ++++++++++++----------
.../Shared/Api/Implementation/OSSL_Api.cs | 2 +-
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 03b5982..6e46992 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7910,7 +7910,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List llGetPrimitiveParams(LSL_List rules)
{
m_host.AddScriptLPS(1);
- return GetPrimParams(m_host, rules);
+
+ LSL_List result = new LSL_List();
+
+ GetPrimParams(m_host, rules, ref result);
+
+ return result;
}
public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules)
@@ -7923,16 +7928,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
foreach (SceneObjectPart part in parts)
{
- LSL_List partRes = GetPrimParams(part, rules);
- res += partRes;
+ GetPrimParams(part, rules, ref res);
}
return res;
}
- public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules)
+ public void GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res)
{
- LSL_List res = new LSL_List();
int idx=0;
while (idx < rules.Length)
{
@@ -8077,7 +8080,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 1)
- return res;
+ return;
int face = (int)rules.GetLSLIntegerItem(idx++);
Primitive.TextureEntry tex = part.Shape.Textures;
@@ -8117,7 +8120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_COLOR:
if (remain < 1)
- return res;
+ return;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8146,7 +8149,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 1)
- return res;
+ return;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8177,7 +8180,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 1)
- return res;
+ return;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8219,7 +8222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXGEN:
if (remain < 1)
- return res;
+ return;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8260,7 +8263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 1)
- return res;
+ return;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8314,7 +8317,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
}
}
- return res;
}
public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
@@ -10755,13 +10757,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
{
SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
- if (obj == null)
- return new LSL_List();
- if (obj.OwnerID != m_host.OwnerID)
- return new LSL_List();
+ LSL_List result = new LSL_List();
- return GetPrimParams(obj, rules);
+ if (obj != null && obj.OwnerID != m_host.OwnerID)
+ {
+ GetPrimParams(obj, rules, ref result);
+ }
+
+ return result;
}
public void print(string str)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index c277708..a391b73 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2250,7 +2250,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
- retVal += ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules);
+ ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules, ref retVal);
}
return retVal;
}
--
cgit v1.1
From 5203665bb2d68c6a4e0ea3180334b607db6ab1ce Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 17:25:37 +0100
Subject: refactoring to local variable for cleaner code
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index a391b73..927f37c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2246,11 +2246,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
m_host.AddScriptLPS(1);
InitLSL();
+ // One needs to cast m_LSL_Api because we're using functions not
+ // on the ILSL_Api interface.
+ LSL_Api LSL_Api = (LSL_Api)m_LSL_Api;
LSL_List retVal = new LSL_List();
- List parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber);
+ List parts = LSL_Api.GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
- ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules, ref retVal);
+ LSL_Api.GetPrimParams(part, rules, ref retVal);
}
return retVal;
}
--
cgit v1.1
From 58714b0aca71ce026226c6f76753905877792caf Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 17:44:28 +0100
Subject: minor formatting
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6e46992..0f0eac6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7238,10 +7238,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
foreach (SceneObjectPart part in parts)
remaining = SetPrimParams(part, rules);
- while(remaining != null && remaining.Length > 2)
+ while (remaining != null && remaining.Length > 2)
{
linknumber = remaining.GetLSLIntegerItem(0);
- rules = remaining.GetSublist(1,-1);
+ rules = remaining.GetSublist(1, -1);
parts = GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
--
cgit v1.1
From 6ea95a329451c803048f179abb4b4ea5014dd7b1 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 25 Aug 2012 17:32:00 +0100
Subject: Fix and refactor region registration. Reorder checks to short-curcuit
expensive and destructive ones. Properly fix region reservation and
authentication. Make region moves and flags preservation work again as
intended. Prevent failes reservation take-over from damging reservation data.
---
OpenSim/Services/GridService/GridService.cs | 53 +++++++++++++++--------------
1 file changed, 28 insertions(+), 25 deletions(-)
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index aab403a..5bdea06 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -137,9 +137,14 @@ namespace OpenSim.Services.GridService
if (regionInfos.RegionID == UUID.Zero)
return "Invalid RegionID - cannot be zero UUID";
- // This needs better sanity testing. What if regionInfo is registering in
- // overlapping coords?
RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
+ if ((region != null) && (region.RegionID != regionInfos.RegionID))
+ {
+ m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
+ regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
+ return "Region overlaps another region";
+ }
+
if (region != null)
{
// There is a preexisting record
@@ -176,19 +181,36 @@ namespace OpenSim.Services.GridService
}
}
- if ((region != null) && (region.RegionID != regionInfos.RegionID))
+ // If we get here, the destination is clear. Now for the real check.
+
+ if (!m_AllowDuplicateNames)
{
- m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
- regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
- return "Region overlaps another region";
+ List dupe = m_Database.Get(regionInfos.RegionName, scopeID);
+ if (dupe != null && dupe.Count > 0)
+ {
+ foreach (RegionData d in dupe)
+ {
+ if (d.RegionID != regionInfos.RegionID)
+ {
+ m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.",
+ regionInfos.RegionName, regionInfos.RegionID);
+ return "Duplicate region name";
+ }
+ }
+ }
}
+ // If there is an old record for us, delete it if it is elsewhere.
+ region = m_Database.Get(regionInfos.RegionID, scopeID);
if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
{
if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0)
return "Can't move this region";
+ if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0)
+ return "Region locked out";
+
// Region reregistering in other coordinates. Delete the old entry
m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.",
regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY);
@@ -203,23 +225,6 @@ namespace OpenSim.Services.GridService
}
}
- if (!m_AllowDuplicateNames)
- {
- List dupe = m_Database.Get(regionInfos.RegionName, scopeID);
- if (dupe != null && dupe.Count > 0)
- {
- foreach (RegionData d in dupe)
- {
- if (d.RegionID != regionInfos.RegionID)
- {
- m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.",
- regionInfos.RegionName, regionInfos.RegionID);
- return "Duplicate region name";
- }
- }
- }
- }
-
// Everything is ok, let's register
RegionData rdata = RegionInfo2RegionData(regionInfos);
rdata.ScopeID = scopeID;
@@ -227,8 +232,6 @@ namespace OpenSim.Services.GridService
if (region != null)
{
int oldFlags = Convert.ToInt32(region.Data["flags"]);
- if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0)
- return "Region locked out";
oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation;
--
cgit v1.1
From 1eb1c1bd4bc972e2df301b9dafb40fbb2f37b40c Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 25 Aug 2012 18:19:51 +0100
Subject: renaming to be similar to equivalent Set command
Conflicts:
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
---
OpenSim/Region/Framework/Scenes/Scene.cs | 2 +-
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 14 +++++++-------
.../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++--
.../Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 2 +-
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index fcc2953..5b529c3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3737,7 +3737,7 @@ namespace OpenSim.Region.Framework.Scenes
"[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
sp.Name, sp.UUID, RegionInfo.RegionName);
- sp.ControllingClient.Close(true);
+ sp.ControllingClient.Close(true, true);
sp = null;
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 5386a28..c8b6a7e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -8821,7 +8821,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List llGetPrimitiveParams(LSL_List rules)
{
m_host.AddScriptLPS(1);
- return GetLinkPrimitiveParams(m_host, rules);
+ return GetPrimParams(m_host, rules);
}
public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules)
@@ -8840,7 +8840,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
foreach (var part in parts)
{
- LSL_List partRes = GetLinkPrimitiveParams(part, rules);
+ LSL_List partRes = GetPrimParams(part, rules);
res += partRes;
}
}
@@ -8848,14 +8848,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
foreach (ScenePresence avatar in avatars)
{
- LSL_List avaRes = GetLinkPrimitiveParams(avatar, rules);
+ LSL_List avaRes = GetPrimParams(avatar, rules);
res += avaRes;
}
}
return res;
}
- public LSL_List GetLinkPrimitiveParams(ScenePresence avatar, LSL_List rules)
+ public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules)
{
// avatars case
// replies as SL wiki
@@ -9116,7 +9116,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
}
- public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules)
+ public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules)
{
LSL_List res = new LSL_List();
int idx=0;
@@ -12104,7 +12104,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
+ public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
{
SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
if (obj == null)
@@ -12113,7 +12113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj.OwnerID != m_host.OwnerID)
return new LSL_List();
- return GetLinkPrimitiveParams(obj, rules);
+ return GetPrimParams(obj, rules);
}
public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index a81c39c..7b71a24 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2261,7 +2261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
- retVal += ((LSL_Api)m_LSL_Api).GetLinkPrimitiveParams(part, rules);
+ retVal += ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules);
}
return retVal;
}
@@ -3013,7 +3013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
InitLSL();
- return m_LSL_Api.GetLinkPrimitiveParamsEx(prim, rules);
+ return m_LSL_Api.GetPrimitiveParamsEx(prim, rules);
}
public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index af35258..e08328f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -430,7 +430,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density);
void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
- LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
void llSetKeyframedMotion(LSL_List frames, LSL_List options);
+ LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
}
}
--
cgit v1.1
From af6b2420718447a534e1ceedea366fc1dbf29dd7 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 25 Aug 2012 18:24:52 +0100
Subject: use SceneObjectPart instead of var
Conflicts:
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
---
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c8b6a7e..7b52ea3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6252,19 +6252,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
List parts = GetLinkParts(linknumber);
- if (parts.Count > 0)
+
+ try
{
- try
- {
- foreach (var part in parts)
- {
- SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
- }
- }
- finally
+ foreach (SceneObjectPart part in parts)
{
+ SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
}
}
+ finally
+ {
+ }
}
private void SetTextureAnim(SceneObjectPart part, int mode, int face, int sizex, int sizey, double start, double length, double rate)
@@ -6658,7 +6656,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = GetLinkParts(linknumber);
- foreach (var part in parts)
+ foreach (SceneObjectPart part in parts)
{
SetParticleSystem(part, rules);
}
--
cgit v1.1
From 5f1021faa6b8196878604ea2f8af57bceeb41ba6 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 25 Aug 2012 18:28:05 +0100
Subject: Temprary restructure to avoid conflicts
---
.../Shared/Api/Implementation/LSL_Api.cs | 366 ++++++++++-----------
1 file changed, 183 insertions(+), 183 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7b52ea3..2bdb485 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7817,189 +7817,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new Vector3((float)x, (float)y, (float)z);
}
- protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules)
- {
- //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
-
- int idx = 0;
-
- bool positionChanged = false;
- Vector3 finalPos = Vector3.Zero;
-
- try
- {
- while (idx < rules.Length)
- {
- int code = rules.GetLSLIntegerItem(idx++);
-
- int remain = rules.Length - idx;
-
- switch (code)
- {
- case (int)ScriptBaseClass.PRIM_POSITION:
- case (int)ScriptBaseClass.PRIM_POS_LOCAL:
- {
- if (remain < 1)
- return null;
-
- LSL_Vector v;
- v = rules.GetVector3Item(idx++);
-
- SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
- if (part == null)
- break;
-
- LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
- LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
- if (part.LinkNum > 1)
- {
- localRot = GetPartLocalRot(part);
- localPos = GetPartLocalPos(part);
- }
-
- v -= localPos;
- v /= localRot;
-
- LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
-
- v = v + 2 * sitOffset;
-
- av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
- av.SendAvatarDataToAllAgents();
-
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
- case (int)ScriptBaseClass.PRIM_ROTATION:
- {
- if (remain < 1)
- return null;
-
- LSL_Rotation r;
- r = rules.GetQuaternionItem(idx++);
-
- SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
- if (part == null)
- break;
-
- LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
- LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
-
- if (part.LinkNum > 1)
- localRot = GetPartLocalRot(part);
-
- r = r * llGetRootRotation() / localRot;
- av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
- av.SendAvatarDataToAllAgents();
- }
- break;
-
- // parse rest doing nothing but number of parameters error check
- case (int)ScriptBaseClass.PRIM_SIZE:
- case (int)ScriptBaseClass.PRIM_MATERIAL:
- case (int)ScriptBaseClass.PRIM_PHANTOM:
- case (int)ScriptBaseClass.PRIM_PHYSICS:
- case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
- case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
- case (int)ScriptBaseClass.PRIM_NAME:
- case (int)ScriptBaseClass.PRIM_DESC:
- if (remain < 1)
- return null;
- idx++;
- break;
-
- case (int)ScriptBaseClass.PRIM_GLOW:
- case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
- case (int)ScriptBaseClass.PRIM_TEXGEN:
- if (remain < 2)
- return null;
- idx += 2;
- break;
-
- case (int)ScriptBaseClass.PRIM_TYPE:
- if (remain < 3)
- return null;
- code = (int)rules.GetLSLIntegerItem(idx++);
- remain = rules.Length - idx;
- switch (code)
- {
- case (int)ScriptBaseClass.PRIM_TYPE_BOX:
- case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
- case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
- if (remain < 6)
- return null;
- idx += 6;
- break;
-
- case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
- if (remain < 5)
- return null;
- idx += 5;
- break;
-
- case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
- case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
- case (int)ScriptBaseClass.PRIM_TYPE_RING:
- if (remain < 11)
- return null;
- idx += 11;
- break;
-
- case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
- if (remain < 2)
- return null;
- idx += 2;
- break;
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_COLOR:
- case (int)ScriptBaseClass.PRIM_TEXT:
- case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
- case (int)ScriptBaseClass.PRIM_OMEGA:
- if (remain < 3)
- return null;
- idx += 3;
- break;
-
- case (int)ScriptBaseClass.PRIM_TEXTURE:
- case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
- case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
- if (remain < 5)
- return null;
- idx += 5;
- break;
-
- case (int)ScriptBaseClass.PRIM_FLEXIBLE:
- if (remain < 7)
- return null;
-
- idx += 7;
- break;
-
- case (int)ScriptBaseClass.PRIM_LINK_TARGET:
- if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
- return null;
-
- return rules.GetSublist(idx, -1);
- }
- }
- }
-
- finally
- {
- if (positionChanged)
- {
- av.OffsetPosition = finalPos;
-// av.SendAvatarDataToAllAgents();
- av.SendTerseUpdateToAllClients();
- positionChanged = false;
- }
- }
- return null;
- }
-
protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules)
{
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
@@ -13152,5 +12969,188 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_Notecards.Remove(key);
}
}
+
+ protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules)
+ {
+ //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
+
+ int idx = 0;
+
+ bool positionChanged = false;
+ Vector3 finalPos = Vector3.Zero;
+
+ try
+ {
+ while (idx < rules.Length)
+ {
+ int code = rules.GetLSLIntegerItem(idx++);
+
+ int remain = rules.Length - idx;
+
+ switch (code)
+ {
+ case (int)ScriptBaseClass.PRIM_POSITION:
+ case (int)ScriptBaseClass.PRIM_POS_LOCAL:
+ {
+ if (remain < 1)
+ return null;
+
+ LSL_Vector v;
+ v = rules.GetVector3Item(idx++);
+
+ SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
+ if (part == null)
+ break;
+
+ LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
+ LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
+ if (part.LinkNum > 1)
+ {
+ localRot = GetPartLocalRot(part);
+ localPos = GetPartLocalPos(part);
+ }
+
+ v -= localPos;
+ v /= localRot;
+
+ LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
+
+ v = v + 2 * sitOffset;
+
+ av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
+ av.SendAvatarDataToAllAgents();
+
+ }
+ break;
+
+ case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
+ case (int)ScriptBaseClass.PRIM_ROTATION:
+ {
+ if (remain < 1)
+ return null;
+
+ LSL_Rotation r;
+ r = rules.GetQuaternionItem(idx++);
+
+ SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
+ if (part == null)
+ break;
+
+ LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
+ LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
+
+ if (part.LinkNum > 1)
+ localRot = GetPartLocalRot(part);
+
+ r = r * llGetRootRotation() / localRot;
+ av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
+ av.SendAvatarDataToAllAgents();
+ }
+ break;
+
+ // parse rest doing nothing but number of parameters error check
+ case (int)ScriptBaseClass.PRIM_SIZE:
+ case (int)ScriptBaseClass.PRIM_MATERIAL:
+ case (int)ScriptBaseClass.PRIM_PHANTOM:
+ case (int)ScriptBaseClass.PRIM_PHYSICS:
+ case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
+ case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
+ case (int)ScriptBaseClass.PRIM_NAME:
+ case (int)ScriptBaseClass.PRIM_DESC:
+ if (remain < 1)
+ return null;
+ idx++;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_GLOW:
+ case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
+ case (int)ScriptBaseClass.PRIM_TEXGEN:
+ if (remain < 2)
+ return null;
+ idx += 2;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE:
+ if (remain < 3)
+ return null;
+ code = (int)rules.GetLSLIntegerItem(idx++);
+ remain = rules.Length - idx;
+ switch (code)
+ {
+ case (int)ScriptBaseClass.PRIM_TYPE_BOX:
+ case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
+ case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
+ if (remain < 6)
+ return null;
+ idx += 6;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
+ if (remain < 5)
+ return null;
+ idx += 5;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
+ case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
+ case (int)ScriptBaseClass.PRIM_TYPE_RING:
+ if (remain < 11)
+ return null;
+ idx += 11;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
+ if (remain < 2)
+ return null;
+ idx += 2;
+ break;
+ }
+ break;
+
+ case (int)ScriptBaseClass.PRIM_COLOR:
+ case (int)ScriptBaseClass.PRIM_TEXT:
+ case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
+ case (int)ScriptBaseClass.PRIM_OMEGA:
+ if (remain < 3)
+ return null;
+ idx += 3;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TEXTURE:
+ case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
+ case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
+ if (remain < 5)
+ return null;
+ idx += 5;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_FLEXIBLE:
+ if (remain < 7)
+ return null;
+
+ idx += 7;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_LINK_TARGET:
+ if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
+ return null;
+
+ return rules.GetSublist(idx, -1);
+ }
+ }
+ }
+
+ finally
+ {
+ if (positionChanged)
+ {
+ av.OffsetPosition = finalPos;
+// av.SendAvatarDataToAllAgents();
+ av.SendTerseUpdateToAllClients();
+ positionChanged = false;
+ }
+ }
+ return null;
+ }
}
}
--
cgit v1.1
From 681066050c2f7019d1b425c86f7985d7650d8226 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 25 Aug 2012 18:32:59 +0100
Subject: Also move the other avatar based overload out of harms way
---
.../Shared/Api/Implementation/LSL_Api.cs | 1430 ++++++++++----------
1 file changed, 715 insertions(+), 715 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2bdb485..64f145b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -8670,75 +8670,142 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
}
- public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules)
+ public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules)
{
- // avatars case
- // replies as SL wiki
-
LSL_List res = new LSL_List();
-// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
- SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
-
- int idx = 0;
+ int idx=0;
while (idx < rules.Length)
{
- int code = (int)rules.GetLSLIntegerItem(idx++);
- int remain = rules.Length - idx;
+ int code=(int)rules.GetLSLIntegerItem(idx++);
+ int remain=rules.Length-idx;
switch (code)
{
case (int)ScriptBaseClass.PRIM_MATERIAL:
- res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh));
+ res.Add(new LSL_Integer(part.Material));
break;
case (int)ScriptBaseClass.PRIM_PHYSICS:
+ if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) != 0)
+ res.Add(new LSL_Integer(1));
+ else
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
+ if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) != 0)
+ res.Add(new LSL_Integer(1));
+ else
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_PHANTOM:
+ if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0)
+ res.Add(new LSL_Integer(1));
+ else
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_POSITION:
-
- Vector3 pos = avatar.OffsetPosition;
-
- Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
- pos -= sitOffset;
-
- if( sitPart != null)
- pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
-
- res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
+ LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X,
+ part.AbsolutePosition.Y,
+ part.AbsolutePosition.Z);
+ res.Add(v);
break;
case (int)ScriptBaseClass.PRIM_SIZE:
- // as in llGetAgentSize above
- res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight));
+ res.Add(new LSL_Vector(part.Scale.X,
+ part.Scale.Y,
+ part.Scale.Z));
break;
case (int)ScriptBaseClass.PRIM_ROTATION:
- Quaternion rot = avatar.Rotation;
- if (sitPart != null)
- {
- rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation
- }
-
- res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W));
+ res.Add(GetPartRot(part));
break;
case (int)ScriptBaseClass.PRIM_TYPE:
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX));
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT));
- res.Add(new LSL_Vector(0f,1.0f,0f));
- res.Add(new LSL_Float(0.0f));
- res.Add(new LSL_Vector(0, 0, 0));
- res.Add(new LSL_Vector(1.0f,1.0f,0f));
- res.Add(new LSL_Vector(0, 0, 0));
+ // implementing box
+ PrimitiveBaseShape Shape = part.Shape;
+ int primType = (int)part.GetPrimType();
+ res.Add(new LSL_Integer(primType));
+ double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX
+ double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY.
+ switch (primType)
+ {
+ case ScriptBaseClass.PRIM_TYPE_BOX:
+ case ScriptBaseClass.PRIM_TYPE_CYLINDER:
+ case ScriptBaseClass.PRIM_TYPE_PRISM:
+ res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
+ res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
+ res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
+ res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
+ res.Add(new LSL_Vector(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0));
+ res.Add(new LSL_Vector(topshearx, topsheary, 0));
+ break;
+
+ case ScriptBaseClass.PRIM_TYPE_SPHERE:
+ res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
+ res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
+ res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
+ res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
+ res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
+ break;
+
+ case ScriptBaseClass.PRIM_TYPE_SCULPT:
+ res.Add(Shape.SculptTexture.ToString());
+ res.Add(new LSL_Integer(Shape.SculptType));
+ break;
+
+ case ScriptBaseClass.PRIM_TYPE_RING:
+ case ScriptBaseClass.PRIM_TYPE_TUBE:
+ case ScriptBaseClass.PRIM_TYPE_TORUS:
+ // holeshape
+ res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
+
+ // cut
+ res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
+
+ // hollow
+ res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
+
+ // twist
+ res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
+
+ // vector holesize
+ res.Add(new LSL_Vector(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0));
+
+ // vector topshear
+ res.Add(new LSL_Vector(topshearx, topsheary, 0));
+
+ // vector profilecut
+ res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
+
+ // vector tapera
+ res.Add(new LSL_Vector(Shape.PathTaperX / 100.0, Shape.PathTaperY / 100.0, 0));
+
+ // float revolutions
+ res.Add(new LSL_Float(Math.Round(Shape.PathRevolutions * 0.015d, 2, MidpointRounding.AwayFromZero)) + 1.0d);
+ // Slightly inaccurate, because an unsigned byte is being used to represent
+ // the entire range of floating-point values from 1.0 through 4.0 (which is how
+ // SL does it).
+ //
+ // Using these formulas to store and retrieve PathRevolutions, it is not
+ // possible to use all values between 1.00 and 4.00. For instance, you can't
+ // represent 1.10. You can represent 1.09 and 1.11, but not 1.10. So, if you
+ // use llSetPrimitiveParams to set revolutions to 1.10 and then retreive them
+ // with llGetPrimitiveParams, you'll retrieve 1.09. You can also see a similar
+ // behavior in the viewer as you cannot set 1.10. The viewer jumps to 1.11.
+ // In SL, llSetPrimitveParams and llGetPrimitiveParams can set and get a value
+ // such as 1.10. So, SL must store and retreive the actual user input rather
+ // than only storing the encoded value.
+
+ // float radiusoffset
+ res.Add(new LSL_Float(Shape.PathRadiusOffset / 100.0));
+
+ // float skew
+ res.Add(new LSL_Float(Shape.PathSkew / 100.0));
+ break;
+ }
break;
case (int)ScriptBaseClass.PRIM_TEXTURE:
@@ -8746,24 +8813,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
int face = (int)rules.GetLSLIntegerItem(idx++);
+ Primitive.TextureEntry tex = part.Shape.Textures;
if (face == ScriptBaseClass.ALL_SIDES)
{
- for (face = 0; face < 21; face++)
+ for (face = 0 ; face < GetNumberOfSides(part); face++)
{
- res.Add(new LSL_String(""));
- res.Add(new LSL_Vector(0,0,0));
- res.Add(new LSL_Vector(0,0,0));
- res.Add(new LSL_Float(0.0));
+ Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
+
+ res.Add(new LSL_String(texface.TextureID.ToString()));
+ res.Add(new LSL_Vector(texface.RepeatU,
+ texface.RepeatV,
+ 0));
+ res.Add(new LSL_Vector(texface.OffsetU,
+ texface.OffsetV,
+ 0));
+ res.Add(new LSL_Float(texface.Rotation));
}
}
else
{
- if (face >= 0 && face < 21)
+ if (face >= 0 && face < GetNumberOfSides(part))
{
- res.Add(new LSL_String(""));
- res.Add(new LSL_Vector(0,0,0));
- res.Add(new LSL_Vector(0,0,0));
- res.Add(new LSL_Float(0.0));
+ Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
+
+ res.Add(new LSL_String(texface.TextureID.ToString()));
+ res.Add(new LSL_Vector(texface.RepeatU,
+ texface.RepeatV,
+ 0));
+ res.Add(new LSL_Vector(texface.OffsetU,
+ texface.OffsetV,
+ 0));
+ res.Add(new LSL_Float(texface.Rotation));
}
}
break;
@@ -8772,20 +8852,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return res;
- face = (int)rules.GetLSLIntegerItem(idx++);
+ face=(int)rules.GetLSLIntegerItem(idx++);
+ tex = part.Shape.Textures;
+ Color4 texcolor;
if (face == ScriptBaseClass.ALL_SIDES)
{
- for (face = 0; face < 21; face++)
+ for (face = 0 ; face < GetNumberOfSides(part); face++)
{
- res.Add(new LSL_Vector(0,0,0));
- res.Add(new LSL_Float(0));
+ texcolor = tex.GetFace((uint)face).RGBA;
+ res.Add(new LSL_Vector(texcolor.R,
+ texcolor.G,
+ texcolor.B));
+ res.Add(new LSL_Float(texcolor.A));
}
}
else
{
- res.Add(new LSL_Vector(0,0,0));
- res.Add(new LSL_Float(0));
+ texcolor = tex.GetFace((uint)face).RGBA;
+ res.Add(new LSL_Vector(texcolor.R,
+ texcolor.G,
+ texcolor.B));
+ res.Add(new LSL_Float(texcolor.A));
}
break;
@@ -8794,18 +8882,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
+ tex = part.Shape.Textures;
+ int shiny;
if (face == ScriptBaseClass.ALL_SIDES)
{
- for (face = 0; face < 21; face++)
+ for (face = 0; face < GetNumberOfSides(part); face++)
{
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
+ Shininess shinyness = tex.GetFace((uint)face).Shiny;
+ if (shinyness == Shininess.High)
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
+ }
+ else if (shinyness == Shininess.Medium)
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
+ }
+ else if (shinyness == Shininess.Low)
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_LOW;
+ }
+ else
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_NONE;
+ }
+ res.Add(new LSL_Integer(shiny));
+ res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
}
}
else
{
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
+ Shininess shinyness = tex.GetFace((uint)face).Shiny;
+ if (shinyness == Shininess.High)
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
+ }
+ else if (shinyness == Shininess.Medium)
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
+ }
+ else if (shinyness == Shininess.Low)
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_LOW;
+ }
+ else
+ {
+ shiny = ScriptBaseClass.PRIM_SHINY_NONE;
+ }
+ res.Add(new LSL_Integer(shiny));
+ res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
}
break;
@@ -8814,27 +8938,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
+ tex = part.Shape.Textures;
+ int fullbright;
if (face == ScriptBaseClass.ALL_SIDES)
{
- for (face = 0; face < 21; face++)
+ for (face = 0; face < GetNumberOfSides(part); face++)
{
- res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
+ if (tex.GetFace((uint)face).Fullbright == true)
+ {
+ fullbright = ScriptBaseClass.TRUE;
+ }
+ else
+ {
+ fullbright = ScriptBaseClass.FALSE;
+ }
+ res.Add(new LSL_Integer(fullbright));
}
}
else
{
- res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
- }
+ if (tex.GetFace((uint)face).Fullbright == true)
+ {
+ fullbright = ScriptBaseClass.TRUE;
+ }
+ else
+ {
+ fullbright = ScriptBaseClass.FALSE;
+ }
+ res.Add(new LSL_Integer(fullbright));
+ }
break;
case (int)ScriptBaseClass.PRIM_FLEXIBLE:
- res.Add(new LSL_Integer(0));
- res.Add(new LSL_Integer(0));// softness
- res.Add(new LSL_Float(0.0f)); // gravity
- res.Add(new LSL_Float(0.0f)); // friction
- res.Add(new LSL_Float(0.0f)); // wind
- res.Add(new LSL_Float(0.0f)); // tension
- res.Add(new LSL_Vector(0f,0f,0f));
+ PrimitiveBaseShape shape = part.Shape;
+
+ if (shape.FlexiEntry)
+ res.Add(new LSL_Integer(1)); // active
+ else
+ res.Add(new LSL_Integer(0));
+ res.Add(new LSL_Integer(shape.FlexiSoftness));// softness
+ res.Add(new LSL_Float(shape.FlexiGravity)); // gravity
+ res.Add(new LSL_Float(shape.FlexiDrag)); // friction
+ res.Add(new LSL_Float(shape.FlexiWind)); // wind
+ res.Add(new LSL_Float(shape.FlexiTension)); // tension
+ res.Add(new LSL_Vector(shape.FlexiForceX, // force
+ shape.FlexiForceY,
+ shape.FlexiForceZ));
break;
case (int)ScriptBaseClass.PRIM_TEXGEN:
@@ -8843,25 +8992,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
+ tex = part.Shape.Textures;
if (face == ScriptBaseClass.ALL_SIDES)
{
- for (face = 0; face < 21; face++)
+ for (face = 0; face < GetNumberOfSides(part); face++)
{
+ if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
+ {
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
+ }
+ else
+ {
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
+ }
}
}
else
{
+ if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
+ {
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
+ }
+ else
+ {
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
+ }
}
break;
case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
- res.Add(new LSL_Integer(0));
- res.Add(new LSL_Vector(0f,0f,0f));
- res.Add(new LSL_Float(0f)); // intensity
- res.Add(new LSL_Float(0f)); // radius
- res.Add(new LSL_Float(0f)); // falloff
+ shape = part.Shape;
+
+ if (shape.LightEntry)
+ res.Add(new LSL_Integer(1)); // active
+ else
+ res.Add(new LSL_Integer(0));
+ res.Add(new LSL_Vector(shape.LightColorR, // color
+ shape.LightColorG,
+ shape.LightColorB));
+ res.Add(new LSL_Float(shape.LightIntensity)); // intensity
+ res.Add(new LSL_Float(shape.LightRadius)); // radius
+ res.Add(new LSL_Float(shape.LightFalloff)); // falloff
break;
case (int)ScriptBaseClass.PRIM_GLOW:
@@ -8869,591 +9040,159 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
+ tex = part.Shape.Textures;
+ float primglow;
if (face == ScriptBaseClass.ALL_SIDES)
{
- for (face = 0; face < 21; face++)
+ for (face = 0; face < GetNumberOfSides(part); face++)
{
- res.Add(new LSL_Float(0f));
+ primglow = tex.GetFace((uint)face).Glow;
+ res.Add(new LSL_Float(primglow));
}
}
else
{
- res.Add(new LSL_Float(0f));
+ primglow = tex.GetFace((uint)face).Glow;
+ res.Add(new LSL_Float(primglow));
}
break;
case (int)ScriptBaseClass.PRIM_TEXT:
- res.Add(new LSL_String(""));
- res.Add(new LSL_Vector(0f,0f,0f));
- res.Add(new LSL_Float(1.0f));
+ Color4 textColor = part.GetTextColor();
+ res.Add(new LSL_String(part.Text));
+ res.Add(new LSL_Vector(textColor.R,
+ textColor.G,
+ textColor.B));
+ res.Add(new LSL_Float(textColor.A));
break;
case (int)ScriptBaseClass.PRIM_NAME:
- res.Add(new LSL_String(avatar.Name));
+ res.Add(new LSL_String(part.Name));
break;
case (int)ScriptBaseClass.PRIM_DESC:
- res.Add(new LSL_String(""));
+ res.Add(new LSL_String(part.Description));
break;
- case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
- Quaternion lrot = avatar.Rotation;
-
- if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
- {
- lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
- }
- res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
+ case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
+ res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W));
break;
case (int)ScriptBaseClass.PRIM_POS_LOCAL:
- Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
- Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
- lpos -= lsitOffset;
-
- if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
- {
- lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
- }
- res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
+ res.Add(new LSL_Vector(GetPartLocalPos(part)));
break;
-
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return res;
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
-
- res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
- return res;
+ LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
+ res += tres;
+ return res;
+ case (int)ScriptBaseClass.PRIM_SLICE:
+ PrimType prim_type = part.GetPrimType();
+ bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING);
+ res.Add(new LSL_Vector(
+ (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0,
+ 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0,
+ 0
+ ));
+ break;
}
}
return res;
}
- public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules)
+ public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
+ {
+ m_host.AddScriptLPS(1);
+ ScriptSleep(1000);
+ return GetPrimMediaParams(m_host, face, rules);
+ }
+
+ public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
+ {
+ m_host.AddScriptLPS(1);
+ ScriptSleep(1000);
+ if (link == ScriptBaseClass.LINK_ROOT)
+ return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules);
+ else if (link == ScriptBaseClass.LINK_THIS)
+ return GetPrimMediaParams(m_host, face, rules);
+ else
+ {
+ SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
+ if (null != part)
+ return GetPrimMediaParams(part, face, rules);
+ }
+
+ return new LSL_List();
+ }
+
+ private LSL_List GetPrimMediaParams(SceneObjectPart part, int face, LSL_List rules)
{
+ // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
+ // TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
+ // Assuming silently fail means give back an empty list. Ideally, need to check this.
+ if (face < 0 || face > part.GetNumberOfSides() - 1)
+ return new LSL_List();
+
+ IMoapModule module = m_ScriptEngine.World.RequestModuleInterface();
+ if (null == module)
+ return new LSL_List();
+
+ MediaEntry me = module.GetMediaEntry(part, face);
+
+ // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
+ if (null == me)
+ return new LSL_List();
+
LSL_List res = new LSL_List();
- int idx=0;
- while (idx < rules.Length)
+
+ for (int i = 0; i < rules.Length; i++)
{
- int code=(int)rules.GetLSLIntegerItem(idx++);
- int remain=rules.Length-idx;
+ int code = (int)rules.GetLSLIntegerItem(i);
switch (code)
{
- case (int)ScriptBaseClass.PRIM_MATERIAL:
- res.Add(new LSL_Integer(part.Material));
+ case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
+ // Not implemented
+ res.Add(new LSL_Integer(0));
break;
- case (int)ScriptBaseClass.PRIM_PHYSICS:
- if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) != 0)
- res.Add(new LSL_Integer(1));
+ case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
+ if (me.Controls == MediaControls.Standard)
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD));
else
- res.Add(new LSL_Integer(0));
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
break;
- case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
- if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) != 0)
- res.Add(new LSL_Integer(1));
- else
- res.Add(new LSL_Integer(0));
+ case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
+ res.Add(new LSL_String(me.CurrentURL));
break;
- case (int)ScriptBaseClass.PRIM_PHANTOM:
- if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0)
- res.Add(new LSL_Integer(1));
- else
- res.Add(new LSL_Integer(0));
+ case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
+ res.Add(new LSL_String(me.HomeURL));
break;
- case (int)ScriptBaseClass.PRIM_POSITION:
- LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X,
- part.AbsolutePosition.Y,
- part.AbsolutePosition.Z);
- res.Add(v);
+ case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
+ res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
break;
- case (int)ScriptBaseClass.PRIM_SIZE:
- res.Add(new LSL_Vector(part.Scale.X,
- part.Scale.Y,
- part.Scale.Z));
+ case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
+ res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
break;
- case (int)ScriptBaseClass.PRIM_ROTATION:
- res.Add(GetPartRot(part));
+ case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
+ res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
break;
- case (int)ScriptBaseClass.PRIM_TYPE:
- // implementing box
- PrimitiveBaseShape Shape = part.Shape;
- int primType = (int)part.GetPrimType();
- res.Add(new LSL_Integer(primType));
- double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX
- double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY.
- switch (primType)
- {
- case ScriptBaseClass.PRIM_TYPE_BOX:
- case ScriptBaseClass.PRIM_TYPE_CYLINDER:
- case ScriptBaseClass.PRIM_TYPE_PRISM:
- res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
- res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
- res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
- res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
- res.Add(new LSL_Vector(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0));
- res.Add(new LSL_Vector(topshearx, topsheary, 0));
- break;
-
- case ScriptBaseClass.PRIM_TYPE_SPHERE:
- res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
- res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
- res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
- res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
- res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
- break;
+ case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
+ res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
+ break;
- case ScriptBaseClass.PRIM_TYPE_SCULPT:
- res.Add(Shape.SculptTexture.ToString());
- res.Add(new LSL_Integer(Shape.SculptType));
- break;
-
- case ScriptBaseClass.PRIM_TYPE_RING:
- case ScriptBaseClass.PRIM_TYPE_TUBE:
- case ScriptBaseClass.PRIM_TYPE_TORUS:
- // holeshape
- res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
-
- // cut
- res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
-
- // hollow
- res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
-
- // twist
- res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
-
- // vector holesize
- res.Add(new LSL_Vector(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0));
-
- // vector topshear
- res.Add(new LSL_Vector(topshearx, topsheary, 0));
-
- // vector profilecut
- res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
-
- // vector tapera
- res.Add(new LSL_Vector(Shape.PathTaperX / 100.0, Shape.PathTaperY / 100.0, 0));
-
- // float revolutions
- res.Add(new LSL_Float(Math.Round(Shape.PathRevolutions * 0.015d, 2, MidpointRounding.AwayFromZero)) + 1.0d);
- // Slightly inaccurate, because an unsigned byte is being used to represent
- // the entire range of floating-point values from 1.0 through 4.0 (which is how
- // SL does it).
- //
- // Using these formulas to store and retrieve PathRevolutions, it is not
- // possible to use all values between 1.00 and 4.00. For instance, you can't
- // represent 1.10. You can represent 1.09 and 1.11, but not 1.10. So, if you
- // use llSetPrimitiveParams to set revolutions to 1.10 and then retreive them
- // with llGetPrimitiveParams, you'll retrieve 1.09. You can also see a similar
- // behavior in the viewer as you cannot set 1.10. The viewer jumps to 1.11.
- // In SL, llSetPrimitveParams and llGetPrimitiveParams can set and get a value
- // such as 1.10. So, SL must store and retreive the actual user input rather
- // than only storing the encoded value.
-
- // float radiusoffset
- res.Add(new LSL_Float(Shape.PathRadiusOffset / 100.0));
-
- // float skew
- res.Add(new LSL_Float(Shape.PathSkew / 100.0));
- break;
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_TEXTURE:
- if (remain < 1)
- return res;
-
- int face = (int)rules.GetLSLIntegerItem(idx++);
- Primitive.TextureEntry tex = part.Shape.Textures;
- if (face == ScriptBaseClass.ALL_SIDES)
- {
- for (face = 0 ; face < GetNumberOfSides(part); face++)
- {
- Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
-
- res.Add(new LSL_String(texface.TextureID.ToString()));
- res.Add(new LSL_Vector(texface.RepeatU,
- texface.RepeatV,
- 0));
- res.Add(new LSL_Vector(texface.OffsetU,
- texface.OffsetV,
- 0));
- res.Add(new LSL_Float(texface.Rotation));
- }
- }
- else
- {
- if (face >= 0 && face < GetNumberOfSides(part))
- {
- Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
-
- res.Add(new LSL_String(texface.TextureID.ToString()));
- res.Add(new LSL_Vector(texface.RepeatU,
- texface.RepeatV,
- 0));
- res.Add(new LSL_Vector(texface.OffsetU,
- texface.OffsetV,
- 0));
- res.Add(new LSL_Float(texface.Rotation));
- }
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_COLOR:
- if (remain < 1)
- return res;
-
- face=(int)rules.GetLSLIntegerItem(idx++);
-
- tex = part.Shape.Textures;
- Color4 texcolor;
- if (face == ScriptBaseClass.ALL_SIDES)
- {
- for (face = 0 ; face < GetNumberOfSides(part); face++)
- {
- texcolor = tex.GetFace((uint)face).RGBA;
- res.Add(new LSL_Vector(texcolor.R,
- texcolor.G,
- texcolor.B));
- res.Add(new LSL_Float(texcolor.A));
- }
- }
- else
- {
- texcolor = tex.GetFace((uint)face).RGBA;
- res.Add(new LSL_Vector(texcolor.R,
- texcolor.G,
- texcolor.B));
- res.Add(new LSL_Float(texcolor.A));
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
- if (remain < 1)
- return res;
- face = (int)rules.GetLSLIntegerItem(idx++);
-
- tex = part.Shape.Textures;
- int shiny;
- if (face == ScriptBaseClass.ALL_SIDES)
- {
- for (face = 0; face < GetNumberOfSides(part); face++)
- {
- Shininess shinyness = tex.GetFace((uint)face).Shiny;
- if (shinyness == Shininess.High)
- {
- shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
- }
- else if (shinyness == Shininess.Medium)
- {
- shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
- }
- else if (shinyness == Shininess.Low)
- {
- shiny = ScriptBaseClass.PRIM_SHINY_LOW;
- }
- else
- {
- shiny = ScriptBaseClass.PRIM_SHINY_NONE;
- }
- res.Add(new LSL_Integer(shiny));
- res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
- }
- }
- else
- {
- Shininess shinyness = tex.GetFace((uint)face).Shiny;
- if (shinyness == Shininess.High)
- {
- shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
- }
- else if (shinyness == Shininess.Medium)
- {
- shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
- }
- else if (shinyness == Shininess.Low)
- {
- shiny = ScriptBaseClass.PRIM_SHINY_LOW;
- }
- else
- {
- shiny = ScriptBaseClass.PRIM_SHINY_NONE;
- }
- res.Add(new LSL_Integer(shiny));
- res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
- if (remain < 1)
- return res;
- face = (int)rules.GetLSLIntegerItem(idx++);
-
- tex = part.Shape.Textures;
- int fullbright;
- if (face == ScriptBaseClass.ALL_SIDES)
- {
- for (face = 0; face < GetNumberOfSides(part); face++)
- {
- if (tex.GetFace((uint)face).Fullbright == true)
- {
- fullbright = ScriptBaseClass.TRUE;
- }
- else
- {
- fullbright = ScriptBaseClass.FALSE;
- }
- res.Add(new LSL_Integer(fullbright));
- }
- }
- else
- {
- if (tex.GetFace((uint)face).Fullbright == true)
- {
- fullbright = ScriptBaseClass.TRUE;
- }
- else
- {
- fullbright = ScriptBaseClass.FALSE;
- }
- res.Add(new LSL_Integer(fullbright));
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_FLEXIBLE:
- PrimitiveBaseShape shape = part.Shape;
-
- if (shape.FlexiEntry)
- res.Add(new LSL_Integer(1)); // active
- else
- res.Add(new LSL_Integer(0));
- res.Add(new LSL_Integer(shape.FlexiSoftness));// softness
- res.Add(new LSL_Float(shape.FlexiGravity)); // gravity
- res.Add(new LSL_Float(shape.FlexiDrag)); // friction
- res.Add(new LSL_Float(shape.FlexiWind)); // wind
- res.Add(new LSL_Float(shape.FlexiTension)); // tension
- res.Add(new LSL_Vector(shape.FlexiForceX, // force
- shape.FlexiForceY,
- shape.FlexiForceZ));
- break;
-
- case (int)ScriptBaseClass.PRIM_TEXGEN:
- // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
- if (remain < 1)
- return res;
- face = (int)rules.GetLSLIntegerItem(idx++);
-
- tex = part.Shape.Textures;
- if (face == ScriptBaseClass.ALL_SIDES)
- {
- for (face = 0; face < GetNumberOfSides(part); face++)
- {
- if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
- {
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
- }
- else
- {
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
- }
- }
- }
- else
- {
- if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
- {
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
- }
- else
- {
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
- }
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
- shape = part.Shape;
-
- if (shape.LightEntry)
- res.Add(new LSL_Integer(1)); // active
- else
- res.Add(new LSL_Integer(0));
- res.Add(new LSL_Vector(shape.LightColorR, // color
- shape.LightColorG,
- shape.LightColorB));
- res.Add(new LSL_Float(shape.LightIntensity)); // intensity
- res.Add(new LSL_Float(shape.LightRadius)); // radius
- res.Add(new LSL_Float(shape.LightFalloff)); // falloff
- break;
-
- case (int)ScriptBaseClass.PRIM_GLOW:
- if (remain < 1)
- return res;
- face = (int)rules.GetLSLIntegerItem(idx++);
-
- tex = part.Shape.Textures;
- float primglow;
- if (face == ScriptBaseClass.ALL_SIDES)
- {
- for (face = 0; face < GetNumberOfSides(part); face++)
- {
- primglow = tex.GetFace((uint)face).Glow;
- res.Add(new LSL_Float(primglow));
- }
- }
- else
- {
- primglow = tex.GetFace((uint)face).Glow;
- res.Add(new LSL_Float(primglow));
- }
- break;
-
- case (int)ScriptBaseClass.PRIM_TEXT:
- Color4 textColor = part.GetTextColor();
- res.Add(new LSL_String(part.Text));
- res.Add(new LSL_Vector(textColor.R,
- textColor.G,
- textColor.B));
- res.Add(new LSL_Float(textColor.A));
- break;
-
- case (int)ScriptBaseClass.PRIM_NAME:
- res.Add(new LSL_String(part.Name));
- break;
-
- case (int)ScriptBaseClass.PRIM_DESC:
- res.Add(new LSL_String(part.Description));
- break;
-
- case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
- res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W));
- break;
-
- case (int)ScriptBaseClass.PRIM_POS_LOCAL:
- res.Add(new LSL_Vector(GetPartLocalPos(part)));
- break;
- case (int)ScriptBaseClass.PRIM_LINK_TARGET:
- if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
- return res;
- LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
- LSL_List new_rules = rules.GetSublist(idx, -1);
- LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
- res += tres;
- return res;
- case (int)ScriptBaseClass.PRIM_SLICE:
- PrimType prim_type = part.GetPrimType();
- bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING);
- res.Add(new LSL_Vector(
- (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0,
- 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0,
- 0
- ));
- break;
- }
- }
- return res;
- }
-
- public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
- {
- m_host.AddScriptLPS(1);
- ScriptSleep(1000);
- return GetPrimMediaParams(m_host, face, rules);
- }
-
- public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
- {
- m_host.AddScriptLPS(1);
- ScriptSleep(1000);
- if (link == ScriptBaseClass.LINK_ROOT)
- return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules);
- else if (link == ScriptBaseClass.LINK_THIS)
- return GetPrimMediaParams(m_host, face, rules);
- else
- {
- SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
- if (null != part)
- return GetPrimMediaParams(part, face, rules);
- }
-
- return new LSL_List();
- }
-
- private LSL_List GetPrimMediaParams(SceneObjectPart part, int face, LSL_List rules)
- {
- // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
- // TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
- // Assuming silently fail means give back an empty list. Ideally, need to check this.
- if (face < 0 || face > part.GetNumberOfSides() - 1)
- return new LSL_List();
-
- IMoapModule module = m_ScriptEngine.World.RequestModuleInterface();
- if (null == module)
- return new LSL_List();
-
- MediaEntry me = module.GetMediaEntry(part, face);
-
- // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
- if (null == me)
- return new LSL_List();
-
- LSL_List res = new LSL_List();
-
- for (int i = 0; i < rules.Length; i++)
- {
- int code = (int)rules.GetLSLIntegerItem(i);
-
- switch (code)
- {
- case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
- // Not implemented
- res.Add(new LSL_Integer(0));
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
- if (me.Controls == MediaControls.Standard)
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD));
- else
- res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
- res.Add(new LSL_String(me.CurrentURL));
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
- res.Add(new LSL_String(me.HomeURL));
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
- res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
- res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
- res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
- res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
- break;
-
- case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
- res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
- break;
+ case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
+ res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
+ break;
case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
res.Add(new LSL_Integer(me.Width));
@@ -13015,142 +12754,403 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
- v = v + 2 * sitOffset;
+ v = v + 2 * sitOffset;
+
+ av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
+ av.SendAvatarDataToAllAgents();
+
+ }
+ break;
+
+ case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
+ case (int)ScriptBaseClass.PRIM_ROTATION:
+ {
+ if (remain < 1)
+ return null;
+
+ LSL_Rotation r;
+ r = rules.GetQuaternionItem(idx++);
+
+ SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
+ if (part == null)
+ break;
+
+ LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
+ LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
+
+ if (part.LinkNum > 1)
+ localRot = GetPartLocalRot(part);
+
+ r = r * llGetRootRotation() / localRot;
+ av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
+ av.SendAvatarDataToAllAgents();
+ }
+ break;
+
+ // parse rest doing nothing but number of parameters error check
+ case (int)ScriptBaseClass.PRIM_SIZE:
+ case (int)ScriptBaseClass.PRIM_MATERIAL:
+ case (int)ScriptBaseClass.PRIM_PHANTOM:
+ case (int)ScriptBaseClass.PRIM_PHYSICS:
+ case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
+ case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
+ case (int)ScriptBaseClass.PRIM_NAME:
+ case (int)ScriptBaseClass.PRIM_DESC:
+ if (remain < 1)
+ return null;
+ idx++;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_GLOW:
+ case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
+ case (int)ScriptBaseClass.PRIM_TEXGEN:
+ if (remain < 2)
+ return null;
+ idx += 2;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE:
+ if (remain < 3)
+ return null;
+ code = (int)rules.GetLSLIntegerItem(idx++);
+ remain = rules.Length - idx;
+ switch (code)
+ {
+ case (int)ScriptBaseClass.PRIM_TYPE_BOX:
+ case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
+ case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
+ if (remain < 6)
+ return null;
+ idx += 6;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
+ if (remain < 5)
+ return null;
+ idx += 5;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
+ case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
+ case (int)ScriptBaseClass.PRIM_TYPE_RING:
+ if (remain < 11)
+ return null;
+ idx += 11;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
+ if (remain < 2)
+ return null;
+ idx += 2;
+ break;
+ }
+ break;
+
+ case (int)ScriptBaseClass.PRIM_COLOR:
+ case (int)ScriptBaseClass.PRIM_TEXT:
+ case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
+ case (int)ScriptBaseClass.PRIM_OMEGA:
+ if (remain < 3)
+ return null;
+ idx += 3;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TEXTURE:
+ case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
+ case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
+ if (remain < 5)
+ return null;
+ idx += 5;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_FLEXIBLE:
+ if (remain < 7)
+ return null;
+
+ idx += 7;
+ break;
+
+ case (int)ScriptBaseClass.PRIM_LINK_TARGET:
+ if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
+ return null;
+
+ return rules.GetSublist(idx, -1);
+ }
+ }
+ }
+
+ finally
+ {
+ if (positionChanged)
+ {
+ av.OffsetPosition = finalPos;
+// av.SendAvatarDataToAllAgents();
+ av.SendTerseUpdateToAllClients();
+ positionChanged = false;
+ }
+ }
+ return null;
+ }
+
+ public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules)
+ {
+ // avatars case
+ // replies as SL wiki
+
+ LSL_List res = new LSL_List();
+// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
+ SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
+
+ int idx = 0;
+ while (idx < rules.Length)
+ {
+ int code = (int)rules.GetLSLIntegerItem(idx++);
+ int remain = rules.Length - idx;
+
+ switch (code)
+ {
+ case (int)ScriptBaseClass.PRIM_MATERIAL:
+ res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_PHYSICS:
+ res.Add(new LSL_Integer(0));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
+ res.Add(new LSL_Integer(0));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_PHANTOM:
+ res.Add(new LSL_Integer(0));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_POSITION:
+
+ Vector3 pos = avatar.OffsetPosition;
+
+ Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
+ pos -= sitOffset;
+
+ if( sitPart != null)
+ pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
+
+ res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_SIZE:
+ // as in llGetAgentSize above
+ res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_ROTATION:
+ Quaternion rot = avatar.Rotation;
+ if (sitPart != null)
+ {
+ rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation
+ }
+
+ res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TYPE:
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX));
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT));
+ res.Add(new LSL_Vector(0f,1.0f,0f));
+ res.Add(new LSL_Float(0.0f));
+ res.Add(new LSL_Vector(0, 0, 0));
+ res.Add(new LSL_Vector(1.0f,1.0f,0f));
+ res.Add(new LSL_Vector(0, 0, 0));
+ break;
+
+ case (int)ScriptBaseClass.PRIM_TEXTURE:
+ if (remain < 1)
+ return res;
+
+ int face = (int)rules.GetLSLIntegerItem(idx++);
+ if (face == ScriptBaseClass.ALL_SIDES)
+ {
+ for (face = 0; face < 21; face++)
+ {
+ res.Add(new LSL_String(""));
+ res.Add(new LSL_Vector(0,0,0));
+ res.Add(new LSL_Vector(0,0,0));
+ res.Add(new LSL_Float(0.0));
+ }
+ }
+ else
+ {
+ if (face >= 0 && face < 21)
+ {
+ res.Add(new LSL_String(""));
+ res.Add(new LSL_Vector(0,0,0));
+ res.Add(new LSL_Vector(0,0,0));
+ res.Add(new LSL_Float(0.0));
+ }
+ }
+ break;
+
+ case (int)ScriptBaseClass.PRIM_COLOR:
+ if (remain < 1)
+ return res;
- av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
- av.SendAvatarDataToAllAgents();
+ face = (int)rules.GetLSLIntegerItem(idx++);
+ if (face == ScriptBaseClass.ALL_SIDES)
+ {
+ for (face = 0; face < 21; face++)
+ {
+ res.Add(new LSL_Vector(0,0,0));
+ res.Add(new LSL_Float(0));
}
- break;
+ }
+ else
+ {
+ res.Add(new LSL_Vector(0,0,0));
+ res.Add(new LSL_Float(0));
+ }
+ break;
- case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
- case (int)ScriptBaseClass.PRIM_ROTATION:
+ case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
+ if (remain < 1)
+ return res;
+ face = (int)rules.GetLSLIntegerItem(idx++);
+
+ if (face == ScriptBaseClass.ALL_SIDES)
+ {
+ for (face = 0; face < 21; face++)
{
- if (remain < 1)
- return null;
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
+ }
+ }
+ else
+ {
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
+ }
+ break;
- LSL_Rotation r;
- r = rules.GetQuaternionItem(idx++);
+ case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
+ if (remain < 1)
+ return res;
+ face = (int)rules.GetLSLIntegerItem(idx++);
- SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
- if (part == null)
- break;
+ if (face == ScriptBaseClass.ALL_SIDES)
+ {
+ for (face = 0; face < 21; face++)
+ {
+ res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
+ }
+ }
+ else
+ {
+ res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
+ }
+ break;
- LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
- LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
+ case (int)ScriptBaseClass.PRIM_FLEXIBLE:
+ res.Add(new LSL_Integer(0));
+ res.Add(new LSL_Integer(0));// softness
+ res.Add(new LSL_Float(0.0f)); // gravity
+ res.Add(new LSL_Float(0.0f)); // friction
+ res.Add(new LSL_Float(0.0f)); // wind
+ res.Add(new LSL_Float(0.0f)); // tension
+ res.Add(new LSL_Vector(0f,0f,0f));
+ break;
- if (part.LinkNum > 1)
- localRot = GetPartLocalRot(part);
+ case (int)ScriptBaseClass.PRIM_TEXGEN:
+ // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
+ if (remain < 1)
+ return res;
+ face = (int)rules.GetLSLIntegerItem(idx++);
- r = r * llGetRootRotation() / localRot;
- av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
- av.SendAvatarDataToAllAgents();
+ if (face == ScriptBaseClass.ALL_SIDES)
+ {
+ for (face = 0; face < 21; face++)
+ {
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
}
- break;
+ }
+ else
+ {
+ res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
+ }
+ break;
- // parse rest doing nothing but number of parameters error check
- case (int)ScriptBaseClass.PRIM_SIZE:
- case (int)ScriptBaseClass.PRIM_MATERIAL:
- case (int)ScriptBaseClass.PRIM_PHANTOM:
- case (int)ScriptBaseClass.PRIM_PHYSICS:
- case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
- case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
- case (int)ScriptBaseClass.PRIM_NAME:
- case (int)ScriptBaseClass.PRIM_DESC:
- if (remain < 1)
- return null;
- idx++;
- break;
+ case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
+ res.Add(new LSL_Integer(0));
+ res.Add(new LSL_Vector(0f,0f,0f));
+ res.Add(new LSL_Float(0f)); // intensity
+ res.Add(new LSL_Float(0f)); // radius
+ res.Add(new LSL_Float(0f)); // falloff
+ break;
- case (int)ScriptBaseClass.PRIM_GLOW:
- case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
- case (int)ScriptBaseClass.PRIM_TEXGEN:
- if (remain < 2)
- return null;
- idx += 2;
- break;
+ case (int)ScriptBaseClass.PRIM_GLOW:
+ if (remain < 1)
+ return res;
+ face = (int)rules.GetLSLIntegerItem(idx++);
- case (int)ScriptBaseClass.PRIM_TYPE:
- if (remain < 3)
- return null;
- code = (int)rules.GetLSLIntegerItem(idx++);
- remain = rules.Length - idx;
- switch (code)
+ if (face == ScriptBaseClass.ALL_SIDES)
+ {
+ for (face = 0; face < 21; face++)
{
- case (int)ScriptBaseClass.PRIM_TYPE_BOX:
- case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
- case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
- if (remain < 6)
- return null;
- idx += 6;
- break;
-
- case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
- if (remain < 5)
- return null;
- idx += 5;
- break;
+ res.Add(new LSL_Float(0f));
+ }
+ }
+ else
+ {
+ res.Add(new LSL_Float(0f));
+ }
+ break;
- case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
- case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
- case (int)ScriptBaseClass.PRIM_TYPE_RING:
- if (remain < 11)
- return null;
- idx += 11;
- break;
+ case (int)ScriptBaseClass.PRIM_TEXT:
+ res.Add(new LSL_String(""));
+ res.Add(new LSL_Vector(0f,0f,0f));
+ res.Add(new LSL_Float(1.0f));
+ break;
- case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
- if (remain < 2)
- return null;
- idx += 2;
- break;
- }
- break;
+ case (int)ScriptBaseClass.PRIM_NAME:
+ res.Add(new LSL_String(avatar.Name));
+ break;
- case (int)ScriptBaseClass.PRIM_COLOR:
- case (int)ScriptBaseClass.PRIM_TEXT:
- case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
- case (int)ScriptBaseClass.PRIM_OMEGA:
- if (remain < 3)
- return null;
- idx += 3;
- break;
+ case (int)ScriptBaseClass.PRIM_DESC:
+ res.Add(new LSL_String(""));
+ break;
- case (int)ScriptBaseClass.PRIM_TEXTURE:
- case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
- case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
- if (remain < 5)
- return null;
- idx += 5;
- break;
+ case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
+ Quaternion lrot = avatar.Rotation;
- case (int)ScriptBaseClass.PRIM_FLEXIBLE:
- if (remain < 7)
- return null;
+ if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
+ {
+ lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
+ }
+ res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
+ break;
- idx += 7;
- break;
+ case (int)ScriptBaseClass.PRIM_POS_LOCAL:
+ Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
+ Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
+ lpos -= lsitOffset;
- case (int)ScriptBaseClass.PRIM_LINK_TARGET:
- if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
- return null;
+ if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
+ {
+ lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
+ }
+ res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
+ break;
- return rules.GetSublist(idx, -1);
- }
- }
- }
+ case (int)ScriptBaseClass.PRIM_LINK_TARGET:
+ if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
+ return res;
+ LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
+ LSL_List new_rules = rules.GetSublist(idx, -1);
- finally
- {
- if (positionChanged)
- {
- av.OffsetPosition = finalPos;
-// av.SendAvatarDataToAllAgents();
- av.SendTerseUpdateToAllClients();
- positionChanged = false;
+ res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
+ return res;
}
}
- return null;
+ return res;
}
}
}
--
cgit v1.1
From 86d4e45f4d5ce7de4a2043dfe753f620925e28c4 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 25 Aug 2012 21:03:47 +0100
Subject: since we will be making the Get return type the remaining ruleset as
with the Set return type, we need to move the original return type to a ref
param
Conflicts:
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
---
.../Shared/Api/Implementation/LSL_Api.cs | 274 +++++++++++----------
.../Shared/Api/Implementation/OSSL_Api.cs | 2 +-
2 files changed, 139 insertions(+), 137 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 64f145b..fbb91ce 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -8636,7 +8636,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List llGetPrimitiveParams(LSL_List rules)
{
m_host.AddScriptLPS(1);
- return GetPrimParams(m_host, rules);
+
+ LSL_List result = new LSL_List();
+
+ GetPrimParams(m_host, rules, ref result);
+
+ return result;
}
public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules)
@@ -8655,24 +8660,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
foreach (var part in parts)
{
- LSL_List partRes = GetPrimParams(part, rules);
- res += partRes;
+ GetPrimParams(part, rules, ref res);
}
}
if (avatars.Count > 0)
{
foreach (ScenePresence avatar in avatars)
{
- LSL_List avaRes = GetPrimParams(avatar, rules);
- res += avaRes;
+ GetPrimParams(avatar, rules, ref res);
}
+ // TODO: FINISH MERGE
}
return res;
}
- public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules)
+ public void GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res)
{
- LSL_List res = new LSL_List();
int idx=0;
while (idx < rules.Length)
{
@@ -8810,7 +8813,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 1)
- return res;
+ return;
int face = (int)rules.GetLSLIntegerItem(idx++);
Primitive.TextureEntry tex = part.Shape.Textures;
@@ -8850,7 +8853,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_COLOR:
if (remain < 1)
- return res;
+ return;
face=(int)rules.GetLSLIntegerItem(idx++);
@@ -8879,7 +8882,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
tex = part.Shape.Textures;
@@ -8935,7 +8938,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
tex = part.Shape.Textures;
@@ -8989,7 +8992,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXGEN:
// (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
tex = part.Shape.Textures;
@@ -9037,7 +9040,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
tex = part.Shape.Textures;
@@ -9083,12 +9086,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
- return res;
+ return;
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
res += tres;
- return res;
+ return;
case (int)ScriptBaseClass.PRIM_SLICE:
PrimType prim_type = part.GetPrimType();
bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING);
@@ -9100,7 +9103,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
}
}
- return res;
}
public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
@@ -11661,13 +11663,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
{
SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
- if (obj == null)
- return new LSL_List();
- if (obj.OwnerID != m_host.OwnerID)
- return new LSL_List();
+ LSL_List result = new LSL_List();
- return GetPrimParams(obj, rules);
+ if (obj != null && obj.OwnerID != m_host.OwnerID)
+ {
+ GetPrimParams(obj, rules, ref result);
+ }
+
+ return result;
}
public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
@@ -12604,110 +12608,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
}
- }
-
- public class NotecardCache
- {
- protected class Notecard
- {
- public string[] text;
- public DateTime lastRef;
- }
-
- protected static Dictionary m_Notecards =
- new Dictionary();
-
- public static void Cache(UUID assetID, string text)
- {
- CacheCheck();
-
- lock (m_Notecards)
- {
- if (m_Notecards.ContainsKey(assetID))
- return;
-
- Notecard nc = new Notecard();
- nc.lastRef = DateTime.Now;
- nc.text = SLUtil.ParseNotecardToList(text).ToArray();
- m_Notecards[assetID] = nc;
- }
- }
-
- public static bool IsCached(UUID assetID)
- {
- lock (m_Notecards)
- {
- return m_Notecards.ContainsKey(assetID);
- }
- }
-
- public static int GetLines(UUID assetID)
- {
- if (!IsCached(assetID))
- return -1;
-
- lock (m_Notecards)
- {
- m_Notecards[assetID].lastRef = DateTime.Now;
- return m_Notecards[assetID].text.Length;
- }
- }
-
- ///
- /// Get a notecard line.
- ///
- ///
- /// Lines start at index 0
- ///
- public static string GetLine(UUID assetID, int lineNumber)
- {
- if (lineNumber < 0)
- return "";
-
- string data;
-
- if (!IsCached(assetID))
- return "";
-
- lock (m_Notecards)
- {
- m_Notecards[assetID].lastRef = DateTime.Now;
-
- if (lineNumber >= m_Notecards[assetID].text.Length)
- return "\n\n\n";
-
- data = m_Notecards[assetID].text[lineNumber];
-
- return data;
- }
- }
-
- ///
- /// Get a notecard line.
- ///
- ///
- /// Lines start at index 0
- /// Maximum length of the returned line. Longer lines will be truncated
- ///
- public static string GetLine(UUID assetID, int lineNumber, int maxLength)
- {
- string line = GetLine(assetID, lineNumber);
-
- if (line.Length > maxLength)
- line = line.Substring(0, maxLength);
-
- return line;
- }
-
- public static void CacheCheck()
- {
- foreach (UUID key in new List(m_Notecards.Keys))
- {
- Notecard nc = m_Notecards[key];
- if (nc.lastRef.AddSeconds(30) < DateTime.Now)
- m_Notecards.Remove(key);
- }
- }
protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules)
{
@@ -12892,12 +12792,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return null;
}
- public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules)
+ public void GetPrimParams(ScenePresence avatar, LSL_List rules, ref LSL_List res)
{
// avatars case
// replies as SL wiki
- LSL_List res = new LSL_List();
// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
@@ -12965,7 +12864,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 1)
- return res;
+ return;
int face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
@@ -12992,7 +12891,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_COLOR:
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
@@ -13013,7 +12912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
@@ -13033,7 +12932,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
@@ -13062,7 +12961,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXGEN:
// (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
@@ -13088,7 +12987,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 1)
- return res;
+ return;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
@@ -13142,15 +13041,118 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
- return res;
+ return;
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
- return res;
+ return;
}
}
- return res;
+ }
+ }
+
+ public class NotecardCache
+ {
+ protected class Notecard
+ {
+ public string[] text;
+ public DateTime lastRef;
+ }
+
+ protected static Dictionary m_Notecards =
+ new Dictionary();
+
+ public static void Cache(UUID assetID, string text)
+ {
+ CacheCheck();
+
+ lock (m_Notecards)
+ {
+ if (m_Notecards.ContainsKey(assetID))
+ return;
+
+ Notecard nc = new Notecard();
+ nc.lastRef = DateTime.Now;
+ nc.text = SLUtil.ParseNotecardToList(text).ToArray();
+ m_Notecards[assetID] = nc;
+ }
+ }
+
+ public static bool IsCached(UUID assetID)
+ {
+ lock (m_Notecards)
+ {
+ return m_Notecards.ContainsKey(assetID);
+ }
+ }
+
+ public static int GetLines(UUID assetID)
+ {
+ if (!IsCached(assetID))
+ return -1;
+
+ lock (m_Notecards)
+ {
+ m_Notecards[assetID].lastRef = DateTime.Now;
+ return m_Notecards[assetID].text.Length;
+ }
+ }
+
+ ///
+ /// Get a notecard line.
+ ///
+ ///
+ /// Lines start at index 0
+ ///
+ public static string GetLine(UUID assetID, int lineNumber)
+ {
+ if (lineNumber < 0)
+ return "";
+
+ string data;
+
+ if (!IsCached(assetID))
+ return "";
+
+ lock (m_Notecards)
+ {
+ m_Notecards[assetID].lastRef = DateTime.Now;
+
+ if (lineNumber >= m_Notecards[assetID].text.Length)
+ return "\n\n\n";
+
+ data = m_Notecards[assetID].text[lineNumber];
+
+ return data;
+ }
+ }
+
+ ///
+ /// Get a notecard line.
+ ///
+ ///
+ /// Lines start at index 0
+ /// Maximum length of the returned line. Longer lines will be truncated
+ ///
+ public static string GetLine(UUID assetID, int lineNumber, int maxLength)
+ {
+ string line = GetLine(assetID, lineNumber);
+
+ if (line.Length > maxLength)
+ line = line.Substring(0, maxLength);
+
+ return line;
+ }
+
+ public static void CacheCheck()
+ {
+ foreach (UUID key in new List(m_Notecards.Keys))
+ {
+ Notecard nc = m_Notecards[key];
+ if (nc.lastRef.AddSeconds(30) < DateTime.Now)
+ m_Notecards.Remove(key);
+ }
}
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7b71a24..efd1f39 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2261,7 +2261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
- retVal += ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules);
+ ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules, ref retVal);
}
return retVal;
}
--
cgit v1.1
From 3d8f393fbe0072d93fc8303741420bb36c844d44 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 24 Aug 2012 17:25:37 +0100
Subject: refactoring to local variable for cleaner code
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index efd1f39..43cfea2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2257,11 +2257,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
m_host.AddScriptLPS(1);
InitLSL();
+ // One needs to cast m_LSL_Api because we're using functions not
+ // on the ILSL_Api interface.
+ LSL_Api LSL_Api = (LSL_Api)m_LSL_Api;
LSL_List retVal = new LSL_List();
- List parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber);
+ List parts = LSL_Api.GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
{
- ((LSL_Api)m_LSL_Api).GetPrimParams(part, rules, ref retVal);
+ LSL_Api.GetPrimParams(part, rules, ref retVal);
}
return retVal;
}
--
cgit v1.1
From bc4bda4441c51779b94307ad60782b037f0a3f2c Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 25 Aug 2012 21:08:33 +0100
Subject: Minor formatting cleanup
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fbb91ce..ed3c2a4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7735,10 +7735,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
remaining = SetPrimParams((ScenePresence)part, rules);
}
- while((object)remaining != null && remaining.Length > 2)
+ while ((object)remaining != null && remaining.Length > 2)
{
linknumber = remaining.GetLSLIntegerItem(0);
- rules = remaining.GetSublist(1,-1);
+ rules = remaining.GetSublist(1, -1);
parts.Clear();
prims = GetLinkParts(linknumber);
avatars = GetLinkAvatars(linknumber);
--
cgit v1.1
From e90168c7382f7750faa001542652e2316841c961 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 27 Aug 2012 22:42:40 +0100
Subject: Add VectorRenderModuleTests.TestRepeatDraw()
---
.../VectorRender/Tests/VectorRenderModuleTests.cs | 59 ++++++++++++++++++----
1 file changed, 48 insertions(+), 11 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
index 9787c8c..f9b5a59 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
@@ -45,31 +45,68 @@ using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
{
[TestFixture]
- public class VectorRenderModuleTests
+ public class VectorRenderModuleTests : OpenSimTestCase
{
+ Scene m_scene;
+ DynamicTextureModule m_dtm;
+ VectorRenderModule m_vrm;
+
+ [SetUp]
+ public void SetUp()
+ {
+ m_scene = new SceneHelpers().SetupScene();
+ m_dtm = new DynamicTextureModule();
+ m_vrm = new VectorRenderModule();
+ SceneHelpers.SetupSceneModules(m_scene, m_dtm, m_vrm);
+ }
+
[Test]
public void TestDraw()
{
TestHelpers.InMethod();
- Scene scene = new SceneHelpers().SetupScene();
- DynamicTextureModule dtm = new DynamicTextureModule();
- VectorRenderModule vrm = new VectorRenderModule();
- SceneHelpers.SetupSceneModules(scene, dtm, vrm);
-
- SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
- dtm.AddDynamicTextureData(
- scene.RegionInfo.RegionID,
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
so.UUID,
- vrm.GetContentType(),
+ m_vrm.GetContentType(),
"PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;",
"",
0);
-
Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
}
+
+ [Test]
+ public void TestRepeatDraw()
+ {
+ TestHelpers.InMethod();
+
+ string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
+
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+ }
}
}
\ No newline at end of file
--
cgit v1.1
From 3082fdd0f6d73fa07fe2266170fcd3e5e572f2a2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 27 Aug 2012 22:58:20 +0100
Subject: Add VectorRenderModuleTests.TestRepeatDrawContainingImage()
---
.../VectorRender/Tests/VectorRenderModuleTests.cs | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
index f9b5a59..21e1d54 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
@@ -108,5 +108,36 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
}
+
+ [Test]
+ public void TestRepeatDrawContainingImage()
+ {
+ TestHelpers.InMethod();
+
+ string dtText
+ = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World; Image http://localhost/shouldnotexist.png";
+
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+ }
}
}
\ No newline at end of file
--
cgit v1.1
From 4e26d039d6ffe03ae9509120015b39692bad44f9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 27 Aug 2012 23:03:21 +0100
Subject: Add VectorRenderModule.TestRepeatSameDrawDifferentExtraParams()
---
.../VectorRender/Tests/VectorRenderModuleTests.cs | 34 ++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
index 21e1d54..180ea9f 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
}
[Test]
- public void TestRepeatDraw()
+ public void TestRepeatSameDraw()
{
TestHelpers.InMethod();
@@ -110,7 +110,37 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
}
[Test]
- public void TestRepeatDrawContainingImage()
+ public void TestRepeatSameDrawDifferentExtraParams()
+ {
+ TestHelpers.InMethod();
+
+ string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
+
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "alpha:250",
+ 0);
+
+ Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+ }
+
+ [Test]
+ public void TestRepeatSameDrawContainingImage()
{
TestHelpers.InMethod();
--
cgit v1.1
From ab9bfe5156d955ca02b7cfcb0ccb5919f6b0743d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 27 Aug 2012 23:06:37 +0100
Subject: minor: Simplify return of vector render module name and some very
minor removal of unncessary syntax clutter
---
.../CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index c48a703..f988c0e 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -47,7 +47,6 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private string m_name = "VectorRenderModule";
private Scene m_scene;
private IDynamicTextureManager m_textureManager;
private Graphics m_graph;
@@ -61,12 +60,12 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
public string GetContentType()
{
- return ("vector");
+ return "vector";
}
public string GetName()
{
- return m_name;
+ return Name;
}
public bool SupportsAsynchronous()
@@ -152,7 +151,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
public string Name
{
- get { return m_name; }
+ get { return "VectorRenderModule"; }
}
public bool IsSharedModule
--
cgit v1.1
From a6d689c529e443df58eb218ccb512c516fb7cc81 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sun, 26 Aug 2012 22:52:33 +0100
Subject: refactoring to assign the first argument to a variable
---
OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 3f848ed..3546654 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -1176,7 +1176,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
private void InterfaceRunPluginEffect(Object[] args)
{
- if ((string) args[0] == "list")
+ string firstArg = (string)args[0];
+ if (firstArg == "list")
{
m_log.Info("List of loaded plugins");
foreach (KeyValuePair kvp in m_plugineffects)
@@ -1185,14 +1186,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain
}
return;
}
- if ((string) args[0] == "reload")
+ if (firstArg == "reload")
{
LoadPlugins();
return;
}
- if (m_plugineffects.ContainsKey((string) args[0]))
+ if (m_plugineffects.ContainsKey(firstArg))
{
- m_plugineffects[(string) args[0]].RunEffect(m_channel);
+ m_plugineffects[firstArg].RunEffect(m_channel);
CheckForTerrainUpdates();
}
else
--
cgit v1.1
From 72c2d13ac6e350317b59b04bca9c79f371f0528a Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sun, 26 Aug 2012 22:53:59 +0100
Subject: refactoring to load from self (fixes ChanneDigger being absent)
---
.../Region/CoreModules/World/Terrain/TerrainModule.cs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 3546654..620d3b5 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -414,6 +414,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
private void LoadPlugins()
{
m_plugineffects = new Dictionary();
+ LoadPlugins(Assembly.GetCallingAssembly());
string plugineffectsPath = "Terrain";
// Load the files in the Terrain/ dir
@@ -427,6 +428,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
try
{
Assembly library = Assembly.LoadFrom(file);
+ LoadPlugins(library);
+ }
+ catch (BadImageFormatException)
+ {
+ }
+ }
+ }
+
+ private void LoadPlugins(Assembly library)
+ {
foreach (Type pluginType in library.GetTypes())
{
try
@@ -453,11 +464,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
{
}
}
- }
- catch (BadImageFormatException)
- {
- }
- }
}
public void InstallPlugin(string pluginName, ITerrainEffect effect)
--
cgit v1.1
From e916b1399f08e726302f576d1653dc7edc445217 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Mon, 27 Aug 2012 01:50:53 +0100
Subject: formatting
---
.../CoreModules/World/Terrain/TerrainModule.cs | 44 +++++++++++-----------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 620d3b5..4694b14 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -438,32 +438,32 @@ namespace OpenSim.Region.CoreModules.World.Terrain
private void LoadPlugins(Assembly library)
{
- foreach (Type pluginType in library.GetTypes())
- {
- try
- {
- if (pluginType.IsAbstract || pluginType.IsNotPublic)
- continue;
+ foreach (Type pluginType in library.GetTypes())
+ {
+ try
+ {
+ if (pluginType.IsAbstract || pluginType.IsNotPublic)
+ continue;
- string typeName = pluginType.Name;
+ string typeName = pluginType.Name;
- if (pluginType.GetInterface("ITerrainEffect", false) != null)
- {
- ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString()));
+ if (pluginType.GetInterface("ITerrainEffect", false) != null)
+ {
+ ITerrainEffect terEffect = (ITerrainEffect)Activator.CreateInstance(library.GetType(pluginType.ToString()));
- InstallPlugin(typeName, terEffect);
- }
- else if (pluginType.GetInterface("ITerrainLoader", false) != null)
- {
- ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString()));
- m_loaders[terLoader.FileExtension] = terLoader;
- m_log.Info("L ... " + typeName);
- }
- }
- catch (AmbiguousMatchException)
- {
- }
+ InstallPlugin(typeName, terEffect);
+ }
+ else if (pluginType.GetInterface("ITerrainLoader", false) != null)
+ {
+ ITerrainLoader terLoader = (ITerrainLoader)Activator.CreateInstance(library.GetType(pluginType.ToString()));
+ m_loaders[terLoader.FileExtension] = terLoader;
+ m_log.Info("L ... " + typeName);
}
+ }
+ catch (AmbiguousMatchException)
+ {
+ }
+ }
}
public void InstallPlugin(string pluginName, ITerrainEffect effect)
--
cgit v1.1
From 8a7fbfb06a20fa1c4b8e25809eb42c12a621e0b4 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Mon, 27 Aug 2012 01:37:55 +0100
Subject: adding some files to .gitignore that get generated when debugging in
c# express with OpenSim.32BitLaunch as the startup project
---
.gitignore | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.gitignore b/.gitignore
index bf3ac37..1e41243 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,10 @@ bin/*.db-journal
bin/addin-db-*
bin/*.dll
bin/OpenSim.vshost.exe.config
+bin/OpenSim.32BitLaunch.vshost.exe.config
+bin/OpenSim.32BitLaunch.log
+UpgradeLog.XML
+_UpgradeReport_Files/
bin/ScriptEngines/*-*-*-*-*
bin/ScriptEngines/*.dll
bin/ScriptEngines/*/*.dll
--
cgit v1.1
From 1e18f0f26aeb45ff9d0097206fec3910fb2291c8 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Thu, 23 Aug 2012 13:59:06 +0100
Subject: copying documentation from http://opensimulator.org/wiki/Threat_level
---
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 59 ++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 9ad1c22..ce1845c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -40,16 +40,75 @@ using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{
+ ///
+ /// To permit region owners to enable the extended scripting functionality
+ /// of OSSL, without allowing malicious scripts to access potentially
+ /// troublesome functions, each OSSL function is assigned a threat level,
+ /// and access to the functions is granted or denied based on a default
+ /// threshold set in OpenSim.ini (which can be overridden for individual
+ /// functions on a case-by-case basis)
+ ///
public enum ThreatLevel
{
+ // Not documented, presumably means permanently disabled ?
NoAccess = -1,
+
+ ///
+ /// Function is no threat at all. It doesn't constitute a threat to
+ /// either users or the system and has no known side effects.
+ ///
None = 0,
+
+ ///
+ /// Abuse of this command can cause a nuisance to the region operator,
+ /// such as log message spew.
+ ///
Nuisance = 1,
+
+ ///
+ /// Extreme levels of abuse of this function can cause impaired
+ /// functioning of the region, or very gullible users can be tricked
+ /// into experiencing harmless effects.
+ ///
VeryLow = 2,
+
+ ///
+ /// Intentional abuse can cause crashes or malfunction under certain
+ /// circumstances, which can be easily rectified; or certain users can
+ /// be tricked into certain situations in an avoidable manner.
+ ///
Low = 3,
+
+ ///
+ /// Intentional abuse can cause denial of service and crashes with
+ /// potential of data or state loss; or trusting users can be tricked
+ /// into embarrassing or uncomfortable situations.
+ ///
Moderate = 4,
+
+ ///
+ /// Casual abuse can cause impaired functionality or temporary denial
+ /// of service conditions. Intentional abuse can easily cause crashes
+ /// with potential data loss, or can be used to trick experienced and
+ /// cautious users into unwanted situations, or changes global data
+ /// permanently and without undo ability.
+ ///
High = 5,
+
+ ///
+ /// Even normal use may, depending on the number of instances, or
+ /// frequency of use, result in severe service impairment or crash
+ /// with loss of data, or can be used to cause unwanted or harmful
+ /// effects on users without giving the user a means to avoid it.
+ ///
VeryHigh = 6,
+
+ ///
+ /// Even casual use is a danger to region stability, or function allows
+ /// console or OS command execution, or function allows taking money
+ /// without consent, or allows deletion or modification of user data,
+ /// or allows the compromise of sensitive data by design.
+ ///
Severe = 7
};
--
cgit v1.1
From aa44df9c04658cfa0af9a0f203faea5e493c6f25 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 28 Aug 2012 20:35:17 +0100
Subject: Add IDynamicTextureManager.ConvertData() to match AsyncConvertData().
Remove mismatching ConvertStream() where there is no AsyncConvertStream and
neither IDynamicTextureManager implementer implements this method.
---
.../CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs | 2 +-
.../CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 11 ++++++-----
OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs | 2 +-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
index 6f83948..6e38b3f 100644
--- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
return null;
}
- public byte[] ConvertStream(Stream data, string extraParams)
+ public byte[] ConvertData(string bodyData, string extraParams)
{
return null;
}
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index f988c0e..3a758c5 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -78,9 +78,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
return null;
}
- public byte[] ConvertStream(Stream data, string extraParams)
+ public byte[] ConvertData(string bodyData, string extraParams)
{
- return null;
+ return Draw(bodyData, extraParams);
}
public bool AsyncConvertUrl(UUID id, string url, string extraParams)
@@ -90,7 +90,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
public bool AsyncConvertData(UUID id, string bodyData, string extraParams)
{
- Draw(bodyData, id, extraParams);
+ // XXX: This isn't actually being done asynchronously!
+ m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams));
return true;
}
@@ -161,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
#endregion
- private void Draw(string data, UUID id, string extraParams)
+ private byte[] Draw(string data, string extraParams)
{
// We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha
// we will now support multiple comma seperated params in the form width:256,height:512,alpha:255
@@ -358,7 +359,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
e.Message, e.StackTrace);
}
- m_textureManager.ReturnData(id, imageJ2000);
+ return imageJ2000;
}
finally
{
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
index 8954513..773ba73 100644
--- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
@@ -114,7 +114,7 @@ namespace OpenSim.Region.Framework.Interfaces
string GetContentType();
bool SupportsAsynchronous();
byte[] ConvertUrl(string url, string extraParams);
- byte[] ConvertStream(Stream data, string extraParams);
+ byte[] ConvertData(string bodyData, string extraParams);
bool AsyncConvertUrl(UUID id, string url, string extraParams);
bool AsyncConvertData(UUID id, string bodyData, string extraParams);
void GetDrawStringSize(string text, string fontName, int fontSize,
--
cgit v1.1
From c1cece4b82d24a17a09b66c9ec3975190cc05d95 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 28 Aug 2012 23:06:53 +0100
Subject: Add experimental DynamicTextureModule.ReuseTextures flag, currently
only configurable on compile.
Disabled (status quo) by default.
This flag makes the dynamic texture module reuse cache previously dynamically generated textures given the same input commands and extra params for 24 hours.
This occurs as long as those commands would always generate the same texture (e.g. they do not contain commands to fetch data from the web).
This makes texture changing faster as a viewer-cached texture uuid is sent and may reduce simulator load in regions with generation of lots of dynamic textures.
A downside is that this stops expiry of old temporary dynamic textures from the cache,
Another downside is that a jpeg2000 generation that partially failed is currently not regenerated until restart or after 24 hours.
---
.../DynamicTexture/DynamicTextureModule.cs | 169 +++++++++++++++------
.../Scripting/LoadImageURL/LoadImageURLModule.cs | 10 +-
.../VectorRender/Tests/VectorRenderModuleTests.cs | 125 ++++++++++++++-
.../Scripting/VectorRender/VectorRenderModule.cs | 48 +++++-
.../Framework/Interfaces/IDynamicTextureManager.cs | 14 +-
5 files changed, 310 insertions(+), 56 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 18bd018..13b7498 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -49,6 +49,11 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public const int DISP_EXPIRE = 1;
public const int DISP_TEMP = 2;
+ ///
+ /// If true then where possible dynamic textures are reused.
+ ///
+ public bool ReuseTextures { get; set; }
+
private Dictionary RegisteredScenes = new Dictionary();
private Dictionary RenderPlugins =
@@ -56,6 +61,15 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
private Dictionary Updaters = new Dictionary();
+ ///
+ /// Record dynamic textures that we can reuse for a given data and parameter combination rather than
+ /// regenerate.
+ ///
+ ///
+ /// Key is string.Format("{0}{1}", data
+ ///
+ private Cache m_reuseableDynamicTextures;
+
#region IDynamicTextureManager Members
public void RegisterRender(string handleType, IDynamicTextureRender render)
@@ -71,7 +85,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
///
///
///
- public void ReturnData(UUID id, byte[] data)
+ /// True if the data generated can be reused for subsequent identical requests
+ public void ReturnData(UUID id, byte[] data, bool isReuseable)
{
DynamicTextureUpdater updater = null;
@@ -88,7 +103,11 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
if (RegisteredScenes.ContainsKey(updater.SimUUID))
{
Scene scene = RegisteredScenes[updater.SimUUID];
- updater.DataReceived(data, scene);
+ UUID newTextureID = updater.DataReceived(data, scene);
+
+ if (ReuseTextures && isReuseable && !updater.BlendWithOldTexture)
+ m_reuseableDynamicTextures.Store(
+ GenerateReusableTextureKey(updater.BodyData, updater.Params), newTextureID);
}
}
@@ -169,6 +188,11 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
{
if (RenderPlugins.ContainsKey(contentType))
{
+ // If we want to reuse dynamic textures then we have to ignore any request from the caller to expire
+ // them.
+ if (ReuseTextures)
+ disp = disp & ~DISP_EXPIRE;
+
DynamicTextureUpdater updater = new DynamicTextureUpdater();
updater.SimUUID = simID;
updater.PrimID = primID;
@@ -183,21 +207,49 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.Url = "Local image";
updater.Disp = disp;
- lock (Updaters)
+ object reusableTextureUUID = null;
+
+ if (ReuseTextures)
+ reusableTextureUUID
+ = m_reuseableDynamicTextures.Get(GenerateReusableTextureKey(data, extraParams));
+
+ // We cannot reuse a dynamic texture if the data is going to be blended with something already there.
+ if (reusableTextureUUID == null || updater.BlendWithOldTexture)
{
- if (!Updaters.ContainsKey(updater.UpdaterID))
+ lock (Updaters)
{
- Updaters.Add(updater.UpdaterID, updater);
+ if (!Updaters.ContainsKey(updater.UpdaterID))
+ {
+ Updaters.Add(updater.UpdaterID, updater);
+ }
+ }
+
+ RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
+ }
+ else
+ {
+ // No need to add to updaters as the texture is always the same. Not that this functionality
+ // apppears to be implemented anyway.
+ if (RegisteredScenes.ContainsKey(updater.SimUUID))
+ {
+ SceneObjectPart part = RegisteredScenes[updater.SimUUID].GetSceneObjectPart(updater.PrimID);
+
+ if (part != null)
+ updater.UpdatePart(part, (UUID)reusableTextureUUID);
}
}
- RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
return updater.UpdaterID;
}
return UUID.Zero;
}
+ private string GenerateReusableTextureKey(string data, string extraParams)
+ {
+ return string.Format("{0}{1}", data, extraParams);
+ }
+
public void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
out double xSize, out double ySize)
{
@@ -224,6 +276,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public void PostInitialise()
{
+// ReuseTextures = true;
+ if (ReuseTextures)
+ {
+ m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative);
+ m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0);
+ }
}
public void Close()
@@ -269,9 +327,60 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
}
///
+ /// Update the given part with the new texture.
+ ///
+ ///
+ /// The old texture UUID.
+ ///
+ public UUID UpdatePart(SceneObjectPart part, UUID textureID)
+ {
+ UUID oldID;
+
+ lock (part)
+ {
+ // mostly keep the values from before
+ Primitive.TextureEntry tmptex = part.Shape.Textures;
+
+ // FIXME: Need to return the appropriate ID if only a single face is replaced.
+ oldID = tmptex.DefaultTexture.TextureID;
+
+ if (Face == ALL_SIDES)
+ {
+ oldID = tmptex.DefaultTexture.TextureID;
+ tmptex.DefaultTexture.TextureID = textureID;
+ }
+ else
+ {
+ try
+ {
+ Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
+ texface.TextureID = textureID;
+ tmptex.FaceTextures[Face] = texface;
+ }
+ catch (Exception)
+ {
+ tmptex.DefaultTexture.TextureID = textureID;
+ }
+ }
+
+ // I'm pretty sure we always want to force this to true
+ // I'm pretty sure noone whats to set fullbright true if it wasn't true before.
+ // tmptex.DefaultTexture.Fullbright = true;
+
+ part.UpdateTextureEntry(tmptex.GetBytes());
+ }
+
+ return oldID;
+ }
+
+ ///
/// Called once new texture data has been received for this updater.
///
- public void DataReceived(byte[] data, Scene scene)
+ ///
+ ///
+ /// True if the data given is reuseable.
+ /// The asset UUID given to the incoming data.
+ public UUID DataReceived(byte[] data, Scene scene)
{
SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
@@ -281,7 +390,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url);
scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,
0, part.ParentGroup.RootPart.AbsolutePosition, part.Name, part.UUID, false);
- return;
+
+ return UUID.Zero;
}
byte[] assetData = null;
@@ -323,52 +433,23 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
cacheLayerDecode = null;
}
- UUID oldID = UUID.Zero;
-
- lock (part)
- {
- // mostly keep the values from before
- Primitive.TextureEntry tmptex = part.Shape.Textures;
-
- // remove the old asset from the cache
- oldID = tmptex.DefaultTexture.TextureID;
-
- if (Face == ALL_SIDES)
- {
- tmptex.DefaultTexture.TextureID = asset.FullID;
- }
- else
- {
- try
- {
- Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
- texface.TextureID = asset.FullID;
- tmptex.FaceTextures[Face] = texface;
- }
- catch (Exception)
- {
- tmptex.DefaultTexture.TextureID = asset.FullID;
- }
- }
-
- // I'm pretty sure we always want to force this to true
- // I'm pretty sure noone whats to set fullbright true if it wasn't true before.
- // tmptex.DefaultTexture.Fullbright = true;
-
- part.UpdateTextureEntry(tmptex.GetBytes());
- }
+ UUID oldID = UpdatePart(part, asset.FullID);
if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
{
- if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString());
+ if (oldAsset == null)
+ oldAsset = scene.AssetService.Get(oldID.ToString());
+
if (oldAsset != null)
{
- if (oldAsset.Temporary == true)
+ if (oldAsset.Temporary)
{
scene.AssetService.Delete(oldID.ToString());
}
}
}
+
+ return asset.FullID;
}
private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha)
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
index 6e38b3f..2b3a0f2 100644
--- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
@@ -67,6 +67,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
return true;
}
+// public bool AlwaysIdenticalConversion(string bodyData, string extraParams)
+// {
+// // We don't support conversion of body data.
+// return false;
+// }
+
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
@@ -236,9 +242,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
stream.Close();
}
}
+
m_log.DebugFormat("[LOADIMAGEURLMODULE] Returning {0} bytes of image data for request {1}",
imageJ2000.Length, state.RequestID);
- m_textureManager.ReturnData(state.RequestID, imageJ2000);
+
+ m_textureManager.ReturnData(state.RequestID, imageJ2000, false);
}
#region Nested type: RequestState
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
index 180ea9f..b50c0bd 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs
@@ -51,12 +51,15 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
DynamicTextureModule m_dtm;
VectorRenderModule m_vrm;
- [SetUp]
- public void SetUp()
+ private void SetupScene(bool reuseTextures)
{
m_scene = new SceneHelpers().SetupScene();
+
m_dtm = new DynamicTextureModule();
+ m_dtm.ReuseTextures = reuseTextures;
+
m_vrm = new VectorRenderModule();
+
SceneHelpers.SetupSceneModules(m_scene, m_dtm, m_vrm);
}
@@ -65,6 +68,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
{
TestHelpers.InMethod();
+ SetupScene(false);
SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
@@ -86,6 +90,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
+ SetupScene(false);
SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
m_dtm.AddDynamicTextureData(
@@ -116,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
+ SetupScene(false);
SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
m_dtm.AddDynamicTextureData(
@@ -147,6 +153,121 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
string dtText
= "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World; Image http://localhost/shouldnotexist.png";
+ SetupScene(false);
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+ }
+
+ [Test]
+ public void TestDrawReusingTexture()
+ {
+ TestHelpers.InMethod();
+
+ SetupScene(true);
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
+ UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;",
+ "",
+ 0);
+
+ Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+ }
+
+ [Test]
+ public void TestRepeatSameDrawReusingTexture()
+ {
+ TestHelpers.InMethod();
+
+ string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
+
+ SetupScene(true);
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+ }
+
+ [Test]
+ public void TestRepeatSameDrawDifferentExtraParamsReusingTexture()
+ {
+ TestHelpers.InMethod();
+
+ string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
+
+ SetupScene(true);
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "",
+ 0);
+
+ UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ m_dtm.AddDynamicTextureData(
+ m_scene.RegionInfo.RegionID,
+ so.UUID,
+ m_vrm.GetContentType(),
+ dtText,
+ "alpha:250",
+ 0);
+
+ Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+ }
+
+ [Test]
+ public void TestRepeatSameDrawContainingImageReusingTexture()
+ {
+ TestHelpers.InMethod();
+
+ string dtText
+ = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World; Image http://localhost/shouldnotexist.png";
+
+ SetupScene(true);
SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
m_dtm.AddDynamicTextureData(
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 3a758c5..4268f2e 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -30,6 +30,7 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
+using System.Linq;
using System.Net;
using Nini.Config;
using OpenMetaverse;
@@ -73,6 +74,12 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
return true;
}
+// public bool AlwaysIdenticalConversion(string bodyData, string extraParams)
+// {
+// string[] lines = GetLines(bodyData);
+// return lines.Any((str, r) => str.StartsWith("Image"));
+// }
+
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
@@ -80,7 +87,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
public byte[] ConvertData(string bodyData, string extraParams)
{
- return Draw(bodyData, extraParams);
+ bool reuseable;
+ return Draw(bodyData, extraParams, out reuseable);
+ }
+
+ private byte[] ConvertData(string bodyData, string extraParams, out bool reuseable)
+ {
+ return Draw(bodyData, extraParams, out reuseable);
}
public bool AsyncConvertUrl(UUID id, string url, string extraParams)
@@ -91,7 +104,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
public bool AsyncConvertData(UUID id, string bodyData, string extraParams)
{
// XXX: This isn't actually being done asynchronously!
- m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams));
+ bool reuseable;
+ byte[] data = ConvertData(bodyData, extraParams, out reuseable);
+
+ m_textureManager.ReturnData(id, data, reuseable);
+
return true;
}
@@ -162,7 +179,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
#endregion
- private byte[] Draw(string data, string extraParams)
+ private byte[] Draw(string data, string extraParams, out bool reuseable)
{
// We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha
// we will now support multiple comma seperated params in the form width:256,height:512,alpha:255
@@ -343,7 +360,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
}
}
- GDIDraw(data, graph, altDataDelim);
+ GDIDraw(data, graph, altDataDelim, out reuseable);
}
byte[] imageJ2000 = new byte[0];
@@ -434,8 +451,21 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
}
*/
- private void GDIDraw(string data, Graphics graph, char dataDelim)
+ ///
+ /// Split input data into discrete command lines.
+ ///
+ ///
+ ///
+ ///
+ private string[] GetLines(string data, char dataDelim)
{
+ char[] lineDelimiter = { dataDelim };
+ return data.Split(lineDelimiter);
+ }
+
+ private void GDIDraw(string data, Graphics graph, char dataDelim, out bool reuseable)
+ {
+ reuseable = true;
Point startPoint = new Point(0, 0);
Point endPoint = new Point(0, 0);
Pen drawPen = null;
@@ -450,11 +480,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
myFont = new Font(fontName, fontSize);
myBrush = new SolidBrush(Color.Black);
- char[] lineDelimiter = {dataDelim};
char[] partsDelimiter = {','};
- string[] lines = data.Split(lineDelimiter);
- foreach (string line in lines)
+ foreach (string line in GetLines(data, dataDelim))
{
string nextLine = line.Trim();
//replace with switch, or even better, do some proper parsing
@@ -485,6 +513,10 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
}
else if (nextLine.StartsWith("Image"))
{
+ // We cannot reuse any generated texture involving fetching an image via HTTP since that image
+ // can change.
+ reuseable = false;
+
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y);
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
index 773ba73..1a3bcbb 100644
--- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IDynamicTextureManager
{
void RegisterRender(string handleType, IDynamicTextureRender render);
- void ReturnData(UUID id, byte[] data);
+ void ReturnData(UUID id, byte[] data, bool isReuseable);
UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams,
int updateTimer);
@@ -113,6 +113,18 @@ namespace OpenSim.Region.Framework.Interfaces
string GetName();
string GetContentType();
bool SupportsAsynchronous();
+
+// ///
+// /// Return true if converting the input body and extra params data will always result in the same byte[] array
+// ///
+// ///
+// /// This method allows the caller to use a previously generated asset if it has one.
+// ///
+// ///
+// ///
+// ///
+// bool AlwaysIdenticalConversion(string bodyData, string extraParams);
+
byte[] ConvertUrl(string url, string extraParams);
byte[] ConvertData(string bodyData, string extraParams);
bool AsyncConvertUrl(UUID id, string url, string extraParams);
--
cgit v1.1
From 7ea832d47c827ad9ef8eb0ce24702fbee585b1ee Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 29 Aug 2012 02:01:43 +0100
Subject: Fix regression introduced in a0d178b2 (Sat Aug 25 02:00:17 2012)
where folders with asset type of 'Folder' and 'Unknown' were accidentally
treated as system folders.
This prevented more than one additional ordinary folder from being created in the base "My Inventory" user folder.
Added regression test for this case.
Switched tests to use XInventoryService with mostly implemented TestXInventoryDataPlugin rather than InventoryService
Disabled TestLoadIarV0_1SameNameCreator() since this has not been working for a very long time (ever since XInventoryService) started being used
since it doesnt' preserve creator data in the same way as InventoryService did and so effectively lost the OSPAs.
However, nobody noticed/complained about this issue and OSPAs have been superseded by HG like creator information via the --home save oar/iar switch.
---
OpenSim/Data/IXInventoryData.cs | 10 ++
OpenSim/Framework/InventoryFolderBase.cs | 18 +--
.../Serialization/External/OspResolver.cs | 14 ++-
.../Archiver/Tests/InventoryArchiverTests.cs | 64 +++++-----
.../Framework/Scenes/Tests/UserInventoryTests.cs | 36 +++++-
.../Services/InventoryService/XInventoryService.cs | 3 +-
OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 2 +-
.../Tests/Common/Helpers/UserInventoryHelpers.cs | 4 +-
.../Tests/Common/Mock/TestXInventoryDataPlugin.cs | 131 +++++++++++++++++++++
OpenSim/Tests/Common/TestHelpers.cs | 1 +
10 files changed, 231 insertions(+), 52 deletions(-)
create mode 100644 OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs
index 85a5c08..e64a828 100644
--- a/OpenSim/Data/IXInventoryData.cs
+++ b/OpenSim/Data/IXInventoryData.cs
@@ -40,6 +40,11 @@ namespace OpenSim.Data
public UUID folderID;
public UUID agentID;
public UUID parentFolderID;
+
+ public XInventoryFolder Clone()
+ {
+ return (XInventoryFolder)MemberwiseClone();
+ }
}
public class XInventoryItem
@@ -64,6 +69,11 @@ namespace OpenSim.Data
public UUID avatarID;
public UUID parentFolderID;
public int inventoryGroupPermissions;
+
+ public XInventoryItem Clone()
+ {
+ return (XInventoryItem)MemberwiseClone();
+ }
}
public interface IXInventoryData
diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs
index a12183c..b3457a6 100644
--- a/OpenSim/Framework/InventoryFolderBase.cs
+++ b/OpenSim/Framework/InventoryFolderBase.cs
@@ -73,33 +73,27 @@ namespace OpenSim.Framework
{
}
- public InventoryFolderBase(UUID id)
+ public InventoryFolderBase(UUID id) : this()
{
ID = id;
}
- public InventoryFolderBase(UUID id, UUID owner)
+ public InventoryFolderBase(UUID id, UUID owner) : this(id)
{
- ID = id;
Owner = owner;
}
- public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent)
+ public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) : this(id, owner)
{
- ID = id;
Name = name;
- Owner = owner;
ParentID = parent;
}
- public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version)
+ public InventoryFolderBase(
+ UUID id, string name, UUID owner, short type, UUID parent, ushort version) : this(id, name, owner, parent)
{
- ID = id;
- Name = name;
- Owner = owner;
Type = type;
- ParentID = parent;
Version = version;
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs
index d31d27c..fa7160f 100644
--- a/OpenSim/Framework/Serialization/External/OspResolver.cs
+++ b/OpenSim/Framework/Serialization/External/OspResolver.cs
@@ -65,9 +65,14 @@ namespace OpenSim.Framework.Serialization
UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
if (account != null)
+ {
return MakeOspa(account.FirstName, account.LastName);
+ }
// else
+// {
// m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId);
+// System.Console.WriteLine("[OSP RESOLVER]: No user account for {0}", userId);
+// }
return null;
}
@@ -79,10 +84,13 @@ namespace OpenSim.Framework.Serialization
///
public static string MakeOspa(string firstName, string lastName)
{
-// m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName);
+ string ospa
+ = OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName;
+
+// m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName);
+// System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName);
- return
- OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName;
+ return ospa;
}
///
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index b112b6d..12a05b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -350,38 +350,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID));
}
- ///
- /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
- /// an account exists with the same name as the creator, though not the same id.
- ///
- [Test]
- public void TestLoadIarV0_1SameNameCreator()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
- UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
-
- m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
- InventoryItemBase foundItem1
- = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
-
- Assert.That(
- foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
- "Loaded item non-uuid creator doesn't match original");
- Assert.That(
- foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
- "Loaded item uuid creator doesn't match original");
- Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
- "Loaded item owner doesn't match inventory reciever");
-
- AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
- string xmlData = Utils.BytesToString(asset1.Data);
- SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
-
- Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
- }
+// ///
+// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
+// /// an account exists with the same name as the creator, though not the same id.
+// ///
+// [Test]
+// public void TestLoadIarV0_1SameNameCreator()
+// {
+// TestHelpers.InMethod();
+// TestHelpers.EnableLogging();
+//
+// UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
+// UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
+//
+// m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
+// InventoryItemBase foundItem1
+// = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
+//
+// Assert.That(
+// foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
+// "Loaded item non-uuid creator doesn't match original");
+// Assert.That(
+// foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
+// "Loaded item uuid creator doesn't match original");
+// Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
+// "Loaded item owner doesn't match inventory reciever");
+//
+// AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
+// string xmlData = Utils.BytesToString(asset1.Data);
+// SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
+//
+// Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
+// }
///
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
index 44d2d45..9457ebb 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -50,9 +50,41 @@ using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.Framework.Tests
{
[TestFixture]
- public class UserInventoryTests
+ public class UserInventoryTests : OpenSimTestCase
{
[Test]
+ public void TestCreateInventoryFolders()
+ {
+ TestHelpers.InMethod();
+// TestHelpers.EnableLogging();
+
+ // For this test both folders will have the same name which is legal in SL user inventories.
+ string foldersName = "f1";
+
+ Scene scene = new SceneHelpers().SetupScene();
+ UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
+
+ UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName);
+
+ List oneFolder
+ = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
+
+ Assert.That(oneFolder.Count, Is.EqualTo(1));
+ InventoryFolderBase firstRetrievedFolder = oneFolder[0];
+ Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName));
+
+ UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName);
+
+ List twoFolders
+ = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
+
+ Assert.That(twoFolders.Count, Is.EqualTo(2));
+ Assert.That(twoFolders[0].Name, Is.EqualTo(foldersName));
+ Assert.That(twoFolders[1].Name, Is.EqualTo(foldersName));
+ Assert.That(twoFolders[0].ID, Is.Not.EqualTo(twoFolders[1].ID));
+ }
+
+ [Test]
public void TestGiveInventoryItem()
{
TestHelpers.InMethod();
@@ -83,7 +115,7 @@ namespace OpenSim.Region.Framework.Tests
public void TestGiveInventoryFolder()
{
TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
+// TestHelpers.EnableLogging();
Scene scene = new SceneHelpers().SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index deacd5a..309dab4 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -94,6 +94,7 @@ namespace OpenSim.Services.InventoryService
m_Database = LoadPlugin(dllName,
new Object[] {connString, String.Empty});
+
if (m_Database == null)
throw new Exception("Could not find a storage interface in the given module");
}
@@ -326,7 +327,7 @@ namespace OpenSim.Services.InventoryService
if (check != null)
return false;
- if (folder.Type != (short)AssetType.Folder || folder.Type != (short)AssetType.Unknown)
+ if (folder.Type != (short)AssetType.Folder && folder.Type != (short)AssetType.Unknown)
{
InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 7598cc3..fc49169 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -245,7 +245,7 @@ namespace OpenSim.Tests.Common
config.AddConfig("Modules");
config.AddConfig("InventoryService");
config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
- config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
+ config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService");
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index b3a7c9e..87d9410 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -199,7 +199,9 @@ namespace OpenSim.Tests.Common
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
InventoryFolderBase newFolder
- = new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID);
+ = new InventoryFolderBase(
+ UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
+
inventoryService.AddFolder(newFolder);
if (components.Length > 1)
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
new file mode 100644
index 0000000..bca5979
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using log4net;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Data;
+
+namespace OpenSim.Tests.Common.Mock
+{
+ public class TestXInventoryDataPlugin : IXInventoryData
+ {
+ private Dictionary m_allFolders = new Dictionary();
+ private Dictionary m_allItems = new Dictionary();
+
+ public TestXInventoryDataPlugin(string conn, string realm) {}
+
+ public XInventoryItem[] GetItems(string[] fields, string[] vals)
+ {
+ List origItems = Get(fields, vals, m_allItems.Values.ToList());
+
+ return origItems.Select(i => i.Clone()).ToArray();
+ }
+
+ public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
+ {
+ List origFolders
+ = Get(fields, vals, m_allFolders.Values.ToList());
+
+ return origFolders.Select(f => f.Clone()).ToArray();
+ }
+
+ private List Get(string[] fields, string[] vals, List inputEntities)
+ {
+ List entities = inputEntities;
+
+ for (int i = 0; i < fields.Length; i++)
+ {
+ entities
+ = entities.Where(
+ e =>
+ {
+ FieldInfo fi = typeof(T).GetField(fields[i]);
+ if (fi == null)
+ throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i]));
+
+ return fi.GetValue(e).ToString() == vals[i];
+ }
+ ).ToList();
+ }
+
+ return entities;
+ }
+
+ public bool StoreFolder(XInventoryFolder folder)
+ {
+ m_allFolders[folder.folderID] = folder.Clone();
+
+// Console.WriteLine("Added folder {0} {1}", folder.folderName, folder.folderID);
+
+ return true;
+ }
+
+ public bool StoreItem(XInventoryItem item)
+ {
+ m_allItems[item.inventoryID] = item.Clone();
+
+// Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID);
+
+ return true;
+ }
+
+ public bool DeleteFolders(string field, string val)
+ {
+ return DeleteFolders(new string[] { field }, new string[] { val });
+ }
+
+ public bool DeleteFolders(string[] fields, string[] vals)
+ {
+ XInventoryFolder[] foldersToDelete = GetFolders(fields, vals);
+ Array.ForEach(foldersToDelete, f => m_allFolders.Remove(f.folderID));
+
+ return true;
+ }
+
+ public bool DeleteItems(string field, string val)
+ {
+ return DeleteItems(new string[] { field }, new string[] { val });
+ }
+
+ public bool DeleteItems(string[] fields, string[] vals)
+ {
+ XInventoryItem[] itemsToDelete = GetItems(fields, vals);
+ Array.ForEach(itemsToDelete, i => m_allItems.Remove(i.inventoryID));
+
+ return true;
+ }
+
+ public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
+ public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
+ public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index 30121fe..57da802 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -95,6 +95,7 @@ namespace OpenSim.Tests.Common
public static void EnableLogging()
{
log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream);
+ EnableLoggingConfigStream.Position = 0;
}
///
--
cgit v1.1
From 3bf7bd6359ffbbc2a00b6870b72cc78287a70bc7 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 28 Aug 2012 03:21:04 +0100
Subject: track originating IScriptApi method for SL-like error messages. Will
add rule number tracking in next commit.
---
.../Shared/Api/Implementation/LSL_Api.cs | 26 +++++++++++++---------
.../Shared/Api/Implementation/OSSL_Api.cs | 2 +-
.../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 2 +-
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b001c51..709cac2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7208,7 +7208,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules);
+ setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules, "llSetPrimitiveParams");
ScriptSleep(200);
}
@@ -7217,7 +7217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- setLinkPrimParams(linknumber, rules);
+ setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams");
ScriptSleep(200);
}
@@ -7226,17 +7226,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- setLinkPrimParams(linknumber, rules);
+ setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast");
}
- protected void setLinkPrimParams(int linknumber, LSL_List rules)
+ protected void setLinkPrimParams(int linknumber, LSL_List rules, string originFunc)
{
List parts = GetLinkParts(linknumber);
LSL_List remaining = null;
foreach (SceneObjectPart part in parts)
- remaining = SetPrimParams(part, rules);
+ remaining = SetPrimParams(part, rules, originFunc);
while (remaining != null && remaining.Length > 2)
{
@@ -7245,13 +7245,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
parts = GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
- remaining = SetPrimParams(part, rules);
+ remaining = SetPrimParams(part, rules, originFunc);
}
}
- protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules)
+ protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc)
{
int idx = 0;
+ int idxStart = 0;
bool positionChanged = false;
LSL_Vector currentPosition = GetPartLocalPos(part);
@@ -7263,6 +7264,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
int code = rules.GetLSLIntegerItem(idx++);
int remain = rules.Length - idx;
+ idxStart = idx;
int face;
LSL_Vector v;
@@ -7639,7 +7641,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
catch (InvalidCastException e)
{
- ShoutError(e.Message);
+ ShoutError(string.Format(
+ "{0} error running rule #{1}: arg #{2} ",
+ originFunc, "unknown", idx - idxStart) + e.Message);
}
finally
{
@@ -10761,7 +10765,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return tid.ToString();
}
- public void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
+ public void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc)
{
SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
if (obj == null)
@@ -10770,14 +10774,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj.OwnerID != m_host.OwnerID)
return;
- LSL_List remaining = SetPrimParams(obj, rules);
+ LSL_List remaining = SetPrimParams(obj, rules, originFunc);
while ((object)remaining != null && remaining.Length > 2)
{
LSL_Integer newLink = remaining.GetLSLIntegerItem(0);
LSL_List newrules = remaining.GetSublist(1, -1);
foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){
- remaining = SetPrimParams(part, newrules);
+ remaining = SetPrimParams(part, newrules, originFunc);
}
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 1afa4fb..09fcf50 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2988,7 +2988,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
InitLSL();
- m_LSL_Api.SetPrimitiveParamsEx(prim, rules);
+ m_LSL_Api.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams");
}
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index cd58614..e97ff9d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -424,7 +424,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_String llXorBase64StringsCorrect(string str1, string str2);
void print(string str);
- void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
+ void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc);
LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
}
}
--
cgit v1.1
From 0c3061f973417ecce8f412c82139cfad82504921 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 28 Aug 2012 03:40:27 +0100
Subject: implementing rule tracking
---
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 709cac2..ae92716 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7234,9 +7234,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List parts = GetLinkParts(linknumber);
LSL_List remaining = null;
+ uint rulesParsed = 0;
foreach (SceneObjectPart part in parts)
- remaining = SetPrimParams(part, rules, originFunc);
+ remaining = SetPrimParams(part, rules, originFunc, ref rulesParsed);
while (remaining != null && remaining.Length > 2)
{
@@ -7245,11 +7246,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
parts = GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
- remaining = SetPrimParams(part, rules, originFunc);
+ remaining = SetPrimParams(part, rules, originFunc, ref rulesParsed);
}
}
- protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc)
+ protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed)
{
int idx = 0;
int idxStart = 0;
@@ -7261,6 +7262,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
while (idx < rules.Length)
{
+ ++rulesParsed;
int code = rules.GetLSLIntegerItem(idx++);
int remain = rules.Length - idx;
@@ -7643,7 +7645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
ShoutError(string.Format(
"{0} error running rule #{1}: arg #{2} ",
- originFunc, "unknown", idx - idxStart) + e.Message);
+ originFunc, rulesParsed, idx - idxStart) + e.Message);
}
finally
{
@@ -10774,14 +10776,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj.OwnerID != m_host.OwnerID)
return;
- LSL_List remaining = SetPrimParams(obj, rules, originFunc);
+ uint rulesParsed = 0;
+ LSL_List remaining = SetPrimParams(obj, rules, originFunc, ref rulesParsed);
while ((object)remaining != null && remaining.Length > 2)
{
LSL_Integer newLink = remaining.GetLSLIntegerItem(0);
LSL_List newrules = remaining.GetSublist(1, -1);
foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){
- remaining = SetPrimParams(part, newrules, originFunc);
+ remaining = SetPrimParams(part, newrules, originFunc, ref rulesParsed);
}
}
}
--
cgit v1.1
From 3d736d575ff9670ac813f13eb1cff07dea10328b Mon Sep 17 00:00:00 2001
From: Mic Bowman
Date: Wed, 29 Aug 2012 14:56:51 -0700
Subject: This partially implements the LSL function to set the response type
for an HTTP request. Since the "official" LSL function limits the use of the
response type, it is implemented as osSetContentType with a string for the
content mime type and a threat level of high. With this function you should
be able to implement rather functional media-on-a-prim application with much
less difficulty.
---
.../CoreModules/Scripting/LSLHttp/UrlModule.cs | 20 +++++++++++++++++++-
OpenSim/Region/Framework/Interfaces/IUrlModule.cs | 2 ++
.../Shared/Api/Implementation/OSSL_Api.cs | 18 +++++++++++++++++-
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 6 ++++++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++
5 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 05d54f0..53a9679 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -84,6 +84,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public string body;
public int responseCode;
public string responseBody;
+ public string responseType = "text/plain";
//public ManualResetEvent ev;
public bool requestDone;
public int startTime;
@@ -302,6 +303,22 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
}
}
+ public void HttpContentType(UUID request, string type)
+ {
+ lock (m_UrlMap)
+ {
+ if (m_RequestMap.ContainsKey(request))
+ {
+ UrlData urlData = m_RequestMap[request];
+ urlData.requests[request].responseType = type;
+ }
+ else
+ {
+ m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
+ }
+ }
+ }
+
public void HttpResponse(UUID request, int status, string body)
{
lock (m_UrlMap)
@@ -504,7 +521,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
//put response
response["int_response_code"] = requestData.responseCode;
response["str_response_string"] = requestData.responseBody;
- response["content_type"] = "text/plain";
+ response["content_type"] = requestData.responseType;
+ // response["content_type"] = "text/plain";
response["keepalive"] = false;
response["reusecontext"] = false;
diff --git a/OpenSim/Region/Framework/Interfaces/IUrlModule.cs b/OpenSim/Region/Framework/Interfaces/IUrlModule.cs
index 457444c..79e9f9d 100644
--- a/OpenSim/Region/Framework/Interfaces/IUrlModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IUrlModule.cs
@@ -39,6 +39,8 @@ namespace OpenSim.Region.Framework.Interfaces
UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID);
void ReleaseURL(string url);
void HttpResponse(UUID request, int status, string body);
+ void HttpContentType(UUID request, string type);
+
string GetHttpHeader(UUID request, string header);
int GetFreeUrls();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 09fcf50..e245684 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -140,12 +140,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal float m_ScriptDistanceFactor = 1.0f;
internal Dictionary m_FunctionPerms = new Dictionary();
+ protected IUrlModule m_UrlModule = null;
+
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
{
m_ScriptEngine = ScriptEngine;
m_host = host;
m_item = item;
+ m_UrlModule = m_ScriptEngine.World.RequestModuleInterface();
+
if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
m_OSFunctionsEnabled = true;
@@ -3358,5 +3362,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
}
- }
+
+ ///
+ /// Sets the response type for an HTTP request/response
+ ///
+ ///
+ public void osSetContentType(LSL_Key id, string type)
+ {
+ CheckThreatLevel(ThreatLevel.High,"osSetResponseType");
+ if (m_UrlModule != null)
+ m_UrlModule.HttpContentType(new UUID(id),type);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index ce1845c..06729ab 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -365,5 +365,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
///
/// Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.
LSL_Key osGetRezzingObject();
+
+ ///
+ /// Sets the response type for an HTTP request/response
+ ///
+ ///
+ void osSetContentType(LSL_Key id, string type);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index e9131e4..ba1ade2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -955,5 +955,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRezzingObject();
}
+
+ public void osSetContentType(LSL_Key id, string type)
+ {
+ m_OSSL_Functions.osSetContentType(id,type);
+ }
}
}
--
cgit v1.1
From ec726413ddcd8632efb2603b968554647419708d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 29 Aug 2012 23:04:00 +0100
Subject: Add VectorRenderModuleStressTests that contains a long running test
that generates thousands of vector textures concurrently.
Intended for use if there are future issues with mono crashes whilst generate dynamic textures.
This test is triggered via a new test-stress nant target.
Not run by default.
---
.nant/local.include | 13 +-
.../Tests/Stress/VectorRenderModuleStressTests.cs | 132 +++++++++++++++++++++
prebuild.xml | 40 +++++++
3 files changed, 184 insertions(+), 1 deletion(-)
create mode 100644 OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs
diff --git a/.nant/local.include b/.nant/local.include
index 6d3e972..181c875 100644
--- a/.nant/local.include
+++ b/.nant/local.include
@@ -135,6 +135,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -142,7 +153,7 @@
-
+
diff --git a/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs b/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs
new file mode 100644
index 0000000..1f220c0
--- /dev/null
+++ b/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Threading;
+using log4net.Config;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenMetaverse.Assets;
+using OpenSim.Framework;
+using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
+using OpenSim.Region.CoreModules.Scripting.VectorRender;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
+using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
+
+namespace OpenSim.Tests.Stress
+{
+ [TestFixture]
+ public class VectorRenderModuleStressTests : OpenSimTestCase
+ {
+ public Scene Scene { get; private set; }
+ public DynamicTextureModule Dtm { get; private set; }
+ public VectorRenderModule Vrm { get; private set; }
+
+ private void SetupScene(bool reuseTextures)
+ {
+ Scene = new SceneHelpers().SetupScene();
+
+ Dtm = new DynamicTextureModule();
+ Dtm.ReuseTextures = reuseTextures;
+
+ Vrm = new VectorRenderModule();
+
+ SceneHelpers.SetupSceneModules(Scene, Dtm, Vrm);
+ }
+
+ [Test]
+ public void TestConcurrentRepeatedDraw()
+ {
+ int threads = 4;
+ TestHelpers.InMethod();
+
+ SetupScene(false);
+
+ List drawers = new List();
+
+ for (int i = 0; i < threads; i++)
+ {
+ Drawer d = new Drawer(this, i);
+ drawers.Add(d);
+ Console.WriteLine("Starting drawer {0}", i);
+ Util.FireAndForget(o => d.Draw());
+ }
+
+ Thread.Sleep(10 * 60 * 1000);
+
+ drawers.ForEach(d => d.Ready = false);
+ drawers.ForEach(d => Console.WriteLine("Drawer {0} drew {1} textures", d.Number, d.Pass + 1));
+ }
+
+ class Drawer
+ {
+ public int Number { get; private set; }
+ public int Pass { get; private set; }
+ public bool Ready { get; set; }
+
+ private VectorRenderModuleStressTests m_tests;
+
+ public Drawer(VectorRenderModuleStressTests tests, int number)
+ {
+ m_tests = tests;
+ Number = number;
+ Ready = true;
+ }
+
+ public void Draw()
+ {
+ SceneObjectGroup so = SceneHelpers.AddSceneObject(m_tests.Scene);
+
+ while (Ready)
+ {
+ UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
+
+ // Ensure unique text
+ string text = string.Format("{0:D2}{1}", Number, Pass);
+
+ m_tests.Dtm.AddDynamicTextureData(
+ m_tests.Scene.RegionInfo.RegionID,
+ so.UUID,
+ m_tests.Vrm.GetContentType(),
+ string.Format("PenColour BLACK; MoveTo 40,220; FontSize 32; Text {0};", text),
+ "",
+ 0);
+
+ Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
+
+ Pass++;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/prebuild.xml b/prebuild.xml
index 1765899..d9c1607 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3250,6 +3250,46 @@
+
+
+
+ ../../../bin/
+
+
+
+
+ ../../../bin/
+
+
+
+ ../../../bin/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--
cgit v1.1
From adce58b33a39c9456468f6d25834a8a7bded5adf Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 29 Aug 2012 23:19:21 +0100
Subject: Renaming existing 'torture' tests to 'performance' tests instead,
since this better matches what they really do.
nant target name changes to test-perf instead of torture, to match test-stress
still not run by default
---
.nant/local.include | 8 +-
OpenSim/Tests/Performance/NPCPerformanceTests.cs | 190 +++++++++++++++++++++
.../Tests/Performance/ObjectPerformanceTests.cs | 175 +++++++++++++++++++
.../Tests/Performance/ScriptPerformanceTests.cs | 168 ++++++++++++++++++
OpenSim/Tests/Torture/NPCTortureTests.cs | 190 ---------------------
OpenSim/Tests/Torture/ObjectTortureTests.cs | 175 -------------------
OpenSim/Tests/Torture/ScriptTortureTests.cs | 168 ------------------
prebuild.xml | 2 +-
8 files changed, 538 insertions(+), 538 deletions(-)
create mode 100644 OpenSim/Tests/Performance/NPCPerformanceTests.cs
create mode 100644 OpenSim/Tests/Performance/ObjectPerformanceTests.cs
create mode 100644 OpenSim/Tests/Performance/ScriptPerformanceTests.cs
delete mode 100644 OpenSim/Tests/Torture/NPCTortureTests.cs
delete mode 100644 OpenSim/Tests/Torture/ObjectTortureTests.cs
delete mode 100644 OpenSim/Tests/Torture/ScriptTortureTests.cs
diff --git a/.nant/local.include b/.nant/local.include
index 181c875..35f0058 100644
--- a/.nant/local.include
+++ b/.nant/local.include
@@ -146,14 +146,14 @@
-
+
-
-
+
+
-
+
diff --git a/OpenSim/Tests/Performance/NPCPerformanceTests.cs b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
new file mode 100644
index 0000000..627765b
--- /dev/null
+++ b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Reflection;
+using log4net;
+using Nini.Config;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Region.CoreModules.Avatar.Attachments;
+using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
+using OpenSim.Region.CoreModules.Framework.InventoryAccess;
+using OpenSim.Region.CoreModules.Framework.UserManagement;
+using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.OptionalModules.World.NPC;
+using OpenSim.Services.AvatarService;
+using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
+
+namespace OpenSim.Tests.Performance
+{
+ ///
+ /// NPC performance tests
+ ///
+ ///
+ /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
+ /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
+ /// earlier tests.
+ ///
+ [TestFixture]
+ public class NPCPerformanceTests
+ {
+ private TestScene scene;
+ private AvatarFactoryModule afm;
+ private UserManagementModule umm;
+ private AttachmentsModule am;
+
+ [TestFixtureSetUp]
+ public void FixtureInit()
+ {
+ // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
+ Util.FireAndForgetMethod = FireAndForgetMethod.None;
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ scene.Close();
+ scene = null;
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+
+ // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
+ // threads. Possibly, later tests should be rewritten not to worry about such things.
+ Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
+ }
+
+ [SetUp]
+ public void Init()
+ {
+ IConfigSource config = new IniConfigSource();
+ config.AddConfig("NPC");
+ config.Configs["NPC"].Set("Enabled", "true");
+ config.AddConfig("Modules");
+ config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
+
+ afm = new AvatarFactoryModule();
+ umm = new UserManagementModule();
+ am = new AttachmentsModule();
+
+ scene = new SceneHelpers().SetupScene();
+ SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
+ }
+
+ [Test]
+ public void Test_0001_AddRemove100NPCs()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddRemoveNPCs(100);
+ }
+
+ [Test]
+ public void Test_0002_AddRemove1000NPCs()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddRemoveNPCs(1000);
+ }
+
+ [Test]
+ public void Test_0003_AddRemove2000NPCs()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddRemoveNPCs(2000);
+ }
+
+ private void TestAddRemoveNPCs(int numberOfNpcs)
+ {
+ ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
+// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
+
+ // 8 is the index of the first baked texture in AvatarAppearance
+ UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
+ Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
+ Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
+ originalTef.TextureID = originalFace8TextureId;
+
+ // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
+ // ScenePresence.SendInitialData() to reset our entire appearance.
+ scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
+
+ afm.SetAppearance(sp, originalTe, null);
+
+ INPCModule npcModule = scene.RequestModuleInterface();
+
+ List npcs = new List();
+
+ long startGcMemory = GC.GetTotalMemory(true);
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+
+ for (int i = 0; i < numberOfNpcs; i++)
+ {
+ npcs.Add(
+ npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance));
+ }
+
+ for (int i = 0; i < numberOfNpcs; i++)
+ {
+ Assert.That(npcs[i], Is.Not.Null);
+
+ ScenePresence npc = scene.GetScenePresence(npcs[i]);
+ Assert.That(npc, Is.Not.Null);
+ }
+
+ for (int i = 0; i < numberOfNpcs; i++)
+ {
+ Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True);
+ ScenePresence npc = scene.GetScenePresence(npcs[i]);
+ Assert.That(npc, Is.Null);
+ }
+
+ sw.Stop();
+
+ long endGcMemory = GC.GetTotalMemory(true);
+
+ Console.WriteLine("Took {0} ms", sw.ElapsedMilliseconds);
+ Console.WriteLine(
+ "End {0} MB, Start {1} MB, Diff {2} MB",
+ endGcMemory / 1024 / 1024,
+ startGcMemory / 1024 / 1024,
+ (endGcMemory - startGcMemory) / 1024 / 1024);
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
new file mode 100644
index 0000000..2264d86
--- /dev/null
+++ b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using log4net;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
+
+namespace OpenSim.Tests.Performance
+{
+ ///
+ /// Object performance tests
+ ///
+ ///
+ /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
+ /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
+ /// earlier tests.
+ ///
+ [TestFixture]
+ public class ObjectPerformanceTests
+ {
+ [TearDown]
+ public void TearDown()
+ {
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ }
+
+// [Test]
+// public void Test0000Clean()
+// {
+// TestHelpers.InMethod();
+//// log4net.Config.XmlConfigurator.Configure();
+//
+// TestAddObjects(200000);
+// }
+
+ [Test]
+ public void Test_0001_10K_1PrimObjects()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddObjects(1, 10000);
+ }
+
+ [Test]
+ public void Test_0002_100K_1PrimObjects()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddObjects(1, 100000);
+ }
+
+ [Test]
+ public void Test_0003_200K_1PrimObjects()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddObjects(1, 200000);
+ }
+
+ [Test]
+ public void Test_0011_100_100PrimObjects()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddObjects(100, 100);
+ }
+
+ [Test]
+ public void Test_0012_1K_100PrimObjects()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddObjects(100, 1000);
+ }
+
+ [Test]
+ public void Test_0013_2K_100PrimObjects()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ TestAddObjects(100, 2000);
+ }
+
+ private void TestAddObjects(int primsInEachObject, int objectsToAdd)
+ {
+ UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000");
+
+ // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage
+ // collected when we teardown this test. If it's done in a member variable, even if that is subsequently
+ // nulled out, the garbage collect can be delayed.
+ TestScene scene = new SceneHelpers().SetupScene();
+
+// Process process = Process.GetCurrentProcess();
+// long startProcessMemory = process.PrivateMemorySize64;
+ long startGcMemory = GC.GetTotalMemory(true);
+ DateTime start = DateTime.Now;
+
+ for (int i = 1; i <= objectsToAdd; i++)
+ {
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i);
+ Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i));
+ }
+
+ TimeSpan elapsed = DateTime.Now - start;
+// long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory;
+ long endGcMemory = GC.GetTotalMemory(false);
+
+ for (int i = 1; i <= objectsToAdd; i++)
+ {
+ Assert.That(
+ scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)),
+ Is.Not.Null,
+ string.Format("Object {0} could not be retrieved", i));
+ }
+
+ // When a scene object is added to a scene, it is placed in the update list for sending to viewers
+ // (though in this case we have none). When it is deleted, it is not removed from the update which is
+ // fine since it will later be ignored.
+ //
+ // However, that means that we need to manually run an update here to clear out that list so that deleted
+ // objects will be clean up by the garbage collector before the next stress test is run.
+ scene.Update(1);
+
+ Console.WriteLine(
+ "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",
+ Math.Round(elapsed.TotalMilliseconds),
+ (endGcMemory - startGcMemory) / 1024 / 1024,
+ endGcMemory / 1024 / 1024,
+ startGcMemory / 1024 / 1024,
+ objectsToAdd,
+ primsInEachObject);
+
+ scene.Close();
+// scene = null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
new file mode 100644
index 0000000..d708abd
--- /dev/null
+++ b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Reflection;
+using System.Threading;
+using log4net;
+using Nini.Config;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Region.CoreModules.Scripting.WorldComm;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.ScriptEngine.XEngine;
+using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
+
+namespace OpenSim.Tests.Performance
+{
+ ///
+ /// Script performance tests
+ ///
+ ///
+ /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
+ /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
+ /// earlier tests.
+ ///
+ [TestFixture]
+ public class ScriptPerformanceTests
+ {
+ private TestScene m_scene;
+ private XEngine m_xEngine;
+ private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
+
+ private int m_expectedChatMessages;
+ private List m_osChatMessagesReceived = new List();
+
+ [SetUp]
+ public void Init()
+ {
+ //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
+// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
+ m_xEngine = new XEngine();
+
+ // Necessary to stop serialization complaining
+ WorldCommModule wcModule = new WorldCommModule();
+
+ IniConfigSource configSource = new IniConfigSource();
+
+ IConfig startupConfig = configSource.AddConfig("Startup");
+ startupConfig.Set("DefaultScriptEngine", "XEngine");
+
+ IConfig xEngineConfig = configSource.AddConfig("XEngine");
+ xEngineConfig.Set("Enabled", "true");
+
+ // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
+ // to AssemblyResolver.OnAssemblyResolve fails.
+ xEngineConfig.Set("AppDomainLoading", "false");
+
+ m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource);
+ SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);
+
+ m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
+ m_scene.StartScripts();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ m_scene.Close();
+ m_scene = null;
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ }
+
+ [Test]
+ public void TestCompileAndStart100Scripts()
+ {
+ TestHelpers.InMethod();
+ log4net.Config.XmlConfigurator.Configure();
+
+ TestCompileAndStartScripts(100);
+ }
+
+ private void TestCompileAndStartScripts(int scriptsToCreate)
+ {
+ UUID userId = TestHelpers.ParseTail(0x1);
+
+ m_expectedChatMessages = scriptsToCreate;
+ int startingObjectIdTail = 0x100;
+
+ GC.Collect();
+
+ for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
+ {
+ AddObjectAndScript(idTail, userId);
+ }
+
+ m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000);
+
+ Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages));
+
+ foreach (OSChatMessage msg in m_osChatMessagesReceived)
+ Assert.That(
+ msg.Message,
+ Is.EqualTo("Script running"),
+ string.Format(
+ "Message from {0} was {1} rather than {2}", msg.SenderUUID, msg.Message, "Script running"));
+ }
+
+ private void AddObjectAndScript(int objectIdTail, UUID userId)
+ {
+// UUID itemId = TestHelpers.ParseTail(0x3);
+ string itemName = string.Format("AddObjectAndScript() Item for object {0}", objectIdTail);
+
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "AddObjectAndScriptPart_", objectIdTail);
+ m_scene.AddNewSceneObject(so, true);
+
+ InventoryItemBase itemTemplate = new InventoryItemBase();
+// itemTemplate.ID = itemId;
+ itemTemplate.Name = itemName;
+ itemTemplate.Folder = so.UUID;
+ itemTemplate.InvType = (int)InventoryType.LSL;
+
+ m_scene.RezNewScript(userId, itemTemplate);
+ }
+
+ private void OnChatFromWorld(object sender, OSChatMessage oscm)
+ {
+// Console.WriteLine("Got chat [{0}]", oscm.Message);
+
+ lock (m_osChatMessagesReceived)
+ {
+ m_osChatMessagesReceived.Add(oscm);
+
+ if (m_osChatMessagesReceived.Count == m_expectedChatMessages)
+ m_chatEvent.Set();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Tests/Torture/NPCTortureTests.cs b/OpenSim/Tests/Torture/NPCTortureTests.cs
deleted file mode 100644
index 731df68..0000000
--- a/OpenSim/Tests/Torture/NPCTortureTests.cs
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using log4net;
-using Nini.Config;
-using NUnit.Framework;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Region.CoreModules.Avatar.Attachments;
-using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
-using OpenSim.Region.CoreModules.Framework.InventoryAccess;
-using OpenSim.Region.CoreModules.Framework.UserManagement;
-using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.OptionalModules.World.NPC;
-using OpenSim.Services.AvatarService;
-using OpenSim.Tests.Common;
-using OpenSim.Tests.Common.Mock;
-
-namespace OpenSim.Tests.Torture
-{
- ///
- /// NPC torture tests
- ///
- ///
- /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
- /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
- /// earlier tests.
- ///
- [TestFixture]
- public class NPCTortureTests
- {
- private TestScene scene;
- private AvatarFactoryModule afm;
- private UserManagementModule umm;
- private AttachmentsModule am;
-
- [TestFixtureSetUp]
- public void FixtureInit()
- {
- // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
- Util.FireAndForgetMethod = FireAndForgetMethod.None;
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- scene.Close();
- scene = null;
- GC.Collect();
- GC.WaitForPendingFinalizers();
-
- // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
- // threads. Possibly, later tests should be rewritten not to worry about such things.
- Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
- }
-
- [SetUp]
- public void Init()
- {
- IConfigSource config = new IniConfigSource();
- config.AddConfig("NPC");
- config.Configs["NPC"].Set("Enabled", "true");
- config.AddConfig("Modules");
- config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
-
- afm = new AvatarFactoryModule();
- umm = new UserManagementModule();
- am = new AttachmentsModule();
-
- scene = new SceneHelpers().SetupScene();
- SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
- }
-
- [Test]
- public void Test_0001_AddRemove100NPCs()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddRemoveNPCs(100);
- }
-
- [Test]
- public void Test_0002_AddRemove1000NPCs()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddRemoveNPCs(1000);
- }
-
- [Test]
- public void Test_0003_AddRemove2000NPCs()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddRemoveNPCs(2000);
- }
-
- private void TestAddRemoveNPCs(int numberOfNpcs)
- {
- ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
-// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
-
- // 8 is the index of the first baked texture in AvatarAppearance
- UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
- Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
- Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
- originalTef.TextureID = originalFace8TextureId;
-
- // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
- // ScenePresence.SendInitialData() to reset our entire appearance.
- scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
-
- afm.SetAppearance(sp, originalTe, null);
-
- INPCModule npcModule = scene.RequestModuleInterface();
-
- List npcs = new List();
-
- long startGcMemory = GC.GetTotalMemory(true);
- Stopwatch sw = new Stopwatch();
- sw.Start();
-
- for (int i = 0; i < numberOfNpcs; i++)
- {
- npcs.Add(
- npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance));
- }
-
- for (int i = 0; i < numberOfNpcs; i++)
- {
- Assert.That(npcs[i], Is.Not.Null);
-
- ScenePresence npc = scene.GetScenePresence(npcs[i]);
- Assert.That(npc, Is.Not.Null);
- }
-
- for (int i = 0; i < numberOfNpcs; i++)
- {
- Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True);
- ScenePresence npc = scene.GetScenePresence(npcs[i]);
- Assert.That(npc, Is.Null);
- }
-
- sw.Stop();
-
- long endGcMemory = GC.GetTotalMemory(true);
-
- Console.WriteLine("Took {0} ms", sw.ElapsedMilliseconds);
- Console.WriteLine(
- "End {0} MB, Start {1} MB, Diff {2} MB",
- endGcMemory / 1024 / 1024,
- startGcMemory / 1024 / 1024,
- (endGcMemory - startGcMemory) / 1024 / 1024);
- }
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs
deleted file mode 100644
index 195d47b..0000000
--- a/OpenSim/Tests/Torture/ObjectTortureTests.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Diagnostics;
-using System.Reflection;
-using log4net;
-using NUnit.Framework;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Tests.Common;
-using OpenSim.Tests.Common.Mock;
-
-namespace OpenSim.Tests.Torture
-{
- ///
- /// Object torture tests
- ///
- ///
- /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
- /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
- /// earlier tests.
- ///
- [TestFixture]
- public class ObjectTortureTests
- {
- [TearDown]
- public void TearDown()
- {
- GC.Collect();
- GC.WaitForPendingFinalizers();
- }
-
-// [Test]
-// public void Test0000Clean()
-// {
-// TestHelpers.InMethod();
-//// log4net.Config.XmlConfigurator.Configure();
-//
-// TestAddObjects(200000);
-// }
-
- [Test]
- public void Test_0001_10K_1PrimObjects()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddObjects(1, 10000);
- }
-
- [Test]
- public void Test_0002_100K_1PrimObjects()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddObjects(1, 100000);
- }
-
- [Test]
- public void Test_0003_200K_1PrimObjects()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddObjects(1, 200000);
- }
-
- [Test]
- public void Test_0011_100_100PrimObjects()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddObjects(100, 100);
- }
-
- [Test]
- public void Test_0012_1K_100PrimObjects()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddObjects(100, 1000);
- }
-
- [Test]
- public void Test_0013_2K_100PrimObjects()
- {
- TestHelpers.InMethod();
-// log4net.Config.XmlConfigurator.Configure();
-
- TestAddObjects(100, 2000);
- }
-
- private void TestAddObjects(int primsInEachObject, int objectsToAdd)
- {
- UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000");
-
- // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage
- // collected when we teardown this test. If it's done in a member variable, even if that is subsequently
- // nulled out, the garbage collect can be delayed.
- TestScene scene = new SceneHelpers().SetupScene();
-
-// Process process = Process.GetCurrentProcess();
-// long startProcessMemory = process.PrivateMemorySize64;
- long startGcMemory = GC.GetTotalMemory(true);
- DateTime start = DateTime.Now;
-
- for (int i = 1; i <= objectsToAdd; i++)
- {
- SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i);
- Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i));
- }
-
- TimeSpan elapsed = DateTime.Now - start;
-// long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory;
- long endGcMemory = GC.GetTotalMemory(false);
-
- for (int i = 1; i <= objectsToAdd; i++)
- {
- Assert.That(
- scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)),
- Is.Not.Null,
- string.Format("Object {0} could not be retrieved", i));
- }
-
- // When a scene object is added to a scene, it is placed in the update list for sending to viewers
- // (though in this case we have none). When it is deleted, it is not removed from the update which is
- // fine since it will later be ignored.
- //
- // However, that means that we need to manually run an update here to clear out that list so that deleted
- // objects will be clean up by the garbage collector before the next stress test is run.
- scene.Update(1);
-
- Console.WriteLine(
- "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",
- Math.Round(elapsed.TotalMilliseconds),
- (endGcMemory - startGcMemory) / 1024 / 1024,
- endGcMemory / 1024 / 1024,
- startGcMemory / 1024 / 1024,
- objectsToAdd,
- primsInEachObject);
-
- scene.Close();
-// scene = null;
- }
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Tests/Torture/ScriptTortureTests.cs b/OpenSim/Tests/Torture/ScriptTortureTests.cs
deleted file mode 100644
index 24f278f..0000000
--- a/OpenSim/Tests/Torture/ScriptTortureTests.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Threading;
-using log4net;
-using Nini.Config;
-using NUnit.Framework;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.CoreModules.Scripting.WorldComm;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.ScriptEngine.XEngine;
-using OpenSim.Tests.Common;
-using OpenSim.Tests.Common.Mock;
-
-namespace OpenSim.Tests.Torture
-{
- ///
- /// Script torture tests
- ///
- ///
- /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
- /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
- /// earlier tests.
- ///
- [TestFixture]
- public class ScriptTortureTests
- {
- private TestScene m_scene;
- private XEngine m_xEngine;
- private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
-
- private int m_expectedChatMessages;
- private List m_osChatMessagesReceived = new List();
-
- [SetUp]
- public void Init()
- {
- //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
-// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
- m_xEngine = new XEngine();
-
- // Necessary to stop serialization complaining
- WorldCommModule wcModule = new WorldCommModule();
-
- IniConfigSource configSource = new IniConfigSource();
-
- IConfig startupConfig = configSource.AddConfig("Startup");
- startupConfig.Set("DefaultScriptEngine", "XEngine");
-
- IConfig xEngineConfig = configSource.AddConfig("XEngine");
- xEngineConfig.Set("Enabled", "true");
-
- // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
- // to AssemblyResolver.OnAssemblyResolve fails.
- xEngineConfig.Set("AppDomainLoading", "false");
-
- m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource);
- SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);
-
- m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
- m_scene.StartScripts();
- }
-
- [TearDown]
- public void TearDown()
- {
- m_scene.Close();
- m_scene = null;
- GC.Collect();
- GC.WaitForPendingFinalizers();
- }
-
- [Test]
- public void TestCompileAndStart100Scripts()
- {
- TestHelpers.InMethod();
- log4net.Config.XmlConfigurator.Configure();
-
- TestCompileAndStartScripts(100);
- }
-
- private void TestCompileAndStartScripts(int scriptsToCreate)
- {
- UUID userId = TestHelpers.ParseTail(0x1);
-
- m_expectedChatMessages = scriptsToCreate;
- int startingObjectIdTail = 0x100;
-
- GC.Collect();
-
- for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
- {
- AddObjectAndScript(idTail, userId);
- }
-
- m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000);
-
- Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages));
-
- foreach (OSChatMessage msg in m_osChatMessagesReceived)
- Assert.That(
- msg.Message,
- Is.EqualTo("Script running"),
- string.Format(
- "Message from {0} was {1} rather than {2}", msg.SenderUUID, msg.Message, "Script running"));
- }
-
- private void AddObjectAndScript(int objectIdTail, UUID userId)
- {
-// UUID itemId = TestHelpers.ParseTail(0x3);
- string itemName = string.Format("AddObjectAndScript() Item for object {0}", objectIdTail);
-
- SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "AddObjectAndScriptPart_", objectIdTail);
- m_scene.AddNewSceneObject(so, true);
-
- InventoryItemBase itemTemplate = new InventoryItemBase();
-// itemTemplate.ID = itemId;
- itemTemplate.Name = itemName;
- itemTemplate.Folder = so.UUID;
- itemTemplate.InvType = (int)InventoryType.LSL;
-
- m_scene.RezNewScript(userId, itemTemplate);
- }
-
- private void OnChatFromWorld(object sender, OSChatMessage oscm)
- {
-// Console.WriteLine("Got chat [{0}]", oscm.Message);
-
- lock (m_osChatMessagesReceived)
- {
- m_osChatMessagesReceived.Add(oscm);
-
- if (m_osChatMessagesReceived.Count == m_expectedChatMessages)
- m_chatEvent.Set();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/prebuild.xml b/prebuild.xml
index d9c1607..0f34713 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3290,7 +3290,7 @@
-
+ ../../../bin/
--
cgit v1.1
From 6b277394c080f5ad50d07e94f3e21340da4913b3 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Wed, 29 Aug 2012 17:21:01 +0100
Subject: refactoring as the list funcs either skip invalid values or recall
ToDoubleList
---
.../Shared/Api/Implementation/LSL_Api.cs | 23 +++++++++++-----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ae92716..45286c0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10119,31 +10119,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Float llListStatistics(int operation, LSL_List src)
{
m_host.AddScriptLPS(1);
- LSL_List nums = LSL_List.ToDoubleList(src);
switch (operation)
{
case ScriptBaseClass.LIST_STAT_RANGE:
- return nums.Range();
+ return src.Range();
case ScriptBaseClass.LIST_STAT_MIN:
- return nums.Min();
+ return src.Min();
case ScriptBaseClass.LIST_STAT_MAX:
- return nums.Max();
+ return src.Max();
case ScriptBaseClass.LIST_STAT_MEAN:
- return nums.Mean();
+ return src.Mean();
case ScriptBaseClass.LIST_STAT_MEDIAN:
- return nums.Median();
+ return LSL_List.ToDoubleList(src).Median();
case ScriptBaseClass.LIST_STAT_NUM_COUNT:
- return nums.NumericLength();
+ return src.NumericLength();
case ScriptBaseClass.LIST_STAT_STD_DEV:
- return nums.StdDev();
+ return src.StdDev();
case ScriptBaseClass.LIST_STAT_SUM:
- return nums.Sum();
+ return src.Sum();
case ScriptBaseClass.LIST_STAT_SUM_SQUARES:
- return nums.SumSqrs();
+ return src.SumSqrs();
case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN:
- return nums.GeometricMean();
+ return src.GeometricMean();
case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN:
- return nums.HarmonicMean();
+ return src.HarmonicMean();
default:
return 0.0;
}
--
cgit v1.1
From c76c63725bedb1f7e22dba23d3a8034885ff60e5 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Wed, 29 Aug 2012 17:21:16 +0100
Subject: fixing bug where last element in list is ignored
---
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 9d9df9c..fcb98a5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -1137,7 +1137,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
{
list ret = new list();
double entry;
- for (int i = 0; i < src.Data.Length - 1; i++)
+ for (int i = 0; i < src.Data.Length; i++)
{
if (double.TryParse(src.Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry))
{
--
cgit v1.1
From d89b974680af52a2d950237962240dde82ff4a85 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 30 Aug 2012 22:28:45 +0100
Subject: If the compile-time DynamicTextureModule.ReuseTextures flag is set,
check metadata still exists for any reused asset in case some other process
has removed it from the cache.
---
.../DynamicTexture/DynamicTextureModule.cs | 102 ++++++++++++---------
1 file changed, 59 insertions(+), 43 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 13b7498..f169117 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -186,63 +186,79 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face)
{
- if (RenderPlugins.ContainsKey(contentType))
- {
- // If we want to reuse dynamic textures then we have to ignore any request from the caller to expire
- // them.
- if (ReuseTextures)
- disp = disp & ~DISP_EXPIRE;
+ if (!RenderPlugins.ContainsKey(contentType))
+ return UUID.Zero;
- DynamicTextureUpdater updater = new DynamicTextureUpdater();
- updater.SimUUID = simID;
- updater.PrimID = primID;
- updater.ContentType = contentType;
- updater.BodyData = data;
- updater.UpdateTimer = updateTimer;
- updater.UpdaterID = UUID.Random();
- updater.Params = extraParams;
- updater.BlendWithOldTexture = SetBlending;
- updater.FrontAlpha = AlphaValue;
- updater.Face = face;
- updater.Url = "Local image";
- updater.Disp = disp;
+ Scene scene;
+ RegisteredScenes.TryGetValue(simID, out scene);
+
+ if (scene == null)
+ return UUID.Zero;
- object reusableTextureUUID = null;
+ SceneObjectPart part = scene.GetSceneObjectPart(primID);
- if (ReuseTextures)
- reusableTextureUUID
- = m_reuseableDynamicTextures.Get(GenerateReusableTextureKey(data, extraParams));
+ if (part == null)
+ return UUID.Zero;
+
+ // If we want to reuse dynamic textures then we have to ignore any request from the caller to expire
+ // them.
+ if (ReuseTextures)
+ disp = disp & ~DISP_EXPIRE;
+
+ DynamicTextureUpdater updater = new DynamicTextureUpdater();
+ updater.SimUUID = simID;
+ updater.PrimID = primID;
+ updater.ContentType = contentType;
+ updater.BodyData = data;
+ updater.UpdateTimer = updateTimer;
+ updater.UpdaterID = UUID.Random();
+ updater.Params = extraParams;
+ updater.BlendWithOldTexture = SetBlending;
+ updater.FrontAlpha = AlphaValue;
+ updater.Face = face;
+ updater.Url = "Local image";
+ updater.Disp = disp;
+
+ object objReusableTextureUUID = null;
+
+ if (ReuseTextures && !updater.BlendWithOldTexture)
+ {
+ string reuseableTextureKey = GenerateReusableTextureKey(data, extraParams);
+ objReusableTextureUUID = m_reuseableDynamicTextures.Get(reuseableTextureKey);
- // We cannot reuse a dynamic texture if the data is going to be blended with something already there.
- if (reusableTextureUUID == null || updater.BlendWithOldTexture)
+ if (objReusableTextureUUID != null)
{
- lock (Updaters)
+ // If something else has removed this temporary asset from the cache, detect and invalidate
+ // our cached uuid.
+ if (scene.AssetService.GetMetadata(objReusableTextureUUID.ToString()) == null)
{
- if (!Updaters.ContainsKey(updater.UpdaterID))
- {
- Updaters.Add(updater.UpdaterID, updater);
- }
+ m_reuseableDynamicTextures.Invalidate(reuseableTextureKey);
+ objReusableTextureUUID = null;
}
-
- RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
}
- else
+ }
+
+ // We cannot reuse a dynamic texture if the data is going to be blended with something already there.
+ if (objReusableTextureUUID == null)
+ {
+ lock (Updaters)
{
- // No need to add to updaters as the texture is always the same. Not that this functionality
- // apppears to be implemented anyway.
- if (RegisteredScenes.ContainsKey(updater.SimUUID))
+ if (!Updaters.ContainsKey(updater.UpdaterID))
{
- SceneObjectPart part = RegisteredScenes[updater.SimUUID].GetSceneObjectPart(updater.PrimID);
-
- if (part != null)
- updater.UpdatePart(part, (UUID)reusableTextureUUID);
+ Updaters.Add(updater.UpdaterID, updater);
}
}
- return updater.UpdaterID;
+ RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
}
-
- return UUID.Zero;
+ else
+ {
+ // No need to add to updaters as the texture is always the same. Not that this functionality
+ // apppears to be implemented anyway.
+ updater.UpdatePart(part, (UUID)objReusableTextureUUID);
+ }
+
+ return updater.UpdaterID;
}
private string GenerateReusableTextureKey(string data, string extraParams)
--
cgit v1.1
From 3ed0d79b00c313eacb2a7df7d5519e840d2fc5c4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 30 Aug 2012 22:57:40 +0100
Subject: Make ReuseDynamicTextures an experimental config setting in
[Textures]. Default is false, as before.
If true, this setting reuses dynamically generated textures (i.e. created through osSetDynamicTextureData() and similar OSSL functions) where possible rather than always regenerating them.
This results in much quicker updates viewer-side but may bloat the asset cache (though this is fixable).
Also, sometimes issue have been seen where dynamic textures do not transfer to the viewer properly (permanently blurry).
If this happens and that flag is set then they are not regenerated, the viewer has to clear cache or wait for 24 hours before all cached uuids are invalidated.
CUrrently experimental. Default is false, as before.
---
.../Scripting/DynamicTexture/DynamicTextureModule.cs | 5 ++++-
bin/OpenSimDefaults.ini | 11 +++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index f169117..3eedf49 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -283,6 +283,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public void Initialise(Scene scene, IConfigSource config)
{
+ IConfig texturesConfig = config.Configs["Textures"];
+ if (texturesConfig != null)
+ ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false);
+
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
@@ -292,7 +296,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public void PostInitialise()
{
-// ReuseTextures = true;
if (ReuseTextures)
{
m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative);
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini
index b2fca0c..42b295f 100644
--- a/bin/OpenSimDefaults.ini
+++ b/bin/OpenSimDefaults.ini
@@ -693,6 +693,17 @@
;LevelUpload = 0
+[Textures]
+ ; If true, textures generated dynamically (i.e. through osSetDynamicTextureData() and similar OSSL functions) are reused where possible
+ ; Chiefly, reuse occurs if a texture has already been generated with identical data and settings, and that texture contains no dynamic components
+ ; (e.g. images pulled from an external HTTP address).
+ ; Reusing previously generated textures results in a much faster update on the viewer but may cause issues if the viewer didn't receive all resolutions of the texture.
+ ; Currently, it will also increase asset cache use since temporary dynamic textures are no longer deleted.
+ ; Hence, currently considered experimental.
+ ; Default is false.
+ ReuseDynamicTextures = false
+
+
[ODEPhysicsSettings]
; ##
; ## Physics stats settings
--
cgit v1.1
From 7c6e8fab155ff24d460e8de4597531849c291957 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 31 Aug 2012 00:29:57 +0100
Subject: Do Windlight storage and removal calls in MySQL under m_dbLock, as is
done with all the other database calls.
---
OpenSim/Data/MySQL/MySQLSimulationData.cs | 210 +++++++++++++++---------------
1 file changed, 108 insertions(+), 102 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 3fc04ee..a021590 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -853,118 +853,124 @@ namespace OpenSim.Data.MySQL
public void StoreRegionWindlightSettings(RegionLightShareData wl)
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ lock (m_dbLock)
{
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, ";
- cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, ";
- cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, ";
- cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, ";
- cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, ";
- cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, ";
- cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, ";
- cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, ";
- cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, ";
- cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, ";
- cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, ";
- cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, ";
- cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, ";
- cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, ";
- cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, ";
- cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, ";
- cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, ";
- cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, ";
- cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, ";
- cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, ";
- cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, ";
- cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, ";
- cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, ";
- cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, ";
- cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)";
-
- cmd.Parameters.AddWithValue("region_id", wl.regionID);
- cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
- cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
- cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
- cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
- cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
- cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
- cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
- cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
- cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
- cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
- cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
- cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
- cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
- cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
- cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
- cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
- cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
- cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
- cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
- cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
- cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
- cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
- cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
- cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
- cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
- cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
- cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
- cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
- cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
- cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
- cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
- cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
- cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
- cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
- cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
- cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
- cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
- cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
- cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
- cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
- cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
- cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
- cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
- cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
- cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
- cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
- cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
- cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
- cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
- cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
- cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
- cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
- cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
- cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
- cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
- cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
- cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
- cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
- cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
- cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
- cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
- cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
-
- ExecuteNonQuery(cmd);
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, ";
+ cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, ";
+ cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, ";
+ cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, ";
+ cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, ";
+ cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, ";
+ cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, ";
+ cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, ";
+ cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, ";
+ cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, ";
+ cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, ";
+ cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, ";
+ cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, ";
+ cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, ";
+ cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, ";
+ cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, ";
+ cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, ";
+ cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, ";
+ cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, ";
+ cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, ";
+ cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, ";
+ cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, ";
+ cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, ";
+ cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, ";
+ cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)";
+
+ cmd.Parameters.AddWithValue("region_id", wl.regionID);
+ cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
+ cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
+ cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
+ cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
+ cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
+ cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
+ cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
+ cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
+ cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
+ cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
+ cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
+ cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
+ cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
+ cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
+ cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
+ cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
+ cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
+ cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
+ cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
+ cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
+ cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
+ cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
+ cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
+ cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
+ cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
+ cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
+ cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
+ cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
+ cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
+ cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
+ cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
+ cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
+ cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
+ cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
+ cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
+ cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
+ cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
+ cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
+ cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
+ cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
+ cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
+ cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
+ cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
+ cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
+ cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
+ cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
+ cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
+ cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
+ cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
+ cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
+ cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
+ cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
+ cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
+ cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
+ cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
+ cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
+ cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
+ cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
+ cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
+ cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
+ cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
+ cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
+
+ ExecuteNonQuery(cmd);
+ }
}
}
}
public void RemoveRegionWindlightSettings(UUID regionID)
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ lock (m_dbLock)
{
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID";
- cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
- ExecuteNonQuery(cmd);
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID";
+ cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
+ ExecuteNonQuery(cmd);
+ }
}
}
}
--
cgit v1.1
From 3bd3f448a2d5b64b267427a0f8f820109338a7bb Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 31 Aug 2012 00:33:06 +0100
Subject: Also do other MySQL region settings related calls under m_dbLock, in
common with other calls.
---
OpenSim/Data/MySQL/MySQLSimulationData.cs | 247 ++++++++++++++++--------------
1 file changed, 130 insertions(+), 117 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index a021590..d562783 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -719,95 +719,99 @@ namespace OpenSim.Data.MySQL
RegionLightShareData nWP = new RegionLightShareData();
nWP.OnSave += StoreRegionWindlightSettings;
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ lock (m_dbLock)
{
- dbcon.Open();
-
- string command = "select * from `regionwindlight` where region_id = ?regionID";
-
- using (MySqlCommand cmd = new MySqlCommand(command))
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- cmd.Connection = dbcon;
-
- cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
-
- IDataReader result = ExecuteReader(cmd);
- if (!result.Read())
- {
- //No result, so store our default windlight profile and return it
- nWP.regionID = regionUUID;
- StoreRegionWindlightSettings(nWP);
- return nWP;
- }
- else
+ dbcon.Open();
+
+ string command = "select * from `regionwindlight` where region_id = ?regionID";
+
+ using (MySqlCommand cmd = new MySqlCommand(command))
{
- nWP.regionID = DBGuid.FromDB(result["region_id"]);
- nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
- nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
- nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
- nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
- nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
- nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
- nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
- nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
- nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
- nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
- nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
- nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
- nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
- nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
- nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
- nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
- nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
- UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
- nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
- nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
- nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
- nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
- nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
- nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
- nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
- nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
- nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
- nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
- nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
- nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
- nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
- nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
- nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
- nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
- nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
- nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
- nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
- nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
- nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
- nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
- nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
- nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
- nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
- nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
- nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
- nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
- nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
- nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
- nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
- nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
- nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
- nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
- nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
- nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
- nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
- nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
- nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
- nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
- nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
- nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
- nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
- nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
- nWP.valid = true;
+ cmd.Connection = dbcon;
+
+ cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
+
+ IDataReader result = ExecuteReader(cmd);
+ if (!result.Read())
+ {
+ //No result, so store our default windlight profile and return it
+ nWP.regionID = regionUUID;
+ StoreRegionWindlightSettings(nWP);
+ return nWP;
+ }
+ else
+ {
+ nWP.regionID = DBGuid.FromDB(result["region_id"]);
+ nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
+ nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
+ nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
+ nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
+ nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
+ nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
+ nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
+ nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
+ nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
+ nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
+ nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
+ nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
+ nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
+ nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
+ nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
+ nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
+ nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
+ UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
+ nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
+ nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
+ nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
+ nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
+ nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
+ nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
+ nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
+ nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
+ nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
+ nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
+ nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
+ nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
+ nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
+ nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
+ nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
+ nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
+ nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
+ nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
+ nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
+ nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
+ nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
+ nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
+ nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
+ nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
+ nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
+ nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
+ nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
+ nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
+ nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
+ nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
+ nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
+ nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
+ nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
+ nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
+ nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
+ nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
+ nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
+ nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
+ nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
+ nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
+ nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
+ nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
+ nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
+ nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
+ nWP.valid = true;
+ }
}
}
}
+
return nWP;
}
@@ -978,26 +982,29 @@ namespace OpenSim.Data.MySQL
#region RegionEnvironmentSettings
public string LoadRegionEnvironmentSettings(UUID regionUUID)
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ lock (m_dbLock)
{
- dbcon.Open();
-
- string command = "select * from `regionenvironment` where region_id = ?region_id";
-
- using (MySqlCommand cmd = new MySqlCommand(command))
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- cmd.Connection = dbcon;
-
- cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
-
- IDataReader result = ExecuteReader(cmd);
- if (!result.Read())
- {
- return String.Empty;
- }
- else
+ dbcon.Open();
+
+ string command = "select * from `regionenvironment` where region_id = ?region_id";
+
+ using (MySqlCommand cmd = new MySqlCommand(command))
{
- return Convert.ToString(result["llsd_settings"]);
+ cmd.Connection = dbcon;
+
+ cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
+
+ IDataReader result = ExecuteReader(cmd);
+ if (!result.Read())
+ {
+ return String.Empty;
+ }
+ else
+ {
+ return Convert.ToString(result["llsd_settings"]);
+ }
}
}
}
@@ -1005,33 +1012,39 @@ namespace OpenSim.Data.MySQL
public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ lock (m_dbLock)
{
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
-
- cmd.Parameters.AddWithValue("region_id", regionUUID);
- cmd.Parameters.AddWithValue("llsd_settings", settings);
-
- ExecuteNonQuery(cmd);
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
+
+ cmd.Parameters.AddWithValue("region_id", regionUUID);
+ cmd.Parameters.AddWithValue("llsd_settings", settings);
+
+ ExecuteNonQuery(cmd);
+ }
}
}
}
public void RemoveRegionEnvironmentSettings(UUID regionUUID)
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ lock (m_dbLock)
{
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
- cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
- ExecuteNonQuery(cmd);
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
+ cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
+ ExecuteNonQuery(cmd);
+ }
}
}
}
--
cgit v1.1
From 68814f904e1f0c5be961791f3f475dcda4a88248 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 31 Aug 2012 00:37:27 +0100
Subject: Replace SendBannedUserList with Avination's version. Untested in
core. Not even test compiled.
---
.../Region/ClientStack/Linden/UDP/LLClientView.cs | 57 ++++++++++++----------
1 file changed, 32 insertions(+), 25 deletions(-)
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 148d0e0..d05ffea 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -4451,37 +4451,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (bl[i].BannedUserID == UUID.Zero)
continue;
BannedUsers.Add(bl[i].BannedUserID);
- }
- EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
- packet.AgentData.TransactionID = UUID.Random();
- packet.AgentData.AgentID = AgentId;
- packet.AgentData.SessionID = SessionId;
- packet.MethodData.Invoice = invoice;
- packet.MethodData.Method = Utils.StringToBytes("setaccess");
+ if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
+ {
+ EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
+ packet.AgentData.TransactionID = UUID.Random();
+ packet.AgentData.AgentID = AgentId;
+ packet.AgentData.SessionID = SessionId;
+ packet.MethodData.Invoice = invoice;
+ packet.MethodData.Method = Utils.StringToBytes("setaccess");
- EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
+ EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
- for (int i = 0; i < (6 + BannedUsers.Count); i++)
- {
- returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
- }
- int j = 0;
+ int j;
+ for (j = 0; j < (6 + BannedUsers.Count); j++)
+ {
+ returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
+ }
+ j = 0;
- returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
- returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
- returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
- returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
- returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
- returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
+ returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
+ returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
+ returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
+ returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
+ returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
+ returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
- foreach (UUID banned in BannedUsers)
- {
- returnblock[j].Parameter = banned.GetBytes(); j++;
+ foreach (UUID banned in BannedUsers)
+ {
+ returnblock[j].Parameter = banned.GetBytes(); j++;
+ }
+ packet.ParamList = returnblock;
+ packet.Header.Reliable = true;
+ OutPacket(packet, ThrottleOutPacketType.Task);
+
+ BannedUsers.Clear();
+ }
}
- packet.ParamList = returnblock;
- packet.Header.Reliable = false;
- OutPacket(packet, ThrottleOutPacketType.Task);
+
}
public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
--
cgit v1.1
From 3c019bea8c006c6d09e6fa5583f60e01a87b766b Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Thu, 30 Aug 2012 15:55:03 +0100
Subject: Implementing a vastly simpler means of allowing region modules to
access GetLinkParts than mantis 6236
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 45286c0..be22cb4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -247,7 +247,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return GetLinkParts(m_host, linkType);
}
- private List GetLinkParts(SceneObjectPart part, int linkType)
+ public static List GetLinkParts(SceneObjectPart part, int linkType)
{
List ret = new List();
ret.Add(part);
--
cgit v1.1
From 973f2e8be540163e12dd8d85fffad3acd96fe212 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 12:50:32 +0100
Subject: adding documentation to script invokation methods
---
.../Framework/Interfaces/IScriptModuleComms.cs | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
index ed71a95..ff8213c 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
@@ -46,9 +46,31 @@ namespace OpenSim.Region.Framework.Interfaces
///
event ScriptCommand OnScriptCommand;
+ ///
+ /// Register an instance method as a script call by method name
+ ///
+ ///
+ ///
void RegisterScriptInvocation(object target, string method);
+
+ ///
+ /// Register an instance method as a script call by method info
+ ///
+ ///
+ ///
void RegisterScriptInvocation(object target, MethodInfo method);
+
+ ///
+ /// Register one or more instance methods as script calls by method name
+ ///
+ ///
+ ///
void RegisterScriptInvocation(object target, string[] methods);
+
+ ///
+ /// Returns an array of all registered script calls
+ ///
+ ///
Delegate[] GetScriptInvocationList();
Delegate LookupScriptInvocation(string fname);
--
cgit v1.1
From dff746df7be488d8ff35c91a974f406216222423 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 12:56:30 +0100
Subject: moving code that will be common into private static method
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 705a847..de0e864 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -130,10 +130,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
m_scriptModule.PostScriptEvent(script, "link_message", args);
}
- public void RegisterScriptInvocation(object target, string meth)
+ private static MethodInfo GetMethodInfoFromType(object target, string meth)
{
MethodInfo mi = target.GetType().GetMethod(meth,
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+
+ return mi;
+ }
+
+ public void RegisterScriptInvocation(object target, string meth)
+ {
+ MethodInfo mi = GetMethodInfoFromType(target, meth);
if (mi == null)
{
m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth);
--
cgit v1.1
From 05648c2c4ad1283f5bd975c4a50ca5a949e67994 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 12:57:51 +0100
Subject: changing to use Type argument instead of object
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index de0e864..21aab84 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -130,9 +130,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
m_scriptModule.PostScriptEvent(script, "link_message", args);
}
- private static MethodInfo GetMethodInfoFromType(object target, string meth)
+ private static MethodInfo GetMethodInfoFromType(Type target, string meth)
{
- MethodInfo mi = target.GetType().GetMethod(meth,
+ MethodInfo mi = target.GetMethod(meth,
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
return mi;
@@ -140,7 +140,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
public void RegisterScriptInvocation(object target, string meth)
{
- MethodInfo mi = GetMethodInfoFromType(target, meth);
+ MethodInfo mi = GetMethodInfoFromType(target.GetType(), meth);
if (mi == null)
{
m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth);
--
cgit v1.1
From 7a9eee8538f474a617a379a66854fe5fa6cb68cd Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 12:59:07 +0100
Subject: no need to assign result to GetMethodInfoFromType
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 21aab84..bbf0dac 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -132,10 +132,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
private static MethodInfo GetMethodInfoFromType(Type target, string meth)
{
- MethodInfo mi = target.GetMethod(meth,
+ return target.GetMethod(meth,
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
-
- return mi;
}
public void RegisterScriptInvocation(object target, string meth)
--
cgit v1.1
From bcf944db4846b42a302e443050132aaea4b4d4d6 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:01:07 +0100
Subject: assign binding flags to variable
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index bbf0dac..50d04cd 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -132,8 +132,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
private static MethodInfo GetMethodInfoFromType(Type target, string meth)
{
+ BindingFlags getMethodFlags =
+ BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
return target.GetMethod(meth,
- BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+ getMethodFlags);
}
public void RegisterScriptInvocation(object target, string meth)
--
cgit v1.1
From e6f43023b6fe682971b78175fbb694c18848eff0 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:09:15 +0100
Subject: adding support for finding static methods
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 50d04cd..19130bd 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -130,17 +130,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
m_scriptModule.PostScriptEvent(script, "link_message", args);
}
- private static MethodInfo GetMethodInfoFromType(Type target, string meth)
+ private static MethodInfo GetMethodInfoFromType(Type target, string meth, bool searchInstanceMethods)
{
BindingFlags getMethodFlags =
- BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
+ BindingFlags.NonPublic | BindingFlags.Public;
+
+ if (searchInstanceMethods)
+ getMethodFlags |= BindingFlags.Instance;
+ else
+ getMethodFlags |= BindingFlags.Static;
+
return target.GetMethod(meth,
getMethodFlags);
}
public void RegisterScriptInvocation(object target, string meth)
{
- MethodInfo mi = GetMethodInfoFromType(target.GetType(), meth);
+ MethodInfo mi = GetMethodInfoFromType(target.GetType(), meth, true);
if (mi == null)
{
m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth);
--
cgit v1.1
From 4c58c1b116d99b72d7c579f2bd2cc87d55b71451 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:10:17 +0100
Subject: formatting
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 19130bd..d785a24 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -140,8 +140,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
else
getMethodFlags |= BindingFlags.Static;
- return target.GetMethod(meth,
- getMethodFlags);
+ return target.GetMethod(meth, getMethodFlags);
}
public void RegisterScriptInvocation(object target, string meth)
--
cgit v1.1
From 8cd415c2b0e7bb7989c64ac17cfaa1b892128b87 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:10:23 +0100
Subject: formatting
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index d785a24..77d7e0a 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -148,7 +148,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
MethodInfo mi = GetMethodInfoFromType(target.GetType(), meth, true);
if (mi == null)
{
- m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth);
+ m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}", meth);
return;
}
--
cgit v1.1
From 7e41559917dbdd9ff1f70765a5a33e2e8f67e9a3 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:13:57 +0100
Subject: using specific type instead of var
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 77d7e0a..6231624 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -166,7 +166,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, target.GetType().Name);
Type delegateType;
- var typeArgs = mi.GetParameters()
+ List typeArgs = mi.GetParameters()
.Select(p => p.ParameterType)
.ToList();
--
cgit v1.1
From b62557978058512ed5b9c3387a507b51365cb8c4 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:17:13 +0100
Subject: moving assignment to new line to make next commit easier to read in
diffs
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 6231624..bbaac3e 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -180,7 +180,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
delegateType = Expression.GetFuncType(typeArgs.ToArray());
}
- Delegate fcall = Delegate.CreateDelegate(delegateType, target, mi);
+ Delegate fcall;
+ fcall = Delegate.CreateDelegate(delegateType, target, mi);
lock (m_scriptInvocation)
{
--
cgit v1.1
From 794c5f5a6d464357101d3da649815251abdc9e10 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:50:46 +0100
Subject: adding support for static method script invocations
---
OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs | 11 +++++++++--
.../ScriptModuleComms/ScriptModuleCommsModule.cs | 15 +++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
index ff8213c..dae7c00 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
@@ -54,9 +54,9 @@ namespace OpenSim.Region.Framework.Interfaces
void RegisterScriptInvocation(object target, string method);
///
- /// Register an instance method as a script call by method info
+ /// Register a static or instance method as a script call by method info
///
- ///
+ /// If target is a Type object, will assume method is static.
///
void RegisterScriptInvocation(object target, MethodInfo method);
@@ -68,6 +68,13 @@ namespace OpenSim.Region.Framework.Interfaces
void RegisterScriptInvocation(object target, string[] methods);
///
+ /// Register one or more static methods as script calls by method name
+ ///
+ ///
+ ///
+ void RegisterScriptInvocation(Type target, string[] methods);
+
+ ///
/// Returns an array of all registered script calls
///
///
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index bbaac3e..d6d96c9 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -181,7 +181,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
}
Delegate fcall;
+ if (!(target is Type))
fcall = Delegate.CreateDelegate(delegateType, target, mi);
+ else
+ fcall = Delegate.CreateDelegate(delegateType, (Type)target, mi.Name);
lock (m_scriptInvocation)
{
@@ -196,6 +199,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType);
}
}
+
+ public void RegisterScriptInvocation(Type target, string[] methods)
+ {
+ foreach (string method in methods)
+ {
+ MethodInfo mi = GetMethodInfoFromType(target, method, false);
+ if (mi == null)
+ m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}", method);
+ else
+ RegisterScriptInvocation(target, mi);
+ }
+ }
public Delegate[] GetScriptInvocationList()
{
--
cgit v1.1
From 054db94d5d14fdd50cb2ca9a95a8d5cac2ab234a Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 13:51:00 +0100
Subject: formatting
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index d6d96c9..8d100e8 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -172,12 +172,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
if (mi.ReturnType == typeof(void))
{
- delegateType = Expression.GetActionType(typeArgs.ToArray());
+ delegateType = Expression.GetActionType(typeArgs.ToArray());
}
else
{
- typeArgs.Add(mi.ReturnType);
- delegateType = Expression.GetFuncType(typeArgs.ToArray());
+ typeArgs.Add(mi.ReturnType);
+ delegateType = Expression.GetFuncType(typeArgs.ToArray());
}
Delegate fcall;
@@ -188,13 +188,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
lock (m_scriptInvocation)
{
- ParameterInfo[] parameters = fcall.Method.GetParameters ();
+ ParameterInfo[] parameters = fcall.Method.GetParameters();
if (parameters.Length < 2) // Must have two UUID params
return;
// Hide the first two parameters
Type[] parmTypes = new Type[parameters.Length - 2];
- for (int i = 2 ; i < parameters.Length ; i++)
+ for (int i = 2; i < parameters.Length; i++)
parmTypes[i - 2] = parameters[i].ParameterType;
m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType);
}
--
cgit v1.1
From dac31303b720310598f51d5ff31355e08c7e4fac Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 31 Aug 2012 15:19:26 +0100
Subject: Type.Type is RuntimeType
---
.../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 8d100e8..23cc633 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -163,7 +163,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
public void RegisterScriptInvocation(object target, MethodInfo mi)
{
- m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, target.GetType().Name);
+ m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, (target is Type) ? ((Type)target).Name : target.GetType().Name);
Type delegateType;
List typeArgs = mi.GetParameters()
--
cgit v1.1
From a0eda6eb1642b8a5d3b6db3e89c8db87dfaefa1c Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Fri, 31 Aug 2012 13:06:28 -0400
Subject: Fix Windows build
Add reference to fix Windows build: no windows here to test, please report any issues back to IRC #opensim-dev ASAP
---
prebuild.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/prebuild.xml b/prebuild.xml
index 0f34713..f10607d 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3264,6 +3264,7 @@
../../../bin/
+
--
cgit v1.1
From 2d2495cc45abe9af8f7cef1aebbf99908955085a Mon Sep 17 00:00:00 2001
From: Mic Bowman
Date: Fri, 31 Aug 2012 11:33:53 -0700
Subject: Remove the unused Newtonsoft.Json dlls Also remove the license files
---
ThirdPartyLicenses/Newtonsoft-JsonDotNet.txt | 23 -
bin/Newtonsoft.Json.Net20.dll | Bin 356352 -> 0 bytes
bin/Newtonsoft.Json.XML | 5827 --------------------------
bin/Newtonsoft.Json.pdb | Bin 742912 -> 0 bytes
4 files changed, 5850 deletions(-)
delete mode 100644 ThirdPartyLicenses/Newtonsoft-JsonDotNet.txt
delete mode 100755 bin/Newtonsoft.Json.Net20.dll
delete mode 100644 bin/Newtonsoft.Json.XML
delete mode 100644 bin/Newtonsoft.Json.pdb
diff --git a/ThirdPartyLicenses/Newtonsoft-JsonDotNet.txt b/ThirdPartyLicenses/Newtonsoft-JsonDotNet.txt
deleted file mode 100644
index 457daca..0000000
--- a/ThirdPartyLicenses/Newtonsoft-JsonDotNet.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Json.NET
-License: The MIT License
-Copyright (c) 2007 James Newton-King
-
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/bin/Newtonsoft.Json.Net20.dll b/bin/Newtonsoft.Json.Net20.dll
deleted file mode 100755
index 177d9b5..0000000
Binary files a/bin/Newtonsoft.Json.Net20.dll and /dev/null differ
diff --git a/bin/Newtonsoft.Json.XML b/bin/Newtonsoft.Json.XML
deleted file mode 100644
index 1a1e56c..0000000
--- a/bin/Newtonsoft.Json.XML
+++ /dev/null
@@ -1,5827 +0,0 @@
-
-
-
- Newtonsoft.Json.Net20
-
-
-
-
- Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.
-
-
-
-
- Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.
-
-
-
-
- Initializes a new instance of the class with the specified .
-
-
-
-
- Reads the next JSON token from the stream.
-
- true if the next token was read successfully; false if there are no more tokens to read.
-
-
-
- Reads the next JSON token from the stream as a .
-
- A or a null reference if the next JSON token is null.
-
-
-
- Skips the children of the current token.
-
-
-
-
- Sets the current token.
-
- The new token.
-
-
-
- Sets the current token and value.
-
- The new token.
- The value.
-
-
-
- Sets the state based on current token type.
-
-
-
-
- Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
-
-
-
-
- Releases unmanaged and - optionally - managed resources
-
- true to release both managed and unmanaged resources; false to release only unmanaged resources.
-
-
-
- Changes the to Closed.
-
-
-
-
- Gets the current reader state.
-
- The current reader state.
-
-
-
- Gets the quotation mark character used to enclose the value of a string.
-
-
-
-
- Gets the type of the current Json token.
-
-
-
-
- Gets the text value of the current Json token.
-
-
-
-
- Gets The Common Language Runtime (CLR) type for the current Json token.
-
-
-
-
- Gets the depth of the current token in the JSON document.
-
- The depth of the current token in the JSON document.
-
-
-
- Specifies the state of the reader.
-
-
-
-
- The Read method has not been called.
-
-
-
-
- The end of the file has been reached successfully.
-
-
-
-
- Reader is at a property.
-
-
-
-
- Reader is at the start of an object.
-
-
-
-
- Reader is in an object.
-
-
-
-
- Reader is at the start of an array.
-
-
-
-
- Reader is in an array.
-
-
-
-
- The Close method has been called.
-
-
-
-
- Reader has just read a value.
-
-
-
-
- Reader is at the start of a constructor.
-
-
-
-
- Reader in a constructor.
-
-
-
-
- An error occurred that prevents the read operation from continuing.
-
-
-
-
- The end of the file has been reached successfully.
-
-
-
-
- Initializes a new instance of the class.
-
- The stream.
-
-
-
- Initializes a new instance of the class.
-
- The stream.
- if set to true the root object will be read as a JSON array.
- The used when reading values from BSON.
-
-
-
- Reads the next JSON token from the stream as a .
-
-
- A or a null reference if the next JSON token is null.
-
-
-
-
- Reads the next JSON token from the stream.
-
-
- true if the next token was read successfully; false if there are no more tokens to read.
-
-
-
-
- Gets or sets a value indicating whether the root object will be read as a JSON array.
-
-
- true if the root object will be read as a JSON array; otherwise, false.
-
-
-
-
- Gets or sets the used when reading values from BSON.
-
- The used when reading values from BSON.
-
-
-
- Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.
-
-
-
-
- Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.
-
-
-
-
- Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.
-
-
-
-
- Creates an instance of the JsonWriter class.
-
-
-
-
- Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
-
-
-
-
- Closes this stream and the underlying stream.
-
-
-
-
- Writes the beginning of a Json object.
-
-
-
-
- Writes the end of a Json object.
-
-
-
-
- Writes the beginning of a Json array.
-
-
-
-
- Writes the end of an array.
-
-
-
-
- Writes the start of a constructor with the given name.
-
- The name of the constructor.
-
-
-
- Writes the end constructor.
-
-
-
-
- Writes the property name of a name/value pair on a Json object.
-
- The name of the property.
-
-
-
- Writes the end of the current Json object or array.
-
-
-
-
- Writes the current token.
-
- The to read the token from.
-
-
-
- Writes the specified end token.
-
- The end token to write.
-
-
-
- Writes indent characters.
-
-
-
-
- Writes the JSON value delimiter.
-
-
-
-
- Writes an indent space.
-
-
-
-
- Writes a null value.
-
-
-
-
- Writes an undefined value.
-
-
-
-
- Writes raw JSON without changing the writer's state.
-
- The raw JSON to write.
-
-
-
- Writes raw JSON where a value is expected and updates the writer's state.
-
- The raw JSON to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
- An error will raised if the value cannot be written as a single JSON token.
-
- The value to write.
-
-
-
- Writes out a comment /*...*/ containing the specified text.
-
- Text to place inside the comment.
-
-
-
- Writes out the given white space.
-
- The string of white space characters.
-
-
-
- Gets the top.
-
- The top.
-
-
-
- Gets the state of the writer.
-
-
-
-
- Indicates how the output is formatted.
-
-
-
-
- Initializes a new instance of the class writing to the given .
-
- The container being written to.
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
-
-
-
-
- Closes this stream and the underlying stream.
-
-
-
-
- Writes the beginning of a Json object.
-
-
-
-
- Writes the beginning of a Json array.
-
-
-
-
- Writes the start of a constructor with the given name.
-
- The name of the constructor.
-
-
-
- Writes the end.
-
- The token.
-
-
-
- Writes the property name of a name/value pair on a Json object.
-
- The name of the property.
-
-
-
- Writes a null value.
-
-
-
-
- Writes an undefined value.
-
-
-
-
- Writes raw JSON.
-
- The raw JSON to write.
-
-
-
- Writes out a comment /*...*/ containing the specified text.
-
- Text to place inside the comment.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Gets the token being writen.
-
- The token being writen.
-
-
-
- Initializes a new instance of the class.
-
- The stream.
-
-
-
- Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
-
-
-
-
- Writes the end.
-
- The token.
-
-
-
- Writes out a comment /*...*/ containing the specified text.
-
- Text to place inside the comment.
-
-
-
- Writes the start of a constructor with the given name.
-
- The name of the constructor.
-
-
-
- Writes raw JSON.
-
- The raw JSON to write.
-
-
-
- Writes raw JSON where a value is expected and updates the writer's state.
-
- The raw JSON to write.
-
-
-
- Specifies how constructors are used when initializing objects during deserialization by the .
-
-
-
-
- First attempt to use the public default constructor then fall back to single paramatized constructor.
-
-
-
-
- Allow Json.NET to use a non-public default constructor.
-
-
-
-
- Converts a binary value to and from a base 64 string value.
-
-
-
-
- Converts an object to and from JSON.
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Determines whether this instance can convert the specified object type.
-
- Type of the object.
-
- true if this instance can convert the specified object type; otherwise, false.
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Determines whether this instance can convert the specified object type.
-
- Type of the object.
-
- true if this instance can convert the specified object type; otherwise, false.
-
-
-
-
- Create a custom object
-
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Creates an object which will then be populated by the serializer.
-
- Type of the object.
-
-
-
-
- Determines whether this instance can convert the specified object type.
-
- Type of the object.
-
- true if this instance can convert the specified object type; otherwise, false.
-
-
-
-
- Converts a to and from JSON.
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Determines whether this instance can convert the specified value type.
-
- Type of the value.
-
- true if this instance can convert the specified value type; otherwise, false.
-
-
-
-
- Converts a to and from JSON.
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Determines whether this instance can convert the specified value type.
-
- Type of the value.
-
- true if this instance can convert the specified value type; otherwise, false.
-
-
-
-
- Provides a base class for converting a to and from JSON.
-
-
-
-
- Determines whether this instance can convert the specified object type.
-
- Type of the object.
-
- true if this instance can convert the specified object type; otherwise, false.
-
-
-
-
- Converts an to and from its name string value.
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Determines whether this instance can convert the specified object type.
-
- Type of the object.
-
- true if this instance can convert the specified object type; otherwise, false.
-
-
-
-
- Represents a view of a .
-
-
-
-
- Initializes a new instance of the class.
-
- The name.
- Type of the property.
-
-
-
- When overridden in a derived class, returns whether resetting an object changes its value.
-
-
- true if resetting the component changes its value; otherwise, false.
-
- The component to test for reset capability.
-
-
-
-
- When overridden in a derived class, gets the current value of the property on a component.
-
-
- The value of a property for a given component.
-
- The component with the property for which to retrieve the value.
-
-
-
-
- When overridden in a derived class, resets the value for this property of the component to the default value.
-
- The component with the property value that is to be reset to the default value.
-
-
-
-
- When overridden in a derived class, sets the value of the component to a different value.
-
- The component with the property value that is to be set.
- The new value.
-
-
-
-
- When overridden in a derived class, determines a value indicating whether the value of this property needs to be persisted.
-
-
- true if the property should be persisted; otherwise, false.
-
- The component with the property to be examined for persistence.
-
-
-
-
- When overridden in a derived class, gets the type of the component this property is bound to.
-
-
- A that represents the type of component this property is bound to. When the or methods are invoked, the object specified might be an instance of this type.
-
-
-
-
- When overridden in a derived class, gets a value indicating whether this property is read-only.
-
-
- true if the property is read-only; otherwise, false.
-
-
-
-
- When overridden in a derived class, gets the type of the property.
-
-
- A that represents the type of the property.
-
-
-
-
- Gets the hash code for the name of the member.
-
-
-
- The hash code for the name of the member.
-
-
-
-
- Represents a view of a .
-
-
-
-
- Initializes a new instance of the class.
-
- The value.
-
-
-
- Returns the properties for this instance of a component.
-
-
- A that represents the properties for this component instance.
-
-
-
-
- Returns the properties for this instance of a component using the attribute array as a filter.
-
- An array of type that is used as a filter.
-
- A that represents the filtered properties for this component instance.
-
-
-
-
- Returns a collection of custom attributes for this instance of a component.
-
-
- An containing the attributes for this object.
-
-
-
-
- Returns the class name of this instance of a component.
-
-
- The class name of the object, or null if the class does not have a name.
-
-
-
-
- Returns the name of this instance of a component.
-
-
- The name of the object, or null if the object does not have a name.
-
-
-
-
- Returns a type converter for this instance of a component.
-
-
- A that is the converter for this object, or null if there is no for this object.
-
-
-
-
- Returns the default event for this instance of a component.
-
-
- An that represents the default event for this object, or null if this object does not have events.
-
-
-
-
- Returns the default property for this instance of a component.
-
-
- A that represents the default property for this object, or null if this object does not have properties.
-
-
-
-
- Returns an editor of the specified type for this instance of a component.
-
- A that represents the editor for this object.
-
- An of the specified type that is the editor for this object, or null if the editor cannot be found.
-
-
-
-
- Returns the events for this instance of a component using the specified attribute array as a filter.
-
- An array of type that is used as a filter.
-
- An that represents the filtered events for this component instance.
-
-
-
-
- Returns the events for this instance of a component.
-
-
- An that represents the events for this component instance.
-
-
-
-
- Returns an object that contains the property described by the specified property descriptor.
-
- A that represents the property whose owner is to be found.
-
- An that represents the owner of the specified property.
-
-
-
-
- Represents a raw JSON string.
-
-
-
-
- Represents a value in JSON (string, integer, date, etc).
-
-
-
-
- Represents an abstract JSON token.
-
-
-
-
- Represents a collection of objects.
-
- The type of token
-
-
-
- Gets the with the specified key.
-
-
-
-
-
- Provides an interface to enable a class to return line and position information.
-
-
-
-
- Gets a value indicating whether the class can return line information.
-
-
- true if LineNumber and LinePosition can be provided; otherwise, false.
-
-
-
-
- Gets the current line number.
-
- The current line number or 0 if no line information is available (for example, HasLineInfo returns false).
-
-
-
- Gets the current line position.
-
- The current line position or 0 if no line information is available (for example, HasLineInfo returns false).
-
-
-
- Compares the values of two tokens, including the values of all descendant tokens.
-
- The first to compare.
- The second to compare.
- true if the tokens are equal; otherwise false.
-
-
-
- Adds the specified content immediately after this token.
-
- A content object that contains simple content or a collection of content objects to be added after this token.
-
-
-
- Adds the specified content immediately before this token.
-
- A content object that contains simple content or a collection of content objects to be added before this token.
-
-
-
- Returns a collection of the ancestor tokens of this token.
-
- A collection of the ancestor tokens of this token.
-
-
-
- Returns a collection of the sibling tokens after this token, in document order.
-
- A collection of the sibling tokens after this tokens, in document order.
-
-
-
- Returns a collection of the sibling tokens before this token, in document order.
-
- A collection of the sibling tokens before this token, in document order.
-
-
-
- Gets the with the specified key converted to the specified type.
-
- The type to convert the token to.
- The token key.
- The converted token value.
-
-
-
- Returns a collection of the child tokens of this token, in document order.
-
- An of containing the child tokens of this , in document order.
-
-
-
- Returns a collection of the child tokens of this token, in document order, filtered by the specified type.
-
- The type to filter the child tokens on.
- A containing the child tokens of this , in document order.
-
-
-
- Returns a collection of the child values of this token, in document order.
-
- The type to convert the values to.
- A containing the child values of this , in document order.
-
-
-
- Removes this token from its parent.
-
-
-
-
- Replaces this token with the specified token.
-
- The value.
-
-
-
- Writes this token to a .
-
- A into which this method will write.
- A collection of which will be used when writing the token.
-
-
-
- Returns the indented JSON for this token.
-
-
- The indented JSON for this token.
-
-
-
-
- Returns the JSON for this token using the given formatting and converters.
-
- Indicates how the output is formatted.
- A collection of which will be used when writing the token.
- The JSON for this token using the given formatting and converters.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an explicit conversion from to .
-
- The value.
- The result of the conversion.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Performs an implicit conversion from to .
-
- The value to create a from.
- The initialized with the specified value.
-
-
-
- Creates an for this token.
-
- An that can be used to read this token and its descendants.
-
-
-
- Creates a from an object.
-
- The object that will be used to create .
- A with the value of the specified object
-
-
-
- Creates a from an object using the specified .
-
- The object that will be used to create .
- The that will be used when reading the object.
- A with the value of the specified object
-
-
-
- Creates a from a .
-
- An positioned at the token to read into this .
-
- An that contains the token and its descendant tokens
- that were read from the reader. The runtime type of the token is determined
- by the token type of the first token encountered in the reader.
-
-
-
-
- Selects the token that matches the object path.
-
-
- The object path from the current to the
- to be returned. This must be a string of property names or array indexes separated
- by periods, such as Tables[0].DefaultView[0].Price in C# or
- Tables(0).DefaultView(0).Price in Visual Basic.
-
- The that matches the object path or a null reference if no matching token is found.
-
-
-
- Selects the token that matches the object path.
-
-
- The object path from the current to the
- to be returned. This must be a string of property names or array indexes separated
- by periods, such as Tables[0].DefaultView[0].Price in C# or
- Tables(0).DefaultView(0).Price in Visual Basic.
-
- A flag to indicate whether an error should be thrown if no token is found.
- The that matches the object path.
-
-
-
- Gets a comparer that can compare two tokens for value equality.
-
- A that can compare two nodes for value equality.
-
-
-
- Gets or sets the parent.
-
- The parent.
-
-
-
- Gets the root of this .
-
- The root of this .
-
-
-
- Gets the node type for this .
-
- The type.
-
-
-
- Gets a value indicating whether this token has childen tokens.
-
-
- true if this token has child values; otherwise, false.
-
-
-
-
- Gets the next sibling token of this node.
-
- The that contains the next sibling token.
-
-
-
- Gets the previous sibling token of this node.
-
- The that contains the previous sibling token.
-
-
-
- Gets the with the specified key.
-
- The with the specified key.
-
-
-
- Get the first child token of this token.
-
- A containing the first child token of the .
-
-
-
- Get the last child token of this token.
-
- A containing the last child token of the .
-
-
-
- Initializes a new instance of the class from another object.
-
- A object to copy from.
-
-
-
- Initializes a new instance of the class with the given value.
-
- The value.
-
-
-
- Initializes a new instance of the class with the given value.
-
- The value.
-
-
-
- Initializes a new instance of the class with the given value.
-
- The value.
-
-
-
- Initializes a new instance of the class with the given value.
-
- The value.
-
-
-
- Initializes a new instance of the class with the given value.
-
- The value.
-
-
-
- Initializes a new instance of the class with the given value.
-
- The value.
-
-
-
- Initializes a new instance of the class with the given value.
-
- The value.
-
-
-
- Creates a comment with the given value.
-
- The value.
- A comment with the given value.
-
-
-
- Creates a string with the given value.
-
- The value.
- A string with the given value.
-
-
-
- Writes this token to a .
-
- A into which this method will write.
- A collection of which will be used when writing the token.
-
-
-
- Indicates whether the current object is equal to another object of the same type.
-
-
- true if the current object is equal to the parameter; otherwise, false.
-
- An object to compare with this object.
-
-
-
- Determines whether the specified is equal to the current .
-
- The to compare with the current .
-
- true if the specified is equal to the current ; otherwise, false.
-
-
- The parameter is null.
-
-
-
-
- Serves as a hash function for a particular type.
-
-
- A hash code for the current .
-
-
-
-
- Gets a value indicating whether this token has childen tokens.
-
-
- true if this token has child values; otherwise, false.
-
-
-
-
- Gets the node type for this .
-
- The type.
-
-
-
- Gets or sets the underlying token value.
-
- The underlying token value.
-
-
-
- Initializes a new instance of the class from another object.
-
- A object to copy from.
-
-
-
- Initializes a new instance of the class.
-
- The raw json.
-
-
-
- Creates an instance of with the content of the reader's current token.
-
- The reader.
- An instance of with the content of the reader's current token.
-
-
-
- Indicating whether a property is required.
-
-
-
-
- The property is not required. The default state.
-
-
-
-
- The property must be defined in JSON but can be a null value.
-
-
-
-
- The property must be defined in JSON and cannot be a null value.
-
-
-
-
- Used to resolve references when serializing and deserializing JSON by the .
-
-
-
-
- Resolves a reference to its object.
-
- The reference to resolve.
- The object that
-
-
-
- Gets the reference for the sepecified object.
-
- The object to get a reference for.
- The reference to the object.
-
-
-
- Determines whether the specified object is referenced.
-
- The object to test for a reference.
-
- true if the specified object is referenced; otherwise, false.
-
-
-
-
- Adds a reference to the specified object.
-
- The reference.
- The object to reference.
-
-
-
- Specifies reference handling options for the .
-
-
-
-
- Do not preserve references when serializing types.
-
-
-
-
- Preserve references when serializing into a JSON object structure.
-
-
-
-
- Preserve references when serializing into a JSON array structure.
-
-
-
-
- Preserve references when serializing.
-
-
-
-
- Instructs the how to serialize the collection.
-
-
-
-
- Instructs the how to serialize the object.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class with the specified container Id.
-
- The container Id.
-
-
-
- Gets or sets the id.
-
- The id.
-
-
-
- Gets or sets the title.
-
- The title.
-
-
-
- Gets or sets the description.
-
- The description.
-
-
-
- Gets or sets a value that indicates whether to preserve object reference data.
-
-
- true to keep object reference; otherwise, false. The default is false.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class with a flag indicating whether the array can contain null items
-
- A flag indicating whether the array can contain null items.
-
-
-
- Initializes a new instance of the class with the specified container Id.
-
- The container Id.
-
-
-
- Gets or sets a value indicating whether null items are allowed in the collection.
-
- true if null items are allowed in the collection; otherwise, false.
-
-
-
- Specifies default value handling options for the .
-
-
-
-
- Include null values when serializing and deserializing objects.
-
-
-
-
- Ignore null values when serializing and deserializing objects.
-
-
-
-
- Instructs the to use the specified when serializing the member or class.
-
-
-
-
- Initializes a new instance of the class.
-
- Type of the converter.
-
-
-
- Gets the type of the converter.
-
- The type of the converter.
-
-
-
- Instructs the how to serialize the object.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class with the specified member serialization.
-
- The member serialization.
-
-
-
- Initializes a new instance of the class with the specified container Id.
-
- The container Id.
-
-
-
- Gets or sets the member serialization.
-
- The member serialization.
-
-
-
- Specifies the settings on a object.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Gets or sets how reference loops (e.g. a class referencing itself) is handled.
-
- Reference loop handling.
-
-
-
- Gets or sets how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization.
-
- Missing member handling.
-
-
-
- Gets or sets how objects are created during deserialization.
-
- The object creation handling.
-
-
-
- Gets or sets how null values are handled during serialization and deserialization.
-
- Null value handling.
-
-
-
- Gets or sets how null default are handled during serialization and deserialization.
-
- The default value handling.
-
-
-
- Gets or sets a collection that will be used during serialization.
-
- The converters.
-
-
-
- Gets or sets how object references are preserved by the serializer.
-
- The preserve references handling.
-
-
-
- Gets or sets how type name writing and reading is handled by the serializer.
-
- The type name handling.
-
-
-
- Gets or sets how constructors are used during deserialization.
-
- The constructor handling.
-
-
-
- Gets or sets the contract resolver used by the serializer when
- serializing .NET objects to JSON and vice versa.
-
- The contract resolver.
-
-
-
- Gets or sets the used by the serializer when resolving references.
-
- The reference resolver.
-
-
-
- Gets or sets the used by the serializer when resolving type names.
-
- The binder.
-
-
-
- Gets or sets the error handler called during serialization and deserialization.
-
- The error handler called during serialization and deserialization.
-
-
-
- Gets or sets the used by the serializer when invoking serialization callback methods.
-
- The context.
-
-
-
- Represents a reader that provides validation.
-
-
-
-
- Initializes a new instance of the class that
- validates the content returned from the given .
-
- The to read from while validating.
-
-
-
- Reads the next JSON token from the stream as a .
-
-
- A or a null reference if the next JSON token is null.
-
-
-
-
- Reads the next JSON token from the stream.
-
-
- true if the next token was read successfully; false if there are no more tokens to read.
-
-
-
-
- Sets an event handler for receiving schema validation errors.
-
-
-
-
- Gets the text value of the current Json token.
-
-
-
-
-
- Gets the depth of the current token in the JSON document.
-
- The depth of the current token in the JSON document.
-
-
-
- Gets the quotation mark character used to enclose the value of a string.
-
-
-
-
-
- Gets the type of the current Json token.
-
-
-
-
-
- Gets The Common Language Runtime (CLR) type for the current Json token.
-
-
-
-
-
- Gets or sets the schema.
-
- The schema.
-
-
-
- Gets the used to construct this .
-
- The specified in the constructor.
-
-
-
- Compares tokens to determine whether they are equal.
-
-
-
-
- Determines whether the specified objects are equal.
-
- The first object of type to compare.
- The second object of type to compare.
-
- true if the specified objects are equal; otherwise, false.
-
-
-
-
- Returns a hash code for the specified object.
-
- The for which a hash code is to be returned.
- A hash code for the specified object.
- The type of is a reference type and is null.
-
-
-
- Specifies the member serialization options for the .
-
-
-
-
- All members are serialized by default. Members can be excluded using the .
-
-
-
-
- Only members must be marked with the are serialized.
-
-
-
-
- Specifies how object creation is handled by the .
-
-
-
-
- Reuse existing objects, create new objects when needed.
-
-
-
-
- Only reuse existing objects.
-
-
-
-
- Always create new objects.
-
-
-
-
- Converts a to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z).
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Gets or sets the date time styles used when converting a date to and from JSON.
-
- The date time styles used when converting a date to and from JSON.
-
-
-
- Gets or sets the date time format used when converting a date to and from JSON.
-
- The date time format used when converting a date to and from JSON.
-
-
-
- Gets or sets the culture used when converting a date to and from JSON.
-
- The culture used when converting a date to and from JSON.
-
-
-
- Converts a to and from a JavaScript date constructor (e.g. new Date(52231943)).
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The value.
- The calling serializer.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Specifies whether a DateTime object represents a local time, a Coordinated Universal Time (UTC), or is not specified as either local time or UTC.
-
-
-
-
- The time represented is local time.
-
-
-
-
- The time represented is UTC.
-
-
-
-
- The time represented is not specified as either local time or Coordinated Universal Time (UTC).
-
-
-
-
- Preserves the DateTimeKind field of a date when a DateTime object is converted to a string and the string is then converted back to a DateTime object.
-
-
-
-
- Converts an to and from JSON.
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The calling serializer.
- The value.
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Checks if the attributeName is a namespace attribute.
-
- Attribute name to test.
- The attribute name prefix if it has one, otherwise an empty string.
- True if attribute name is for a namespace attribute, otherwise false.
-
-
-
- Determines whether this instance can convert the specified value type.
-
- Type of the value.
-
- true if this instance can convert the specified value type; otherwise, false.
-
-
-
-
- Gets or sets the name of the root element to insert when deserializing to XML if the JSON structure has produces multiple root elements.
-
- The name of the deserialize root element.
-
-
-
- Converts a object to and from JSON.
-
-
-
-
- Writes the JSON representation of the object.
-
- The to write to.
- The calling serializer.
- The value.
-
-
-
- Determines whether this instance can convert the specified value type.
-
- Type of the value.
-
- true if this instance can convert the specified value type; otherwise, false.
-
-
-
-
- Reads the JSON representation of the object.
-
- The to read from.
- Type of the object.
- The calling serializer.
- The object value.
-
-
-
- Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.
-
-
-
-
- Initializes a new instance of the class with the specified .
-
- The TextReader containing the XML data to read.
-
-
-
- Reads the next JSON token from the stream.
-
-
- true if the next token was read successfully; false if there are no more tokens to read.
-
-
-
-
- Reads the next JSON token from the stream as a .
-
-
- A or a null reference if the next JSON token is null.
-
-
-
-
- Changes the state to closed.
-
-
-
-
- Gets a value indicating whether the class can return line information.
-
-
- true if LineNumber and LinePosition can be provided; otherwise, false.
-
-
-
-
- Gets the current line number.
-
-
- The current line number or 0 if no line information is available (for example, HasLineInfo returns false).
-
-
-
-
- Gets the current line position.
-
-
- The current line position or 0 if no line information is available (for example, HasLineInfo returns false).
-
-
-
-
- Instructs the to always serialize the member with the specified name.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class with the specified name.
-
- Name of the property.
-
-
-
- Gets or sets the null value handling used when serializing this property.
-
- The null value handling.
-
-
-
- Gets or sets the default value handling used when serializing this property.
-
- The default value handling.
-
-
-
- Gets or sets the reference loop handling used when serializing this property.
-
- The reference loop handling.
-
-
-
- Gets or sets the object creation handling used when deserializing this property.
-
- The object creation handling.
-
-
-
- Gets or sets whether this property's value is serialized as a reference.
-
- Whether this property's value is serialized as a reference.
-
-
-
- Gets or sets the name of the property.
-
- The name of the property.
-
-
-
- Gets or sets a value indicating whether this property is required.
-
-
- A value indicating whether this property is required.
-
-
-
-
- Instructs the not to serialize the public field or public read/write property value.
-
-
-
-
- Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.
-
-
-
-
- Creates an instance of the JsonWriter class using the specified .
-
- The TextWriter to write to.
-
-
-
- Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
-
-
-
-
- Closes this stream and the underlying stream.
-
-
-
-
- Writes the beginning of a Json object.
-
-
-
-
- Writes the beginning of a Json array.
-
-
-
-
- Writes the start of a constructor with the given name.
-
- The name of the constructor.
-
-
-
- Writes the specified end token.
-
- The end token to write.
-
-
-
- Writes the property name of a name/value pair on a Json object.
-
- The name of the property.
-
-
-
- Writes indent characters.
-
-
-
-
- Writes the JSON value delimiter.
-
-
-
-
- Writes an indent space.
-
-
-
-
- Writes a null value.
-
-
-
-
- Writes an undefined value.
-
-
-
-
- Writes raw JSON.
-
- The raw JSON to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes a value.
-
- The value to write.
-
-
-
- Writes out a comment /*...*/ containing the specified text.
-
- Text to place inside the comment.
-
-
-
- Writes out the given white space.
-
- The string of white space characters.
-
-
-
- Gets or sets how many IndentChars to write for each level in the hierarchy when is set to Formatting.Indented.
-
-
-
-
- Gets or sets which character to use to quote attribute values.
-
-
-
-
- Gets or sets which character to use for indenting when is set to Formatting.Indented.
-
-
-
-
- Gets or sets a value indicating whether object names will be surrounded with quotes.
-
-
-
-
- The exception thrown when an error occurs while reading Json text.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class
- with a specified error message.
-
- The error message that explains the reason for the exception.
-
-
-
- Initializes a new instance of the class
- with a specified error message and a reference to the inner exception that is the cause of this exception.
-
- The error message that explains the reason for the exception.
- The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
-
-
-
- The exception thrown when an error occurs while reading Json text.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class
- with a specified error message.
-
- The error message that explains the reason for the exception.
-
-
-
- Initializes a new instance of the class
- with a specified error message and a reference to the inner exception that is the cause of this exception.
-
- The error message that explains the reason for the exception.
- The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
-
-
-
- Gets the line number indicating where the error occurred.
-
- The line number indicating where the error occurred.
-
-
-
- Gets the line position indicating where the error occurred.
-
- The line position indicating where the error occurred.
-
-
-
- Represents a collection of .
-
-
-
-
- Provides methods for converting between common language runtime types and JSON types.
-
-
-
-
- Represents JavaScript's boolean value true as a string. This field is read-only.
-
-
-
-
- Represents JavaScript's boolean value false as a string. This field is read-only.
-
-
-
-
- Represents JavaScript's null as a string. This field is read-only.
-
-
-
-
- Represents JavaScript's undefined as a string. This field is read-only.
-
-
-
-
- Represents JavaScript's positive infinity as a string. This field is read-only.
-
-
-
-
- Represents JavaScript's negative infinity as a string. This field is read-only.
-
-
-
-
- Represents JavaScript's NaN as a string. This field is read-only.
-
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- The string delimiter character.
- A JSON string representation of the .
-
-
-
- Converts the to its JSON string representation.
-
- The value to convert.
- A JSON string representation of the .
-
-
-
- Serializes the specified object to a JSON string.
-
- The object to serialize.
- A JSON string representation of the object.
-
-
-
- Serializes the specified object to a JSON string.
-
- The object to serialize.
- Indicates how the output is formatted.
-
- A JSON string representation of the object.
-
-
-
-
- Serializes the specified object to a JSON string using a collection of .
-
- The object to serialize.
- A collection converters used while serializing.
- A JSON string representation of the object.
-
-
-
- Serializes the specified object to a JSON string using a collection of .
-
- The object to serialize.
- Indicates how the output is formatted.
- A collection converters used while serializing.
- A JSON string representation of the object.
-
-
-
- Serializes the specified object to a JSON string using a collection of .
-
- The object to serialize.
- Indicates how the output is formatted.
- The used to serialize the object.
- If this is null, default serialization settings will be is used.
-
- A JSON string representation of the object.
-
-
-
-
- Deserializes the specified object to a Json object.
-
- The object to deserialize.
- The deserialized object from the Json string.
-
-
-
- Deserializes the specified object to a Json object.
-
- The object to deserialize.
- The of object being deserialized.
- The deserialized object from the Json string.
-
-
-
- Deserializes the specified object to a Json object.
-
- The type of the object to deserialize.
- The object to deserialize.
- The deserialized object from the Json string.
-
-
-
- Deserializes the specified JSON to the given anonymous type.
-
-
- The anonymous type to deserialize to. This can't be specified
- traditionally and must be infered from the anonymous type passed
- as a parameter.
-
- The object to deserialize.
- The anonymous type object.
- The deserialized anonymous type from the JSON string.
-
-
-
- Deserializes the JSON string to the specified type.
-
- The type of the object to deserialize.
- The object to deserialize.
- Converters to use while deserializing.
- The deserialized object from the JSON string.
-
-
-
- Deserializes the JSON string to the specified type.
-
- The type of the object to deserialize.
- The object to deserialize.
-
- The used to deserialize the object.
- If this is null, default serialization settings will be is used.
-
- The deserialized object from the JSON string.
-
-
-
- Deserializes the JSON string to the specified type.
-
- The object to deserialize.
- The type of the object to deserialize.
- Converters to use while deserializing.
- The deserialized object from the JSON string.
-
-
-
- Deserializes the JSON string to the specified type.
-
- The JSON to deserialize.
- The type of the object to deserialize.
-
- The used to deserialize the object.
- If this is null, default serialization settings will be is used.
-
- The deserialized object from the JSON string.
-
-
-
- Populates the object with values from the JSON string.
-
- The JSON to populate values from.
- The target object to populate values onto.
-
-
-
- Populates the object with values from the JSON string.
-
- The JSON to populate values from.
- The target object to populate values onto.
-
- The used to deserialize the object.
- If this is null, default serialization settings will be is used.
-
-
-
-
- Serializes the XML node to a JSON string.
-
- The node to serialize.
- A JSON string of the XmlNode.
-
-
-
- Deserializes the XmlNode from a JSON string.
-
- The JSON string.
- The deserialized XmlNode
-
-
-
- Deserializes the XmlNode from a JSON string nested in a root elment.
-
- The JSON string.
- The name of the root element to append when deserializing.
- The deserialized XmlNode
-
-
-
- The exception thrown when an error occurs during Json serialization or deserialization.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class
- with a specified error message.
-
- The error message that explains the reason for the exception.
-
-
-
- Initializes a new instance of the class
- with a specified error message and a reference to the inner exception that is the cause of this exception.
-
- The error message that explains the reason for the exception.
- The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
-
-
-
- Serializes and deserializes objects into and from the JSON format.
- The enables you to control how objects are encoded into JSON.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Creates a new instance using the specified .
-
- The settings to be applied to the .
- A new instance using the specified .
-
-
-
- Populates the JSON values onto the target object.
-
- The that contains the JSON structure to reader values from.
- The target object to populate values onto.
-
-
-
- Populates the JSON values onto the target object.
-
- The that contains the JSON structure to reader values from.
- The target object to populate values onto.
-
-
-
- Deserializes the Json structure contained by the specified .
-
- The that contains the JSON structure to deserialize.
- The being deserialized.
-
-
-
- Deserializes the Json structure contained by the specified
- into an instance of the specified type.
-
- The containing the object.
- The of object being deserialized.
- The instance of being deserialized.
-
-
-
- Deserializes the Json structure contained by the specified
- into an instance of the specified type.
-
- The containing the object.
- The type of the object to deserialize.
- The instance of being deserialized.
-
-
-
- Deserializes the Json structure contained by the specified
- into an instance of the specified type.
-
- The containing the object.
- The of object being deserialized.
- The instance of being deserialized.
-
-
-
- Serializes the specified and writes the Json structure
- to a Stream using the specified .
-
- The used to write the Json structure.
- The to serialize.
-
-
-
- Serializes the specified and writes the Json structure
- to a Stream using the specified .
-
- The used to write the Json structure.
- The to serialize.
-
-
-
- Occurs when the errors during serialization and deserialization.
-
-
-
-
- Gets or sets the used by the serializer when resolving references.
-
-
-
-
- Gets or sets the used by the serializer when resolving type names.
-
-
-
-
- Gets or sets how type name writing and reading is handled by the serializer.
-
-
-
-
- Gets or sets how object references are preserved by the serializer.
-
-
-
-
- Get or set how reference loops (e.g. a class referencing itself) is handled.
-
-
-
-
- Get or set how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization.
-
-
-
-
- Get or set how null values are handled during serialization and deserialization.
-
-
-
-
- Get or set how null default are handled during serialization and deserialization.
-
-
-
-
- Gets or sets how objects are created during deserialization.
-
- The object creation handling.
-
-
-
- Gets or sets how constructors are used during deserialization.
-
- The constructor handling.
-
-
-
- Gets a collection that will be used during serialization.
-
- Collection that will be used during serialization.
-
-
-
- Gets or sets the contract resolver used by the serializer when
- serializing .NET objects to JSON and vice versa.
-
-
-
-
- Gets or sets the used by the serializer when invoking serialization callback methods.
-
- The context.
-
-
-
- Contains the LINQ to JSON extension methods.
-
-
-
-
- Returns a collection of tokens that contains the ancestors of every token in the source collection.
-
- The type of the objects in source, constrained to .
- An of that contains the source collection.
- An of that contains the ancestors of every node in the source collection.
-
-
-
- Returns a collection of tokens that contains the descendants of every token in the source collection.
-
- The type of the objects in source, constrained to .
- An of that contains the source collection.
- An of that contains the descendants of every node in the source collection.
-
-
-
- Returns a collection of child properties of every object in the source collection.
-
- An of that contains the source collection.
- An of that contains the properties of every object in the source collection.
-
-
-
- Returns a collection of child values of every object in the source collection with the given key.
-
- An of that contains the source collection.
- The token key.
- An of that contains the values of every node in the source collection with the given key.
-
-
-
- Returns a collection of child values of every object in the source collection.
-
- An of that contains the source collection.
- An of that contains the values of every node in the source collection.
-
-
-
- Returns a collection of converted child values of every object in the source collection with the given key.
-
- The type to convert the values to.
- An of that contains the source collection.
- The token key.
- An that contains the converted values of every node in the source collection with the given key.
-
-
-
- Returns a collection of converted child values of every object in the source collection.
-
- The type to convert the values to.
- An of that contains the source collection.
- An that contains the converted values of every node in the source collection.
-
-
-
- Converts the value.
-
- The type to convert the value to.
- A cast as a of .
- A converted value.
-
-
-
- Converts the value.
-
- The source collection type.
- The type to convert the value to.
- A cast as a of .
- A converted value.
-
-
-
- Returns a collection of child tokens of every array in the source collection.
-
- The source collection type.
- An of that contains the source collection.
- An of that contains the values of every node in the source collection.
-
-
-
- Returns a collection of converted child tokens of every array in the source collection.
-
- An of that contains the source collection.
- The type to convert the values to.
- The source collection type.
- An that contains the converted values of every node in the source collection.
-
-
-
- Returns the input typed as .
-
- An of that contains the source collection.
- The input typed as .
-
-
-
- Returns the input typed as .
-
- The source collection type.
- An of that contains the source collection.
- The input typed as .
-
-
-
- Represents a JSON constructor.
-
-
-
-
- Represents a token that can contain other tokens.
-
-
-
-
- Raises the event.
-
- The instance containing the event data.
-
-
-
- Raises the event.
-
- The instance containing the event data.
-
-
-
- Returns a collection of the child tokens of this token, in document order.
-
-
- An of containing the child tokens of this , in document order.
-
-
-
-
- Returns a collection of the child values of this token, in document order.
-
- The type to convert the values to.
-
- A containing the child values of this , in document order.
-
-
-
-
- Returns a collection of the descendant tokens for this token in document order.
-
- An containing the descendant tokens of the .
-
-
-
- Adds the specified content as children of this .
-
- The content to be added.
-
-
-
- Adds the specified content as the first children of this .
-
- The content to be added.
-
-
-
- Creates an that can be used to add tokens to the .
-
- An that is ready to have content written to it.
-
-
-
- Replaces the children nodes of this token with the specified content.
-
- The content.
-
-
-
- Removes the child nodes from this token.
-
-
-
-
- Occurs when the list changes or an item in the list changes.
-
-
-
-
- Occurs before an item is added to the collection.
-
-
-
-
- Gets a value indicating whether this token has childen tokens.
-
-
- true if this token has child values; otherwise, false.
-
-
-
-
- Get the first child token of this token.
-
-
- A containing the first child token of the .
-
-
-
-
- Get the last child token of this token.
-
-
- A containing the last child token of the .
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class from another object.
-
- A object to copy from.
-
-
-
- Initializes a new instance of the class with the specified name and content.
-
- The constructor name.
- The contents of the constructor.
-
-
-
- Initializes a new instance of the class with the specified name and content.
-
- The constructor name.
- The contents of the constructor.
-
-
-
- Initializes a new instance of the class with the specified name.
-
- The constructor name.
-
-
-
- Writes this token to a .
-
- A into which this method will write.
- A collection of which will be used when writing the token.
-
-
-
- Loads an from a .
-
- A that will be read for the content of the .
- A that contains the JSON that was read from the specified .
-
-
-
- Gets or sets the name of this constructor.
-
- The constructor name.
-
-
-
- Gets the node type for this .
-
- The type.
-
-
-
- Gets the with the specified key.
-
- The with the specified key.
-
-
-
- Represents a collection of objects.
-
- The type of token
-
-
-
- An empty collection of objects.
-
-
-
-
- Initializes a new instance of the struct.
-
- The enumerable.
-
-
-
- Returns an enumerator that iterates through the collection.
-
-
- A that can be used to iterate through the collection.
-
-
-
-
- Returns an enumerator that iterates through a collection.
-
-
- An object that can be used to iterate through the collection.
-
-
-
-
- Determines whether the specified is equal to this instance.
-
- The to compare with this instance.
-
- true if the specified is equal to this instance; otherwise, false.
-
-
-
-
- Returns a hash code for this instance.
-
-
- A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
-
-
-
-
- Gets the with the specified key.
-
-
-
-
-
- Represents a JSON object.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class from another object.
-
- A object to copy from.
-
-
-
- Initializes a new instance of the class with the specified content.
-
- The contents of the object.
-
-
-
- Initializes a new instance of the class with the specified content.
-
- The contents of the object.
-
-
-
- Gets an of this object's properties.
-
- An of this object's properties.
-
-
-
- Gets a the specified name.
-
- The property name.
- A with the specified name or null.
-
-
-
- Gets an of this object's property values.
-
- An of this object's property values.
-
-
-
- Loads an from a .
-
- A that will be read for the content of the .
- A that contains the JSON that was read from the specified .
-
-
-
- Load a from a string that contains JSON.
-
- A that contains JSON.
- A populated from the string that contains JSON.
-
-
-
- Creates a from an object.
-
- The object that will be used to create .
- A with the values of the specified object
-
-
-
- Creates a from an object.
-
- The object that will be used to create .
- The that will be used to read the object.
- A with the values of the specified object
-
-
-
- Writes this token to a .
-
- A into which this method will write.
- A collection of which will be used when writing the token.
-
-
-
- Adds the specified property name.
-
- Name of the property.
- The value.
-
-
-
- Removes the property with the specified name.
-
- Name of the property.
- true if item was successfully removed; otherwise, false.
-
-
-
- Tries the get value.
-
- Name of the property.
- The value.
- true if a value was successfully retrieved; otherwise, false.
-
-
-
- Returns an enumerator that iterates through the collection.
-
-
- A that can be used to iterate through the collection.
-
-
-
-
- Raises the event with the provided arguments.
-
- Name of the property.
-
-
-
- Occurs when a property value changes.
-
-
-
-
- Gets the node type for this .
-
- The type.
-
-
-
- Gets the with the specified key.
-
- The with the specified key.
-
-
-
- Gets or sets the with the specified property name.
-
-
-
-
-
- Gets the number of elements contained in the .
-
-
- The number of elements contained in the .
-
-
-
- Represents a JSON array.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class from another object.
-
- A object to copy from.
-
-
-
- Initializes a new instance of the class with the specified content.
-
- The contents of the array.
-
-
-
- Initializes a new instance of the class with the specified content.
-
- The contents of the array.
-
-
-
- Loads an from a .
-
- A that will be read for the content of the .
- A that contains the JSON that was read from the specified .
-
-
-
- Load a from a string that contains JSON.
-
- A that contains JSON.
- A populated from the string that contains JSON.
-
-
-
- Creates a from an object.
-
- The object that will be used to create .
- A with the values of the specified object
-
-
-
- Creates a from an object.
-
- The object that will be used to create .
- The that will be used to read the object.
- A with the values of the specified object
-
-
-
- Writes this token to a .
-
- A into which this method will write.
- A collection of which will be used when writing the token.
-
-
-
- Determines the index of a specific item in the .
-
- The object to locate in the .
-
- The index of if found in the list; otherwise, -1.
-
-
-
-
- Inserts an item to the at the specified index.
-
- The zero-based index at which should be inserted.
- The object to insert into the .
-
- is not a valid index in the .
- The is read-only.
-
-
-
- Removes the item at the specified index.
-
- The zero-based index of the item to remove.
-
- is not a valid index in the .
- The is read-only.
-
-
-
- Adds an item to the .
-
- The object to add to the .
- The is read-only.
-
-
-
- Removes all items from the .
-
- The is read-only.
-
-
-
- Determines whether the contains a specific value.
-
- The object to locate in the .
-
- true if is found in the ; otherwise, false.
-
-
-
-
- Removes the first occurrence of a specific object from the .
-
- The object to remove from the .
-
- true if was successfully removed from the ; otherwise, false. This method also returns false if is not found in the original .
-
- The is read-only.
-
-
-
- Gets the node type for this .
-
- The type.
-
-
-
- Gets the with the specified key.
-
- The with the specified key.
-
-
-
- Gets or sets the at the specified index.
-
-
-
-
-
- Gets the number of elements contained in the .
-
-
- The number of elements contained in the .
-
-
-
- Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.
-
-
-
-
- Initializes a new instance of the class.
-
- The token to read from.
-
-
-
- Reads the next JSON token from the stream as a .
-
-
- A or a null reference if the next JSON token is null.
-
-
-
-
- Reads the next JSON token from the stream.
-
-
- true if the next token was read successfully; false if there are no more tokens to read.
-
-
-
-
- Represents a JSON property.
-
-
-
-
- Initializes a new instance of the class from another object.
-
- A object to copy from.
-
-
-
- Returns a collection of the child tokens of this token, in document order.
-
-
- An of containing the child tokens of this , in document order.
-
-
-
-
- Initializes a new instance of the class.
-
- The property name.
- The property content.
-
-
-
- Initializes a new instance of the class.
-
- The property name.
- The property content.
-
-
-
- Writes this token to a .
-
- A into which this method will write.
- A collection of which will be used when writing the token.
-
-
-
- Loads an from a .
-
- A that will be read for the content of the .
- A that contains the JSON that was read from the specified .
-
-
-
- Gets the property name.
-
- The property name.
-
-
-
- Gets or sets the property value.
-
- The property value.
-
-
-
- Gets the node type for this .
-
- The type.
-
-
-
- Specifies the type of token.
-
-
-
-
- No token type has been set.
-
-
-
-
- A JSON object.
-
-
-
-
- A JSON array.
-
-
-
-
- A JSON constructor.
-
-
-
-
- A JSON object property.
-
-
-
-
- A comment.
-
-
-
-
- An integer value.
-
-
-
-
- A float value.
-
-
-
-
- A string value.
-
-
-
-
- A boolean value.
-
-
-
-
- A null value.
-
-
-
-
- An undefined value.
-
-
-
-
- A date value.
-
-
-
-
- A raw JSON value.
-
-
-
-
- A collection of bytes value.
-
-
-
-
- Contains the JSON schema extension methods.
-
-
-
-
- Determines whether the is valid.
-
- The source to test.
- The schema to test with.
-
- true if the specified is valid; otherwise, false.
-
-
-
-
- Validates the specified .
-
- The source to test.
- The schema to test with.
-
-
-
- Validates the specified .
-
- The source to test.
- The schema to test with.
- The validation event handler.
-
-
-
- Returns detailed information about the schema exception.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Initializes a new instance of the class
- with a specified error message.
-
- The error message that explains the reason for the exception.
-
-
-
- Initializes a new instance of the class
- with a specified error message and a reference to the inner exception that is the cause of this exception.
-
- The error message that explains the reason for the exception.
- The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
-
-
-
- Gets the line number indicating where the error occurred.
-
- The line number indicating where the error occurred.
-
-
-
- Gets the line position indicating where the error occurred.
-
- The line position indicating where the error occurred.
-
-
-
- Resolves from an id.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Gets a for the specified id.
-
- The id.
- A for the specified id.
-
-
-
- Gets or sets the loaded schemas.
-
- The loaded schemas.
-
-
-
- Specifies undefined schema Id handling options for the .
-
-
-
-
- Do not infer a schema Id.
-
-
-
-
- Use the .NET type name as the schema Id.
-
-
-
-
- Use the assembly qualified .NET type name as the schema Id.
-
-
-
-
- Returns detailed information related to the .
-
-
-
-
- Gets the associated with the validation event.
-
- The JsonSchemaException associated with the validation event.
-
-
-
- Gets the text description corresponding to the validation event.
-
- The text description.
-
-
-
- Represents the callback method that will handle JSON schema validation events and the .
-
-
-
-
- Resolves member mappings for a type, camel casing property names.
-
-
-
-
- Used by to resolves a for a given .
-
-
-
-
- Used by to resolves a for a given .
-
-
-
-
- Resolves the contract for a given type.
-
- The type to resolve a contract for.
- The contract for a given type.
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Resolves the contract for a given type.
-
- The type to resolve a contract for.
- The contract for a given type.
-
-
-
- Gets the serializable members for the type.
-
- The type to get serializable members for.
- The serializable members for the type.
-
-
-
- Creates a for the given type.
-
- Type of the object.
- A for the given type.
-
-
-
- Resolves the default for the contract.
-
- Type of the object.
-
-
-
-
- Creates a for the given type.
-
- Type of the object.
- A for the given type.
-
-
-
- Creates a for the given type.
-
- Type of the object.
- A for the given type.
-
-
-
- Creates a for the given type.
-
- Type of the object.
- A for the given type.
-
-
-
- Creates a for the given type.
-
- Type of the object.
- A for the given type.
-
-
-
- Creates properties for the given .
-
- The contract to create properties for.
- Properties for the given .
-
-
-
- Creates the used by the serializer to get and set values from a member.
-
- The member.
- The used by the serializer to get and set values from a member.
-
-
-
- Creates a for the given .
-
- The member's declaring types .
- The member to create a for.
- A created for the given .
-
-
-
- Resolves the name of the property.
-
- Name of the property.
- Name of the property.
-
-
-
- Gets or sets the default members search flags.
-
- The default members search flags.
-
-
-
- Resolves the name of the property.
-
- Name of the property.
- The property name camel cased.
-
-
-
- The default serialization binder used when resolving and loading classes from type names.
-
-
-
-
- When overridden in a derived class, controls the binding of a serialized object to a type.
-
- Specifies the name of the serialized object.
- Specifies the name of the serialized object.
-
- The type of the object the formatter creates a new instance of.
-
-
-
-
- Get and set values for a using dynamic methods.
-
-
-
-
- Provides methods to get and set values.
-
-
-
-
- Sets the value.
-
- The target to set the value on.
- The value to set on the target.
-
-
-
- Gets the value.
-
- The target to get the value from.
- The value.
-
-
-
- Initializes a new instance of the class.
-
- The member info.
-
-
-
- Sets the value.
-
- The target to set the value on.
- The value to set on the target.
-
-
-
- Gets the value.
-
- The target to get the value from.
- The value.
-
-
-
- Provides information surrounding an error.
-
-
-
-
- Gets or sets the error.
-
- The error.
-
-
-
- Gets the original object that caused the error.
-
- The original object that caused the error.
-
-
-
- Gets the member that caused the error.
-
- The member that caused the error.
-
-
-
- Gets or sets a value indicating whether this is handled.
-
- true if handled; otherwise, false.
-
-
-
- Provides data for the Error event.
-
-
-
-
- Initializes a new instance of the class.
-
- The current object.
- The error context.
-
-
-
- Gets the current object the error event is being raised against.
-
- The current object the error event is being raised against.
-
-
-
- Gets the error context.
-
- The error context.
-
-
-
- Contract details for a used by the .
-
-
-
-
- Contract details for a used by the .
-
-
-
-
- Gets the underlying type for the contract.
-
- The underlying type for the contract.
-
-
-
- Gets or sets the type created during deserialization.
-
- The type created during deserialization.
-
-
-
- Gets or sets whether this type contract is serialized as a reference.
-
- Whether this type contract is serialized as a reference.
-
-
-
- Gets or sets the default for this contract.
-
- The converter.
-
-
-
- Gets or sets the method called immediately after deserialization of the object.
-
- The method called immediately after deserialization of the object.
-
-
-
- Gets or sets the method called during deserialization of the object.
-
- The method called during deserialization of the object.
-
-
-
- Gets or sets the method called after serialization of the object graph.
-
- The method called after serialization of the object graph.
-
-
-
- Gets or sets the method called before serialization of the object.
-
- The method called before serialization of the object.
-
-
-
- Gets or sets the default creator.
-
- The default creator.
-
-
-
- Gets or sets a value indicating whether [default creator non public].
-
- true if the default object creator is non-public; otherwise, false.
-
-
-
- Gets or sets the method called when an error is thrown during the serialization of the object.
-
- The method called when an error is thrown during the serialization of the object.
-
-
-
- Initializes a new instance of the class.
-
- The underlying type for the contract.
-
-
-
- Contract details for a used by the .
-
-
-
-
- Initializes a new instance of the class.
-
- The underlying type for the contract.
-
-
-
- Contract details for a used by the .
-
-
-
-
- Initializes a new instance of the class.
-
- The underlying type for the contract.
-
-
-
- Contract details for a used by the .
-
-
-
-
- Initializes a new instance of the class.
-
- The underlying type for the contract.
-
-
-
- Maps a JSON property to a .NET member.
-
-
-
-
- Gets the name of the property.
-
- The name of the property.
-
-
-
- Gets the that will get and set the during serialization.
-
- The that will get and set the during serialization.
-
-
-
- Gets or sets the type of the property.
-
- The type of the property.
-
-
-
- Gets or sets the for the property.
- If set this converter takes presidence over the contract converter for the property type.
-
- The converter.
-
-
-
- Gets a value indicating whether this is ignored.
-
- true if ignored; otherwise, false.
-
-
-
- Gets a value indicating whether this is readable.
-
- true if readable; otherwise, false.
-
-
-
- Gets a value indicating whether this is writable.
-
- true if writable; otherwise, false.
-
-
-
- Gets the member converter.
-
- The member converter.
-
-
-
- Gets the default value.
-
- The default value.
-
-
-
- Gets a value indicating whether this is required.
-
- A value indicating whether this is required.
-
-
-
- Gets a value indicating whether this property preserves object references.
-
-
- true if this instance is reference; otherwise, false.
-
-
-
-
- Gets the property null value handling.
-
- The null value handling.
-
-
-
- Gets the property default value handling.
-
- The default value handling.
-
-
-
- Gets the property reference loop handling.
-
- The reference loop handling.
-
-
-
- Gets the property object creation handling.
-
- The object creation handling.
-
-
-
- A collection of objects.
-
-
-
-
- Initializes a new instance of the class.
-
- The contract.
-
-
-
- When implemented in a derived class, extracts the key from the specified element.
-
- The element from which to extract the key.
- The key for the specified element.
-
-
-
- Adds a object.
-
- The property to add to the collection.
-
-
-
- Gets the closest matching object.
- First attempts to get an exact case match of propertyName and then
- a case insensitive match.
-
- Name of the property.
- A matching property if found.
-
-
-
- Gets a property by property name.
-
- The name of the property to get.
- Type property name string comparison.
- A matching property if found.
-
-
-
- Specifies missing member handling options for the .
-
-
-
-
- Ignore a missing member and do not attempt to deserialize it.
-
-
-
-
- Throw a when a missing member is encountered during deserialization.
-
-
-
-
- Specifies null value handling options for the .
-
-
-
-
- Include null values when serializing and deserializing objects.
-
-
-
-
- Ignore null values when serializing and deserializing objects.
-
-
-
-
- Specifies reference loop handling options for the .
-
-
-
-
- Throw a when a loop is encountered.
-
-
-
-
- Ignore loop references and do not serialize.
-
-
-
-
- Serialize loop references.
-
-
-
-
- An in-memory representation of a JSON Schema.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Reads a from the specified .
-
- The containing the JSON Schema to read.
- The object representing the JSON Schema.
-
-
-
- Reads a from the specified .
-
- The containing the JSON Schema to read.
- The to use when resolving schema references.
- The object representing the JSON Schema.
-
-
-
- Load a from a string that contains schema JSON.
-
- A that contains JSON.
- A populated from the string that contains JSON.
-
-
-
- Parses the specified json.
-
- The json.
- The resolver.
- A populated from the string that contains JSON.
-
-
-
- Writes this schema to a .
-
- A into which this method will write.
-
-
-
- Writes this schema to a using the specified .
-
- A into which this method will write.
- The resolver used.
-
-
-
- Returns a that represents the current .
-
-
- A that represents the current .
-
-
-
-
- Gets or sets the id.
-
-
-
-
- Gets or sets the title.
-
-
-
-
- Gets or sets whether the object is optional.
-
-
-
-
- Gets or sets whether the object is read only.
-
-
-
-
- Gets or sets whether the object is visible to users.
-
-
-
-
- Gets or sets whether the object is transient.
-
-
-
-
- Gets or sets the description of the object.
-
-
-
-
- Gets or sets the types of values allowed by the object.
-
- The type.
-
-
-
- Gets or sets the pattern.
-
- The pattern.
-
-
-
- Gets or sets the minimum length.
-
- The minimum length.
-
-
-
- Gets or sets the maximum length.
-
- The maximum length.
-
-
-
- Gets or sets the maximum decimals.
-
- The maximum decimals.
-
-
-
- Gets or sets the minimum.
-
- The minimum.
-
-
-
- Gets or sets the maximum.
-
- The maximum.
-
-
-
- Gets or sets the minimum number of items.
-
- The minimum number of items.
-
-
-
- Gets or sets the maximum number of items.
-
- The maximum number of items.
-
-
-
- Gets or sets the of items.
-
- The of items.
-
-
-
- Gets or sets the of properties.
-
- The of properties.
-
-
-
- Gets or sets the of additional properties.
-
- The of additional properties.
-
-
-
- Gets or sets a value indicating whether additional properties are allowed.
-
-
- true if additional properties are allowed; otherwise, false.
-
-
-
-
- Gets or sets the required property if this property is present.
-
- The required property if this property is present.
-
-
-
- Gets or sets the identity.
-
- The identity.
-
-
-
- Gets or sets the a collection of valid enum values allowed.
-
- A collection of valid enum values allowed.
-
-
-
- Gets or sets a collection of options.
-
- A collection of options.
-
-
-
- Gets or sets disallowed types.
-
- The disallow types.
-
-
-
- Gets or sets the default value.
-
- The default value.
-
-
-
- Gets or sets the extend .
-
- The extended .
-
-
-
- Gets or sets the format.
-
- The format.
-
-
-
- Generates a from a specified .
-
-
-
-
- Generate a from the specified type.
-
- The type to generate a from.
- A generated from the specified type.
-
-
-
- Generate a from the specified type.
-
- The type to generate a from.
- The used to resolve schema references.
- A generated from the specified type.
-
-
-
- Generate a from the specified type.
-
- The type to generate a from.
- Specify whether the generated root will be nullable.
- A generated from the specified type.
-
-
-
- Generate a from the specified type.
-
- The type to generate a from.
- The used to resolve schema references.
- Specify whether the generated root will be nullable.
- A generated from the specified type.
-
-
-
- Gets or sets how undefined schemas are handled by the serializer.
-
-
-
-
- Gets or sets the contract resolver.
-
- The contract resolver.
-
-
-
- The value types allowed by the .
-
-
-
-
- No type specified.
-
-
-
-
- String type.
-
-
-
-
- Float type.
-
-
-
-
- Integer type.
-
-
-
-
- Boolean type.
-
-
-
-
- Object type.
-
-
-
-
- Array type.
-
-
-
-
- Null type.
-
-
-
-
- Any type.
-
-
-
-
- Contract details for a used by the .
-
-
-
-
- Initializes a new instance of the class.
-
- The underlying type for the contract.
-
-
-
- Gets or sets the object member serialization.
-
- The member object serialization.
-
-
-
- Gets the object's properties.
-
- The object's properties.
-
-
-
- Gets or sets the parametrized constructor used to create the object.
-
- The parametrized constructor.
-
-
-
- When applied to a method, specifies that the method is called when an error occurs serializing an object.
-
-
-
-
- Get and set values for a using reflection.
-
-
-
-
- Initializes a new instance of the class.
-
- The member info.
-
-
-
- Sets the value.
-
- The target to set the value on.
- The value to set on the target.
-
-
-
- Gets the value.
-
- The target to get the value from.
- The value.
-
-
-
- Specifies type name handling options for the .
-
-
-
-
- Do not include the .NET type name when serializing types.
-
-
-
-
- Include the .NET type name when serializing into a JSON object structure.
-
-
-
-
- Include the .NET type name when serializing into a JSON array structure.
-
-
-
-
- Always include the .NET type name when serializing.
-
-
-
-
- Converts the value to the specified type.
-
- The type to convert the value to.
- The value to convert.
- The converted type.
-
-
-
- Converts the value to the specified type.
-
- The type to convert the value to.
- The value to convert.
- The culture to use when converting.
- The converted type.
-
-
-
- Converts the value to the specified type.
-
- The value to convert.
- The culture to use when converting.
- The type to convert the value to.
- The converted type.
-
-
-
- Converts the value to the specified type.
-
- The type to convert the value to.
- The value to convert.
- The converted value if the conversion was successful or the default value of T if it failed.
-
- true if initialValue was converted successfully; otherwise, false.
-
-
-
-
- Converts the value to the specified type.
-
- The type to convert the value to.
- The value to convert.
- The culture to use when converting.
- The converted value if the conversion was successful or the default value of T if it failed.
-
- true if initialValue was converted successfully; otherwise, false.
-
-
-
-
- Converts the value to the specified type.
-
- The value to convert.
- The culture to use when converting.
- The type to convert the value to.
- The converted value if the conversion was successful or the default value of T if it failed.
-
- true if initialValue was converted successfully; otherwise, false.
-
-
-
-
- Converts the value to the specified type. If the value is unable to be converted, the
- value is checked whether it assignable to the specified type.
-
- The type to convert or cast the value to.
- The value to convert.
- The converted type. If conversion was unsuccessful, the initial value is returned if assignable to the target type
-
-
-
- Converts the value to the specified type. If the value is unable to be converted, the
- value is checked whether it assignable to the specified type.
-
- The type to convert or cast the value to.
- The value to convert.
- The culture to use when converting.
- The converted type. If conversion was unsuccessful, the initial value is returned if assignable to the target type
-
-
-
- Converts the value to the specified type. If the value is unable to be converted, the
- value is checked whether it assignable to the specified type.
-
- The value to convert.
- The culture to use when converting.
- The type to convert or cast the value to.
-
- The converted type. If conversion was unsuccessful, the initial value
- is returned if assignable to the target type.
-
-
-
-
- Converts the value to the specified type. If the value is unable to be converted, the
- value is checked whether it assignable to the specified type.
-
- The type to convert the value to.
- The value to convert.
- The converted value if the conversion was successful or the default value of T if it failed.
-
- true if initialValue was converted successfully or is assignable; otherwise, false.
-
-
-
-
- Converts the value to the specified type. If the value is unable to be converted, the
- value is checked whether it assignable to the specified type.
-
- The type to convert the value to.
- The value to convert.
- The culture to use when converting.
- The converted value if the conversion was successful or the default value of T if it failed.
-
- true if initialValue was converted successfully or is assignable; otherwise, false.
-
-
-
-
- Converts the value to the specified type. If the value is unable to be converted, the
- value is checked whether it assignable to the specified type.
-
- The value to convert.
- The culture to use when converting.
- The type to convert the value to.
- The converted value if the conversion was successful or the default value of T if it failed.
-
- true if initialValue was converted successfully or is assignable; otherwise, false.
-
-
-
-
- Parses the specified enum member name, returning it's value.
-
- Name of the enum member.
-
-
-
-
- Parses the specified enum member name, returning it's value.
-
- Name of the enum member.
- If set to true ignore case.
-
-
-
-
- Gets a dictionary of the names and values of an Enum type.
-
-
-
-
-
- Gets a dictionary of the names and values of an Enum type.
-
-
-
-
-
- Gets a dictionary of the names and values of an Enum type.
-
- The enum type to get names and values for.
-
-
-
-
- Gets the maximum valid value of an Enum type. Flags enums are ORed.
-
- The type of the returned value. Must be assignable from the enum's underlying value type.
- The enum type to get the maximum value for.
-
-
-
-
- Specifies the type of Json token.
-
-
-
-
- This is returned by the if a method has not been called.
-
-
-
-
- An object start token.
-
-
-
-
- An array start token.
-
-
-
-
- A constructor start token.
-
-
-
-
- An object property name.
-
-
-
-
- A comment.
-
-
-
-
- Raw JSON.
-
-
-
-
- An interger.
-
-
-
-
- A float.
-
-
-
-
- A string.
-
-
-
-
- A boolean.
-
-
-
-
- A null token.
-
-
-
-
- An undefined token.
-
-
-
-
- An object end token.
-
-
-
-
- An array end token.
-
-
-
-
- A constructor end token.
-
-
-
-
- A Date.
-
-
-
-
- Byte data.
-
-
-
-
- Specifies the state of the .
-
-
-
-
- An exception has been thrown, which has left the in an invalid state.
- You may call the method to put the in the Closed state.
- Any other method calls results in an being thrown.
-
-
-
-
- The method has been called.
-
-
-
-
- An object is being written.
-
-
-
-
- A array is being written.
-
-
-
-
- A constructor is being written.
-
-
-
-
- A property is being written.
-
-
-
-
- A write method has not been called.
-
-
-
-
- Specifies formatting options for the .
-
-
-
-
- No special formatting is applied. This is the default.
-
-
-
-
- Causes child objects to be indented according to the and settings.
-
-
-
-
- Builds a string. Unlike StringBuilder this class lets you reuse it's internal buffer.
-
-
-
-
- Determines whether the collection is null or empty.
-
- The collection.
-
- true if the collection is null or empty; otherwise, false.
-
-
-
-
- Determines whether the collection is null or empty.
-
- The collection.
-
- true if the collection is null or empty; otherwise, false.
-
-
-
-
- Determines whether the collection is null, empty or its contents are uninitialized values.
-
- The list.
-
- true if the collection is null or empty or its contents are uninitialized values; otherwise, false.
-
-
-
-
- Makes a slice of the specified list in between the start and end indexes.
-
- The list.
- The start index.
- The end index.
- A slice of the list.
-
-
-
- Makes a slice of the specified list in between the start and end indexes,
- getting every so many items based upon the step.
-
- The list.
- The start index.
- The end index.
- The step.
- A slice of the list.
-
-
-
- Group the collection using a function which returns the key.
-
- The source collection to group.
- The key selector.
- A Dictionary with each key relating to a list of objects in a list grouped under it.
-
-
-
- Adds the elements of the specified collection to the specified generic IList.
-
- The list to add to.
- The collection of elements to add.
-
-
-
- Gets the type of the typed collection's items.
-
- The type.
- The type of the typed collection's items.
-
-
-
- Tests whether the list's items are their unitialized value.
-
- The list.
- Whether the list's items are their unitialized value
-
-
-
- Gets the member's underlying type.
-
- The member.
- The underlying type of the member.
-
-
-
- Determines whether the member is an indexed property.
-
- The member.
-
- true if the member is an indexed property; otherwise, false.
-
-
-
-
- Determines whether the property is an indexed property.
-
- The property.
-
- true if the property is an indexed property; otherwise, false.
-
-
-
-
- Gets the member's value on the object.
-
- The member.
- The target object.
- The member's value on the object.
-
-
-
- Sets the member's value on the target object.
-
- The member.
- The target.
- The value.
-
-
-
- Determines whether the specified MemberInfo can be read.
-
- The MemberInfo to determine whether can be read.
-
- true if the specified MemberInfo can be read; otherwise, false.
-
-
-
-
- Determines whether the specified MemberInfo can be set.
-
- The MemberInfo to determine whether can be set.
-
- true if the specified MemberInfo can be set; otherwise, false.
-
-
-
-
- Determines whether the string contains white space.
-
- The string to test for white space.
-
- true if the string contains white space; otherwise, false.
-
-
-
-
- Determines whether the string is all white space. Empty string will return false.
-
- The string to test whether it is all white space.
-
- true if the string is all white space; otherwise, false.
-
-
-
-
- Ensures the target string ends with the specified string.
-
- The target.
- The value.
- The target string with the value string at the end.
-
-
-
- Perform an action if the string is not null or empty.
-
- The value.
- The action to perform.
-
-
-
- Indents the specified string.
-
- The string to indent.
- The number of characters to indent by.
-
-
-
-
- Indents the specified string.
-
- The string to indent.
- The number of characters to indent by.
- The indent character.
-
-
-
-
- Numbers the lines.
-
- The string to number.
-
-
-
-
- Nulls an empty string.
-
- The string.
- Null if the string was null, otherwise the string unchanged.
-
-
-
diff --git a/bin/Newtonsoft.Json.pdb b/bin/Newtonsoft.Json.pdb
deleted file mode 100644
index 892546a..0000000
Binary files a/bin/Newtonsoft.Json.pdb and /dev/null differ
--
cgit v1.1
From 0376b8ddbc4101627aa045a1deb18202fb51fffe Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 24 Aug 2012 10:10:55 -0700
Subject: BulletSim: add new interface for mesh, hull and terrain creation that
will move nearly all of the logic into the C# code.
---
.../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 27 ++++++++++++++++------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 504bd3c..dab2420 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -392,23 +392,36 @@ public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSt
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool PushUpdate2(IntPtr obj);
-/*
+// =====================================================================================
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern IntPtr CreateMeshShape2(IntPtr world,
+ int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
+ int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices );
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern IntPtr CreateHullShape2(IntPtr world,
+ int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls);
+
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateMesh2(IntPtr world, int indicesCount, int* indices, int verticesCount, float* vertices );
+public static extern IntPtr BuildHullShape2(IntPtr world, IntPtr meshShape);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool BuildHull2(IntPtr world, IntPtr mesh);
+public static extern IntPtr BuildNativeShape2(IntPtr world,
+ float shapeType, float collisionMargin, Vector3 scale);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool ReleaseHull2(IntPtr world, IntPtr mesh);
+public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
+// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool DestroyMesh2(IntPtr world, IntPtr mesh);
+public static extern IntPtr CreateGroundPlaneBody2(uint id, Vector3 center, float collisionMargin);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateObject2(IntPtr world, ShapeData shapeData);
-*/
+public static extern IntPtr CreateTerrainBody2(uint id,
+ Vector3 minCoords, Vector3 maxCoords, float collisionMargin,
+ [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
+// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
Vector3 frame1loc, Quaternion frame1rot,
--
cgit v1.1
From 7b6987ce83d16871f6070f3cc7d56280ad3d5dbe Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 24 Aug 2012 12:58:42 -0700
Subject: BulletSim: unify physical objects under BSPhysObjects. Now BSScene
and BSLinkset only know of BSPhysObject's and there is only one list to
search in BSScene.
---
.../Region/Physics/BulletSPlugin/BSCharacter.cs | 31 +++--
OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 50 ++++----
.../Region/Physics/BulletSPlugin/BSPhysObject.cs | 58 +++++++++
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 84 ++++++-------
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 137 +++++++++------------
5 files changed, 200 insertions(+), 160 deletions(-)
create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 1b23a36..784076d 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -34,7 +34,7 @@ using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Physics.BulletSPlugin
{
-public class BSCharacter : PhysicsActor
+public class BSCharacter : BSPhysObject
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[BULLETS CHAR]";
@@ -74,11 +74,8 @@ public class BSCharacter : PhysicsActor
private bool _kinematic;
private float _buoyancy;
- private BulletBody m_body;
- public BulletBody Body {
- get { return m_body; }
- set { m_body = value; }
- }
+ public override BulletBody Body { get; set; }
+ public override BSLinkset Linkset { get; set; }
private int _subscribedEventsMs = 0;
private int _nextCollisionOkTime = 0;
@@ -108,6 +105,8 @@ public class BSCharacter : PhysicsActor
_density = _scene.Params.avatarDensity;
ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale
+ Linkset = new BSLinkset(_scene, this);
+
ShapeData shapeData = new ShapeData();
shapeData.ID = _localID;
shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR;
@@ -130,7 +129,7 @@ public class BSCharacter : PhysicsActor
// Set the buoyancy for flying. This will be refactored when all the settings happen in C#
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
- m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID));
+ Body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID));
// avatars get all collisions no matter what (makes walking on ground and such work)
BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
});
@@ -139,7 +138,7 @@ public class BSCharacter : PhysicsActor
}
// called when this character is being destroyed and the resources should be released
- public void Destroy()
+ public override void Destroy()
{
DetailLog("{0},BSCharacter.Destroy", LocalID);
_scene.TaintedObject("BSCharacter.destroy", delegate()
@@ -245,6 +244,10 @@ public class BSCharacter : PhysicsActor
return _mass;
}
}
+
+ // used when we only want this prim's mass and not the linkset thing
+ public override float MassRaw { get {return _mass; } }
+
public override Vector3 Force {
get { return _force; }
set {
@@ -448,6 +451,12 @@ public class BSCharacter : PhysicsActor
});
}
}
+
+ public override void ZeroMotion()
+ {
+ return;
+ }
+
// Stop collision events
public override void UnSubscribeEvents() {
_subscribedEventsMs = 0;
@@ -481,7 +490,7 @@ public class BSCharacter : PhysicsActor
// The physics engine says that properties have updated. Update same and inform
// the world that things have changed.
- public void UpdateProperties(EntityProperties entprop)
+ public override void UpdateProperties(EntityProperties entprop)
{
_position = entprop.Position;
_orientation = entprop.Rotation;
@@ -500,7 +509,7 @@ public class BSCharacter : PhysicsActor
// The collision, if it should be reported to the character, is placed in a collection
// that will later be sent to the simulator when SendCollisions() is called.
CollisionEventUpdate collisionCollection = null;
- public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth)
+ public override void Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth)
{
// m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
@@ -525,7 +534,7 @@ public class BSCharacter : PhysicsActor
}
}
- public void SendCollisions()
+ public override void SendCollisions()
{
/*
if (collisionCollection != null && collisionCollection.Count > 0)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 9e3f0db..b04e1b6 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -36,8 +36,8 @@ public class BSLinkset
{
private static string LogHeader = "[BULLETSIM LINKSET]";
- private BSPrim m_linksetRoot;
- public BSPrim LinksetRoot { get { return m_linksetRoot; } }
+ private BSPhysObject m_linksetRoot;
+ public BSPhysObject LinksetRoot { get { return m_linksetRoot; } }
private BSScene m_physicsScene;
public BSScene PhysicsScene { get { return m_physicsScene; } }
@@ -46,7 +46,7 @@ public class BSLinkset
public int LinksetID { get; private set; }
// The children under the root in this linkset
- private List m_children;
+ private List m_children;
// We lock the diddling of linkset classes to prevent any badness.
// This locks the modification of the instances of this class. Changes
@@ -74,7 +74,7 @@ public class BSLinkset
get { return ComputeLinksetGeometricCenter(); }
}
- public BSLinkset(BSScene scene, BSPrim parent)
+ public BSLinkset(BSScene scene, BSPhysObject parent)
{
// A simple linkset of one (no children)
LinksetID = m_nextLinksetID++;
@@ -83,14 +83,14 @@ public class BSLinkset
m_nextLinksetID = 1;
m_physicsScene = scene;
m_linksetRoot = parent;
- m_children = new List();
+ m_children = new List();
m_mass = parent.MassRaw;
}
// Link to a linkset where the child knows the parent.
// Parent changing should not happen so do some sanity checking.
// We return the parent's linkset so the child can track its membership.
- public BSLinkset AddMeToLinkset(BSPrim child)
+ public BSLinkset AddMeToLinkset(BSPhysObject child)
{
lock (m_linksetActivityLock)
{
@@ -102,7 +102,7 @@ public class BSLinkset
// Remove a child from a linkset.
// Returns a new linkset for the child which is a linkset of one (just the
// orphened child).
- public BSLinkset RemoveMeFromLinkset(BSPrim child)
+ public BSLinkset RemoveMeFromLinkset(BSPhysObject child)
{
lock (m_linksetActivityLock)
{
@@ -129,7 +129,7 @@ public class BSLinkset
}
// Return 'true' if the passed object is the root object of this linkset
- public bool IsRoot(BSPrim requestor)
+ public bool IsRoot(BSPhysObject requestor)
{
return (requestor.LocalID == m_linksetRoot.LocalID);
}
@@ -140,12 +140,12 @@ public class BSLinkset
public bool HasAnyChildren { get { return (m_children.Count > 0); } }
// Return 'true' if this child is in this linkset
- public bool HasChild(BSPrim child)
+ public bool HasChild(BSPhysObject child)
{
bool ret = false;
lock (m_linksetActivityLock)
{
- foreach (BSPrim bp in m_children)
+ foreach (BSPhysObject bp in m_children)
{
if (child.LocalID == bp.LocalID)
{
@@ -160,7 +160,7 @@ public class BSLinkset
private float ComputeLinksetMass()
{
float mass = m_linksetRoot.MassRaw;
- foreach (BSPrim bp in m_children)
+ foreach (BSPhysObject bp in m_children)
{
mass += bp.MassRaw;
}
@@ -174,7 +174,7 @@ public class BSLinkset
lock (m_linksetActivityLock)
{
- foreach (BSPrim bp in m_children)
+ foreach (BSPhysObject bp in m_children)
{
com += bp.Position * bp.MassRaw;
totalMass += bp.MassRaw;
@@ -192,7 +192,7 @@ public class BSLinkset
lock (m_linksetActivityLock)
{
- foreach (BSPrim bp in m_children)
+ foreach (BSPhysObject bp in m_children)
{
com += bp.Position * bp.MassRaw;
}
@@ -204,7 +204,7 @@ public class BSLinkset
// When physical properties are changed the linkset needs to recalculate
// its internal properties.
- public void Refresh(BSPrim requestor)
+ public void Refresh(BSPhysObject requestor)
{
// If there are no children, there aren't any constraints to recompute
if (!HasAnyChildren)
@@ -230,7 +230,7 @@ public class BSLinkset
float linksetMass = LinksetMass;
lock (m_linksetActivityLock)
{
- foreach (BSPrim child in m_children)
+ foreach (BSPhysObject child in m_children)
{
BSConstraint constrain;
if (m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.Body, child.Body, out constrain))
@@ -255,14 +255,14 @@ public class BSLinkset
// I am the root of a linkset and a new child is being added
// Called while LinkActivity is locked.
- private void AddChildToLinkset(BSPrim child)
+ private void AddChildToLinkset(BSPhysObject child)
{
if (!HasChild(child))
{
m_children.Add(child);
- BSPrim rootx = LinksetRoot; // capture the root as of now
- BSPrim childx = child;
+ BSPhysObject rootx = LinksetRoot; // capture the root as of now
+ BSPhysObject childx = child;
m_physicsScene.TaintedObject("AddChildToLinkset", delegate()
{
DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
@@ -277,7 +277,7 @@ public class BSLinkset
// it's still connected to the linkset.
// Normal OpenSimulator operation will never do this because other SceneObjectPart information
// has to be updated also (like pointer to prim's parent).
- private void RemoveChildFromOtherLinkset(BSPrim pchild)
+ private void RemoveChildFromOtherLinkset(BSPhysObject pchild)
{
pchild.Linkset = new BSLinkset(m_physicsScene, pchild);
RemoveChildFromLinkset(pchild);
@@ -285,12 +285,12 @@ public class BSLinkset
// I am the root of a linkset and one of my children is being removed.
// Safe to call even if the child is not really in my linkset.
- private void RemoveChildFromLinkset(BSPrim child)
+ private void RemoveChildFromLinkset(BSPhysObject child)
{
if (m_children.Remove(child))
{
- BSPrim rootx = LinksetRoot; // capture the root as of now
- BSPrim childx = child;
+ BSPhysObject rootx = LinksetRoot; // capture the root as of now
+ BSPhysObject childx = child;
m_physicsScene.TaintedObject("RemoveChildFromLinkset", delegate()
{
DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
@@ -310,7 +310,7 @@ public class BSLinkset
// Create a constraint between me (root of linkset) and the passed prim (the child).
// Called at taint time!
- private void PhysicallyLinkAChildToRoot(BSPrim rootPrim, BSPrim childPrim)
+ private void PhysicallyLinkAChildToRoot(BSPhysObject rootPrim, BSPhysObject childPrim)
{
// Zero motion for children so they don't interpolate
childPrim.ZeroMotion();
@@ -383,7 +383,7 @@ public class BSLinkset
// Remove linkage between myself and a particular child
// Called at taint time!
- private void PhysicallyUnlinkAChildFromRoot(BSPrim rootPrim, BSPrim childPrim)
+ private void PhysicallyUnlinkAChildFromRoot(BSPhysObject rootPrim, BSPhysObject childPrim)
{
DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID);
@@ -396,7 +396,7 @@ public class BSLinkset
// Remove linkage between myself and any possible children I might have
// Called at taint time!
- private void PhysicallyUnlinkAllChildrenFromRoot(BSPrim rootPrim)
+ private void PhysicallyUnlinkAllChildrenFromRoot(BSPhysObject rootPrim)
{
DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
new file mode 100755
index 0000000..6e205a9
--- /dev/null
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyrightD
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using OMV = OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Physics.BulletSPlugin
+{
+// Class to wrap all objects.
+// The rest of BulletSim doesn't need to keep checking for avatars or prims
+// unless the difference is significant.
+public abstract class BSPhysObject : PhysicsActor
+{
+ public abstract BSLinkset Linkset { get; set; }
+
+ public abstract void Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type,
+ OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth);
+ public abstract void SendCollisions();
+
+ // Return the object mass without calculating it or side effects
+ public abstract float MassRaw { get; }
+
+ public abstract BulletBody Body { get; set; }
+ public abstract void ZeroMotion();
+
+ public abstract void UpdateProperties(EntityProperties entprop);
+
+ public abstract void Destroy();
+}
+}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index d3f1e9c..036fd4f 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -37,7 +37,7 @@ using OpenSim.Region.Physics.ConvexDecompositionDotNet;
namespace OpenSim.Region.Physics.BulletSPlugin
{
[Serializable]
-public sealed class BSPrim : PhysicsActor
+public sealed class BSPrim : BSPhysObject
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[BULLETS PRIM]";
@@ -88,23 +88,14 @@ public sealed class BSPrim : PhysicsActor
private float _buoyancy;
// Membership in a linkset is controlled by this class.
- private BSLinkset _linkset;
- public BSLinkset Linkset
- {
- get { return _linkset; }
- set { _linkset = value; }
- }
+ public override BSLinkset Linkset { get; set; }
private int _subscribedEventsMs = 0;
private int _nextCollisionOkTime = 0;
long _collidingStep;
long _collidingGroundStep;
- private BulletBody m_body;
- public BulletBody Body {
- get { return m_body; }
- set { m_body = value; }
- }
+ public override BulletBody Body { get; set; }
private BSDynamics _vehicle;
@@ -139,7 +130,7 @@ public sealed class BSPrim : PhysicsActor
_friction = _scene.Params.defaultFriction; // TODO: compute based on object material
_density = _scene.Params.defaultDensity; // TODO: compute based on object material
_restitution = _scene.Params.defaultRestitution;
- _linkset = new BSLinkset(Scene, this); // a linkset of one
+ Linkset = new BSLinkset(Scene, this); // a linkset of one
_vehicle = new BSDynamics(Scene, this); // add vehicleness
_mass = CalculateMass();
// do the actual object creation at taint time
@@ -151,23 +142,23 @@ public sealed class BSPrim : PhysicsActor
// Get the pointer to the physical body for this object.
// At the moment, we're still letting BulletSim manage the creation and destruction
// of the object. Someday we'll move that into the C# code.
- m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID));
+ Body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID));
});
}
// called when this prim is being destroyed and we should free all the resources
- public void Destroy()
+ public override void Destroy()
{
// m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID);
// Undo any links between me and any other object
- BSPrim parentBefore = _linkset.LinksetRoot;
- int childrenBefore = _linkset.NumberOfChildren;
+ BSPhysObject parentBefore = Linkset.LinksetRoot;
+ int childrenBefore = Linkset.NumberOfChildren;
- _linkset = _linkset.RemoveMeFromLinkset(this);
+ Linkset = Linkset.RemoveMeFromLinkset(this);
DetailLog("{0},BSPrim.Destroy,call,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}",
- LocalID, parentBefore.LocalID, childrenBefore, _linkset.LinksetRoot.LocalID, _linkset.NumberOfChildren);
+ LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren);
// Undo any vehicle properties
this.VehicleType = (int)Vehicle.TYPE_NONE;
@@ -230,13 +221,13 @@ public sealed class BSPrim : PhysicsActor
BSPrim parent = obj as BSPrim;
if (parent != null)
{
- BSPrim parentBefore = _linkset.LinksetRoot;
- int childrenBefore = _linkset.NumberOfChildren;
+ BSPhysObject parentBefore = Linkset.LinksetRoot;
+ int childrenBefore = Linkset.NumberOfChildren;
- _linkset = parent.Linkset.AddMeToLinkset(this);
+ Linkset = parent.Linkset.AddMeToLinkset(this);
DetailLog("{0},BSPrim.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}",
- LocalID, parentBefore.LocalID, childrenBefore, _linkset.LinksetRoot.LocalID, _linkset.NumberOfChildren);
+ LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren);
}
return;
}
@@ -246,13 +237,13 @@ public sealed class BSPrim : PhysicsActor
// TODO: decide if this parent checking needs to happen at taint time
// Race condition here: if link() and delink() in same simulation tick, the delink will not happen
- BSPrim parentBefore = _linkset.LinksetRoot;
- int childrenBefore = _linkset.NumberOfChildren;
+ BSPhysObject parentBefore = Linkset.LinksetRoot;
+ int childrenBefore = Linkset.NumberOfChildren;
- _linkset = _linkset.RemoveMeFromLinkset(this);
+ Linkset = Linkset.RemoveMeFromLinkset(this);
DetailLog("{0},BSPrim.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ",
- LocalID, parentBefore.LocalID, childrenBefore, _linkset.LinksetRoot.LocalID, _linkset.NumberOfChildren);
+ LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren);
return;
}
@@ -260,7 +251,7 @@ public sealed class BSPrim : PhysicsActor
// Do it to the properties so the values get set in the physics engine.
// Push the setting of the values to the viewer.
// Called at taint time!
- public void ZeroMotion()
+ public override void ZeroMotion()
{
_velocity = OMV.Vector3.Zero;
_acceleration = OMV.Vector3.Zero;
@@ -281,7 +272,7 @@ public sealed class BSPrim : PhysicsActor
public override OMV.Vector3 Position {
get {
- if (!_linkset.IsRoot(this))
+ if (!Linkset.IsRoot(this))
// child prims move around based on their parent. Need to get the latest location
_position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
@@ -306,23 +297,23 @@ public sealed class BSPrim : PhysicsActor
{
get
{
- return _linkset.LinksetMass;
+ return Linkset.LinksetMass;
}
}
// used when we only want this prim's mass and not the linkset thing
- public float MassRaw { get { return _mass; } }
+ public override float MassRaw { get { return _mass; } }
// Is this used?
public override OMV.Vector3 CenterOfMass
{
- get { return _linkset.CenterOfMass; }
+ get { return Linkset.CenterOfMass; }
}
// Is this used?
public override OMV.Vector3 GeometricCenter
{
- get { return _linkset.GeometricCenter; }
+ get { return Linkset.GeometricCenter; }
}
public override OMV.Vector3 Force {
@@ -431,7 +422,7 @@ public sealed class BSPrim : PhysicsActor
}
public override OMV.Quaternion Orientation {
get {
- if (!_linkset.IsRoot(this))
+ if (!Linkset.IsRoot(this))
{
// Children move around because tied to parent. Get a fresh value.
_orientation = BulletSimAPI.GetObjectOrientation(_scene.WorldID, LocalID);
@@ -490,7 +481,7 @@ public sealed class BSPrim : PhysicsActor
BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass);
// recompute any linkset parameters
- _linkset.Refresh(this);
+ Linkset.Refresh(this);
CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr);
DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf);
@@ -1299,7 +1290,7 @@ public sealed class BSPrim : PhysicsActor
const float ACCELERATION_TOLERANCE = 0.01f;
const float ROTATIONAL_VELOCITY_TOLERANCE = 0.01f;
- public void UpdateProperties(EntityProperties entprop)
+ public override void UpdateProperties(EntityProperties entprop)
{
/*
UpdatedProperties changed = 0;
@@ -1347,7 +1338,7 @@ public sealed class BSPrim : PhysicsActor
// Don't check for damping here -- it's done in BulletSim and SceneObjectPart.
// Updates only for individual prims and for the root object of a linkset.
- if (_linkset.IsRoot(this))
+ if (Linkset.IsRoot(this))
{
// Assign to the local variables so the normal set action does not happen
_position = entprop.Position;
@@ -1375,7 +1366,7 @@ public sealed class BSPrim : PhysicsActor
// I've collided with something
// Called at taint time from within the Step() function
CollisionEventUpdate collisionCollection;
- public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
+ public override void Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
{
// m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
@@ -1387,18 +1378,15 @@ public sealed class BSPrim : PhysicsActor
}
// DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith);
- BSPrim collidingWithPrim;
- if (_scene.Prims.TryGetValue(collidingWith, out collidingWithPrim))
+
+ // prims in the same linkset cannot collide with each other
+ if (collidee != null && (this.Linkset.LinksetID == collidee.Linkset.LinksetID))
{
- // prims in the same linkset cannot collide with each other
- if (this.Linkset.LinksetID == collidingWithPrim.Linkset.LinksetID)
- {
- return;
- }
+ return;
}
- // if someone is subscribed to collision events....
- if (_subscribedEventsMs != 0) {
+ // if someone has subscribed for collision events....
+ if (SubscribedEvents()) {
// throttle the collisions to the number of milliseconds specified in the subscription
int nowTime = _scene.SimulationNowTime;
if (nowTime >= _nextCollisionOkTime) {
@@ -1412,7 +1400,7 @@ public sealed class BSPrim : PhysicsActor
}
// The scene is telling us it's time to pass our collected collisions into the simulator
- public void SendCollisions()
+ public override void SendCollisions()
{
if (collisionCollection != null && collisionCollection.Count > 0)
{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 56924aa..ce64b9b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -78,14 +78,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public string BulletSimVersion = "?";
- private Dictionary m_avatars = new Dictionary();
- public Dictionary Characters { get { return m_avatars; } }
-
- private Dictionary m_prims = new Dictionary();
- public Dictionary Prims { get { return m_prims; } }
+ public Dictionary PhysObjects = new Dictionary();
+ private HashSet m_objectsWithCollisions = new HashSet();
+ // Following is a kludge and can be removed when avatar animation updating is
+ // moved to a better place.
private HashSet m_avatarsWithCollisions = new HashSet();
- private HashSet m_primsWithCollisions = new HashSet();
private List m_vehicles = new List();
@@ -235,7 +233,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// BulletSimVersion = BulletSimAPI.GetVersion();
// m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion);
- // if Debug, enable logging from the unmanaged code
+ // If Debug logging level, enable logging from the unmanaged code
if (m_log.IsDebugEnabled || PhysicsLogging.Enabled)
{
m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader);
@@ -243,13 +241,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters
m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog);
else
m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger);
- // the handle is saved in a variable to make sure it doesn't get freed after this call
+ // The handle is saved in a variable to make sure it doesn't get freed after this call
BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle);
}
_taintedObjects = new List();
mesher = meshmerizer;
+
// The bounding box for the simulated world
Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 8192f);
@@ -337,7 +336,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters
if (!m_initialized) return null;
BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
- lock (m_avatars) m_avatars.Add(localID, actor);
+ lock (PhysObjects) PhysObjects.Add(localID, actor);
+
+ // Remove kludge someday
+ lock (m_avatarsWithCollisions) m_avatarsWithCollisions.Add(actor);
+
return actor;
}
@@ -352,7 +355,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
{
try
{
- lock (m_avatars) m_avatars.Remove(actor.LocalID);
+ lock (PhysObjects) PhysObjects.Remove(actor.LocalID);
+ // Remove kludge someday
+ lock (m_avatarsWithCollisions) m_avatarsWithCollisions.Remove(bsactor);
}
catch (Exception e)
{
@@ -374,7 +379,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID);
try
{
- lock (m_prims) m_prims.Remove(bsprim.LocalID);
+ lock (PhysObjects) PhysObjects.Remove(bsprim.LocalID);
}
catch (Exception e)
{
@@ -399,7 +404,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
DetailLog("{0},AddPrimShape,call", localID);
BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical);
- lock (m_prims) m_prims.Add(localID, prim);
+ lock (PhysObjects) PhysObjects.Add(localID, prim);
return prim;
}
@@ -470,19 +475,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// The above SendCollision's batch up the collisions on the objects.
// Now push the collisions into the simulator.
- foreach (BSPrim bsp in m_primsWithCollisions)
+ foreach (BSPhysObject bsp in m_objectsWithCollisions)
bsp.SendCollisions();
- m_primsWithCollisions.Clear();
+ m_objectsWithCollisions.Clear();
// This is a kludge to get avatar movement updated.
- // Don't send collisions only if there were collisions -- send everytime.
// ODE sends collisions even if there are none and this is used to update
// avatar animations and stuff.
- // foreach (BSCharacter bsc in m_avatarsWithCollisions)
- // bsc.SendCollisions();
- foreach (KeyValuePair kvp in m_avatars)
- kvp.Value.SendCollisions();
- m_avatarsWithCollisions.Clear();
+ foreach (BSPhysObject bpo in m_avatarsWithCollisions)
+ bpo.SendCollisions();
+ // m_avatarsWithCollisions.Clear();
// If any of the objects had updated properties, tell the object it has been changed by the physics engine
if (updatedEntityCount > 0)
@@ -490,16 +492,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters
for (int ii = 0; ii < updatedEntityCount; ii++)
{
EntityProperties entprop = m_updateArray[ii];
- BSPrim prim;
- if (m_prims.TryGetValue(entprop.ID, out prim))
- {
- prim.UpdateProperties(entprop);
- continue;
- }
- BSCharacter actor;
- if (m_avatars.TryGetValue(entprop.ID, out actor))
+ BSPhysObject pobj;
+ if (PhysObjects.TryGetValue(entprop.ID, out pobj))
{
- actor.UpdateProperties(entprop);
+ pobj.UpdateProperties(entprop);
continue;
}
}
@@ -529,33 +525,36 @@ public class BSScene : PhysicsScene, IPhysicsParameters
}
// Something has collided
- private void SendCollision(uint localID, uint collidingWith, Vector3 collidePoint, Vector3 collideNormal, float penitration)
+ private void SendCollision(uint localID, uint collidingWith, Vector3 collidePoint, Vector3 collideNormal, float penetration)
{
if (localID == TERRAIN_ID || localID == GROUNDPLANE_ID)
{
return; // don't send collisions to the terrain
}
+ BSPhysObject collider = PhysObjects[localID];
+ // TODO: as of this code, terrain was not in the physical object list.
+ // When BSTerrain is created and it will be in the list, we can remove
+ // the possibility that it's not there and just fetch the collidee.
+ BSPhysObject collidee = null;
+
ActorTypes type = ActorTypes.Prim;
if (collidingWith == TERRAIN_ID || collidingWith == GROUNDPLANE_ID)
+ {
type = ActorTypes.Ground;
- else if (m_avatars.ContainsKey(collidingWith))
- type = ActorTypes.Agent;
+ }
+ else
+ {
+ collidee = PhysObjects[collidingWith];
+ if (collidee is BSCharacter)
+ type = ActorTypes.Agent;
+ }
// DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
- BSPrim prim;
- if (m_prims.TryGetValue(localID, out prim)) {
- prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration);
- m_primsWithCollisions.Add(prim);
- return;
- }
- BSCharacter actor;
- if (m_avatars.TryGetValue(localID, out actor)) {
- actor.Collide(collidingWith, type, collidePoint, collideNormal, penitration);
- m_avatarsWithCollisions.Add(actor);
- return;
- }
+ collider.Collide(collidingWith, collidee, type, collidePoint, collideNormal, penetration);
+ m_objectsWithCollisions.Add(collider);
+
return;
}
@@ -605,17 +604,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// make sure no stepping happens while we're deleting stuff
m_initialized = false;
- foreach (KeyValuePair kvp in m_avatars)
- {
- kvp.Value.Destroy();
- }
- m_avatars.Clear();
-
- foreach (KeyValuePair kvp in m_prims)
+ foreach (KeyValuePair kvp in PhysObjects)
{
kvp.Value.Destroy();
}
- m_prims.Clear();
+ PhysObjects.Clear();
// Now that the prims are all cleaned up, there should be no constraints left
if (m_constraintCollection != null)
@@ -996,42 +989,42 @@ public class BSScene : PhysicsScene, IPhysicsParameters
0f,
(s,cf,p,v) => { s.m_params[0].linearDamping = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].linearDamping; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].linearDamping, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].linearDamping, p, l, v); } ),
new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)",
0f,
(s,cf,p,v) => { s.m_params[0].angularDamping = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].angularDamping; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].angularDamping, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].angularDamping, p, l, v); } ),
new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static",
0.2f,
(s,cf,p,v) => { s.m_params[0].deactivationTime = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].deactivationTime; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].deactivationTime, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].deactivationTime, p, l, v); } ),
new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static",
0.8f,
(s,cf,p,v) => { s.m_params[0].linearSleepingThreshold = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].linearSleepingThreshold; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].linearSleepingThreshold, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].linearSleepingThreshold, p, l, v); } ),
new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static",
1.0f,
(s,cf,p,v) => { s.m_params[0].angularSleepingThreshold = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].angularSleepingThreshold; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].angularSleepingThreshold, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].angularSleepingThreshold, p, l, v); } ),
new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
0f, // set to zero to disable
(s,cf,p,v) => { s.m_params[0].ccdMotionThreshold = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].ccdMotionThreshold; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].ccdMotionThreshold, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].ccdMotionThreshold, p, l, v); } ),
new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
0f,
(s,cf,p,v) => { s.m_params[0].ccdSweptSphereRadius = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].ccdSweptSphereRadius; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].ccdSweptSphereRadius, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].ccdSweptSphereRadius, p, l, v); } ),
new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" ,
0.1f,
(s,cf,p,v) => { s.m_params[0].contactProcessingThreshold = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].contactProcessingThreshold; },
- (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].contactProcessingThreshold, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].contactProcessingThreshold, p, l, v); } ),
new ParameterDefn("TerrainFriction", "Factor to reduce movement against terrain surface" ,
0.5f,
@@ -1052,32 +1045,32 @@ public class BSScene : PhysicsScene, IPhysicsParameters
0.5f,
(s,cf,p,v) => { s.m_params[0].avatarFriction = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarFriction; },
- (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarFriction, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarFriction, p, l, v); } ),
new ParameterDefn("AvatarDensity", "Density of an avatar. Changed on avatar recreation.",
60f,
(s,cf,p,v) => { s.m_params[0].avatarDensity = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarDensity; },
- (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarDensity, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarDensity, p, l, v); } ),
new ParameterDefn("AvatarRestitution", "Bouncyness. Changed on avatar recreation.",
0f,
(s,cf,p,v) => { s.m_params[0].avatarRestitution = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarRestitution; },
- (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarRestitution, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarRestitution, p, l, v); } ),
new ParameterDefn("AvatarCapsuleRadius", "Radius of space around an avatar",
0.37f,
(s,cf,p,v) => { s.m_params[0].avatarCapsuleRadius = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarCapsuleRadius; },
- (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarCapsuleRadius, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleRadius, p, l, v); } ),
new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar",
1.5f,
(s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarCapsuleHeight; },
- (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarCapsuleHeight, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleHeight, p, l, v); } ),
new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
0.1f,
(s,cf,p,v) => { s.m_params[0].avatarContactProcessingThreshold = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarContactProcessingThreshold; },
- (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarContactProcessingThreshold, p, l, v); } ),
+ (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarContactProcessingThreshold, p, l, v); } ),
new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
@@ -1264,18 +1257,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters
}
// check to see if we are updating a parameter for a particular or all of the prims
- protected void UpdateParameterPrims(ref float loc, string parm, uint localID, float val)
- {
- List operateOn;
- lock (m_prims) operateOn = new List(m_prims.Keys);
- UpdateParameterSet(operateOn, ref loc, parm, localID, val);
- }
-
- // check to see if we are updating a parameter for a particular or all of the avatars
- protected void UpdateParameterAvatars(ref float loc, string parm, uint localID, float val)
+ protected void UpdateParameterObject(ref float loc, string parm, uint localID, float val)
{
List operateOn;
- lock (m_avatars) operateOn = new List(m_avatars.Keys);
+ lock (PhysObjects) operateOn = new List(PhysObjects.Keys);
UpdateParameterSet(operateOn, ref loc, parm, localID, val);
}
--
cgit v1.1
From 7c140570db3b01eb83efc0d42a47715d3047e376 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Sat, 25 Aug 2012 23:18:46 -0700
Subject: BulletSim: Changes to terrain storage and management so mega-regions
work. Moved all terrain code out of BSScene and into new BSTerrainManager.
Added logic to manage multiple terrains for mega-regions. Added new functions
to BulletSimAPI to match the library. Moved all of the terrain creation and
setup logic from C++ code to C# code. The unused code has not yet been
removed from either place. Soon. Moved checks for avatar above ground and in
bounds into BSCharacter.
---
.../Region/Physics/BulletSPlugin/BSCharacter.cs | 37 ++-
.../Region/Physics/BulletSPlugin/BSConstraint.cs | 3 +-
OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 9 +-
.../Region/Physics/BulletSPlugin/BSPhysObject.cs | 118 ++++----
OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 2 +-
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 245 ++++++++--------
.../Physics/BulletSPlugin/BSTerrainManager.cs | 307 +++++++++++++++++++++
.../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 61 +++-
8 files changed, 597 insertions(+), 185 deletions(-)
create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 784076d..e76d8a4 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -226,16 +226,37 @@ public class BSCharacter : BSPhysObject
bool ret = false;
// If below the ground, move the avatar up
- float terrainHeight = Scene.GetTerrainHeightAtXYZ(_position);
- if (_position.Z < terrainHeight)
+ float terrainHeight = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position);
+ if (Position.Z < terrainHeight)
{
- DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},orient={2}", LocalID, _position, _orientation);
- _position.Z = terrainHeight + 2.0f;
+ DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
+ Vector3 newPos = _position;
+ newPos.Z = terrainHeight + 2.0f;
+ _position = newPos;
ret = true;
}
// TODO: check for out of bounds
+ return ret;
+ }
+ // A version of the sanity check that also makes sure a new position value is
+ // pushed back to the physics engine. This routine would be used by anyone
+ // who is not already pushing the value.
+ private bool PositionSanityCheck2()
+ {
+ bool ret = false;
+ if (PositionSanityCheck())
+ {
+ // The new position value must be pushed into the physics engine but we can't
+ // just assign to "Position" because of potential call loops.
+ _scene.TaintedObject("BSCharacter.PositionSanityCheck", delegate()
+ {
+ DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
+ BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
+ });
+ ret = true;
+ }
return ret;
}
@@ -500,9 +521,13 @@ public class BSCharacter : BSPhysObject
// Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.
// base.RequestPhysicsterseUpdate();
- DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
+ // Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
+ PositionSanityCheck2();
+
+ float heightHere = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position); // just for debug
+ DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5},terrain={6}",
LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
- entprop.Acceleration, entprop.RotationalVelocity);
+ entprop.Acceleration, entprop.RotationalVelocity, heightHere);
}
// Called by the scene when a collision with this object is reported
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
index 25084d8..d9270d1 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
@@ -48,11 +48,10 @@ public abstract class BSConstraint : IDisposable
{
if (m_enabled)
{
- // BulletSimAPI.RemoveConstraint(m_world.ID, m_body1.ID, m_body2.ID);
+ m_enabled = false;
bool success = BulletSimAPI.DestroyConstraint2(m_world.Ptr, m_constraint.Ptr);
m_world.scene.DetailLog("{0},BSConstraint.Dispose,taint,body1={1},body2={2},success={3}", BSScene.DetailLogZero, m_body1.ID, m_body2.ID, success);
m_constraint.Ptr = System.IntPtr.Zero;
- m_enabled = false;
}
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index d7213fc..8169e99 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -465,6 +465,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
}//end SetDefaultsForType
+ // One step of the vehicle properties for the next 'pTimestep' seconds.
internal void Step(float pTimestep)
{
if (m_type == Vehicle.TYPE_NONE) return;
@@ -592,9 +593,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
// If below the terrain, move us above the ground a little.
- if (pos.Z < m_prim.Scene.GetTerrainHeightAtXYZ(pos))
+ if (pos.Z < m_prim.Scene.TerrainManager.GetTerrainHeightAtXYZ(pos))
{
- pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2;
+ pos.Z = m_prim.Scene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2;
m_prim.Position = pos;
VDetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos);
}
@@ -609,7 +610,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
{
- m_VhoverTargetHeight = m_prim.Scene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight;
+ m_VhoverTargetHeight = m_prim.Scene.TerrainManager.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight;
}
if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0)
{
@@ -673,7 +674,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
grav.Z = (float)(grav.Z * 1.125);
}
- float terraintemp = m_prim.Scene.GetTerrainHeightAtXYZ(pos);
+ float terraintemp = m_prim.Scene.TerrainManager.GetTerrainHeightAtXYZ(pos);
float postemp = (pos.Z - terraintemp);
if (postemp > 2.5f)
{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 6e205a9..ef463ca 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -1,58 +1,60 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyrightD
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using OMV = OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Physics.Manager;
-
-namespace OpenSim.Region.Physics.BulletSPlugin
-{
-// Class to wrap all objects.
-// The rest of BulletSim doesn't need to keep checking for avatars or prims
-// unless the difference is significant.
-public abstract class BSPhysObject : PhysicsActor
-{
- public abstract BSLinkset Linkset { get; set; }
-
- public abstract void Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type,
- OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth);
- public abstract void SendCollisions();
-
- // Return the object mass without calculating it or side effects
- public abstract float MassRaw { get; }
-
- public abstract BulletBody Body { get; set; }
- public abstract void ZeroMotion();
-
- public abstract void UpdateProperties(EntityProperties entprop);
-
- public abstract void Destroy();
-}
-}
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyrightD
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using OMV = OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Physics.BulletSPlugin
+{
+// Class to wrap all objects.
+// The rest of BulletSim doesn't need to keep checking for avatars or prims
+// unless the difference is significant.
+public abstract class BSPhysObject : PhysicsActor
+{
+ public abstract BSLinkset Linkset { get; set; }
+
+ public abstract void Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type,
+ OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth);
+ public abstract void SendCollisions();
+
+ // Return the object mass without calculating it or side effects
+ public abstract float MassRaw { get; }
+
+ public abstract BulletBody Body { get; set; }
+ public abstract void ZeroMotion();
+
+ public virtual void StepVehicle(float timeStep) { }
+
+ public abstract void UpdateProperties(EntityProperties entprop);
+
+ public abstract void Destroy();
+}
+}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 036fd4f..6bfce5c 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -377,7 +377,7 @@ public sealed class BSPrim : BSPhysObject
// Called each simulation step to advance vehicle characteristics.
// Called from Scene when doing simulation step so we're in taint processing time.
- public void StepVehicle(float timeStep)
+ public override void StepVehicle(float timeStep)
{
if (IsPhysical)
_vehicle.Step(timeStep);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index ce64b9b..f80304d 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -39,8 +39,6 @@ using log4net;
using OpenMetaverse;
// TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim)
-// Debug linkset
-// Test with multiple regions in one simulator
// Adjust character capsule size when height is adjusted (ScenePresence.SetHeight)
// Test sculpties
// Compute physics FPS reasonably
@@ -54,10 +52,8 @@ using OpenMetaverse;
// Use collision masks for collision with terrain and phantom objects
// Check out llVolumeDetect. Must do something for that.
// Should prim.link() and prim.delink() membership checking happen at taint time?
-// changing the position and orientation of a linked prim must rebuild the constraint with the root.
// Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once
// Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect
-// Implement the genCollisions feature in BulletSim::SetObjectProperties (don't pass up unneeded collisions)
// Implement LockAngularMotion
// Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation)
// Does NeedsMeshing() really need to exclude all the different shapes?
@@ -85,18 +81,15 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// moved to a better place.
private HashSet m_avatarsWithCollisions = new HashSet();
- private List m_vehicles = new List();
-
- private float[] m_heightMap;
- private float m_waterLevel;
- private uint m_worldID;
- public uint WorldID { get { return m_worldID; } }
+ // List of all the objects that have vehicle properties and should be called
+ // to update each physics step.
+ private List m_vehicles = new List();
// let my minuions use my logger
public ILog Logger { get { return m_log; } }
- private bool m_initialized = false;
-
+ // If non-zero, the number of simulation steps between calls to the physics
+ // engine to output detailed physics stats. Debug logging level must be on also.
private int m_detailedStatsStep = 0;
public IMesher mesher;
@@ -106,29 +99,31 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public float MeshMegaPrimThreshold { get; private set; }
public float SculptLOD { get; private set; }
- private BulletSim m_worldSim;
- public BulletSim World
- {
- get { return m_worldSim; }
- }
- private BSConstraintCollection m_constraintCollection;
- public BSConstraintCollection Constraints
- {
- get { return m_constraintCollection; }
- }
+ public uint WorldID { get; private set; }
+ public BulletSim World { get; private set; }
+
+ // All the constraints that have been allocated in this instance.
+ public BSConstraintCollection Constraints { get; private set; }
+ // Simulation parameters
private int m_maxSubSteps;
private float m_fixedTimeStep;
private long m_simulationStep = 0;
public long SimulationStep { get { return m_simulationStep; } }
+ // The length of the last timestep we were asked to simulate.
+ // This is used by the vehicle code. Since the vehicle code is called
+ // once per simulation step, its constants need to be scaled by this.
public float LastSimulatedTimestep { get; private set; }
// A value of the time now so all the collision and update routines do not have to get their own
- // Set to 'now' just before all the prims and actors are called for collisions and updates
- private int m_simulationNowTime;
- public int SimulationNowTime { get { return m_simulationNowTime; } }
+ // Set to 'now' just before all the prims and actors are called for collisions and updates
+ public int SimulationNowTime { get; private set; }
+
+ // True if initialized and ready to do simulation steps
+ private bool m_initialized = false;
+ // Pinned memory used to pass step information between managed and unmanaged
private int m_maxCollisionsPerFrame;
private CollisionDesc[] m_collisionArray;
private GCHandle m_collisionArrayPinnedHandle;
@@ -145,6 +140,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero
public const uint GROUNDPLANE_ID = 1;
+ public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here
+
+ private float m_waterLevel;
+ public BSTerrainManager TerrainManager { get; private set; }
public ConfigurationParameters Params
{
@@ -155,12 +154,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
get { return new Vector3(0f, 0f, Params.gravity); }
}
- private float m_maximumObjectMass;
- public float MaximumObjectMass
- {
- get { return m_maximumObjectMass; }
- }
+ public float MaximumObjectMass { get; private set; }
+ // When functions in the unmanaged code must be called, it is only
+ // done at a known time just before the simulation step. The taint
+ // system saves all these function calls and executes them in
+ // order before the simulation.
public delegate void TaintCallback();
private struct TaintCallbackEntry
{
@@ -176,6 +175,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private Object _taintLock = new Object();
// A pointer to an instance if this structure is passed to the C++ code
+ // Used to pass basic configuration values to the unmanaged code.
ConfigurationParameters[] m_params;
GCHandle m_paramsHandle;
@@ -189,11 +189,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private bool m_physicsLoggingEnabled;
private string m_physicsLoggingDir;
private string m_physicsLoggingPrefix;
- private int m_physicsLoggingFileMinutes;
-
- private bool m_vehicleLoggingEnabled;
- public bool VehicleLoggingEnabled { get { return m_vehicleLoggingEnabled; } }
+ private int m_physicsLoggingFileMinutes;
+ // 'true' of the vehicle code is to log lots of details
+ public bool VehicleLoggingEnabled { get; private set; }
+ #region Construction and Initialization
public BSScene(string identifier)
{
m_initialized = false;
@@ -216,6 +216,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];
m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned);
+ mesher = meshmerizer;
+ _taintedObjects = new List();
+
// Enable very detailed logging.
// By creating an empty logger when not logging, the log message invocation code
// can be left in and every call doesn't have to check for null.
@@ -228,11 +231,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters
PhysicsLogging = new Logging.LogWriter();
}
- // Get the version of the DLL
- // TODO: this doesn't work yet. Something wrong with marshaling the returned string.
- // BulletSimVersion = BulletSimAPI.GetVersion();
- // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion);
-
// If Debug logging level, enable logging from the unmanaged code
if (m_log.IsDebugEnabled || PhysicsLogging.Enabled)
{
@@ -245,22 +243,32 @@ public class BSScene : PhysicsScene, IPhysicsParameters
BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle);
}
- _taintedObjects = new List();
-
- mesher = meshmerizer;
+ // Get the version of the DLL
+ // TODO: this doesn't work yet. Something wrong with marshaling the returned string.
+ // BulletSimVersion = BulletSimAPI.GetVersion();
+ // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion);
- // The bounding box for the simulated world
+ // The bounding box for the simulated world. The origin is 0,0,0 unless we're
+ // a child in a mega-region.
+ // Turns out that Bullet really doesn't care about the extents of the simulated
+ // area. It tracks active objects no matter where they are.
Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 8192f);
// m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader);
- m_worldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(),
+ WorldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(),
m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(),
m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject());
// Initialization to support the transition to a new API which puts most of the logic
// into the C# code so it is easier to modify and add to.
- m_worldSim = new BulletSim(m_worldID, this, BulletSimAPI.GetSimHandle2(m_worldID));
- m_constraintCollection = new BSConstraintCollection(World);
+ World = new BulletSim(WorldID, this, BulletSimAPI.GetSimHandle2(WorldID));
+
+ Constraints = new BSConstraintCollection(World);
+
+ // Note: choose one of the two following lines
+ // BulletSimAPI.CreateInitialGroundPlaneAndTerrain(WorldID);
+ TerrainManager = new BSTerrainManager(this);
+ TerrainManager.CreateInitialGroundPlaneAndTerrain();
m_initialized = true;
}
@@ -288,7 +296,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
// Very detailed logging for vehicle debugging
- m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
+ VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
// Do any replacements in the parameters
m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
@@ -323,6 +331,38 @@ public class BSScene : PhysicsScene, IPhysicsParameters
PhysicsLogging.Write("[BULLETS UNMANAGED]:" + msg);
}
+ public override void Dispose()
+ {
+ // m_log.DebugFormat("{0}: Dispose()", LogHeader);
+
+ // make sure no stepping happens while we're deleting stuff
+ m_initialized = false;
+
+ TerrainManager.ReleaseGroundPlaneAndTerrain();
+
+ foreach (KeyValuePair kvp in PhysObjects)
+ {
+ kvp.Value.Destroy();
+ }
+ PhysObjects.Clear();
+
+ // Now that the prims are all cleaned up, there should be no constraints left
+ if (Constraints != null)
+ {
+ Constraints.Dispose();
+ Constraints = null;
+ }
+
+ // Anything left in the unmanaged code should be cleaned out
+ BulletSimAPI.Shutdown(WorldID);
+
+ // Not logging any more
+ PhysicsLogging.Close();
+ }
+ #endregion // Construction and Initialization
+
+ #region Prim and Avatar addition and removal
+
public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{
m_log.ErrorFormat("{0}: CALL TO AddAvatar in BSScene. NOT IMPLEMENTED", LogHeader);
@@ -413,6 +453,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// information call is not needed.
public override void AddPhysicsActorTaint(PhysicsActor prim) { }
+ #endregion // Prim and Avatar addition and removal
+
+ #region Simulation
// Simulate one timestep
public override float Simulate(float timeStep)
{
@@ -428,7 +471,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
int simulateStartTime = Util.EnvironmentTickCount();
- // update the prim states while we know the physics engine is not busy
+ // update the prim states while we know the physics engine is not busy
+ int numTaints = _taintedObjects.Count;
ProcessTaints();
// Some of the prims operate with special vehicle properties
@@ -440,14 +484,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters
int numSubSteps = 0;
try
{
- numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep,
+ numSubSteps = BulletSimAPI.PhysicsStep(WorldID, timeStep, m_maxSubSteps, m_fixedTimeStep,
out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr);
- DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount);
+ DetailLog("{0},Simulate,call, nTaints= {1}, substeps={2}, updates={3}, colliders={4}",
+ DetailLogZero, numTaints, numSubSteps, updatedEntityCount, collidersCount);
}
catch (Exception e)
{
- m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e);
- // DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount);
+ m_log.WarnFormat("{0},PhysicsStep Exception: nTaints={1}, substeps={2}, updates={3}, colliders={4}, e={5}",
+ LogHeader, numTaints, numSubSteps, updatedEntityCount, collidersCount, e);
+ DetailLog("{0},PhysicsStepException,call, nTaints={1}, substeps={2}, updates={3}, colliders={4}",
+ DetailLogZero, numTaints, numSubSteps, updatedEntityCount, collidersCount);
updatedEntityCount = 0;
collidersCount = 0;
}
@@ -456,7 +503,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// Don't have to use the pointers passed back since we know it is the same pinned memory we passed in
// Get a value for 'now' so all the collision and update routines don't have to get their own
- m_simulationNowTime = Util.EnvironmentTickCount();
+ SimulationNowTime = Util.EnvironmentTickCount();
// If there were collisions, process them by sending the event to the prim.
// Collisions must be processed before updates.
@@ -527,7 +574,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// Something has collided
private void SendCollision(uint localID, uint collidingWith, Vector3 collidePoint, Vector3 collideNormal, float penetration)
{
- if (localID == TERRAIN_ID || localID == GROUNDPLANE_ID)
+ if (localID <= TerrainManager.HighestTerrainID)
{
return; // don't send collisions to the terrain
}
@@ -539,7 +586,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
BSPhysObject collidee = null;
ActorTypes type = ActorTypes.Prim;
- if (collidingWith == TERRAIN_ID || collidingWith == GROUNDPLANE_ID)
+ if (collidingWith <= TerrainManager.HighestTerrainID)
{
type = ActorTypes.Ground;
}
@@ -558,28 +605,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters
return;
}
+ #endregion // Simulation
+
public override void GetResults() { }
- public override void SetTerrain(float[] heightMap) {
- m_heightMap = heightMap;
- this.TaintedObject("BSScene.SetTerrain", delegate()
- {
- BulletSimAPI.SetHeightmap(m_worldID, m_heightMap);
- });
- }
+ #region Terrain
- // Someday we will have complex terrain with caves and tunnels
- // For the moment, it's flat and convex
- public float GetTerrainHeightAtXYZ(Vector3 loc)
- {
- return GetTerrainHeightAtXY(loc.X, loc.Y);
- }
-
- public float GetTerrainHeightAtXY(float tX, float tY)
- {
- if (tX < 0 || tX >= Constants.RegionSize || tY < 0 || tY >= Constants.RegionSize)
- return 30;
- return m_heightMap[((int)tX) * Constants.RegionSize + ((int)tY)];
+ public override void SetTerrain(float[] heightMap) {
+ TerrainManager.SetTerrain(heightMap);
}
public override void SetWaterLevel(float baseheight)
@@ -595,35 +628,29 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public override void DeleteTerrain()
{
// m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
+ }
+
+ // Although no one seems to check this, I do support combining.
+ public override bool SupportsCombining()
+ {
+ return TerrainManager.SupportsCombining();
}
-
- public override void Dispose()
- {
- // m_log.DebugFormat("{0}: Dispose()", LogHeader);
-
- // make sure no stepping happens while we're deleting stuff
- m_initialized = false;
-
- foreach (KeyValuePair kvp in PhysObjects)
- {
- kvp.Value.Destroy();
- }
- PhysObjects.Clear();
-
- // Now that the prims are all cleaned up, there should be no constraints left
- if (m_constraintCollection != null)
- {
- m_constraintCollection.Dispose();
- m_constraintCollection = null;
- }
-
- // Anything left in the unmanaged code should be cleaned out
- BulletSimAPI.Shutdown(WorldID);
-
- // Not logging any more
- PhysicsLogging.Close();
+ // This call says I am a child to region zero in a mega-region. 'pScene' is that
+ // of region zero, 'offset' is my offset from regions zero's origin, and
+ // 'extents' is the largest XY that is handled in my region.
+ public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
+ {
+ TerrainManager.Combine(pScene, offset, extents);
+ }
+
+ // Unhook all the combining that I know about.
+ public override void UnCombine(PhysicsScene pScene)
+ {
+ TerrainManager.UnCombine(pScene);
}
+ #endregion // Terrain
+
public override Dictionary GetTopColliders()
{
return new Dictionary();
@@ -833,14 +860,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// no locking because only called when physics engine is not busy
private void ProcessVehicles(float timeStep)
{
- foreach (BSPrim prim in m_vehicles)
+ foreach (BSPhysObject pobj in m_vehicles)
{
- prim.StepVehicle(timeStep);
+ pobj.StepVehicle(timeStep);
}
}
#endregion Vehicles
- #region Parameters
+ #region INI and command line parameter processing
delegate void ParamUser(BSScene scene, IConfig conf, string paramName, float val);
delegate float ParamGet(BSScene scene);
@@ -943,9 +970,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
(s,p,l,v) => { s.m_maxUpdatesPerFrame = (int)v; } ),
new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)",
10000.01f,
- (s,cf,p,v) => { s.m_maximumObjectMass = cf.GetFloat(p, v); },
- (s) => { return (float)s.m_maximumObjectMass; },
- (s,p,l,v) => { s.m_maximumObjectMass = v; } ),
+ (s,cf,p,v) => { s.MaximumObjectMass = cf.GetFloat(p, v); },
+ (s) => { return (float)s.MaximumObjectMass; },
+ (s,p,l,v) => { s.MaximumObjectMass = v; } ),
new ParameterDefn("PID_D", "Derivitive factor for motion smoothing",
2200f,
@@ -1207,6 +1234,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private PhysParameterEntry[] SettableParameters = new PhysParameterEntry[1];
+ // This creates an array in the correct format for returning the list of
+ // parameters. This is used by the 'list' option of the 'physics' command.
private void BuildParameterTable()
{
if (SettableParameters.Length < ParameterDefinitions.Length)
@@ -1283,7 +1312,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
TaintedObject("BSScene.UpdateParameterSet", delegate() {
foreach (uint lID in objectIDs)
{
- BulletSimAPI.UpdateParameter(m_worldID, lID, xparm, xval);
+ BulletSimAPI.UpdateParameter(WorldID, lID, xparm, xval);
}
});
break;
@@ -1301,7 +1330,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
string xparm = parm.ToLower();
float xval = val;
TaintedObject("BSScene.TaintedUpdateParameter", delegate() {
- BulletSimAPI.UpdateParameter(m_worldID, xlocalID, xparm, xval);
+ BulletSimAPI.UpdateParameter(WorldID, xlocalID, xparm, xval);
});
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
new file mode 100755
index 0000000..28c1940
--- /dev/null
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyrightD
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using OpenSim.Framework;
+using OpenSim.Region.Framework;
+using OpenSim.Region.CoreModules;
+using OpenSim.Region.Physics.Manager;
+
+using Nini.Config;
+using log4net;
+
+using OpenMetaverse;
+
+namespace OpenSim.Region.Physics.BulletSPlugin
+{
+public class BSTerrainManager
+{
+ static string LogHeader = "[BULLETSIM TERRAIN MANAGER]";
+
+ BSScene m_physicsScene;
+
+ private BulletBody m_groundPlane;
+
+ // If doing mega-regions, if we're region zero we will be managing multiple
+ // region terrains since region zero does the physics for the whole mega-region.
+ private Dictionary m_terrains;
+ private Dictionary m_heightMaps;
+
+ // If we are doing mega-regions, terrains are added from TERRAIN_ID to m_terrainCount.
+ // This is incremented before assigning to new region so it is the last ID allocated.
+ private uint m_terrainCount = BSScene.CHILDTERRAIN_ID - 1;
+ public uint HighestTerrainID { get {return m_terrainCount; } }
+
+ // If doing mega-regions, this holds our offset from region zero of
+ // the mega-regions. "parentScene" points to the PhysicsScene of region zero.
+ private Vector3 m_worldOffset = Vector3.Zero;
+ public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
+ private PhysicsScene m_parentScene = null;
+
+ public BSTerrainManager(BSScene physicsScene)
+ {
+ m_physicsScene = physicsScene;
+ m_terrains = new Dictionary();
+ m_heightMaps = new Dictionary();
+ }
+
+ // Create the initial instance of terrain and the underlying ground plane.
+ // The objects are allocated in the unmanaged space and the pointers are tracked
+ // by the managed code.
+ // The terrains and the groundPlane are not added to the list of PhysObjects.
+ // This is called from the initialization routine so we presume it is
+ // safe to call Bullet in real time. We hope no one is moving around prim yet.
+ public void CreateInitialGroundPlaneAndTerrain()
+ {
+ // The ground plane is here to catch things that are trying to drop to negative infinity
+ m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID,
+ BulletSimAPI.CreateGroundPlaneBody2(BSScene.GROUNDPLANE_ID, 1f, 0.4f));
+ BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr);
+
+ Vector3 minTerrainCoords = new Vector3(0f, 0f, 24f);
+ Vector3 maxTerrainCoords = new Vector3(Constants.RegionSize, Constants.RegionSize, 25f);
+ int totalHeights = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y;
+ float[] initialMap = new float[totalHeights];
+ for (int ii = 0; ii < totalHeights; ii++)
+ {
+ initialMap[ii] = 25f;
+ }
+ CreateNewTerrainSegment(BSScene.TERRAIN_ID, initialMap, minTerrainCoords, maxTerrainCoords);
+ }
+
+ public void ReleaseGroundPlaneAndTerrain()
+ {
+ if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr))
+ {
+ BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, m_groundPlane.Ptr);
+ }
+ m_groundPlane.Ptr = IntPtr.Zero;
+
+ foreach (KeyValuePair kvp in m_terrains)
+ {
+ if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, kvp.Value.Ptr))
+ {
+ BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, kvp.Value.Ptr);
+ BulletSimAPI.ReleaseHeightmapInfo2(m_heightMaps[kvp.Key].Ptr);
+ }
+ }
+ m_terrains.Clear();
+ m_heightMaps.Clear();
+ }
+
+ // Create a new terrain description. This is used for mega-regions where
+ // the children of region zero give region zero all of the terrain
+ // segments since region zero does all the physics for the mega-region.
+ // Call at taint time!!
+ public void CreateNewTerrainSegment(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords)
+ {
+ // The Z coordinates are recalculated to be the min and max height of the terrain
+ // itself. The caller may have passed us the real region extent.
+ float minZ = float.MaxValue;
+ float maxZ = float.MinValue;
+ int hSize = heightMap.Length;
+ for (int ii = 0; ii < hSize; ii++)
+ {
+ minZ = heightMap[ii] < minZ ? heightMap[ii] : minZ;
+ maxZ = heightMap[ii] > maxZ ? heightMap[ii] : maxZ;
+ }
+ minCoords.Z = minZ;
+ maxCoords.Z = maxZ;
+ // If the terrain is flat, make a difference so we get a good bounding box
+ if (minZ == maxZ)
+ minZ -= 0.2f;
+ Vector2 terrainRegionBase = new Vector2(minCoords.X, minCoords.Y);
+
+ // Create the heightmap data structure in the unmanaged space
+ BulletHeightMapInfo mapInfo = new BulletHeightMapInfo(
+ BulletSimAPI.CreateHeightmap2(minCoords, maxCoords, heightMap), heightMap);
+ mapInfo.terrainRegionBase = terrainRegionBase;
+ mapInfo.maxRegionExtent = maxCoords;
+ mapInfo.minZ = minZ;
+ mapInfo.maxZ = maxZ;
+ mapInfo.sizeX = maxCoords.X - minCoords.X;
+ mapInfo.sizeY = maxCoords.Y - minCoords.Y;
+
+ DetailLog("{0},BSScene.CreateNewTerrainSegment,call,minZ={1},maxZ={2},hMapPtr={3},minC={4},maxC={5}",
+ BSScene.DetailLogZero, minZ, maxZ, mapInfo.Ptr, minCoords, maxCoords);
+ // Create the terrain body from that heightmap
+ BulletBody terrainBody = new BulletBody(id, BulletSimAPI.CreateTerrainBody2(id, mapInfo.Ptr, 0.01f));
+
+ BulletSimAPI.SetFriction2(terrainBody.Ptr, m_physicsScene.Params.terrainFriction);
+ BulletSimAPI.SetHitFraction2(terrainBody.Ptr, m_physicsScene.Params.terrainHitFraction);
+ BulletSimAPI.SetRestitution2(terrainBody.Ptr, m_physicsScene.Params.terrainRestitution);
+ BulletSimAPI.SetCollisionFlags2(terrainBody.Ptr, CollisionFlags.CF_STATIC_OBJECT);
+ BulletSimAPI.Activate2(terrainBody.Ptr, true);
+
+ // Add the new terrain to the dynamics world
+ BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, terrainBody.Ptr);
+ BulletSimAPI.UpdateSingleAabb2(m_physicsScene.World.Ptr, terrainBody.Ptr);
+
+
+ // Add the created terrain to the management set. If we are doing mega-regions,
+ // the terrains of our children will be added.
+ m_terrains.Add(terrainRegionBase, terrainBody);
+ m_heightMaps.Add(terrainRegionBase, mapInfo);
+ }
+
+ public void SetTerrain(float[] heightMap) {
+ if (m_worldOffset != Vector3.Zero && m_parentScene != null)
+ {
+ // If doing the mega-prim stuff and we are the child of the zero region,
+ // the terrain is really added to our parent
+ if (m_parentScene is BSScene)
+ {
+ ((BSScene)m_parentScene).TerrainManager.SetTerrain(heightMap, m_worldOffset);
+ }
+ }
+ else
+ {
+ // if not doing the mega-prim thing, just change the terrain
+ SetTerrain(heightMap, m_worldOffset);
+ }
+ }
+
+ private void SetTerrain(float[] heightMap, Vector3 tOffset)
+ {
+ float minZ = float.MaxValue;
+ float maxZ = float.MinValue;
+
+ // Copy heightMap local and compute some statistics.
+ // Not really sure if we need to do this deep copy but, given
+ // the magic that happens to make the closure for taint
+ // below, I don't want there to be any problem with sharing
+ // locations of there are multiple calls to this routine
+ // within one tick.
+ int heightMapSize = heightMap.Length;
+ float[] localHeightMap = new float[heightMapSize];
+ for (int ii = 0; ii < heightMapSize; ii++)
+ {
+ float height = heightMap[ii];
+ if (height < minZ) minZ = height;
+ if (height > maxZ) maxZ = height;
+ localHeightMap[ii] = height;
+ }
+
+ Vector2 terrainRegionBase = new Vector2(tOffset.X, tOffset.Y);
+ BulletHeightMapInfo mapInfo;
+ if (m_heightMaps.TryGetValue(terrainRegionBase, out mapInfo))
+ {
+ // If this is terrain we know about, it's easy to update
+ mapInfo.heightMap = localHeightMap;
+ m_physicsScene.TaintedObject("BSScene.SetTerrain:UpdateExisting", delegate()
+ {
+ DetailLog("{0},SetTerrain:UpdateExisting,baseX={1},baseY={2},minZ={3},maxZ={4}",
+ BSScene.DetailLogZero, tOffset.X, tOffset.Y, minZ, maxZ);
+ BulletSimAPI.UpdateHeightMap2(m_physicsScene.World.Ptr, mapInfo.Ptr, mapInfo.heightMap);
+ });
+ }
+ else
+ {
+ // Our mega-prim child is giving us a new terrain to add to the phys world
+ uint newTerrainID = ++m_terrainCount;
+
+ Vector3 minCoords = tOffset;
+ minCoords.Z = minZ;
+ Vector3 maxCoords = new Vector3(tOffset.X + Constants.RegionSize,
+ tOffset.Y + Constants.RegionSize,
+ maxZ);
+ m_physicsScene.TaintedObject("BSScene.SetTerrain:NewTerrain", delegate()
+ {
+ DetailLog("{0},SetTerrain:NewTerrain,baseX={1},baseY={2}", BSScene.DetailLogZero, tOffset.X, tOffset.Y);
+ CreateNewTerrainSegment(newTerrainID, heightMap, minCoords, maxCoords);
+ });
+ }
+ }
+
+ // Someday we will have complex terrain with caves and tunnels
+ // For the moment, it's flat and convex
+ public float GetTerrainHeightAtXYZ(Vector3 loc)
+ {
+ return GetTerrainHeightAtXY(loc.X, loc.Y);
+ }
+
+ // Given an X and Y, find the height of the terrain.
+ // Since we could be handling multiple terrains for a mega-region,
+ // the base of the region is calcuated assuming all regions are
+ // the same size and that is the default.
+ // Once the heightMapInfo is found, we have all the information to
+ // compute the offset into the array.
+ public float GetTerrainHeightAtXY(float tX, float tY)
+ {
+ float ret = 30f;
+
+ int offsetX = ((int)(tX / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
+ int offsetY = ((int)(tY / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
+ Vector2 terrainBaseXY = new Vector2(offsetX, offsetY);
+
+ BulletHeightMapInfo mapInfo;
+ if (m_heightMaps.TryGetValue(terrainBaseXY, out mapInfo))
+ {
+ float regionX = tX - offsetX;
+ float regionY = tY - offsetY;
+ regionX = regionX > mapInfo.sizeX ? 0 : regionX;
+ regionY = regionY > mapInfo.sizeY ? 0 : regionY;
+ ret = mapInfo.heightMap[(int)(regionX * mapInfo.sizeX + regionY)];
+ }
+ else
+ {
+ m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: x={1}, y={2}",
+ LogHeader, tX, tY);
+ }
+ return ret;
+ }
+
+ // Although no one seems to check this, I do support combining.
+ public bool SupportsCombining()
+ {
+ return true;
+ }
+ // This call says I am a child to region zero in a mega-region. 'pScene' is that
+ // of region zero, 'offset' is my offset from regions zero's origin, and
+ // 'extents' is the largest XY that is handled in my region.
+ public void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
+ {
+ m_worldOffset = offset;
+ WorldExtents = new Vector2(extents.X, extents.Y);
+ m_parentScene = pScene;
+ }
+
+ // Unhook all the combining that I know about.
+ public void UnCombine(PhysicsScene pScene)
+ {
+ // Just like ODE, for the moment a NOP
+ }
+
+
+ private void DetailLog(string msg, params Object[] args)
+ {
+ m_physicsScene.PhysicsLogging.Write(msg, args);
+ }
+}
+}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index dab2420..3b319fb 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -33,6 +33,9 @@ using OpenMetaverse;
namespace OpenSim.Region.Physics.BulletSPlugin {
// Classes to allow some type checking for the API
+// These hold pointers to allocated objects in the unmanaged space.
+
+// The physics engine controller class created at initialization
public struct BulletSim
{
public BulletSim(uint id, BSScene bss, IntPtr xx) { ID = id; scene = bss; Ptr = xx; }
@@ -42,6 +45,7 @@ public struct BulletSim
public IntPtr Ptr;
}
+// An allocated Bullet btRigidBody
public struct BulletBody
{
public BulletBody(uint id, IntPtr xx) { ID = id; Ptr = xx; }
@@ -49,12 +53,35 @@ public struct BulletBody
public uint ID;
}
+// An allocated Bullet btConstraint
public struct BulletConstraint
{
public BulletConstraint(IntPtr xx) { Ptr = xx; }
public IntPtr Ptr;
}
+// An allocated HeightMapThing which hold various heightmap info
+// Made a class rather than a struct so there would be only one
+// instance of this and C# will pass around pointers rather
+// than making copies.
+public class BulletHeightMapInfo
+{
+ public BulletHeightMapInfo(IntPtr xx, float[] hm) {
+ Ptr = xx;
+ heightMap = hm;
+ terrainRegionBase = new Vector2(0f, 0f);
+ maxRegionExtent = new Vector3(100f, 100f, 25f);
+ minZ = maxZ = 0f;
+ sizeX = sizeY = 256f;
+ }
+ public IntPtr Ptr;
+ public float[] heightMap;
+ public Vector2 terrainRegionBase;
+ public Vector3 maxRegionExtent;
+ public float sizeX, sizeY;
+ public float minZ, maxZ;
+}
+
// ===============================================================================
[StructLayout(LayoutKind.Sequential)]
public struct ConvexHull
@@ -231,6 +258,9 @@ public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
int maxUpdates, IntPtr updateArray);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern void CreateInitialGroundPlaneAndTerrain(uint worldID);
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -414,12 +444,23 @@ public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateGroundPlaneBody2(uint id, Vector3 center, float collisionMargin);
+public static extern IntPtr CreateGroundPlaneBody2(uint id, float height, float collisionMargin);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern IntPtr CreateTerrainBody2(uint id,
- Vector3 minCoords, Vector3 maxCoords, float collisionMargin,
- [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
+ IntPtr heightMapInfo,
+ float collisionMargin);
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern IntPtr CreateHeightmap2(Vector3 minCoords, Vector3 maxCoords,
+ [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern bool ReleaseHeightmapInfo2(IntPtr heightMapInfo);
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern void UpdateHeightMap2(IntPtr world, IntPtr heightMapInfo,
+ [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -473,11 +514,16 @@ public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain);
+// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 AddObjectToWorld2(IntPtr world, IntPtr obj);
+public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
+public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
+
+// =====================================================================================
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern void Activate2(IntPtr obj, bool forceActivation);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern Vector3 GetPosition2(IntPtr obj);
@@ -522,6 +568,9 @@ public static extern bool SetContactProcessingThreshold2(IntPtr obj, float val);
public static extern bool SetFriction2(IntPtr obj, float val);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern bool SetHitFraction2(IntPtr obj, float val);
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool SetRestitution2(IntPtr obj, float val);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -564,7 +613,7 @@ public static extern bool SetMargin2(IntPtr obj, float val);
public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool DestroyObject2(IntPtr world, uint id);
+public static extern bool DestroyObject2(IntPtr world, IntPtr obj);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern void DumpPhysicsStatistics2(IntPtr sim);
--
cgit v1.1
From d3adf9b2b3bd8e0e76168cd6eb6414f3123c5f02 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Sat, 25 Aug 2012 23:25:29 -0700
Subject: BulletSim: fix line endings.
---
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 44 ++++++++++++-------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index f80304d..7b4802e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -102,7 +102,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public uint WorldID { get; private set; }
public BulletSim World { get; private set; }
- // All the constraints that have been allocated in this instance.
+ // All the constraints that have been allocated in this instance.
public BSConstraintCollection Constraints { get; private set; }
// Simulation parameters
@@ -117,7 +117,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public float LastSimulatedTimestep { get; private set; }
// A value of the time now so all the collision and update routines do not have to get their own
- // Set to 'now' just before all the prims and actors are called for collisions and updates
+ // Set to 'now' just before all the prims and actors are called for collisions and updates
public int SimulationNowTime { get; private set; }
// True if initialized and ready to do simulation steps
@@ -140,8 +140,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero
public const uint GROUNDPLANE_ID = 1;
- public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here
-
+ public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here
+
private float m_waterLevel;
public BSTerrainManager TerrainManager { get; private set; }
@@ -189,8 +189,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
private bool m_physicsLoggingEnabled;
private string m_physicsLoggingDir;
private string m_physicsLoggingPrefix;
- private int m_physicsLoggingFileMinutes;
- // 'true' of the vehicle code is to log lots of details
+ private int m_physicsLoggingFileMinutes;
+ // 'true' of the vehicle code is to log lots of details
public bool VehicleLoggingEnabled { get; private set; }
#region Construction and Initialization
@@ -266,7 +266,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
Constraints = new BSConstraintCollection(World);
// Note: choose one of the two following lines
- // BulletSimAPI.CreateInitialGroundPlaneAndTerrain(WorldID);
+ // BulletSimAPI.CreateInitialGroundPlaneAndTerrain(WorldID);
TerrainManager = new BSTerrainManager(this);
TerrainManager.CreateInitialGroundPlaneAndTerrain();
@@ -471,7 +471,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
int simulateStartTime = Util.EnvironmentTickCount();
- // update the prim states while we know the physics engine is not busy
+ // update the prim states while we know the physics engine is not busy
int numTaints = _taintedObjects.Count;
ProcessTaints();
@@ -611,7 +611,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
#region Terrain
- public override void SetTerrain(float[] heightMap) {
+ public override void SetTerrain(float[] heightMap) {
TerrainManager.SetTerrain(heightMap);
}
@@ -628,25 +628,25 @@ public class BSScene : PhysicsScene, IPhysicsParameters
public override void DeleteTerrain()
{
// m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
- }
-
- // Although no one seems to check this, I do support combining.
- public override bool SupportsCombining()
- {
- return TerrainManager.SupportsCombining();
+ }
+
+ // Although no one seems to check this, I do support combining.
+ public override bool SupportsCombining()
+ {
+ return TerrainManager.SupportsCombining();
}
// This call says I am a child to region zero in a mega-region. 'pScene' is that
// of region zero, 'offset' is my offset from regions zero's origin, and
// 'extents' is the largest XY that is handled in my region.
public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
- {
+ {
TerrainManager.Combine(pScene, offset, extents);
- }
-
- // Unhook all the combining that I know about.
- public override void UnCombine(PhysicsScene pScene)
- {
- TerrainManager.UnCombine(pScene);
+ }
+
+ // Unhook all the combining that I know about.
+ public override void UnCombine(PhysicsScene pScene)
+ {
+ TerrainManager.UnCombine(pScene);
}
#endregion // Terrain
--
cgit v1.1
From ae852bb8738c7bce60c8fee9fbf6038288bd9363 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 29 Aug 2012 09:20:09 -0700
Subject: BulletSim: clean up some variable naming for consistancy. Update DLL
API for new terrain and shape/body pattern methods. Terrain creation and
modification uses new shape/body pattern. Move debug logging callback set to
initialization call so logging is per physics engine.
---
.../Region/Physics/BulletSPlugin/BSCharacter.cs | 78 ++++++------
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 13 +-
.../Physics/BulletSPlugin/BSTerrainManager.cs | 139 +++++++++++++++------
.../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 55 +++++---
4 files changed, 183 insertions(+), 102 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index e76d8a4..fa21233 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -39,8 +39,7 @@ public class BSCharacter : BSPhysObject
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[BULLETS CHAR]";
- private BSScene _scene;
- public BSScene Scene { get { return _scene; } }
+ public BSScene Scene { get; private set; }
private String _avName;
// private bool _stopped;
private Vector3 _size;
@@ -92,7 +91,7 @@ public class BSCharacter : BSPhysObject
{
_localID = localID;
_avName = avName;
- _scene = parent_scene;
+ Scene = parent_scene;
_position = pos;
_size = size;
_flying = isFlying;
@@ -101,11 +100,11 @@ public class BSCharacter : BSPhysObject
_buoyancy = ComputeBuoyancyFromFlying(isFlying);
// The dimensions of the avatar capsule are kept in the scale.
// Physics creates a unit capsule which is scaled by the physics engine.
- _scale = new Vector3(_scene.Params.avatarCapsuleRadius, _scene.Params.avatarCapsuleRadius, size.Z);
- _density = _scene.Params.avatarDensity;
+ _scale = new Vector3(Scene.Params.avatarCapsuleRadius, Scene.Params.avatarCapsuleRadius, size.Z);
+ _density = Scene.Params.avatarDensity;
ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale
- Linkset = new BSLinkset(_scene, this);
+ Linkset = new BSLinkset(Scene, this);
ShapeData shapeData = new ShapeData();
shapeData.ID = _localID;
@@ -117,19 +116,19 @@ public class BSCharacter : BSPhysObject
shapeData.Mass = _mass;
shapeData.Buoyancy = _buoyancy;
shapeData.Static = ShapeData.numericFalse;
- shapeData.Friction = _scene.Params.avatarFriction;
- shapeData.Restitution = _scene.Params.avatarRestitution;
+ shapeData.Friction = Scene.Params.avatarFriction;
+ shapeData.Restitution = Scene.Params.avatarRestitution;
// do actual create at taint time
- _scene.TaintedObject("BSCharacter.create", delegate()
+ Scene.TaintedObject("BSCharacter.create", delegate()
{
DetailLog("{0},BSCharacter.create", _localID);
- BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
+ BulletSimAPI.CreateObject(Scene.WorldID, shapeData);
// Set the buoyancy for flying. This will be refactored when all the settings happen in C#
- BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
+ BulletSimAPI.SetObjectBuoyancy(Scene.WorldID, LocalID, _buoyancy);
- Body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID));
+ Body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(Scene.World.Ptr, LocalID));
// avatars get all collisions no matter what (makes walking on ground and such work)
BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
});
@@ -141,9 +140,9 @@ public class BSCharacter : BSPhysObject
public override void Destroy()
{
DetailLog("{0},BSCharacter.Destroy", LocalID);
- _scene.TaintedObject("BSCharacter.destroy", delegate()
+ Scene.TaintedObject("BSCharacter.destroy", delegate()
{
- BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
+ BulletSimAPI.DestroyObject(Scene.WorldID, _localID);
});
}
@@ -172,9 +171,9 @@ public class BSCharacter : BSPhysObject
ComputeAvatarVolumeAndMass();
- _scene.TaintedObject("BSCharacter.setSize", delegate()
+ Scene.TaintedObject("BSCharacter.setSize", delegate()
{
- BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true);
+ BulletSimAPI.SetObjectScaleMass(Scene.WorldID, LocalID, _scale, _mass, true);
});
}
@@ -203,17 +202,17 @@ public class BSCharacter : BSPhysObject
public override Vector3 Position {
get {
- // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
+ // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID);
return _position;
}
set {
_position = value;
PositionSanityCheck();
- _scene.TaintedObject("BSCharacter.setPosition", delegate()
+ Scene.TaintedObject("BSCharacter.setPosition", delegate()
{
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
- BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
+ BulletSimAPI.SetObjectTranslation(Scene.WorldID, _localID, _position, _orientation);
});
}
}
@@ -229,10 +228,8 @@ public class BSCharacter : BSPhysObject
float terrainHeight = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position);
if (Position.Z < terrainHeight)
{
- DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
- Vector3 newPos = _position;
- newPos.Z = terrainHeight + 2.0f;
- _position = newPos;
+ DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
+ _position.Z = terrainHeight + 2.0f;
ret = true;
}
@@ -250,10 +247,10 @@ public class BSCharacter : BSPhysObject
{
// The new position value must be pushed into the physics engine but we can't
// just assign to "Position" because of potential call loops.
- _scene.TaintedObject("BSCharacter.PositionSanityCheck", delegate()
+ Scene.TaintedObject("BSCharacter.PositionSanityCheck", delegate()
{
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
- BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
+ BulletSimAPI.SetObjectTranslation(Scene.WorldID, _localID, _position, _orientation);
});
ret = true;
}
@@ -301,10 +298,10 @@ public class BSCharacter : BSPhysObject
set {
_velocity = value;
// m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity);
- _scene.TaintedObject("BSCharacter.setVelocity", delegate()
+ Scene.TaintedObject("BSCharacter.setVelocity", delegate()
{
DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity);
- BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity);
+ BulletSimAPI.SetObjectVelocity(Scene.WorldID, _localID, _velocity);
});
}
}
@@ -327,10 +324,10 @@ public class BSCharacter : BSPhysObject
set {
_orientation = value;
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
- _scene.TaintedObject("BSCharacter.setOrientation", delegate()
+ Scene.TaintedObject("BSCharacter.setOrientation", delegate()
{
- // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
- BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
+ // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID);
+ BulletSimAPI.SetObjectTranslation(Scene.WorldID, _localID, _position, _orientation);
});
}
}
@@ -367,11 +364,11 @@ public class BSCharacter : BSPhysObject
set { _throttleUpdates = value; }
}
public override bool IsColliding {
- get { return (_collidingStep == _scene.SimulationStep); }
+ get { return (_collidingStep == Scene.SimulationStep); }
set { _isColliding = value; }
}
public override bool CollidingGround {
- get { return (_collidingGroundStep == _scene.SimulationStep); }
+ get { return (_collidingGroundStep == Scene.SimulationStep); }
set { _collidingGround = value; }
}
public override bool CollidingObj {
@@ -393,10 +390,10 @@ public class BSCharacter : BSPhysObject
public override float Buoyancy {
get { return _buoyancy; }
set { _buoyancy = value;
- _scene.TaintedObject("BSCharacter.setBuoyancy", delegate()
+ Scene.TaintedObject("BSCharacter.setBuoyancy", delegate()
{
DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
- BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
+ BulletSimAPI.SetObjectBuoyancy(Scene.WorldID, LocalID, _buoyancy);
});
}
}
@@ -440,7 +437,7 @@ public class BSCharacter : BSPhysObject
_force.Y += force.Y;
_force.Z += force.Z;
// m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force);
- _scene.TaintedObject("BSCharacter.AddForce", delegate()
+ Scene.TaintedObject("BSCharacter.AddForce", delegate()
{
DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force);
BulletSimAPI.AddObjectForce2(Body.Ptr, _force);
@@ -524,10 +521,9 @@ public class BSCharacter : BSPhysObject
// Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
PositionSanityCheck2();
- float heightHere = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position); // just for debug
+ float heightHere = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position); // only for debug
DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5},terrain={6}",
- LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
- entprop.Acceleration, entprop.RotationalVelocity, heightHere);
+ LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity, heightHere);
}
// Called by the scene when a collision with this object is reported
@@ -539,16 +535,16 @@ public class BSCharacter : BSPhysObject
// m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
// The following makes IsColliding() and IsCollidingGround() work
- _collidingStep = _scene.SimulationStep;
+ _collidingStep = Scene.SimulationStep;
if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID)
{
- _collidingGroundStep = _scene.SimulationStep;
+ _collidingGroundStep = Scene.SimulationStep;
}
// DetailLog("{0},BSCharacter.Collison,call,with={1}", LocalID, collidingWith);
// throttle collisions to the rate specified in the subscription
if (_subscribedEventsMs != 0) {
- int nowTime = _scene.SimulationNowTime;
+ int nowTime = Scene.SimulationNowTime;
if (nowTime >= _nextCollisionOkTime) {
_nextCollisionOkTime = nowTime + _subscribedEventsMs;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 7b4802e..2f55ba4 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -232,15 +232,15 @@ public class BSScene : PhysicsScene, IPhysicsParameters
}
// If Debug logging level, enable logging from the unmanaged code
+ m_DebugLogCallbackHandle = null;
if (m_log.IsDebugEnabled || PhysicsLogging.Enabled)
{
m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader);
if (PhysicsLogging.Enabled)
+ // The handle is saved in a variable to make sure it doesn't get freed after this call
m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog);
else
m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger);
- // The handle is saved in a variable to make sure it doesn't get freed after this call
- BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle);
}
// Get the version of the DLL
@@ -257,7 +257,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader);
WorldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(),
m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(),
- m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject());
+ m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject(),
+ m_DebugLogCallbackHandle);
// Initialization to support the transition to a new API which puts most of the logic
// into the C# code so it is easier to modify and add to.
@@ -265,8 +266,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters
Constraints = new BSConstraintCollection(World);
- // Note: choose one of the two following lines
- // BulletSimAPI.CreateInitialGroundPlaneAndTerrain(WorldID);
TerrainManager = new BSTerrainManager(this);
TerrainManager.CreateInitialGroundPlaneAndTerrain();
@@ -378,7 +377,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
lock (PhysObjects) PhysObjects.Add(localID, actor);
- // Remove kludge someday
+ // TODO: Remove kludge someday.
+ // We must generate a collision for avatars whether they collide or not.
+ // This is required by OpenSim to update avatar animations, etc.
lock (m_avatarsWithCollisions) m_avatarsWithCollisions.Add(actor);
return actor;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index 28c1940..733d9c2 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -44,8 +44,22 @@ public class BSTerrainManager
{
static string LogHeader = "[BULLETSIM TERRAIN MANAGER]";
+ // These height values are fractional so the odd values will be
+ // noticable when debugging.
+ public const float HEIGHT_INITIALIZATION = 24.987f;
+ public const float HEIGHT_INITIAL_LASTHEIGHT = 24.876f;
+ public const float HEIGHT_GETHEIGHT_RET = 24.765f;
+
+ // If the min and max height are equal, we reduce the min by this
+ // amount to make sure that a bounding box is built for the terrain.
+ public const float HEIGHT_EQUAL_FUDGE = 0.2f;
+
+ public const float TERRAIN_COLLISION_MARGIN = 0.2f;
+
+ // The scene that I am part of
BSScene m_physicsScene;
+ // The ground plane created to keep thing from falling to infinity.
private BulletBody m_groundPlane;
// If doing mega-regions, if we're region zero we will be managing multiple
@@ -53,6 +67,10 @@ public class BSTerrainManager
private Dictionary m_terrains;
private Dictionary m_heightMaps;
+ // True of the terrain has been modified.
+ // Used to force recalculation of terrain height after terrain has been modified
+ private bool m_terrainModified;
+
// If we are doing mega-regions, terrains are added from TERRAIN_ID to m_terrainCount.
// This is incremented before assigning to new region so it is the last ID allocated.
private uint m_terrainCount = BSScene.CHILDTERRAIN_ID - 1;
@@ -69,6 +87,7 @@ public class BSTerrainManager
m_physicsScene = physicsScene;
m_terrains = new Dictionary();
m_heightMaps = new Dictionary();
+ m_terrainModified = false;
}
// Create the initial instance of terrain and the underlying ground plane.
@@ -80,17 +99,18 @@ public class BSTerrainManager
public void CreateInitialGroundPlaneAndTerrain()
{
// The ground plane is here to catch things that are trying to drop to negative infinity
+ BulletShape groundPlaneShape = new BulletShape(BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN));
m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID,
- BulletSimAPI.CreateGroundPlaneBody2(BSScene.GROUNDPLANE_ID, 1f, 0.4f));
+ BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.Ptr, Vector3.Zero, Quaternion.Identity));
BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr);
- Vector3 minTerrainCoords = new Vector3(0f, 0f, 24f);
- Vector3 maxTerrainCoords = new Vector3(Constants.RegionSize, Constants.RegionSize, 25f);
+ Vector3 minTerrainCoords = new Vector3(0f, 0f, HEIGHT_INITIALIZATION - HEIGHT_EQUAL_FUDGE);
+ Vector3 maxTerrainCoords = new Vector3(Constants.RegionSize, Constants.RegionSize, HEIGHT_INITIALIZATION);
int totalHeights = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y;
float[] initialMap = new float[totalHeights];
for (int ii = 0; ii < totalHeights; ii++)
{
- initialMap[ii] = 25f;
+ initialMap[ii] = HEIGHT_INITIALIZATION;
}
CreateNewTerrainSegment(BSScene.TERRAIN_ID, initialMap, minTerrainCoords, maxTerrainCoords);
}
@@ -108,7 +128,7 @@ public class BSTerrainManager
if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, kvp.Value.Ptr))
{
BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, kvp.Value.Ptr);
- BulletSimAPI.ReleaseHeightmapInfo2(m_heightMaps[kvp.Key].Ptr);
+ BulletSimAPI.ReleaseHeightMapInfo2(m_heightMaps[kvp.Key].Ptr);
}
}
m_terrains.Clear();
@@ -128,30 +148,41 @@ public class BSTerrainManager
int hSize = heightMap.Length;
for (int ii = 0; ii < hSize; ii++)
{
- minZ = heightMap[ii] < minZ ? heightMap[ii] : minZ;
- maxZ = heightMap[ii] > maxZ ? heightMap[ii] : maxZ;
+ float height = heightMap[ii];
+ if (height < minZ) minZ = height;
+ if (height > maxZ) maxZ = height;
}
+ // If the terrain is flat, make a difference so we get a bounding box
+ if (minZ == maxZ)
+ minZ -= HEIGHT_EQUAL_FUDGE;
+
minCoords.Z = minZ;
maxCoords.Z = maxZ;
- // If the terrain is flat, make a difference so we get a good bounding box
- if (minZ == maxZ)
- minZ -= 0.2f;
Vector2 terrainRegionBase = new Vector2(minCoords.X, minCoords.Y);
// Create the heightmap data structure in the unmanaged space
- BulletHeightMapInfo mapInfo = new BulletHeightMapInfo(
- BulletSimAPI.CreateHeightmap2(minCoords, maxCoords, heightMap), heightMap);
+ BulletHeightMapInfo mapInfo = new BulletHeightMapInfo(id, heightMap,
+ BulletSimAPI.CreateHeightMapInfo2(id, minCoords, maxCoords, heightMap, TERRAIN_COLLISION_MARGIN));
mapInfo.terrainRegionBase = terrainRegionBase;
- mapInfo.maxRegionExtent = maxCoords;
+ mapInfo.minCoords = minCoords;
+ mapInfo.maxCoords = maxCoords;
mapInfo.minZ = minZ;
mapInfo.maxZ = maxZ;
mapInfo.sizeX = maxCoords.X - minCoords.X;
mapInfo.sizeY = maxCoords.Y - minCoords.Y;
+ Vector3 centerPos;
+ centerPos.X = minCoords.X + (mapInfo.sizeX / 2f);
+ centerPos.Y = minCoords.Y + (mapInfo.sizeY / 2f);
+ centerPos.Z = minZ + (maxZ - minZ) / 2f;
+
DetailLog("{0},BSScene.CreateNewTerrainSegment,call,minZ={1},maxZ={2},hMapPtr={3},minC={4},maxC={5}",
BSScene.DetailLogZero, minZ, maxZ, mapInfo.Ptr, minCoords, maxCoords);
- // Create the terrain body from that heightmap
- BulletBody terrainBody = new BulletBody(id, BulletSimAPI.CreateTerrainBody2(id, mapInfo.Ptr, 0.01f));
+ // Create the terrain shape from the mapInfo
+ BulletShape terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr));
+
+ BulletBody terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2(terrainShape.Ptr,
+ centerPos, Quaternion.Identity));
BulletSimAPI.SetFriction2(terrainBody.Ptr, m_physicsScene.Params.terrainFriction);
BulletSimAPI.SetHitFraction2(terrainBody.Ptr, m_physicsScene.Params.terrainHitFraction);
@@ -163,11 +194,12 @@ public class BSTerrainManager
BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, terrainBody.Ptr);
BulletSimAPI.UpdateSingleAabb2(m_physicsScene.World.Ptr, terrainBody.Ptr);
-
// Add the created terrain to the management set. If we are doing mega-regions,
// the terrains of our children will be added.
m_terrains.Add(terrainRegionBase, terrainBody);
m_heightMaps.Add(terrainRegionBase, mapInfo);
+
+ m_terrainModified = true;
}
public void SetTerrain(float[] heightMap) {
@@ -191,34 +223,57 @@ public class BSTerrainManager
{
float minZ = float.MaxValue;
float maxZ = float.MinValue;
+ Vector2 terrainRegionBase = new Vector2(tOffset.X, tOffset.Y);
- // Copy heightMap local and compute some statistics.
- // Not really sure if we need to do this deep copy but, given
- // the magic that happens to make the closure for taint
- // below, I don't want there to be any problem with sharing
- // locations of there are multiple calls to this routine
- // within one tick.
int heightMapSize = heightMap.Length;
- float[] localHeightMap = new float[heightMapSize];
for (int ii = 0; ii < heightMapSize; ii++)
{
float height = heightMap[ii];
if (height < minZ) minZ = height;
if (height > maxZ) maxZ = height;
- localHeightMap[ii] = height;
}
- Vector2 terrainRegionBase = new Vector2(tOffset.X, tOffset.Y);
+ // The shape of the terrain is from its base to its extents.
+ Vector3 minCoords, maxCoords;
+ minCoords = tOffset;
+ minCoords.Z = minZ;
+ maxCoords = tOffset;
+ maxCoords.X += Constants.RegionSize;
+ maxCoords.Y += Constants.RegionSize;
+ maxCoords.Z = maxZ;
+
+ BulletBody terrainBody;
BulletHeightMapInfo mapInfo;
if (m_heightMaps.TryGetValue(terrainRegionBase, out mapInfo))
{
+ terrainBody = m_terrains[terrainRegionBase];
+ // Copy heightMap local and compute some statistics.
+ for (int ii = 0; ii < heightMapSize; ii++)
+ {
+ mapInfo.heightMap[ii] = heightMap[ii];
+ }
+
// If this is terrain we know about, it's easy to update
- mapInfo.heightMap = localHeightMap;
m_physicsScene.TaintedObject("BSScene.SetTerrain:UpdateExisting", delegate()
{
DetailLog("{0},SetTerrain:UpdateExisting,baseX={1},baseY={2},minZ={3},maxZ={4}",
BSScene.DetailLogZero, tOffset.X, tOffset.Y, minZ, maxZ);
- BulletSimAPI.UpdateHeightMap2(m_physicsScene.World.Ptr, mapInfo.Ptr, mapInfo.heightMap);
+ // Fill the existing height map info with the new location and size information
+ BulletSimAPI.FillHeightMapInfo2(mapInfo.Ptr, mapInfo.ID, minCoords, maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN);
+
+ // Create a terrain shape based on the new info
+ BulletShape terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr));
+
+ // Swap the shape in the terrain body (this also deletes the old shape)
+ bool success = BulletSimAPI.ReplaceBodyShape2(m_physicsScene.World.Ptr, terrainBody.Ptr, terrainShape.Ptr);
+
+ if (!success)
+ {
+ DetailLog("{0},SetTerrain:UpdateExisting,Failed", BSScene.DetailLogZero);
+ m_physicsScene.Logger.ErrorFormat("{0} Failed updating terrain heightmap. Region={1}",
+ LogHeader, m_physicsScene.RegionName);
+
+ }
});
}
else
@@ -226,11 +281,6 @@ public class BSTerrainManager
// Our mega-prim child is giving us a new terrain to add to the phys world
uint newTerrainID = ++m_terrainCount;
- Vector3 minCoords = tOffset;
- minCoords.Z = minZ;
- Vector3 maxCoords = new Vector3(tOffset.X + Constants.RegionSize,
- tOffset.Y + Constants.RegionSize,
- maxZ);
m_physicsScene.TaintedObject("BSScene.SetTerrain:NewTerrain", delegate()
{
DetailLog("{0},SetTerrain:NewTerrain,baseX={1},baseY={2}", BSScene.DetailLogZero, tOffset.X, tOffset.Y);
@@ -240,9 +290,9 @@ public class BSTerrainManager
}
// Someday we will have complex terrain with caves and tunnels
- // For the moment, it's flat and convex
public float GetTerrainHeightAtXYZ(Vector3 loc)
{
+ // For the moment, it's flat and convex
return GetTerrainHeightAtXY(loc.X, loc.Y);
}
@@ -252,9 +302,19 @@ public class BSTerrainManager
// the same size and that is the default.
// Once the heightMapInfo is found, we have all the information to
// compute the offset into the array.
+ private float lastHeightTX = 999999f;
+ private float lastHeightTY = 999999f;
+ private float lastHeight = HEIGHT_INITIAL_LASTHEIGHT;
public float GetTerrainHeightAtXY(float tX, float tY)
{
- float ret = 30f;
+ // You'd be surprized at the number of times this routine is called
+ // with the same parameters as last time.
+ if (!m_terrainModified && lastHeightTX == tX && lastHeightTY == tY)
+ return lastHeight;
+
+ lastHeightTX = tX;
+ lastHeightTY = tY;
+ float ret = HEIGHT_GETHEIGHT_RET;
int offsetX = ((int)(tX / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
int offsetY = ((int)(tY / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
@@ -265,15 +325,20 @@ public class BSTerrainManager
{
float regionX = tX - offsetX;
float regionY = tY - offsetY;
- regionX = regionX > mapInfo.sizeX ? 0 : regionX;
- regionY = regionY > mapInfo.sizeY ? 0 : regionY;
- ret = mapInfo.heightMap[(int)(regionX * mapInfo.sizeX + regionY)];
+ if (regionX > mapInfo.sizeX) regionX = 0;
+ if (regionY > mapInfo.sizeY) regionY = 0;
+ int mapIndex = (int)regionY * (int)mapInfo.sizeY + (int)regionX;
+ ret = mapInfo.heightMap[mapIndex];
+ m_terrainModified = false;
+ DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXY,bX={1},baseY={2},szX={3},szY={4},regX={5},regY={6},index={7},ht={8}",
+ BSScene.DetailLogZero, offsetX, offsetY, mapInfo.sizeX, mapInfo.sizeY, regionX, regionY, mapIndex, ret);
}
else
{
m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: x={1}, y={2}",
LogHeader, tX, tY);
}
+ lastHeight = ret;
return ret;
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 3b319fb..804d2ea 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -38,13 +38,19 @@ namespace OpenSim.Region.Physics.BulletSPlugin {
// The physics engine controller class created at initialization
public struct BulletSim
{
- public BulletSim(uint id, BSScene bss, IntPtr xx) { ID = id; scene = bss; Ptr = xx; }
- public uint ID;
+ public BulletSim(uint worldId, BSScene bss, IntPtr xx) { worldID = worldId; scene = bss; Ptr = xx; }
+ public uint worldID;
// The scene is only in here so very low level routines have a handle to print debug/error messages
public BSScene scene;
public IntPtr Ptr;
}
+public struct BulletShape
+{
+ public BulletShape(IntPtr xx) { Ptr = xx; }
+ public IntPtr Ptr;
+}
+
// An allocated Bullet btRigidBody
public struct BulletBody
{
@@ -66,18 +72,22 @@ public struct BulletConstraint
// than making copies.
public class BulletHeightMapInfo
{
- public BulletHeightMapInfo(IntPtr xx, float[] hm) {
+ public BulletHeightMapInfo(uint id, float[] hm, IntPtr xx) {
+ ID = id;
Ptr = xx;
heightMap = hm;
terrainRegionBase = new Vector2(0f, 0f);
- maxRegionExtent = new Vector3(100f, 100f, 25f);
+ minCoords = new Vector3(100f, 100f, 25f);
+ maxCoords = new Vector3(101f, 101f, 26f);
minZ = maxZ = 0f;
sizeX = sizeY = 256f;
}
+ public uint ID;
public IntPtr Ptr;
public float[] heightMap;
public Vector2 terrainRegionBase;
- public Vector3 maxRegionExtent;
+ public Vector3 minCoords;
+ public Vector3 maxCoords;
public float sizeX, sizeY;
public float minZ, maxZ;
}
@@ -248,6 +258,10 @@ public enum ConstraintParamAxis : int
// ===============================================================================
static class BulletSimAPI {
+// Link back to the managed code for outputting log messages
+[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
+
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string GetVersion();
@@ -255,7 +269,8 @@ public static extern string GetVersion();
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
int maxCollisions, IntPtr collisionArray,
- int maxUpdates, IntPtr updateArray);
+ int maxUpdates, IntPtr updateArray,
+ DebugLogCallback logRoutine);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern void CreateInitialGroundPlaneAndTerrain(uint worldID);
@@ -372,8 +387,6 @@ public static extern Vector3 RecoverFromPenetration(uint worldID, uint id);
public static extern void DumpBulletStatistics();
// Log a debug message
-[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern void SetDebugLogCallback(DebugLogCallback callback);
@@ -407,7 +420,7 @@ public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetHeightmap2(IntPtr world, float[] heightmap);
+public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern void Shutdown2(IntPtr sim);
@@ -442,25 +455,31 @@ public static extern IntPtr BuildNativeShape2(IntPtr world,
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, Vector3 pos, Quaternion rot);
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, Vector3 pos, Quaternion rot);
+
+[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
+public static extern bool ReplaceBodyShape2(IntPtr sim, IntPtr obj, IntPtr shape);
// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateGroundPlaneBody2(uint id, float height, float collisionMargin);
+public static extern IntPtr CreateHeightMapInfo2(uint id, Vector3 minCoords, Vector3 maxCoords,
+ [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateTerrainBody2(uint id,
- IntPtr heightMapInfo,
- float collisionMargin);
+public static extern IntPtr FillHeightMapInfo2(IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
+ [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateHeightmap2(Vector3 minCoords, Vector3 maxCoords,
- [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
+public static extern bool ReleaseHeightMapInfo2(IntPtr heightMapInfo);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool ReleaseHeightmapInfo2(IntPtr heightMapInfo);
+public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void UpdateHeightMap2(IntPtr world, IntPtr heightMapInfo,
- [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
+public static extern IntPtr CreateTerrainShape2(IntPtr mapInfo);
// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
--
cgit v1.1
From ffdc7987207de279116a077e2042ed3a1f381a5f Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 31 Aug 2012 11:33:36 -0700
Subject: BulletSim: Update BulletSimAPI to match the DLL interface. Major
rework of terrain management which finally makes mega-regions work. Update
heightmap of terrain by rebuilding the terrain's body and shape. There is
a problem with just replacing the shape so this workaround will do for
the moment but it will need to be resolved for mesh and hull switching.
---
.../Region/Physics/BulletSPlugin/BSCharacter.cs | 2 +-
OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 2 +-
.../Physics/BulletSPlugin/BSTerrainManager.cs | 356 +++++++++++++--------
.../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 8 +-
4 files changed, 231 insertions(+), 137 deletions(-)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index fa21233..747ae71 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -228,7 +228,7 @@ public class BSCharacter : BSPhysObject
float terrainHeight = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position);
if (Position.Z < terrainHeight)
{
- DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
+ DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
_position.Z = terrainHeight + 2.0f;
ret = true;
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 2f55ba4..4a468af 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -1070,7 +1070,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
(s) => { return s.m_params[0].terrainRestitution; },
(s,p,l,v) => { s.m_params[0].terrainRestitution = v; s.TaintedUpdateParameter(p,l,v); } ),
new ParameterDefn("AvatarFriction", "Factor to reduce movement against an avatar. Changed on avatar recreation.",
- 0.5f,
+ 0.2f,
(s,cf,p,v) => { s.m_params[0].avatarFriction = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarFriction; },
(s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarFriction, p, l, v); } ),
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index 733d9c2..ab45f8f 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -54,17 +54,19 @@ public class BSTerrainManager
// amount to make sure that a bounding box is built for the terrain.
public const float HEIGHT_EQUAL_FUDGE = 0.2f;
- public const float TERRAIN_COLLISION_MARGIN = 0.2f;
+ public const float TERRAIN_COLLISION_MARGIN = 0.0f;
+
+ // Until the whole simulator is changed to pass us the region size, we rely on constants.
+ public Vector3 DefaultRegionSize = new Vector3(Constants.RegionSize, Constants.RegionSize, 0f);
// The scene that I am part of
- BSScene m_physicsScene;
+ private BSScene m_physicsScene;
// The ground plane created to keep thing from falling to infinity.
private BulletBody m_groundPlane;
// If doing mega-regions, if we're region zero we will be managing multiple
// region terrains since region zero does the physics for the whole mega-region.
- private Dictionary m_terrains;
private Dictionary m_heightMaps;
// True of the terrain has been modified.
@@ -78,16 +80,22 @@ public class BSTerrainManager
// If doing mega-regions, this holds our offset from region zero of
// the mega-regions. "parentScene" points to the PhysicsScene of region zero.
- private Vector3 m_worldOffset = Vector3.Zero;
- public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
- private PhysicsScene m_parentScene = null;
+ private Vector3 m_worldOffset;
+ // If the parent region (region 0), this is the extent of the combined regions
+ // relative to the origin of region zero
+ private Vector3 m_worldMax;
+ private PhysicsScene m_parentScene;
public BSTerrainManager(BSScene physicsScene)
{
m_physicsScene = physicsScene;
- m_terrains = new Dictionary();
m_heightMaps = new Dictionary();
m_terrainModified = false;
+
+ // Assume one region of default size
+ m_worldOffset = Vector3.Zero;
+ m_worldMax = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, 4096f);
+ m_parentScene = null;
}
// Create the initial instance of terrain and the underlying ground plane.
@@ -95,7 +103,7 @@ public class BSTerrainManager
// by the managed code.
// The terrains and the groundPlane are not added to the list of PhysObjects.
// This is called from the initialization routine so we presume it is
- // safe to call Bullet in real time. We hope no one is moving around prim yet.
+ // safe to call Bullet in real time. We hope no one is moving prims around yet.
public void CreateInitialGroundPlaneAndTerrain()
{
// The ground plane is here to catch things that are trying to drop to negative infinity
@@ -105,125 +113,91 @@ public class BSTerrainManager
BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr);
Vector3 minTerrainCoords = new Vector3(0f, 0f, HEIGHT_INITIALIZATION - HEIGHT_EQUAL_FUDGE);
- Vector3 maxTerrainCoords = new Vector3(Constants.RegionSize, Constants.RegionSize, HEIGHT_INITIALIZATION);
+ Vector3 maxTerrainCoords = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, HEIGHT_INITIALIZATION);
int totalHeights = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y;
float[] initialMap = new float[totalHeights];
for (int ii = 0; ii < totalHeights; ii++)
{
initialMap[ii] = HEIGHT_INITIALIZATION;
}
- CreateNewTerrainSegment(BSScene.TERRAIN_ID, initialMap, minTerrainCoords, maxTerrainCoords);
+ UpdateOrCreateTerrain(BSScene.TERRAIN_ID, initialMap, minTerrainCoords, maxTerrainCoords, true);
}
+ // Release all the terrain structures we might have allocated
public void ReleaseGroundPlaneAndTerrain()
{
- if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr))
+ if (m_groundPlane.Ptr != IntPtr.Zero)
{
- BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, m_groundPlane.Ptr);
- }
- m_groundPlane.Ptr = IntPtr.Zero;
-
- foreach (KeyValuePair kvp in m_terrains)
- {
- if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, kvp.Value.Ptr))
+ if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr))
{
- BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, kvp.Value.Ptr);
- BulletSimAPI.ReleaseHeightMapInfo2(m_heightMaps[kvp.Key].Ptr);
+ BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, m_groundPlane.Ptr);
}
+ m_groundPlane.Ptr = IntPtr.Zero;
}
- m_terrains.Clear();
- m_heightMaps.Clear();
+
+ ReleaseTerrain();
}
- // Create a new terrain description. This is used for mega-regions where
- // the children of region zero give region zero all of the terrain
- // segments since region zero does all the physics for the mega-region.
- // Call at taint time!!
- public void CreateNewTerrainSegment(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords)
+ // Release all the terrain we have allocated
+ public void ReleaseTerrain()
{
- // The Z coordinates are recalculated to be the min and max height of the terrain
- // itself. The caller may have passed us the real region extent.
- float minZ = float.MaxValue;
- float maxZ = float.MinValue;
- int hSize = heightMap.Length;
- for (int ii = 0; ii < hSize; ii++)
+ foreach (KeyValuePair kvp in m_heightMaps)
{
- float height = heightMap[ii];
- if (height < minZ) minZ = height;
- if (height > maxZ) maxZ = height;
+ if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, kvp.Value.terrainBody.Ptr))
+ {
+ BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, kvp.Value.terrainBody.Ptr);
+ BulletSimAPI.ReleaseHeightMapInfo2(kvp.Value.Ptr);
+ }
}
- // If the terrain is flat, make a difference so we get a bounding box
- if (minZ == maxZ)
- minZ -= HEIGHT_EQUAL_FUDGE;
-
- minCoords.Z = minZ;
- maxCoords.Z = maxZ;
- Vector2 terrainRegionBase = new Vector2(minCoords.X, minCoords.Y);
-
- // Create the heightmap data structure in the unmanaged space
- BulletHeightMapInfo mapInfo = new BulletHeightMapInfo(id, heightMap,
- BulletSimAPI.CreateHeightMapInfo2(id, minCoords, maxCoords, heightMap, TERRAIN_COLLISION_MARGIN));
- mapInfo.terrainRegionBase = terrainRegionBase;
- mapInfo.minCoords = minCoords;
- mapInfo.maxCoords = maxCoords;
- mapInfo.minZ = minZ;
- mapInfo.maxZ = maxZ;
- mapInfo.sizeX = maxCoords.X - minCoords.X;
- mapInfo.sizeY = maxCoords.Y - minCoords.Y;
-
- Vector3 centerPos;
- centerPos.X = minCoords.X + (mapInfo.sizeX / 2f);
- centerPos.Y = minCoords.Y + (mapInfo.sizeY / 2f);
- centerPos.Z = minZ + (maxZ - minZ) / 2f;
-
- DetailLog("{0},BSScene.CreateNewTerrainSegment,call,minZ={1},maxZ={2},hMapPtr={3},minC={4},maxC={5}",
- BSScene.DetailLogZero, minZ, maxZ, mapInfo.Ptr, minCoords, maxCoords);
- // Create the terrain shape from the mapInfo
- BulletShape terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr));
-
- BulletBody terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2(terrainShape.Ptr,
- centerPos, Quaternion.Identity));
-
- BulletSimAPI.SetFriction2(terrainBody.Ptr, m_physicsScene.Params.terrainFriction);
- BulletSimAPI.SetHitFraction2(terrainBody.Ptr, m_physicsScene.Params.terrainHitFraction);
- BulletSimAPI.SetRestitution2(terrainBody.Ptr, m_physicsScene.Params.terrainRestitution);
- BulletSimAPI.SetCollisionFlags2(terrainBody.Ptr, CollisionFlags.CF_STATIC_OBJECT);
- BulletSimAPI.Activate2(terrainBody.Ptr, true);
-
- // Add the new terrain to the dynamics world
- BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, terrainBody.Ptr);
- BulletSimAPI.UpdateSingleAabb2(m_physicsScene.World.Ptr, terrainBody.Ptr);
-
- // Add the created terrain to the management set. If we are doing mega-regions,
- // the terrains of our children will be added.
- m_terrains.Add(terrainRegionBase, terrainBody);
- m_heightMaps.Add(terrainRegionBase, mapInfo);
-
- m_terrainModified = true;
+ m_heightMaps.Clear();
}
+ // The simulator wants to set a new heightmap for the terrain.
public void SetTerrain(float[] heightMap) {
if (m_worldOffset != Vector3.Zero && m_parentScene != null)
{
+ // If a child of a mega-region, we shouldn't have any terrain allocated for us
+ ReleaseGroundPlaneAndTerrain();
// If doing the mega-prim stuff and we are the child of the zero region,
- // the terrain is really added to our parent
+ // the terrain is added to our parent
if (m_parentScene is BSScene)
{
- ((BSScene)m_parentScene).TerrainManager.SetTerrain(heightMap, m_worldOffset);
+ DetailLog("{0},SetTerrain.ToParent,offset={1},worldMax={2}",
+ BSScene.DetailLogZero, m_worldOffset, m_worldMax);
+ ((BSScene)m_parentScene).TerrainManager.UpdateOrCreateTerrain(BSScene.CHILDTERRAIN_ID,
+ heightMap, m_worldOffset, m_worldOffset+DefaultRegionSize, false);
}
}
else
{
- // if not doing the mega-prim thing, just change the terrain
- SetTerrain(heightMap, m_worldOffset);
+ // If not doing the mega-prim thing, just change the terrain
+ DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero);
+
+ UpdateOrCreateTerrain(BSScene.TERRAIN_ID, heightMap, m_worldOffset, m_worldOffset+DefaultRegionSize, false);
}
}
- private void SetTerrain(float[] heightMap, Vector3 tOffset)
+ // If called with no mapInfo for the terrain, this will create a new mapInfo and terrain
+ // based on the passed information. The 'id' should be either the terrain id or
+ // BSScene.CHILDTERRAIN_ID. If the latter, a new child terrain ID will be allocated and used.
+ // The latter feature is for creating child terrains for mega-regions.
+ // If called with a mapInfo in m_heightMaps but the terrain has no body yet (mapInfo.terrainBody.Ptr == 0)
+ // then a new body and shape is created and the mapInfo is filled.
+ // This call is used for doing the initial terrain creation.
+ // If called with a mapInfo in m_heightMaps and there is an existing terrain body, a new
+ // terrain shape is created and added to the body.
+ // This call is most often used to update the heightMap and parameters of the terrain.
+ // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when
+ // calling this routine from initialization or taint-time routines) or whether to delay
+ // all the unmanaged activities to taint-time.
+ private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool doNow)
{
+ DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},doNow={3}",
+ BSScene.DetailLogZero, minCoords, maxCoords, doNow);
+
float minZ = float.MaxValue;
float maxZ = float.MinValue;
- Vector2 terrainRegionBase = new Vector2(tOffset.X, tOffset.Y);
+ Vector2 terrainRegionBase = new Vector2(minCoords.X, minCoords.Y);
int heightMapSize = heightMap.Length;
for (int ii = 0; ii < heightMapSize; ii++)
@@ -234,58 +208,162 @@ public class BSTerrainManager
}
// The shape of the terrain is from its base to its extents.
- Vector3 minCoords, maxCoords;
- minCoords = tOffset;
minCoords.Z = minZ;
- maxCoords = tOffset;
- maxCoords.X += Constants.RegionSize;
- maxCoords.Y += Constants.RegionSize;
maxCoords.Z = maxZ;
- BulletBody terrainBody;
BulletHeightMapInfo mapInfo;
if (m_heightMaps.TryGetValue(terrainRegionBase, out mapInfo))
{
- terrainBody = m_terrains[terrainRegionBase];
- // Copy heightMap local and compute some statistics.
- for (int ii = 0; ii < heightMapSize; ii++)
- {
- mapInfo.heightMap[ii] = heightMap[ii];
- }
-
// If this is terrain we know about, it's easy to update
- m_physicsScene.TaintedObject("BSScene.SetTerrain:UpdateExisting", delegate()
+
+ mapInfo.heightMap = heightMap;
+ mapInfo.minCoords = minCoords;
+ mapInfo.maxCoords = maxCoords;
+ mapInfo.minZ = minZ;
+ mapInfo.maxZ = maxZ;
+ mapInfo.sizeX = maxCoords.X - minCoords.X;
+ mapInfo.sizeY = maxCoords.Y - minCoords.Y;
+ DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,call,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}",
+ BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY);
+
+ BSScene.TaintCallback rebuildOperation = delegate()
{
- DetailLog("{0},SetTerrain:UpdateExisting,baseX={1},baseY={2},minZ={3},maxZ={4}",
- BSScene.DetailLogZero, tOffset.X, tOffset.Y, minZ, maxZ);
- // Fill the existing height map info with the new location and size information
- BulletSimAPI.FillHeightMapInfo2(mapInfo.Ptr, mapInfo.ID, minCoords, maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN);
+ if (m_parentScene != null)
+ {
+ // It's possible that Combine() was called after this code was queued.
+ // If we are a child of combined regions, we don't create any terrain for us.
+ DetailLog("{0},UpdateOrCreateTerrain:AmACombineChild,taint", BSScene.DetailLogZero);
- // Create a terrain shape based on the new info
- BulletShape terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr));
+ // Get rid of any terrain that may have been allocated for us.
+ ReleaseGroundPlaneAndTerrain();
- // Swap the shape in the terrain body (this also deletes the old shape)
- bool success = BulletSimAPI.ReplaceBodyShape2(m_physicsScene.World.Ptr, terrainBody.Ptr, terrainShape.Ptr);
+ // I hate doing this, but just bail
+ return;
+ }
- if (!success)
+ if (mapInfo.terrainBody.Ptr != IntPtr.Zero)
{
- DetailLog("{0},SetTerrain:UpdateExisting,Failed", BSScene.DetailLogZero);
- m_physicsScene.Logger.ErrorFormat("{0} Failed updating terrain heightmap. Region={1}",
- LogHeader, m_physicsScene.RegionName);
-
+ // Updating an existing terrain.
+ DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}",
+ BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY);
+
+ // Remove from the dynamics world because we're going to mangle this object
+ BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr);
+
+ // Get rid of the old terrain
+ BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr);
+ BulletSimAPI.ReleaseHeightMapInfo2(mapInfo.Ptr);
+ mapInfo.Ptr = IntPtr.Zero;
+
+ /*
+ // NOTE: This routine is half here because I can't get the terrain shape replacement
+ // to work. In the short term, the above three lines completely delete the old
+ // terrain and the code below recreates one from scratch.
+ // Hopefully the Bullet community will help me out on this one.
+
+ // First, release the old collision shape (there is only one terrain)
+ BulletSimAPI.DeleteCollisionShape2(m_physicsScene.World.Ptr, mapInfo.terrainShape.Ptr);
+
+ // Fill the existing height map info with the new location and size information
+ BulletSimAPI.FillHeightMapInfo2(m_physicsScene.World.Ptr, mapInfo.Ptr, mapInfo.ID,
+ mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN);
+
+ // Create a terrain shape based on the new info
+ mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr));
+
+ // Stuff the shape into the existing terrain body
+ BulletSimAPI.SetBodyShape2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr, mapInfo.terrainShape.Ptr);
+ */
}
- });
+ // else
+ {
+ // Creating a new terrain.
+ DetailLog("{0},UpdateOrCreateTerrain:CreateNewTerrain,taint,baseX={1},baseY={2},minZ={3},maxZ={4}",
+ BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ);
+
+ mapInfo.ID = id;
+ mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(m_physicsScene.World.Ptr, mapInfo.ID,
+ mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN);
+
+ // The terrain object initial position is at the center of the object
+ Vector3 centerPos;
+ centerPos.X = minCoords.X + (mapInfo.sizeX / 2f);
+ centerPos.Y = minCoords.Y + (mapInfo.sizeY / 2f);
+ centerPos.Z = minZ + ((maxZ - minZ) / 2f);
+
+ // Create the terrain shape from the mapInfo
+ mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr));
+
+ mapInfo.terrainBody = new BulletBody(mapInfo.ID,
+ BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.Ptr,
+ centerPos, Quaternion.Identity));
+ }
+
+ // Make sure the entry is in the heightmap table
+ m_heightMaps[terrainRegionBase] = mapInfo;
+
+ // Set current terrain attributes
+ BulletSimAPI.SetFriction2(mapInfo.terrainBody.Ptr, m_physicsScene.Params.terrainFriction);
+ BulletSimAPI.SetHitFraction2(mapInfo.terrainBody.Ptr, m_physicsScene.Params.terrainHitFraction);
+ BulletSimAPI.SetRestitution2(mapInfo.terrainBody.Ptr, m_physicsScene.Params.terrainRestitution);
+ BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.Ptr, CollisionFlags.CF_STATIC_OBJECT);
+
+ BulletSimAPI.SetMassProps2(mapInfo.terrainBody.Ptr, 0f, Vector3.Zero);
+ BulletSimAPI.UpdateInertiaTensor2(mapInfo.terrainBody.Ptr);
+
+ // Return the new terrain to the world of physical objects
+ BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr);
+
+ // redo its bounding box now that it is in the world
+ BulletSimAPI.UpdateSingleAabb2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr);
+
+ // Make sure the new shape is processed.
+ BulletSimAPI.Activate2(mapInfo.terrainBody.Ptr, true);
+ };
+
+ // There is the option to do the changes now (we're already in 'taint time'), or
+ // to do the Bullet operations later.
+ if (doNow)
+ rebuildOperation();
+ else
+ m_physicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation);
}
else
{
- // Our mega-prim child is giving us a new terrain to add to the phys world
- uint newTerrainID = ++m_terrainCount;
+ // We don't know about this terrain so either we are creating a new terrain or
+ // our mega-prim child is giving us a new terrain to add to the phys world
- m_physicsScene.TaintedObject("BSScene.SetTerrain:NewTerrain", delegate()
+ // if this is a child terrain, calculate a unique terrain id
+ uint newTerrainID = id;
+ if (newTerrainID >= BSScene.CHILDTERRAIN_ID)
+ newTerrainID = ++m_terrainCount;
+
+ float[] heightMapX = heightMap;
+ Vector3 minCoordsX = minCoords;
+ Vector3 maxCoordsX = maxCoords;
+
+ DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,call,id={1}, minC={2}, maxC={3}",
+ BSScene.DetailLogZero, newTerrainID, minCoords, minCoords);
+
+ // Code that must happen at taint-time
+ BSScene.TaintCallback createOperation = delegate()
{
- DetailLog("{0},SetTerrain:NewTerrain,baseX={1},baseY={2}", BSScene.DetailLogZero, tOffset.X, tOffset.Y);
- CreateNewTerrainSegment(newTerrainID, heightMap, minCoords, maxCoords);
- });
+ DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y);
+ // Create a new mapInfo that will be filled with the new info
+ mapInfo = new BulletHeightMapInfo(id, heightMapX,
+ BulletSimAPI.CreateHeightMapInfo2(m_physicsScene.World.Ptr, newTerrainID,
+ minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN));
+ // Put the unfilled heightmap info into the collection of same
+ m_heightMaps.Add(terrainRegionBase, mapInfo);
+ // Build the terrain
+ UpdateOrCreateTerrain(newTerrainID, heightMap, minCoords, maxCoords, true);
+ };
+
+ // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time.
+ if (doNow)
+ createOperation();
+ else
+ m_physicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation);
}
}
@@ -316,8 +394,8 @@ public class BSTerrainManager
lastHeightTY = tY;
float ret = HEIGHT_GETHEIGHT_RET;
- int offsetX = ((int)(tX / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
- int offsetY = ((int)(tY / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
+ int offsetX = ((int)(tX / (int)DefaultRegionSize.X)) * (int)DefaultRegionSize.X;
+ int offsetY = ((int)(tY / (int)DefaultRegionSize.Y)) * (int)DefaultRegionSize.Y;
Vector2 terrainBaseXY = new Vector2(offsetX, offsetY);
BulletHeightMapInfo mapInfo;
@@ -335,8 +413,8 @@ public class BSTerrainManager
}
else
{
- m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: x={1}, y={2}",
- LogHeader, tX, tY);
+ m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}",
+ LogHeader, m_physicsScene.RegionName, tX, tY);
}
lastHeight = ret;
return ret;
@@ -347,20 +425,34 @@ public class BSTerrainManager
{
return true;
}
- // This call says I am a child to region zero in a mega-region. 'pScene' is that
- // of region zero, 'offset' is my offset from regions zero's origin, and
- // 'extents' is the largest XY that is handled in my region.
+
+ // This routine is called two ways:
+ // One with 'offset' and 'pScene' zero and null but 'extents' giving the maximum
+ // extent of the combined regions. This is to inform the parent of the size
+ // of the combined regions.
+ // and one with 'offset' as the offset of the child region to the base region,
+ // 'pScene' pointing to the parent and 'extents' of zero. This informs the
+ // child of its relative base and new parent.
public void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
{
m_worldOffset = offset;
- WorldExtents = new Vector2(extents.X, extents.Y);
+ m_worldMax = extents;
m_parentScene = pScene;
+ if (pScene != null)
+ {
+ // We are a child.
+ // We want m_worldMax to be the highest coordinate of our piece of terrain.
+ m_worldMax = offset + DefaultRegionSize;
+ }
+ DetailLog("{0},BSTerrainManager.Combine,offset={1},extents={2},wOffset={3},wMax={4}",
+ BSScene.DetailLogZero, offset, extents, m_worldOffset, m_worldMax);
}
// Unhook all the combining that I know about.
public void UnCombine(PhysicsScene pScene)
{
// Just like ODE, for the moment a NOP
+ DetailLog("{0},BSTerrainManager.UnCombine", BSScene.DetailLogZero);
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 804d2ea..a0bad3a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -90,6 +90,8 @@ public class BulletHeightMapInfo
public Vector3 maxCoords;
public float sizeX, sizeY;
public float minZ, maxZ;
+ public BulletShape terrainShape;
+ public BulletBody terrainBody;
}
// ===============================================================================
@@ -462,14 +464,14 @@ public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, Vecto
public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, Vector3 pos, Quaternion rot);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool ReplaceBodyShape2(IntPtr sim, IntPtr obj, IntPtr shape);
+public static extern bool SetBodyShape2(IntPtr sim, IntPtr obj, IntPtr shape);
// =====================================================================================
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr CreateHeightMapInfo2(uint id, Vector3 minCoords, Vector3 maxCoords,
+public static extern IntPtr CreateHeightMapInfo2(IntPtr sim, uint id, Vector3 minCoords, Vector3 maxCoords,
[MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern IntPtr FillHeightMapInfo2(IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
+public static extern IntPtr FillHeightMapInfo2(IntPtr sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
[MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
--
cgit v1.1
From 32b534f324c0d69b3b56746a07e80ab38d7dd546 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 31 Aug 2012 11:40:00 -0700
Subject: BulletSim: update the SOs and DLLs
---
bin/lib32/BulletSim.dll | Bin 552960 -> 556544 bytes
bin/lib32/libBulletSim.so | Bin 2387278 -> 2423331 bytes
bin/lib64/BulletSim.dll | Bin 710144 -> 715264 bytes
bin/lib64/libBulletSim.so | Bin 2599821 -> 2645594 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll
index ce0dd9d..5673b91 100755
Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ
diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so
index d2d6540..a9768b2 100755
Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ
diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll
index 67d3f1c..de9df08 100755
Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ
diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so
index 9a5c171..aefab07 100755
Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ
--
cgit v1.1
From f7b88d1c40ba06c62491d8d32809fe6c1c4d360d Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sun, 2 Sep 2012 13:43:16 +0100
Subject: made setting rotation match Second Life
---
.../Shared/Api/Implementation/LSL_Api.cs | 33 +---------------------
1 file changed, 1 insertion(+), 32 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index be22cb4..9f952d1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2083,23 +2083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetRot(LSL_Rotation rot)
{
m_host.AddScriptLPS(1);
-
- // try to let this work as in SL...
- if (m_host.ParentID == 0)
- {
- // special case: If we are root, rotate complete SOG to new rotation
SetRot(m_host, rot);
- }
- else
- {
- // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
- SceneObjectPart rootPart = m_host.ParentGroup.RootPart;
- if (rootPart != null) // better safe than sorry
- {
- SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
- }
- }
-
ScriptSleep(200);
}
@@ -7292,22 +7276,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case (int)ScriptBaseClass.PRIM_ROTATION:
+ case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
if (remain < 1)
return null;
LSL_Rotation q = rules.GetQuaternionItem(idx++);
- // try to let this work as in SL...
- if (part.ParentID == 0)
- {
- // special case: If we are root, rotate complete SOG to new rotation
SetRot(part, q);
- }
- else
- {
- // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
- SceneObjectPart rootPart = part.ParentGroup.RootPart;
- SetRot(part, rootPart.RotationOffset * (Quaternion)q);
- }
break;
@@ -7614,11 +7588,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primDesc = rules.GetLSLStringItem(idx++);
part.Description = primDesc;
break;
- case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
- if (remain < 1)
- return null;
- SetRot(part, rules.GetQuaternionItem(idx++));
- break;
case (int)ScriptBaseClass.PRIM_OMEGA:
if (remain < 3)
return null;
--
cgit v1.1
From a3d140b57c5e2ae0f3334d59b82e116d40199b49 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sun, 2 Sep 2012 13:45:42 +0100
Subject: no need to assign rotation to a variable now
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9f952d1..6f4bc8b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7280,8 +7280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return null;
- LSL_Rotation q = rules.GetQuaternionItem(idx++);
- SetRot(part, q);
+ SetRot(part, rules.GetQuaternionItem(idx++));
break;
--
cgit v1.1
From fb211c64fd9d335f4879549023870b1e28416f74 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sun, 2 Sep 2012 13:47:18 +0100
Subject: formatting
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6f4bc8b..1d2ef40 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2083,7 +2083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetRot(LSL_Rotation rot)
{
m_host.AddScriptLPS(1);
- SetRot(m_host, rot);
+ SetRot(m_host, rot);
ScriptSleep(200);
}
@@ -7280,7 +7280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return null;
- SetRot(part, rules.GetQuaternionItem(idx++));
+ SetRot(part, rules.GetQuaternionItem(idx++));
break;
--
cgit v1.1
From 359f9efc768d701460491b64b75660bf3c145419 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 3 Sep 2012 21:51:54 +0100
Subject: Revert "formatting"
This reverts commit fb211c64fd9d335f4879549023870b1e28416f74.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 1d2ef40..6f4bc8b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2083,7 +2083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetRot(LSL_Rotation rot)
{
m_host.AddScriptLPS(1);
- SetRot(m_host, rot);
+ SetRot(m_host, rot);
ScriptSleep(200);
}
@@ -7280,7 +7280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return null;
- SetRot(part, rules.GetQuaternionItem(idx++));
+ SetRot(part, rules.GetQuaternionItem(idx++));
break;
--
cgit v1.1
From 29218cdb3169b70e047acc372433769ece3ffae1 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 3 Sep 2012 21:52:03 +0100
Subject: Revert "no need to assign rotation to a variable now"
This reverts commit a3d140b57c5e2ae0f3334d59b82e116d40199b49.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6f4bc8b..9f952d1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7280,7 +7280,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return null;
- SetRot(part, rules.GetQuaternionItem(idx++));
+ LSL_Rotation q = rules.GetQuaternionItem(idx++);
+ SetRot(part, q);
break;
--
cgit v1.1
From d297eb39e57f9dc70abe43839e263af19b5777e2 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 3 Sep 2012 21:52:12 +0100
Subject: Revert "made setting rotation match Second Life" Second Life seems to
have introduced a bug, as we have confirmation that SL behavior changed
recently and changed in contradiction to their stated intention This appears
to be another of the bugs SL is notorious for. Signpost and I have decided to
back this out until SL's intention becomes clear.
This reverts commit f7b88d1c40ba06c62491d8d32809fe6c1c4d360d.
---
.../Shared/Api/Implementation/LSL_Api.cs | 33 +++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9f952d1..be22cb4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2083,7 +2083,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetRot(LSL_Rotation rot)
{
m_host.AddScriptLPS(1);
+
+ // try to let this work as in SL...
+ if (m_host.ParentID == 0)
+ {
+ // special case: If we are root, rotate complete SOG to new rotation
SetRot(m_host, rot);
+ }
+ else
+ {
+ // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
+ SceneObjectPart rootPart = m_host.ParentGroup.RootPart;
+ if (rootPart != null) // better safe than sorry
+ {
+ SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
+ }
+ }
+
ScriptSleep(200);
}
@@ -7276,12 +7292,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case (int)ScriptBaseClass.PRIM_ROTATION:
- case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
if (remain < 1)
return null;
LSL_Rotation q = rules.GetQuaternionItem(idx++);
+ // try to let this work as in SL...
+ if (part.ParentID == 0)
+ {
+ // special case: If we are root, rotate complete SOG to new rotation
SetRot(part, q);
+ }
+ else
+ {
+ // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
+ SceneObjectPart rootPart = part.ParentGroup.RootPart;
+ SetRot(part, rootPart.RotationOffset * (Quaternion)q);
+ }
break;
@@ -7588,6 +7614,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primDesc = rules.GetLSLStringItem(idx++);
part.Description = primDesc;
break;
+ case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
+ if (remain < 1)
+ return null;
+ SetRot(part, rules.GetQuaternionItem(idx++));
+ break;
case (int)ScriptBaseClass.PRIM_OMEGA:
if (remain < 3)
return null;
--
cgit v1.1
From 574a6e35807d522a211f05d2370da2a31277051a Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 3 Sep 2012 21:53:46 +0100
Subject: Revert "formatting"
This reverts commit fb211c64fd9d335f4879549023870b1e28416f74.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index dda8257..89bd6ac 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2314,7 +2314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetRot(LSL_Rotation rot)
{
m_host.AddScriptLPS(1);
- SetRot(m_host, rot);
+ SetRot(m_host, rot);
ScriptSleep(200);
}
@@ -7850,7 +7850,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return null;
- SetRot(part, rules.GetQuaternionItem(idx++));
+ SetRot(part, rules.GetQuaternionItem(idx++));
break;
--
cgit v1.1
From f32c74b2ffdeb439b3e939a3e21fe210af717af4 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 3 Sep 2012 21:53:55 +0100
Subject: Revert "no need to assign rotation to a variable now"
This reverts commit a3d140b57c5e2ae0f3334d59b82e116d40199b49.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 89bd6ac..c47893e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7850,7 +7850,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return null;
- SetRot(part, rules.GetQuaternionItem(idx++));
+ LSL_Rotation q = rules.GetQuaternionItem(idx++);
+ SetRot(part, q);
break;
--
cgit v1.1
From 72d20b794a245f0e9b9e1f968b50067db2910b6c Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 3 Sep 2012 21:54:02 +0100
Subject: Revert "made setting rotation match Second Life"
This reverts commit f7b88d1c40ba06c62491d8d32809fe6c1c4d360d.
---
.../Shared/Api/Implementation/LSL_Api.cs | 33 +++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c47893e..efeca26 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2314,7 +2314,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetRot(LSL_Rotation rot)
{
m_host.AddScriptLPS(1);
+
+ // try to let this work as in SL...
+ if (m_host.ParentID == 0)
+ {
+ // special case: If we are root, rotate complete SOG to new rotation
SetRot(m_host, rot);
+ }
+ else
+ {
+ // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
+ SceneObjectPart rootPart = m_host.ParentGroup.RootPart;
+ if (rootPart != null) // better safe than sorry
+ {
+ SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
+ }
+ }
+
ScriptSleep(200);
}
@@ -7846,12 +7862,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case (int)ScriptBaseClass.PRIM_ROTATION:
- case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
if (remain < 1)
return null;
LSL_Rotation q = rules.GetQuaternionItem(idx++);
+ // try to let this work as in SL...
+ if (part.ParentID == 0)
+ {
+ // special case: If we are root, rotate complete SOG to new rotation
SetRot(part, q);
+ }
+ else
+ {
+ // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
+ SceneObjectPart rootPart = part.ParentGroup.RootPart;
+ SetRot(part, rootPart.RotationOffset * (Quaternion)q);
+ }
break;
@@ -8188,6 +8214,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primDesc = rules.GetLSLStringItem(idx++);
part.Description = primDesc;
break;
+ case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
+ if (remain < 1)
+ return null;
+ SetRot(part, rules.GetQuaternionItem(idx++));
+ break;
case (int)ScriptBaseClass.PRIM_OMEGA:
if (remain < 3)
return null;
--
cgit v1.1
From 663bfbb372218af6e2a854a011152c9efdb82eaa Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 1 Sep 2012 02:18:36 +0100
Subject: although the attachmentPoint argument is a uint, zero is not a valid
attachment point
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5bf69ad..22d3289 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3418,7 +3418,9 @@ namespace OpenSim.Region.Framework.Scenes
public List GetAttachments(uint attachmentPoint)
{
List attachments = new List();
-
+
+ if (attachmentPoint >= 0)
+ {
lock (m_attachments)
{
foreach (SceneObjectGroup so in m_attachments)
@@ -3427,6 +3429,7 @@ namespace OpenSim.Region.Framework.Scenes
attachments.Add(so);
}
}
+ }
return attachments;
}
--
cgit v1.1
From 8d431c63594b7576fe295d50658531e81df2ac4e Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 1 Sep 2012 02:20:07 +0100
Subject: formatting
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 22d3289..1222ac6 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3421,15 +3421,15 @@ namespace OpenSim.Region.Framework.Scenes
if (attachmentPoint >= 0)
{
- lock (m_attachments)
- {
- foreach (SceneObjectGroup so in m_attachments)
+ lock (m_attachments)
{
- if (attachmentPoint == so.AttachmentPoint)
- attachments.Add(so);
+ foreach (SceneObjectGroup so in m_attachments)
+ {
+ if (attachmentPoint == so.AttachmentPoint)
+ attachments.Add(so);
+ }
}
}
- }
return attachments;
}
--
cgit v1.1
From a858c5daee64223355de04b77746142be0f5795f Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 1 Sep 2012 02:39:49 +0100
Subject: implementing a function to get the number of attachments worn
---
.../Shared/Api/Implementation/OSSL_Api.cs | 38 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 10 ++++++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 7 ++++
3 files changed, 55 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e245684..57f1e65 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3313,6 +3313,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
((LSL_Api)m_LSL_Api).DetachFromAvatar();
}
+ public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
+ {
+ CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments");
+
+ m_host.AddScriptLPS(1);
+
+ UUID targetUUID;
+ ScenePresence target;
+ LSL_List resp = new LSL_List();
+
+ if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
+ {
+ foreach (object point in attachmentPoints.Data)
+ {
+ LSL_Integer ipoint = new LSL_Integer(
+ (point is LSL_Integer || point is int || point is uint) ?
+ (int)point :
+ 0
+ );
+ resp.Add(ipoint);
+ if (ipoint == 0)
+ {
+ // indicates zero attachments
+ resp.Add(new LSL_Integer(0));
+ }
+ else
+ {
+ // gets the number of attachments on the attachment point
+ resp.Add(new LSL_Integer(target.GetAttachments((uint)ipoint).Count));
+ }
+ }
+ }
+
+ return resp;
+ }
+
+ #endregion
+
///
/// Checks if thing is a UUID.
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 06729ab..6db6443 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -192,6 +192,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// Nothing happens if the object is not attached.
void osForceDetachFromAvatar();
+ ///
+ /// Returns a strided list of the specified attachment points and the number of attachments on those points.
+ ///
+ /// avatar UUID
+ /// list of ATTACH_* constants
+ ///
+ LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints);
+
+ #endregion
+
//texture draw functions
string osMovePen(string drawList, int x, int y);
string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index ba1ade2..230c378 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -311,6 +311,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osForceDetachFromAvatar();
}
+ public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
+ {
+ return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints);
+ }
+
+ #endregion
+
// Texture Draw functions
public string osMovePen(string drawList, int x, int y)
--
cgit v1.1
From d4b8a13a1d63c950feba694eca53df06f2cc5792 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 1 Sep 2012 02:43:04 +0100
Subject: refactoring the grunt work of MessageObject into a private method
with a UUID argument
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 57f1e65..82114b3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1673,6 +1673,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
}
+ MessageObject(objUUID, message);
+ }
+
+ private void MessageObject(UUID objUUID, string message)
+ {
object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) };
SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID);
--
cgit v1.1
From ff867b59cf59fdab19413cd46f3dd04058fbf3c7 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 1 Sep 2012 02:44:11 +0100
Subject: Implementing functing to send messages directly to attachments
---
.../Shared/Api/Implementation/OSSL_Api.cs | 131 +++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 13 ++
.../Shared/Api/Runtime/LSL_Constants.cs | 52 ++++++++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +
4 files changed, 201 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 82114b3..8e80b4c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3354,6 +3354,137 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return resp;
}
+ public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options)
+ {
+ CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments");
+ m_host.AddScriptLPS(1);
+
+ UUID targetUUID;
+ ScenePresence target;
+
+ if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
+ {
+ List aps = new List();
+ foreach (object point in attachmentPoints.Data)
+ {
+ int ipoint;
+ if (int.TryParse(point.ToString(), out ipoint))
+ {
+ aps.Add(ipoint);
+ }
+ }
+
+ List attachments = new List();
+
+ bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);
+ bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;
+
+ if (msgAll && invertPoints)
+ {
+ return;
+ }
+ else if (msgAll || invertPoints)
+ {
+ attachments = target.GetAttachments();
+ }
+ else
+ {
+ foreach (int point in aps)
+ {
+ if (point > 0)
+ {
+ attachments.AddRange(target.GetAttachments((uint)point));
+ }
+ }
+ }
+
+ // if we have no attachments at this point, exit now
+ if (attachments.Count == 0)
+ {
+ return;
+ }
+
+ List ignoreThese = new List();
+
+ if (invertPoints)
+ {
+ foreach (SceneObjectGroup attachment in attachments)
+ {
+ if (aps.Contains((int)attachment.AttachmentPoint))
+ {
+ ignoreThese.Add(attachment);
+ }
+ }
+ }
+
+ foreach (SceneObjectGroup attachment in ignoreThese)
+ {
+ attachments.Remove(attachment);
+ }
+ ignoreThese.Clear();
+
+ // if inverting removed all attachments to check, exit now
+ if (attachments.Count < 1)
+ {
+ return;
+ }
+
+ if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0)
+ {
+ foreach (SceneObjectGroup attachment in attachments)
+ {
+ if (attachment.RootPart.CreatorID != m_host.CreatorID)
+ {
+ ignoreThese.Add(attachment);
+ }
+ }
+
+ foreach (SceneObjectGroup attachment in ignoreThese)
+ {
+ attachments.Remove(attachment);
+ }
+ ignoreThese.Clear();
+
+ // if filtering by same object creator removed all
+ // attachments to check, exit now
+ if (attachments.Count == 0)
+ {
+ return;
+ }
+ }
+
+ if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0)
+ {
+ foreach (SceneObjectGroup attachment in attachments)
+ {
+ if (attachment.RootPart.CreatorID != m_item.CreatorID)
+ {
+ ignoreThese.Add(attachment);
+ }
+ }
+
+ foreach (SceneObjectGroup attachment in ignoreThese)
+ {
+ attachments.Remove(attachment);
+ }
+ ignoreThese.Clear();
+
+ // if filtering by object creator must match originating
+ // script creator removed all attachments to check,
+ // exit now
+ if (attachments.Count == 0)
+ {
+ return;
+ }
+ }
+
+ foreach (SceneObjectGroup attachment in attachments)
+ {
+ MessageObject(attachment.RootPart.UUID, message);
+ }
+ }
+ }
+
#endregion
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 6db6443..bde7a8e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -200,6 +200,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
///
LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints);
+ ///
+ /// Sends a specified message to the specified avatar's attachments on
+ /// the specified attachment points.
+ ///
+ ///
+ /// Behaves as osMessageObject(), without the sending script needing to know the attachment keys in advance.
+ ///
+ /// avatar UUID
+ /// message string
+ /// list of ATTACH_* constants, or -1 for all attachments. If -1 is specified and OS_ATTACH_MSG_INVERT_POINTS is present in flags, no action is taken.
+ /// flags further constraining the attachments to deliver the message to.
+ void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags);
+
#endregion
//texture draw functions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index cad8518..60a7e14 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -237,6 +237,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int ATTACH_HUD_BOTTOM = 37;
public const int ATTACH_HUD_BOTTOM_RIGHT = 38;
+ #region osMessageAttachments constants
+
+ ///
+ /// Instructs osMessageAttachements to send the message to attachments
+ /// on every point.
+ ///
+ ///
+ /// One might expect this to be named OS_ATTACH_ALL, but then one might
+ /// also expect functions designed to attach or detach or get
+ /// attachments to work with it too. Attaching a no-copy item to
+ /// many attachments could be dangerous.
+ /// when combined with OS_ATTACH_MSG_INVERT_POINTS, will prevent the
+ /// message from being sent.
+ /// if combined with OS_ATTACH_MSG_OBJECT_CREATOR or
+ /// OS_ATTACH_MSG_SCRIPT_CREATOR, could result in no message being
+ /// sent- this is expected behaviour.
+ ///
+ public const int OS_ATTACH_MSG_ALL = -65535;
+
+ ///
+ /// Instructs osMessageAttachements to invert how the attachment points
+ /// list should be treated (e.g. go from inclusive operation to
+ /// exclusive operation).
+ ///
+ ///
+ /// This might be used if you want to deliver a message to one set of
+ /// attachments and a different message to everything else. With
+ /// this flag, you only need to build one explicit list for both calls.
+ ///
+ public const int OS_ATTACH_MSG_INVERT_POINTS = 1;
+
+ ///
+ /// Instructs osMessageAttachments to only send the message to
+ /// attachments with a CreatorID that matches the host object CreatorID
+ ///
+ ///
+ /// This would be used if distributed in an object vendor/updater server.
+ ///
+ public const int OS_ATTACH_MSG_OBJECT_CREATOR = 2;
+
+ ///
+ /// Instructs osMessageAttachments to only send the message to
+ /// attachments with a CreatorID that matches the sending script CreatorID
+ ///
+ ///
+ /// This might be used if the script is distributed independently of a
+ /// containing object.
+ ///
+ public const int OS_ATTACH_MSG_SCRIPT_CREATOR = 4;
+
+ #endregion
+
public const int LAND_LEVEL = 0;
public const int LAND_RAISE = 1;
public const int LAND_LOWER = 2;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 230c378..08ebfd6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -316,6 +316,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints);
}
+ public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags)
+ {
+ m_OSSL_Functions.osMessageAttachments(avatar, message, attachmentPoints, flags);
+ }
+
#endregion
// Texture Draw functions
--
cgit v1.1
From 07dbe46ba3c2b949c9da34eaa80d7e1afd68fece Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 1 Sep 2012 02:45:07 +0100
Subject: wrapping attachment functions in a region
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 ++
OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +-
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8e80b4c..2e1e5b6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3229,6 +3229,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ #region Attachment commands
+
public void osForceAttachToAvatar(int attachmentPoint)
{
CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index bde7a8e..3985e66 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -157,7 +157,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osAvatarPlayAnimation(string avatar, string animation);
void osAvatarStopAnimation(string avatar, string animation);
- // Attachment commands
+ #region Attachment commands
///
/// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 08ebfd6..52ca3da 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,7 +289,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
}
- // Avatar functions
+ #region Attachment commands
public void osForceAttachToAvatar(int attachmentPoint)
{
--
cgit v1.1
From 15d5f3d09d140a0850d968fd3b738afc0b1f3985 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 4 Sep 2012 00:11:14 +0100
Subject: Bump master code up to 0.7.5 now that 0.7.4 is out.
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 5f01788..c9d9770 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,7 +29,7 @@ namespace OpenSim
{
public class VersionInfo
{
- private const string VERSION_NUMBER = "0.7.4";
+ private const string VERSION_NUMBER = "0.7.5";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
--
cgit v1.1
From 641b08aa781fcf4c1bf6d8425c98a302f96a8b88 Mon Sep 17 00:00:00 2001
From: Mic Bowman
Date: Wed, 5 Sep 2012 09:13:16 -0700
Subject: Enables cast from int to float for MOD* functions; Thanks
SignpostMarv!
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 84cf6ca..cde2d9f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -310,7 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// ---------- Integer ----------
else if (lslparm is LSL_Integer)
{
- if (type == typeof(int))
+ if (type == typeof(int) || type == typeof(float))
return (int)(LSL_Integer)lslparm;
}
--
cgit v1.1
From a0d0c9f751f45d54772af2e33866b27c9be33511 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 6 Sep 2012 00:11:47 +0100
Subject: If the GetTexture capability receives a request for a range of data
beyond that of an otherwise valid asset, return HTTP PartialContent rather
than RequestedRangeNotSatisfiable.
This is because recent viewers (3.2.1, 3.3.4) and probably earlier ones using the http GetTexture capability will sometimes make such invalid range requests.
This appears to happen if the viewer's estimate of texture sizes at discard levels > 0 (chiefly 2) exceeds the total texture size.
I believe this does not normally happen but can occur for dynamic textures with are large but mainly blank.
If this happens, returning a RequestedRangeNotSatisfiable will cause the viewer to not render the texture at the final resolution.
However, returning a PartialContent (or OK) even with 0 data will allow the viewer to render the final texture.
---
.../Handlers/GetTexture/GetTextureHandler.cs | 34 ++++++++++++++++++----
.../DynamicTexture/DynamicTextureModule.cs | 16 ++++++++--
.../Scripting/VectorRender/VectorRenderModule.cs | 20 +++++++++++++
3 files changed, 62 insertions(+), 8 deletions(-)
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index ae6c44b..9b43a80 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -163,7 +163,7 @@ namespace OpenSim.Capabilities.Handlers
if (texture == null)
{
- //m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
+// m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
// Fetch locally or remotely. Misses return a 404
texture = m_assetService.Get(textureID.ToString());
@@ -197,7 +197,7 @@ namespace OpenSim.Capabilities.Handlers
}
else // it was on the cache
{
- //m_log.DebugFormat("[GETTEXTURE]: texture was in the cache");
+// m_log.DebugFormat("[GETTEXTURE]: texture was in the cache");
WriteTextureData(httpRequest, httpResponse, texture, format);
return true;
}
@@ -219,12 +219,30 @@ namespace OpenSim.Capabilities.Handlers
int start, end;
if (TryParseRange(range, out start, out end))
{
-
// Before clamping start make sure we can satisfy it in order to avoid
// sending back the last byte instead of an error status
if (start >= texture.Data.Length)
{
- response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
+ m_log.DebugFormat(
+ "[GETTEXTURE]: Client requested range for texture {0} starting at {1} but texture has end of {2}",
+ texture.ID, start, texture.Data.Length);
+
+ // Stricly speaking, as per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, we should be sending back
+ // Requested Range Not Satisfiable (416) here. However, it appears that at least recent implementations
+ // of the Linden Lab viewer (3.2.1 and 3.3.4 and probably earlier), a viewer that has previously
+ // received a very small texture may attempt to fetch bytes from the server past the
+ // range of data that it received originally. Whether this happens appears to depend on whether
+ // the viewer's estimation of how large a request it needs to make for certain discard levels
+ // (http://wiki.secondlife.com/wiki/Image_System#Discard_Level_and_Mip_Mapping), chiefly discard
+ // level 2. If this estimate is greater than the total texture size, returning a RequestedRangeNotSatisfiable
+ // here will cause the viewer to treat the texture as bad and never display the full resolution
+ // However, if we return PartialContent (or OK) instead, the viewer will display that resolution.
+
+// response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
+// response.AddHeader("Content-Range", String.Format("bytes */{0}", texture.Data.Length));
+// response.StatusCode = (int)System.Net.HttpStatusCode.OK;
+ response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
+ response.ContentType = texture.Metadata.ContentType;
}
else
{
@@ -232,12 +250,18 @@ namespace OpenSim.Capabilities.Handlers
start = Utils.Clamp(start, 0, end);
int len = end - start + 1;
- //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
+// m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
// Always return PartialContent, even if the range covered the entire data length
// We were accidentally sending back 404 before in this situation
// https://issues.apache.org/bugzilla/show_bug.cgi?id=51878 supports sending 206 even if the
// entire range is requested, and viewer 3.2.2 (and very probably earlier) seems fine with this.
+ //
+ // We also do not want to send back OK even if the whole range was satisfiable since this causes
+ // HTTP textures on at least Imprudence 1.4.0-beta2 to never display the final texture quality.
+// if (end > maxEnd)
+// response.StatusCode = (int)System.Net.HttpStatusCode.OK;
+// else
response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
response.ContentLength = len;
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 3eedf49..e09f1a9 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
{
public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
{
- //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const int ALL_SIDES = -1;
@@ -249,10 +249,18 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
}
}
+// m_log.DebugFormat(
+// "[DYNAMIC TEXTURE MODULE]: Requesting generation of new dynamic texture for {0} in {1}",
+// part.Name, part.ParentGroup.Scene.Name);
+
RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
}
else
{
+// m_log.DebugFormat(
+// "[DYNAMIC TEXTURE MODULE]: Reusing cached texture {0} for {1} in {2}",
+// objReusableTextureUUID, part.Name, part.ParentGroup.Scene.Name);
+
// No need to add to updaters as the texture is always the same. Not that this functionality
// apppears to be implemented anyway.
updater.UpdatePart(part, (UUID)objReusableTextureUUID);
@@ -448,8 +456,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface();
if (cacheLayerDecode != null)
{
- cacheLayerDecode.Decode(asset.FullID, asset.Data);
- cacheLayerDecode = null;
+ if (!cacheLayerDecode.Decode(asset.FullID, asset.Data))
+ m_log.WarnFormat(
+ "[DYNAMIC TEXTURE MODULE]: Decoding of dynamically generated asset {0} for {1} in {2} failed",
+ asset.ID, part.Name, part.ParentGroup.Scene.Name);
}
UUID oldID = UpdatePart(part, asset.FullID);
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 4268f2e..0e7051e 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -46,6 +46,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
{
public class VectorRenderModule : IRegionModule, IDynamicTextureRender
{
+ // These fields exist for testing purposes, please do not remove.
+// private static bool s_flipper;
+// private static byte[] s_asset1Data;
+// private static byte[] s_asset2Data;
+
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
@@ -161,6 +166,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
{
m_textureManager.RegisterRender(GetContentType(), this);
}
+
+ // This code exists for testing purposes, please do not remove.
+// s_asset1Data = m_scene.AssetService.Get("00000000-0000-1111-9999-000000000001").Data;
+// s_asset1Data = m_scene.AssetService.Get("9f4acf0d-1841-4e15-bdb8-3a12efc9dd8f").Data;
+
+ // Terrain dirt - smallest bin/assets file (6004 bytes)
+// s_asset2Data = m_scene.AssetService.Get("b8d3965a-ad78-bf43-699b-bff8eca6c975").Data;
}
public void Close()
@@ -364,6 +376,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
}
byte[] imageJ2000 = new byte[0];
+
+ // This code exists for testing purposes, please do not remove.
+// if (s_flipper)
+// imageJ2000 = s_asset1Data;
+// else
+// imageJ2000 = s_asset2Data;
+//
+// s_flipper = !s_flipper;
try
{
--
cgit v1.1
From 5eb2526e889cd49d1c77e6e057f847cfd990268f Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Thu, 6 Sep 2012 05:13:10 -0400
Subject: 0006270: Warp3D leaks memory on mono based systems
Thanks Hiro Lecker for a patch to reduce memory useage with Warp3D map module
---
CONTRIBUTORS.txt | 1 +
OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 22b29a9..f334b3d 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -92,6 +92,7 @@ what it is today.
* Flyte Xevious
* Garmin Kawaguichi
* Gryc Ueusp
+* Hiro Lecker
* Imaze Rhiano
* Intimidated
* Jeremy Bongio (IBM)
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
index 9002a9f..ed9b127 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
@@ -208,6 +208,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height);
}
+ GC.Collect();
+ m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()");
+
return bitmap;
}
@@ -673,4 +676,4 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
return result;
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1
From 0a71e3ab3961bb0a0d440fb2c18f9c5eb1a28148 Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Thu, 6 Sep 2012 05:23:05 -0400
Subject: Add file to .gitignore
Add OpenSim.userprefs which is created by Monodevelop to .gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 1e41243..39a8333 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,6 +66,7 @@ Examples/*.dll
OpenSim.build
OpenSim.sln
OpenSim.suo
+OpenSim.userprefs
Prebuild/Prebuild.build
Prebuild/Prebuild.sln
TestResult.xml
--
cgit v1.1
From 3f6c6eed33a4d6101180abd4c14d0d0faab9c5d7 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Wed, 5 Sep 2012 11:25:37 +0100
Subject: pasting in show uptime code
Signed-off-by: BlueWall
---
OpenSim/Server/Base/ServicesServerBase.cs | 41 +++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index b137c05..0cff6ed 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -26,6 +26,7 @@
*/
using System;
+using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading;
@@ -71,10 +72,17 @@ namespace OpenSim.Server.Base
//
private string m_pidFile = String.Empty;
+ ///
+ /// Time at which this server was started
+ ///
+ protected DateTime m_startuptime;
+
// Handle all the automagical stuff
//
public ServicesServerBase(string prompt, string[] args)
{
+ m_startuptime = DateTime.Now;
+
// Save raw arguments
//
m_Arguments = args;
@@ -250,6 +258,10 @@ namespace OpenSim.Server.Base
"command-script