From 8428b25939d39711e732eeb3928e8a8e64aad8a9 Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Mon, 26 Oct 2009 00:10:23 +0100
Subject: Add llRotLookat pt1.
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 39 ++++++++++
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 ++++
.../BasicPhysicsPlugin/BasicPhysicsActor.cs | 20 ++++++
.../BulletDotNETPlugin/BulletDotNETCharacter.cs | 6 ++
.../Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | 5 ++
.../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 20 ++++++
OpenSim/Region/Physics/Manager/PhysicsActor.cs | 13 +++-
OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 22 ++++++
OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | 4 +-
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 83 ++++++++++++++++------
OpenSim/Region/Physics/POSPlugin/POSCharacter.cs | 21 ++++++
OpenSim/Region/Physics/POSPlugin/POSPrim.cs | 20 ++++++
OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 44 ++++++++++++
.../Shared/Api/Implementation/LSL_Api.cs | 18 +++--
14 files changed, 296 insertions(+), 31 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 69b3ded..fff807a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1727,6 +1727,45 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public void rotLookAt(Quaternion target, float strength, float damping)
+ {
+ SceneObjectPart rootpart = m_rootPart;
+ if (rootpart != null)
+ {
+ if (IsAttachment)
+ {
+ /*
+ ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
+ if (avatar != null)
+ {
+ Rotate the Av?
+ } */
+ }
+ else
+ {
+ if (rootpart.PhysActor != null)
+ {
+ rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W);
+ rootpart.PhysActor.APIDStrength = strength;
+ rootpart.PhysActor.APIDDamping = damping;
+ rootpart.PhysActor.APIDActive = true;
+ }
+ }
+ }
+ }
+ public void stopLookAt()
+ {
+ SceneObjectPart rootpart = m_rootPart;
+ if (rootpart != null)
+ {
+ if (rootpart.PhysActor != null)
+ {
+ rootpart.PhysActor.APIDActive = false;
+ }
+ }
+
+ }
+
///
/// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 32171a0..5f46f6f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2187,6 +2187,11 @@ if (m_shape != null) {
ParentGroup.HasGroupChanged = true;
ScheduleFullUpdate();
}
+
+ public void RotLookAt(Quaternion target, float strength, float damping)
+ {
+ m_parentGroup.rotLookAt(target, strength, damping);
+ }
///
/// Schedules this prim for a full update
@@ -2662,6 +2667,13 @@ if (m_shape != null) {
SetText(text);
}
+ public void StopLookAt()
+ {
+ m_parentGroup.stopLookAt();
+
+ m_parentGroup.ScheduleGroupForTerseUpdate();
+ }
+
public void StopMoveToTarget()
{
m_parentGroup.stopMoveToTarget();
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
index 8d8b3fe..2b905b6 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
@@ -307,6 +307,26 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
set { return; }
}
+ public override Quaternion APIDTarget
+ {
+ set { return; }
+ }
+
+ public override bool APIDActive
+ {
+ set { return; }
+ }
+
+ public override float APIDStrength
+ {
+ set { return; }
+ }
+
+ public override float APIDDamping
+ {
+ set { return; }
+ }
+
public override void SubscribeEvents(int ms)
{
}
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
index 8da9687..d7aed3c 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
@@ -627,6 +627,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{
set { return; }
}
+
+ public override Quaternion APIDTarget { set { return; } }
+ public override bool APIDActive { set { return; } }
+ public override float APIDStrength { set { return; } }
+ public override float APIDDamping { set { return; } }
+
///
/// Adds the force supplied to the Target Velocity
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index f22ea71..977b463 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -566,6 +566,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
+ public override Quaternion APIDTarget { set { return; } }
+ public override bool APIDActive { set { return; } }
+ public override float APIDStrength { set { return; } }
+ public override float APIDDamping { set { return; } }
+
public override void AddForce(PhysicsVector force, bool pushforce)
{
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index abed8df..14b8f39 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -1236,6 +1236,26 @@ namespace OpenSim.Region.Physics.BulletXPlugin
public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } }
+ public override OpenMetaverse.Quaternion APIDTarget
+ {
+ set { return; }
+ }
+
+ public override bool APIDActive
+ {
+ set { return; }
+ }
+
+ public override float APIDStrength
+ {
+ set { return; }
+ }
+
+ public override float APIDDamping
+ {
+ set { return; }
+ }
+
public override void SubscribeEvents(int ms)
{
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 7603131..566746a 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -230,7 +230,12 @@ namespace OpenSim.Region.Physics.Manager
public abstract PIDHoverType PIDHoverType { set;}
public abstract float PIDHoverTau { set;}
-
+ // For RotLookAt
+ public abstract Quaternion APIDTarget { set;}
+ public abstract bool APIDActive { set;}
+ public abstract float APIDStrength { set;}
+ public abstract float APIDDamping { set;}
+
public abstract void AddForce(PhysicsVector force, bool pushforce);
public abstract void AddAngularForce(PhysicsVector force, bool pushforce);
public abstract void SetMomentum(PhysicsVector momentum);
@@ -463,6 +468,12 @@ namespace OpenSim.Region.Physics.Manager
public override bool PIDHoverActive { set { return; } }
public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } }
+
+ public override Quaternion APIDTarget { set { return; } }
+ public override bool APIDActive { set { return; } }
+ public override float APIDStrength { set { return; } }
+ public override float APIDDamping { set { return; } }
+
public override void SetMomentum(PhysicsVector momentum)
{
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 71ace16..8272083 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -1205,6 +1205,28 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool PIDHoverActive { set { return; } }
public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } }
+
+ public override Quaternion APIDTarget
+ {
+ set { return; }
+ }
+
+ public override bool APIDActive
+ {
+ set { return; }
+ }
+
+ public override float APIDStrength
+ {
+ set { return; }
+ }
+
+ public override float APIDDamping
+ {
+ set { return; }
+ }
+
+
public override void SubscribeEvents(int ms)
{
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 467eba0..8b57f06 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -119,7 +119,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_VhoverEfficiency = 0f;
private float m_VhoverTimescale = 0f;
private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
- private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle.
+ private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle.
// Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
// KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
// Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.
@@ -478,7 +478,7 @@ namespace OpenSim.Region.Physics.OdePlugin
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
m_dir *= rotq; // apply obj rotation to velocity vector
- // add Gravity andBuoyancy
+ // add Gravity and Buoyancy
// KF: So far I have found no good method to combine a script-requested
// .Z velocity and gravity. Therefore only 0g will used script-requested
// .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index f59f0ae..e1bf996 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1,15 +1,4 @@
/*
- * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
- * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
- * ODEPrim.cs contains methods dealing with Prim editing, Prim
- * characteristics and Kinetic motion.
- * ODEDynamics.cs contains methods dealing with Prim Physical motion
- * (dynamics) and the associated settings. Old Linear and angular
- * motors for dynamic motion have been replace with MoveLinear()
- * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
- * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
- * switch between 'VEHICLE' parameter use and general dynamics
- * settings use.
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@@ -34,6 +23,18 @@
* 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.
+ *
+ * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
+ * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
+ * ODEPrim.cs contains methods dealing with Prim editing, Prim
+ * characteristics and Kinetic motion.
+ * ODEDynamics.cs contains methods dealing with Prim Physical motion
+ * (dynamics) and the associated settings. Old Linear and angular
+ * motors for dynamic motion have been replace with MoveLinear()
+ * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
+ * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
+ * switch between 'VEHICLE' parameter use and general dynamics
+ * settings use.
*/
using System;
using System.Collections.Generic;
@@ -82,6 +83,14 @@ namespace OpenSim.Region.Physics.OdePlugin
private float PID_D = 35f;
private float PID_G = 25f;
private bool m_usePID = false;
+
+ private Quaternion m_APIDTarget = new Quaternion();
+ private float m_APIDStrength = 0.5f;
+ private float m_APIDDamping = 0.5f;
+
+ private float APID_D = 35f;
+ private float APID_G = 25f;
+ private bool m_useAPID = false;
// KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
// and are for non-VEHICLES only.
@@ -93,7 +102,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_targetHoverHeight = 0f;
private float m_groundHeight = 0f;
private float m_waterHeight = 0f;
- private float m_buoyancy = 0f; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
+ private float m_buoyancy = 0f; //Set by llSetBuoyancy(), for non-vehicles.
// private float m_tensor = 5f;
private int body_autodisable_frames = 20;
@@ -1586,21 +1595,18 @@ Console.WriteLine(" JointCreateFixed");
//m_log.Info(m_collisionFlags.ToString());
- //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
- // would come from SceneObjectPart.cs, public void SetBuoyancy(float fvalue) , PhysActor.Buoyancy = fvalue; ??
+ //KF: m_buoyancy is set by llSetBuoyancy() and is for non-vehicle.
// m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
- // gravityz multiplier = 1 - m_buoyancy
- fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass;
+ // NB Prims in ODE are no subject to global gravity
+ fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; // force = acceleration * mass
if (m_usePID)
{
//Console.WriteLine("PID " + m_primName);
- // KF - this is for object move? eg. llSetPos() ?
+ // KF - this is for object MoveToTarget.
+
//if (!d.BodyIsEnabled(Body))
//d.BodySetForce(Body, 0f, 0f, 0f);
- // If we're using the PID controller, then we have no gravity
- //fz = (-1 * _parent_scene.gravityz) * m_mass; //KF: ?? Prims have no global gravity,so simply...
- fz = 0f;
// no lock; for now it's only called from within Simulate()
@@ -1744,8 +1750,37 @@ Console.WriteLine(" JointCreateFixed");
// We're flying and colliding with something
fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
}
- }
+ } // end m_useHoverPID && !m_usePID
+
+ if (m_useAPID)
+ {
+ // RotLookAt, apparently overrides all other rotation sources. Inputs:
+ // Quaternion m_APIDTarget
+ // float m_APIDStrength // perhaps ratio other forces to lookat force?
+ // float m_APIDDamping //'seconds to critically damps in'[sic]
+ // Factors:
+ // float APID_D
+ // float APID_G
+
+ // get present body rotation
+ d.Quaternion rot = d.BodyGetQuaternion(Body);
+ Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
+ Quaternion rot_diff = Quaternion.Inverse(rotq) * m_APIDTarget;
+ float diff_angle;
+ Vector3 diff_axis;
+ rot_diff.GetAxisAngle(out diff_axis, out diff_angle);
+ diff_axis.Normalize();
+ PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
+ float RLAservo = timestep / m_APIDDamping;
+ rotforce = rotforce * RLAservo * m_mass;
+ d.BodyAddTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
+
+ // d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
+
+
+ } // end m_useAPID
+
fx *= m_mass;
fy *= m_mass;
//fz *= m_mass;
@@ -2778,6 +2813,12 @@ Console.WriteLine(" JointCreateFixed");
}
public override bool PIDActive { set { m_usePID = value; } }
public override float PIDTau { set { m_PIDTau = value; } }
+
+ // For RotLookAt
+ public override Quaternion APIDTarget { set { m_APIDTarget = value; } }
+ public override bool APIDActive { set { m_useAPID = value; } }
+ public override float APIDStrength { set { m_APIDStrength = value; } }
+ public override float APIDDamping { set { m_APIDDamping = value; } }
public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } }
public override bool PIDHoverActive { set { m_useHoverPID = value; } }
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
index 35fc616..135f49e 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
@@ -307,6 +307,27 @@ namespace OpenSim.Region.Physics.POSPlugin
{
set { return; }
}
+
+ public override Quaternion APIDTarget
+ {
+ set { return; }
+ }
+
+ public override bool APIDActive
+ {
+ set { return; }
+ }
+
+ public override float APIDStrength
+ {
+ set { return; }
+ }
+
+ public override float APIDDamping
+ {
+ set { return; }
+ }
+
public override void SubscribeEvents(int ms)
{
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
index b50364b..4521dce 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
@@ -302,6 +302,26 @@ namespace OpenSim.Region.Physics.POSPlugin
{
set { return; }
}
+ public override Quaternion APIDTarget
+ {
+ set { return; }
+ }
+
+ public override bool APIDActive
+ {
+ set { return; }
+ }
+
+ public override float APIDStrength
+ {
+ set { return; }
+ }
+
+ public override float APIDDamping
+ {
+ set { return; }
+ }
+
public override void SubscribeEvents(int ms)
{
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index e7d989c..b3bf70b 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -500,6 +500,28 @@ namespace OpenSim.Region.Physics.PhysXPlugin
public override bool PIDHoverActive { set { return; } }
public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } }
+
+ public override Quaternion APIDTarget
+ {
+ set { return; }
+ }
+
+ public override bool APIDActive
+ {
+ set { return; }
+ }
+
+ public override float APIDStrength
+ {
+ set { return; }
+ }
+
+ public override float APIDDamping
+ {
+ set { return; }
+ }
+
+
public override void SubscribeEvents(int ms)
{
@@ -782,6 +804,28 @@ namespace OpenSim.Region.Physics.PhysXPlugin
public override bool PIDHoverActive { set { return; } }
public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } }
+
+ public override Quaternion APIDTarget
+ {
+ set { return; }
+ }
+
+ public override bool APIDActive
+ {
+ set { return; }
+ }
+
+ public override float APIDStrength
+ {
+ set { return; }
+ }
+
+ public override float APIDDamping
+ {
+ set { return; }
+ }
+
+
public override void SubscribeEvents(int ms)
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 11f255f..1dc20ff 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2694,11 +2694,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// Orient the object to the angle calculated
llSetRot(rot);
}
+
+ public void llRotLookAt(LSL_Rotation target, double strength, double damping)
+ {
+ m_host.AddScriptLPS(1);
+// NotImplemented("llRotLookAt");
+ m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
+
+ }
+
public void llStopLookAt()
{
m_host.AddScriptLPS(1);
- NotImplemented("llStopLookAt");
+// NotImplemented("llStopLookAt");
+ m_host.StopLookAt();
}
public void llSetTimerEvent(double sec)
@@ -3042,12 +3052,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
}
- public void llRotLookAt(LSL_Rotation target, double strength, double damping)
- {
- m_host.AddScriptLPS(1);
- NotImplemented("llRotLookAt");
- }
-
public LSL_Integer llStringLength(string str)
{
m_host.AddScriptLPS(1);
--
cgit v1.1
From a81a16f22f7af6d102f365f69a50c5d201ae8362 Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Tue, 27 Oct 2009 19:56:39 +0100
Subject: llRotLookAt Pt 2
---
OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | 34 ++++++++-------
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 55 +++++++++++++++----------
2 files changed, 52 insertions(+), 37 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 8b57f06..0c168c6 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -1,16 +1,4 @@
/*
- * Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
- * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
- * ODEPrim.cs contains methods dealing with Prim editing, Prim
- * characteristics and Kinetic motion.
- * ODEDynamics.cs contains methods dealing with Prim Physical motion
- * (dynamics) and the associated settings. Old Linear and angular
- * motors for dynamic motion have been replace with MoveLinear()
- * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
- * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
- * switch between 'VEHICLE' parameter use and general dynamics
- * settings use.
- *
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@@ -35,6 +23,19 @@
* 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.
+ *
+ * Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
+ * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
+ * ODEPrim.cs contains methods dealing with Prim editing, Prim
+ * characteristics and Kinetic motion.
+ * ODEDynamics.cs contains methods dealing with Prim Physical motion
+ * (dynamics) and the associated settings. Old Linear and angular
+ * motors for dynamic motion have been replace with MoveLinear()
+ * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
+ * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
+ * switch between 'VEHICLE' parameter use and general dynamics
+ * settings use.
+ *
*/
using System;
@@ -66,8 +67,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// private OdeScene m_parentScene = null;
private IntPtr m_body = IntPtr.Zero;
- private IntPtr m_jointGroup = IntPtr.Zero;
- private IntPtr m_aMotor = IntPtr.Zero;
+// private IntPtr m_jointGroup = IntPtr.Zero;
+// private IntPtr m_aMotor = IntPtr.Zero;
// Vehicle properties
@@ -560,6 +561,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
*/
+//if(frcount == 0) Console.WriteLine("MoveAngular ");
// Get what the body is doing, this includes 'external' influences
d.Vector3 angularVelocity = d.BodyGetAngularVel(Body);
@@ -614,7 +616,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Error is 0 (no error) to +/- 2 (max error)
// scale it by VAservo
verterr = verterr * VAservo;
-//if(frcount == 0) Console.WriteLine("VAerr=" + verterr);
+if(frcount == 0) Console.WriteLine("VAerr=" + verterr);
// As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so
// Change Body angular velocity X based on Y, and Y based on X. Z is not changed.
@@ -635,7 +637,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Deflection section tba
// Sum velocities
- m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection
+ m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // tba: + bank + deflection
if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
{
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index e1bf996..93c9a44 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -87,9 +87,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private Quaternion m_APIDTarget = new Quaternion();
private float m_APIDStrength = 0.5f;
private float m_APIDDamping = 0.5f;
-
- private float APID_D = 35f;
- private float APID_G = 25f;
private bool m_useAPID = false;
// KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
@@ -192,6 +189,9 @@ namespace OpenSim.Region.Physics.OdePlugin
private ODEDynamics m_vehicle;
internal int m_material = (int)Material.Wood;
+
+ private int frcount = 0; // Used to limit dynamics debug output to
+
public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
@@ -1563,9 +1563,14 @@ Console.WriteLine(" JointCreateFixed");
float fy = 0;
float fz = 0;
+ frcount++; // used to limit debug comment output
+ if (frcount > 100)
+ frcount = 0;
if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims.
{
+if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle.Type +
+ " usePID=" + m_usePID + " seHover=" + m_useHoverPID + " useAPID=" + m_useAPID);
if (m_vehicle.Type != Vehicle.TYPE_NONE)
{
// 'VEHICLES' are dealt with in ODEDynamics.cs
@@ -1573,7 +1578,6 @@ Console.WriteLine(" JointCreateFixed");
}
else
{
-//Console.WriteLine("Move " + m_primName);
if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
// NON-'VEHICLES' are dealt with here
if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f))
@@ -1602,7 +1606,7 @@ Console.WriteLine(" JointCreateFixed");
if (m_usePID)
{
-//Console.WriteLine("PID " + m_primName);
+//if(frcount == 0) Console.WriteLine("PID " + m_primName);
// KF - this is for object MoveToTarget.
//if (!d.BodyIsEnabled(Body))
@@ -1741,7 +1745,7 @@ Console.WriteLine(" JointCreateFixed");
d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
d.BodyAddForce(Body, 0, 0, fz);
- return;
+ //KF this prevents furthur motions return;
}
else
{
@@ -1756,13 +1760,16 @@ Console.WriteLine(" JointCreateFixed");
{
// RotLookAt, apparently overrides all other rotation sources. Inputs:
// Quaternion m_APIDTarget
- // float m_APIDStrength // perhaps ratio other forces to lookat force?
- // float m_APIDDamping //'seconds to critically damps in'[sic]
+ // float m_APIDStrength // From SL experiments, this is the time to get there
+ // float m_APIDDamping // From SL experiments, this is damping, 1.0 = damped, 0.1 = wobbly
+ // Also in SL the mass of the object has no effect on time to get there.
// Factors:
- // float APID_D
- // float APID_G
-
+//if(frcount == 0) Console.WriteLine("APID ");
// get present body rotation
+ float limit = 1.0f;
+ float scaler = 50f; // adjusts damping time
+ float RLAservo = 0f;
+
d.Quaternion rot = d.BodyGetQuaternion(Body);
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
Quaternion rot_diff = Quaternion.Inverse(rotq) * m_APIDTarget;
@@ -1770,15 +1777,21 @@ Console.WriteLine(" JointCreateFixed");
Vector3 diff_axis;
rot_diff.GetAxisAngle(out diff_axis, out diff_angle);
diff_axis.Normalize();
- PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
- float RLAservo = timestep / m_APIDDamping;
- rotforce = rotforce * RLAservo * m_mass;
- d.BodyAddTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
-
- // d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
-
-
-
+ if(diff_angle > 0.01f) // diff_angle is always +ve
+ {
+// PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
+ Vector3 rotforce = new Vector3(diff_axis.X, diff_axis.Y, diff_axis.Z);
+ rotforce = rotforce * rotq;
+ if(diff_angle > limit) diff_angle = limit; // cap the rotate rate
+// RLAservo = timestep / m_APIDStrength * m_mass * scaler;
+ // rotforce = rotforce * RLAservo * diff_angle ;
+ // d.BodyAddRelTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
+ RLAservo = timestep / m_APIDStrength * scaler;
+ rotforce = rotforce * RLAservo * diff_angle ;
+ d.BodySetAngularVel (Body, rotforce.X, rotforce.Y, rotforce.Z);
+//Console.WriteLine("axis= " + diff_axis + " angle= " + diff_angle + "servo= " + RLAservo);
+ }
+if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo + " angle= " + diff_angle);
} // end m_useAPID
fx *= m_mass;
@@ -2674,7 +2687,7 @@ Console.WriteLine(" JointCreateFixed");
//outofBounds = true;
}
- float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation));
+// float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation));
//Console.WriteLine("Adiff " + m_primName + " = " + Adiff);
if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02)
&& (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02)
--
cgit v1.1
From 28aa8010b2b47b73c6b867ff8f6284f98f12f37a Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 15 Nov 2009 21:38:38 +0100
Subject: - Lower TIME_MS_TOLERANCE to 200ms - Allow m_updateFlag to be reset
to 0 in the event of a terse update being rejected - Re-add a synchronous
SendTo for certain types of packets
---
.../Region/ClientStack/LindenUDP/LLUDPServer.cs | 24 ++++++++++++++++++++--
.../Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 18 ++++++++++++++++
.../Region/ClientStack/LindenUDP/OutgoingPacket.cs | 4 +++-
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 ++++++----------
4 files changed, 49 insertions(+), 15 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index c773c05..0b05ed9 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -399,6 +399,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Queue or Send
OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category);
+ outgoingPacket.Type = type;
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
SendPacketFinal(outgoingPacket);
@@ -510,6 +511,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
byte flags = buffer.Data[0];
bool isResend = (flags & Helpers.MSG_RESENT) != 0;
bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
+ bool sendSynchronous = false;
LLUDPClient udpClient = outgoingPacket.Client;
if (!udpClient.IsConnected)
@@ -565,9 +567,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (isReliable)
Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength);
- // Put the UDP payload on the wire
- AsyncBeginSend(buffer);
+ //Some packet types need to be sent synchonously.
+ //Sorry, i know it's not optimal, but until the LL client
+ //manages packets correctly and re-orders them as required, this is necessary.
+
+ if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate
+ || outgoingPacket.Type == PacketType.ChatFromSimulator
+ || outgoingPacket.Type == PacketType.ObjectUpdate
+ || outgoingPacket.Type == PacketType.LayerData)
+ {
+ sendSynchronous = true;
+ }
+ // Put the UDP payload on the wire
+ if (sendSynchronous == true)
+ {
+ SyncBeginSend(buffer);
+ }
+ else
+ {
+ AsyncBeginSend(buffer);
+ }
// Keep track of when this packet was sent out (right now)
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
index d2779ba..63579ac 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
@@ -246,6 +246,24 @@ namespace OpenMetaverse
}
}
+ public void SyncBeginSend(UDPPacketBuffer buf)
+ {
+ if (!m_shutdownFlag)
+ {
+ try
+ {
+ m_udpSocket.SendTo(
+ buf.Data,
+ 0,
+ buf.DataLength,
+ SocketFlags.None,
+ buf.RemoteEndPoint);
+ }
+ catch (SocketException) { }
+ catch (ObjectDisposedException) { }
+ }
+ }
+
public void AsyncBeginSend(UDPPacketBuffer buf)
{
if (!m_shutdownFlag)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
index 1a1a1cb..7dc42d3 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
@@ -28,6 +28,7 @@
using System;
using OpenSim.Framework;
using OpenMetaverse;
+using OpenMetaverse.Packets;
namespace OpenSim.Region.ClientStack.LindenUDP
{
@@ -52,7 +53,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public int TickCount;
/// Category this packet belongs to
public ThrottleOutPacketType Category;
-
+ /// The type of packet so its delivery method can be determined
+ public PacketType Type;
///
/// Default constructor
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 73d0984..c0fd437 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1064,14 +1064,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- ///
- /// Clear all pending updates of parts to clients
- ///
- private void ClearUpdateSchedule()
- {
- m_updateFlag = 0;
- }
-
private void SendObjectPropertiesToClient(UUID AgentID)
{
ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
@@ -2387,8 +2379,8 @@ namespace OpenSim.Region.Framework.Scenes
{
const float ROTATION_TOLERANCE = 0.01f;
const float VELOCITY_TOLERANCE = 0.001f;
- const float POSITION_TOLERANCE = 0.05f;
- const int TIME_MS_TOLERANCE = 3000;
+ const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
+ const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
if (m_updateFlag == 1)
{
@@ -2401,7 +2393,7 @@ namespace OpenSim.Region.Framework.Scenes
Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
{
AddTerseUpdateToAllAvatars();
- ClearUpdateSchedule();
+
// This causes the Scene to 'poll' physical objects every couple of frames
// bad, so it's been replaced by an event driven method.
@@ -2419,13 +2411,15 @@ namespace OpenSim.Region.Framework.Scenes
m_lastAngularVelocity = AngularVelocity;
m_lastTerseSent = Environment.TickCount;
}
+ //Moved this outside of the if clause so updates don't get blocked.. *sigh*
+ m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams*
}
else
{
if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
{
AddFullUpdateToAllAvatars();
- ClearUpdateSchedule();
+ m_updateFlag = 0; //Same here
}
}
}
--
cgit v1.1
From b7f1fc116eb37a651a80bc09df11fa47540a1df9 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 15 Nov 2009 20:21:46 +0000
Subject: Prevent a nullref if a recipient of a group message gas left the
scene
---
.../Avatar/InstantMessage/OfflineMessageModule.cs | 27 ++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 1614b70..7f9e5af 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -164,19 +164,22 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
Listmsglist = SynchronousRestObjectPoster.BeginPostObject>(
"POST", m_RestURL+"/RetrieveMessages/", client.AgentId);
- foreach (GridInstantMessage im in msglist)
+ if (msglist != null)
{
- // client.SendInstantMessage(im);
-
- // Send through scene event manager so all modules get a chance
- // to look at this message before it gets delivered.
- //
- // Needed for proper state management for stored group
- // invitations
- //
- Scene s = FindScene(client.AgentId);
- if (s != null)
- s.EventManager.TriggerIncomingInstantMessage(im);
+ foreach (GridInstantMessage im in msglist)
+ {
+ // client.SendInstantMessage(im);
+
+ // Send through scene event manager so all modules get a chance
+ // to look at this message before it gets delivered.
+ //
+ // Needed for proper state management for stored group
+ // invitations
+ //
+ Scene s = FindScene(client.AgentId);
+ if (s != null)
+ s.EventManager.TriggerIncomingInstantMessage(im);
+ }
}
}
--
cgit v1.1
From a49c524c9e93db1409f1f05d7b881922e178927c Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 15 Nov 2009 20:22:15 +0000
Subject: Add the ability to send messages to users ir regions via remote admin
---
.../RemoteController/RemoteAdminPlugin.cs | 48 ++++++++++++++++++++++
1 file changed, 48 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 3149eaa..3bc557d 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -123,6 +123,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod;
availableMethods["admin_shutdown"] = XmlRpcShutdownMethod;
availableMethods["admin_broadcast"] = XmlRpcAlertMethod;
+ availableMethods["admin_dialog"] = XmlRpcDialogMethod;
availableMethods["admin_restart"] = XmlRpcRestartMethod;
availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
// User management
@@ -277,6 +278,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController
m_log.Info("[RADMIN]: Alert request complete");
return response;
}
+ public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient)
+ {
+ XmlRpcResponse response = new XmlRpcResponse();
+ Hashtable responseData = new Hashtable();
+
+ m_log.Info("[RADMIN]: Dialog request started");
+
+ try
+ {
+ Hashtable requestData = (Hashtable)request.Params[0];
+
+ checkStringParameters(request, new string[] { "password", "from", "message" });
+
+ if (m_requiredPassword != String.Empty &&
+ (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword))
+ throw new Exception("wrong password");
+
+ string message = (string)requestData["message"];
+ string fromuuid = (string)requestData["from"];
+ m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
+
+ responseData["accepted"] = true;
+ responseData["success"] = true;
+ response.Value = responseData;
+
+ m_app.SceneManager.ForEachScene(
+ delegate(Scene scene)
+ {
+ IDialogModule dialogModule = scene.RequestModuleInterface();
+ if (dialogModule != null)
+ dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
+ });
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
+ m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
+
+ responseData["accepted"] = false;
+ responseData["success"] = false;
+ responseData["error"] = e.Message;
+ response.Value = responseData;
+ }
+
+ m_log.Info("[RADMIN]: Alert request complete");
+ return response;
+ }
public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
--
cgit v1.1
From b9546d12f230f4153b2c6e7e71520aa2d35c762b Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 15 Nov 2009 21:20:42 +0000
Subject: Change land packet sending back to what the careminster release used
to use, remove the silly spiral stuff. Revert to double packets for improved
user experience
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 83 +++++++++-------------
1 file changed, 34 insertions(+), 49 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 7eb829e..49b9378 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -785,6 +785,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual void SendLayerData(float[] map)
{
Util.FireAndForget(DoSendLayerData, map);
+
+ // Send it sync, and async. It's not that much data
+ // and it improves user experience just so much!
+ DoSendLayerData(map);
}
///
@@ -797,16 +801,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
try
{
- //for (int y = 0; y < 16; y++)
- //{
- // for (int x = 0; x < 16; x++)
- // {
- // SendLayerData(x, y, map);
- // }
- //}
-
- // Send LayerData in a spiral pattern. Fun!
- SendLayerTopRight(map, 0, 0, 15, 15);
+ for (int y = 0; y < 16; y++)
+ {
+ for (int x = 0; x < 16; x+=4)
+ {
+ SendLayerPacket(x, y, map);
+ }
+ }
}
catch (Exception e)
{
@@ -814,51 +815,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
- private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
- {
- // Row
- for (int i = x1; i <= x2; i++)
- SendLayerData(i, y1, map);
-
- // Column
- for (int j = y1 + 1; j <= y2; j++)
- SendLayerData(x2, j, map);
-
- if (x2 - x1 > 0)
- SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
- }
-
- void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
- {
- // Row in reverse
- for (int i = x2; i >= x1; i--)
- SendLayerData(i, y2, map);
-
- // Column in reverse
- for (int j = y2 - 1; j >= y1; j--)
- SendLayerData(x1, j, map);
-
- if (x2 - x1 > 0)
- SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
- }
-
///
/// Sends a set of four patches (x, x+1, ..., x+3) to the client
///
/// heightmap
/// X coordinate for patches 0..12
/// Y coordinate for patches 0..15
- // private void SendLayerPacket(float[] map, int y, int x)
- // {
- // int[] patches = new int[4];
- // patches[0] = x + 0 + y * 16;
- // patches[1] = x + 1 + y * 16;
- // patches[2] = x + 2 + y * 16;
- // patches[3] = x + 3 + y * 16;
-
- // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
- // OutPacket(layerpack, ThrottleOutPacketType.Land);
- // }
+ private void SendLayerPacket(int x, int y, float[] map)
+ {
+ int[] patches = new int[4];
+ patches[0] = x + 0 + y * 16;
+ patches[1] = x + 1 + y * 16;
+ patches[2] = x + 2 + y * 16;
+ patches[3] = x + 3 + y * 16;
+
+ float[] heightmap = (map.Length == 65536) ?
+ map :
+ LLHeightFieldMoronize(map);
+
+ try
+ {
+ Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
+ OutPacket(layerpack, ThrottleOutPacketType.Land);
+ }
+ catch
+ {
+ for (int px = x ; px < x + 4 ; px++)
+ SendLayerData(px, y, map);
+ }
+ }
///
/// Sends a specified patch to a client
--
cgit v1.1
From 4c10826caa4b2b19200ab3f0272bb1c20c26c53e Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Mon, 16 Nov 2009 02:12:56 +0100
Subject: Fix merge conflicts
---
OpenSim/Region/Physics/Manager/PhysicsActor.cs | 6 +++---
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 7 -------
2 files changed, 3 insertions(+), 10 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 8241e8f..b82586f 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -249,9 +249,9 @@ namespace OpenSim.Region.Physics.Manager
public abstract float APIDStrength { set;}
public abstract float APIDDamping { set;}
- public abstract void AddForce(PhysicsVector force, bool pushforce);
- public abstract void AddAngularForce(PhysicsVector force, bool pushforce);
- public abstract void SetMomentum(PhysicsVector momentum);
+ public abstract void AddForce(Vector3 force, bool pushforce);
+ public abstract void AddAngularForce(Vector3 force, bool pushforce);
+ public abstract void SetMomentum(Vector3 momentum);
public abstract void SubscribeEvents(int ms);
public abstract void UnSubscribeEvents();
public abstract bool SubscribedEvents();
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index b963d65..8f2c801 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -107,17 +107,10 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_PIDHoverTau;
private bool m_useHoverPID;
private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
-<<<<<<< HEAD:OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
- private float m_targetHoverHeight = 0f;
- private float m_groundHeight = 0f;
- private float m_waterHeight = 0f;
- private float m_buoyancy = 0f; //Set by llSetBuoyancy(), for non-vehicles.
-=======
private float m_targetHoverHeight;
private float m_groundHeight;
private float m_waterHeight;
private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
->>>>>>> vehicles:OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
// private float m_tensor = 5f;
private int body_autodisable_frames = 20;
--
cgit v1.1
From 7f0f5060ec418533ee7d952bdc0815f3925bda9f Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Thu, 19 Nov 2009 20:13:26 +0100
Subject: Clean up messages in ODE
---
OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | 2 +-
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 1842eb4..78b15be 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -629,7 +629,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Error is 0 (no error) to +/- 2 (max error)
// scale it by VAservo
verterr = verterr * VAservo;
-if(frcount == 0) Console.WriteLine("VAerr=" + verterr);
+//if(frcount == 0) Console.WriteLine("VAerr=" + verterr);
// As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so
// Change Body angular velocity X based on Y, and Y based on X. Z is not changed.
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 8f2c801..2bf96e4 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1584,8 +1584,8 @@ Console.WriteLine(" JointCreateFixed");
if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims.
{
-if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle.Type +
- " usePID=" + m_usePID + " seHover=" + m_useHoverPID + " useAPID=" + m_useAPID);
+//if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle.Type +
+ // " usePID=" + m_usePID + " seHover=" + m_useHoverPID + " useAPID=" + m_useAPID);
if (m_vehicle.Type != Vehicle.TYPE_NONE)
{
// 'VEHICLES' are dealt with in ODEDynamics.cs
@@ -1806,7 +1806,7 @@ if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle
d.BodySetAngularVel (Body, rotforce.X, rotforce.Y, rotforce.Z);
//Console.WriteLine("axis= " + diff_axis + " angle= " + diff_angle + "servo= " + RLAservo);
}
-if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo + " angle= " + diff_angle);
+//if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo + " angle= " + diff_angle);
} // end m_useAPID
fx *= m_mass;
--
cgit v1.1
From 0149265ee83581cf2fb150dcd5d8734c02926261 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Sat, 21 Nov 2009 15:36:38 +0100
Subject: Improved avatar responsiveness.
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 4 +-
.../Region/ClientStack/LindenUDP/LLUDPServer.cs | 24 +++---
.../Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 89 +++++++++++++++++++---
.../Scenes/Animation/ScenePresenceAnimator.cs | 4 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 10 +--
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 80 +++++++++++++++----
6 files changed, 163 insertions(+), 48 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 49b9378..39eb968 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3121,7 +3121,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = CreateAvatarUpdateBlock(data);
-
OutPacket(objupdate, ThrottleOutPacketType.Task);
}
@@ -3172,8 +3171,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue();
}
- // HACK: Using the task category until the tiered reprioritization code is in
- OutPacket(terse, ThrottleOutPacketType.Task);
+ OutPacket(terse, ThrottleOutPacketType.State);
}
public void SendCoarseLocationUpdate(List users, List CoarseLocations)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 0b05ed9..4a7bdfe 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -571,23 +571,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//Sorry, i know it's not optimal, but until the LL client
//manages packets correctly and re-orders them as required, this is necessary.
- if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate
- || outgoingPacket.Type == PacketType.ChatFromSimulator
- || outgoingPacket.Type == PacketType.ObjectUpdate
- || outgoingPacket.Type == PacketType.LayerData)
+
+ // Put the UDP payload on the wire
+ if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate)
{
- sendSynchronous = true;
+ SyncBeginPrioritySend(buffer, 2); // highest priority
}
-
- // Put the UDP payload on the wire
- if (sendSynchronous == true)
+ else if (outgoingPacket.Type == PacketType.ObjectUpdate
+ || outgoingPacket.Type == PacketType.ChatFromSimulator
+ || outgoingPacket.Type == PacketType.LayerData)
{
- SyncBeginSend(buffer);
+ SyncBeginPrioritySend(buffer, 1); // medium priority
}
else
{
- AsyncBeginSend(buffer);
+ SyncBeginPrioritySend(buffer, 0); // normal priority
}
+
+ //AsyncBeginSend(buffer);
+
// Keep track of when this packet was sent out (right now)
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
}
@@ -862,7 +864,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length);
- AsyncBeginSend(buffer);
+ SyncBeginPrioritySend(buffer, 1); //Setting this to a medium priority should help minimise resends
}
private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
index 63579ac..45d9170 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
@@ -29,6 +29,7 @@ using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
+using System.Collections.Generic;
using log4net;
namespace OpenMetaverse
@@ -52,12 +53,25 @@ namespace OpenMetaverse
/// Local IP address to bind to in server mode
protected IPAddress m_localBindAddress;
+ ///
+ /// Standard queue for our outgoing SyncBeginPrioritySend
+ ///
+ private List m_standardQueue = new List();
+
+ ///
+ /// Prioritised queue for our outgoing SyncBeginPrioritySend
+ ///
+ private List m_priorityQueue = new List();
+
/// UDP socket, used in either client or server mode
private Socket m_udpSocket;
/// Flag to process packets asynchronously or synchronously
private bool m_asyncPacketHandling;
+ /// Are we currently sending data asynchronously?
+ private volatile bool m_sendingData = false;
+
/// The all important shutdown flag
private volatile bool m_shutdownFlag = true;
@@ -246,25 +260,48 @@ namespace OpenMetaverse
}
}
- public void SyncBeginSend(UDPPacketBuffer buf)
+ public void SyncBeginPrioritySend(UDPPacketBuffer buf, int Priority)
{
if (!m_shutdownFlag)
{
- try
+ if (!m_sendingData)
{
- m_udpSocket.SendTo(
- buf.Data,
- 0,
- buf.DataLength,
- SocketFlags.None,
- buf.RemoteEndPoint);
+ m_sendingData = true;
+ try
+ {
+ AsyncBeginSend(buf);
+ }
+ catch (SocketException) { }
+ catch (ObjectDisposedException) { }
+ }
+ else
+ {
+ if (Priority == 2)
+ {
+ lock (m_priorityQueue)
+ {
+ m_priorityQueue.Add(buf);
+ }
+ }
+ else
+ {
+ lock (m_standardQueue)
+ {
+ if (Priority != 0)
+ {
+ m_standardQueue.Insert(0, buf);
+ }
+ else
+ {
+ m_standardQueue.Add(buf);
+ }
+ }
+ }
}
- catch (SocketException) { }
- catch (ObjectDisposedException) { }
}
}
- public void AsyncBeginSend(UDPPacketBuffer buf)
+ private void AsyncBeginSend(UDPPacketBuffer buf)
{
if (!m_shutdownFlag)
{
@@ -288,8 +325,36 @@ namespace OpenMetaverse
{
try
{
-// UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState;
m_udpSocket.EndSendTo(result);
+
+ if (m_sendingData)
+ {
+ lock (m_priorityQueue)
+ {
+ if (m_priorityQueue.Count > 0)
+ {
+ UDPPacketBuffer buf = m_priorityQueue[0];
+ m_priorityQueue.RemoveAt(0);
+ AsyncBeginSend(buf);
+ }
+ else
+ {
+ lock (m_standardQueue)
+ {
+ if (m_standardQueue.Count > 0)
+ {
+ UDPPacketBuffer buf = m_standardQueue[0];
+ m_standardQueue.RemoveAt(0);
+ AsyncBeginSend(buf);
+ }
+ else
+ {
+ m_sendingData = false;
+ }
+ }
+ }
+ }
+ }
}
catch (SocketException) { }
catch (ObjectDisposedException) { }
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index cbe4118..2230fba 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -156,8 +156,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix);
// Check control flags
- bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
- bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
+ bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS);
+ bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
//bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a430b1e..5058457 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1164,16 +1164,16 @@ namespace OpenSim.Region.Framework.Scenes
// Check if any objects have reached their targets
CheckAtTargets();
- // Update SceneObjectGroups that have scheduled themselves for updates
- // Objects queue their updates onto all scene presences
- if (m_frame % m_update_objects == 0)
- m_sceneGraph.UpdateObjectGroups();
-
// Run through all ScenePresences looking for updates
// Presence updates and queued object updates for each presence are sent to clients
if (m_frame % m_update_presences == 0)
m_sceneGraph.UpdatePresences();
+ // Update SceneObjectGroups that have scheduled themselves for updates
+ // Objects queue their updates onto all scene presences
+ if (m_frame % m_update_objects == 0)
+ m_sceneGraph.UpdateObjectGroups();
+
int TempPhysicsMS2 = Environment.TickCount;
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
m_sceneGraph.UpdatePreparePhysics();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 424c25b..99f3141 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes
// {
// m_log.Debug("[ScenePresence] Destructor called");
// }
-
+
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
@@ -144,7 +144,6 @@ namespace OpenSim.Region.Framework.Scenes
private int m_perfMonMS;
private bool m_setAlwaysRun;
-
private bool m_forceFly;
private bool m_flyDisabled;
@@ -166,7 +165,8 @@ namespace OpenSim.Region.Framework.Scenes
protected RegionInfo m_regionInfo;
protected ulong crossingFromRegion;
- private readonly Vector3[] Dir_Vectors = new Vector3[6];
+ private readonly Vector3[] Dir_Vectors = new Vector3[9];
+ private bool m_isNudging = false;
// Position of agent's camera in world (region cordinates)
protected Vector3 m_CameraCenter;
@@ -230,6 +230,8 @@ namespace OpenSim.Region.Framework.Scenes
DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
+ DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS,
+ DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
}
@@ -714,21 +716,41 @@ namespace OpenSim.Region.Framework.Scenes
Dir_Vectors[3] = -Vector3.UnitY; //RIGHT
Dir_Vectors[4] = Vector3.UnitZ; //UP
Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
- Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
+ Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE
+ Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE
+ Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
}
private Vector3[] GetWalkDirectionVectors()
{
- Vector3[] vector = new Vector3[6];
+ Vector3[] vector = new Vector3[9];
vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD
vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK
vector[2] = Vector3.UnitY; //LEFT
vector[3] = -Vector3.UnitY; //RIGHT
vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN
- vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
+ vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE
+ vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE
+ vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
return vector;
}
+
+ private bool[] GetDirectionIsNudge()
+ {
+ bool[] isNudge = new bool[9];
+ isNudge[0] = false; //FORWARD
+ isNudge[1] = false; //BACK
+ isNudge[2] = false; //LEFT
+ isNudge[3] = false; //RIGHT
+ isNudge[4] = false; //UP
+ isNudge[5] = false; //DOWN
+ isNudge[6] = true; //FORWARD_NUDGE
+ isNudge[7] = true; //BACK_NUDGE
+ isNudge[8] = true; //DOWN_Nudge
+ return isNudge;
+ }
+
#endregion
@@ -1147,7 +1169,6 @@ namespace OpenSim.Region.Framework.Scenes
// // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
// return;
//}
-
m_perfMonMS = Environment.TickCount;
++m_movementUpdateCount;
@@ -1229,7 +1250,6 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback);
}
}
-
lock (scriptedcontrols)
{
if (scriptedcontrols.Count > 0)
@@ -1261,7 +1281,6 @@ namespace OpenSim.Region.Framework.Scenes
{
return;
}
-
if (m_allowMovement)
{
int i = 0;
@@ -1289,6 +1308,11 @@ namespace OpenSim.Region.Framework.Scenes
update_rotation = true;
}
+ //guilty until proven innocent..
+ bool Nudging = true;
+ //Basically, if there is at least one non-nudge control then we don't need
+ //to worry about stopping the avatar
+
if (m_parentID == 0)
{
bool bAllowUpdateMoveToPosition = false;
@@ -1303,6 +1327,12 @@ namespace OpenSim.Region.Framework.Scenes
else
dirVectors = Dir_Vectors;
+ bool[] isNudge = GetDirectionIsNudge();
+
+
+
+
+
foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
{
if (((uint)flags & (uint)DCF) != 0)
@@ -1312,6 +1342,10 @@ namespace OpenSim.Region.Framework.Scenes
try
{
agent_control_v3 += dirVectors[i];
+ if (isNudge[i] == false)
+ {
+ Nudging = false;
+ }
}
catch (IndexOutOfRangeException)
{
@@ -1373,6 +1407,9 @@ namespace OpenSim.Region.Framework.Scenes
// Ignore z component of vector
Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f);
LocalVectorToTarget2D.Normalize();
+
+ //We're not nudging
+ Nudging = false;
agent_control_v3 += LocalVectorToTarget2D;
// update avatar movement flags. the avatar coordinate system is as follows:
@@ -1450,7 +1487,7 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3);
- AddNewMovement(agent_control_v3, q);
+ AddNewMovement(agent_control_v3, q, Nudging);
if (update_movementflag)
Animator.UpdateMovementAnimations();
@@ -1886,7 +1923,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// The vector in which to move. This is relative to the rotation argument
/// The direction in which this avatar should now face.
- public void AddNewMovement(Vector3 vec, Quaternion rotation)
+ public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging)
{
if (m_isChildAgent)
{
@@ -1960,7 +1997,7 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: Add the force instead of only setting it to support multiple forces per frame?
m_forceToApply = direc;
-
+ m_isNudging = Nudging;
m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
}
@@ -1975,7 +2012,7 @@ namespace OpenSim.Region.Framework.Scenes
const float POSITION_TOLERANCE = 0.05f;
//const int TIME_MS_TOLERANCE = 3000;
- SendPrimUpdates();
+
if (m_newCoarseLocations)
{
@@ -2011,6 +2048,9 @@ namespace OpenSim.Region.Framework.Scenes
CheckForBorderCrossing();
CheckForSignificantMovement(); // sends update to the modules.
}
+
+ //Sending prim updates AFTER the avatar terse updates are sent
+ SendPrimUpdates();
}
#endregion
@@ -2864,14 +2904,24 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_forceToApply.HasValue)
{
- Vector3 force = m_forceToApply.Value;
+ Vector3 force = m_forceToApply.Value;
m_updateflag = true;
-// movementvector = force;
Velocity = force;
m_forceToApply = null;
}
+ else
+ {
+ if (m_isNudging)
+ {
+ Vector3 force = Vector3.Zero;
+
+ m_updateflag = true;
+ Velocity = force;
+ m_isNudging = false;
+ }
+ }
}
public override void SetText(string text, Vector3 color, double alpha)
--
cgit v1.1
From 4a29a7f92cc5264dfcb4a4376a61506d29dd9d8d Mon Sep 17 00:00:00 2001
From: CasperW
Date: Sat, 21 Nov 2009 18:50:52 +0100
Subject: Minor packet ordering fix
---
.../Region/ClientStack/LindenUDP/LLUDPServer.cs | 1 -
.../Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 40 ++++++++++++++++------
2 files changed, 30 insertions(+), 11 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 4a7bdfe..98bb4f7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -578,7 +578,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
SyncBeginPrioritySend(buffer, 2); // highest priority
}
else if (outgoingPacket.Type == PacketType.ObjectUpdate
- || outgoingPacket.Type == PacketType.ChatFromSimulator
|| outgoingPacket.Type == PacketType.LayerData)
{
SyncBeginPrioritySend(buffer, 1); // medium priority
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
index 45d9170..de2cd24 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
@@ -57,7 +57,12 @@ namespace OpenMetaverse
/// Standard queue for our outgoing SyncBeginPrioritySend
///
private List m_standardQueue = new List();
-
+
+ ///
+ /// Medium priority queue for our outgoing SyncBeginPrioritySend
+ ///
+ private List m_mediumPriorityQueue = new List();
+
///
/// Prioritised queue for our outgoing SyncBeginPrioritySend
///
@@ -285,13 +290,16 @@ namespace OpenMetaverse
}
else
{
- lock (m_standardQueue)
+ if (Priority != 0)
{
- if (Priority != 0)
+ lock (m_mediumPriorityQueue)
{
- m_standardQueue.Insert(0, buf);
+ m_mediumPriorityQueue.Add(buf);
}
- else
+ }
+ else
+ {
+ lock (m_standardQueue)
{
m_standardQueue.Add(buf);
}
@@ -339,17 +347,29 @@ namespace OpenMetaverse
}
else
{
- lock (m_standardQueue)
+ lock (m_mediumPriorityQueue)
{
- if (m_standardQueue.Count > 0)
+ if (m_mediumPriorityQueue.Count > 0)
{
- UDPPacketBuffer buf = m_standardQueue[0];
- m_standardQueue.RemoveAt(0);
+ UDPPacketBuffer buf = m_mediumPriorityQueue[0];
+ m_mediumPriorityQueue.RemoveAt(0);
AsyncBeginSend(buf);
}
else
{
- m_sendingData = false;
+ lock (m_standardQueue)
+ {
+ if (m_standardQueue.Count > 0)
+ {
+ UDPPacketBuffer buf = m_standardQueue[0];
+ m_standardQueue.RemoveAt(0);
+ AsyncBeginSend(buf);
+ }
+ else
+ {
+ m_sendingData = false;
+ }
+ }
}
}
}
--
cgit v1.1
From f1522e62042d11604ad70a39b26dc94953e9db7d Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Sun, 22 Nov 2009 08:31:35 +0100
Subject: Add non-scripted sit, fix scripted sit.
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 99 +++++++++++++++++-------
1 file changed, 69 insertions(+), 30 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1dedcf1..aa538dc 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -89,7 +89,8 @@ namespace OpenSim.Region.Framework.Scenes
/// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis
/// issue #1716
///
- private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f);
+// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f);
+ private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f);
public UUID currentParcelUUID = UUID.Zero;
@@ -113,7 +114,8 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 lastKnownAllowedPosition;
public bool sentMessageAboutRestrictedParcelFlyingDown;
public Vector4 CollisionPlane = Vector4.UnitW;
-
+
+ private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation
private Vector3 m_lastPosition;
private Quaternion m_lastRotation;
private Vector3 m_lastVelocity;
@@ -1531,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes
Velocity = Vector3.Zero;
SendFullUpdateToAllClients();
- //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID);
+ HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ??
}
//ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false);
m_requestedSitTargetUUID = UUID.Zero;
@@ -1644,7 +1646,7 @@ namespace OpenSim.Region.Framework.Scenes
bool SitTargetisSet =
(!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f &&
avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f));
-
+ // this test is probably failing
if (SitTargetisSet && SitTargetUnOccupied)
{
//switch the target to this prim
@@ -1671,26 +1673,37 @@ namespace OpenSim.Region.Framework.Scenes
{
// TODO: determine position to sit at based on scene geometry; don't trust offset from client
// see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
-
+
+ // part is the prim to sit on
+ // offset is the vector distance from that prim center to the click-spot
+ // UUID is the UUID of the Avatar doing the clicking
+
+ m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation
+
// Is a sit target available?
Vector3 avSitOffSet = part.SitTargetPosition;
Quaternion avSitOrientation = part.SitTargetOrientation;
UUID avOnTargetAlready = part.GetAvatarOnSitTarget();
bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero));
- bool SitTargetisSet =
- (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f &&
- avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f));
+// bool SitTargetisSet =
+// (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f &&
+// avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f));
+ bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation));
+
+//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied +
+// " TargSet=" + SitTargetisSet);
+
if (SitTargetisSet && SitTargetUnOccupied)
{
part.SetAvatarOnSitTarget(UUID);
offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z);
sitOrientation = avSitOrientation;
- autopilot = false;
+ autopilot = false; // Jump direct to scripted llSitPos()
}
- pos = part.AbsolutePosition + offset;
+ pos = part.AbsolutePosition + offset; // Region position where clicked
//if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1)
//{
// offset = pos;
@@ -1703,17 +1716,17 @@ namespace OpenSim.Region.Framework.Scenes
m_sitAvatarHeight = m_physicsActor.Size.Z;
if (autopilot)
- {
+ { // its not a scripted sit
if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5)
{
- autopilot = false;
+ autopilot = false; // close enough
RemoveFromPhysicalScene();
- AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
- }
+ AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim
+ } // else the autopilot will get us close
}
else
- {
+ { // its a scripted sit
RemoveFromPhysicalScene();
}
}
@@ -1816,26 +1829,41 @@ namespace OpenSim.Region.Framework.Scenes
{
if (part.GetAvatarOnSitTarget() == UUID)
{
+ // Scripted sit
Vector3 sitTargetPos = part.SitTargetPosition;
Quaternion sitTargetOrient = part.SitTargetOrientation;
-
- //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0);
- //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w);
-
- //Quaternion result = (sitTargetOrient * vq) * nq;
-
m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z);
m_pos += SIT_TARGET_ADJUSTMENT;
m_bodyRot = sitTargetOrient;
- //Rotation = sitTargetOrient;
m_parentPosition = part.AbsolutePosition;
-
- //SendTerseUpdateToAllClients();
}
else
{
- m_pos -= part.AbsolutePosition;
+ // Non-scripted sit by Kitto Flora 21Nov09
+ // Calculate angle of line from prim to Av
+ float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y);
+ float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X);
+ if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0
+ if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0
+ float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff);
+ Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'.
+ // Av sits at world euler <0,0, z>, translated by part rotation
+ m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click
+ m_pos = new Vector3(0f, 0f, 0.05f) +
+ (new Vector3(0.0f, 0f, 0.625f) * partIRot) +
+ (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim
m_parentPosition = part.AbsolutePosition;
+ //Set up raytrace to find top surface of prim
+ Vector3 size = part.Scale;
+ float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
+ Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
+ Vector3 down = new Vector3(0f, 0f, -1f);
+ m_scene.PhysicsScene.RaycastWorld(
+ start, // Vector3 position,
+ down, // Vector3 direction,
+ mag, // float length,
+ SitAltitudeCallback); // retMethod
}
}
else
@@ -1850,11 +1878,22 @@ namespace OpenSim.Region.Framework.Scenes
Animator.TrySetMovementAnimation(sitAnimation);
SendFullUpdateToAllClients();
- // This may seem stupid, but Our Full updates don't send avatar rotation :P
- // So we're also sending a terse update (which has avatar rotation)
- // [Update] We do now.
- //SendTerseUpdateToAllClients();
}
+
+ public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance)
+ {
+// Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance);
+ if(hitYN)
+ {
+ // m_pos = Av offset from prim center to make look like on center
+ // m_parentPosition = Actual center pos of prim
+ // collisionPoint = spot on prim where we want to sit
+ SceneObjectPart part = m_scene.GetSceneObjectPart(localid);
+ Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset);
+ m_pos += offset;
+// Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit);
+ }
+ }
///
/// Event handler for the 'Always run' setting on the client
@@ -3578,4 +3617,4 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1
From 889ce36afa67c521f3e50e4833a894ffd39af490 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 23 Nov 2009 16:02:05 +0100
Subject: Added some [DebuggerNonUserCode] modifiers to functions that throw
EventAbortException() to ease debugging on Visual Studio
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++++
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | 2 ++
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 2 ++
OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 5 ++++-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 3 +++
5 files changed, 15 insertions(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 50b2fb5..b549b5c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Threading;
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
get { return m_ScriptEngine.World; }
}
+ [DebuggerNonUserCode]
public void state(string newState)
{
m_ScriptEngine.SetState(m_itemID, newState);
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// Reset the named script. The script must be present
/// in the same prim.
///
+ [DebuggerNonUserCode]
public void llResetScript()
{
m_host.AddScriptLPS(1);
@@ -3755,6 +3758,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(3000);
}
+ [DebuggerNonUserCode]
public void llRemoveInventory(string name)
{
m_host.AddScriptLPS(1);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
index 7f67599..15e0408 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Reflection;
using System.Runtime.Remoting.Lifetime;
using OpenSim.Region.ScriptEngine.Shared;
@@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return (eventFlags);
}
+ [DebuggerNonUserCode]
public void ExecuteEvent(string state, string FunctionName, object[] args)
{
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index 121159c..a44abb0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -33,6 +33,7 @@ using System.Threading;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return (int)m_Executor.GetStateEventFlags(state);
}
+ [DebuggerNonUserCode]
public void ExecuteEvent(string state, string FunctionName, object[] args)
{
m_Executor.ExecuteEvent(state, FunctionName, args);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 41b5d49..ed3fdbe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -27,6 +27,7 @@
using System;
using System.IO;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Runtime.Remoting;
using System.Runtime.Remoting.Lifetime;
using System.Threading;
@@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
return true;
}
+ [DebuggerNonUserCode] //Prevents the debugger from farting in this function
public void SetState(string state)
{
if (state == State)
@@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
new DetectParams[0]));
PostEvent(new EventParams("state_entry", new Object[0],
new DetectParams[0]));
-
+
throw new EventAbortException();
}
@@ -824,6 +826,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
new Object[0], new DetectParams[0]));
}
+ [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
public void ApiResetScript()
{
// bool running = Running;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index a60c0ba..8b94f28 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -30,6 +30,7 @@ using System.IO;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Security;
using System.Security.Policy;
using System.Reflection;
@@ -1119,6 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return false;
}
+ [DebuggerNonUserCode]
public void ApiResetScript(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
@@ -1170,6 +1172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return UUID.Zero;
}
+ [DebuggerNonUserCode]
public void SetState(UUID itemID, string newState)
{
IScriptInstance instance = GetInstance(itemID);
--
cgit v1.1
From 73c2162ff60850d96761aa07a1950dbbb2ec3e80 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 23 Nov 2009 19:51:40 +0100
Subject: Fixed nullrefs
---
.../Region/CoreModules/Avatar/Chat/ChatModule.cs | 42 ++++++++++++----------
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 +++--
2 files changed, 29 insertions(+), 21 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index cd59bdb..5c24f03 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -266,25 +266,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
}
// m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
-
- ((Scene)c.Scene).ForEachScenePresence(
- delegate(ScenePresence presence)
- {
- // ignore chat from child agents
- if (presence.IsChildAgent) return;
-
- IClientAPI client = presence.ControllingClient;
-
- // don't forward SayOwner chat from objects to
- // non-owner agents
- if ((c.Type == ChatTypeEnum.Owner) &&
- (null != c.SenderObject) &&
- (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
- return;
-
- client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
- (byte)sourceType, (byte)ChatAudibleLevel.Fully);
- });
+ if (c.Scene != null)
+ {
+ ((Scene)c.Scene).ForEachScenePresence
+ (
+ delegate(ScenePresence presence)
+ {
+ // ignore chat from child agents
+ if (presence.IsChildAgent) return;
+
+ IClientAPI client = presence.ControllingClient;
+
+ // don't forward SayOwner chat from objects to
+ // non-owner agents
+ if ((c.Type == ChatTypeEnum.Owner) &&
+ (null != c.SenderObject) &&
+ (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
+ return;
+
+ client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
+ (byte)sourceType, (byte)ChatAudibleLevel.Fully);
+ }
+ );
+ }
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 66fb918..83208e9 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -840,8 +840,12 @@ namespace OpenSim.Region.Framework.Scenes
public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
{
SceneObjectPart part = GetSceneObjectPart(localID);
- SceneObjectGroup group = part.ParentGroup;
- if (group != null)
+ SceneObjectGroup group = null;
+ if (part != null)
+ {
+ group = part.ParentGroup;
+ }
+ if (part != null && group != null)
{
TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
if (item == null)
--
cgit v1.1
From 247c66b3fe792692468ede6a516d85c6c9852d23 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 23 Nov 2009 20:25:53 +0100
Subject: Swap the locking of m_EventQueue and m_Script to ease locks on script
inventory operations
---
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 234 +++++++++++----------
1 file changed, 119 insertions(+), 115 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index ed3fdbe..063d50f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -640,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
///
public object EventProcessor()
{
+
+ EventParams data = null;
+
+ lock (m_EventQueue)
+ {
lock (m_Script)
{
- EventParams data = null;
-
- lock (m_EventQueue)
+ data = (EventParams) m_EventQueue.Dequeue();
+ if (data == null) // Shouldn't happen
{
- data = (EventParams) m_EventQueue.Dequeue();
- if (data == null) // Shouldn't happen
+ if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{
- if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
- {
- m_CurrentResult = m_Engine.QueueEventHandler(this);
- }
- else
- {
- m_CurrentResult = null;
- }
- return 0;
+ m_CurrentResult = m_Engine.QueueEventHandler(this);
}
-
- if (data.EventName == "timer")
- m_TimerQueued = false;
- if (data.EventName == "control")
+ else
{
- if (m_ControlEventsInQueue > 0)
- m_ControlEventsInQueue--;
+ m_CurrentResult = null;
}
- if (data.EventName == "collision")
- m_CollisionInQueue = false;
+ return 0;
}
-
- //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
- m_DetectParams = data.DetectParams;
-
- if (data.EventName == "state") // Hardcoded state change
+ if (data.EventName == "timer")
+ m_TimerQueued = false;
+ if (data.EventName == "control")
{
- // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
- // m_PrimName, m_ScriptName, data.Params[0].ToString());
- m_State=data.Params[0].ToString();
- AsyncCommandManager.RemoveScript(m_Engine,
- m_LocalID, m_ItemID);
+ if (m_ControlEventsInQueue > 0)
+ m_ControlEventsInQueue--;
+ }
+ if (data.EventName == "collision")
+ m_CollisionInQueue = false;
+ }
+ }
+ lock(m_Script)
+ {
+
+ //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
- SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
- m_LocalID);
- if (part != null)
- {
- part.SetScriptEvents(m_ItemID,
- (int)m_Script.GetStateEventFlags(State));
- }
+ m_DetectParams = data.DetectParams;
+
+ if (data.EventName == "state") // Hardcoded state change
+ {
+// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
+// m_PrimName, m_ScriptName, data.Params[0].ToString());
+ m_State=data.Params[0].ToString();
+ AsyncCommandManager.RemoveScript(m_Engine,
+ m_LocalID, m_ItemID);
+
+ SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
+ m_LocalID);
+ if (part != null)
+ {
+ part.SetScriptEvents(m_ItemID,
+ (int)m_Script.GetStateEventFlags(State));
}
- else
+ }
+ else
+ {
+ if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
+ data.EventName == "control") // Don't freeze avies!
{
- if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
- data.EventName == "control") // Don't freeze avies!
- {
- SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
- m_LocalID);
- // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
- // m_PrimName, m_ScriptName, data.EventName, m_State);
+ SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
+ m_LocalID);
+ // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
+ // m_PrimName, m_ScriptName, data.EventName, m_State);
- try
- {
- m_CurrentEvent = data.EventName;
- m_EventStart = DateTime.Now;
- m_InEvent = true;
+ try
+ {
+ m_CurrentEvent = data.EventName;
+ m_EventStart = DateTime.Now;
+ m_InEvent = true;
- m_Script.ExecuteEvent(State, data.EventName, data.Params);
+ m_Script.ExecuteEvent(State, data.EventName, data.Params);
- m_InEvent = false;
- m_CurrentEvent = String.Empty;
+ m_InEvent = false;
+ m_CurrentEvent = String.Empty;
- if (m_SaveState)
- {
- // This will be the very first event we deliver
- // (state_entry) in default state
- //
+ if (m_SaveState)
+ {
+ // This will be the very first event we deliver
+ // (state_entry) in default state
+ //
- SaveState(m_Assembly);
+ SaveState(m_Assembly);
- m_SaveState = false;
- }
+ m_SaveState = false;
}
- catch (Exception e)
- {
- // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
- m_InEvent = false;
- m_CurrentEvent = String.Empty;
+ }
+ catch (Exception e)
+ {
+ // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
+ m_InEvent = false;
+ m_CurrentEvent = String.Empty;
- if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
- {
- try
- {
- // DISPLAY ERROR INWORLD
- string text = FormatException(e);
-
- if (text.Length > 1000)
- text = text.Substring(0, 1000);
- m_Engine.World.SimChat(Utils.StringToBytes(text),
- ChatTypeEnum.DebugChannel, 2147483647,
- part.AbsolutePosition,
- part.Name, part.UUID, false);
- }
- catch (Exception)
- {
- }
- // catch (Exception e2) // LEGIT: User Scripting
- // {
- // m_log.Error("[SCRIPT]: "+
- // "Error displaying error in-world: " +
- // e2.ToString());
- // m_log.Error("[SCRIPT]: " +
- // "Errormessage: Error compiling script:\r\n" +
- // e.ToString());
- // }
- }
- else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
+ if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
+ {
+ try
{
- m_InSelfDelete = true;
- if (part != null && part.ParentGroup != null)
- m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
+ // DISPLAY ERROR INWORLD
+ string text = FormatException(e);
+
+ if (text.Length > 1000)
+ text = text.Substring(0, 1000);
+ m_Engine.World.SimChat(Utils.StringToBytes(text),
+ ChatTypeEnum.DebugChannel, 2147483647,
+ part.AbsolutePosition,
+ part.Name, part.UUID, false);
}
- else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
+ catch (Exception)
{
- m_InSelfDelete = true;
- if (part != null && part.ParentGroup != null)
- part.Inventory.RemoveInventoryItem(m_ItemID);
}
+ // catch (Exception e2) // LEGIT: User Scripting
+ // {
+ // m_log.Error("[SCRIPT]: "+
+ // "Error displaying error in-world: " +
+ // e2.ToString());
+ // m_log.Error("[SCRIPT]: " +
+ // "Errormessage: Error compiling script:\r\n" +
+ // e.ToString());
+ // }
+ }
+ else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
+ {
+ m_InSelfDelete = true;
+ if (part != null && part.ParentGroup != null)
+ m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
+ }
+ else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
+ {
+ m_InSelfDelete = true;
+ if (part != null && part.ParentGroup != null)
+ part.Inventory.RemoveInventoryItem(m_ItemID);
}
}
}
+ }
- lock (m_EventQueue)
+ lock (m_EventQueue)
+ {
+ if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{
- if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
- {
- m_CurrentResult = m_Engine.QueueEventHandler(this);
- }
- else
- {
- m_CurrentResult = null;
- }
+ m_CurrentResult = m_Engine.QueueEventHandler(this);
+ }
+ else
+ {
+ m_CurrentResult = null;
}
+ }
- m_DetectParams = null;
+ m_DetectParams = null;
- return 0;
- }
+ return 0;
+ }
}
public int EventTime()
--
cgit v1.1
From d1147136946daf14724183b3191119be44ff8b16 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Tue, 24 Nov 2009 18:02:12 +0100
Subject: Drop all locking of part.TaskInventory in favour of a
ReaderWriterLockSlim lock handler. This gives us: - Faster prim inventory
actions. Multiple threads can read at once. - Fixes the known prim inventory
thread locks - In the event of a thread lock occurring, it will usually self
heal after sixty seconds with an error message in the console
---
OpenSim/Framework/TaskInventoryDictionary.cs | 111 ++++-
.../World/Archiver/ArchiveReadRequest.cs | 21 +-
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 38 +-
.../Framework/Scenes/SceneObjectPartInventory.cs | 390 ++++++++-------
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 +-
.../Shared/Api/Implementation/LSL_Api.cs | 532 ++++++++++++---------
.../Shared/Api/Implementation/OSSL_Api.cs | 36 +-
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 22 +-
8 files changed, 685 insertions(+), 481 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs
index 25ae6b0..efe5f0c 100644
--- a/OpenSim/Framework/TaskInventoryDictionary.cs
+++ b/OpenSim/Framework/TaskInventoryDictionary.cs
@@ -27,9 +27,12 @@
using System;
using System.Collections.Generic;
+using System.Threading;
+using System.Reflection;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
+using log4net;
using OpenMetaverse;
namespace OpenSim.Framework
@@ -45,6 +48,105 @@ namespace OpenSim.Framework
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem));
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private Thread LockedByThread;
+ ///
+ /// An advanced lock for inventory data
+ ///
+ private System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim();
+
+ ///
+ /// Are we readlocked by the calling thread?
+ ///
+ public bool IsReadLockedByMe()
+ {
+ if (m_itemLock.RecursiveReadCount > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Lock our inventory list for reading (many can read, one can write)
+ ///
+ public void LockItemsForRead(bool locked)
+ {
+ if (locked)
+ {
+ if (m_itemLock.IsWriteLockHeld && LockedByThread != null)
+ {
+ if (!LockedByThread.IsAlive)
+ {
+ //Locked by dead thread, reset.
+ m_itemLock = new System.Threading.ReaderWriterLockSlim();
+ }
+ }
+
+ if (m_itemLock.RecursiveReadCount > 0)
+ {
+ m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
+ m_itemLock.ExitReadLock();
+ }
+ if (m_itemLock.RecursiveWriteCount > 0)
+ {
+ m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
+ m_itemLock.ExitWriteLock();
+ }
+
+ while (!m_itemLock.TryEnterReadLock(60000))
+ {
+ m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
+ if (m_itemLock.IsWriteLockHeld)
+ {
+ m_itemLock = new System.Threading.ReaderWriterLockSlim();
+ }
+ }
+ }
+ else
+ {
+ m_itemLock.ExitReadLock();
+ }
+ }
+
+ ///
+ /// Lock our inventory list for writing (many can read, one can write)
+ ///
+ public void LockItemsForWrite(bool locked)
+ {
+ if (locked)
+ {
+ //Enter a write lock, wait indefinately for one to open.
+ if (m_itemLock.RecursiveReadCount > 0)
+ {
+ m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
+ m_itemLock.ExitReadLock();
+ }
+ if (m_itemLock.RecursiveWriteCount > 0)
+ {
+ m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
+ m_itemLock.ExitWriteLock();
+ }
+ while (!m_itemLock.TryEnterWriteLock(60000))
+ {
+ m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
+ if (m_itemLock.IsWriteLockHeld)
+ {
+ m_itemLock = new System.Threading.ReaderWriterLockSlim();
+ }
+ }
+
+ LockedByThread = Thread.CurrentThread;
+ }
+ else
+ {
+ m_itemLock.ExitWriteLock();
+ }
+ }
#region ICloneable Members
@@ -52,13 +154,12 @@ namespace OpenSim.Framework
{
TaskInventoryDictionary clone = new TaskInventoryDictionary();
- lock (this)
+ m_itemLock.EnterReadLock();
+ foreach (UUID uuid in Keys)
{
- foreach (UUID uuid in Keys)
- {
- clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
- }
+ clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
}
+ m_itemLock.ExitReadLock();
return clone;
}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 70a225e..f204faf 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -246,21 +246,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Fix ownership/creator of inventory items
// Not doing so results in inventory items
// being no copy/no mod for everyone
- lock (part.TaskInventory)
+ part.TaskInventory.LockItemsForRead(true);
+ TaskInventoryDictionary inv = part.TaskInventory;
+ foreach (KeyValuePair kvp in inv)
{
- TaskInventoryDictionary inv = part.TaskInventory;
- foreach (KeyValuePair kvp in inv)
+ if (!ResolveUserUuid(kvp.Value.OwnerID))
{
- if (!ResolveUserUuid(kvp.Value.OwnerID))
- {
- kvp.Value.OwnerID = masterAvatarId;
- }
- if (!ResolveUserUuid(kvp.Value.CreatorID))
- {
- kvp.Value.CreatorID = masterAvatarId;
- }
+ kvp.Value.OwnerID = masterAvatarId;
+ }
+ if (!ResolveUserUuid(kvp.Value.CreatorID))
+ {
+ kvp.Value.CreatorID = masterAvatarId;
}
}
+ part.TaskInventory.LockItemsForRead(false);
}
if (m_scene.AddRestoredSceneObject(sceneObject, true, false))
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index cdec135..bbece2f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -389,12 +389,16 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
+ /// Get the inventory list
///
public TaskInventoryDictionary TaskInventory
{
- get { return m_inventory.Items; }
- set { m_inventory.Items = value; }
+ get {
+ return m_inventory.Items;
+ }
+ set {
+ m_inventory.Items = value;
+ }
}
public uint ObjectFlags
@@ -2101,17 +2105,18 @@ namespace OpenSim.Region.Framework.Scenes
//Trys to fetch sound id from prim's inventory.
//Prim's inventory doesn't support non script items yet
- lock (TaskInventory)
+ TaskInventory.LockItemsForRead(true);
+
+ foreach (KeyValuePair item in TaskInventory)
{
- foreach (KeyValuePair item in TaskInventory)
+ if (item.Value.Name == sound)
{
- if (item.Value.Name == sound)
- {
- soundID = item.Value.ItemID;
- break;
- }
+ soundID = item.Value.ItemID;
+ break;
}
}
+
+ TaskInventory.LockItemsForRead(false);
}
List avatarts = m_parentGroup.Scene.GetAvatars();
@@ -2457,17 +2462,16 @@ namespace OpenSim.Region.Framework.Scenes
if (!UUID.TryParse(sound, out soundID))
{
// search sound file from inventory
- lock (TaskInventory)
+ TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair item in TaskInventory)
{
- foreach (KeyValuePair item in TaskInventory)
+ if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
{
- if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
- {
- soundID = item.Value.ItemID;
- break;
- }
+ soundID = item.Value.ItemID;
+ break;
}
}
+ TaskInventory.LockItemsForRead(false);
}
if (soundID == UUID.Zero)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index f4ca877..4dc709e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -80,7 +80,9 @@ namespace OpenSim.Region.Framework.Scenes
///
protected internal TaskInventoryDictionary Items
{
- get { return m_items; }
+ get {
+ return m_items;
+ }
set
{
m_items = value;
@@ -116,22 +118,25 @@ namespace OpenSim.Region.Framework.Scenes
/// Link number for the part
public void ResetInventoryIDs()
{
- lock (Items)
+ m_items.LockItemsForWrite(true);
+
+ if (0 == Items.Count)
{
- if (0 == Items.Count)
- return;
+ m_items.LockItemsForWrite(false);
+ return;
+ }
- HasInventoryChanged = true;
- m_part.ParentGroup.HasGroupChanged = true;
- IList items = new List(Items.Values);
- Items.Clear();
+ HasInventoryChanged = true;
+ m_part.ParentGroup.HasGroupChanged = true;
+ IList items = new List(Items.Values);
+ Items.Clear();
- foreach (TaskInventoryItem item in items)
- {
- item.ResetIDs(m_part.UUID);
- Items.Add(item.ItemID, item);
- }
+ foreach (TaskInventoryItem item in items)
+ {
+ item.ResetIDs(m_part.UUID);
+ Items.Add(item.ItemID, item);
}
+ m_items.LockItemsForWrite(false);
}
///
@@ -140,25 +145,25 @@ namespace OpenSim.Region.Framework.Scenes
///
public void ChangeInventoryOwner(UUID ownerId)
{
- lock (Items)
+ m_items.LockItemsForWrite(true);
+ if (0 == Items.Count)
{
- if (0 == Items.Count)
- {
- return;
- }
+ m_items.LockItemsForWrite(false);
+ return;
+ }
- HasInventoryChanged = true;
- m_part.ParentGroup.HasGroupChanged = true;
- IList items = new List(Items.Values);
- foreach (TaskInventoryItem item in items)
+ HasInventoryChanged = true;
+ m_part.ParentGroup.HasGroupChanged = true;
+ IList items = new List(Items.Values);
+ foreach (TaskInventoryItem item in items)
+ {
+ if (ownerId != item.OwnerID)
{
- if (ownerId != item.OwnerID)
- {
- item.LastOwnerID = item.OwnerID;
- item.OwnerID = ownerId;
- }
+ item.LastOwnerID = item.OwnerID;
+ item.OwnerID = ownerId;
}
}
+ m_items.LockItemsForWrite(false);
}
///
@@ -167,24 +172,24 @@ namespace OpenSim.Region.Framework.Scenes
///
public void ChangeInventoryGroup(UUID groupID)
{
- lock (Items)
+ m_items.LockItemsForWrite(true);
+ if (0 == Items.Count)
{
- if (0 == Items.Count)
- {
- return;
- }
+ m_items.LockItemsForWrite(false);
+ return;
+ }
- HasInventoryChanged = true;
- m_part.ParentGroup.HasGroupChanged = true;
- IList items = new List(Items.Values);
- foreach (TaskInventoryItem item in items)
+ HasInventoryChanged = true;
+ m_part.ParentGroup.HasGroupChanged = true;
+ IList items = new List(Items.Values);
+ foreach (TaskInventoryItem item in items)
+ {
+ if (groupID != item.GroupID)
{
- if (groupID != item.GroupID)
- {
- item.GroupID = groupID;
- }
+ item.GroupID = groupID;
}
}
+ m_items.LockItemsForWrite(false);
}
///
@@ -192,14 +197,14 @@ namespace OpenSim.Region.Framework.Scenes
///
public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
{
- lock (m_items)
+ Items.LockItemsForRead(true);
+ IList items = new List(Items.Values);
+ Items.LockItemsForRead(false);
+ foreach (TaskInventoryItem item in items)
{
- foreach (TaskInventoryItem item in Items.Values)
+ if ((int)InventoryType.LSL == item.InvType)
{
- if ((int)InventoryType.LSL == item.InvType)
- {
- CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
- }
+ CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
}
}
}
@@ -209,17 +214,20 @@ namespace OpenSim.Region.Framework.Scenes
///
public void RemoveScriptInstances()
{
- lock (Items)
+ Items.LockItemsForRead(true);
+ IList items = new List(Items.Values);
+ Items.LockItemsForRead(false);
+
+ foreach (TaskInventoryItem item in items)
{
- foreach (TaskInventoryItem item in Items.Values)
+ if ((int)InventoryType.LSL == item.InvType)
{
- if ((int)InventoryType.LSL == item.InvType)
- {
- RemoveScriptInstance(item.ItemID);
- m_part.RemoveScriptEvents(item.ItemID);
- }
+ RemoveScriptInstance(item.ItemID);
+ m_part.RemoveScriptEvents(item.ItemID);
}
}
+
+
}
///
@@ -244,8 +252,10 @@ namespace OpenSim.Region.Framework.Scenes
if (stateSource == 1 && // Prim crossing
m_part.ParentGroup.Scene.m_trustBinaries)
{
+ m_items.LockItemsForWrite(true);
m_items[item.ItemID].PermsMask = 0;
m_items[item.ItemID].PermsGranter = UUID.Zero;
+ m_items.LockItemsForWrite(false);
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
m_part.ParentGroup.AddActiveScriptCount(1);
@@ -266,8 +276,10 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_part.ParentGroup.m_savedScriptState != null)
RestoreSavedScriptState(item.OldItemID, item.ItemID);
+ m_items.LockItemsForWrite(true);
m_items[item.ItemID].PermsMask = 0;
m_items[item.ItemID].PermsGranter = UUID.Zero;
+ m_items.LockItemsForWrite(false);
string script = Utils.BytesToString(asset.Data);
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
@@ -302,20 +314,22 @@ namespace OpenSim.Region.Framework.Scenes
///
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
{
- lock (m_items)
+ m_items.LockItemsForRead(true);
+ if (m_items.ContainsKey(itemId))
{
- if (m_items.ContainsKey(itemId))
- {
- CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource);
- }
- else
- {
- m_log.ErrorFormat(
- "[PRIM INVENTORY]: " +
- "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
- itemId, m_part.Name, m_part.UUID);
- }
+ TaskInventoryItem item = m_items[itemId];
+ m_items.LockItemsForRead(false);
+ CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
}
+ else
+ {
+ m_items.LockItemsForRead(false);
+ m_log.ErrorFormat(
+ "[PRIM INVENTORY]: " +
+ "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
+ itemId, m_part.Name, m_part.UUID);
+ }
+
}
///
@@ -346,11 +360,16 @@ namespace OpenSim.Region.Framework.Scenes
///
private bool InventoryContainsName(string name)
{
- foreach (TaskInventoryItem item in Items.Values)
+ m_items.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_items.Values)
{
if (item.Name == name)
+ {
+ m_items.LockItemsForRead(false);
return true;
+ }
}
+ m_items.LockItemsForRead(false);
return false;
}
@@ -392,7 +411,9 @@ namespace OpenSim.Region.Framework.Scenes
///
public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
{
+ m_items.LockItemsForRead(true);
List il = new List(m_items.Values);
+ m_items.LockItemsForRead(false);
foreach (TaskInventoryItem i in il)
{
if (i.Name == item.Name)
@@ -429,15 +450,14 @@ namespace OpenSim.Region.Framework.Scenes
item.ParentPartID = m_part.UUID;
item.Name = name;
- lock (m_items)
- {
- m_items.Add(item.ItemID, item);
-
+ m_items.LockItemsForWrite(true);
+ m_items.Add(item.ItemID, item);
+ m_items.LockItemsForWrite(false);
if (allowedDrop)
m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
else
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
- }
+
m_inventorySerial++;
//m_inventorySerial += 2;
@@ -454,14 +474,13 @@ namespace OpenSim.Region.Framework.Scenes
///
public void RestoreInventoryItems(ICollection items)
{
- lock (m_items)
+ m_items.LockItemsForWrite(true);
+ foreach (TaskInventoryItem item in items)
{
- foreach (TaskInventoryItem item in items)
- {
- m_items.Add(item.ItemID, item);
- m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
- }
+ m_items.Add(item.ItemID, item);
+ m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
}
+ m_items.LockItemsForWrite(false);
m_inventorySerial++;
}
@@ -474,8 +493,9 @@ namespace OpenSim.Region.Framework.Scenes
public TaskInventoryItem GetInventoryItem(UUID itemId)
{
TaskInventoryItem item;
+ m_items.LockItemsForRead(true);
m_items.TryGetValue(itemId, out item);
-
+ m_items.LockItemsForRead(false);
return item;
}
@@ -487,45 +507,45 @@ namespace OpenSim.Region.Framework.Scenes
/// false if the item did not exist, true if the update occurred successfully
public bool UpdateInventoryItem(TaskInventoryItem item)
{
- lock (m_items)
+ m_items.LockItemsForWrite(true);
+
+ if (m_items.ContainsKey(item.ItemID))
{
- if (m_items.ContainsKey(item.ItemID))
+ item.ParentID = m_part.UUID;
+ item.ParentPartID = m_part.UUID;
+ item.Flags = m_items[item.ItemID].Flags;
+ if (item.AssetID == UUID.Zero)
{
- item.ParentID = m_part.UUID;
- item.ParentPartID = m_part.UUID;
- item.Flags = m_items[item.ItemID].Flags;
- if (item.AssetID == UUID.Zero)
- {
- item.AssetID = m_items[item.ItemID].AssetID;
- }
- else if ((InventoryType)item.Type == InventoryType.Notecard)
- {
- ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID);
+ item.AssetID = m_items[item.ItemID].AssetID;
+ }
+ else if ((InventoryType)item.Type == InventoryType.Notecard)
+ {
+ ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID);
- if (presence != null)
- {
- presence.ControllingClient.SendAgentAlertMessage(
- "Notecard saved", false);
- }
+ if (presence != null)
+ {
+ presence.ControllingClient.SendAgentAlertMessage(
+ "Notecard saved", false);
}
+ }
- m_items[item.ItemID] = item;
- m_inventorySerial++;
- m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
-
- HasInventoryChanged = true;
- m_part.ParentGroup.HasGroupChanged = true;
+ m_items[item.ItemID] = item;
+ m_inventorySerial++;
+ m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
- return true;
- }
- else
- {
- m_log.ErrorFormat(
- "[PRIM INVENTORY]: " +
- "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
- item.ItemID, m_part.Name, m_part.UUID);
- }
+ HasInventoryChanged = true;
+ m_part.ParentGroup.HasGroupChanged = true;
+ m_items.LockItemsForWrite(false);
+ return true;
+ }
+ else
+ {
+ m_log.ErrorFormat(
+ "[PRIM INVENTORY]: " +
+ "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ item.ItemID, m_part.Name, m_part.UUID);
}
+ m_items.LockItemsForWrite(false);
return false;
}
@@ -538,51 +558,54 @@ namespace OpenSim.Region.Framework.Scenes
/// in this prim's inventory.
public int RemoveInventoryItem(UUID itemID)
{
- lock (m_items)
+ m_items.LockItemsForRead(true);
+
+ if (m_items.ContainsKey(itemID))
{
- if (m_items.ContainsKey(itemID))
+ int type = m_items[itemID].InvType;
+ m_items.LockItemsForRead(false);
+ if (type == 10) // Script
{
- int type = m_items[itemID].InvType;
- if (type == 10) // Script
- {
- m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
- }
- m_items.Remove(itemID);
- m_inventorySerial++;
- m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
-
- HasInventoryChanged = true;
- m_part.ParentGroup.HasGroupChanged = true;
+ m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
+ }
+ m_items.LockItemsForWrite(true);
+ m_items.Remove(itemID);
+ m_items.LockItemsForWrite(false);
+ m_inventorySerial++;
+ m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
- int scriptcount = 0;
- lock (m_items)
- {
- foreach (TaskInventoryItem item in m_items.Values)
- {
- if (item.Type == 10)
- {
- scriptcount++;
- }
- }
- }
+ HasInventoryChanged = true;
+ m_part.ParentGroup.HasGroupChanged = true;
- if (scriptcount <= 0)
+ int scriptcount = 0;
+ m_items.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_items.Values)
+ {
+ if (item.Type == 10)
{
- m_part.RemFlag(PrimFlags.Scripted);
+ scriptcount++;
}
-
- m_part.ScheduleFullUpdate();
-
- return type;
}
- else
+ m_items.LockItemsForRead(false);
+
+
+ if (scriptcount <= 0)
{
- m_log.ErrorFormat(
- "[PRIM INVENTORY]: " +
- "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
- itemID, m_part.Name, m_part.UUID);
+ m_part.RemFlag(PrimFlags.Scripted);
}
+
+ m_part.ScheduleFullUpdate();
+
+ return type;
+ }
+ else
+ {
+ m_log.ErrorFormat(
+ "[PRIM INVENTORY]: " +
+ "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ itemID, m_part.Name, m_part.UUID);
}
+ m_items.LockItemsForWrite(false);
return -1;
}
@@ -635,52 +658,53 @@ namespace OpenSim.Region.Framework.Scenes
// isn't available (such as drag from prim inventory to agent inventory)
InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
- lock (m_items)
+ m_items.LockItemsForRead(true);
+
+ foreach (TaskInventoryItem item in m_items.Values)
{
- foreach (TaskInventoryItem item in m_items.Values)
- {
- UUID ownerID = item.OwnerID;
- uint everyoneMask = 0;
- uint baseMask = item.BasePermissions;
- uint ownerMask = item.CurrentPermissions;
+ UUID ownerID = item.OwnerID;
+ uint everyoneMask = 0;
+ uint baseMask = item.BasePermissions;
+ uint ownerMask = item.CurrentPermissions;
- invString.AddItemStart();
- invString.AddNameValueLine("item_id", item.ItemID.ToString());
- invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
+ invString.AddItemStart();
+ invString.AddNameValueLine("item_id", item.ItemID.ToString());
+ invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
- invString.AddPermissionsStart();
+ invString.AddPermissionsStart();
- invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
- invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
- invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0));
- invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
- invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
+ invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
+ invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
+ invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0));
+ invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
+ invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
- invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
- invString.AddNameValueLine("owner_id", ownerID.ToString());
+ invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
+ invString.AddNameValueLine("owner_id", ownerID.ToString());
- invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
+ invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
- invString.AddNameValueLine("group_id", item.GroupID.ToString());
- invString.AddSectionEnd();
+ invString.AddNameValueLine("group_id", item.GroupID.ToString());
+ invString.AddSectionEnd();
- invString.AddNameValueLine("asset_id", item.AssetID.ToString());
- invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
- invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
- invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
+ invString.AddNameValueLine("asset_id", item.AssetID.ToString());
+ invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
+ invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
+ invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
- invString.AddSaleStart();
- invString.AddNameValueLine("sale_type", "not");
- invString.AddNameValueLine("sale_price", "0");
- invString.AddSectionEnd();
+ invString.AddSaleStart();
+ invString.AddNameValueLine("sale_type", "not");
+ invString.AddNameValueLine("sale_price", "0");
+ invString.AddSectionEnd();
- invString.AddNameValueLine("name", item.Name + "|");
- invString.AddNameValueLine("desc", item.Description + "|");
+ invString.AddNameValueLine("name", item.Name + "|");
+ invString.AddNameValueLine("desc", item.Description + "|");
- invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
- invString.AddSectionEnd();
- }
+ invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
+ invString.AddSectionEnd();
}
+ int count = m_items.Count;
+ m_items.LockItemsForRead(false);
fileData = Utils.StringToBytes(invString.BuildString);
@@ -689,6 +713,7 @@ namespace OpenSim.Region.Framework.Scenes
if (fileData.Length > 2)
{
+ m_log.Debug("Sending task inventory list of " + count.ToString() + " items to client " + client.AgentId.ToString());
xferManager.AddNewFile(m_inventoryFileName, fileData);
}
}
@@ -701,10 +726,9 @@ namespace OpenSim.Region.Framework.Scenes
{
if (HasInventoryChanged)
{
- lock (Items)
- {
- datastore.StorePrimInventory(m_part.UUID, Items.Values);
- }
+ Items.LockItemsForRead(true);
+ datastore.StorePrimInventory(m_part.UUID, Items.Values);
+ Items.LockItemsForRead(false);
HasInventoryChanged = false;
}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4e5fee1..4c8c94f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1615,21 +1615,19 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
if (part != null)
{
+ part.TaskInventory.LockItemsForRead(true);
TaskInventoryDictionary taskIDict = part.TaskInventory;
if (taskIDict != null)
{
- lock (taskIDict)
+ foreach (UUID taskID in taskIDict.Keys)
{
- foreach (UUID taskID in taskIDict.Keys)
- {
- UnRegisterControlEventsToScript(LocalId, taskID);
- taskIDict[taskID].PermsMask &= ~(
- 2048 | //PERMISSION_CONTROL_CAMERA
- 4); // PERMISSION_TAKE_CONTROLS
- }
+ UnRegisterControlEventsToScript(LocalId, taskID);
+ taskIDict[taskID].PermsMask &= ~(
+ 2048 | //PERMISSION_CONTROL_CAMERA
+ 4); // PERMISSION_TAKE_CONTROLS
}
-
}
+ part.TaskInventory.LockItemsForRead(false);
// Reset sit target.
if (part.GetAvatarOnSitTarget() == UUID)
part.SetAvatarOnSitTarget(UUID.Zero);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b549b5c..a94cd46 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -275,40 +275,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected UUID InventorySelf()
{
UUID invItemID = new UUID();
-
- lock (m_host.TaskInventory)
+ bool unlock = false;
+ if (!m_host.TaskInventory.IsReadLockedByMe())
+ {
+ m_host.TaskInventory.LockItemsForRead(true);
+ unlock = true;
+ }
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
{
- if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
- {
- invItemID = inv.Key;
- break;
- }
+ invItemID = inv.Key;
+ break;
}
}
-
+ if (unlock)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ }
return invItemID;
}
protected UUID InventoryKey(string name, int type)
{
m_host.AddScriptLPS(1);
-
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
+ m_host.TaskInventory.LockItemsForRead(false);
+
+ if (inv.Value.Type != type)
{
- if (inv.Value.Type != type)
- return UUID.Zero;
-
- return inv.Value.AssetID;
+ return UUID.Zero;
}
+
+ return inv.Value.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@@ -316,17 +324,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
- {
- return inv.Value.AssetID;
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
+
return UUID.Zero;
}
@@ -2537,12 +2549,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
+ m_host.TaskInventory.LockItemsForRead(true);
TaskInventoryItem item = m_host.TaskInventory[invItemID];
-
- lock (m_host.TaskInventory)
- {
- item = m_host.TaskInventory[invItemID];
- }
+ m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero)
return 0;
@@ -2617,6 +2626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (dist > m_ScriptDistanceFactor * 10.0f)
return;
+ //Clone is thread-safe
TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
foreach (KeyValuePair inv in partInventory)
@@ -2750,13 +2760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != UUID.Zero)
{
@@ -2778,13 +2792,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
TaskInventoryItem item;
+ m_host.TaskInventory.LockItemsForRead(true);
lock (m_host.TaskInventory)
{
+
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
return;
+ }
else
+ {
item = m_host.TaskInventory[InventorySelf()];
+ }
}
+ m_host.TaskInventory.LockItemsForRead(false);
m_host.AddScriptLPS(1);
@@ -2821,14 +2843,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (item.PermsGranter != m_host.OwnerID)
return;
@@ -2853,13 +2881,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (item.PermsGranter != m_host.OwnerID)
return;
@@ -3083,14 +3117,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
-
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero)
return;
@@ -3120,13 +3157,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (item.PermsGranter == UUID.Zero)
return;
@@ -3199,10 +3241,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(invItemID))
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
{
item = m_host.TaskInventory[invItemID];
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (agentID == UUID.Zero || perm == 0) // Releasing permissions
{
@@ -3234,11 +3284,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsGranter = agentID;
- m_host.TaskInventory[invItemID].PermsMask = perm;
- }
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsGranter = agentID;
+ m_host.TaskInventory[invItemID].PermsMask = perm;
+ m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@@ -3258,11 +3307,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsGranter = agentID;
- m_host.TaskInventory[invItemID].PermsMask = perm;
- }
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsGranter = agentID;
+ m_host.TaskInventory[invItemID].PermsMask = perm;
+ m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@@ -3283,11 +3331,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_waitingForScriptAnswer)
{
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsGranter = agentID;
- m_host.TaskInventory[invItemID].PermsMask = 0;
- }
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsGranter = agentID;
+ m_host.TaskInventory[invItemID].PermsMask = 0;
+ m_host.TaskInventory.LockItemsForWrite(false);
presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
m_waitingForScriptAnswer=true;
@@ -3322,10 +3369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
llReleaseControls();
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsMask = answer;
- }
+
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsMask = answer;
+ m_host.TaskInventory.LockItemsForWrite(false);
+
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@@ -3337,16 +3385,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.ItemID == m_itemID)
{
- if (item.Type == 10 && item.ItemID == m_itemID)
- {
- return item.PermsGranter.ToString();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return item.PermsGranter.ToString();
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
}
@@ -3355,19 +3404,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.ItemID == m_itemID)
{
- if (item.Type == 10 && item.ItemID == m_itemID)
- {
- int perms = item.PermsMask;
- if (m_automaticLinkPermission)
- perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
- return perms;
- }
+ int perms = item.PermsMask;
+ if (m_automaticLinkPermission)
+ perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return perms;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return 0;
}
@@ -3400,11 +3450,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID invItemID = InventorySelf();
TaskInventoryItem item;
- lock (m_host.TaskInventory)
- {
- item = m_host.TaskInventory[invItemID];
- }
-
+ m_host.TaskInventory.LockItemsForRead(true);
+ item = m_host.TaskInventory[invItemID];
+ m_host.TaskInventory.LockItemsForRead(false);
+
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
{
@@ -3457,16 +3506,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf();
- lock (m_host.TaskInventory)
- {
+ m_host.TaskInventory.LockItemsForRead(true);
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
{
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
+ m_host.TaskInventory.LockItemsForRead(false);
return;
}
- }
-
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (linknum < ScriptBaseClass.LINK_THIS)
return;
@@ -3635,17 +3684,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
int count = 0;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Type == type || type == -1)
{
- if (inv.Value.Type == type || type == -1)
- {
- count = count + 1;
- }
+ count = count + 1;
}
}
-
+
+ m_host.TaskInventory.LockItemsForRead(false);
return count;
}
@@ -3654,16 +3702,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
ArrayList keys = new ArrayList();
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Type == type || type == -1)
{
- if (inv.Value.Type == type || type == -1)
- {
- keys.Add(inv.Value.Name);
- }
+ keys.Add(inv.Value.Name);
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (keys.Count == 0)
{
@@ -3700,20 +3747,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// move the first object found with this inventory name
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == inventory)
{
- if (inv.Value.Name == inventory)
- {
- found = true;
- objId = inv.Key;
- assetType = inv.Value.Type;
- objName = inv.Value.Name;
- break;
- }
+ found = true;
+ objId = inv.Key;
+ assetType = inv.Value.Type;
+ objName = inv.Value.Name;
+ break;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (!found)
{
@@ -3763,20 +3809,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Name == name)
{
- if (item.Name == name)
- {
- if (item.ItemID == m_itemID)
- throw new ScriptDeleteException();
- else
- m_host.Inventory.RemoveInventoryItem(item.ItemID);
- return;
- }
+ if (item.ItemID == m_itemID)
+ throw new ScriptDeleteException();
+ else
+ m_host.Inventory.RemoveInventoryItem(item.ItemID);
+
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
public void llSetText(string text, LSL_Vector color, double alpha)
@@ -3865,6 +3912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
+ //Clone is thread safe
TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -3955,17 +4003,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID soundId = UUID.Zero;
if (!UUID.TryParse(impact_sound, out soundId))
{
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
{
- if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
- {
- soundId = item.AssetID;
- break;
- }
+ soundId = item.AssetID;
+ break;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
m_host.CollisionSound = soundId;
m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4011,6 +4058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID partItemID;
foreach (SceneObjectPart part in parts)
{
+ //Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4218,17 +4266,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.ItemID == m_itemID)
{
- if (item.Type == 10 && item.ItemID == m_itemID)
- {
- result = item.Name!=null?item.Name:String.Empty;
- break;
- }
+ result = item.Name!=null?item.Name:String.Empty;
+ break;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return result;
}
@@ -4486,23 +4533,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
+ if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
{
- if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
- {
- return inv.Value.AssetID.ToString();
- }
- else
- {
- return UUID.Zero.ToString();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.AssetID.ToString();
+ }
+ else
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return UUID.Zero.ToString();
}
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
}
@@ -5997,14 +6045,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected UUID GetTaskInventoryItem(string name)
{
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
- return inv.Key;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Key;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@@ -6315,22 +6365,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// copy the first script found with this inventory name
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
+ // make sure the object is a script
+ if (10 == inv.Value.Type)
{
- // make sure the object is a script
- if (10 == inv.Value.Type)
- {
- found = true;
- srcId = inv.Key;
- break;
- }
+ found = true;
+ srcId = inv.Key;
+ break;
}
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (!found)
{
@@ -8133,28 +8182,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == item)
{
- if (inv.Value.Name == item)
+ m_host.TaskInventory.LockItemsForRead(false);
+ switch (mask)
{
- switch (mask)
- {
- case 0:
- return (int)inv.Value.BasePermissions;
- case 1:
- return (int)inv.Value.CurrentPermissions;
- case 2:
- return (int)inv.Value.GroupPermissions;
- case 3:
- return (int)inv.Value.EveryonePermissions;
- case 4:
- return (int)inv.Value.NextPermissions;
- }
+ case 0:
+ return (int)inv.Value.BasePermissions;
+ case 1:
+ return (int)inv.Value.CurrentPermissions;
+ case 2:
+ return (int)inv.Value.GroupPermissions;
+ case 3:
+ return (int)inv.Value.EveryonePermissions;
+ case 4:
+ return (int)inv.Value.NextPermissions;
}
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return -1;
}
@@ -8169,16 +8218,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == item)
{
- if (inv.Value.Name == item)
- {
- return inv.Value.CreatorID.ToString();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.CreatorID.ToString();
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
llSay(0, "No item name '" + item + "'");
@@ -8702,16 +8751,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
- {
- return inv.Value.Type;
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.Type;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return -1;
}
@@ -8742,17 +8791,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (invItemID == UUID.Zero)
return new LSL_Vector();
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
- if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
- return new LSL_Vector();
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Vector();
+ }
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
- {
- ShoutError("No permissions to track the camera");
- return new LSL_Vector();
- }
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
+ {
+ ShoutError("No permissions to track the camera");
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Vector();
}
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
if (presence != null)
@@ -8770,17 +8822,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (invItemID == UUID.Zero)
return new LSL_Rotation();
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
- if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
- return new LSL_Rotation();
-
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
- {
- ShoutError("No permissions to track the camera");
- return new LSL_Rotation();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Rotation();
}
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
+ {
+ ShoutError("No permissions to track the camera");
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Rotation();
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
if (presence != null)
@@ -8930,14 +8984,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (objectID == UUID.Zero) return;
UUID agentID;
- lock (m_host.TaskInventory)
- {
- // we need the permission first, to know which avatar we want to set the camera for
- agentID = m_host.TaskInventory[invItemID].PermsGranter;
+ m_host.TaskInventory.LockItemsForRead(true);
+ // we need the permission first, to know which avatar we want to set the camera for
+ agentID = m_host.TaskInventory[invItemID].PermsGranter;
- if (agentID == UUID.Zero) return;
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
+ if (agentID == UUID.Zero)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID);
@@ -8987,12 +9048,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// we need the permission first, to know which avatar we want to clear the camera for
UUID agentID;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ agentID = m_host.TaskInventory[invItemID].PermsGranter;
+ if (agentID == UUID.Zero)
{
- agentID = m_host.TaskInventory[invItemID].PermsGranter;
- if (agentID == UUID.Zero) return;
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID);
@@ -9449,15 +9517,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal UUID ScriptByName(string name)
{
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.Name == name)
{
- if (item.Type == 10 && item.Name == name)
- return item.ItemID;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return item.ItemID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
return UUID.Zero;
}
@@ -9498,6 +9570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
+ //Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
@@ -9560,6 +9633,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
+ //Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7fdbac8..83322eb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (target != null)
{
UUID animID=UUID.Zero;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == animation)
{
- if (inv.Value.Name == animation)
- {
- if (inv.Value.Type == (int)AssetType.Animation)
- animID = inv.Value.AssetID;
- continue;
- }
+ if (inv.Value.Type == (int)AssetType.Animation)
+ animID = inv.Value.AssetID;
+ continue;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (animID == UUID.Zero)
target.Animator.AddAnimation(animation, m_host.UUID);
else
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (target != null)
{
UUID animID=UUID.Zero;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == animation)
{
- if (inv.Value.Name == animation)
- {
- if (inv.Value.Type == (int)AssetType.Animation)
- animID = inv.Value.AssetID;
- continue;
- }
+ if (inv.Value.Type == (int)AssetType.Animation)
+ animID = inv.Value.AssetID;
+ continue;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (animID == UUID.Zero)
target.Animator.RemoveAnimation(animation);
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
+ m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
+ m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
+ m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 063d50f..0f4a9ad 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -238,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (part != null)
{
- lock (part.TaskInventory)
+ part.TaskInventory.LockItemsForRead(true);
+ if (part.TaskInventory.ContainsKey(m_ItemID))
{
- if (part.TaskInventory.ContainsKey(m_ItemID))
- {
- m_thisScriptTask = part.TaskInventory[m_ItemID];
- }
+ m_thisScriptTask = part.TaskInventory[m_ItemID];
}
+ part.TaskInventory.LockItemsForRead(false);
}
ApiManager am = new ApiManager();
@@ -429,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
int permsMask;
UUID permsGranter;
- lock (part.TaskInventory)
+ part.TaskInventory.LockItemsForRead(true);
+ if (!part.TaskInventory.ContainsKey(m_ItemID))
{
- if (!part.TaskInventory.ContainsKey(m_ItemID))
- return;
-
- permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
- permsMask = part.TaskInventory[m_ItemID].PermsMask;
+ part.TaskInventory.LockItemsForRead(false);
+ return;
}
+ permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
+ permsMask = part.TaskInventory[m_ItemID].PermsMask;
+ part.TaskInventory.LockItemsForRead(false);
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
{
--
cgit v1.1
From 8383bde76880fc94a6644422d45baa28252b0231 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Tue, 24 Nov 2009 18:18:19 +0100
Subject: Removed some extra debug chatter
---
.../CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 2 +-
OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index d9a021f..b60b32b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -389,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
// Check if this is ours to handle
//
- m_log.Info("OnFridInstantMessage");
+ //m_log.Info("OnFridInstantMessage");
if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered)
return;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 4dc709e..abb04cd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -713,7 +713,6 @@ namespace OpenSim.Region.Framework.Scenes
if (fileData.Length > 2)
{
- m_log.Debug("Sending task inventory list of " + count.ToString() + " items to client " + client.AgentId.ToString());
xferManager.AddNewFile(m_inventoryFileName, fileData);
}
}
--
cgit v1.1
From d5aceb6d95779b19d13eef9f2427c79233166a63 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Tue, 24 Nov 2009 23:33:12 +0100
Subject: Append a prefix to the god avatar names appearing in chat whilst in
god mode (disabled by default, config entry admin_prefix)
---
OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 5c24f03..1e63e3e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
private int m_shoutdistance = 100;
private int m_whisperdistance = 10;
private List m_scenes = new List();
-
+ private string m_adminPrefix = "";
internal object m_syncy = new object();
internal IConfig m_config;
@@ -76,6 +76,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
+ m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
}
public virtual void AddRegion(Scene scene)
@@ -185,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
{
string fromName = c.From;
+ string fromNamePrefix = "";
UUID fromID = UUID.Zero;
string message = c.Message;
IScene scene = c.Scene;
@@ -207,7 +209,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
fromPos = avatar.AbsolutePosition;
fromName = avatar.Name;
fromID = c.Sender.AgentId;
-
+ if (avatar.GodLevel > 200)
+ {
+ fromNamePrefix = m_adminPrefix;
+ }
break;
case ChatSourceType.Object:
@@ -227,7 +232,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
s.ForEachScenePresence(
delegate(ScenePresence presence)
{
- TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType);
+ TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType);
}
);
}
--
cgit v1.1
From 32c464ad1f43cbee9492108c1bec7f874a20cd47 Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Wed, 25 Nov 2009 08:03:09 +0100
Subject: Fixed animation sequencing: SitHere, Falling, Stand/Walk etc. Login
Init Av Animation at Stand.
---
.../Scenes/Animation/ScenePresenceAnimator.cs | 15 ++++++----
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 34 +++++++++++++++-------
2 files changed, 33 insertions(+), 16 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 30a95ce..2d41342 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -53,8 +53,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
{
get { return m_movementAnimation; }
}
- protected string m_movementAnimation = "DEFAULT";
-
+ // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist!
+ protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init.
private int m_animTickFall;
private int m_animTickJump;
@@ -123,17 +123,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation
///
public void TrySetMovementAnimation(string anim)
{
- //m_log.DebugFormat("Updating movement animation to {0}", anim);
+//Console.WriteLine("Updating movement animation to {0}", anim);
if (!m_scenePresence.IsChildAgent)
{
if (m_animations.TrySetDefaultAnimation(
anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero))
{
+//Console.WriteLine("TSMA {0} success.", anim);
// 16384 is CHANGED_ANIMATION
m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 });
SendAnimPack();
}
+ else
+ {
+//Console.WriteLine("TSMA {0} fail.", anim);
+ }
}
}
@@ -313,7 +318,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
public void UpdateMovementAnimations()
{
m_movementAnimation = GetMovementAnimation();
-
+//Console.WriteLine("UMA got {0}", m_movementAnimation);
if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump)
{
// This was the previous behavior before PREJUMP
@@ -445,4 +450,4 @@ namespace OpenSim.Region.Framework.Scenes.Animation
SendAnimPack(animIDs, sequenceNums, objectIDs);
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4e5fee1..a65b84b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -90,6 +90,7 @@ namespace OpenSim.Region.Framework.Scenes
/// issue #1716
///
// private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f);
+ // Value revised by KF 091121 by comparison with SL.
private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f);
public UUID currentParcelUUID = UUID.Zero;
@@ -205,6 +206,9 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_followCamAuto;
private int m_movementUpdateCount;
+ private int m_lastColCount = -1; //KF: Look for Collision chnages
+ private int m_updateCount = 0; //KF: Update Anims for a while
+ private static readonly int UPDATE_COUNT = 10; // how many frames to update for
private const int NumMovementsBetweenRayCast = 5;
@@ -662,9 +666,7 @@ namespace OpenSim.Region.Framework.Scenes
AdjustKnownSeeds();
- // TODO: I think, this won't send anything, as we are still a child here...
- Animator.TrySetMovementAnimation("STAND");
-
+ Animator.TrySetMovementAnimation("STAND");
// we created a new ScenePresence (a new child agent) in a fresh region.
// Request info about all the (root) agents in this region
// Note: This won't send data *to* other clients in that region (children don't send)
@@ -1018,7 +1020,9 @@ namespace OpenSim.Region.Framework.Scenes
{
AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f));
}
-
+
+ m_updateCount = UPDATE_COUNT; //KF: Trigger Anim updates to catch falling anim.
+
ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
}
@@ -1266,9 +1270,7 @@ namespace OpenSim.Region.Framework.Scenes
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
{
- // TODO: This doesn't prevent the user from walking yet.
- // Setting parent ID would fix this, if we knew what value
- // to use. Or we could add a m_isSitting variable.
+ m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.
Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
}
@@ -1926,7 +1928,6 @@ namespace OpenSim.Region.Framework.Scenes
public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance)
{
-// Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance);
if(hitYN)
{
// m_pos = Av offset from prim center to make look like on center
@@ -2964,6 +2965,7 @@ namespace OpenSim.Region.Framework.Scenes
m_updateflag = true;
Velocity = force;
m_isNudging = false;
+ m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND"
}
}
}
@@ -3015,19 +3017,29 @@ namespace OpenSim.Region.Framework.Scenes
// Event called by the physics plugin to tell the avatar about a collision.
private void PhysicsCollisionUpdate(EventArgs e)
{
+ if (m_updateCount > 0) //KF: Update Anims for a short period. Many Anim
+ { // changes are very asynchronous.
+ Animator.UpdateMovementAnimations();
+ m_updateCount--;
+ }
+
if (e == null)
return;
- //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
// The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents(
// as of this comment the interval is set in AddToPhysicalScene
- Animator.UpdateMovementAnimations();
-
+
CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
Dictionary coldata = collisionData.m_objCollisionList;
CollisionPlane = Vector4.UnitW;
+ if (m_lastColCount != coldata.Count)
+ {
+ m_updateCount = 10;
+ m_lastColCount = coldata.Count;
+ }
+
if (coldata.Count != 0)
{
switch (Animator.CurrentMovementAnimation)
--
cgit v1.1
From c81f37cf82c3a9d2aae92d5f44734fc5098c5b75 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 25 Nov 2009 17:01:41 +0000
Subject: Change osTeleportAgent parameters from long to int. That numerical
range is not even supported by the underlying type, so there is no need to
ask for a type the script can not even supply.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++--
OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +-
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 83322eb..10165d3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -636,13 +636,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// Teleport functions
- public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+ public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
{
// High because there is no security check. High griefer potential
//
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
- ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize));
+ ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
m_host.AddScriptLPS(1);
UUID agentId = new UUID();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 2a403bf..470946a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
// Teleport commands
void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
- void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
+ void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
// Animation commands
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 4928e90..6b88834 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -201,9 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat);
}
- public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat)
+ public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat)
{
- m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat);
+ m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat);
}
public void osTeleportAgent(string agent, vector position, vector lookat)
--
cgit v1.1
From de927adf2709f50d0fe85a1c59e7677d862d0d72 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 25 Nov 2009 20:01:21 +0000
Subject: Add the dummy "Size" property to the list type
---
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 3f38bb6..1fc31c5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -429,6 +429,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
+ public int Size
+ {
+ get { return 0; }
+ }
+
public object[] Data
{
get {
--
cgit v1.1
From b9d22aa8213b62eb0c368b345ccfc105367c1aba Mon Sep 17 00:00:00 2001
From: CasperW
Date: Thu, 26 Nov 2009 01:59:08 +0100
Subject: Add nudge right and left to avatar movement (faster reaction times
when stepping left or right.)
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4c8c94f..9b04422 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes
protected RegionInfo m_regionInfo;
protected ulong crossingFromRegion;
- private readonly Vector3[] Dir_Vectors = new Vector3[9];
+ private readonly Vector3[] Dir_Vectors = new Vector3[11];
private bool m_isNudging = false;
// Position of agent's camera in world (region cordinates)
@@ -236,6 +236,8 @@ namespace OpenSim.Region.Framework.Scenes
DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS,
DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
+ DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS,
+ DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG,
DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
}
@@ -722,12 +724,14 @@ namespace OpenSim.Region.Framework.Scenes
Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE
Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE
- Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
+ Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE
+ Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE
+ Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
}
private Vector3[] GetWalkDirectionVectors()
{
- Vector3[] vector = new Vector3[9];
+ Vector3[] vector = new Vector3[11];
vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD
vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK
vector[2] = Vector3.UnitY; //LEFT
@@ -736,13 +740,15 @@ namespace OpenSim.Region.Framework.Scenes
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN
vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE
vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE
- vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
+ vector[8] = Vector3.UnitY; //LEFT_NUDGE
+ vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
+ vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
return vector;
}
private bool[] GetDirectionIsNudge()
{
- bool[] isNudge = new bool[9];
+ bool[] isNudge = new bool[11];
isNudge[0] = false; //FORWARD
isNudge[1] = false; //BACK
isNudge[2] = false; //LEFT
@@ -751,7 +757,9 @@ namespace OpenSim.Region.Framework.Scenes
isNudge[5] = false; //DOWN
isNudge[6] = true; //FORWARD_NUDGE
isNudge[7] = true; //BACK_NUDGE
- isNudge[8] = true; //DOWN_Nudge
+ isNudge[8] = true; //LEFT_NUDGE
+ isNudge[9] = true; //RIGHT_NUDGE
+ isNudge[10] = true; //DOWN_Nudge
return isNudge;
}
--
cgit v1.1
From 63b6b9cdce6382e2285b1a9d76e68a0ac10602ef Mon Sep 17 00:00:00 2001
From: CasperW
Date: Thu, 26 Nov 2009 02:35:27 +0100
Subject: Added animation support for my last commit
---
OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 4 ++--
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 30a95ce..2c4a4b0 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -158,8 +158,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
// Check control flags
bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS);
bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
- bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
- bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
+ bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS);
+ bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG);
//bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
//bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT;
bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9b04422..a1bb244 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -742,7 +742,7 @@ namespace OpenSim.Region.Framework.Scenes
vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE
vector[8] = Vector3.UnitY; //LEFT_NUDGE
vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
- vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
+ vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE
return vector;
}
--
cgit v1.1
From ac2fcbe224d4877dccc4d73e9c58771e40a4ae1c Mon Sep 17 00:00:00 2001
From: CasperW
Date: Thu, 26 Nov 2009 15:17:44 +0100
Subject: Improvements to rAdmin admin_shutdown and admin_restart. Both methods
can now accept a parameter of noticetype = dialog in order to display a blue
persistant dropdown instead of a short notice. Added an optional and
configurable delay to the restart method, defaulting at 30 seconds as before.
Both methods can also accept a noticetype = none dialog in order to act
silently.
---
.../RemoteController/RemoteAdminPlugin.cs | 74 +++++++++++++++++++++-
OpenSim/Region/Framework/Scenes/Scene.cs | 16 ++++-
2 files changed, 86 insertions(+), 4 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 3bc557d..325816d 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -213,9 +213,59 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
throw new Exception("region not found");
+ int timeout = 30000;
+ string message;
+
+ if (requestData.ContainsKey("restart")
+ && ((string)requestData["restart"] == "delayed")
+ && requestData.ContainsKey("milliseconds"))
+ {
+ timeout = Int32.Parse(requestData["milliseconds"].ToString());
+
+ if (timeout < 15000)
+ {
+ //It must be at least 15 seconds or we'll cancel the reboot request
+ timeout = 15000;
+ }
+
+ message
+ = "Region is restarting in " + ((int)(timeout / 1000)).ToString()
+ + " second(s). Please save what you are doing and log out.";
+ }
+ else
+ {
+ message = "Region is restarting in 30 second(s). Please save what you are doing and log out.";
+ }
+
+ if (requestData.ContainsKey("noticetype")
+ && ((string)requestData["noticetype"] == "dialog"))
+ {
+ m_app.SceneManager.ForEachScene(
+ delegate(Scene scene)
+ {
+ IDialogModule dialogModule = scene.RequestModuleInterface();
+ if (dialogModule != null)
+ dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
+ });
+ }
+ else
+ {
+ if (!requestData.ContainsKey("noticetype")
+ || ((string)requestData["noticetype"] != "none"))
+ {
+ m_app.SceneManager.ForEachScene(
+ delegate(Scene scene)
+ {
+ IDialogModule dialogModule = scene.RequestModuleInterface();
+ if (dialogModule != null)
+ dialogModule.SendGeneralAlert(message);
+ });
+ }
+ }
+
responseData["rebooting"] = true;
response.Value = responseData;
- rebootedScene.Restart(30);
+ rebootedScene.Restart(timeout / 1000,false);
}
catch (Exception e)
{
@@ -419,13 +469,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
message = "Region is going down now.";
}
- m_app.SceneManager.ForEachScene(
+ if (requestData.ContainsKey("noticetype")
+ && ((string) requestData["noticetype"] == "dialog"))
+ {
+ m_app.SceneManager.ForEachScene(
delegate(Scene scene)
{
IDialogModule dialogModule = scene.RequestModuleInterface();
if (dialogModule != null)
+ dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
+ });
+ }
+ else
+ {
+ if (!requestData.ContainsKey("noticetype")
+ || ((string)requestData["noticetype"] != "none"))
+ {
+ m_app.SceneManager.ForEachScene(
+ delegate(Scene scene)
+ {
+ IDialogModule dialogModule = scene.RequestModuleInterface();
+ if (dialogModule != null)
dialogModule.SendGeneralAlert(message);
});
+ }
+ }
+
+
// Perform shutdown
System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4ffa1a2..be1d4bf 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -873,6 +873,15 @@ namespace OpenSim.Region.Framework.Scenes
/// float indicating duration before restart.
public virtual void Restart(float seconds)
{
+ Restart(seconds, true);
+ }
+
+ ///
+ /// Given float seconds, this will restart the region. showDialog will optionally alert the users.
+ ///
+ /// float indicating duration before restart.
+ public virtual void Restart(float seconds, bool showDialog)
+ {
// notifications are done in 15 second increments
// so .. if the number of seconds is less then 15 seconds, it's not really a restart request
// It's a 'Cancel restart' request.
@@ -893,8 +902,11 @@ namespace OpenSim.Region.Framework.Scenes
m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
m_restartTimer.Start();
- m_dialogModule.SendNotificationToUsersInRegion(
- UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
+ if (showDialog)
+ {
+ m_dialogModule.SendNotificationToUsersInRegion(
+ UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + (seconds / 60).ToString() + " Minutes");
+ }
}
}
--
cgit v1.1
From 22c325aa5ae06b897e5eb10404c0aa3727f8237b Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 12:08:20 +0000
Subject: Remove GetAssemblyName and friends from the SE interface. It's now
handled internally
---
.../Framework/Interfaces/IEntityInventory.cs | 6 --
.../Region/Framework/Interfaces/IScriptModule.cs | 1 -
.../Framework/Scenes/SceneObjectGroup.Inventory.cs | 93 ++-------------------
.../Framework/Scenes/SceneObjectPartInventory.cs | 30 -------
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 95 ++++++++++++++++++++--
5 files changed, 91 insertions(+), 134 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 2c906a2..2998f45 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -185,12 +185,6 @@ namespace OpenSim.Region.Framework.Interfaces
List GetInventoryList();
///
- /// Get the names of the assemblies associated with scripts in this inventory.
- ///
- ///
- string[] GetScriptAssemblies();
-
- ///
/// Get the xml representing the saved states of scripts in this inventory.
///
///
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 10835b9..72bb0f0 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
{
string ScriptEngineName { get; }
- string GetAssemblyName(UUID itemID);
string GetXMLState(UUID itemID);
bool CanBeDeleted(UUID itemID);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 3cec77f..9a6f2b8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes
public string GetStateSnapshot()
{
- //m_log.Debug(" >>> GetStateSnapshot <<<");
-
- List assemblies = new List();
Dictionary states = new Dictionary();
foreach (SceneObjectPart part in m_parts.Values)
{
- foreach (string a in part.Inventory.GetScriptAssemblies())
- {
- if (a != "" && !assemblies.Contains(a))
- assemblies.Add(a);
- }
-
foreach (KeyValuePair s in part.Inventory.GetScriptStates())
- {
states[s.Key] = s.Value;
- }
}
- if (states.Count < 1 || assemblies.Count < 1)
+ if (states.Count < 1)
return "";
XmlDocument xmldoc = new XmlDocument();
@@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes
xmldoc.AppendChild(rootElement);
- XmlElement wrapper = xmldoc.CreateElement("", "Assemblies",
- "");
- rootElement.AppendChild(wrapper);
-
- foreach (string assembly in assemblies)
- {
- string fn = Path.GetFileName(assembly);
- if (fn == String.Empty)
- continue;
-
- String filedata = String.Empty;
-
- if (File.Exists(assembly+".text"))
- {
- FileInfo tfi = new FileInfo(assembly+".text");
-
- if (tfi == null)
- continue;
-
- Byte[] tdata = new Byte[tfi.Length];
-
- try
- {
- FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read);
- tfs.Read(tdata, 0, tdata.Length);
- tfs.Close();
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message);
- }
-
- filedata = new System.Text.ASCIIEncoding().GetString(tdata);
- }
- else
- {
- FileInfo fi = new FileInfo(assembly);
-
- if (fi == null)
- continue;
-
- Byte[] data = new Byte[fi.Length];
-
- try
- {
- FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
- fs.Read(data, 0, data.Length);
- fs.Close();
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
- }
-
- filedata = System.Convert.ToBase64String(data);
- }
- XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
- XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
- assemblyName.Value = fn;
- assemblyData.Attributes.Append(assemblyName);
-
- assemblyData.InnerText = filedata;
-
- wrapper.AppendChild(assemblyData);
- }
-
- wrapper = xmldoc.CreateElement("", "ScriptStates",
+ XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates",
"");
rootElement.AppendChild(wrapper);
foreach (KeyValuePair state in states)
{
- XmlElement stateData = xmldoc.CreateElement("", "State", "");
-
- XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", "");
- stateID.Value = state.Key.ToString();
- stateData.Attributes.Append(stateID);
-
XmlDocument sdoc = new XmlDocument();
sdoc.LoadXml(state.Value);
- XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
+ XmlNodeList rootL = sdoc.GetElementsByTagName("State");
XmlNode rootNode = rootL[0];
XmlNode newNode = xmldoc.ImportNode(rootNode, true);
- stateData.AppendChild(newNode);
- wrapper.AppendChild(stateData);
+ wrapper.AppendChild(newNode);
}
return xmldoc.InnerXml;
@@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SetState(string objXMLData, UUID RegionID)
{
+m_log.Debug("SetState called with " + objXMLData);
if (objXMLData == String.Empty)
return;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index abb04cd..2ef8258 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -880,36 +880,6 @@ namespace OpenSim.Region.Framework.Scenes
return ret;
}
- public string[] GetScriptAssemblies()
- {
- IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces();
-
- List ret = new List();
- if (engines == null) // No engine at all
- return new string[0];
-
- foreach (TaskInventoryItem item in m_items.Values)
- {
- if (item.InvType == (int)InventoryType.LSL)
- {
- foreach (IScriptModule e in engines)
- {
- if (e != null)
- {
- string n = e.GetAssemblyName(item.ItemID);
- if (n != String.Empty)
- {
- if (!ret.Contains(n))
- ret.Add(n);
- break;
- }
- }
- }
- }
- }
- return ret.ToArray();
- }
-
public Dictionary GetScriptStates()
{
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces();
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 8b94f28..4dc6cb8 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1248,20 +1248,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
- public string GetAssemblyName(UUID itemID)
- {
- IScriptInstance instance = GetInstance(itemID);
- if (instance == null)
- return "";
- return instance.GetAssemblyName();
- }
-
public string GetXMLState(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return "";
- return instance.GetXMLState();
+ string xml = instance.GetXMLState();
+
+ XmlDocument sdoc = new XmlDocument();
+ sdoc.LoadXml(xml);
+ XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
+ XmlNode rootNode = rootL[0];
+
+ // Create
+ XmlDocument doc = new XmlDocument();
+ XmlElement stateData = doc.CreateElement("", "State", "");
+ XmlAttribute stateID = doc.CreateAttribute("", "UUID", "");
+ stateID.Value = itemID.ToString();
+ stateData.Attributes.Append(stateID);
+ XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
+ assetID.Value = instance.AssetID.ToString();
+ stateData.Attributes.Append(assetID);
+ doc.AppendChild(stateData);
+
+ // Add ...
+ XmlNode xmlstate = doc.ImportNode(rootNode, true);
+ stateData.AppendChild(xmlstate);
+
+ string assemName = instance.GetAssemblyName();
+
+ string fn = Path.GetFileName(assemName);
+
+ string assem = String.Empty;
+
+ if (File.Exists(assemName + ".text"))
+ {
+ FileInfo tfi = new FileInfo(assemName + ".text");
+
+ if (tfi != null)
+ {
+ Byte[] tdata = new Byte[tfi.Length];
+
+ try
+ {
+ FileStream tfs = File.Open(assemName + ".text",
+ FileMode.Open, FileAccess.Read);
+ tfs.Read(tdata, 0, tdata.Length);
+ tfs.Close();
+
+ assem = new System.Text.ASCIIEncoding().GetString(tdata);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message);
+ }
+ }
+ }
+ else
+ {
+ FileInfo fi = new FileInfo(assemName);
+
+ if (fi != null)
+ {
+ Byte[] data = new Byte[fi.Length];
+
+ try
+ {
+ FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read);
+ fs.Read(data, 0, data.Length);
+ fs.Close();
+
+ assem = System.Convert.ToBase64String(data);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message);
+ }
+
+ }
+ }
+
+ XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
+ XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", "");
+
+ assemblyName.Value = fn;
+ assemblyData.Attributes.Append(assemblyName);
+
+ assemblyData.InnerText = assem;
+
+ stateData.AppendChild(assemblyData);
+
+ return doc.InnerXml;
}
public bool CanBeDeleted(UUID itemID)
--
cgit v1.1
From a27d33cb634c78425eaa34cb5efd113e131baa51 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 12:16:42 +0000
Subject: Remove the old remoting-type interregion code for prim/script
crossing
---
OpenSim/Framework/IRegionCommsListener.cs | 2 -
OpenSim/Framework/RegionCommsListener.cs | 25 ------
OpenSim/Region/Framework/Scenes/Scene.cs | 99 ----------------------
.../Framework/Scenes/SceneCommunicationService.cs | 72 ----------------
4 files changed, 198 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/IRegionCommsListener.cs b/OpenSim/Framework/IRegionCommsListener.cs
index 307c6bc..cd59c63 100644
--- a/OpenSim/Framework/IRegionCommsListener.cs
+++ b/OpenSim/Framework/IRegionCommsListener.cs
@@ -32,7 +32,6 @@ namespace OpenSim.Framework
{
public delegate void ExpectUserDelegate(AgentCircuitData agent);
- public delegate bool ExpectPrimDelegate(UUID primID, string objData, int XMLMethod);
public delegate void UpdateNeighbours(List neighbours);
@@ -55,7 +54,6 @@ namespace OpenSim.Framework
public interface IRegionCommsListener
{
event ExpectUserDelegate OnExpectUser;
- event ExpectPrimDelegate OnExpectPrim;
event GenericCall2 OnExpectChildAgent;
event AgentCrossing OnAvatarCrossingIntoRegion;
event PrimCrossing OnPrimCrossingIntoRegion;
diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs
index 90200d6..718a556 100644
--- a/OpenSim/Framework/RegionCommsListener.cs
+++ b/OpenSim/Framework/RegionCommsListener.cs
@@ -43,7 +43,6 @@ namespace OpenSim.Framework
private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
private GenericCall2 handlerExpectChildAgent = null; // OnExpectChildAgent;
- private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
@@ -53,7 +52,6 @@ namespace OpenSim.Framework
#region IRegionCommsListener Members
public event ExpectUserDelegate OnExpectUser;
- public event ExpectPrimDelegate OnExpectPrim;
public event GenericCall2 OnExpectChildAgent;
public event AgentCrossing OnAvatarCrossingIntoRegion;
public event PrimCrossing OnPrimCrossingIntoRegion;
@@ -95,17 +93,6 @@ namespace OpenSim.Framework
}
- public virtual bool TriggerExpectPrim(UUID primID, string objData, int XMLMethod)
- {
- handlerExpectPrim = OnExpectPrim;
- if (handlerExpectPrim != null)
- {
- handlerExpectPrim(primID, objData, XMLMethod);
- return true;
- }
- return false;
- }
-
public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
{
handlerChildAgentUpdate = OnChildAgentUpdate;
@@ -128,18 +115,6 @@ namespace OpenSim.Framework
return false;
}
- public virtual bool TriggerExpectPrimCrossing(UUID primID, Vector3 position,
- bool isPhysical)
- {
- handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
- if (handlerPrimCrossingIntoRegion != null)
- {
- handlerPrimCrossingIntoRegion(primID, position, isPhysical);
- return true;
- }
- return false;
- }
-
public virtual bool TriggerAcknowledgeAgentCrossed(UUID agentID)
{
handlerAcknowledgeAgentCrossed = OnAcknowledgeAgentCrossed;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index be1d4bf..f932659 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2393,103 +2393,6 @@ namespace OpenSim.Region.Framework.Scenes
return successYN;
}
- ///
- /// Handle a scene object that is crossing into this region from another.
- /// NOTE: Unused as of 2009-02-09. Soon to be deleted.
- ///
- ///
- ///
- ///
- ///
- ///
- public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod)
- {
- if (XMLMethod == 0)
- {
- m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID);
- SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData);
- if (sceneObject.IsAttachment)
- sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
-
- return AddSceneObject(sceneObject);
- }
- else if ((XMLMethod == 100) && m_allowScriptCrossings)
- {
- m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor");
-
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(objXMLData);
-
- XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
- if (rootL.Count == 1)
- {
- XmlNode rootNode = rootL[0];
- if (rootNode != null)
- {
- XmlNodeList partL = rootNode.ChildNodes;
-
- foreach (XmlNode part in partL)
- {
- XmlNodeList nodeL = part.ChildNodes;
-
- switch (part.Name)
- {
- case "Assemblies":
- foreach (XmlNode asm in nodeL)
- {
- string fn = asm.Attributes.GetNamedItem("Filename").Value;
-
- Byte[] filedata = Convert.FromBase64String(asm.InnerText);
- string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
- path = Path.Combine(path, fn);
-
- if (!File.Exists(path))
- {
- FileStream fs = File.Create(path);
- fs.Write(filedata, 0, filedata.Length);
- fs.Close();
- }
- }
- break;
- case "ScriptStates":
- foreach (XmlNode st in nodeL)
- {
- string id = st.Attributes.GetNamedItem("UUID").Value;
- UUID uuid = new UUID(id);
- XmlNode state = st.ChildNodes[0];
-
- XmlDocument sdoc = new XmlDocument();
- XmlNode sxmlnode = sdoc.CreateNode(
- XmlNodeType.XmlDeclaration,
- "", "");
- sdoc.AppendChild(sxmlnode);
-
- XmlNode newnode = sdoc.ImportNode(state, true);
- sdoc.AppendChild(newnode);
-
- string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
- spath = Path.Combine(spath, uuid.ToString());
- FileStream sfs = File.Create(spath + ".state");
- ASCIIEncoding enc = new ASCIIEncoding();
- Byte[] buf = enc.GetBytes(sdoc.InnerXml);
- sfs.Write(buf, 0, buf.Length);
- sfs.Close();
- }
- break;
- }
- }
- }
- }
-
- SceneObjectPart RootPrim = GetSceneObjectPart(primID);
- RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
-
- return true;
- }
-
- return true;
- }
-
public bool IncomingCreateObject(ISceneObject sog)
{
//m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
@@ -3362,7 +3265,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
//m_eventManager.OnRegionUp += OtherRegionUp;
//m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
- m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
m_sceneGridService.KiPrimitive += SendKillObject;
@@ -3386,7 +3288,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.KiPrimitive -= SendKillObject;
m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
- m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
//m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
//m_eventManager.OnRegionUp -= OtherRegionUp;
m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 76c6cab..3892769 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes
///
/// A Prim will arrive shortly
///
- public event ExpectPrimDelegate OnExpectPrim;
public event CloseAgentConnection OnCloseAgentConnection;
///
@@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
- private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
//private RegionUp handlerRegionUp = null; // OnRegionUp;
@@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes
/// Thrown if region registration fails.
public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
{
- //m_interregionCommsOut = comms_out;
-
- //m_regionInfo = regionInfos;
- //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
- //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
-
- //if (regionCommsHost != null)
- //{
- // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
-
- // regionCommsHost.debugRegionName = regionInfos.RegionName;
- // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
- // regionCommsHost.OnExpectUser += NewUserConnection;
- // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
- // regionCommsHost.OnCloseAgentConnection += CloseConnection;
- // regionCommsHost.OnRegionUp += newRegionUp;
- // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
- // regionCommsHost.OnLogOffUser += GridLogOffUser;
- // regionCommsHost.OnGetLandData += FetchLandData;
- //}
- //else
- //{
- // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
- //}
}
///
@@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes
///
public void Close()
{
-
- //if (regionCommsHost != null)
- //{
- // regionCommsHost.OnLogOffUser -= GridLogOffUser;
- // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
- // regionCommsHost.OnRegionUp -= newRegionUp;
- // regionCommsHost.OnExpectUser -= NewUserConnection;
- // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
- // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
- // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
- // regionCommsHost.OnGetLandData -= FetchLandData;
-
- // try
- // {
- // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
- // }
- // catch (Exception e)
- // {
- // m_log.ErrorFormat(
- // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
- // m_regionInfo.RegionName, e);
- // }
-
- // regionCommsHost = null;
- //}
}
#region CommsManager Event handlers
@@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- ///
- /// We have a new prim from a neighbor
- ///
- /// unique ID for the primative
- /// XML2 encoded data of the primative
- /// An Int that represents the version of the XMLMethod
- /// True if the prim was accepted, false if it was not
- protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod)
- {
- handlerExpectPrim = OnExpectPrim;
- if (handlerExpectPrim != null)
- {
- return handlerExpectPrim(primID, objXMLData, XMLMethod);
- }
- else
- {
- return false;
- }
-
- }
-
protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
{
handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
--
cgit v1.1
From bd3b9f79c2ac25c39d531c3d0c390eacab8ab958 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 17:59:28 +0000
Subject: Update CM version
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index ec94b2d..0d4215b 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.6.9";
+ private const string VERSION_NUMBER = "0.6.9-CM";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
--
cgit v1.1
From ad2f0a1290b9260393a27291fdd8a1592222c368 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 18:04:58 +0000
Subject: Remove OS version crap from about dialog
---
OpenSim/Framework/Util.cs | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 87ba5a8..c052745 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -990,19 +990,19 @@ namespace OpenSim.Framework
{
string os = String.Empty;
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- {
- os = Environment.OSVersion.ToString();
- }
- else
- {
- os = ReadEtcIssue();
- }
-
- if (os.Length > 45)
- {
- os = os.Substring(0, 45);
- }
+// if (Environment.OSVersion.Platform != PlatformID.Unix)
+// {
+// os = Environment.OSVersion.ToString();
+// }
+// else
+// {
+// os = ReadEtcIssue();
+// }
+//
+// if (os.Length > 45)
+// {
+// os = os.Substring(0, 45);
+// }
return os;
}
--
cgit v1.1
From 5dedacca3c9692948f29f5198dd444efe7c8526d Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Thu, 26 Nov 2009 20:37:08 +0100
Subject: First attempt at mult-sit on large single prims.
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 91 +++++++++++++++---------
1 file changed, 58 insertions(+), 33 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a65b84b..e677cfd 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -117,6 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
public Vector4 CollisionPlane = Vector4.UnitW;
private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation
+ private Vector3 m_avUnscriptedSitPos; // for non-scripted prims
private Vector3 m_lastPosition;
private Quaternion m_lastRotation;
private Vector3 m_lastVelocity;
@@ -1644,9 +1645,9 @@ namespace OpenSim.Region.Framework.Scenes
{
AddToPhysicalScene(false);
}
-
m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight);
m_parentPosition = Vector3.Zero;
+//Console.WriteLine("Stand Pos {0}", m_pos);
m_parentID = 0;
SendFullUpdateToAllClients();
@@ -1740,21 +1741,37 @@ namespace OpenSim.Region.Framework.Scenes
//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied +
// " TargSet=" + SitTargetisSet);
-
- if (SitTargetisSet && SitTargetUnOccupied)
- {
- part.SetAvatarOnSitTarget(UUID);
- offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z);
- sitOrientation = avSitOrientation;
- autopilot = false; // Jump direct to scripted llSitPos()
- }
+ // Sit analysis rewritten by KF 091125
+ if (SitTargetisSet) // scipted sit
+ {
+ if (SitTargetUnOccupied)
+ {
+ part.SetAvatarOnSitTarget(UUID); // set that Av will be on it
+ offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one
+ sitOrientation = avSitOrientation; // Change rotatione to the scripted one
+ autopilot = false; // Jump direct to scripted llSitPos()
+ }
+ else return;
+ }
+ else // Not Scripted
+ {
+ if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim
+ {
+ Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ m_avUnscriptedSitPos = offset * partIRot; // sit where clicked
+ pos = part.AbsolutePosition + (offset * partIRot);
+ }
+ else // small prim
+ {
+ if (SitTargetUnOccupied)
+ {
+ m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center
+ pos = part.AbsolutePosition;
+ }
+ else return; // occupied small
+ } // end large/small
+ } // end Scripted/not
- pos = part.AbsolutePosition + offset; // Region position where clicked
- //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1)
- //{
- // offset = pos;
- //autopilot = false;
- //}
if (m_physicsActor != null)
{
// If we're not using the client autopilot, we're immediately warping the avatar to the location
@@ -1887,8 +1904,9 @@ namespace OpenSim.Region.Framework.Scenes
{
// Non-scripted sit by Kitto Flora 21Nov09
// Calculate angle of line from prim to Av
- float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y);
- float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X);
+ Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos;
+ float y_diff = (m_avInitialPos.Y - sitTargetPos.Y);
+ float x_diff = ( m_avInitialPos.X - sitTargetPos.X);
if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0
if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0
float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff);
@@ -1896,23 +1914,30 @@ namespace OpenSim.Region.Framework.Scenes
// NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'.
// Av sits at world euler <0,0, z>, translated by part rotation
m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click
- m_pos = new Vector3(0f, 0f, 0.05f) +
- (new Vector3(0.0f, 0f, 0.625f) * partIRot) +
- (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim
m_parentPosition = part.AbsolutePosition;
- //Set up raytrace to find top surface of prim
- Vector3 size = part.Scale;
- float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
- Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
- Vector3 down = new Vector3(0f, 0f, -1f);
- m_scene.PhysicsScene.RaycastWorld(
- start, // Vector3 position,
- down, // Vector3 direction,
- mag, // float length,
- SitAltitudeCallback); // retMethod
- }
- }
- else
+ if(m_avUnscriptedSitPos != Vector3.Zero)
+ { // sit where clicked on big prim
+ m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot);
+ }
+ else
+ { // sit at center of small prim
+ m_pos = new Vector3(0f, 0f, 0.05f) +
+ (new Vector3(0.0f, 0f, 0.625f) * partIRot) +
+ (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot);
+ //Set up raytrace to find top surface of prim
+ Vector3 size = part.Scale;
+ float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
+ Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
+ Vector3 down = new Vector3(0f, 0f, -1f);
+ m_scene.PhysicsScene.RaycastWorld(
+ start, // Vector3 position,
+ down, // Vector3 direction,
+ mag, // float length,
+ SitAltitudeCallback); // retMethod
+ } // end small/big
+ } // end scripted/not
+ }
+ else // no Av
{
return;
}
--
cgit v1.1
From aa695e92f7d3b56e6e3371be021d9e6acf91077c Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 27 Nov 2009 08:58:26 +0000
Subject: Reset update flag when a SOG is deleted. This fixes llDie();
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index f36ff1d..26a843e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1199,6 +1199,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!silent)
{
+ part.UpdateFlag = 0;
if (part == m_rootPart)
avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
}
--
cgit v1.1
From 9888f95068373f1bfdb289e85560a7d873d22696 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Fri, 27 Nov 2009 18:29:03 +0100
Subject: Convert multiple lock()s which directly hinder script performance in
linksets to ReaderWriterLockSlim.
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 400 ++++++++++++++------
.../Shared/Api/Implementation/LSL_Api.cs | 11 +-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 415 ++++++++++++---------
3 files changed, 531 insertions(+), 295 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 26a843e..fb34ddc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -98,6 +98,66 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_hasGroupChanged = false;
private long timeFirstChanged;
private long timeLastChanged;
+ private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim();
+
+ public void lockPartsForRead(bool locked)
+ {
+ if (locked)
+ {
+ if (m_partsLock.RecursiveReadCount > 0)
+ {
+ m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
+ m_partsLock.ExitReadLock();
+ }
+ if (m_partsLock.RecursiveWriteCount > 0)
+ {
+ m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed.");
+ m_partsLock.ExitWriteLock();
+ }
+
+ while (!m_partsLock.TryEnterReadLock(60000))
+ {
+ m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire READ lock of m_parts in SceneObjectGroup. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
+ if (m_partsLock.IsWriteLockHeld)
+ {
+ m_partsLock = new System.Threading.ReaderWriterLockSlim();
+ }
+ }
+ }
+ else
+ {
+ m_partsLock.ExitReadLock();
+ }
+ }
+ public void lockPartsForWrite(bool locked)
+ {
+ if (locked)
+ {
+ if (m_partsLock.RecursiveReadCount > 0)
+ {
+ m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
+ m_partsLock.ExitReadLock();
+ }
+ if (m_partsLock.RecursiveWriteCount > 0)
+ {
+ m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed.");
+ m_partsLock.ExitWriteLock();
+ }
+
+ while (!m_partsLock.TryEnterWriteLock(60000))
+ {
+ m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
+ if (m_partsLock.IsWriteLockHeld)
+ {
+ m_partsLock = new System.Threading.ReaderWriterLockSlim();
+ }
+ }
+ }
+ else
+ {
+ m_partsLock.ExitWriteLock();
+ }
+ }
public bool HasGroupChanged
{
@@ -243,13 +303,16 @@ namespace OpenSim.Region.Framework.Scenes
set
{
m_regionHandle = value;
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.RegionHandle = m_regionHandle;
+
}
}
+ lockPartsForRead(false);
}
}
@@ -275,13 +338,16 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
}
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.GroupPosition = val;
+
}
}
+ lockPartsForRead(false);
//if (m_rootPart.PhysActor != null)
//{
@@ -432,13 +498,16 @@ namespace OpenSim.Region.Framework.Scenes
public void SetFromItemID(UUID AssetId)
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.FromItemID = AssetId;
+
}
}
+ lockPartsForRead(false);
}
public UUID GetFromItemID()
@@ -505,10 +574,11 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 maxScale = Vector3.Zero;
Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
Vector3 partscale = part.Scale;
Vector3 partoffset = part.OffsetPosition;
@@ -519,8 +589,11 @@ namespace OpenSim.Region.Framework.Scenes
maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
+
}
}
+ lockPartsForRead(false);
+
finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
@@ -536,10 +609,11 @@ namespace OpenSim.Region.Framework.Scenes
EntityIntersection result = new EntityIntersection();
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
// Temporary commented to stop compiler warning
//Vector3 partPosition =
// new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z);
@@ -567,8 +641,10 @@ namespace OpenSim.Region.Framework.Scenes
result.distance = inter.distance;
}
}
+
}
}
+ lockPartsForRead(false);
return result;
}
@@ -581,10 +657,11 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight)
{
float maxX = -256f, maxY = -256f, maxZ = -256f, minX = 256f, minY = 256f, minZ = 256f;
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
Vector3 worldPos = part.GetWorldPosition();
Vector3 offset = worldPos - AbsolutePosition;
Quaternion worldRot;
@@ -643,6 +720,8 @@ namespace OpenSim.Region.Framework.Scenes
backBottomRight.Y = orig.Y + (part.Scale.Y / 2);
backBottomRight.Z = orig.Z - (part.Scale.Z / 2);
+
+
//m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z);
//m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z);
//m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z);
@@ -814,6 +893,7 @@ namespace OpenSim.Region.Framework.Scenes
minZ = backBottomLeft.Z;
}
}
+ lockPartsForRead(false);
Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ);
@@ -842,17 +922,20 @@ namespace OpenSim.Region.Framework.Scenes
Dictionary states = new Dictionary();
// Capture script state while holding the lock
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
Dictionary pstates = part.Inventory.GetScriptStates();
foreach (UUID itemid in pstates.Keys)
{
states.Add(itemid, pstates[itemid]);
}
+
}
}
+ lockPartsForRead(false);
if (states.Count > 0)
{
@@ -1014,13 +1097,16 @@ namespace OpenSim.Region.Framework.Scenes
public override void UpdateMovement()
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.UpdateMovement();
+
}
}
+ lockPartsForRead(false);
}
public ushort GetTimeDilation()
@@ -1064,7 +1150,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void AddPart(SceneObjectPart part)
{
- lock (m_parts)
+ lockPartsForWrite(true);
{
part.SetParent(this);
m_parts.Add(part.UUID, part);
@@ -1074,6 +1160,7 @@ namespace OpenSim.Region.Framework.Scenes
if (part.LinkNum == 2 && RootPart != null)
RootPart.LinkNum = 1;
}
+ lockPartsForWrite(false);
}
///
@@ -1081,28 +1168,33 @@ namespace OpenSim.Region.Framework.Scenes
///
private void UpdateParentIDs()
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
if (part.UUID != m_rootPart.UUID)
{
part.ParentID = m_rootPart.LocalId;
}
+
}
}
+ lockPartsForRead(false);
}
public void RegenerateFullIDs()
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.UUID = UUID.Random();
-
+
}
}
+ lockPartsForRead(false);
}
// helper provided for parts.
@@ -1183,29 +1275,33 @@ namespace OpenSim.Region.Framework.Scenes
DetachFromBackup();
- lock (m_parts)
+ lockPartsForRead(true);
+ List values = new List(m_parts.Values);
+ lockPartsForRead(false);
+
+ foreach (SceneObjectPart part in values)
{
- foreach (SceneObjectPart part in m_parts.Values)
- {
// part.Inventory.RemoveScriptInstances();
-
- ScenePresence[] avatars = Scene.GetScenePresences();
- for (int i = 0; i < avatars.Length; i++)
+
+ ScenePresence[] avatars = Scene.GetScenePresences();
+ for (int i = 0; i < avatars.Length; i++)
+ {
+ if (avatars[i].ParentID == LocalId)
{
- if (avatars[i].ParentID == LocalId)
- {
- avatars[i].StandUp();
- }
+ avatars[i].StandUp();
+ }
- if (!silent)
- {
- part.UpdateFlag = 0;
- if (part == m_rootPart)
- avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
- }
+ if (!silent)
+ {
+ part.UpdateFlag = 0;
+ if (part == m_rootPart)
+ avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
}
}
+
}
+
+
}
public void AddScriptLPS(int count)
@@ -1230,17 +1326,20 @@ namespace OpenSim.Region.Framework.Scenes
scriptEvents aggregateScriptEvents=0;
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
if (part == null)
continue;
if (part != RootPart)
part.ObjectFlags = objectflagupdate;
aggregateScriptEvents |= part.AggregateScriptEvents;
+
}
}
+ lockPartsForRead(false);
m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0);
m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0);
@@ -1273,42 +1372,52 @@ namespace OpenSim.Region.Framework.Scenes
///
public void ApplyPhysics(bool m_physicalPrim)
{
- lock (m_parts)
+ lockPartsForRead(true);
+
+ if (m_parts.Count > 1)
{
- if (m_parts.Count > 1)
+ List values = new List(m_parts.Values);
+ lockPartsForRead(false);
+ m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
+ foreach (SceneObjectPart part in values)
{
- m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
- foreach (SceneObjectPart part in m_parts.Values)
+
+ if (part.LocalId != m_rootPart.LocalId)
{
- if (part.LocalId != m_rootPart.LocalId)
- {
- part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim);
- }
+ part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim);
}
- // Hack to get the physics scene geometries in the right spot
- ResetChildPrimPhysicsPositions();
- }
- else
- {
- m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
}
+ // Hack to get the physics scene geometries in the right spot
+ ResetChildPrimPhysicsPositions();
+ }
+ else
+ {
+ lockPartsForRead(false);
+ m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim);
}
}
public void SetOwnerId(UUID userId)
{
- ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; });
+ ForEachPart(delegate(SceneObjectPart part)
+ {
+
+ part.OwnerID = userId;
+
+ });
}
public void ForEachPart(Action whatToDo)
{
- lock (m_parts)
+ lockPartsForRead(true);
+ List values = new List(m_parts.Values);
+ lockPartsForRead(false);
+ foreach (SceneObjectPart part in values)
{
- foreach (SceneObjectPart part in m_parts.Values)
- {
- whatToDo(part);
- }
+
+ whatToDo(part);
+
}
}
@@ -1407,14 +1516,17 @@ namespace OpenSim.Region.Framework.Scenes
{
SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID));
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
if (part != RootPart)
SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID));
+
}
}
+ lockPartsForRead(false);
}
///
@@ -1509,10 +1621,11 @@ namespace OpenSim.Region.Framework.Scenes
List partList;
- lock (m_parts)
- {
- partList = new List(m_parts.Values);
- }
+ lockPartsForRead(true);
+
+ partList = new List(m_parts.Values);
+
+ lockPartsForRead(false);
partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
{
@@ -1835,10 +1948,11 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed);
newPart.SetParent(this);
- lock (m_parts)
+ lockPartsForWrite(true);
{
m_parts.Add(newPart.UUID, newPart);
}
+ lockPartsForWrite(false);
SetPartAsNonRoot(newPart);
@@ -1901,7 +2015,7 @@ namespace OpenSim.Region.Framework.Scenes
//if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
// return;
- lock (m_parts)
+ lockPartsForRead(true);
{
bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
@@ -1919,34 +2033,43 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.SendScheduledUpdates();
+
}
}
+ lockPartsForRead(false);
}
public void ScheduleFullUpdateToAvatar(ScenePresence presence)
{
RootPart.AddFullUpdateToAvatar(presence);
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
if (part != RootPart)
part.AddFullUpdateToAvatar(presence);
+
}
}
+ lockPartsForRead(false);
}
public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.AddTerseUpdateToAvatar(presence);
+
}
}
+ lockPartsForRead(false);
}
///
@@ -1957,14 +2080,17 @@ namespace OpenSim.Region.Framework.Scenes
checkAtTargets();
RootPart.ScheduleFullUpdate();
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
if (part != RootPart)
part.ScheduleFullUpdate();
+
}
}
+ lockPartsForRead(false);
}
///
@@ -1972,13 +2098,16 @@ namespace OpenSim.Region.Framework.Scenes
///
public void ScheduleGroupForTerseUpdate()
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
part.ScheduleTerseUpdate();
+
}
}
+ lockPartsForRead(false);
}
///
@@ -1991,14 +2120,17 @@ namespace OpenSim.Region.Framework.Scenes
RootPart.SendFullUpdateToAllClients();
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
+
if (part != RootPart)
part.SendFullUpdateToAllClients();
+
}
}
+ lockPartsForRead(false);
}
///
@@ -2029,14 +2161,15 @@ namespace OpenSim.Region.Framework.Scenes
{
if (IsDeleted)
return;
-
- lock (m_parts)
+
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
part.SendTerseUpdateToAllClients();
}
}
+ lockPartsForRead(false);
}
#endregion
@@ -2050,16 +2183,18 @@ namespace OpenSim.Region.Framework.Scenes
/// null if no child part with that linknum or child part
public SceneObjectPart GetLinkNumPart(int linknum)
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
if (part.LinkNum == linknum)
{
+ lockPartsForRead(false);
return part;
}
}
}
+ lockPartsForRead(false);
return null;
}
@@ -2087,17 +2222,19 @@ namespace OpenSim.Region.Framework.Scenes
public SceneObjectPart GetChildPart(uint localID)
{
//m_log.DebugFormat("Entered looking for {0}", localID);
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
//m_log.DebugFormat("Found {0}", part.LocalId);
if (part.LocalId == localID)
{
+ lockPartsForRead(false);
return part;
}
}
}
+ lockPartsForRead(false);
return null;
}
@@ -2127,17 +2264,19 @@ namespace OpenSim.Region.Framework.Scenes
public bool HasChildPrim(uint localID)
{
//m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID);
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
//m_log.DebugFormat("Found {0}", part.LocalId);
if (part.LocalId == localID)
{
+ lockPartsForRead(false);
return true;
}
}
}
+ lockPartsForRead(false);
return false;
}
@@ -2187,53 +2326,57 @@ namespace OpenSim.Region.Framework.Scenes
if (m_rootPart.LinkNum == 0)
m_rootPart.LinkNum = 1;
- lock (m_parts)
- {
- m_parts.Add(linkPart.UUID, linkPart);
+ lockPartsForWrite(true);
+
+ m_parts.Add(linkPart.UUID, linkPart);
+
+ lockPartsForWrite(false);
- // Insert in terms of link numbers, the new links
- // before the current ones (with the exception of
- // the root prim. Shuffle the old ones up
- foreach (KeyValuePair kvp in m_parts)
+ // Insert in terms of link numbers, the new links
+ // before the current ones (with the exception of
+ // the root prim. Shuffle the old ones up
+ lockPartsForRead(true);
+ foreach (KeyValuePair kvp in m_parts)
+ {
+ if (kvp.Value.LinkNum != 1)
{
- if (kvp.Value.LinkNum != 1)
- {
- // Don't update root prim link number
- kvp.Value.LinkNum += objectGroup.PrimCount;
- }
+ // Don't update root prim link number
+ kvp.Value.LinkNum += objectGroup.PrimCount;
}
+ }
+ lockPartsForRead(false);
- linkPart.LinkNum = 2;
+ linkPart.LinkNum = 2;
- linkPart.SetParent(this);
- linkPart.AddFlag(PrimFlags.CreateSelected);
+ linkPart.SetParent(this);
+ linkPart.AddFlag(PrimFlags.CreateSelected);
- //if (linkPart.PhysActor != null)
- //{
- // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
-
- //linkPart.PhysActor = null;
- //}
+ //if (linkPart.PhysActor != null)
+ //{
+ // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
+
+ //linkPart.PhysActor = null;
+ //}
- //TODO: rest of parts
- int linkNum = 3;
- foreach (SceneObjectPart part in objectGroup.Children.Values)
+ //TODO: rest of parts
+ int linkNum = 3;
+ foreach (SceneObjectPart part in objectGroup.Children.Values)
+ {
+ if (part.UUID != objectGroup.m_rootPart.UUID)
{
- if (part.UUID != objectGroup.m_rootPart.UUID)
- {
- LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
- }
- part.ClearUndoState();
+ LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
}
+ part.ClearUndoState();
}
m_scene.UnlinkSceneObject(objectGroup.UUID, true);
objectGroup.m_isDeleted = true;
+
+ objectGroup.lockPartsForWrite(true);
- lock (objectGroup.m_parts)
- {
- objectGroup.m_parts.Clear();
- }
+ objectGroup.m_parts.Clear();
+
+ objectGroup.lockPartsForWrite(false);
// Can't do this yet since backup still makes use of the root part without any synchronization
// objectGroup.m_rootPart = null;
@@ -2292,11 +2435,12 @@ namespace OpenSim.Region.Framework.Scenes
Quaternion worldRot = linkPart.GetWorldRotation();
// Remove the part from this object
- lock (m_parts)
+ lockPartsForWrite(true);
{
m_parts.Remove(linkPart.UUID);
}
-
+ lockPartsForWrite(false);
+ lockPartsForRead(true);
if (m_parts.Count == 1 && RootPart != null) //Single prim is left
RootPart.LinkNum = 0;
else
@@ -2307,6 +2451,7 @@ namespace OpenSim.Region.Framework.Scenes
p.LinkNum--;
}
}
+ lockPartsForRead(false);
linkPart.ParentID = 0;
linkPart.LinkNum = 0;
@@ -2624,22 +2769,23 @@ namespace OpenSim.Region.Framework.Scenes
if (selectionPart != null)
{
- lock (m_parts)
+ lockPartsForRead(true);
+ List parts = new List(m_parts.Values);
+ lockPartsForRead(false);
+ foreach (SceneObjectPart part in parts)
{
- foreach (SceneObjectPart part in m_parts.Values)
+ if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
{
- if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
- {
- UsePhysics = false; // Reset physics
- break;
- }
+ UsePhysics = false; // Reset physics
+ break;
}
+ }
- foreach (SceneObjectPart part in m_parts.Values)
- {
- part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
- }
+ foreach (SceneObjectPart part in parts)
+ {
+ part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
}
+
}
}
@@ -2863,7 +3009,7 @@ namespace OpenSim.Region.Framework.Scenes
prevScale.Z *= z;
part.Resize(prevScale);
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart obPart in m_parts.Values)
{
@@ -2882,6 +3028,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
+ lockPartsForRead(false);
if (part.PhysActor != null)
{
@@ -2962,7 +3109,7 @@ namespace OpenSim.Region.Framework.Scenes
axDiff *= Quaternion.Inverse(partRotation);
diff = axDiff;
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart obPart in m_parts.Values)
{
@@ -2972,6 +3119,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
+ lockPartsForRead(false);
AbsolutePosition = newPos;
@@ -3089,7 +3237,7 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
}
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart prim in m_parts.Values)
{
@@ -3107,6 +3255,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
+ lockPartsForRead(false);
m_rootPart.ScheduleTerseUpdate();
}
@@ -3205,7 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes
if (atTargets.Count > 0)
{
uint[] localids = new uint[0];
- lock (m_parts)
+ lockPartsForRead(true);
{
localids = new uint[m_parts.Count];
int cntr = 0;
@@ -3215,6 +3364,7 @@ namespace OpenSim.Region.Framework.Scenes
cntr++;
}
}
+ lockPartsForRead(false);
for (int ctr = 0; ctr < localids.Length; ctr++)
{
@@ -3233,7 +3383,7 @@ namespace OpenSim.Region.Framework.Scenes
{
//trigger not_at_target
uint[] localids = new uint[0];
- lock (m_parts)
+ lockPartsForRead(true);
{
localids = new uint[m_parts.Count];
int cntr = 0;
@@ -3243,7 +3393,8 @@ namespace OpenSim.Region.Framework.Scenes
cntr++;
}
}
-
+ lockPartsForRead(false);
+
for (int ctr = 0; ctr < localids.Length; ctr++)
{
m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]);
@@ -3256,19 +3407,20 @@ namespace OpenSim.Region.Framework.Scenes
public float GetMass()
{
float retmass = 0f;
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
retmass += part.GetMass();
}
}
+ lockPartsForRead(false);
return retmass;
}
public void CheckSculptAndLoad()
{
- lock (m_parts)
+ lockPartsForRead(true);
{
if (!IsDeleted)
{
@@ -3293,6 +3445,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
+ lockPartsForRead(false);
}
protected void AssetReceived(string id, Object sender, AssetBase asset)
@@ -3313,7 +3466,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SetGroup(UUID GroupID, IClientAPI client)
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
{
@@ -3323,7 +3476,7 @@ namespace OpenSim.Region.Framework.Scenes
HasGroupChanged = true;
}
-
+ lockPartsForRead(false);
ScheduleGroupForFullUpdate();
}
@@ -3342,11 +3495,12 @@ namespace OpenSim.Region.Framework.Scenes
public void SetAttachmentPoint(byte point)
{
- lock (m_parts)
+ lockPartsForRead(true);
{
foreach (SceneObjectPart part in m_parts.Values)
part.SetAttachmentPoint(point);
}
+ lockPartsForRead(false);
}
#region ISceneObject
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ec771e3..267928b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2950,8 +2950,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return m_host.OwnerID.ToString();
}
+ [DebuggerNonUserCode]
public void llInstantMessage(string user, string message)
{
+ UUID result;
+ if (!UUID.TryParse(user, out result))
+ {
+ throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user));
+ return;
+ }
+
+
m_host.AddScriptLPS(1);
// We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -2966,7 +2975,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID friendTransactionID = UUID.Random();
//m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
-
+
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
msg.toAgentID = new Guid(user); // toAgentID.Guid;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index d997ea3..49c69ab 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -101,6 +101,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private Dictionary m_Scripts =
new Dictionary();
+ private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim();
+
// Maps the asset ID to the assembly
private Dictionary m_Assemblies =
@@ -122,6 +124,65 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue();
IWorkItemResult m_CurrentCompile = null;
+ private void lockScriptsForRead(bool locked)
+ {
+ if (locked)
+ {
+ if (m_scriptsLock.RecursiveReadCount > 0)
+ {
+ m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
+ m_scriptsLock.ExitReadLock();
+ }
+ if (m_scriptsLock.RecursiveWriteCount > 0)
+ {
+ m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed.");
+ m_scriptsLock.ExitWriteLock();
+ }
+
+ while (!m_scriptsLock.TryEnterReadLock(60000))
+ {
+ m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire READ lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
+ if (m_scriptsLock.IsWriteLockHeld)
+ {
+ m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim();
+ }
+ }
+ }
+ else
+ {
+ m_scriptsLock.ExitReadLock();
+ }
+ }
+ private void lockScriptsForWrite(bool locked)
+ {
+ if (locked)
+ {
+ if (m_scriptsLock.RecursiveReadCount > 0)
+ {
+ m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
+ m_scriptsLock.ExitReadLock();
+ }
+ if (m_scriptsLock.RecursiveWriteCount > 0)
+ {
+ m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed.");
+ m_scriptsLock.ExitWriteLock();
+ }
+
+ while (!m_scriptsLock.TryEnterWriteLock(60000))
+ {
+ m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
+ if (m_scriptsLock.IsWriteLockHeld)
+ {
+ m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim();
+ }
+ }
+ }
+ else
+ {
+ m_scriptsLock.ExitWriteLock();
+ }
+ }
+
public string ScriptEngineName
{
get { return "XEngine"; }
@@ -261,43 +322,45 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void RemoveRegion(Scene scene)
{
- lock (m_Scripts)
+ lockScriptsForRead(true);
+ foreach (IScriptInstance instance in m_Scripts.Values)
{
- foreach (IScriptInstance instance in m_Scripts.Values)
+ // Force a final state save
+ //
+ if (m_Assemblies.ContainsKey(instance.AssetID))
{
- // Force a final state save
- //
- if (m_Assemblies.ContainsKey(instance.AssetID))
- {
- string assembly = m_Assemblies[instance.AssetID];
- instance.SaveState(assembly);
- }
+ string assembly = m_Assemblies[instance.AssetID];
+ instance.SaveState(assembly);
+ }
- // Clear the event queue and abort the instance thread
- //
- instance.ClearQueue();
- instance.Stop(0);
+ // Clear the event queue and abort the instance thread
+ //
+ instance.ClearQueue();
+ instance.Stop(0);
- // Release events, timer, etc
- //
- instance.DestroyScriptInstance();
+ // Release events, timer, etc
+ //
+ instance.DestroyScriptInstance();
- // Unload scripts and app domains
- // Must be done explicitly because they have infinite
- // lifetime
- //
- m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
- if (m_DomainScripts[instance.AppDomain].Count == 0)
- {
- m_DomainScripts.Remove(instance.AppDomain);
- UnloadAppDomain(instance.AppDomain);
- }
+ // Unload scripts and app domains
+ // Must be done explicitly because they have infinite
+ // lifetime
+ //
+ m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
+ if (m_DomainScripts[instance.AppDomain].Count == 0)
+ {
+ m_DomainScripts.Remove(instance.AppDomain);
+ UnloadAppDomain(instance.AppDomain);
}
- m_Scripts.Clear();
- m_PrimObjects.Clear();
- m_Assemblies.Clear();
- m_DomainScripts.Clear();
}
+ lockScriptsForRead(false);
+ lockScriptsForWrite(true);
+ m_Scripts.Clear();
+ lockScriptsForWrite(false);
+ m_PrimObjects.Clear();
+ m_Assemblies.Clear();
+ m_DomainScripts.Clear();
+
lock (m_ScriptEngines)
{
m_ScriptEngines.Remove(this);
@@ -356,22 +419,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
List instances = new List();
- lock (m_Scripts)
- {
- foreach (IScriptInstance instance in m_Scripts.Values)
+ lockScriptsForRead(true);
+ foreach (IScriptInstance instance in m_Scripts.Values)
instances.Add(instance);
- }
+ lockScriptsForRead(false);
foreach (IScriptInstance i in instances)
{
string assembly = String.Empty;
- lock (m_Scripts)
- {
+
if (!m_Assemblies.ContainsKey(i.AssetID))
continue;
assembly = m_Assemblies[i.AssetID];
- }
+
i.SaveState(assembly);
}
@@ -673,172 +734,183 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return false;
}
- lock (m_Scripts)
+
+
+ ScriptInstance instance = null;
+ // Create the object record
+ lockScriptsForRead(true);
+ if ((!m_Scripts.ContainsKey(itemID)) ||
+ (m_Scripts[itemID].AssetID != assetID))
{
- ScriptInstance instance = null;
- // Create the object record
+ lockScriptsForRead(false);
- if ((!m_Scripts.ContainsKey(itemID)) ||
- (m_Scripts[itemID].AssetID != assetID))
- {
- UUID appDomain = assetID;
+ UUID appDomain = assetID;
- if (part.ParentGroup.IsAttachment)
- appDomain = part.ParentGroup.RootPart.UUID;
+ if (part.ParentGroup.IsAttachment)
+ appDomain = part.ParentGroup.RootPart.UUID;
- if (!m_AppDomains.ContainsKey(appDomain))
+ if (!m_AppDomains.ContainsKey(appDomain))
+ {
+ try
{
- try
- {
- AppDomainSetup appSetup = new AppDomainSetup();
-// appSetup.ApplicationBase = Path.Combine(
-// "ScriptEngines",
-// m_Scene.RegionInfo.RegionID.ToString());
-
- Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
- Evidence evidence = new Evidence(baseEvidence);
-
- AppDomain sandbox;
- if (m_AppDomainLoading)
- sandbox = AppDomain.CreateDomain(
- m_Scene.RegionInfo.RegionID.ToString(),
- evidence, appSetup);
- else
- sandbox = AppDomain.CurrentDomain;
-
- //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
- //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
- //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
- //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
- //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
- //sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
- //sandbox.SetAppDomainPolicy(sandboxPolicy);
-
- m_AppDomains[appDomain] = sandbox;
-
- m_AppDomains[appDomain].AssemblyResolve +=
- new ResolveEventHandler(
- AssemblyResolver.OnAssemblyResolve);
- m_DomainScripts[appDomain] = new List();
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
- m_ScriptErrorMessage += "Exception creating app domain:\n";
- m_ScriptFailCount++;
- lock (m_AddingAssemblies)
- {
- m_AddingAssemblies[assembly]--;
- }
- return false;
- }
+ AppDomainSetup appSetup = new AppDomainSetup();
+ // appSetup.ApplicationBase = Path.Combine(
+ // "ScriptEngines",
+ // m_Scene.RegionInfo.RegionID.ToString());
+
+ Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
+ Evidence evidence = new Evidence(baseEvidence);
+
+ AppDomain sandbox;
+ if (m_AppDomainLoading)
+ sandbox = AppDomain.CreateDomain(
+ m_Scene.RegionInfo.RegionID.ToString(),
+ evidence, appSetup);
+ else
+ sandbox = AppDomain.CurrentDomain;
+
+ //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
+ //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
+ //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
+ //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
+ //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
+ //sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
+ //sandbox.SetAppDomainPolicy(sandboxPolicy);
+
+ m_AppDomains[appDomain] = sandbox;
+
+ m_AppDomains[appDomain].AssemblyResolve +=
+ new ResolveEventHandler(
+ AssemblyResolver.OnAssemblyResolve);
+ m_DomainScripts[appDomain] = new List();
}
- m_DomainScripts[appDomain].Add(itemID);
-
- instance = new ScriptInstance(this, part,
- itemID, assetID, assembly,
- m_AppDomains[appDomain],
- part.ParentGroup.RootPart.Name,
- item.Name, startParam, postOnRez,
- stateSource, m_MaxScriptQueue);
-
- m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}",
- part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString());
-
- if (presence != null)
+ catch (Exception e)
{
- ShowScriptSaveResponse(item.OwnerID,
- assetID, "Compile successful", true);
+ m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
+ m_ScriptErrorMessage += "Exception creating app domain:\n";
+ m_ScriptFailCount++;
+ lock (m_AddingAssemblies)
+ {
+ m_AddingAssemblies[assembly]--;
+ }
+ return false;
}
+ }
+ m_DomainScripts[appDomain].Add(itemID);
- instance.AppDomain = appDomain;
- instance.LineMap = linemap;
+ instance = new ScriptInstance(this, part,
+ itemID, assetID, assembly,
+ m_AppDomains[appDomain],
+ part.ParentGroup.RootPart.Name,
+ item.Name, startParam, postOnRez,
+ stateSource, m_MaxScriptQueue);
- m_Scripts[itemID] = instance;
- }
+ m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}",
+ part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString());
- lock (m_PrimObjects)
+ if (presence != null)
{
- if (!m_PrimObjects.ContainsKey(localID))
- m_PrimObjects[localID] = new List();
+ ShowScriptSaveResponse(item.OwnerID,
+ assetID, "Compile successful", true);
+ }
- if (!m_PrimObjects[localID].Contains(itemID))
- m_PrimObjects[localID].Add(itemID);
+ instance.AppDomain = appDomain;
+ instance.LineMap = linemap;
+ lockScriptsForWrite(true);
+ m_Scripts[itemID] = instance;
+ lockScriptsForWrite(false);
+ }
+ else
+ {
+ lockScriptsForRead(false);
+ }
+ lock (m_PrimObjects)
+ {
+ if (!m_PrimObjects.ContainsKey(localID))
+ m_PrimObjects[localID] = new List();
- }
+ if (!m_PrimObjects[localID].Contains(itemID))
+ m_PrimObjects[localID].Add(itemID);
- if (!m_Assemblies.ContainsKey(assetID))
- m_Assemblies[assetID] = assembly;
+ }
- lock (m_AddingAssemblies)
- {
- m_AddingAssemblies[assembly]--;
- }
+ if (!m_Assemblies.ContainsKey(assetID))
+ m_Assemblies[assetID] = assembly;
- if (instance!=null)
- instance.Init();
+ lock (m_AddingAssemblies)
+ {
+ m_AddingAssemblies[assembly]--;
}
+
+ if (instance!=null)
+ instance.Init();
+
return true;
}
public void OnRemoveScript(uint localID, UUID itemID)
{
- lock (m_Scripts)
+ lockScriptsForRead(true);
+ // Do we even have it?
+ if (!m_Scripts.ContainsKey(itemID))
{
- // Do we even have it?
- if (!m_Scripts.ContainsKey(itemID))
- return;
+ lockScriptsForRead(false);
+ return;
+ }
+
- IScriptInstance instance=m_Scripts[itemID];
- m_Scripts.Remove(itemID);
+ IScriptInstance instance=m_Scripts[itemID];
+ lockScriptsForRead(false);
+ lockScriptsForWrite(true);
+ m_Scripts.Remove(itemID);
+ lockScriptsForWrite(false);
+ instance.ClearQueue();
+ instance.Stop(0);
- instance.ClearQueue();
- instance.Stop(0);
+ SceneObjectPart part =
+ m_Scene.GetSceneObjectPart(localID);
- SceneObjectPart part =
- m_Scene.GetSceneObjectPart(localID);
-
- if (part != null)
- part.RemoveScriptEvents(itemID);
+ if (part != null)
+ part.RemoveScriptEvents(itemID);
// bool objectRemoved = false;
- lock (m_PrimObjects)
+ lock (m_PrimObjects)
+ {
+ // Remove the script from it's prim
+ if (m_PrimObjects.ContainsKey(localID))
{
- // Remove the script from it's prim
- if (m_PrimObjects.ContainsKey(localID))
- {
- // Remove inventory item record
- if (m_PrimObjects[localID].Contains(itemID))
- m_PrimObjects[localID].Remove(itemID);
+ // Remove inventory item record
+ if (m_PrimObjects[localID].Contains(itemID))
+ m_PrimObjects[localID].Remove(itemID);
- // If there are no more scripts, remove prim
- if (m_PrimObjects[localID].Count == 0)
- {
- m_PrimObjects.Remove(localID);
+ // If there are no more scripts, remove prim
+ if (m_PrimObjects[localID].Count == 0)
+ {
+ m_PrimObjects.Remove(localID);
// objectRemoved = true;
- }
}
}
+ }
- instance.RemoveState();
- instance.DestroyScriptInstance();
+ instance.RemoveState();
+ instance.DestroyScriptInstance();
- m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
- if (m_DomainScripts[instance.AppDomain].Count == 0)
- {
- m_DomainScripts.Remove(instance.AppDomain);
- UnloadAppDomain(instance.AppDomain);
- }
+ m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
+ if (m_DomainScripts[instance.AppDomain].Count == 0)
+ {
+ m_DomainScripts.Remove(instance.AppDomain);
+ UnloadAppDomain(instance.AppDomain);
+ }
- instance = null;
+ instance = null;
- ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
- if (handlerObjectRemoved != null)
- handlerObjectRemoved(part.UUID);
+ ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
+ if (handlerObjectRemoved != null)
+ handlerObjectRemoved(part.UUID);
- CleanAssemblies();
- }
+ CleanAssemblies();
+
ScriptRemoved handlerScriptRemoved = OnScriptRemoved;
if (handlerScriptRemoved != null)
@@ -1091,12 +1163,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private IScriptInstance GetInstance(UUID itemID)
{
IScriptInstance instance;
- lock (m_Scripts)
+ lockScriptsForRead(true);
+ if (!m_Scripts.ContainsKey(itemID))
{
- if (!m_Scripts.ContainsKey(itemID))
- return null;
- instance = m_Scripts[itemID];
+ lockScriptsForRead(false);
+ return null;
}
+ instance = m_Scripts[itemID];
+ lockScriptsForRead(false);
return instance;
}
@@ -1200,11 +1274,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
List instances = new List();
- lock (m_Scripts)
- {
- foreach (IScriptInstance instance in m_Scripts.Values)
+ lockScriptsForRead(true);
+ foreach (IScriptInstance instance in m_Scripts.Values)
instances.Add(instance);
- }
+ lockScriptsForRead(false);
foreach (IScriptInstance i in instances)
{
--
cgit v1.1
From 2e6dce434f1fd20664a60e464e589798287dcfe3 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 30 Nov 2009 21:52:55 +0100
Subject: Enforce physical prim max size on single prims. Also convert a lock()
to ReaderWriterLockSlim that i missed in the last commit
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 119 ++++++++++-----------
1 file changed, 58 insertions(+), 61 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fb34ddc..42481ff 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2871,11 +2871,9 @@ namespace OpenSim.Region.Framework.Scenes
scale.Y = m_scene.m_maxNonphys;
if (scale.Z > m_scene.m_maxNonphys)
scale.Z = m_scene.m_maxNonphys;
-
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
- part.Resize(scale);
if (part.PhysActor != null)
{
if (part.PhysActor.IsPhysical)
@@ -2890,7 +2888,7 @@ namespace OpenSim.Region.Framework.Scenes
part.PhysActor.Size = scale;
m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
}
- //if (part.UUID != m_rootPart.UUID)
+ part.Resize(scale);
HasGroupChanged = true;
ScheduleGroupForFullUpdate();
@@ -2931,77 +2929,76 @@ namespace OpenSim.Region.Framework.Scenes
float y = (scale.Y / part.Scale.Y);
float z = (scale.Z / part.Scale.Z);
- lock (m_parts)
+ lockPartsForRead(true);
+ if (x > 1.0f || y > 1.0f || z > 1.0f)
{
- if (x > 1.0f || y > 1.0f || z > 1.0f)
+ foreach (SceneObjectPart obPart in m_parts.Values)
{
- foreach (SceneObjectPart obPart in m_parts.Values)
+ if (obPart.UUID != m_rootPart.UUID)
{
- if (obPart.UUID != m_rootPart.UUID)
- {
- Vector3 oldSize = new Vector3(obPart.Scale);
+ Vector3 oldSize = new Vector3(obPart.Scale);
- float f = 1.0f;
- float a = 1.0f;
+ float f = 1.0f;
+ float a = 1.0f;
- if (part.PhysActor != null && part.PhysActor.IsPhysical)
+ if (part.PhysActor != null && part.PhysActor.IsPhysical)
+ {
+ if (oldSize.X*x > m_scene.m_maxPhys)
{
- if (oldSize.X*x > m_scene.m_maxPhys)
- {
- f = m_scene.m_maxPhys / oldSize.X;
- a = f / x;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Y*y > m_scene.m_maxPhys)
- {
- f = m_scene.m_maxPhys / oldSize.Y;
- a = f / y;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Z*z > m_scene.m_maxPhys)
- {
- f = m_scene.m_maxPhys / oldSize.Z;
- a = f / z;
- x *= a;
- y *= a;
- z *= a;
- }
+ f = m_scene.m_maxPhys / oldSize.X;
+ a = f / x;
+ x *= a;
+ y *= a;
+ z *= a;
}
- else
+ if (oldSize.Y*y > m_scene.m_maxPhys)
+ {
+ f = m_scene.m_maxPhys / oldSize.Y;
+ a = f / y;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ if (oldSize.Z*z > m_scene.m_maxPhys)
+ {
+ f = m_scene.m_maxPhys / oldSize.Z;
+ a = f / z;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ }
+ else
+ {
+ if (oldSize.X*x > m_scene.m_maxNonphys)
{
- if (oldSize.X*x > m_scene.m_maxNonphys)
- {
- f = m_scene.m_maxNonphys / oldSize.X;
- a = f / x;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Y*y > m_scene.m_maxNonphys)
- {
- f = m_scene.m_maxNonphys / oldSize.Y;
- a = f / y;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Z*z > m_scene.m_maxNonphys)
- {
- f = m_scene.m_maxNonphys / oldSize.Z;
- a = f / z;
- x *= a;
- y *= a;
- z *= a;
- }
+ f = m_scene.m_maxNonphys / oldSize.X;
+ a = f / x;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ if (oldSize.Y*y > m_scene.m_maxNonphys)
+ {
+ f = m_scene.m_maxNonphys / oldSize.Y;
+ a = f / y;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ if (oldSize.Z*z > m_scene.m_maxNonphys)
+ {
+ f = m_scene.m_maxNonphys / oldSize.Z;
+ a = f / z;
+ x *= a;
+ y *= a;
+ z *= a;
}
}
}
}
}
+ lockPartsForRead(false);
Vector3 prevScale = part.Scale;
prevScale.X *= x;
--
cgit v1.1
From cc8246206d5044aff0b306a4bcaf4b321fb826c9 Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Sat, 5 Dec 2009 09:03:02 +0100
Subject: Secnond revision of Sit and Stand for unscripted prims; Comment out
spammy debug messages in Interregion....
---
OpenSim/Framework/Servers/VersionInfo.cs | 8 +-
.../Interregion/RESTInterregionComms.cs | 9 +-
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 +
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 253 ++++++++++++---------
4 files changed, 156 insertions(+), 122 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 0d4215b..f5be1e6 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,9 +29,8 @@ namespace OpenSim
{
public class VersionInfo
{
- private const string VERSION_NUMBER = "0.6.9-CM";
- private const Flavour VERSION_FLAVOUR = Flavour.Dev;
-
+ private const string VERSION_NUMBER = "112609s";
+ private const Flavour VERSION_FLAVOUR = Flavour.BetaM7;
public enum Flavour
{
Unknown,
@@ -39,7 +38,8 @@ namespace OpenSim
RC1,
RC2,
Release,
- Post_Fixes
+ Post_Fixes,
+ BetaM7
}
public static string Version
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
index 710e3ca..39e2413 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
@@ -331,12 +331,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{
//m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called");
- m_log.Debug("---------------------------");
+/* m_log.Debug("---------------------------");
m_log.Debug(" >> uri=" + request["uri"]);
m_log.Debug(" >> content-type=" + request["content-type"]);
m_log.Debug(" >> http-method=" + request["http-method"]);
- m_log.Debug("---------------------------\n");
-
+ m_log.Debug("---------------------------\n"); */
Hashtable responsedata = new Hashtable();
responsedata["content_type"] = "text/html";
responsedata["keepalive"] = false;
@@ -576,11 +575,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{
m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called");
- m_log.Debug("---------------------------");
+ /* m_log.Debug("---------------------------");
m_log.Debug(" >> uri=" + request["uri"]);
m_log.Debug(" >> content-type=" + request["content-type"]);
m_log.Debug(" >> http-method=" + request["http-method"]);
- m_log.Debug("---------------------------\n");
+ m_log.Debug("---------------------------\n"); */
Hashtable responsedata = new Hashtable();
responsedata["content_type"] = "text/html";
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 19e3023..9f2c3db 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -212,6 +212,7 @@ namespace OpenSim.Region.Framework.Scenes
private Quaternion m_sitTargetOrientation = Quaternion.Identity;
private Vector3 m_sitTargetPosition;
private string m_sitAnimation = "SIT";
+ private bool m_occupied; // KF if any av is sitting on this prim
private string m_text = String.Empty;
private string m_touchName = String.Empty;
private readonly UndoStack m_undo = new UndoStack(5);
@@ -993,6 +994,13 @@ namespace OpenSim.Region.Framework.Scenes
get { return _flags; }
set { _flags = value; }
}
+
+ [XmlIgnore]
+ public bool IsOccupied // KF If an av is sittingon this prim
+ {
+ get { return m_occupied; }
+ set { m_occupied = value; }
+ }
[XmlIgnore]
public UUID SitTargetAvatar
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cebd108..817b9df 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -197,6 +197,7 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_autopilotMoving;
private Vector3 m_autoPilotTarget;
private bool m_sitAtAutoTarget;
+ private Vector3 m_initialSitTarget; //KF: First estimate of where to sit
private string m_nextSitAnimation = String.Empty;
@@ -1524,7 +1525,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sitAtAutoTarget = false;
PrimitiveBaseShape proxy = PrimitiveBaseShape.Default;
//proxy.PCode = (byte)PCode.ParticleSystem;
-
proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy);
proxyObjectGroup.AttachToScene(m_scene);
@@ -1566,7 +1566,7 @@ namespace OpenSim.Region.Framework.Scenes
}
m_moveToPositionInProgress = true;
m_moveToPositionTarget = new Vector3(locx, locy, locz);
- }
+ }
catch (Exception ex)
{
//Why did I get this error?
@@ -1646,16 +1646,22 @@ namespace OpenSim.Region.Framework.Scenes
m_parentPosition = part.GetWorldPosition();
ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
}
+ // part.GetWorldRotation() is the rotation of the object being sat on
+ // Rotation is the sittiing Av's rotation
+
+ Quaternion wr = Quaternion.Inverse(Quaternion.Inverse(Rotation) * Quaternion.Inverse(part.GetWorldRotation())); // world or. of the av
+ Vector3 so = new Vector3(1.0f, 0f, 0f) * wr; // 1M infront of av
+ Vector3 wso = so + part.GetWorldPosition() + ( m_pos * part.GetWorldRotation()); // + av sit offset!
if (m_physicsActor == null)
{
AddToPhysicalScene(false);
}
- m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight);
+ AbsolutePosition = wso; //KF: Fix stand up.
m_parentPosition = Vector3.Zero;
-//Console.WriteLine("Stand Pos {0}", m_pos);
-
- m_parentID = 0;
+
+ m_parentID = 0;
+ part.IsOccupied = false;
SendFullUpdateToAllClients();
m_requestedSitTargetID = 0;
if ((m_physicsActor != null) && (m_avHeight > 0))
@@ -1694,13 +1700,9 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 avSitOffSet = part.SitTargetPosition;
Quaternion avSitOrientation = part.SitTargetOrientation;
UUID avOnTargetAlready = part.GetAvatarOnSitTarget();
-
- bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero));
- bool SitTargetisSet =
- (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f &&
- avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f));
- // this test is probably failing
- if (SitTargetisSet && SitTargetUnOccupied)
+ bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero);
+ bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored.
+ if (SitTargetisSet && !SitTargetOccupied)
{
//switch the target to this prim
return part;
@@ -1714,7 +1716,7 @@ namespace OpenSim.Region.Framework.Scenes
private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset)
{
bool autopilot = true;
- Vector3 pos = new Vector3();
+ Vector3 autopilotTarget = new Vector3();
Quaternion sitOrientation = Quaternion.Identity;
Vector3 cameraEyeOffset = Vector3.Zero;
Vector3 cameraAtOffset = Vector3.Zero;
@@ -1722,98 +1724,104 @@ namespace OpenSim.Region.Framework.Scenes
//SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
SceneObjectPart part = FindNextAvailableSitTarget(targetID);
- if (part != null)
- {
- // TODO: determine position to sit at based on scene geometry; don't trust offset from client
- // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
+ if (part == null) return;
+
+ // TODO: determine position to sit at based on scene geometry; don't trust offset from client
+ // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
- // part is the prim to sit on
- // offset is the vector distance from that prim center to the click-spot
- // UUID is the UUID of the Avatar doing the clicking
-
- m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation
+ // part is the prim to sit on
+ // offset is the world-ref vector distance from that prim center to the click-spot
+ // UUID is the UUID of the Avatar doing the clicking
- // Is a sit target available?
- Vector3 avSitOffSet = part.SitTargetPosition;
- Quaternion avSitOrientation = part.SitTargetOrientation;
- UUID avOnTargetAlready = part.GetAvatarOnSitTarget();
-
- bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero));
-// bool SitTargetisSet =
-// (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f &&
-// avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f));
-
- bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation));
-
-//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied +
-// " TargSet=" + SitTargetisSet);
- // Sit analysis rewritten by KF 091125
- if (SitTargetisSet) // scipted sit
- {
- if (SitTargetUnOccupied)
- {
- part.SetAvatarOnSitTarget(UUID); // set that Av will be on it
- offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one
- sitOrientation = avSitOrientation; // Change rotatione to the scripted one
- autopilot = false; // Jump direct to scripted llSitPos()
- }
- else return;
+ m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation
+
+ // Is a sit target available?
+ Vector3 avSitOffSet = part.SitTargetPosition;
+ Quaternion avSitOrientation = part.SitTargetOrientation;
+
+ bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored.
+ Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
+
+//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet);
+ // Sit analysis rewritten by KF 091125
+ if (SitTargetisSet) // scipted sit
+ {
+ if (!part.IsOccupied)
+ {
+//Console.WriteLine("Scripted, unoccupied");
+ part.SetAvatarOnSitTarget(UUID); // set that Av will be on it
+ offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one
+ sitOrientation = avSitOrientation; // Change rotatione to the scripted one
+ autopilot = false; // Jump direct to scripted llSitPos()
}
- else // Not Scripted
- {
- if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim
- {
- Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
- m_avUnscriptedSitPos = offset * partIRot; // sit where clicked
- pos = part.AbsolutePosition + (offset * partIRot);
- }
- else // small prim
- {
- if (SitTargetUnOccupied)
- {
- m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center
- pos = part.AbsolutePosition;
- }
- else return; // occupied small
- } // end large/small
- } // end Scripted/not
-
- if (m_physicsActor != null)
- {
- // If we're not using the client autopilot, we're immediately warping the avatar to the location
- // We can remove the physicsActor until they stand up.
- m_sitAvatarHeight = m_physicsActor.Size.Z;
-
- if (autopilot)
- { // its not a scripted sit
- if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5)
- {
- autopilot = false; // close enough
+ else
+ {
+//Console.WriteLine("Scripted, occupied");
+ return;
+ }
+ }
+ else // Not Scripted
+ {
+ if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) )
+ {
+ // large prim & offset, ignore if other Avs sitting
+// offset.Z -= 0.05f;
+ m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked
+ autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point
+
+//Console.WriteLine(" offset ={0}", offset);
+//Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos);
+//Console.WriteLine(" autopilotTarget={0}", autopilotTarget);
+
+ }
+ else // small offset
+ {
+//Console.WriteLine("Small offset");
+ if (!part.IsOccupied)
+ {
+ m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center
+ autopilotTarget = part.AbsolutePosition;
+ }
+ else return; // occupied small
+ } // end large/small
+ } // end Scripted/not
+ cameraAtOffset = part.GetCameraAtOffset();
+ cameraEyeOffset = part.GetCameraEyeOffset();
+ forceMouselook = part.GetForceMouselook();
- RemoveFromPhysicalScene();
- AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim
- } // else the autopilot will get us close
- }
- else
- { // its a scripted sit
+ if (m_physicsActor != null)
+ {
+ // If we're not using the client autopilot, we're immediately warping the avatar to the location
+ // We can remove the physicsActor until they stand up.
+ m_sitAvatarHeight = m_physicsActor.Size.Z;
+ if (autopilot)
+ { // its not a scripted sit
+// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5)
+ if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) )
+ {
+ autopilot = false; // close enough
RemoveFromPhysicalScene();
- }
+ AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target
+ } // else the autopilot will get us close
+ }
+ else
+ { // its a scripted sit
+ RemoveFromPhysicalScene();
}
-
- cameraAtOffset = part.GetCameraAtOffset();
- cameraEyeOffset = part.GetCameraEyeOffset();
- forceMouselook = part.GetForceMouselook();
}
+ else return; // physactor is null!
- ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook);
- m_requestedSitTargetUUID = targetID;
+ Vector3 offsetr = offset * partIRot;
+ ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook);
+ m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target
// This calls HandleAgentSit twice, once from here, and the client calls
// HandleAgentSit itself after it gets to the location
// It doesn't get to the location until we've moved them there though
// which happens in HandleAgentSit :P
m_autopilotMoving = autopilot;
- m_autoPilotTarget = pos;
+ m_autoPilotTarget = autopilotTarget;
m_sitAtAutoTarget = autopilot;
+ m_initialSitTarget = autopilotTarget;
if (!autopilot)
HandleAgentSit(remoteClient, UUID);
}
@@ -1898,6 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (part.GetAvatarOnSitTarget() == UUID)
{
+//Console.WriteLine("Scripted Sit");
// Scripted sit
Vector3 sitTargetPos = part.SitTargetPosition;
Quaternion sitTargetOrient = part.SitTargetOrientation;
@@ -1905,42 +1914,44 @@ namespace OpenSim.Region.Framework.Scenes
m_pos += SIT_TARGET_ADJUSTMENT;
m_bodyRot = sitTargetOrient;
m_parentPosition = part.AbsolutePosition;
+ part.IsOccupied = true;
}
else
{
+//Console.WriteLine("NON Scripted Sit");
+ // if m_avUnscriptedSitPos is zero then Av sits above center
+ // Else Av sits at m_avUnscriptedSitPos
+
// Non-scripted sit by Kitto Flora 21Nov09
// Calculate angle of line from prim to Av
+ Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos;
float y_diff = (m_avInitialPos.Y - sitTargetPos.Y);
float x_diff = ( m_avInitialPos.X - sitTargetPos.X);
if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0
if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0
float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff);
- Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
// NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'.
// Av sits at world euler <0,0, z>, translated by part rotation
m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click
+
m_parentPosition = part.AbsolutePosition;
- if(m_avUnscriptedSitPos != Vector3.Zero)
- { // sit where clicked on big prim
- m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot);
- }
- else
- { // sit at center of small prim
- m_pos = new Vector3(0f, 0f, 0.05f) +
- (new Vector3(0.0f, 0f, 0.625f) * partIRot) +
- (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot);
- //Set up raytrace to find top surface of prim
- Vector3 size = part.Scale;
- float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
- Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
- Vector3 down = new Vector3(0f, 0f, -1f);
- m_scene.PhysicsScene.RaycastWorld(
+ part.IsOccupied = true;
+ m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation
+ (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center
+ (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) +
+ m_avUnscriptedSitPos; // adds click offset, if any
+ //Set up raytrace to find top surface of prim
+ Vector3 size = part.Scale;
+ float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
+ Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
+ Vector3 down = new Vector3(0f, 0f, -1f);
+//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag);
+ m_scene.PhysicsScene.RaycastWorld(
start, // Vector3 position,
down, // Vector3 direction,
mag, // float length,
SitAltitudeCallback); // retMethod
- } // end small/big
} // end scripted/not
}
else // no Av
@@ -1957,19 +1968,24 @@ namespace OpenSim.Region.Framework.Scenes
SendFullUpdateToAllClients();
}
- public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance)
+ public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) // KF: Nov 2009
{
+ // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer
+ // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height.
if(hitYN)
{
// m_pos = Av offset from prim center to make look like on center
// m_parentPosition = Actual center pos of prim
// collisionPoint = spot on prim where we want to sit
+ // collisionPoint.Z = global sit surface height
SceneObjectPart part = m_scene.GetSceneObjectPart(localid);
- Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset);
+ Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ float offZ = collisionPoint.Z - m_initialSitTarget.Z;
+ Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction
+//Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset);
m_pos += offset;
-// Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit);
}
- }
+ } // End SitAltitudeCallback KF.
///
/// Event handler for the 'Always run' setting on the client
@@ -3716,5 +3732,16 @@ namespace OpenSim.Region.Framework.Scenes
m_reprioritization_called = false;
}
}
+
+ private Vector3 Quat2Euler(Quaternion rot){
+ float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) ,
+ (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z)));
+ float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W)));
+ float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) ,
+ (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z)));
+ return(new Vector3(x,y,z));
+ }
+
+
}
}
--
cgit v1.1
From 129de260329791529904c02c3515d40879d7d214 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 5 Dec 2009 23:25:30 +0000
Subject: Cause better packing of ObjectProperties
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 106 +++++++++++++++------
1 file changed, 79 insertions(+), 27 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index e812945..71f9b90 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -352,6 +352,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private IHyperAssetService m_hyperAssets;
private const bool m_checkPackets = true;
+ private Timer m_propertiesPacketTimer;
+ private List m_propertiesBlocks = new List();
+
#endregion Class Members
#region Properties
@@ -433,6 +436,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_udpClient.OnQueueEmpty += HandleQueueEmpty;
m_udpClient.OnPacketStats += PopulateStats;
+ m_propertiesPacketTimer = new Timer(100);
+ m_propertiesPacketTimer.Elapsed += ProcessObjectPropertiesPacket;
+
RegisterLocalPacketHandlers();
}
@@ -3562,42 +3568,88 @@ namespace OpenSim.Region.ClientStack.LindenUDP
string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
uint BaseMask, byte saleType, int salePrice)
{
- ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
+ //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
// TODO: don't create new blocks if recycling an old packet
- proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
- proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
- proper.ObjectData[0].ItemID = ItemID;
- proper.ObjectData[0].CreationDate = CreationDate;
- proper.ObjectData[0].CreatorID = CreatorUUID;
- proper.ObjectData[0].FolderID = FolderUUID;
- proper.ObjectData[0].FromTaskID = FromTaskUUID;
- proper.ObjectData[0].GroupID = GroupUUID;
- proper.ObjectData[0].InventorySerial = InventorySerial;
-
- proper.ObjectData[0].LastOwnerID = LastOwnerUUID;
+ ObjectPropertiesPacket.ObjectDataBlock block =
+ new ObjectPropertiesPacket.ObjectDataBlock();
+
+ block.ItemID = ItemID;
+ block.CreationDate = CreationDate;
+ block.CreatorID = CreatorUUID;
+ block.FolderID = FolderUUID;
+ block.FromTaskID = FromTaskUUID;
+ block.GroupID = GroupUUID;
+ block.InventorySerial = InventorySerial;
+
+ block.LastOwnerID = LastOwnerUUID;
// proper.ObjectData[0].LastOwnerID = UUID.Zero;
- proper.ObjectData[0].ObjectID = ObjectUUID;
+ block.ObjectID = ObjectUUID;
if (OwnerUUID == GroupUUID)
- proper.ObjectData[0].OwnerID = UUID.Zero;
+ block.OwnerID = UUID.Zero;
else
- proper.ObjectData[0].OwnerID = OwnerUUID;
- proper.ObjectData[0].TouchName = Util.StringToBytes256(TouchTitle);
- proper.ObjectData[0].TextureID = TextureID;
- proper.ObjectData[0].SitName = Util.StringToBytes256(SitTitle);
- proper.ObjectData[0].Name = Util.StringToBytes256(ItemName);
- proper.ObjectData[0].Description = Util.StringToBytes256(ItemDescription);
- proper.ObjectData[0].OwnerMask = OwnerMask;
- proper.ObjectData[0].NextOwnerMask = NextOwnerMask;
- proper.ObjectData[0].GroupMask = GroupMask;
- proper.ObjectData[0].EveryoneMask = EveryoneMask;
- proper.ObjectData[0].BaseMask = BaseMask;
+ block.OwnerID = OwnerUUID;
+ block.TouchName = Util.StringToBytes256(TouchTitle);
+ block.TextureID = TextureID;
+ block.SitName = Util.StringToBytes256(SitTitle);
+ block.Name = Util.StringToBytes256(ItemName);
+ block.Description = Util.StringToBytes256(ItemDescription);
+ block.OwnerMask = OwnerMask;
+ block.NextOwnerMask = NextOwnerMask;
+ block.GroupMask = GroupMask;
+ block.EveryoneMask = EveryoneMask;
+ block.BaseMask = BaseMask;
// proper.ObjectData[0].AggregatePerms = 53;
// proper.ObjectData[0].AggregatePermTextures = 0;
// proper.ObjectData[0].AggregatePermTexturesOwner = 0;
- proper.ObjectData[0].SaleType = saleType;
- proper.ObjectData[0].SalePrice = salePrice;
+ block.SaleType = saleType;
+ block.SalePrice = salePrice;
+
+ lock (m_propertiesPacketTimer)
+ {
+ m_propertiesBlocks.Add(block);
+
+ int length = 0;
+ foreach (ObjectPropertiesPacket.ObjectDataBlock b in m_propertiesBlocks)
+ {
+ length += b.Length;
+ }
+ if (length > 1100) // FIXME: use real MTU
+ {
+ ProcessObjectPropertiesPacket(null, null);
+ m_propertiesPacketTimer.Stop();
+ return;
+ }
+
+ m_propertiesPacketTimer.Stop();
+ m_propertiesPacketTimer.Start();
+ }
+
+ //proper.Header.Zerocoded = true;
+ //OutPacket(proper, ThrottleOutPacketType.Task);
+ }
+
+ private void ProcessObjectPropertiesPacket(Object sender, ElapsedEventArgs e)
+ {
+ ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
+
+ lock (m_propertiesPacketTimer)
+ {
+ m_propertiesPacketTimer.Stop();
+
+ proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
+
+ int index = 0;
+
+ foreach (ObjectPropertiesPacket.ObjectDataBlock b in m_propertiesBlocks)
+ {
+ proper.ObjectData[index++] = b;
+ }
+
+ m_propertiesBlocks.Clear();
+ }
+
proper.Header.Zerocoded = true;
OutPacket(proper, ThrottleOutPacketType.Task);
}
--
cgit v1.1
From ceccfe02d0e25c234560b6ef25306b8db4cd9875 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 00:02:24 +0000
Subject: Eliminate multiple updates on link/unlink
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 ++
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++----
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 ++++++++
3 files changed, 14 insertions(+), 4 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2fdb48d..d87e814 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1593,6 +1593,8 @@ namespace OpenSim.Region.Framework.Scenes
// occur on link to invoke this elsewhere (such as object selection)
parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected);
parentGroup.TriggerScriptChangedEvent(Changed.LINK);
+ parentGroup.HasGroupChanged = true;
+ parentGroup.ScheduleGroupForFullUpdate();
if (client != null)
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index ecda80c..fa2e3ce 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2389,8 +2389,8 @@ namespace OpenSim.Region.Framework.Scenes
// unmoved prims!
ResetChildPrimPhysicsPositions();
- HasGroupChanged = true;
- ScheduleGroupForFullUpdate();
+ //HasGroupChanged = true;
+ //ScheduleGroupForFullUpdate();
}
///
@@ -2483,8 +2483,8 @@ namespace OpenSim.Region.Framework.Scenes
linkPart.Rezzed = RootPart.Rezzed;
- HasGroupChanged = true;
- ScheduleGroupForFullUpdate();
+ //HasGroupChanged = true;
+ //ScheduleGroupForFullUpdate();
}
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 267928b..e694f15 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3588,6 +3588,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
parentPrim.DelinkFromGroup(part.LocalId, true);
}
+ parentPrim.HasGroupChanged = true;
+ parentPrim.ScheduleGroupForFullUpdate();
parentPrim.TriggerScriptChangedEvent(Changed.LINK);
if (parts.Count > 0)
@@ -3599,6 +3601,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.UpdateFlag = 0;
newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
}
+ newRoot.ParentGroup.HasGroupChanged = true;
+ newRoot.ParentGroup.ScheduleGroupForFullUpdate();
}
}
else
@@ -3607,6 +3611,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
parentPrim.DelinkFromGroup(childPrim.LocalId, true);
+ parentPrim.HasGroupChanged = true;
+ parentPrim.ScheduleGroupForFullUpdate();
parentPrim.TriggerScriptChangedEvent(Changed.LINK);
}
}
@@ -3626,6 +3632,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
parentPrim.DelinkFromGroup(part.LocalId, true);
parentPrim.TriggerScriptChangedEvent(Changed.LINK);
}
+ parentPrim.HasGroupChanged = true;
+ parentPrim.ScheduleGroupForFullUpdate();
}
public LSL_String llGetLinkKey(int linknum)
--
cgit v1.1
From fbefa8273be70d90404b37230c168fd031288e31 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 00:25:04 +0000
Subject: Lock updates out while linking and unlinking
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 255 ++++++++++++++------------
1 file changed, 134 insertions(+), 121 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index d87e814..5efe188 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -26,6 +26,7 @@
*/
using System;
+using System.Threading;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
@@ -96,6 +97,8 @@ namespace OpenSim.Region.Framework.Scenes
protected internal Dictionary SceneObjectGroupsByFullID = new Dictionary();
private readonly Object m_dictionary_lock = new Object();
+ private Object m_updateLock = new Object();
+
#endregion
protected internal SceneGraph(Scene parent, RegionInfo regInfo)
@@ -369,6 +372,9 @@ namespace OpenSim.Region.Framework.Scenes
///
protected internal void UpdateObjectGroups()
{
+ if (!Monitor.TryEnter(m_updateLock))
+ return;
+
List updates;
// Some updates add more updates to the updateList.
@@ -395,6 +401,7 @@ namespace OpenSim.Region.Framework.Scenes
"[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e);
}
}
+ Monitor.Exit(m_updateLock);
}
protected internal void AddPhysicalPrim(int number)
@@ -1555,56 +1562,59 @@ namespace OpenSim.Region.Framework.Scenes
///
protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List childPrimIds)
{
- SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId);
-
- List childGroups = new List();
- if (parentGroup != null)
+ lock (m_updateLock)
{
- // We do this in reverse to get the link order of the prims correct
- for (int i = childPrimIds.Count - 1; i >= 0; i--)
+ SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId);
+
+ List childGroups = new List();
+ if (parentGroup != null)
{
- SceneObjectGroup child = GetGroupByPrim(childPrimIds[i]);
- if (child != null)
+ // We do this in reverse to get the link order of the prims correct
+ for (int i = childPrimIds.Count - 1; i >= 0; i--)
{
- // Make sure no child prim is set for sale
- // So that, on delink, no prims are unwittingly
- // left for sale and sold off
- child.RootPart.ObjectSaleType = 0;
- child.RootPart.SalePrice = 10;
- childGroups.Add(child);
+ SceneObjectGroup child = GetGroupByPrim(childPrimIds[i]);
+ if (child != null)
+ {
+ // Make sure no child prim is set for sale
+ // So that, on delink, no prims are unwittingly
+ // left for sale and sold off
+ child.RootPart.ObjectSaleType = 0;
+ child.RootPart.SalePrice = 10;
+ childGroups.Add(child);
+ }
}
}
- }
- else
- {
- return; // parent is null so not in this region
- }
+ else
+ {
+ return; // parent is null so not in this region
+ }
- foreach (SceneObjectGroup child in childGroups)
- {
- parentGroup.LinkToGroup(child);
+ foreach (SceneObjectGroup child in childGroups)
+ {
+ parentGroup.LinkToGroup(child);
- // this is here so physics gets updated!
- // Don't remove! Bad juju! Stay away! or fix physics!
- child.AbsolutePosition = child.AbsolutePosition;
- }
+ // this is here so physics gets updated!
+ // Don't remove! Bad juju! Stay away! or fix physics!
+ child.AbsolutePosition = child.AbsolutePosition;
+ }
- // We need to explicitly resend the newly link prim's object properties since no other actions
- // occur on link to invoke this elsewhere (such as object selection)
- parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected);
- parentGroup.TriggerScriptChangedEvent(Changed.LINK);
- parentGroup.HasGroupChanged = true;
- parentGroup.ScheduleGroupForFullUpdate();
-
- if (client != null)
- {
- parentGroup.GetProperties(client);
- }
- else
- {
- foreach (ScenePresence p in GetScenePresences())
+ // We need to explicitly resend the newly link prim's object properties since no other actions
+ // occur on link to invoke this elsewhere (such as object selection)
+ parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected);
+ parentGroup.TriggerScriptChangedEvent(Changed.LINK);
+ parentGroup.HasGroupChanged = true;
+ parentGroup.ScheduleGroupForFullUpdate();
+
+ if (client != null)
{
- parentGroup.GetProperties(p.ControllingClient);
+ parentGroup.GetProperties(client);
+ }
+ else
+ {
+ foreach (ScenePresence p in GetScenePresences())
+ {
+ parentGroup.GetProperties(p.ControllingClient);
+ }
}
}
}
@@ -1620,109 +1630,112 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void DelinkObjects(List primIds, bool sendEvents)
{
- List childParts = new List();
- List rootParts = new List();
- List affectedGroups = new List();
- // Look them all up in one go, since that is comparatively expensive
- //
- foreach (uint primID in primIds)
+ lock (m_updateLock)
{
- SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID);
- if (part != null)
+ List childParts = new List();
+ List rootParts = new List();
+ List affectedGroups = new List();
+ // Look them all up in one go, since that is comparatively expensive
+ //
+ foreach (uint primID in primIds)
{
- if (part.LinkNum < 2) // Root or single
- rootParts.Add(part);
+ SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID);
+ if (part != null)
+ {
+ if (part.LinkNum < 2) // Root or single
+ rootParts.Add(part);
+ else
+ childParts.Add(part);
+
+ SceneObjectGroup group = part.ParentGroup;
+ if (!affectedGroups.Contains(group))
+ affectedGroups.Add(group);
+ }
else
- childParts.Add(part);
-
- SceneObjectGroup group = part.ParentGroup;
- if (!affectedGroups.Contains(group))
- affectedGroups.Add(group);
+ {
+ m_log.ErrorFormat("Viewer requested unlink of nonexistent part {0}", primID);
+ }
}
- else
+
+ foreach (SceneObjectPart child in childParts)
{
- m_log.ErrorFormat("Viewer requested unlink of nonexistent part {0}", primID);
+ // Unlink all child parts from their groups
+ //
+ child.ParentGroup.DelinkFromGroup(child, sendEvents);
}
- }
- foreach (SceneObjectPart child in childParts)
- {
- // Unlink all child parts from their groups
- //
- child.ParentGroup.DelinkFromGroup(child, sendEvents);
- }
-
- foreach (SceneObjectPart root in rootParts)
- {
- // In most cases, this will run only one time, and the prim
- // will be a solo prim
- // However, editing linked parts and unlinking may be different
- //
- SceneObjectGroup group = root.ParentGroup;
- List newSet = new List(group.Children.Values);
- int numChildren = group.Children.Count;
-
- // If there are prims left in a link set, but the root is
- // slated for unlink, we need to do this
- //
- if (numChildren != 1)
+ foreach (SceneObjectPart root in rootParts)
{
- // Unlink the remaining set
+ // In most cases, this will run only one time, and the prim
+ // will be a solo prim
+ // However, editing linked parts and unlinking may be different
//
- bool sendEventsToRemainder = true;
- if (numChildren > 1)
- sendEventsToRemainder = false;
-
- foreach (SceneObjectPart p in newSet)
- {
- if (p != group.RootPart)
- group.DelinkFromGroup(p, sendEventsToRemainder);
- }
+ SceneObjectGroup group = root.ParentGroup;
+ List newSet = new List(group.Children.Values);
+ int numChildren = group.Children.Count;
- // If there is more than one prim remaining, we
- // need to re-link
+ // If there are prims left in a link set, but the root is
+ // slated for unlink, we need to do this
//
- if (numChildren > 2)
+ if (numChildren != 1)
{
- // Remove old root
+ // Unlink the remaining set
//
- if (newSet.Contains(root))
- newSet.Remove(root);
+ bool sendEventsToRemainder = true;
+ if (numChildren > 1)
+ sendEventsToRemainder = false;
- // Preserve link ordering
- //
- newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b)
+ foreach (SceneObjectPart p in newSet)
{
- return a.LinkNum.CompareTo(b.LinkNum);
- });
+ if (p != group.RootPart)
+ group.DelinkFromGroup(p, sendEventsToRemainder);
+ }
- // Determine new root
+ // If there is more than one prim remaining, we
+ // need to re-link
//
- SceneObjectPart newRoot = newSet[0];
- newSet.RemoveAt(0);
+ if (numChildren > 2)
+ {
+ // Remove old root
+ //
+ if (newSet.Contains(root))
+ newSet.Remove(root);
+
+ // Preserve link ordering
+ //
+ newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b)
+ {
+ return a.LinkNum.CompareTo(b.LinkNum);
+ });
- List linkIDs = new List();
+ // Determine new root
+ //
+ SceneObjectPart newRoot = newSet[0];
+ newSet.RemoveAt(0);
- foreach (SceneObjectPart newChild in newSet)
- {
- newChild.UpdateFlag = 0;
- linkIDs.Add(newChild.LocalId);
- }
+ List linkIDs = new List();
+
+ foreach (SceneObjectPart newChild in newSet)
+ {
+ newChild.UpdateFlag = 0;
+ linkIDs.Add(newChild.LocalId);
+ }
- LinkObjects(null, newRoot.LocalId, linkIDs);
- if (!affectedGroups.Contains(newRoot.ParentGroup))
- affectedGroups.Add(newRoot.ParentGroup);
+ LinkObjects(null, newRoot.LocalId, linkIDs);
+ if (!affectedGroups.Contains(newRoot.ParentGroup))
+ affectedGroups.Add(newRoot.ParentGroup);
+ }
}
}
- }
- // Finally, trigger events in the roots
- //
- foreach (SceneObjectGroup g in affectedGroups)
- {
- g.TriggerScriptChangedEvent(Changed.LINK);
- g.HasGroupChanged = true; // Persist
- g.ScheduleGroupForFullUpdate();
+ // Finally, trigger events in the roots
+ //
+ foreach (SceneObjectGroup g in affectedGroups)
+ {
+ g.TriggerScriptChangedEvent(Changed.LINK);
+ g.HasGroupChanged = true; // Persist
+ g.ScheduleGroupForFullUpdate();
+ }
}
}
--
cgit v1.1
From f2891e77383f70d807f4ef1ceefbf9a0f2bf6a84 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 00:50:28 +0000
Subject: Remove extra forced updates. They're not needed for each prim.
Really.
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fa2e3ce..93888f1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2292,14 +2292,14 @@ namespace OpenSim.Region.Framework.Scenes
public void LinkToGroup(SceneObjectGroup objectGroup)
{
// Make sure we have sent any pending unlinks or stuff.
- if (objectGroup.RootPart.UpdateFlag > 0)
- {
- m_log.WarnFormat(
- "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.",
- objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
+ //if (objectGroup.RootPart.UpdateFlag > 0)
+ //{
+ // m_log.WarnFormat(
+ // "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.",
+ // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
- objectGroup.RootPart.SendScheduledUpdates();
- }
+ // objectGroup.RootPart.SendScheduledUpdates();
+ //}
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}",
--
cgit v1.1
From da414fd509a6adfa0499b71172e1c789b3cf7ca4 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 01:20:39 +0000
Subject: Change locking to not mix explicit Monitor.* calls with lock()
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 5efe188..4bdc52c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1562,7 +1562,8 @@ namespace OpenSim.Region.Framework.Scenes
///
protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List childPrimIds)
{
- lock (m_updateLock)
+ Monitor.Enter(m_updateLock);
+ try
{
SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId);
@@ -1617,6 +1618,10 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
+ finally
+ {
+ Monitor.Exit(m_updateLock);
+ }
}
///
@@ -1630,7 +1635,8 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void DelinkObjects(List primIds, bool sendEvents)
{
- lock (m_updateLock)
+ Monitor.Enter(m_updateLock);
+ try
{
List childParts = new List();
List rootParts = new List();
@@ -1737,6 +1743,10 @@ namespace OpenSim.Region.Framework.Scenes
g.ScheduleGroupForFullUpdate();
}
}
+ finally
+ {
+ Monitor.Exit(m_updateLock);
+ }
}
protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID)
--
cgit v1.1
From 2fe75a62bec2f06155bf5f05b6f558d028f6b12c Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 02:00:32 +0000
Subject: Skip single prims in unlink selections
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 4bdc52c..18e7b79 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1648,14 +1648,17 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart part = m_parentScene.GetSceneObjectPart(primID);
if (part != null)
{
- if (part.LinkNum < 2) // Root or single
- rootParts.Add(part);
- else
- childParts.Add(part);
-
- SceneObjectGroup group = part.ParentGroup;
- if (!affectedGroups.Contains(group))
- affectedGroups.Add(group);
+ if (part.ParentGroup.Children.Count != 1) // Skip single
+ {
+ if (part.LinkNum < 2) // Root
+ rootParts.Add(part);
+ else
+ childParts.Add(part);
+
+ SceneObjectGroup group = part.ParentGroup;
+ if (!affectedGroups.Contains(group))
+ affectedGroups.Add(group);
+ }
}
else
{
--
cgit v1.1
From 79511ecce240a864dc02575acd3399fb244a8d82 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 02:15:52 +0000
Subject: Experimental: Remove explicit property sends
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 18e7b79..f74fd5d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1606,17 +1606,17 @@ namespace OpenSim.Region.Framework.Scenes
parentGroup.HasGroupChanged = true;
parentGroup.ScheduleGroupForFullUpdate();
- if (client != null)
- {
- parentGroup.GetProperties(client);
- }
- else
- {
- foreach (ScenePresence p in GetScenePresences())
- {
- parentGroup.GetProperties(p.ControllingClient);
- }
- }
+// if (client != null)
+// {
+// parentGroup.GetProperties(client);
+// }
+// else
+// {
+// foreach (ScenePresence p in GetScenePresences())
+// {
+// parentGroup.GetProperties(p.ControllingClient);
+// }
+// }
}
finally
{
--
cgit v1.1
From f9ae9afaacc82ee0284b1f7dc88ad880aabe23af Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 03:10:34 +0000
Subject: Fix build break from conflicted merge
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 3d4490a..f6bcb59 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1972,7 +1972,7 @@ namespace OpenSim.Region.Framework.Scenes
SendFullUpdateToAllClients();
}
- public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance)
+ public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal)
{
if(hitYN)
{
--
cgit v1.1
From 1e222d52e6219db4ad32338b952a94eebb0f7799 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 6 Dec 2009 03:56:15 +0000
Subject: Change EntityManager to use RWlocks
---
OpenSim/Region/Framework/Scenes/EntityManager.cs | 79 ++++++++++++++++++++----
1 file changed, 67 insertions(+), 12 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs
index 099fcce..c246e32 100644
--- a/OpenSim/Region/Framework/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Region.Framework.Scenes
private readonly Dictionary m_eb_uuid = new Dictionary();
private readonly Dictionary m_eb_localID = new Dictionary();
//private readonly Dictionary m_pres_uuid = new Dictionary();
- private readonly Object m_lock = new Object();
+ private System.Threading.ReaderWriterLockSlim m_lock = new System.Threading.ReaderWriterLockSlim();
[Obsolete("Use Add() instead.")]
public void Add(UUID id, EntityBase eb)
@@ -50,7 +50,8 @@ namespace OpenSim.Region.Framework.Scenes
public void Add(EntityBase entity)
{
- lock (m_lock)
+ m_lock.EnterWriteLock();
+ try
{
try
{
@@ -62,11 +63,16 @@ namespace OpenSim.Region.Framework.Scenes
m_log.ErrorFormat("Add Entity failed: {0}", e.Message);
}
}
+ finally
+ {
+ m_lock.ExitWriteLock();
+ }
}
public void InsertOrReplace(EntityBase entity)
{
- lock (m_lock)
+ m_lock.EnterWriteLock();
+ try
{
try
{
@@ -78,15 +84,24 @@ namespace OpenSim.Region.Framework.Scenes
m_log.ErrorFormat("Insert or Replace Entity failed: {0}", e.Message);
}
}
+ finally
+ {
+ m_lock.ExitWriteLock();
+ }
}
public void Clear()
{
- lock (m_lock)
+ m_lock.EnterWriteLock();
+ try
{
m_eb_uuid.Clear();
m_eb_localID.Clear();
}
+ finally
+ {
+ m_lock.ExitWriteLock();
+ }
}
public int Count
@@ -123,7 +138,8 @@ namespace OpenSim.Region.Framework.Scenes
public bool Remove(uint localID)
{
- lock (m_lock)
+ m_lock.EnterWriteLock();
+ try
{
try
{
@@ -141,11 +157,16 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
}
+ finally
+ {
+ m_lock.ExitWriteLock();
+ }
}
public bool Remove(UUID id)
{
- lock (m_lock)
+ m_lock.EnterWriteLock();
+ try
{
try
{
@@ -163,13 +184,18 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
}
+ finally
+ {
+ m_lock.ExitWriteLock();
+ }
}
public List GetAllByType()
{
List tmp = new List();
- lock (m_lock)
+ m_lock.EnterReadLock();
+ try
{
try
{
@@ -187,23 +213,33 @@ namespace OpenSim.Region.Framework.Scenes
tmp = null;
}
}
+ finally
+ {
+ m_lock.ExitReadLock();
+ }
return tmp;
}
public List GetEntities()
{
- lock (m_lock)
+ m_lock.EnterReadLock();
+ try
{
return new List(m_eb_uuid.Values);
}
+ finally
+ {
+ m_lock.ExitReadLock();
+ }
}
public EntityBase this[UUID id]
{
get
{
- lock (m_lock)
+ m_lock.EnterReadLock();
+ try
{
EntityBase entity;
if (m_eb_uuid.TryGetValue(id, out entity))
@@ -211,6 +247,10 @@ namespace OpenSim.Region.Framework.Scenes
else
return null;
}
+ finally
+ {
+ m_lock.ExitReadLock();
+ }
}
set
{
@@ -222,7 +262,8 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- lock (m_lock)
+ m_lock.EnterReadLock();
+ try
{
EntityBase entity;
if (m_eb_localID.TryGetValue(localID, out entity))
@@ -230,6 +271,10 @@ namespace OpenSim.Region.Framework.Scenes
else
return null;
}
+ finally
+ {
+ m_lock.ExitReadLock();
+ }
}
set
{
@@ -239,18 +284,28 @@ namespace OpenSim.Region.Framework.Scenes
public bool TryGetValue(UUID key, out EntityBase obj)
{
- lock (m_lock)
+ m_lock.EnterReadLock();
+ try
{
return m_eb_uuid.TryGetValue(key, out obj);
}
+ finally
+ {
+ m_lock.ExitReadLock();
+ }
}
public bool TryGetValue(uint key, out EntityBase obj)
{
- lock (m_lock)
+ m_lock.EnterReadLock();
+ try
{
return m_eb_localID.TryGetValue(key, out obj);
}
+ finally
+ {
+ m_lock.ExitReadLock();
+ }
}
///
--
cgit v1.1
From 172e2f4e7609c278d02ad83ca207fd79624db587 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Sun, 6 Dec 2009 17:23:07 +0100
Subject: Fix to existing ReaderWriterLockSlim implementations
---
OpenSim/Framework/TaskInventoryDictionary.cs | 10 ++++++++--
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ++++++++--
OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 3 ++-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 10 ++++++++--
4 files changed, 26 insertions(+), 7 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs
index efe5f0c..4b9a509 100644
--- a/OpenSim/Framework/TaskInventoryDictionary.cs
+++ b/OpenSim/Framework/TaskInventoryDictionary.cs
@@ -109,7 +109,10 @@ namespace OpenSim.Framework
}
else
{
- m_itemLock.ExitReadLock();
+ if (m_itemLock.RecursiveReadCount>0)
+ {
+ m_itemLock.ExitReadLock();
+ }
}
}
@@ -144,7 +147,10 @@ namespace OpenSim.Framework
}
else
{
- m_itemLock.ExitWriteLock();
+ if (m_itemLock.RecursiveWriteCount > 0)
+ {
+ m_itemLock.ExitWriteLock();
+ }
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 93888f1..eacd219 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -126,7 +126,10 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- m_partsLock.ExitReadLock();
+ if (m_partsLock.RecursiveReadCount > 0)
+ {
+ m_partsLock.ExitReadLock();
+ }
}
}
public void lockPartsForWrite(bool locked)
@@ -155,7 +158,10 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- m_partsLock.ExitWriteLock();
+ if (m_partsLock.RecursiveWriteCount > 0)
+ {
+ m_partsLock.ExitWriteLock();
+ }
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 4780ff2..b57d912 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -320,17 +320,18 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_items.ContainsKey(itemId))
{
+ m_items.LockItemsForRead(false);
CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource);
}
else
{
+ m_items.LockItemsForRead(false);
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
itemId, m_part.Name, m_part.UUID,
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
}
- m_items.LockItemsForRead(false);
}
else
{
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 49c69ab..184af19 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -150,7 +150,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
else
{
- m_scriptsLock.ExitReadLock();
+ if (m_scriptsLock.RecursiveReadCount > 0)
+ {
+ m_scriptsLock.ExitReadLock();
+ }
}
}
private void lockScriptsForWrite(bool locked)
@@ -179,7 +182,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
else
{
- m_scriptsLock.ExitWriteLock();
+ if (m_scriptsLock.RecursiveWriteCount > 0)
+ {
+ m_scriptsLock.ExitWriteLock();
+ }
}
}
--
cgit v1.1
From 0d1d437bd3bf608448d71ea7de8e4f7cfb0371f0 Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Sun, 6 Dec 2009 21:11:59 +0100
Subject: Fix linked physical daughter prim position update.
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 17 ++++++++++++++---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 --
2 files changed, 14 insertions(+), 5 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 9f2c3db..a6382ee 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -513,9 +513,16 @@ namespace OpenSim.Region.Framework.Scenes
{
// If this is a linkset, we don't want the physics engine mucking up our group position here.
PhysicsActor actor = PhysActor;
- if (actor != null && _parentID == 0)
+ if (actor != null)
{
- m_groupPosition = actor.Position;
+ if (_parentID == 0)
+ {
+ m_groupPosition = actor.Position;
+ }
+ else
+ {
+ m_groupPosition = ParentGroup.AbsolutePosition; // KF+Casper Update Child prims too!
+ }
}
if (IsAttachment)
@@ -1743,9 +1750,13 @@ namespace OpenSim.Region.Framework.Scenes
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
Vector3 axPos = OffsetPosition;
-
axPos *= parentRot;
Vector3 translationOffsetPosition = axPos;
+
+ int tx = (int)GroupPosition.X;
+ int ty = (int)GroupPosition.Y;
+ int tz = (int)GroupPosition.Z;
+
return GroupPosition + translationOffsetPosition;
}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 817b9df..5d0218f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1642,7 +1642,6 @@ namespace OpenSim.Region.Framework.Scenes
// Reset sit target.
if (part.GetAvatarOnSitTarget() == UUID)
part.SetAvatarOnSitTarget(UUID.Zero);
-
m_parentPosition = part.GetWorldPosition();
ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
}
@@ -1659,7 +1658,6 @@ namespace OpenSim.Region.Framework.Scenes
}
AbsolutePosition = wso; //KF: Fix stand up.
m_parentPosition = Vector3.Zero;
-
m_parentID = 0;
part.IsOccupied = false;
SendFullUpdateToAllClients();
--
cgit v1.1
From c2d3afdeee1b1b8b9b4ef0c6588777536adc15db Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 7 Dec 2009 14:31:20 +0000
Subject: Same for the remote auth connector
---
.../Authorization/RemoteAuthorizationServiceConnector.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index fca2df2..68499f3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
IConfig authorizationConfig = source.Configs["AuthorizationService"];
if (authorizationConfig == null)
{
- m_log.Error("[REMOTE AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
+ m_log.Info("[REMOTE AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
return;
}
--
cgit v1.1
From 29a740ec8c78bfc3c1ab5b41b302ae2205c6e9aa Mon Sep 17 00:00:00 2001
From: unknown
Date: Mon, 7 Dec 2009 18:03:53 +0100
Subject: Initial windlight codebase commit
---
OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 2 +-
.../Client/VWoHTTP/ClientStack/VWHClientView.cs | 2 +-
OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 9 +-
OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 192 +++++++++++++++++++++
OpenSim/Data/Null/NullDataStore.cs | 7 +-
OpenSim/Data/SQLite/SQLiteRegionData.cs | 7 +-
OpenSim/Framework/IClientAPI.cs | 2 +-
OpenSim/Framework/RegionInfo.cs | 69 +++++++-
.../Region/ClientStack/LindenUDP/LLClientView.cs | 6 +-
.../Region/Examples/SimpleModule/MyNpcCharacter.cs | 2 +-
.../Framework/Interfaces/IRegionDataStore.cs | 1 +
OpenSim/Region/Framework/Scenes/Scene.cs | 2 +
.../Region/Framework/Scenes/Tests/SceneTests.cs | 7 +-
.../Server/IRCClientView.cs | 2 +-
.../Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +-
OpenSim/Tests/Common/Mock/TestClient.cs | 2 +-
16 files changed, 297 insertions(+), 17 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index 0cae3dd..9f9d151 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -902,7 +902,7 @@ namespace OpenSim.Client.MXP.ClientStack
// Need to translate to MXP somehow
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
// Need to translate to MXP somehow
}
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
index fb87c15..533475f 100644
--- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
+++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
@@ -483,7 +483,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
throw new System.NotImplementedException();
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
throw new System.NotImplementedException();
}
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
index 6371307..678b251 100644
--- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
@@ -671,7 +671,12 @@ VALUES
cmd.ExecuteNonQuery();
}
}
-
+ public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
+ {
+ //This connector doesn't support the windlight module yet
+ //Return default LL windlight settings
+ return new RegionMeta7WindlightData();
+ }
///
/// Loads the settings of a region.
///
@@ -696,7 +701,7 @@ VALUES
}
}
- //If comes here then there is now region setting for that region
+ //If we reach this point then there are new region settings for that region
regionSettings = new RegionSettings();
regionSettings.RegionUUID = regionUUID;
regionSettings.OnSave += StoreRegionSettings;
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
index c49153f..e47d2a5 100644
--- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
@@ -691,6 +691,97 @@ namespace OpenSim.Data.MySQL
}
}
+ public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
+ {
+ RegionMeta7WindlightData nWP = new RegionMeta7WindlightData();
+ nWP.OnSave += StoreRegionWindlightSettings;
+ lock (m_Connection)
+ {
+
+ string command = "select * from `regionwindlight` where region_id = ?regionID";
+
+ MySqlCommand cmd = new MySqlCommand(command);
+
+ 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
+ {
+ UUID.TryParse(result["region_id"].ToString(), out nWP.regionID);
+ 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"]);
+ }
+ }
+ return nWP;
+ }
+
public RegionSettings LoadRegionSettings(UUID regionUUID)
{
RegionSettings rs = null;
@@ -724,6 +815,107 @@ namespace OpenSim.Data.MySQL
return rs;
}
+ public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
+ {
+ lock (m_Connection)
+ {
+ using (MySqlCommand cmd = m_Connection.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 StoreRegionSettings(RegionSettings rs)
{
lock (m_Connection)
diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs
index 427fa0a..39ca8f9 100644
--- a/OpenSim/Data/Null/NullDataStore.cs
+++ b/OpenSim/Data/Null/NullDataStore.cs
@@ -50,7 +50,12 @@ namespace OpenSim.Data.Null
public void StoreRegionSettings(RegionSettings rs)
{
}
-
+ public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
+ {
+ //This connector doesn't support the windlight module yet
+ //Return default LL windlight settings
+ return new RegionMeta7WindlightData();
+ }
public RegionSettings LoadRegionSettings(UUID regionUUID)
{
return null;
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index b68de1a..53b806c 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -272,7 +272,12 @@ namespace OpenSim.Data.SQLite
Commit();
}
}
-
+ public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
+ {
+ //This connector doesn't support the windlight module yet
+ //Return default LL windlight settings
+ return new RegionMeta7WindlightData();
+ }
public RegionSettings LoadRegionSettings(UUID regionUUID)
{
lock (ds)
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 04ba9c6..cb136e2 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1077,7 +1077,7 @@ namespace OpenSim.Framework
void SendInstantMessage(GridInstantMessage im);
- void SendGenericMessage(string method, List message);
+ void SendGenericMessage(string method, List message);
void SendLayerData(float[] map);
void SendLayerData(int px, int py, float[] map);
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 721233d..c39cc03 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -36,8 +36,59 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework.Console;
+
namespace OpenSim.Framework
{
+ public class RegionMeta7WindlightData
+ {
+ public UUID regionID = UUID.Zero;
+ public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f);
+ public float waterFogDensityExponent = 4.0f;
+ public float underwaterFogModifier = 0.25f;
+ public Vector3 reflectionWaveletScale = new Vector3(2.0f,2.0f,2.0f);
+ public float fresnelScale = 0.40f;
+ public float fresnelOffset = 0.50f;
+ public float refractScaleAbove = 0.03f;
+ public float refractScaleBelow = 0.20f;
+ public float blurMultiplier = 0.040f;
+ public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f);
+ public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f);
+ public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4");
+ public Vector4 horizon = new Vector4(0.26f, 0.24f, 0.34f, 0.33f);
+ public float hazeHorizon = 0.19f;
+ public Vector4 blueDensity = new Vector4(0.10f, 0.93f, 0.02f, 0.93f);
+ public float hazeDensity = 0.70f;
+ public float densityMultiplier = 0.18f;
+ public float distanceMultiplier = 0.8f;
+ public UInt16 maxAltitude = 1605;
+ public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f);
+ public float sunMoonPosition = 0.335f;
+ public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f);
+ public float eastAngle = 0.0f;
+ public float sunGlowFocus = 0.10f;
+ public float sunGlowSize = 0.10f;
+ public float sceneGamma = 1.0f;
+ public float starBrightness = 0.0f;
+ public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f);
+ public Vector3 cloudXYDensity = new Vector3(1.00f, 0.53f, 1.00f);
+ public float cloudCoverage = 0.27f;
+ public float cloudScale = 0.42f;
+ public Vector3 cloudDetailXYDensity = new Vector3(1.00f, 0.53f, 0.12f);
+ public float cloudScrollX = 0.20f;
+ public bool cloudScrollXLock = false;
+ public float cloudScrollY = 0.01f;
+ public bool cloudScrollYLock = false;
+ public bool drawClassicClouds = false;
+
+ public delegate void SaveDelegate(RegionMeta7WindlightData wl);
+ public event SaveDelegate OnSave;
+ public void Save()
+ {
+ if (OnSave != null)
+ OnSave(this);
+ }
+ }
+
[Serializable]
public class SimpleRegionInfo
{
@@ -304,8 +355,7 @@ namespace OpenSim.Framework
private bool m_clampPrimSize = false;
private int m_objectCapacity = 0;
private string m_regionType = String.Empty;
-
-
+ private RegionMeta7WindlightData m_windlight = new RegionMeta7WindlightData();
// Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
// MT: Yes. Estates can't span trust boundaries. Therefore, it can be
@@ -454,6 +504,21 @@ namespace OpenSim.Framework
set { m_regionSettings = value; }
}
+ public RegionMeta7WindlightData WindlightSettings
+ {
+ get
+ {
+ if (m_windlight == null)
+ {
+ m_windlight = new RegionMeta7WindlightData();
+ }
+
+ return m_windlight;
+ }
+
+ set { m_windlight = value; }
+ }
+
public int NonphysPrimMax
{
get { return m_nonphysPrimMax; }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index b588a2e..6cbf1a6 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -764,16 +764,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
GenericMessagePacket gmp = new GenericMessagePacket();
gmp.MethodData.Method = Util.StringToBytes256(method);
gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
int i = 0;
- foreach (string val in message)
+ foreach (byte[] val in message)
{
gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
- gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
+ gmp.ParamList[i++].Parameter = val;
}
OutPacket(gmp, ThrottleOutPacketType.Task);
}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 9754da3..816060f 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -433,7 +433,7 @@ namespace OpenSim.Region.Examples.SimpleModule
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
}
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
index 78bd622..225cc9a 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces
void StoreRegionSettings(RegionSettings rs);
RegionSettings LoadRegionSettings(UUID regionUUID);
+ RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID);
void Shutdown();
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f5a1e74..f70af27 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -539,6 +539,8 @@ namespace OpenSim.Region.Framework.Scenes
// Load region settings
m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID);
+ m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(m_regInfo.RegionID);
+
if (m_storageManager.EstateDataStore != null)
{
m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 8a27b7b..e8cda60 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -101,7 +101,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
{
throw new NotImplementedException();
}
-
+ public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID)
+ {
+ //This connector doesn't support the windlight module yet
+ //Return default LL windlight settings
+ return new RegionMeta7WindlightData();
+ }
public RegionSettings LoadRegionSettings(UUID regionUUID)
{
return null;
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 6c3e7eb..bdf1574 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -936,7 +936,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
// TODO
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index cf36d08..975033a 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -522,7 +522,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 27025d9..5f172c4 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -491,7 +491,7 @@ namespace OpenSim.Tests.Common.Mock
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
}
--
cgit v1.1
From ee9d46c8255840473ed62c3b37270b35af1a9027 Mon Sep 17 00:00:00 2001
From: KittoFlora
Date: Tue, 8 Dec 2009 05:49:05 +0100
Subject: Correct AbsolutePosition calculation
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a6382ee..a23c11e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -849,7 +849,8 @@ namespace OpenSim.Region.Framework.Scenes
if (IsAttachment)
return GroupPosition;
- return m_offsetPosition + m_groupPosition; }
+// return m_offsetPosition + m_groupPosition; }
+ return m_groupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset) ; } //KF: Rotation was ignored!
}
public SceneObjectGroup ParentGroup
--
cgit v1.1
From e3f229225c5a1506090bfcffcce6d423a566f1fe Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 9 Dec 2009 01:34:26 +0100
Subject: Enable scripting interface for windlight
---
OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 4 +
OpenSim/Data/Null/NullDataStore.cs | 4 +
OpenSim/Data/SQLite/SQLiteRegionData.cs | 4 +
.../Framework/Interfaces/IRegionDataStore.cs | 1 +
OpenSim/Region/Framework/Scenes/EventManager.cs | 12 +
OpenSim/Region/Framework/Scenes/Scene.cs | 7 +
.../Region/Framework/Scenes/Tests/SceneTests.cs | 4 +
.../Shared/Api/Implementation/OSSL_Api.cs | 333 +++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 7 +-
.../Shared/Api/Runtime/LSL_Constants.cs | 38 +++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 +
11 files changed, 423 insertions(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
index 678b251..0b430c7 100644
--- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
@@ -677,6 +677,10 @@ VALUES
//Return default LL windlight settings
return new RegionMeta7WindlightData();
}
+ public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
+ {
+ //This connector doesn't support the windlight module yet
+ }
///
/// Loads the settings of a region.
///
diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs
index 39ca8f9..4b6d0f3 100644
--- a/OpenSim/Data/Null/NullDataStore.cs
+++ b/OpenSim/Data/Null/NullDataStore.cs
@@ -56,6 +56,10 @@ namespace OpenSim.Data.Null
//Return default LL windlight settings
return new RegionMeta7WindlightData();
}
+ public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
+ {
+ //This connector doesn't support the windlight module yet
+ }
public RegionSettings LoadRegionSettings(UUID regionUUID)
{
return null;
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 53b806c..f1c1f78 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -278,6 +278,10 @@ namespace OpenSim.Data.SQLite
//Return default LL windlight settings
return new RegionMeta7WindlightData();
}
+ public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
+ {
+ //This connector doesn't support the windlight module yet
+ }
public RegionSettings LoadRegionSettings(UUID regionUUID)
{
lock (ds)
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
index 225cc9a..7312799 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs
@@ -104,6 +104,7 @@ namespace OpenSim.Region.Framework.Interfaces
void StoreRegionSettings(RegionSettings rs);
RegionSettings LoadRegionSettings(UUID regionUUID);
RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID);
+ void StoreRegionWindlightSettings(RegionMeta7WindlightData wl);
void Shutdown();
}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 753344d..a86e263 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -193,7 +193,9 @@ namespace OpenSim.Region.Framework.Scenes
public event OnMakeChildAgentDelegate OnMakeChildAgent;
public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
+ public delegate void OnSaveNewWindlightProfileDelegate();
public event OnMakeRootAgentDelegate OnMakeRootAgent;
+ public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
@@ -411,6 +413,7 @@ namespace OpenSim.Region.Framework.Scenes
private IncomingInstantMessage handlerUnhandledInstantMessage = null; //OnUnhandledInstantMessage;
private ClientClosed handlerClientClosed = null; //OnClientClosed;
private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
+ private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile;
private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent;
private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick;
private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
@@ -772,6 +775,15 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public void TriggerOnSaveNewWindlightProfile()
+ {
+ handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile;
+ if (handlerSaveNewWindlightProfile != null)
+ {
+ handlerSaveNewWindlightProfile();
+ }
+ }
+
public void TriggerOnMakeRootAgent(ScenePresence presence)
{
handlerMakeRootAgent = OnMakeRootAgent;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 8d91d65..475d775 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1505,6 +1505,13 @@ namespace OpenSim.Region.Framework.Scenes
m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
}
+ public void StoreWindlightProfile(RegionMeta7WindlightData wl)
+ {
+ m_regInfo.WindlightSettings = wl;
+ m_storageManager.DataStore.StoreRegionWindlightSettings(wl);
+ m_eventManager.TriggerOnSaveNewWindlightProfile();
+ }
+
///
/// Loads the World heightmap
///
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index e8cda60..5abbb82 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -107,6 +107,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
//Return default LL windlight settings
return new RegionMeta7WindlightData();
}
+ public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl)
+ {
+ //This connector doesn't support the windlight module yet
+ }
public RegionSettings LoadRegionSettings(UUID regionUUID)
{
return null;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7f739b1..33c67d5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -42,6 +42,7 @@ using OpenSim.Region.CoreModules.Avatar.NPC;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
+using OpenSim.Region.CoreModules.World.Meta7Windlight;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
@@ -1974,5 +1975,337 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return ret;
}
+ ///
+ /// Get the current Windlight scene
+ ///
+ /// List of windlight parameters
+ public LSL_List osGetWindlightScene(LSL_List rules)
+ {
+ CheckThreatLevel(ThreatLevel.Low, "osGetWindlightScene");
+ m_host.AddScriptLPS(1);
+ RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
+
+ LSL_List values = new LSL_List();
+ int idx = 0;
+ while (idx < rules.Length)
+ {
+ uint rule = (uint)rules.GetLSLIntegerItem(idx);
+ LSL_List toadd = new LSL_List();
+
+ switch (rule)
+ {
+ case (int)ScriptBaseClass.WL_AMBIENT:
+ toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
+ break;
+ case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
+ toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
+ break;
+ case (int)ScriptBaseClass.WL_BLUE_DENSITY:
+ toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
+ break;
+ case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
+ toadd.Add(new LSL_Float(wl.blurMultiplier));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COLOR:
+ toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
+ toadd.Add(new LSL_Float(wl.cloudCoverage));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
+ toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCALE:
+ toadd.Add(new LSL_Float(wl.cloudScale));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
+ toadd.Add(new LSL_Float(wl.cloudScrollX));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
+ toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
+ toadd.Add(new LSL_Float(wl.cloudScrollY));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
+ toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
+ toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
+ break;
+ case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
+ toadd.Add(new LSL_Float(wl.densityMultiplier));
+ break;
+ case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
+ toadd.Add(new LSL_Float(wl.distanceMultiplier));
+ break;
+ case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
+ toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
+ break;
+ case (int)ScriptBaseClass.WL_EAST_ANGLE:
+ toadd.Add(new LSL_Float(wl.eastAngle));
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
+ toadd.Add(new LSL_Float(wl.fresnelOffset));
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
+ toadd.Add(new LSL_Float(wl.fresnelScale));
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_DENSITY:
+ toadd.Add(new LSL_Float(wl.hazeDensity));
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_HORIZON:
+ toadd.Add(new LSL_Float(wl.hazeHorizon));
+ break;
+ case (int)ScriptBaseClass.WL_HORIZON:
+ toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
+ break;
+ case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
+ toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
+ break;
+ case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
+ toadd.Add(new LSL_Integer(wl.maxAltitude));
+ break;
+ case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
+ toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
+ break;
+ case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
+ toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
+ toadd.Add(new LSL_Float(wl.refractScaleAbove));
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
+ toadd.Add(new LSL_Float(wl.refractScaleBelow));
+ break;
+ case (int)ScriptBaseClass.WL_SCENE_GAMMA:
+ toadd.Add(new LSL_Float(wl.sceneGamma));
+ break;
+ case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
+ toadd.Add(new LSL_Float(wl.starBrightness));
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
+ toadd.Add(new LSL_Float(wl.sunGlowFocus));
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
+ toadd.Add(new LSL_Float(wl.sunGlowSize));
+ break;
+ case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
+ toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
+ break;
+ case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
+ toadd.Add(new LSL_Float(wl.underwaterFogModifier));
+ break;
+ case (int)ScriptBaseClass.WL_WATER_COLOR:
+ toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
+ break;
+ case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
+ toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
+ break;
+ }
+
+ if (toadd.Length > 0)
+ {
+ values.Add(rule);
+ values.Add(toadd.Data[0]);
+ }
+ idx++;
+ }
+
+
+ return values;
+
+ }
+
+ ///
+ /// Set the current Windlight scene
+ ///
+ ///
+ /// success: true or false
+ public int osSetWindlightScene(LSL_List rules)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osSetWindlightScene");
+ int success = 0;
+ m_host.AddScriptLPS(1);
+ if (Meta7WindlightModule.EnableWindlight)
+ {
+ RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
+
+ LSL_List values = new LSL_List();
+ int idx = 0;
+ success = 1;
+ while (idx < rules.Length)
+ {
+ uint rule = (uint)rules.GetLSLIntegerItem(idx);
+ LSL_Types.Quaternion iQ;
+ LSL_Types.Vector3 iV;
+ switch (rule)
+ {
+ case (int)ScriptBaseClass.WL_AMBIENT:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
+ break;
+ case (int)ScriptBaseClass.WL_BLUE_DENSITY:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
+ idx++;
+ wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COLOR:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
+ idx++;
+ wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
+ break;
+ 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);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCALE:
+ idx++;
+ wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
+ idx++;
+ wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
+ idx++;
+ wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
+ idx++;
+ wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
+ idx++;
+ wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ break;
+ case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
+ idx++;
+ wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
+ idx++;
+ wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
+ idx++;
+ wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_EAST_ANGLE:
+ idx++;
+ wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
+ idx++;
+ wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
+ idx++;
+ wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_DENSITY:
+ idx++;
+ wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_HORIZON:
+ idx++;
+ wl.hazeHorizon= (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HORIZON:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
+ break;
+ case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
+ idx++;
+ wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
+ break;
+ case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
+ idx++;
+ wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
+ break;
+ 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);
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
+ idx++;
+ wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
+ idx++;
+ wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SCENE_GAMMA:
+ idx++;
+ wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
+ idx++;
+ wl.starBrightness= (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
+ idx++;
+ wl.sunGlowFocus= (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
+ idx++;
+ wl.sunGlowSize= (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
+ idx++;
+ wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_WATER_COLOR:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ break;
+ case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
+ idx++;
+ wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
+ break;
+ default:
+ success = 0;
+ break;
+ }
+ idx++;
+ }
+ m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
+
+ }
+ return success;
+ }
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 0b0dc00..dd2869b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
// Avatar Info Commands
string osGetAgentIP(string agent);
LSL_List osGetAgents();
-
+
// Teleport commands
void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
@@ -163,5 +163,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
key osGetMapTexture();
key osGetRegionMapTexture(string regionName);
LSL_List osGetRegionStats();
+
+ // Windlight Functions
+ LSL_List osGetWindlightScene(LSL_List rules);
+ int osSetWindlightScene(LSL_List rules);
+
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index acff8fb..4956c28 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -539,5 +539,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int STATS_ACTIVE_SCRIPTS = 19;
public const int STATS_SCRIPT_LPS = 20;
+ // Constants for osWindlight*
+ public const int WL_WATER_COLOR = 0;
+ public const int WL_WATER_FOG_DENSITY_EXPONENT = 1;
+ public const int WL_UNDERWATER_FOG_MODIFIER = 2;
+ public const int WL_REFLECTION_WAVELET_SCALE = 3;
+ public const int WL_FRESNEL_SCALE = 4;
+ public const int WL_FRESNEL_OFFSET = 5;
+ public const int WL_REFRACT_SCALE_ABOVE = 6;
+ public const int WL_REFRACT_SCALE_BELOW = 7;
+ public const int WL_BLUR_MULTIPLIER = 8;
+ public const int WL_BIG_WAVE_DIRECTION = 9;
+ public const int WL_LITTLE_WAVE_DIRECTION = 10;
+ public const int WL_NORMAL_MAP_TEXTURE = 11;
+ public const int WL_HORIZON = 12;
+ public const int WL_HAZE_HORIZON = 13;
+ public const int WL_BLUE_DENSITY = 14;
+ public const int WL_HAZE_DENSITY = 15;
+ public const int WL_DENSITY_MULTIPLIER = 16;
+ public const int WL_DISTANCE_MULTIPLIER = 17;
+ public const int WL_MAX_ALTITUDE = 18;
+ public const int WL_SUN_MOON_COLOR = 19;
+ public const int WL_AMBIENT = 20;
+ public const int WL_EAST_ANGLE = 21;
+ public const int WL_SUN_GLOW_FOCUS = 22;
+ public const int WL_SUN_GLOW_SIZE = 23;
+ public const int WL_SCENE_GAMMA = 24;
+ public const int WL_STAR_BRIGHTNESS = 25;
+ public const int WL_CLOUD_COLOR = 26;
+ public const int WL_CLOUD_XY_DENSITY = 27;
+ public const int WL_CLOUD_COVERAGE = 28;
+ public const int WL_CLOUD_SCALE = 29;
+ public const int WL_CLOUD_DETAIL_XY_DENSITY = 30;
+ public const int WL_CLOUD_SCROLL_X = 31;
+ public const int WL_CLOUD_SCROLL_Y = 32;
+ public const int WL_CLOUD_SCROLL_Y_LOCK = 33;
+ public const int WL_CLOUD_SCROLL_X_LOCK = 34;
+ public const int WL_DRAW_CLASSIC_CLOUDS = 35;
+
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 519463e..1480b8b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -637,5 +637,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRegionStats();
}
+
+ public LSL_List osGetWindlightScene(LSL_List rules)
+ {
+ return m_OSSL_Functions.osGetWindlightScene(rules);
+ }
+
+ public int osSetWindlightScene(LSL_List rules)
+ {
+ return m_OSSL_Functions.osSetWindlightScene(rules);
+ }
}
}
--
cgit v1.1
From d092977f4a933baa990cb239d91c1bec860698e9 Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 9 Dec 2009 01:53:41 +0100
Subject: Windlight configuration option in ini, and migration
---
OpenSim/Data/MySQL/Resources/032_RegionStore.sql | 70 ++++++++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100644 OpenSim/Data/MySQL/Resources/032_RegionStore.sql
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql
new file mode 100644
index 0000000..0545ee1
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql
@@ -0,0 +1,70 @@
+BEGIN;
+
+CREATE TABLE `regionwindlight` (
+ `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000',
+ `water_color_r` float(9,6) unsigned NOT NULL DEFAULT '4.000000',
+ `water_color_g` float(9,6) unsigned NOT NULL DEFAULT '38.000000',
+ `water_color_b` float(9,6) unsigned NOT NULL DEFAULT '64.000000',
+ `water_fog_density_exponent` float(3,1) unsigned NOT NULL DEFAULT '4.0',
+ `underwater_fog_modifier` float(3,2) unsigned NOT NULL DEFAULT '0.25',
+ `reflection_wavelet_scale_1` float(3,1) unsigned NOT NULL DEFAULT '2.0',
+ `reflection_wavelet_scale_2` float(3,1) unsigned NOT NULL DEFAULT '2.0',
+ `reflection_wavelet_scale_3` float(3,1) unsigned NOT NULL DEFAULT '2.0',
+ `fresnel_scale` float(3,2) unsigned NOT NULL DEFAULT '0.40',
+ `fresnel_offset` float(3,2) unsigned NOT NULL DEFAULT '0.50',
+ `refract_scale_above` float(3,2) unsigned NOT NULL DEFAULT '0.03',
+ `refract_scale_below` float(3,2) unsigned NOT NULL DEFAULT '0.20',
+ `blur_multiplier` float(4,3) unsigned NOT NULL DEFAULT '0.040',
+ `big_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.05',
+ `big_wave_direction_y` float(3,2) NOT NULL DEFAULT '-0.42',
+ `little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11',
+ `little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16',
+ `normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4',
+ `horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.26',
+ `horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.24',
+ `horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.33',
+ `horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.33',
+ `haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19',
+ `blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.10',
+ `blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.93',
+ `blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.02',
+ `blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.93',
+ `haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70',
+ `density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18',
+ `distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8',
+ `max_altitude` int(4) unsigned NOT NULL DEFAULT '1605',
+ `sun_moon_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.24',
+ `sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26',
+ `sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30',
+ `sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30',
+ `sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.335',
+ `ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35',
+ `ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35',
+ `ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35',
+ `ambient_i` float(3,2) unsigned NOT NULL DEFAULT '0.35',
+ `east_angle` float(3,2) unsigned NOT NULL DEFAULT '0.00',
+ `sun_glow_focus` float(3,2) unsigned NOT NULL DEFAULT '0.10',
+ `sun_glow_size` float(3,2) unsigned NOT NULL DEFAULT '1.75',
+ `scene_gamma` float(4,2) unsigned NOT NULL DEFAULT '1.00',
+ `star_brightness` float(3,2) unsigned NOT NULL DEFAULT '0.00',
+ `cloud_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.41',
+ `cloud_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.41',
+ `cloud_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.41',
+ `cloud_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.41',
+ `cloud_x` float(3,2) unsigned NOT NULL DEFAULT '1.00',
+ `cloud_y` float(3,2) unsigned NOT NULL DEFAULT '0.53',
+ `cloud_density` float(3,2) unsigned NOT NULL DEFAULT '1.00',
+ `cloud_coverage` float(3,2) unsigned NOT NULL DEFAULT '0.27',
+ `cloud_scale` float(3,2) unsigned NOT NULL DEFAULT '0.42',
+ `cloud_detail_x` float(3,2) unsigned NOT NULL DEFAULT '1.00',
+ `cloud_detail_y` float(3,2) unsigned NOT NULL DEFAULT '0.53',
+ `cloud_detail_density` float(3,2) unsigned NOT NULL DEFAULT '0.12',
+ `cloud_scroll_x` float(3,2) unsigned NOT NULL DEFAULT '0.20',
+ `cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ `cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01',
+ `cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`region_id`)
+);
+
+COMMIT;
\ No newline at end of file
--
cgit v1.1
From 2a6dbd068ef48c7605f44153dcfea6b215749bed Mon Sep 17 00:00:00 2001
From: CasperW
Date: Wed, 9 Dec 2009 03:58:56 +0100
Subject: Last bits and bobs to clean up the Meta7WindlightModule
---
.../World/Meta7Windlight/Meta7WindlightModule.cs | 245 +++++++++++++++++++++
OpenSim/Region/Framework/Scenes/Scene.cs | 8 +-
2 files changed, 252 insertions(+), 1 deletion(-)
create mode 100644 OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
new file mode 100644
index 0000000..f180b47
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) Thomas Grimshaw and Magne Metaverse Research
+ *
+ * This module is not open source. All rights reserved.
+ * Unauthorised copying, distribution or public display is prohibited.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using OpenMetaverse;
+using log4net;
+using Nini.Config;
+using OpenSim.Data;
+using OpenSim.Framework;
+using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+
+
+namespace OpenSim.Region.CoreModules.World.Meta7Windlight
+{
+ public class Meta7WindlightModule : IRegionModule, ICommandableModule
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private readonly Commander m_commander = new Commander("windlight");
+ private Scene m_scene;
+ private static bool m_enableWindlight;
+
+ #region ICommandableModule Members
+
+ public ICommander CommandInterface
+ {
+ get { return m_commander; }
+ }
+
+ #endregion
+
+ #region IRegionModule Members
+
+ public static bool EnableWindlight
+ {
+ get
+ {
+ return m_enableWindlight;
+ }
+ set
+ {
+ }
+ }
+
+ public void Initialise(Scene scene, IConfigSource config)
+ {
+ m_scene = scene;
+ m_scene.RegisterModuleInterface(this);
+ m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
+
+ // ini file settings
+ try
+ {
+ m_enableWindlight = config.Configs["Meta7Windlight"].GetBoolean("enable_windlight", false);
+ }
+ catch (Exception)
+ {
+ m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default");
+ }
+
+ if (m_enableWindlight)
+ {
+ m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent;
+ m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
+ }
+
+ InstallCommands();
+
+ m_log.Debug("[WINDLIGHT]: Initialised windlight module");
+ }
+ public void SendProfileToClient(ScenePresence presence)
+ {
+ if (m_enableWindlight)
+ {
+ if (presence.IsChildAgent == false)
+ {
+ IClientAPI client = presence.ControllingClient;
+ RegionMeta7WindlightData wl = m_scene.RegionInfo.WindlightSettings;
+ byte[] mBlock = new Byte[249];
+ int pos = 0;
+
+ wl.waterColor.ToBytes(mBlock, 0); pos += 12;
+ Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
+ wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
+ Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
+ wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
+ wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
+ wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
+ wl.horizon.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
+ wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
+ wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
+ wl.ambient.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
+ wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
+ wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
+ Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
+ wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
+ Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
+ Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
+ mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
+ mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
+ mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
+ List param = new List();
+ param.Add(mBlock);
+
+ client.SendGenericMessage("Windlight", param);
+ }
+ }
+ else
+ {
+ //We probably don't want to spam chat with this.. probably
+ //m_log.Debug("[WINDLIGHT]: Module disabled");
+ }
+ }
+ private void EventManager_OnMakeRootAgent(ScenePresence presence)
+ {
+ m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
+ SendProfileToClient(presence);
+ }
+
+ private void EventManager_OnSaveNewWindlightProfile()
+ {
+ m_scene.ForEachScenePresence(SendProfileToClient);
+ }
+
+ public void PostInitialise()
+ {
+
+ }
+
+ public void Close()
+ {
+ }
+
+ public string Name
+ {
+ get { return "Meta7WindlightModule"; }
+ }
+
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+
+ #endregion
+
+ #region events
+
+ #endregion
+
+ #region ICommandableModule Members
+
+ private void InstallCommands()
+ {
+ Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast");
+ Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin");
+ Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin");
+
+ m_commander.RegisterCommand("load", wlload);
+ m_commander.RegisterCommand("enable", wlenable);
+ m_commander.RegisterCommand("disable", wldisable);
+
+ m_scene.RegisterModuleCommander(m_commander);
+ }
+
+ private void HandleLoad(Object[] args)
+ {
+ if (!m_enableWindlight)
+ {
+ m_log.InfoFormat("[WINDLIGHT]: Cannot load windlight profile, module disabled. Use 'windlight enable' first.");
+ }
+ else
+ {
+ m_log.InfoFormat("[WINDLIGHT]: Loading Windlight profile from database");
+ m_scene.LoadWindlightProfile();
+ m_log.InfoFormat("[WINDLIGHT]: Load complete");
+ }
+ }
+
+ private void HandleDisable(Object[] args)
+ {
+ m_log.InfoFormat("[WINDLIGHT]: Plugin now disabled");
+ m_enableWindlight=false;
+ }
+
+ private void HandleEnable(Object[] args)
+ {
+ m_log.InfoFormat("[WINDLIGHT]: Plugin now enabled");
+ m_enableWindlight = true;
+ }
+
+ ///
+ /// Processes commandline input. Do not call directly.
+ ///
+ /// Commandline arguments
+ private void EventManager_OnPluginConsole(string[] args)
+ {
+ if (args[0] == "windlight")
+ {
+ if (args.Length == 1)
+ {
+ m_commander.ProcessConsoleCommand("add", new string[0]);
+ return;
+ }
+
+ string[] tmpArgs = new string[args.Length - 2];
+ int i;
+ for (i = 2; i < args.Length; i++)
+ {
+ tmpArgs[i - 2] = args[i];
+ }
+
+ m_commander.ProcessConsoleCommand(args[1], tmpArgs);
+ }
+ }
+ #endregion
+
+ }
+}
+
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 475d775..1b275b0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1504,7 +1504,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
}
-
+
public void StoreWindlightProfile(RegionMeta7WindlightData wl)
{
m_regInfo.WindlightSettings = wl;
@@ -1512,6 +1512,12 @@ namespace OpenSim.Region.Framework.Scenes
m_eventManager.TriggerOnSaveNewWindlightProfile();
}
+ public void LoadWindlightProfile()
+ {
+ m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(RegionInfo.RegionID);
+ m_eventManager.TriggerOnSaveNewWindlightProfile();
+ }
+
///
/// Loads the World heightmap
///
--
cgit v1.1
From a6a6bf007a2fb0e33daefc0ea7c4ad968a85d08e Mon Sep 17 00:00:00 2001
From: CasperW
Date: Wed, 9 Dec 2009 22:57:35 +0100
Subject: Move osFunctions into a new Careminster script interface
---
.../Shared/Api/Implementation/CM_Api.cs | 430 +++++++++++++++++++++
.../Shared/Api/Implementation/OSSL_Api.cs | 334 ----------------
.../ScriptEngine/Shared/Api/Interface/ICM_Api.cs | 20 +
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 5 -
.../Shared/Api/Runtime/CM_Constants.cs | 76 ++++
.../ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | 71 ++++
.../Shared/Api/Runtime/LSL_Constants.cs | 38 --
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 -
8 files changed, 597 insertions(+), 387 deletions(-)
create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..4cc2f0a
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,430 @@
+using System;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.Remoting.Lifetime;
+using OpenMetaverse;
+using Nini.Config;
+using OpenSim;
+using OpenSim.Framework;
+using OpenSim.Region.CoreModules.World.Meta7Windlight;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.ScriptEngine.Shared;
+using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
+using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
+using OpenSim.Region.ScriptEngine.Interfaces;
+using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
+
+using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
+using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
+using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
+using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
+using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
+using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
+using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
+
+namespace OpenSim.Region.ScriptEngine.Shared.Api
+{
+ [Serializable]
+ public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
+ {
+ internal IScriptEngine m_ScriptEngine;
+ internal SceneObjectPart m_host;
+ internal uint m_localID;
+ internal UUID m_itemID;
+ internal bool m_CMFunctionsEnabled = false;
+ internal IScriptModuleComms m_comms = null;
+
+ public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
+ {
+ m_ScriptEngine = ScriptEngine;
+ m_host = host;
+ m_localID = localID;
+ m_itemID = itemID;
+
+ if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
+ m_CMFunctionsEnabled = true;
+
+ m_comms = m_ScriptEngine.World.RequestModuleInterface();
+ if (m_comms == null)
+ m_CMFunctionsEnabled = false;
+ }
+
+ public override Object InitializeLifetimeService()
+ {
+ ILease lease = (ILease)base.InitializeLifetimeService();
+
+ if (lease.CurrentState == LeaseState.Initial)
+ {
+ lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
+ // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
+ // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
+ }
+ return lease;
+ }
+
+ public Scene World
+ {
+ get { return m_ScriptEngine.World; }
+ }
+
+ //
+ //Dumps an error message on the debug console.
+ //
+
+ internal void CMShoutError(string message)
+ {
+ if (message.Length > 1023)
+ message = message.Substring(0, 1023);
+
+ World.SimChat(Utils.StringToBytes(message),
+ ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
+
+ IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
+ wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
+ }
+
+ ///
+ /// Get the current Windlight scene
+ ///
+ /// List of windlight parameters
+ public LSL_List cmGetWindlightScene(LSL_List rules)
+ {
+ if (!m_CMFunctionsEnabled)
+ {
+ CMShoutError("Careminster functions are not enabled.");
+ return new LSL_List();
+ }
+ m_host.AddScriptLPS(1);
+ RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
+
+ LSL_List values = new LSL_List();
+ int idx = 0;
+ while (idx < rules.Length)
+ {
+ uint rule = (uint)rules.GetLSLIntegerItem(idx);
+ LSL_List toadd = new LSL_List();
+
+ switch (rule)
+ {
+ case (int)ScriptBaseClass.WL_AMBIENT:
+ toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
+ break;
+ case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
+ toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
+ break;
+ case (int)ScriptBaseClass.WL_BLUE_DENSITY:
+ toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
+ break;
+ case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
+ toadd.Add(new LSL_Float(wl.blurMultiplier));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COLOR:
+ toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
+ toadd.Add(new LSL_Float(wl.cloudCoverage));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
+ toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCALE:
+ toadd.Add(new LSL_Float(wl.cloudScale));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
+ toadd.Add(new LSL_Float(wl.cloudScrollX));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
+ toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
+ toadd.Add(new LSL_Float(wl.cloudScrollY));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
+ toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
+ toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
+ break;
+ case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
+ toadd.Add(new LSL_Float(wl.densityMultiplier));
+ break;
+ case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
+ toadd.Add(new LSL_Float(wl.distanceMultiplier));
+ break;
+ case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
+ toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
+ break;
+ case (int)ScriptBaseClass.WL_EAST_ANGLE:
+ toadd.Add(new LSL_Float(wl.eastAngle));
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
+ toadd.Add(new LSL_Float(wl.fresnelOffset));
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
+ toadd.Add(new LSL_Float(wl.fresnelScale));
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_DENSITY:
+ toadd.Add(new LSL_Float(wl.hazeDensity));
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_HORIZON:
+ toadd.Add(new LSL_Float(wl.hazeHorizon));
+ break;
+ case (int)ScriptBaseClass.WL_HORIZON:
+ toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
+ break;
+ case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
+ toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
+ break;
+ case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
+ toadd.Add(new LSL_Integer(wl.maxAltitude));
+ break;
+ case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
+ toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
+ break;
+ case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
+ toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
+ toadd.Add(new LSL_Float(wl.refractScaleAbove));
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
+ toadd.Add(new LSL_Float(wl.refractScaleBelow));
+ break;
+ case (int)ScriptBaseClass.WL_SCENE_GAMMA:
+ toadd.Add(new LSL_Float(wl.sceneGamma));
+ break;
+ case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
+ toadd.Add(new LSL_Float(wl.starBrightness));
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
+ toadd.Add(new LSL_Float(wl.sunGlowFocus));
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
+ toadd.Add(new LSL_Float(wl.sunGlowSize));
+ break;
+ case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
+ toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
+ break;
+ case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
+ toadd.Add(new LSL_Float(wl.underwaterFogModifier));
+ break;
+ case (int)ScriptBaseClass.WL_WATER_COLOR:
+ toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
+ break;
+ case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
+ toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
+ break;
+ }
+
+ if (toadd.Length > 0)
+ {
+ values.Add(rule);
+ values.Add(toadd.Data[0]);
+ }
+ idx++;
+ }
+
+
+ return values;
+
+ }
+
+ ///
+ /// Set the current Windlight scene
+ ///
+ ///
+ /// success: true or false
+ public int cmSetWindlightScene(LSL_List rules)
+ {
+ if (!m_CMFunctionsEnabled)
+ {
+ CMShoutError("Careminster functions are not enabled.");
+ return 0;
+ }
+ int success = 0;
+ m_host.AddScriptLPS(1);
+ if (Meta7WindlightModule.EnableWindlight)
+ {
+ RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
+
+ LSL_List values = new LSL_List();
+ int idx = 0;
+ success = 1;
+ while (idx < rules.Length)
+ {
+ uint rule = (uint)rules.GetLSLIntegerItem(idx);
+ LSL_Types.Quaternion iQ;
+ LSL_Types.Vector3 iV;
+ switch (rule)
+ {
+ case (int)ScriptBaseClass.WL_AMBIENT:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
+ break;
+ case (int)ScriptBaseClass.WL_BLUE_DENSITY:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
+ idx++;
+ wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COLOR:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
+ idx++;
+ wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
+ break;
+ 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);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCALE:
+ idx++;
+ wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
+ idx++;
+ wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
+ idx++;
+ wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
+ idx++;
+ wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
+ idx++;
+ wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ break;
+ case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
+ idx++;
+ wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
+ idx++;
+ wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
+ idx++;
+ wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_EAST_ANGLE:
+ idx++;
+ wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
+ idx++;
+ wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
+ idx++;
+ wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_DENSITY:
+ idx++;
+ wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_HORIZON:
+ idx++;
+ wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HORIZON:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
+ break;
+ case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
+ idx++;
+ wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
+ break;
+ case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
+ idx++;
+ wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
+ break;
+ 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);
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
+ idx++;
+ wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
+ idx++;
+ wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SCENE_GAMMA:
+ idx++;
+ wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
+ idx++;
+ wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
+ idx++;
+ wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
+ idx++;
+ wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
+ idx++;
+ wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_WATER_COLOR:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ break;
+ case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
+ idx++;
+ wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
+ break;
+ default:
+ success = 0;
+ break;
+ }
+ idx++;
+ }
+ m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
+
+ }
+ return success;
+ }
+
+ }
+}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 33c67d5..836f276 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -42,7 +42,6 @@ using OpenSim.Region.CoreModules.Avatar.NPC;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
-using OpenSim.Region.CoreModules.World.Meta7Windlight;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
@@ -1974,338 +1973,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
return ret;
}
-
- ///
- /// Get the current Windlight scene
- ///
- /// List of windlight parameters
- public LSL_List osGetWindlightScene(LSL_List rules)
- {
- CheckThreatLevel(ThreatLevel.Low, "osGetWindlightScene");
- m_host.AddScriptLPS(1);
- RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
-
- LSL_List values = new LSL_List();
- int idx = 0;
- while (idx < rules.Length)
- {
- uint rule = (uint)rules.GetLSLIntegerItem(idx);
- LSL_List toadd = new LSL_List();
-
- switch (rule)
- {
- case (int)ScriptBaseClass.WL_AMBIENT:
- toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
- break;
- case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
- toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
- break;
- case (int)ScriptBaseClass.WL_BLUE_DENSITY:
- toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
- break;
- case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
- toadd.Add(new LSL_Float(wl.blurMultiplier));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_COLOR:
- toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
- toadd.Add(new LSL_Float(wl.cloudCoverage));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
- toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCALE:
- toadd.Add(new LSL_Float(wl.cloudScale));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
- toadd.Add(new LSL_Float(wl.cloudScrollX));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
- toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
- toadd.Add(new LSL_Float(wl.cloudScrollY));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
- toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
- break;
- case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
- toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
- break;
- case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
- toadd.Add(new LSL_Float(wl.densityMultiplier));
- break;
- case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
- toadd.Add(new LSL_Float(wl.distanceMultiplier));
- break;
- case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
- toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
- break;
- case (int)ScriptBaseClass.WL_EAST_ANGLE:
- toadd.Add(new LSL_Float(wl.eastAngle));
- break;
- case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
- toadd.Add(new LSL_Float(wl.fresnelOffset));
- break;
- case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
- toadd.Add(new LSL_Float(wl.fresnelScale));
- break;
- case (int)ScriptBaseClass.WL_HAZE_DENSITY:
- toadd.Add(new LSL_Float(wl.hazeDensity));
- break;
- case (int)ScriptBaseClass.WL_HAZE_HORIZON:
- toadd.Add(new LSL_Float(wl.hazeHorizon));
- break;
- case (int)ScriptBaseClass.WL_HORIZON:
- toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
- break;
- case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
- toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
- break;
- case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
- toadd.Add(new LSL_Integer(wl.maxAltitude));
- break;
- case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
- toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
- break;
- case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
- toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
- break;
- case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
- toadd.Add(new LSL_Float(wl.refractScaleAbove));
- break;
- case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
- toadd.Add(new LSL_Float(wl.refractScaleBelow));
- break;
- case (int)ScriptBaseClass.WL_SCENE_GAMMA:
- toadd.Add(new LSL_Float(wl.sceneGamma));
- break;
- case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
- toadd.Add(new LSL_Float(wl.starBrightness));
- break;
- case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
- toadd.Add(new LSL_Float(wl.sunGlowFocus));
- break;
- case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
- toadd.Add(new LSL_Float(wl.sunGlowSize));
- break;
- case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
- toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
- break;
- case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
- toadd.Add(new LSL_Float(wl.underwaterFogModifier));
- break;
- case (int)ScriptBaseClass.WL_WATER_COLOR:
- toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
- break;
- case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
- toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
- break;
- }
-
- if (toadd.Length > 0)
- {
- values.Add(rule);
- values.Add(toadd.Data[0]);
- }
- idx++;
- }
-
-
- return values;
-
- }
-
- ///
- /// Set the current Windlight scene
- ///
- ///
- /// success: true or false
- public int osSetWindlightScene(LSL_List rules)
- {
- CheckThreatLevel(ThreatLevel.High, "osSetWindlightScene");
- int success = 0;
- m_host.AddScriptLPS(1);
- if (Meta7WindlightModule.EnableWindlight)
- {
- RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
-
- LSL_List values = new LSL_List();
- int idx = 0;
- success = 1;
- while (idx < rules.Length)
- {
- uint rule = (uint)rules.GetLSLIntegerItem(idx);
- LSL_Types.Quaternion iQ;
- LSL_Types.Vector3 iV;
- switch (rule)
- {
- case (int)ScriptBaseClass.WL_AMBIENT:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
- break;
- case (int)ScriptBaseClass.WL_BLUE_DENSITY:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
- idx++;
- wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_COLOR:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
- idx++;
- wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
- break;
- 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);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCALE:
- idx++;
- wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
- idx++;
- wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
- idx++;
- wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
- idx++;
- wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
- idx++;
- wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
- break;
- case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
- break;
- case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
- idx++;
- wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
- idx++;
- wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
- idx++;
- wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
- break;
- case (int)ScriptBaseClass.WL_EAST_ANGLE:
- idx++;
- wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
- idx++;
- wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
- idx++;
- wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_HAZE_DENSITY:
- idx++;
- wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_HAZE_HORIZON:
- idx++;
- wl.hazeHorizon= (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_HORIZON:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
- break;
- case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
- idx++;
- wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
- break;
- case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
- idx++;
- wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
- break;
- 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);
- break;
- case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
- idx++;
- wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
- idx++;
- wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SCENE_GAMMA:
- idx++;
- wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
- idx++;
- wl.starBrightness= (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
- idx++;
- wl.sunGlowFocus= (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
- idx++;
- wl.sunGlowSize= (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
- idx++;
- wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_WATER_COLOR:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
- break;
- case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
- idx++;
- wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
- break;
- default:
- success = 0;
- break;
- }
- idx++;
- }
- m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
-
- }
- return success;
- }
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
new file mode 100644
index 0000000..9dd0b73
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -0,0 +1,20 @@
+using System.Collections;
+using OpenSim.Region.ScriptEngine.Interfaces;
+
+using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
+using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
+using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
+using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
+using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
+using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
+using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
+
+namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
+{
+ public interface ICM_Api
+ {
+ // Windlight Functions
+ LSL_List cmGetWindlightScene(LSL_List rules);
+ int cmSetWindlightScene(LSL_List rules);
+ }
+}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index dd2869b..c3bf7d2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -163,10 +163,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
key osGetMapTexture();
key osGetRegionMapTexture(string regionName);
LSL_List osGetRegionStats();
-
- // Windlight Functions
- LSL_List osGetWindlightScene(LSL_List rules);
- int osSetWindlightScene(LSL_List rules);
-
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
new file mode 100644
index 0000000..7b67fa3
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
@@ -0,0 +1,76 @@
+/*
+ * 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 vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
+using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
+using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
+
+namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
+{
+ public partial class ScriptBaseClass
+ {
+ // Constants for cmWindlight*
+ public const int WL_WATER_COLOR = 0;
+ public const int WL_WATER_FOG_DENSITY_EXPONENT = 1;
+ public const int WL_UNDERWATER_FOG_MODIFIER = 2;
+ public const int WL_REFLECTION_WAVELET_SCALE = 3;
+ public const int WL_FRESNEL_SCALE = 4;
+ public const int WL_FRESNEL_OFFSET = 5;
+ public const int WL_REFRACT_SCALE_ABOVE = 6;
+ public const int WL_REFRACT_SCALE_BELOW = 7;
+ public const int WL_BLUR_MULTIPLIER = 8;
+ public const int WL_BIG_WAVE_DIRECTION = 9;
+ public const int WL_LITTLE_WAVE_DIRECTION = 10;
+ public const int WL_NORMAL_MAP_TEXTURE = 11;
+ public const int WL_HORIZON = 12;
+ public const int WL_HAZE_HORIZON = 13;
+ public const int WL_BLUE_DENSITY = 14;
+ public const int WL_HAZE_DENSITY = 15;
+ public const int WL_DENSITY_MULTIPLIER = 16;
+ public const int WL_DISTANCE_MULTIPLIER = 17;
+ public const int WL_MAX_ALTITUDE = 18;
+ public const int WL_SUN_MOON_COLOR = 19;
+ public const int WL_AMBIENT = 20;
+ public const int WL_EAST_ANGLE = 21;
+ public const int WL_SUN_GLOW_FOCUS = 22;
+ public const int WL_SUN_GLOW_SIZE = 23;
+ public const int WL_SCENE_GAMMA = 24;
+ public const int WL_STAR_BRIGHTNESS = 25;
+ public const int WL_CLOUD_COLOR = 26;
+ public const int WL_CLOUD_XY_DENSITY = 27;
+ public const int WL_CLOUD_COVERAGE = 28;
+ public const int WL_CLOUD_SCALE = 29;
+ public const int WL_CLOUD_DETAIL_XY_DENSITY = 30;
+ public const int WL_CLOUD_SCROLL_X = 31;
+ public const int WL_CLOUD_SCROLL_Y = 32;
+ public const int WL_CLOUD_SCROLL_Y_LOCK = 33;
+ public const int WL_CLOUD_SCROLL_X_LOCK = 34;
+ public const int WL_DRAW_CLASSIC_CLOUDS = 35;
+
+ }
+}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
new file mode 100644
index 0000000..e85d41e
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -0,0 +1,71 @@
+/*
+ * 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.Runtime.Remoting.Lifetime;
+using System.Threading;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.ScriptEngine.Interfaces;
+using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
+using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
+using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
+using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
+using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
+using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
+using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
+using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
+using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
+
+namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
+{
+ public partial class ScriptBaseClass : MarshalByRefObject
+ {
+ public ICM_Api m_CM_Functions;
+
+ public void ApiTypeCM(IScriptApi api)
+ {
+ if (!(api is ICM_Api))
+ return;
+
+ m_CM_Functions = (ICM_Api)api;
+ }
+
+ public LSL_List cmGetWindlightScene(LSL_List rules)
+ {
+ return m_CM_Functions.cmGetWindlightScene(rules);
+ }
+
+ public int cmSetWindlightScene(LSL_List rules)
+ {
+ return m_CM_Functions.cmSetWindlightScene(rules);
+ }
+ }
+}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 4956c28..acff8fb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -539,43 +539,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int STATS_ACTIVE_SCRIPTS = 19;
public const int STATS_SCRIPT_LPS = 20;
- // Constants for osWindlight*
- public const int WL_WATER_COLOR = 0;
- public const int WL_WATER_FOG_DENSITY_EXPONENT = 1;
- public const int WL_UNDERWATER_FOG_MODIFIER = 2;
- public const int WL_REFLECTION_WAVELET_SCALE = 3;
- public const int WL_FRESNEL_SCALE = 4;
- public const int WL_FRESNEL_OFFSET = 5;
- public const int WL_REFRACT_SCALE_ABOVE = 6;
- public const int WL_REFRACT_SCALE_BELOW = 7;
- public const int WL_BLUR_MULTIPLIER = 8;
- public const int WL_BIG_WAVE_DIRECTION = 9;
- public const int WL_LITTLE_WAVE_DIRECTION = 10;
- public const int WL_NORMAL_MAP_TEXTURE = 11;
- public const int WL_HORIZON = 12;
- public const int WL_HAZE_HORIZON = 13;
- public const int WL_BLUE_DENSITY = 14;
- public const int WL_HAZE_DENSITY = 15;
- public const int WL_DENSITY_MULTIPLIER = 16;
- public const int WL_DISTANCE_MULTIPLIER = 17;
- public const int WL_MAX_ALTITUDE = 18;
- public const int WL_SUN_MOON_COLOR = 19;
- public const int WL_AMBIENT = 20;
- public const int WL_EAST_ANGLE = 21;
- public const int WL_SUN_GLOW_FOCUS = 22;
- public const int WL_SUN_GLOW_SIZE = 23;
- public const int WL_SCENE_GAMMA = 24;
- public const int WL_STAR_BRIGHTNESS = 25;
- public const int WL_CLOUD_COLOR = 26;
- public const int WL_CLOUD_XY_DENSITY = 27;
- public const int WL_CLOUD_COVERAGE = 28;
- public const int WL_CLOUD_SCALE = 29;
- public const int WL_CLOUD_DETAIL_XY_DENSITY = 30;
- public const int WL_CLOUD_SCROLL_X = 31;
- public const int WL_CLOUD_SCROLL_Y = 32;
- public const int WL_CLOUD_SCROLL_Y_LOCK = 33;
- public const int WL_CLOUD_SCROLL_X_LOCK = 34;
- public const int WL_DRAW_CLASSIC_CLOUDS = 35;
-
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 1480b8b..519463e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -637,15 +637,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRegionStats();
}
-
- public LSL_List osGetWindlightScene(LSL_List rules)
- {
- return m_OSSL_Functions.osGetWindlightScene(rules);
- }
-
- public int osSetWindlightScene(LSL_List rules)
- {
- return m_OSSL_Functions.osSetWindlightScene(rules);
- }
}
}
--
cgit v1.1
From 0889b5aef1b93909cb7ae5c29beb5e23bd566c47 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 10 Dec 2009 18:20:40 +0000
Subject: Fix version number
---
OpenSim/Framework/Servers/VersionInfo.cs | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index f5be1e6..d348c90 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,8 +29,8 @@ namespace OpenSim
{
public class VersionInfo
{
- private const string VERSION_NUMBER = "112609s";
- private const Flavour VERSION_FLAVOUR = Flavour.BetaM7;
+ private const string VERSION_NUMBER = "0.6.9CM";
+ private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
{
Unknown,
@@ -38,8 +38,7 @@ namespace OpenSim
RC1,
RC2,
Release,
- Post_Fixes,
- BetaM7
+ Post_Fixes
}
public static string Version
--
cgit v1.1
From 5ffd59e7b870acb74ad7c6be4a1f49b62b013f21 Mon Sep 17 00:00:00 2001
From: grid
Date: Thu, 10 Dec 2009 22:09:16 -0500
Subject: Kill a NRE caused by an error message trying to print unavailable
data
---
OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
index e2a5406..17977f1 100644
--- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
@@ -480,8 +480,8 @@ namespace OpenSim.Data.MySQL
else
{
m_log.WarnFormat(
- "[REGION DB]: Database contains an orphan child prim {0} {1} at {2} in region {3} pointing to missing parent {4}. This prim will not be loaded.",
- prim.Name, prim.UUID, prim.AbsolutePosition, regionID, prim.ParentUUID);
+ "[REGION DB]: Database contains an orphan child prim {0} {1} in region {3} pointing to missing parent {4}. This prim will not be loaded.",
+ prim.Name, prim.UUID, regionID, prim.ParentUUID);
}
}
}
--
cgit v1.1
From f6b1344722908f0d14d6e30c4b01b2f712c584f2 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 11 Dec 2009 02:40:33 +0000
Subject: Refix the fix
---
OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
index 17977f1..e57e929 100644
--- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
@@ -480,7 +480,7 @@ namespace OpenSim.Data.MySQL
else
{
m_log.WarnFormat(
- "[REGION DB]: Database contains an orphan child prim {0} {1} in region {3} pointing to missing parent {4}. This prim will not be loaded.",
+ "[REGION DB]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.",
prim.Name, prim.UUID, regionID, prim.ParentUUID);
}
}
--
cgit v1.1
From b9cd66d510f9229952aec5594d512faf7b60c899 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 12 Dec 2009 13:33:45 +0000
Subject: test commit
---
OpenSim/Framework/Servers/VersionInfo.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index d348c90..75e4a5d 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,6 +29,7 @@ namespace OpenSim
{
public class VersionInfo
{
+
private const string VERSION_NUMBER = "0.6.9CM";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
--
cgit v1.1
From fbafd2212402619ec5efa66797fd42d59da1333b Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 12 Dec 2009 13:43:49 +0000
Subject: Reverse text commit whitespace change
---
OpenSim/Framework/Servers/VersionInfo.cs | 1 -
1 file changed, 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 75e4a5d..d348c90 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,7 +29,6 @@ namespace OpenSim
{
public class VersionInfo
{
-
private const string VERSION_NUMBER = "0.6.9CM";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
--
cgit v1.1
From 794419852b793cd0be96bafb945305fadbb95b6c Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 12 Dec 2009 14:23:20 +0000
Subject: Another test
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index d348c90..714a592 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
namespace OpenSim
{
public class VersionInfo
--
cgit v1.1
From c00158b238c863d27f1b883f2cd4e573f7036dda Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 12 Dec 2009 14:35:12 +0000
Subject: Reverse test commit (again)
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 714a592..d348c90 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
namespace OpenSim
{
public class VersionInfo
--
cgit v1.1
From b056c243e46daa3370f8d330b70a37b5f856e9ec Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Sat, 12 Dec 2009 10:12:59 -0500
Subject: Commit partial work because of repo change
---
OpenSim/Data/SQLite/SQLiteRegionData.cs | 2 +-
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 83 ++++++++++++++++++++----
2 files changed, 73 insertions(+), 12 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index f1c1f78..83fd775 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -329,7 +329,7 @@ namespace OpenSim.Data.SQLite
{
foreach (SceneObjectPart prim in obj.Children.Values)
{
- m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
+// m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
addPrim(prim, obj.UUID, regionUUID);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index c553ca0..d0c20ff 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1660,16 +1660,27 @@ namespace OpenSim.Region.Framework.Scenes
}
// part.GetWorldRotation() is the rotation of the object being sat on
// Rotation is the sittiing Av's rotation
-
- Quaternion wr = Quaternion.Inverse(Quaternion.Inverse(Rotation) * Quaternion.Inverse(part.GetWorldRotation())); // world or. of the av
- Vector3 so = new Vector3(1.0f, 0f, 0f) * wr; // 1M infront of av
- Vector3 wso = so + part.GetWorldPosition() + ( m_pos * part.GetWorldRotation()); // + av sit offset!
+
+ Quaternion partRot;
+ if (part.LinkNum == 1)
+ { // Root prim of linkset
+ partRot = part.ParentGroup.RootPart.RotationOffset;
+ }
+ else
+ { // single or child prim
+ partRot = part.GetWorldRotation();
+ }
+ Quaternion partIRot = Quaternion.Inverse(partRot);
+
+ Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av
+ Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av
+ Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ( m_pos * partRot); // + av sit offset!
if (m_physicsActor == null)
{
AddToPhysicalScene(false);
}
- AbsolutePosition = wso; //KF: Fix stand up.
+ AbsolutePosition = avWorldStandUp; //KF: Fix stand up.
m_parentPosition = Vector3.Zero;
m_parentID = 0;
part.IsOccupied = false;
@@ -1752,8 +1763,17 @@ namespace OpenSim.Region.Framework.Scenes
Quaternion avSitOrientation = part.SitTargetOrientation;
bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored.
- Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
-
+ // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ Quaternion partRot;
+ if (part.LinkNum == 1)
+ { // Root prim of linkset
+ partRot = part.ParentGroup.RootPart.RotationOffset;
+ }
+ else
+ { // single or child prim
+ partRot = part.GetWorldRotation();
+ }
+ Quaternion partIRot = Quaternion.Inverse(partRot);
//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet);
// Sit analysis rewritten by KF 091125
if (SitTargetisSet) // scipted sit
@@ -1800,6 +1820,8 @@ namespace OpenSim.Region.Framework.Scenes
cameraAtOffset = part.GetCameraAtOffset();
cameraEyeOffset = part.GetCameraEyeOffset();
forceMouselook = part.GetForceMouselook();
+ if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); //
+ if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); //
if (m_physicsActor != null)
{
@@ -1823,7 +1845,29 @@ namespace OpenSim.Region.Framework.Scenes
}
else return; // physactor is null!
- Vector3 offsetr = offset * partIRot;
+ Vector3 offsetr; // = offset * partIRot;
+ // KF: In a linkset, offsetr needs to be relative to the group root! 091208
+ // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot);
+ if (part.LinkNum < 2)
+ { // Single, or Root prim of linkset, target is ClickOffset * RootRot
+ offsetr = offset * partIRot;
+ }
+ else
+ { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot)
+ offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) +
+ (offset * partRot);
+ }
+
+Console.WriteLine(" ");
+Console.WriteLine("link number ={0}", part.LinkNum);
+Console.WriteLine("Prim offset ={0}", part.OffsetPosition );
+Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset);
+Console.WriteLine("Click offst ={0}", offset);
+Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation());
+Console.WriteLine("offsetr ={0}", offsetr);
+Console.WriteLine("Camera At ={0}", cameraAtOffset);
+Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
+
ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook);
m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target
// This calls HandleAgentSit twice, once from here, and the client calls
@@ -2142,13 +2186,20 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
-//Console.WriteLine("NON Scripted Sit");
// if m_avUnscriptedSitPos is zero then Av sits above center
// Else Av sits at m_avUnscriptedSitPos
// Non-scripted sit by Kitto Flora 21Nov09
// Calculate angle of line from prim to Av
- Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ Quaternion partIRot;
+ if (part.LinkNum == 1)
+ { // Root prim of linkset
+ partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset);
+ }
+ else
+ { // single or child prim
+ partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ }
Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos;
float y_diff = (m_avInitialPos.Y - sitTargetPos.Y);
float x_diff = ( m_avInitialPos.X - sitTargetPos.X);
@@ -2203,11 +2254,21 @@ namespace OpenSim.Region.Framework.Scenes
// collisionPoint = spot on prim where we want to sit
// collisionPoint.Z = global sit surface height
SceneObjectPart part = m_scene.GetSceneObjectPart(localid);
- Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ Quaternion partIRot;
+ if (part.LinkNum == 1)
+ { // Root prim of linkset
+ partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset);
+ }
+ else
+ { // single or child prim
+ partIRot = Quaternion.Inverse(part.GetWorldRotation());
+ }
float offZ = collisionPoint.Z - m_initialSitTarget.Z;
Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction
//Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset);
m_pos += offset;
+ ControllingClient.SendClearFollowCamProperties(part.UUID);
+
}
} // End SitAltitudeCallback KF.
--
cgit v1.1
From 9904700dfdb7c6a111d9464eb23566fff73dc6b1 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 12 Dec 2009 16:00:44 +0000
Subject: Another whitespace test commit
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index d348c90..714a592 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
namespace OpenSim
{
public class VersionInfo
--
cgit v1.1
From 30d64444a090148e5c07f27adc19ac2925533a19 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 12 Dec 2009 16:01:53 +0000
Subject: And reverse
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 714a592..d348c90 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
namespace OpenSim
{
public class VersionInfo
--
cgit v1.1
From b8b4517211d332f76c022075f81cfefd41877d14 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Tue, 15 Dec 2009 01:49:23 -0500
Subject: Removed excessive call to UpdateMovementAnimations which prevented
GroundSit; Corrected cause of 'sit on roof'.
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 48 ++++++++++++------------
1 file changed, 23 insertions(+), 25 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index d0c20ff..c67463a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -670,8 +670,7 @@ namespace OpenSim.Region.Framework.Scenes
AdjustKnownSeeds();
-
- Animator.TrySetMovementAnimation("STAND");
+ Animator.TrySetMovementAnimation("STAND");
// we created a new ScenePresence (a new child agent) in a fresh region.
// Request info about all the (root) agents in this region
// Note: This won't send data *to* other clients in that region (children don't send)
@@ -1691,7 +1690,6 @@ namespace OpenSim.Region.Framework.Scenes
SetHeight(m_avHeight);
}
}
-
Animator.TrySetMovementAnimation("STAND");
}
@@ -1858,15 +1856,15 @@ namespace OpenSim.Region.Framework.Scenes
(offset * partRot);
}
-Console.WriteLine(" ");
-Console.WriteLine("link number ={0}", part.LinkNum);
-Console.WriteLine("Prim offset ={0}", part.OffsetPosition );
-Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset);
-Console.WriteLine("Click offst ={0}", offset);
-Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation());
-Console.WriteLine("offsetr ={0}", offsetr);
-Console.WriteLine("Camera At ={0}", cameraAtOffset);
-Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
+//Console.WriteLine(" ");
+//Console.WriteLine("link number ={0}", part.LinkNum);
+//Console.WriteLine("Prim offset ={0}", part.OffsetPosition );
+//Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset);
+//Console.WriteLine("Click offst ={0}", offset);
+//Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation());
+//Console.WriteLine("offsetr ={0}", offsetr);
+//Console.WriteLine("Camera At ={0}", cameraAtOffset);
+//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook);
m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target
@@ -2218,7 +2216,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
m_avUnscriptedSitPos; // adds click offset, if any
//Set up raytrace to find top surface of prim
Vector3 size = part.Scale;
- float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
+ float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
Vector3 down = new Vector3(0f, 0f, -1f);
//Console.WriteLine("st={0} do={1} ma={2}", start, down, mag);
@@ -2267,7 +2265,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction
//Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset);
m_pos += offset;
- ControllingClient.SendClearFollowCamProperties(part.UUID);
+// ControllingClient.SendClearFollowCamProperties(part.UUID);
}
} // End SitAltitudeCallback KF.
@@ -3297,7 +3295,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
m_updateflag = true;
Velocity = force;
m_isNudging = false;
- m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND"
+ m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND"
}
}
}
@@ -3349,19 +3347,19 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
// Event called by the physics plugin to tell the avatar about a collision.
private void PhysicsCollisionUpdate(EventArgs e)
{
- if (m_updateCount > 0) //KF: Update Anims for a short period. Many Anim
- { // changes are very asynchronous.
- Animator.UpdateMovementAnimations();
- m_updateCount--;
- }
-
if (e == null)
return;
-
- // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents(
+
+ // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents(
// as of this comment the interval is set in AddToPhysicalScene
if (Animator!=null)
- Animator.UpdateMovementAnimations();
+ {
+ if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper,
+ { // else its will lock out other animation changes, like ground sit.
+ Animator.UpdateMovementAnimations();
+ m_updateCount--;
+ }
+ }
CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
Dictionary coldata = collisionData.m_objCollisionList;
@@ -3370,7 +3368,7 @@ Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
if (m_lastColCount != coldata.Count)
{
- m_updateCount = 10;
+ m_updateCount = UPDATE_COUNT;
m_lastColCount = coldata.Count;
}
--
cgit v1.1
From 7cd44c1a818615ca0e267f64c74593ad0361350b Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Tue, 15 Dec 2009 20:04:53 -0500
Subject: Fix prim linking bug, Manis #14
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a23c11e..778e384 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -513,18 +513,24 @@ namespace OpenSim.Region.Framework.Scenes
{
// If this is a linkset, we don't want the physics engine mucking up our group position here.
PhysicsActor actor = PhysActor;
+
+ if (actor != null && _parentID == 0)
+ {
+ m_groupPosition = actor.Position;
+ }
+/*
if (actor != null)
{
if (_parentID == 0)
{
- m_groupPosition = actor.Position;
+ m_groupPosition = actor.Position;
}
else
{
m_groupPosition = ParentGroup.AbsolutePosition; // KF+Casper Update Child prims too!
}
}
-
+*/
if (IsAttachment)
{
ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
--
cgit v1.1
From 6483470ec5e9000fb6a85bbdfe5b79be6f336a74 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Thu, 17 Dec 2009 02:54:02 -0500
Subject: Fix GetWorldRotation(), and a host of related Sit fixes.
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +-
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 73 +++++++++++-----------
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 6 +-
3 files changed, 43 insertions(+), 38 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 778e384..4495eda 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1775,7 +1775,7 @@ namespace OpenSim.Region.Framework.Scenes
{
Quaternion newRot;
- if (this.LinkNum == 0)
+ if (this.LinkNum < 2) //KF Single or root prim
{
newRot = RotationOffset;
}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index c67463a..865f649 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1661,14 +1661,14 @@ namespace OpenSim.Region.Framework.Scenes
// Rotation is the sittiing Av's rotation
Quaternion partRot;
- if (part.LinkNum == 1)
- { // Root prim of linkset
- partRot = part.ParentGroup.RootPart.RotationOffset;
- }
- else
- { // single or child prim
+// if (part.LinkNum == 1)
+// { // Root prim of linkset
+// partRot = part.ParentGroup.RootPart.RotationOffset;
+// }
+// else
+// { // single or child prim
partRot = part.GetWorldRotation();
- }
+// }
Quaternion partIRot = Quaternion.Inverse(partRot);
Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av
@@ -1763,14 +1763,14 @@ namespace OpenSim.Region.Framework.Scenes
bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored.
// Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
Quaternion partRot;
- if (part.LinkNum == 1)
- { // Root prim of linkset
- partRot = part.ParentGroup.RootPart.RotationOffset;
- }
- else
- { // single or child prim
+// if (part.LinkNum == 1)
+// { // Root prim of linkset
+// partRot = part.ParentGroup.RootPart.RotationOffset;
+// }
+// else
+// { // single or child prim
partRot = part.GetWorldRotation();
- }
+// }
Quaternion partIRot = Quaternion.Inverse(partRot);
//Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet);
// Sit analysis rewritten by KF 091125
@@ -1846,15 +1846,15 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 offsetr; // = offset * partIRot;
// KF: In a linkset, offsetr needs to be relative to the group root! 091208
// offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot);
- if (part.LinkNum < 2)
- { // Single, or Root prim of linkset, target is ClickOffset * RootRot
+ // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error.
+ // { // Single, or Root prim of linkset, target is ClickOffset * RootRot
offsetr = offset * partIRot;
- }
- else
- { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot)
- offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) +
- (offset * partRot);
- }
+//
+ // else
+ // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot)
+ // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) +
+ // (offset * partRot);
+ // }
//Console.WriteLine(" ");
//Console.WriteLine("link number ={0}", part.LinkNum);
@@ -2170,6 +2170,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (part != null)
{
+//Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation());
if (part.GetAvatarOnSitTarget() == UUID)
{
//Console.WriteLine("Scripted Sit");
@@ -2190,14 +2191,14 @@ namespace OpenSim.Region.Framework.Scenes
// Non-scripted sit by Kitto Flora 21Nov09
// Calculate angle of line from prim to Av
Quaternion partIRot;
- if (part.LinkNum == 1)
- { // Root prim of linkset
- partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset);
- }
- else
- { // single or child prim
+// if (part.LinkNum == 1)
+// { // Root prim of linkset
+// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset);
+// }
+// else
+// { // single or child prim
partIRot = Quaternion.Inverse(part.GetWorldRotation());
- }
+// }
Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos;
float y_diff = (m_avInitialPos.Y - sitTargetPos.Y);
float x_diff = ( m_avInitialPos.X - sitTargetPos.X);
@@ -2253,14 +2254,14 @@ namespace OpenSim.Region.Framework.Scenes
// collisionPoint.Z = global sit surface height
SceneObjectPart part = m_scene.GetSceneObjectPart(localid);
Quaternion partIRot;
- if (part.LinkNum == 1)
- { // Root prim of linkset
- partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset);
- }
- else
- { // single or child prim
+// if (part.LinkNum == 1)
+/// { // Root prim of linkset
+// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset);
+// }
+// else
+// { // single or child prim
partIRot = Quaternion.Inverse(part.GetWorldRotation());
- }
+// }
float offZ = collisionPoint.Z - m_initialSitTarget.Z;
Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction
//Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset);
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index c27c420..688be83 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -2673,7 +2673,7 @@ Console.WriteLine(" JointCreateFixed");
m_lastposition = _position;
m_lastorientation = _orientation;
-
+
l_position.X = vec.X;
l_position.Y = vec.Y;
l_position.Z = vec.Z;
@@ -2681,6 +2681,10 @@ Console.WriteLine(" JointCreateFixed");
l_orientation.Y = ori.Y;
l_orientation.Z = ori.Z;
l_orientation.W = ori.W;
+
+// if(l_position.Y != m_lastposition.Y){
+// Console.WriteLine("UP&V {0} {1}", m_primName, l_position);
+// }
if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f)
{
--
cgit v1.1
From 6dbe25360ec3dc3c998378da8b422751d3e032a9 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Thu, 17 Dec 2009 18:40:34 +0100
Subject: Add cmSetWindlightSceneTargeted. Add restrictions on windlight script
use.
---
OpenSim/Data/MySQL/Resources/032_RegionStore.sql | 20 +-
OpenSim/Framework/RegionInfo.cs | 21 +-
.../World/Meta7Windlight/Meta7WindlightModule.cs | 127 ++++---
OpenSim/Region/Framework/Scenes/EventManager.cs | 12 +
OpenSim/Region/Framework/Scenes/Scene.cs | 4 +-
.../Shared/Api/Implementation/CM_Api.cs | 401 ++++++++++++---------
.../ScriptEngine/Shared/Api/Interface/ICM_Api.cs | 3 +-
.../ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | 5 +
8 files changed, 344 insertions(+), 249 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql
index 0545ee1..b10ffcf 100644
--- a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql
+++ b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql
@@ -20,15 +20,15 @@ CREATE TABLE `regionwindlight` (
`little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11',
`little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16',
`normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4',
- `horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.26',
- `horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.24',
- `horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.33',
- `horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.33',
+ `horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.25',
+ `horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.25',
+ `horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.32',
+ `horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.32',
`haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19',
- `blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.10',
- `blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.93',
- `blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.02',
- `blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.93',
+ `blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.12',
+ `blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.22',
+ `blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.38',
+ `blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.38',
`haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70',
`density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18',
`distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8',
@@ -37,7 +37,7 @@ CREATE TABLE `regionwindlight` (
`sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26',
`sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30',
`sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30',
- `sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.335',
+ `sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.317',
`ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35',
`ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35',
`ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35',
@@ -63,7 +63,7 @@ CREATE TABLE `regionwindlight` (
`cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
`cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01',
`cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
- `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`region_id`)
);
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 9e00528..1ea08f9 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -38,8 +38,8 @@ using OpenSim.Framework.Console;
namespace OpenSim.Framework
-{
- public class RegionMeta7WindlightData
+{
+ public class RegionMeta7WindlightData : ICloneable
{
public UUID regionID = UUID.Zero;
public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f);
@@ -54,19 +54,19 @@ namespace OpenSim.Framework
public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f);
public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f);
public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4");
- public Vector4 horizon = new Vector4(0.26f, 0.24f, 0.34f, 0.33f);
+ public Vector4 horizon = new Vector4(0.25f, 0.25f, 0.32f, 0.32f);
public float hazeHorizon = 0.19f;
- public Vector4 blueDensity = new Vector4(0.10f, 0.93f, 0.02f, 0.93f);
+ public Vector4 blueDensity = new Vector4(0.12f, 0.22f, 0.38f, 0.38f);
public float hazeDensity = 0.70f;
public float densityMultiplier = 0.18f;
public float distanceMultiplier = 0.8f;
public UInt16 maxAltitude = 1605;
public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f);
- public float sunMoonPosition = 0.335f;
+ public float sunMoonPosition = 0.317f;
public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f);
public float eastAngle = 0.0f;
public float sunGlowFocus = 0.10f;
- public float sunGlowSize = 0.10f;
+ public float sunGlowSize = 1.75f;
public float sceneGamma = 1.0f;
public float starBrightness = 0.0f;
public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f);
@@ -78,7 +78,7 @@ namespace OpenSim.Framework
public bool cloudScrollXLock = false;
public float cloudScrollY = 0.01f;
public bool cloudScrollYLock = false;
- public bool drawClassicClouds = false;
+ public bool drawClassicClouds = true;
public delegate void SaveDelegate(RegionMeta7WindlightData wl);
public event SaveDelegate OnSave;
@@ -86,7 +86,12 @@ namespace OpenSim.Framework
{
if (OnSave != null)
OnSave(this);
- }
+ }
+ public object Clone()
+ {
+ return this.MemberwiseClone(); // call clone method
+ }
+
}
[Serializable]
diff --git a/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
index f180b47..72b0b38 100644
--- a/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
+++ b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
@@ -70,64 +70,69 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight
if (m_enableWindlight)
{
m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent;
- m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
+ m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
+ m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted;
}
InstallCommands();
m_log.Debug("[WINDLIGHT]: Initialised windlight module");
+ }
+
+ private List compileWindlightSettings(RegionMeta7WindlightData wl)
+ {
+ byte[] mBlock = new Byte[249];
+ int pos = 0;
+
+ wl.waterColor.ToBytes(mBlock, 0); pos += 12;
+ Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
+ wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
+ Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
+ wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
+ wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
+ wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
+ wl.horizon.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
+ wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
+ wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
+ wl.ambient.ToBytes(mBlock, pos); pos += 16;
+ Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
+ wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
+ wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
+ Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
+ wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
+ Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
+ Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
+ Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
+ mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
+ mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
+ mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
+ List param = new List();
+ param.Add(mBlock);
+ return param;
}
public void SendProfileToClient(ScenePresence presence)
- {
+ {
+ IClientAPI client = presence.ControllingClient;
if (m_enableWindlight)
{
if (presence.IsChildAgent == false)
- {
- IClientAPI client = presence.ControllingClient;
- RegionMeta7WindlightData wl = m_scene.RegionInfo.WindlightSettings;
- byte[] mBlock = new Byte[249];
- int pos = 0;
-
- wl.waterColor.ToBytes(mBlock, 0); pos += 12;
- Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
- wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
- Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
- wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
- wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
- wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
- wl.horizon.ToBytes(mBlock, pos); pos += 16;
- Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
- wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
- Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
- wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
- Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
- wl.ambient.ToBytes(mBlock, pos); pos += 16;
- Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
- wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
- wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
- Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
- wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
- Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
- Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
- Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
- mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
- mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
- mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
- List param = new List();
- param.Add(mBlock);
-
+ {
+ List param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings);
client.SendGenericMessage("Windlight", param);
}
}
@@ -136,13 +141,37 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight
//We probably don't want to spam chat with this.. probably
//m_log.Debug("[WINDLIGHT]: Module disabled");
}
+ }
+ public void SendProfileToClient(ScenePresence presence, RegionMeta7WindlightData wl)
+ {
+ IClientAPI client = presence.ControllingClient;
+ if (m_enableWindlight)
+ {
+ if (presence.IsChildAgent == false)
+ {
+ List param = compileWindlightSettings(wl);
+ client.SendGenericMessage("Windlight", param);
+ }
+ }
+ else
+ {
+ //We probably don't want to spam chat with this.. probably
+ //m_log.Debug("[WINDLIGHT]: Module disabled");
+ }
}
private void EventManager_OnMakeRootAgent(ScenePresence presence)
{
m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
SendProfileToClient(presence);
+ }
+ private void EventManager_OnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID pUUID)
+ {
+ ScenePresence Sc;
+ if (m_scene.TryGetAvatar(pUUID,out Sc))
+ {
+ SendProfileToClient(Sc,wl);
+ }
}
-
private void EventManager_OnSaveNewWindlightProfile()
{
m_scene.ForEachScenePresence(SendProfileToClient);
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index a86e263..68e73b1 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -194,7 +194,9 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
public delegate void OnSaveNewWindlightProfileDelegate();
+ public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionMeta7WindlightData wl, UUID user);
public event OnMakeRootAgentDelegate OnMakeRootAgent;
+ public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
@@ -414,6 +416,7 @@ namespace OpenSim.Region.Framework.Scenes
private ClientClosed handlerClientClosed = null; //OnClientClosed;
private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile;
+ private OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = null; //OnSendNewWindlightProfileTargeted;
private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent;
private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick;
private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
@@ -775,6 +778,15 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user)
+ {
+ handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted;
+ if (handlerSendNewWindlightProfileTargeted != null)
+ {
+ handlerSendNewWindlightProfileTargeted(wl, user);
+ }
+ }
+
public void TriggerOnSaveNewWindlightProfile()
{
handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 104d22b..20cae5d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1519,8 +1519,8 @@ namespace OpenSim.Region.Framework.Scenes
public void SaveTerrain()
{
m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
- }
-
+ }
+
public void StoreWindlightProfile(RegionMeta7WindlightData wl)
{
m_regInfo.WindlightSettings = wl;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
index 4cc2f0a..d4250c1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -229,8 +229,181 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return values;
- }
+ }
+
+ private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
+ {
+ RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
+ LSL_List values = new LSL_List();
+ int idx = 0;
+ while (idx < rules.Length)
+ {
+ uint rule = (uint)rules.GetLSLIntegerItem(idx);
+ LSL_Types.Quaternion iQ;
+ LSL_Types.Vector3 iV;
+ switch (rule)
+ {
+ case (int)ScriptBaseClass.WL_AMBIENT:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
+ break;
+ case (int)ScriptBaseClass.WL_BLUE_DENSITY:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
+ idx++;
+ wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COLOR:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
+ idx++;
+ wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
+ break;
+ 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);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCALE:
+ idx++;
+ wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
+ idx++;
+ wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
+ idx++;
+ wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
+ idx++;
+ wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
+ idx++;
+ wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ break;
+ case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
+ idx++;
+ wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
+ idx++;
+ wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
+ idx++;
+ wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
+ break;
+ case (int)ScriptBaseClass.WL_EAST_ANGLE:
+ idx++;
+ wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
+ idx++;
+ wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
+ idx++;
+ wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_DENSITY:
+ idx++;
+ wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HAZE_HORIZON:
+ idx++;
+ wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_HORIZON:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
+ break;
+ case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
+ idx++;
+ wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
+ break;
+ case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
+ idx++;
+ wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
+ break;
+ 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);
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
+ idx++;
+ wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
+ idx++;
+ wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SCENE_GAMMA:
+ idx++;
+ wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
+ idx++;
+ wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
+ idx++;
+ wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
+ idx++;
+ wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
+ idx++;
+ iQ = rules.GetQuaternionItem(idx);
+ wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
+ break;
+ case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
+ idx++;
+ wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
+ break;
+ case (int)ScriptBaseClass.WL_WATER_COLOR:
+ idx++;
+ iV = rules.GetVector3Item(idx);
+ wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ break;
+ case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
+ idx++;
+ wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
+ break;
+ }
+ idx++;
+ }
+ return wl;
+ }
///
/// Set the current Windlight scene
///
@@ -242,188 +415,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
CMShoutError("Careminster functions are not enabled.");
return 0;
+ }
+ if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
+ {
+ CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
+ return 0;
}
int success = 0;
- m_host.AddScriptLPS(1);
- if (Meta7WindlightModule.EnableWindlight)
- {
- RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
-
- LSL_List values = new LSL_List();
- int idx = 0;
- success = 1;
- while (idx < rules.Length)
- {
- uint rule = (uint)rules.GetLSLIntegerItem(idx);
- LSL_Types.Quaternion iQ;
- LSL_Types.Vector3 iV;
- switch (rule)
- {
- case (int)ScriptBaseClass.WL_AMBIENT:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
- break;
- case (int)ScriptBaseClass.WL_BLUE_DENSITY:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
- idx++;
- wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_COLOR:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
- idx++;
- wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
- break;
- 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);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCALE:
- idx++;
- wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
- idx++;
- wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
- idx++;
- wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
- idx++;
- wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
- idx++;
- wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
- break;
- case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
- break;
- case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
- idx++;
- wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
- idx++;
- wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
- idx++;
- wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
- break;
- case (int)ScriptBaseClass.WL_EAST_ANGLE:
- idx++;
- wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
- idx++;
- wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
- idx++;
- wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_HAZE_DENSITY:
- idx++;
- wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_HAZE_HORIZON:
- idx++;
- wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_HORIZON:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
- break;
- case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
- idx++;
- wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
- break;
- case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
- idx++;
- wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
- break;
- 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);
- break;
- case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
- idx++;
- wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
- idx++;
- wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SCENE_GAMMA:
- idx++;
- wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
- idx++;
- wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
- idx++;
- wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
- idx++;
- wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
- idx++;
- iQ = rules.GetQuaternionItem(idx);
- wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
- break;
- case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
- idx++;
- wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
- break;
- case (int)ScriptBaseClass.WL_WATER_COLOR:
- idx++;
- iV = rules.GetVector3Item(idx);
- wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
- break;
- case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
- idx++;
- wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
- break;
- default:
- success = 0;
- break;
- }
- idx++;
- }
- m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
-
+ m_host.AddScriptLPS(1);
+ if (Meta7WindlightModule.EnableWindlight)
+ {
+ RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
+ m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
+ success = 1;
+ }
+ else
+ {
+ CMShoutError("Windlight module is disabled");
+ return 0;
}
return success;
+ }
+ ///
+ /// Set the current Windlight scene to a target avatar
+ ///
+ ///
+ /// success: true or false
+ public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
+ {
+ if (!m_CMFunctionsEnabled)
+ {
+ CMShoutError("Careminster functions are not enabled.");
+ return 0;
+ }
+ if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
+ {
+ CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
+ return 0;
+ }
+ int success = 0;
+ m_host.AddScriptLPS(1);
+ if (Meta7WindlightModule.EnableWindlight)
+ {
+ RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
+ World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
+ success = 1;
+ }
+ else
+ {
+ CMShoutError("Windlight module is disabled");
+ return 0;
+ }
+ return success;
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
index 9dd0b73..ef990a1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -15,6 +15,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{
// Windlight Functions
LSL_List cmGetWindlightScene(LSL_List rules);
- int cmSetWindlightScene(LSL_List rules);
+ int cmSetWindlightScene(LSL_List rules);
+ int cmSetWindlightSceneTargeted(LSL_List rules, key target);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
index e85d41e..5bc3a88 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -66,6 +66,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public int cmSetWindlightScene(LSL_List rules)
{
return m_CM_Functions.cmSetWindlightScene(rules);
+ }
+
+ public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
+ {
+ return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
}
}
}
--
cgit v1.1
From e38e8ae98759e403175016260edd27772b5c9e4c Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Sat, 19 Dec 2009 19:54:44 -0500
Subject: Fix mantis #10 & #14
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 33 +++++++---------------
2 files changed, 11 insertions(+), 24 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index d348c90..a7d34f5 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.6.9CM";
+ private const string VERSION_NUMBER = "0.6.91CM";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 778e384..0eddbfd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -513,24 +513,11 @@ namespace OpenSim.Region.Framework.Scenes
{
// If this is a linkset, we don't want the physics engine mucking up our group position here.
PhysicsActor actor = PhysActor;
-
if (actor != null && _parentID == 0)
{
m_groupPosition = actor.Position;
- }
-/*
- if (actor != null)
- {
- if (_parentID == 0)
- {
- m_groupPosition = actor.Position;
- }
- else
- {
- m_groupPosition = ParentGroup.AbsolutePosition; // KF+Casper Update Child prims too!
- }
}
-*/
+
if (IsAttachment)
{
ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
@@ -545,7 +532,6 @@ namespace OpenSim.Region.Framework.Scenes
StoreUndoState();
m_groupPosition = value;
-
PhysicsActor actor = PhysActor;
if (actor != null)
{
@@ -1755,16 +1741,17 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 GetWorldPosition()
{
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
-
Vector3 axPos = OffsetPosition;
axPos *= parentRot;
Vector3 translationOffsetPosition = axPos;
-
- int tx = (int)GroupPosition.X;
- int ty = (int)GroupPosition.Y;
- int tz = (int)GroupPosition.Z;
-
- return GroupPosition + translationOffsetPosition;
+ if(_parentID == 0)
+ {
+ return GroupPosition;
+ }
+ else
+ {
+ return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
+ }
}
///
@@ -1775,7 +1762,7 @@ namespace OpenSim.Region.Framework.Scenes
{
Quaternion newRot;
- if (this.LinkNum == 0)
+ if (this.LinkNum < 2) //KF Single or root prim
{
newRot = RotationOffset;
}
--
cgit v1.1
From 31bf25d05e09395416c0427e783f8685a9e69889 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Sun, 20 Dec 2009 16:18:43 +0100
Subject: Reverted my changes to jhurliman's packet stack since it currently
causes more problems than it resolves. The stack DOES need a rework
particularly with regards to priorities, but this is not it.
---
.../Region/ClientStack/LindenUDP/LLUDPServer.cs | 27 +-----
.../Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 107 +--------------------
.../Region/ClientStack/LindenUDP/OutgoingPacket.cs | 4 +-
3 files changed, 6 insertions(+), 132 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 4d9f58f..3c4fa72 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -402,7 +402,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Queue or Send
OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category);
- outgoingPacket.Type = type;
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
SendPacketFinal(outgoingPacket);
@@ -514,7 +513,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
byte flags = buffer.Data[0];
bool isResend = (flags & Helpers.MSG_RESENT) != 0;
bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
- bool sendSynchronous = false;
LLUDPClient udpClient = outgoingPacket.Client;
if (!udpClient.IsConnected)
@@ -570,28 +568,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (isReliable)
Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength);
- //Some packet types need to be sent synchonously.
- //Sorry, i know it's not optimal, but until the LL client
- //manages packets correctly and re-orders them as required, this is necessary.
-
-
// Put the UDP payload on the wire
- if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate)
- {
- SyncBeginPrioritySend(buffer, 2); // highest priority
- }
- else if (outgoingPacket.Type == PacketType.ObjectUpdate
- || outgoingPacket.Type == PacketType.LayerData)
- {
- SyncBeginPrioritySend(buffer, 1); // medium priority
- }
- else
- {
- SyncBeginPrioritySend(buffer, 0); // normal priority
- }
-
- //AsyncBeginSend(buffer);
-
+ AsyncBeginSend(buffer);
+
// Keep track of when this packet was sent out (right now)
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
}
@@ -872,7 +851,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length);
- SyncBeginPrioritySend(buffer, 1); //Setting this to a medium priority should help minimise resends
+ AsyncBeginSend(buffer);
}
private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
index de2cd24..d2779ba 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
@@ -29,7 +29,6 @@ using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
-using System.Collections.Generic;
using log4net;
namespace OpenMetaverse
@@ -53,30 +52,12 @@ namespace OpenMetaverse
/// Local IP address to bind to in server mode
protected IPAddress m_localBindAddress;
- ///
- /// Standard queue for our outgoing SyncBeginPrioritySend
- ///
- private List m_standardQueue = new List();
-
- ///
- /// Medium priority queue for our outgoing SyncBeginPrioritySend
- ///
- private List m_mediumPriorityQueue = new List();
-
- ///
- /// Prioritised queue for our outgoing SyncBeginPrioritySend
- ///
- private List m_priorityQueue = new List();
-
/// UDP socket, used in either client or server mode
private Socket m_udpSocket;
/// Flag to process packets asynchronously or synchronously
private bool m_asyncPacketHandling;
- /// Are we currently sending data asynchronously?
- private volatile bool m_sendingData = false;
-
/// The all important shutdown flag
private volatile bool m_shutdownFlag = true;
@@ -265,51 +246,7 @@ namespace OpenMetaverse
}
}
- public void SyncBeginPrioritySend(UDPPacketBuffer buf, int Priority)
- {
- if (!m_shutdownFlag)
- {
- if (!m_sendingData)
- {
- m_sendingData = true;
- try
- {
- AsyncBeginSend(buf);
- }
- catch (SocketException) { }
- catch (ObjectDisposedException) { }
- }
- else
- {
- if (Priority == 2)
- {
- lock (m_priorityQueue)
- {
- m_priorityQueue.Add(buf);
- }
- }
- else
- {
- if (Priority != 0)
- {
- lock (m_mediumPriorityQueue)
- {
- m_mediumPriorityQueue.Add(buf);
- }
- }
- else
- {
- lock (m_standardQueue)
- {
- m_standardQueue.Add(buf);
- }
- }
- }
- }
- }
- }
-
- private void AsyncBeginSend(UDPPacketBuffer buf)
+ public void AsyncBeginSend(UDPPacketBuffer buf)
{
if (!m_shutdownFlag)
{
@@ -333,48 +270,8 @@ namespace OpenMetaverse
{
try
{
+// UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState;
m_udpSocket.EndSendTo(result);
-
- if (m_sendingData)
- {
- lock (m_priorityQueue)
- {
- if (m_priorityQueue.Count > 0)
- {
- UDPPacketBuffer buf = m_priorityQueue[0];
- m_priorityQueue.RemoveAt(0);
- AsyncBeginSend(buf);
- }
- else
- {
- lock (m_mediumPriorityQueue)
- {
- if (m_mediumPriorityQueue.Count > 0)
- {
- UDPPacketBuffer buf = m_mediumPriorityQueue[0];
- m_mediumPriorityQueue.RemoveAt(0);
- AsyncBeginSend(buf);
- }
- else
- {
- lock (m_standardQueue)
- {
- if (m_standardQueue.Count > 0)
- {
- UDPPacketBuffer buf = m_standardQueue[0];
- m_standardQueue.RemoveAt(0);
- AsyncBeginSend(buf);
- }
- else
- {
- m_sendingData = false;
- }
- }
- }
- }
- }
- }
- }
}
catch (SocketException) { }
catch (ObjectDisposedException) { }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
index 7dc42d3..1a1a1cb 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
@@ -28,7 +28,6 @@
using System;
using OpenSim.Framework;
using OpenMetaverse;
-using OpenMetaverse.Packets;
namespace OpenSim.Region.ClientStack.LindenUDP
{
@@ -53,8 +52,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public int TickCount;
/// Category this packet belongs to
public ThrottleOutPacketType Category;
- /// The type of packet so its delivery method can be determined
- public PacketType Type;
+
///
/// Default constructor
///
--
cgit v1.1
From e3c14660478bdd3af8c792b4b6b48ffffbbe19f9 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 21 Dec 2009 13:22:52 +0100
Subject: Fixed a nasty crash in StandUp() that occurred when the part got
killed with an avatar sitting on it.
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 54 ++++++++++++++++++------
1 file changed, 41 insertions(+), 13 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 865f649..abdd1a0 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -118,7 +118,8 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation
private Vector3 m_avUnscriptedSitPos; // for non-scripted prims
- private Vector3 m_lastPosition;
+ private Vector3 m_lastPosition;
+ private Vector3 m_lastWorldPosition;
private Quaternion m_lastRotation;
private Vector3 m_lastVelocity;
//private int m_lastTerseSent;
@@ -1667,24 +1668,45 @@ namespace OpenSim.Region.Framework.Scenes
// }
// else
// { // single or child prim
- partRot = part.GetWorldRotation();
-// }
+
+// }
+ if (part == null) //CW: Part may be gone. llDie() for example.
+ {
+ partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
+ }
+ else
+ {
+ partRot = part.GetWorldRotation();
+ }
+
Quaternion partIRot = Quaternion.Inverse(partRot);
Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av
Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av
- Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ( m_pos * partRot); // + av sit offset!
- if (m_physicsActor == null)
- {
- AddToPhysicalScene(false);
+
+ if (m_physicsActor == null)
+ {
+ AddToPhysicalScene(false);
+ }
+ //CW: If the part isn't null then we can set the current position
+ if (part != null)
+ {
+ Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset!
+ AbsolutePosition = avWorldStandUp; //KF: Fix stand up.
+ part.IsOccupied = false;
+ }
+ else
+ {
+ //CW: Since the part doesn't exist, a coarse standup position isn't an issue
+ AbsolutePosition = m_lastWorldPosition;
}
- AbsolutePosition = avWorldStandUp; //KF: Fix stand up.
- m_parentPosition = Vector3.Zero;
+
+ m_parentPosition = Vector3.Zero;
m_parentID = 0;
- part.IsOccupied = false;
SendFullUpdateToAllClients();
m_requestedSitTargetID = 0;
+
if ((m_physicsActor != null) && (m_avHeight > 0))
{
SetHeight(m_avHeight);
@@ -1778,7 +1800,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (!part.IsOccupied)
{
-//Console.WriteLine("Scripted, unoccupied");
+//Console.WriteLine("Scripted, unoccupied");
part.SetAvatarOnSitTarget(UUID); // set that Av will be on it
offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one
sitOrientation = avSitOrientation; // Change rotatione to the scripted one
@@ -1831,13 +1853,19 @@ namespace OpenSim.Region.Framework.Scenes
// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5)
if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) )
{
- autopilot = false; // close enough
+ autopilot = false; // close enough
+ m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup.
+ Not using the part's position because returning the AV to the last known standing
+ position is likely to be more friendly, isn't it? */
RemoveFromPhysicalScene();
AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target
} // else the autopilot will get us close
}
else
- { // its a scripted sit
+ { // its a scripted sit
+ m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup.
+ I *am* using the part's position this time because we have no real idea how far away
+ the avatar is from the sit target. */
RemoveFromPhysicalScene();
}
}
--
cgit v1.1
From 69b551c51686bca58c478f517f6ccfa561ad9730 Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 22 Dec 2009 03:22:33 +0100
Subject: Allow 100ms for scripts to run attach(NULL_KEY) on detach
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 12 ++++++++++++
1 file changed, 12 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index f74fd5d..e875525 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -542,6 +542,18 @@ namespace OpenSim.Region.Framework.Scenes
if (group.GetFromItemID() == itemID)
{
m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero);
+ bool hasScripts = false;
+ foreach (SceneObjectPart part in group.Children)
+ {
+ if (part..Inventory.ContainsScripts())
+ {
+ hasScripts = true;
+ break;
+ }
+ }
+
+ if (hasScripts) // Allow the object to execute the attach(NULL_KEY) event
+ System.Threading.Thread.Sleep(100);
group.DetachToInventoryPrep();
m_log.Debug("[DETACH]: Saving attachpoint: " +
((uint)group.GetAttachmentPoint()).ToString());
--
cgit v1.1
From 46fea747265574bb056b8d1ffa189ec3725a7abc Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 22 Dec 2009 03:25:09 +0100
Subject: Jumped the gun...
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index e875525..fadeaf4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -545,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
bool hasScripts = false;
foreach (SceneObjectPart part in group.Children)
{
- if (part..Inventory.ContainsScripts())
+ if (part.Inventory.ContainsScripts())
{
hasScripts = true;
break;
--
cgit v1.1
From 49fbe0ddb429b8625682255bf0cafa9ea93d274a Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 22 Dec 2009 03:26:47 +0100
Subject: Should not commit without compiling
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index fadeaf4..b0fb8b3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -543,7 +543,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero);
bool hasScripts = false;
- foreach (SceneObjectPart part in group.Children)
+ foreach (SceneObjectPart part in group.Children.Values)
{
if (part.Inventory.ContainsScripts())
{
--
cgit v1.1
From 0a29842caf5dbe711490b9b323ae922c418c6c30 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Tue, 22 Dec 2009 00:20:04 -0500
Subject: Include ChOdePlugin
---
OpenSim/Region/Physics/ChOdePlugin/AssemblyInfo.cs | 58 +
OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | 1353 +++++++
.../Physics/ChOdePlugin/ODEDynamics.c_comments | 630 ++++
OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs | 673 ++++
OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 3271 +++++++++++++++++
.../ChOdePlugin/ODERayCastRequestManager.cs | 375 ++
.../Region/Physics/ChOdePlugin/OdePhysicsJoint.cs | 48 +
OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 3865 ++++++++++++++++++++
.../Physics/ChOdePlugin/Tests/ODETestClass.cs | 122 +
OpenSim/Region/Physics/ChOdePlugin/drawstuff.cs | 98 +
OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 21 +-
OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | 20 +-
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 108 +-
13 files changed, 10524 insertions(+), 118 deletions(-)
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/AssemblyInfo.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.c_comments
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/ODERayCastRequestManager.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/OdePhysicsJoint.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/Tests/ODETestClass.cs
create mode 100644 OpenSim/Region/Physics/ChOdePlugin/drawstuff.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Physics/ChOdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/ChOdePlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..d65929a
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/AssemblyInfo.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 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.Reflection;
+using System.Runtime.InteropServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly : AssemblyTitle("OdePlugin")]
+[assembly : AssemblyDescription("")]
+[assembly : AssemblyConfiguration("")]
+[assembly : AssemblyCompany("http://opensimulator.org")]
+[assembly : AssemblyProduct("OdePlugin")]
+[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
+[assembly : AssemblyTrademark("")]
+[assembly : AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+
+[assembly : ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly : AssemblyVersion("0.6.5.*")]
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
new file mode 100644
index 0000000..aa0acb7
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
@@ -0,0 +1,1353 @@
+/*
+ * 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.Reflection;
+using OpenMetaverse;
+using Ode.NET;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+using log4net;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ ///
+ /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves.
+ ///
+
+ public enum dParam : int
+ {
+ LowStop = 0,
+ HiStop = 1,
+ Vel = 2,
+ FMax = 3,
+ FudgeFactor = 4,
+ Bounce = 5,
+ CFM = 6,
+ StopERP = 7,
+ StopCFM = 8,
+ LoStop2 = 256,
+ HiStop2 = 257,
+ Vel2 = 258,
+ FMax2 = 259,
+ StopERP2 = 7 + 256,
+ StopCFM2 = 8 + 256,
+ LoStop3 = 512,
+ HiStop3 = 513,
+ Vel3 = 514,
+ FMax3 = 515,
+ StopERP3 = 7 + 512,
+ StopCFM3 = 8 + 512
+ }
+ public class OdeCharacter : PhysicsActor
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private Vector3 _position;
+ private d.Vector3 _zeroPosition;
+ // private d.Matrix3 m_StandUpRotation;
+ private bool _zeroFlag = false;
+ private bool m_lastUpdateSent = false;
+ private Vector3 _velocity;
+ private Vector3 _target_velocity;
+ private Vector3 _acceleration;
+ private Vector3 m_rotationalVelocity;
+ private float m_mass = 80f;
+ public float m_density = 60f;
+ private bool m_pidControllerActive = true;
+ public float PID_D = 800.0f;
+ public float PID_P = 900.0f;
+ //private static float POSTURE_SERVO = 10000.0f;
+ public float CAPSULE_RADIUS = 0.37f;
+ public float CAPSULE_LENGTH = 2.140599f;
+ public float m_tensor = 3800000f;
+ public float heightFudgeFactor = 0.52f;
+ public float walkDivisor = 1.3f;
+ public float runDivisor = 0.8f;
+ private bool flying = false;
+ private bool m_iscolliding = false;
+ private bool m_iscollidingGround = false;
+ private bool m_wascolliding = false;
+ private bool m_wascollidingGround = false;
+ private bool m_iscollidingObj = false;
+ private bool m_alwaysRun = false;
+ private bool m_hackSentFall = false;
+ private bool m_hackSentFly = false;
+ private int m_requestedUpdateFrequency = 0;
+ private Vector3 m_taintPosition = Vector3.Zero;
+ public uint m_localID = 0;
+ public bool m_returnCollisions = false;
+ // taints and their non-tainted counterparts
+ public bool m_isPhysical = false; // the current physical status
+ public bool m_tainted_isPhysical = false; // set when the physical status is tainted (false=not existing in physics engine, true=existing)
+ public float MinimumGroundFlightOffset = 3f;
+
+ private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
+ private float m_tiltMagnitudeWhenProjectedOnXYPlane = 0.1131371f; // used to introduce a fixed tilt because a straight-up capsule falls through terrain, probably a bug in terrain collider
+
+
+ private float m_buoyancy = 0f;
+
+ // private CollisionLocker ode;
+
+ private string m_name = String.Empty;
+
+ private bool[] m_colliderarr = new bool[11];
+ private bool[] m_colliderGroundarr = new bool[11];
+
+ // Default we're a Character
+ private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
+
+ // Default, Collide with Other Geometries, spaces, bodies and characters.
+ private CollisionCategories m_collisionFlags = (CollisionCategories.Geom
+ | CollisionCategories.Space
+ | CollisionCategories.Body
+ | CollisionCategories.Character
+ | CollisionCategories.Land);
+ public IntPtr Body = IntPtr.Zero;
+ private OdeScene _parent_scene;
+ public IntPtr Shell = IntPtr.Zero;
+ public IntPtr Amotor = IntPtr.Zero;
+ public d.Mass ShellMass;
+ public bool collidelock = false;
+
+ public int m_eventsubscription = 0;
+ private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
+
+ // unique UUID of this character object
+ public UUID m_uuid;
+ public bool bad = false;
+
+ public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
+ {
+ m_uuid = UUID.Random();
+
+ if (pos.IsFinite())
+ {
+ if (pos.Z > 9999999f)
+ {
+ pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+ if (pos.Z < -90000f)
+ {
+ pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+ _position = pos;
+ m_taintPosition.X = pos.X;
+ m_taintPosition.Y = pos.Y;
+ m_taintPosition.Z = pos.Z;
+ }
+ else
+ {
+ _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
+ m_taintPosition.X = _position.X;
+ m_taintPosition.Y = _position.Y;
+ m_taintPosition.Z = _position.Z;
+ m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
+ }
+
+ _parent_scene = parent_scene;
+
+ PID_D = pid_d;
+ PID_P = pid_p;
+ CAPSULE_RADIUS = capsule_radius;
+ m_tensor = tensor;
+ m_density = density;
+ heightFudgeFactor = height_fudge_factor;
+ walkDivisor = walk_divisor;
+ runDivisor = rundivisor;
+
+ // m_StandUpRotation =
+ // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f,
+ // 0.5f);
+
+ for (int i = 0; i < 11; i++)
+ {
+ m_colliderarr[i] = false;
+ }
+ CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
+ //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
+ m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
+
+ m_isPhysical = false; // current status: no ODE information exists
+ m_tainted_isPhysical = true; // new tainted status: need to create ODE information
+
+ _parent_scene.AddPhysicsActorTaint(this);
+
+ m_name = avName;
+ }
+
+ public override int PhysicsActorType
+ {
+ get { return (int) ActorTypes.Agent; }
+ set { return; }
+ }
+
+ ///
+ /// If this is set, the avatar will move faster
+ ///
+ public override bool SetAlwaysRun
+ {
+ get { return m_alwaysRun; }
+ set { m_alwaysRun = value; }
+ }
+
+ public override uint LocalID
+ {
+ set { m_localID = value; }
+ }
+
+ public override bool Grabbed
+ {
+ set { return; }
+ }
+
+ public override bool Selected
+ {
+ set { return; }
+ }
+
+ public override float Buoyancy
+ {
+ get { return m_buoyancy; }
+ set { m_buoyancy = value; }
+ }
+
+ public override bool FloatOnWater
+ {
+ set { return; }
+ }
+
+ public override bool IsPhysical
+ {
+ get { return false; }
+ set { return; }
+ }
+
+ public override bool ThrottleUpdates
+ {
+ get { return false; }
+ set { return; }
+ }
+
+ public override bool Flying
+ {
+ get { return flying; }
+ set { flying = value; }
+ }
+
+ ///
+ /// Returns if the avatar is colliding in general.
+ /// This includes the ground and objects and avatar.
+ ///
+ public override bool IsColliding
+ {
+ get { return m_iscolliding; }
+ set
+ {
+ int i;
+ int truecount = 0;
+ int falsecount = 0;
+
+ if (m_colliderarr.Length >= 10)
+ {
+ for (i = 0; i < 10; i++)
+ {
+ m_colliderarr[i] = m_colliderarr[i + 1];
+ }
+ }
+ m_colliderarr[10] = value;
+
+ for (i = 0; i < 11; i++)
+ {
+ if (m_colliderarr[i])
+ {
+ truecount++;
+ }
+ else
+ {
+ falsecount++;
+ }
+ }
+
+ // Equal truecounts and false counts means we're colliding with something.
+
+ if (falsecount > 1.2*truecount)
+ {
+ m_iscolliding = false;
+ }
+ else
+ {
+ m_iscolliding = true;
+ }
+ if (m_wascolliding != m_iscolliding)
+ {
+ //base.SendCollisionUpdate(new CollisionEventUpdate());
+ }
+ m_wascolliding = m_iscolliding;
+ }
+ }
+
+ ///
+ /// Returns if an avatar is colliding with the ground
+ ///
+ public override bool CollidingGround
+ {
+ get { return m_iscollidingGround; }
+ set
+ {
+ // Collisions against the ground are not really reliable
+ // So, to get a consistant value we have to average the current result over time
+ // Currently we use 1 second = 10 calls to this.
+ int i;
+ int truecount = 0;
+ int falsecount = 0;
+
+ if (m_colliderGroundarr.Length >= 10)
+ {
+ for (i = 0; i < 10; i++)
+ {
+ m_colliderGroundarr[i] = m_colliderGroundarr[i + 1];
+ }
+ }
+ m_colliderGroundarr[10] = value;
+
+ for (i = 0; i < 11; i++)
+ {
+ if (m_colliderGroundarr[i])
+ {
+ truecount++;
+ }
+ else
+ {
+ falsecount++;
+ }
+ }
+
+ // Equal truecounts and false counts means we're colliding with something.
+
+ if (falsecount > 1.2*truecount)
+ {
+ m_iscollidingGround = false;
+ }
+ else
+ {
+ m_iscollidingGround = true;
+ }
+ if (m_wascollidingGround != m_iscollidingGround)
+ {
+ //base.SendCollisionUpdate(new CollisionEventUpdate());
+ }
+ m_wascollidingGround = m_iscollidingGround;
+ }
+ }
+
+ ///
+ /// Returns if the avatar is colliding with an object
+ ///
+ public override bool CollidingObj
+ {
+ get { return m_iscollidingObj; }
+ set
+ {
+ m_iscollidingObj = value;
+ if (value)
+ m_pidControllerActive = false;
+ else
+ m_pidControllerActive = true;
+ }
+ }
+
+ ///
+ /// turn the PID controller on or off.
+ /// The PID Controller will turn on all by itself in many situations
+ ///
+ ///
+ public void SetPidStatus(bool status)
+ {
+ m_pidControllerActive = status;
+ }
+
+ public override bool Stopped
+ {
+ get { return _zeroFlag; }
+ }
+
+ ///
+ /// This 'puts' an avatar somewhere in the physics space.
+ /// Not really a good choice unless you 'know' it's a good
+ /// spot otherwise you're likely to orbit the avatar.
+ ///
+ public override Vector3 Position
+ {
+ get { return _position; }
+ set
+ {
+ if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
+ {
+ if (value.IsFinite())
+ {
+ if (value.Z > 9999999f)
+ {
+ value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+ if (value.Z < -90000f)
+ {
+ value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+
+ _position.X = value.X;
+ _position.Y = value.Y;
+ _position.Z = value.Z;
+
+ m_taintPosition.X = value.X;
+ m_taintPosition.Y = value.Y;
+ m_taintPosition.Z = value.Z;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character");
+ }
+ }
+ }
+ }
+
+ public override Vector3 RotationalVelocity
+ {
+ get { return m_rotationalVelocity; }
+ set { m_rotationalVelocity = value; }
+ }
+
+ ///
+ /// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight
+ /// and use it to offset landings properly
+ ///
+ public override Vector3 Size
+ {
+ get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_pidControllerActive = true;
+
+ Vector3 SetSize = value;
+ m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f;
+ //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
+
+ Velocity = Vector3.Zero;
+
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN Size from Scene on a Character");
+ }
+ }
+ }
+
+ private void AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3 movementVector)
+ {
+ movementVector.Z = 0f;
+ float magnitude = (float)Math.Sqrt((double)(movementVector.X * movementVector.X + movementVector.Y * movementVector.Y));
+ if (magnitude < 0.1f) return;
+
+ // normalize the velocity vector
+ float invMagnitude = 1.0f / magnitude;
+ movementVector.X *= invMagnitude;
+ movementVector.Y *= invMagnitude;
+
+ // if we change the capsule heading too often, the capsule can fall down
+ // therefore we snap movement vector to just 1 of 4 predefined directions (ne, nw, se, sw),
+ // meaning only 4 possible capsule tilt orientations
+ if (movementVector.X > 0)
+ {
+ // east
+ if (movementVector.Y > 0)
+ {
+ // northeast
+ movementVector.X = (float)Math.Sqrt(2.0);
+ movementVector.Y = (float)Math.Sqrt(2.0);
+ }
+ else
+ {
+ // southeast
+ movementVector.X = (float)Math.Sqrt(2.0);
+ movementVector.Y = -(float)Math.Sqrt(2.0);
+ }
+ }
+ else
+ {
+ // west
+ if (movementVector.Y > 0)
+ {
+ // northwest
+ movementVector.X = -(float)Math.Sqrt(2.0);
+ movementVector.Y = (float)Math.Sqrt(2.0);
+ }
+ else
+ {
+ // southwest
+ movementVector.X = -(float)Math.Sqrt(2.0);
+ movementVector.Y = -(float)Math.Sqrt(2.0);
+ }
+ }
+
+
+ // movementVector.Z is zero
+
+ // calculate tilt components based on desired amount of tilt and current (snapped) heading.
+ // the "-" sign is to force the tilt to be OPPOSITE the direction of movement.
+ float xTiltComponent = -movementVector.X * m_tiltMagnitudeWhenProjectedOnXYPlane;
+ float yTiltComponent = -movementVector.Y * m_tiltMagnitudeWhenProjectedOnXYPlane;
+
+ //m_log.Debug("[PHYSICS] changing avatar tilt");
+ d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, xTiltComponent);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, xTiltComponent); // must be same as lowstop, else a different, spurious tilt is introduced
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, yTiltComponent);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, yTiltComponent); // same as lowstop
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
+ }
+
+ ///
+ /// This creates the Avatar's physical Surrogate at the position supplied
+ ///
+ ///
+ ///
+ ///
+
+ // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
+ // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
+ // place that is safe to call this routine AvatarGeomAndBodyCreation.
+ private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor)
+ {
+ //CAPSULE_LENGTH = -5;
+ //CAPSULE_RADIUS = -5;
+ int dAMotorEuler = 1;
+ _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+ if (CAPSULE_LENGTH <= 0)
+ {
+ m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
+ CAPSULE_LENGTH = 0.01f;
+
+ }
+
+ if (CAPSULE_RADIUS <= 0)
+ {
+ m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
+ CAPSULE_RADIUS = 0.01f;
+
+ }
+ Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
+
+ d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
+ d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
+
+ d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
+ Body = d.BodyCreate(_parent_scene.world);
+ d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
+
+ _position.X = npositionX;
+ _position.Y = npositionY;
+ _position.Z = npositionZ;
+
+
+ m_taintPosition.X = npositionX;
+ m_taintPosition.Y = npositionY;
+ m_taintPosition.Z = npositionZ;
+
+ d.BodySetMass(Body, ref ShellMass);
+ d.Matrix3 m_caprot;
+ // 90 Stand up on the cap of the capped cyllinder
+ if (_parent_scene.IsAvCapsuleTilted)
+ {
+ d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2));
+ }
+ else
+ {
+ d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
+ }
+
+
+ d.GeomSetRotation(Shell, ref m_caprot);
+ d.BodySetRotation(Body, ref m_caprot);
+
+ d.GeomSetBody(Shell, Body);
+
+
+ // The purpose of the AMotor here is to keep the avatar's physical
+ // surrogate from rotating while moving
+ Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
+ d.JointAttach(Amotor, Body, IntPtr.Zero);
+ d.JointSetAMotorMode(Amotor, dAMotorEuler);
+ d.JointSetAMotorNumAxes(Amotor, 3);
+ d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
+ d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
+ d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
+ d.JointSetAMotorAngle(Amotor, 0, 0);
+ d.JointSetAMotorAngle(Amotor, 1, 0);
+ d.JointSetAMotorAngle(Amotor, 2, 0);
+
+ // These lowstops and high stops are effectively (no wiggle room)
+ if (_parent_scene.IsAvCapsuleTilted)
+ {
+ d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
+ }
+ else
+ {
+ #region Documentation of capsule motor LowStop and HighStop parameters
+ // Intentionally introduce some tilt into the capsule by setting
+ // the motor stops to small epsilon values. This small tilt prevents
+ // the capsule from falling into the terrain; a straight-up capsule
+ // (with -0..0 motor stops) falls into the terrain for reasons yet
+ // to be comprehended in their entirety.
+ #endregion
+ AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop
+ }
+
+ // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the
+ // capped cyllinder will fall over
+ d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
+
+ //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
+ //d.QfromR(
+ //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
+ //
+ //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
+ //standupStraight();
+ }
+
+ //
+ ///
+ /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
+ /// This may be used in calculations in the scene/scenepresence
+ ///
+ public override float Mass
+ {
+ get
+ {
+ float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
+ return m_density*AVvolume;
+ }
+ }
+ public override void link(PhysicsActor obj)
+ {
+
+ }
+
+ public override void delink()
+ {
+
+ }
+
+ public override void LockAngularMotion(Vector3 axis)
+ {
+
+ }
+
+// This code is very useful. Written by DanX0r. We're just not using it right now.
+// Commented out to prevent a warning.
+//
+// private void standupStraight()
+// {
+// // The purpose of this routine here is to quickly stabilize the Body while it's popped up in the air.
+// // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you
+// // change appearance and when you enter the simulator
+// // After this routine is done, the amotor stabilizes much quicker
+// d.Vector3 feet;
+// d.Vector3 head;
+// d.BodyGetRelPointPos(Body, 0.0f, 0.0f, -1.0f, out feet);
+// d.BodyGetRelPointPos(Body, 0.0f, 0.0f, 1.0f, out head);
+// float posture = head.Z - feet.Z;
+
+// // restoring force proportional to lack of posture:
+// float servo = (2.5f - posture) * POSTURE_SERVO;
+// d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f);
+// d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f);
+// //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
+// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
+// }
+
+ public override Vector3 Force
+ {
+ get { return _target_velocity; }
+ set { return; }
+ }
+
+ public override int VehicleType
+ {
+ get { return 0; }
+ set { return; }
+ }
+
+ public override void VehicleFloatParam(int param, float value)
+ {
+
+ }
+
+ public override void VehicleVectorParam(int param, Vector3 value)
+ {
+
+ }
+
+ public override void VehicleRotationParam(int param, Quaternion rotation)
+ {
+
+ }
+
+ public override void SetVolumeDetect(int param)
+ {
+
+ }
+
+ public override Vector3 CenterOfMass
+ {
+ get { return Vector3.Zero; }
+ }
+
+ public override Vector3 GeometricCenter
+ {
+ get { return Vector3.Zero; }
+ }
+
+ public override PrimitiveBaseShape Shape
+ {
+ set { return; }
+ }
+
+ public override Vector3 Velocity
+ {
+ get {
+ // There's a problem with Vector3.Zero! Don't Use it Here!
+ if (_zeroFlag)
+ return Vector3.Zero;
+ m_lastUpdateSent = false;
+ return _velocity;
+ }
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_pidControllerActive = true;
+ _target_velocity = value;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character");
+ }
+ }
+ }
+
+ public override Vector3 Torque
+ {
+ get { return Vector3.Zero; }
+ set { return; }
+ }
+
+ public override float CollisionScore
+ {
+ get { return 0f; }
+ set { }
+ }
+
+ public override bool Kinematic
+ {
+ get { return false; }
+ set { }
+ }
+
+ public override Quaternion Orientation
+ {
+ get { return Quaternion.Identity; }
+ set {
+ //Matrix3 or = Orientation.ToRotationMatrix();
+ //d.Matrix3 ord = new d.Matrix3(or.m00, or.m10, or.m20, or.m01, or.m11, or.m21, or.m02, or.m12, or.m22);
+ //d.BodySetRotation(Body, ref ord);
+ }
+ }
+
+ public override Vector3 Acceleration
+ {
+ get { return _acceleration; }
+ }
+
+ public void SetAcceleration(Vector3 accel)
+ {
+ m_pidControllerActive = true;
+ _acceleration = accel;
+ }
+
+ ///
+ /// Adds the force supplied to the Target Velocity
+ /// The PID controller takes this target velocity and tries to make it a reality
+ ///
+ ///
+ public override void AddForce(Vector3 force, bool pushforce)
+ {
+ if (force.IsFinite())
+ {
+ if (pushforce)
+ {
+ m_pidControllerActive = false;
+ force *= 100f;
+ doForce(force);
+ // If uncommented, things get pushed off world
+ //
+ // m_log.Debug("Push!");
+ // _target_velocity.X += force.X;
+ // _target_velocity.Y += force.Y;
+ // _target_velocity.Z += force.Z;
+ }
+ else
+ {
+ m_pidControllerActive = true;
+ _target_velocity.X += force.X;
+ _target_velocity.Y += force.Y;
+ _target_velocity.Z += force.Z;
+ }
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN force applied to a Character");
+ }
+ //m_lastUpdateSent = false;
+ }
+
+ public override void AddAngularForce(Vector3 force, bool pushforce)
+ {
+
+ }
+
+ ///
+ /// After all of the forces add up with 'add force' we apply them with doForce
+ ///
+ ///
+ public void doForce(Vector3 force)
+ {
+ if (!collidelock)
+ {
+ d.BodyAddForce(Body, force.X, force.Y, force.Z);
+ //d.BodySetRotation(Body, ref m_StandUpRotation);
+ //standupStraight();
+
+ }
+ }
+
+ public override void SetMomentum(Vector3 momentum)
+ {
+ }
+
+
+ ///
+ /// Called from Simulate
+ /// This is the avatar's movement control + PID Controller
+ ///
+ ///
+ public void Move(float timeStep, List defects)
+ {
+ // no lock; for now it's only called from within Simulate()
+
+ // If the PID Controller isn't active then we set our force
+ // calculating base velocity to the current position
+
+ if (Body == IntPtr.Zero)
+ return;
+
+ if (m_pidControllerActive == false)
+ {
+ _zeroPosition = d.BodyGetPosition(Body);
+ }
+ //PidStatus = true;
+
+ d.Vector3 localpos = d.BodyGetPosition(Body);
+ Vector3 localPos = new Vector3(localpos.X, localpos.Y, localpos.Z);
+
+ if (!localPos.IsFinite())
+ {
+
+ m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
+ defects.Add(this);
+ // _parent_scene.RemoveCharacter(this);
+
+ // destroy avatar capsule and related ODE data
+ if (Amotor != IntPtr.Zero)
+ {
+ // Kill the Amotor
+ d.JointDestroy(Amotor);
+ Amotor = IntPtr.Zero;
+ }
+
+ //kill the Geometry
+ _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+
+ if (Body != IntPtr.Zero)
+ {
+ //kill the body
+ d.BodyDestroy(Body);
+
+ Body = IntPtr.Zero;
+ }
+
+ if (Shell != IntPtr.Zero)
+ {
+ d.GeomDestroy(Shell);
+ _parent_scene.geom_name_map.Remove(Shell);
+ Shell = IntPtr.Zero;
+ }
+
+ return;
+ }
+
+ Vector3 vec = Vector3.Zero;
+ d.Vector3 vel = d.BodyGetLinearVel(Body);
+
+ float movementdivisor = 1f;
+
+ if (!m_alwaysRun)
+ {
+ movementdivisor = walkDivisor;
+ }
+ else
+ {
+ movementdivisor = runDivisor;
+ }
+
+ // if velocity is zero, use position control; otherwise, velocity control
+ if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f && m_iscolliding)
+ {
+ // keep track of where we stopped. No more slippin' & slidin'
+ if (!_zeroFlag)
+ {
+ _zeroFlag = true;
+ _zeroPosition = d.BodyGetPosition(Body);
+ }
+ if (m_pidControllerActive)
+ {
+ // We only want to deactivate the PID Controller if we think we want to have our surrogate
+ // react to the physics scene by moving it's position.
+ // Avatar to Avatar collisions
+ // Prim to avatar collisions
+
+ d.Vector3 pos = d.BodyGetPosition(Body);
+ vec.X = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
+ vec.Y = (_target_velocity.Y - vel.Y)*(PID_D) + (_zeroPosition.Y - pos.Y)* (PID_P * 2);
+ if (flying)
+ {
+ vec.Z = (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
+ }
+ }
+ //PidStatus = true;
+ }
+ else
+ {
+ m_pidControllerActive = true;
+ _zeroFlag = false;
+ if (m_iscolliding && !flying)
+ {
+ // We're standing on something
+ vec.X = ((_target_velocity.X / movementdivisor) - vel.X) * (PID_D);
+ vec.Y = ((_target_velocity.Y / movementdivisor) - vel.Y) * (PID_D);
+ }
+ else if (m_iscolliding && flying)
+ {
+ // We're flying and colliding with something
+ vec.X = ((_target_velocity.X/movementdivisor) - vel.X)*(PID_D / 16);
+ vec.Y = ((_target_velocity.Y/movementdivisor) - vel.Y)*(PID_D / 16);
+ }
+ else if (!m_iscolliding && flying)
+ {
+ // we're in mid air suspended
+ vec.X = ((_target_velocity.X / movementdivisor) - vel.X) * (PID_D/6);
+ vec.Y = ((_target_velocity.Y / movementdivisor) - vel.Y) * (PID_D/6);
+ }
+
+ if (m_iscolliding && !flying && _target_velocity.Z > 0.0f)
+ {
+ // We're colliding with something and we're not flying but we're moving
+ // This means we're walking or running.
+ d.Vector3 pos = d.BodyGetPosition(Body);
+ vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P;
+ if (_target_velocity.X > 0)
+ {
+ vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D;
+ }
+ if (_target_velocity.Y > 0)
+ {
+ vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D;
+ }
+ }
+ else if (!m_iscolliding && !flying)
+ {
+ // we're not colliding and we're not flying so that means we're falling!
+ // m_iscolliding includes collisions with the ground.
+
+ // d.Vector3 pos = d.BodyGetPosition(Body);
+ if (_target_velocity.X > 0)
+ {
+ vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D;
+ }
+ if (_target_velocity.Y > 0)
+ {
+ vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D;
+ }
+ }
+
+ if (flying)
+ {
+ vec.Z = (_target_velocity.Z - vel.Z) * (PID_D);
+ }
+ }
+ if (flying)
+ {
+ vec.Z += ((-1 * _parent_scene.gravityz)*m_mass);
+
+ //Added for auto fly height. Kitto Flora
+ //d.Vector3 pos = d.BodyGetPosition(Body);
+ float target_altitude = _parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + MinimumGroundFlightOffset;
+
+ if (_position.Z < target_altitude)
+ {
+ vec.Z += (target_altitude - _position.Z) * PID_P * 5.0f;
+ }
+ // end add Kitto Flora
+ }
+ if (vec.IsFinite())
+ {
+ doForce(vec);
+ if (!_zeroFlag)
+ {
+ AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
+ }
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN force vector in Move()");
+ m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
+ defects.Add(this);
+ // _parent_scene.RemoveCharacter(this);
+ // destroy avatar capsule and related ODE data
+ if (Amotor != IntPtr.Zero)
+ {
+ // Kill the Amotor
+ d.JointDestroy(Amotor);
+ Amotor = IntPtr.Zero;
+ }
+ //kill the Geometry
+ _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+
+ if (Body != IntPtr.Zero)
+ {
+ //kill the body
+ d.BodyDestroy(Body);
+
+ Body = IntPtr.Zero;
+ }
+
+ if (Shell != IntPtr.Zero)
+ {
+ d.GeomDestroy(Shell);
+ _parent_scene.geom_name_map.Remove(Shell);
+ Shell = IntPtr.Zero;
+ }
+ }
+ }
+
+ ///
+ /// Updates the reported position and velocity. This essentially sends the data up to ScenePresence.
+ ///
+ public void UpdatePositionAndVelocity()
+ {
+ // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
+ d.Vector3 vec;
+ try
+ {
+ vec = d.BodyGetPosition(Body);
+ }
+ catch (NullReferenceException)
+ {
+ bad = true;
+ _parent_scene.BadCharacter(this);
+ vec = new d.Vector3(_position.X, _position.Y, _position.Z);
+ base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
+ m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid);
+ }
+
+
+ // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
+ if (vec.X < 0.0f) vec.X = 0.0f;
+ if (vec.Y < 0.0f) vec.Y = 0.0f;
+ if (vec.X > (int)_parent_scene.WorldExtents.X - 0.05f) vec.X = (int)_parent_scene.WorldExtents.X - 0.05f;
+ if (vec.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) vec.Y = (int)_parent_scene.WorldExtents.Y - 0.05f;
+
+ _position.X = vec.X;
+ _position.Y = vec.Y;
+ _position.Z = vec.Z;
+
+ // Did we move last? = zeroflag
+ // This helps keep us from sliding all over
+
+ if (_zeroFlag)
+ {
+ _velocity.X = 0.0f;
+ _velocity.Y = 0.0f;
+ _velocity.Z = 0.0f;
+
+ // Did we send out the 'stopped' message?
+ if (!m_lastUpdateSent)
+ {
+ m_lastUpdateSent = true;
+ //base.RequestPhysicsterseUpdate();
+
+ }
+ }
+ else
+ {
+ m_lastUpdateSent = false;
+ try
+ {
+ vec = d.BodyGetLinearVel(Body);
+ }
+ catch (NullReferenceException)
+ {
+ vec.X = _velocity.X;
+ vec.Y = _velocity.Y;
+ vec.Z = _velocity.Z;
+ }
+ _velocity.X = (vec.X);
+ _velocity.Y = (vec.Y);
+
+ _velocity.Z = (vec.Z);
+
+ if (_velocity.Z < -6 && !m_hackSentFall)
+ {
+ m_hackSentFall = true;
+ m_pidControllerActive = false;
+ }
+ else if (flying && !m_hackSentFly)
+ {
+ //m_hackSentFly = true;
+ //base.SendCollisionUpdate(new CollisionEventUpdate());
+ }
+ else
+ {
+ m_hackSentFly = false;
+ m_hackSentFall = false;
+ }
+ }
+ }
+
+ ///
+ /// Cleanup the things we use in the scene.
+ ///
+ public void Destroy()
+ {
+ m_tainted_isPhysical = false;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+
+ public override void CrossingFailure()
+ {
+ }
+
+ public override Vector3 PIDTarget { set { return; } }
+ public override bool PIDActive { set { return; } }
+ public override float PIDTau { set { return; } }
+
+ public override float PIDHoverHeight { set { return; } }
+ public override bool PIDHoverActive { set { return; } }
+ public override PIDHoverType PIDHoverType { set { return; } }
+ public override float PIDHoverTau { set { return; } }
+
+ public override Quaternion APIDTarget{ set { return; } }
+
+ public override bool APIDActive{ set { return; } }
+
+ public override float APIDStrength{ set { return; } }
+
+ public override float APIDDamping{ set { return; } }
+
+
+ public override void SubscribeEvents(int ms)
+ {
+ m_requestedUpdateFrequency = ms;
+ m_eventsubscription = ms;
+ _parent_scene.addCollisionEventReporting(this);
+ }
+ public override void UnSubscribeEvents()
+ {
+ _parent_scene.remCollisionEventReporting(this);
+ m_requestedUpdateFrequency = 0;
+ m_eventsubscription = 0;
+ }
+ public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
+ {
+ if (m_eventsubscription > 0)
+ {
+ CollisionEventsThisFrame.addCollider(CollidedWith, contact);
+ }
+ }
+
+ public void SendCollisions()
+ {
+ if (m_eventsubscription > m_requestedUpdateFrequency)
+ {
+ if (CollisionEventsThisFrame != null)
+ {
+ base.SendCollisionUpdate(CollisionEventsThisFrame);
+ }
+ CollisionEventsThisFrame = new CollisionEventUpdate();
+ m_eventsubscription = 0;
+ }
+ }
+ public override bool SubscribedEvents()
+ {
+ if (m_eventsubscription > 0)
+ return true;
+ return false;
+ }
+
+ public void ProcessTaints(float timestep)
+ {
+
+ if (m_tainted_isPhysical != m_isPhysical)
+ {
+ if (m_tainted_isPhysical)
+ {
+ // Create avatar capsule and related ODE data
+ if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
+ {
+ m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - "
+ + (Shell!=IntPtr.Zero ? "Shell ":"")
+ + (Body!=IntPtr.Zero ? "Body ":"")
+ + (Amotor!=IntPtr.Zero ? "Amotor ":""));
+ }
+ AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
+
+ _parent_scene.geom_name_map[Shell] = m_name;
+ _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+ _parent_scene.AddCharacter(this);
+ }
+ else
+ {
+ _parent_scene.RemoveCharacter(this);
+ // destroy avatar capsule and related ODE data
+ if (Amotor != IntPtr.Zero)
+ {
+ // Kill the Amotor
+ d.JointDestroy(Amotor);
+ Amotor = IntPtr.Zero;
+ }
+ //kill the Geometry
+ _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+
+ if (Body != IntPtr.Zero)
+ {
+ //kill the body
+ d.BodyDestroy(Body);
+
+ Body = IntPtr.Zero;
+ }
+
+ if (Shell != IntPtr.Zero)
+ {
+ d.GeomDestroy(Shell);
+ _parent_scene.geom_name_map.Remove(Shell);
+ Shell = IntPtr.Zero;
+ }
+
+ }
+
+ m_isPhysical = m_tainted_isPhysical;
+ }
+
+ if (m_tainted_CAPSULE_LENGTH != CAPSULE_LENGTH)
+ {
+ if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero)
+ {
+
+ m_pidControllerActive = true;
+ // no lock needed on _parent_scene.OdeLock because we are called from within the thread lock in OdePlugin's simulate()
+ d.JointDestroy(Amotor);
+ float prevCapsule = CAPSULE_LENGTH;
+ CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH;
+ //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
+ d.BodyDestroy(Body);
+ d.GeomDestroy(Shell);
+ AvatarGeomAndBodyCreation(_position.X, _position.Y,
+ _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
+ Velocity = Vector3.Zero;
+
+ _parent_scene.geom_name_map[Shell] = m_name;
+ _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - "
+ + (Shell==IntPtr.Zero ? "Shell ":"")
+ + (Body==IntPtr.Zero ? "Body ":"")
+ + (Amotor==IntPtr.Zero ? "Amotor ":""));
+ }
+ }
+
+ if (!m_taintPosition.ApproxEquals(_position, 0.05f))
+ {
+ if (Body != IntPtr.Zero)
+ {
+ d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z);
+
+ _position.X = m_taintPosition.X;
+ _position.Y = m_taintPosition.Y;
+ _position.Z = m_taintPosition.Z;
+ }
+ }
+
+ }
+
+ internal void AddCollisionFrameTime(int p)
+ {
+ // protect it from overflow crashing
+ if (m_eventsubscription + p >= int.MaxValue)
+ m_eventsubscription = 0;
+ m_eventsubscription += p;
+ }
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.c_comments b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.c_comments
new file mode 100644
index 0000000..1060aa6
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.c_comments
@@ -0,0 +1,630 @@
+/*
+ * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
+ * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
+ * ODEPrim.cs contains methods dealing with Prim editing, Prim
+ * characteristics and Kinetic motion.
+ * ODEDynamics.cs contains methods dealing with Prim Physical motion
+ * (dynamics) and the associated settings. Old Linear and angular
+ * motors for dynamic motion have been replace with MoveLinear()
+ * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
+ * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
+ * switch between 'VEHICLE' parameter use and general dynamics
+ * settings use.
+ *
+ * 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.Reflection;
+using System.Runtime.InteropServices;
+using log4net;
+using OpenMetaverse;
+using Ode.NET;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ public class ODEDynamics
+ {
+ public Vehicle Type
+ {
+ get { return m_type; }
+ }
+
+ public IntPtr Body
+ {
+ get { return m_body; }
+ }
+
+ private int frcount = 0; // Used to limit dynamics debug output to
+ // every 100th frame
+
+ // private OdeScene m_parentScene = null;
+ private IntPtr m_body = IntPtr.Zero;
+ private IntPtr m_jointGroup = IntPtr.Zero;
+ private IntPtr m_aMotor = IntPtr.Zero;
+
+
+ // Vehicle properties
+ private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind
+ // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier
+ private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings:
+ // HOVER_TERRAIN_ONLY
+ // HOVER_GLOBAL_HEIGHT
+ // NO_DEFLECTION_UP
+ // HOVER_WATER_ONLY
+ // HOVER_UP_ONLY
+ // LIMIT_MOTOR_UP
+ // LIMIT_ROLL_ONLY
+
+ // Linear properties
+ private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time
+ private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL
+ private Vector3 m_dir = Vector3.Zero; // velocity applied to body
+ private Vector3 m_linearFrictionTimescale = Vector3.Zero;
+ private float m_linearMotorDecayTimescale = 0;
+ private float m_linearMotorTimescale = 0;
+ private Vector3 m_lastLinearVelocityVector = Vector3.Zero;
+ // private bool m_LinearMotorSetLastFrame = false;
+ // private Vector3 m_linearMotorOffset = Vector3.Zero;
+
+ //Angular properties
+ private Vector3 m_angularMotorDirection = Vector3.Zero;
+ private Vector3 m_angularMotorDirectionLASTSET = Vector3.Zero;
+ private Vector3 m_angularFrictionTimescale = Vector3.Zero;
+ private float m_angularMotorDecayTimescale = 0;
+ private float m_angularMotorTimescale = 0;
+ private Vector3 m_lastAngularVelocityVector = Vector3.Zero;
+
+ //Deflection properties
+ // private float m_angularDeflectionEfficiency = 0;
+ // private float m_angularDeflectionTimescale = 0;
+ // private float m_linearDeflectionEfficiency = 0;
+ // private float m_linearDeflectionTimescale = 0;
+
+ //Banking properties
+ // private float m_bankingEfficiency = 0;
+ // private float m_bankingMix = 0;
+ // private float m_bankingTimescale = 0;
+
+ //Hover and Buoyancy properties
+ private float m_VhoverHeight = 0f;
+ private float m_VhoverEfficiency = 0f;
+ private float m_VhoverTimescale = 0f;
+ private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
+ private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle.
+ // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
+ // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
+ // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.
+
+ //Attractor properties
+ private float m_verticalAttractionEfficiency = 0;
+ private float m_verticalAttractionTimescale = 0;
+
+
+
+
+
+ internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
+ {
+ switch (pParam)
+ {
+ case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_angularDeflectionEfficiency = pValue;
+ break;
+ case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_angularDeflectionTimescale = pValue;
+ break;
+ case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_angularMotorDecayTimescale = pValue;
+ break;
+ case Vehicle.ANGULAR_MOTOR_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_angularMotorTimescale = pValue;
+ break;
+ case Vehicle.BANKING_EFFICIENCY:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_bankingEfficiency = pValue;
+ break;
+ case Vehicle.BANKING_MIX:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_bankingMix = pValue;
+ break;
+ case Vehicle.BANKING_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_bankingTimescale = pValue;
+ break;
+ case Vehicle.BUOYANCY:
+ if (pValue < -1f) pValue = -1f;
+ if (pValue > 1f) pValue = 1f;
+ m_VehicleBuoyancy = pValue;
+ break;
+ case Vehicle.HOVER_EFFICIENCY:
+ if (pValue < 0f) pValue = 0f;
+ if (pValue > 1f) pValue = 1f;
+ m_VhoverEfficiency = pValue;
+ break;
+ case Vehicle.HOVER_HEIGHT:
+ m_VhoverHeight = pValue;
+ break;
+ case Vehicle.HOVER_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_VhoverTimescale = pValue;
+ break;
+ case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_linearDeflectionEfficiency = pValue;
+ break;
+ case Vehicle.LINEAR_DEFLECTION_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_linearDeflectionTimescale = pValue;
+ break;
+ case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_linearMotorDecayTimescale = pValue;
+ break;
+ case Vehicle.LINEAR_MOTOR_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_linearMotorTimescale = pValue;
+ break;
+ case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
+ if (pValue < 0.0f) pValue = 0.0f;
+ if (pValue > 1.0f) pValue = 1.0f;
+ m_verticalAttractionEfficiency = pValue;
+ break;
+ case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_verticalAttractionTimescale = pValue;
+ break;
+
+ // These are vector properties but the engine lets you use a single float value to
+ // set all of the components to the same value
+ case Vehicle.ANGULAR_FRICTION_TIMESCALE:
+ m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue);
+ break;
+ case Vehicle.ANGULAR_MOTOR_DIRECTION:
+ m_angularMotorDirection = new Vector3(pValue, pValue, pValue);
+ m_angularMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue);
+ break;
+ case Vehicle.LINEAR_FRICTION_TIMESCALE:
+ m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue);
+ break;
+ case Vehicle.LINEAR_MOTOR_DIRECTION:
+ m_linearMotorDirection = new Vector3(pValue, pValue, pValue);
+ m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue);
+ break;
+ case Vehicle.LINEAR_MOTOR_OFFSET:
+ // m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
+ break;
+
+ }
+
+ }//end ProcessFloatVehicleParam
+
+ internal void ProcessVectorVehicleParam(Vehicle pParam, PhysicsVector pValue)
+ {
+ switch (pParam)
+ {
+ case Vehicle.ANGULAR_FRICTION_TIMESCALE:
+ m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ case Vehicle.ANGULAR_MOTOR_DIRECTION:
+ m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ m_angularMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ case Vehicle.LINEAR_FRICTION_TIMESCALE:
+ m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ case Vehicle.LINEAR_MOTOR_DIRECTION:
+ m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ case Vehicle.LINEAR_MOTOR_OFFSET:
+ // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ }
+
+ }//end ProcessVectorVehicleParam
+
+ internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue)
+ {
+ switch (pParam)
+ {
+ case Vehicle.REFERENCE_FRAME:
+ // m_referenceFrame = pValue;
+ break;
+ }
+
+ }//end ProcessRotationVehicleParam
+
+ internal void ProcessTypeChange(Vehicle pType)
+ {
+Console.WriteLine("ProcessTypeChange to " + pType);
+
+ // Set Defaults For Type
+ m_type = pType;
+ switch (pType)
+ {
+ case Vehicle.TYPE_SLED:
+ m_linearFrictionTimescale = new Vector3(30, 1, 1000);
+ m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 1000;
+ m_linearMotorDecayTimescale = 120;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 1000;
+ m_angularMotorDecayTimescale = 120;
+ m_VhoverHeight = 0;
+ m_VhoverEfficiency = 1;
+ m_VhoverTimescale = 10;
+ m_VehicleBuoyancy = 0;
+ // m_linearDeflectionEfficiency = 1;
+ // m_linearDeflectionTimescale = 1;
+ // m_angularDeflectionEfficiency = 1;
+ // m_angularDeflectionTimescale = 1000;
+ // m_bankingEfficiency = 0;
+ // m_bankingMix = 1;
+ // m_bankingTimescale = 10;
+ // m_referenceFrame = Quaternion.Identity;
+ 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);
+ m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 1;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 1;
+ m_angularMotorDecayTimescale = 0.8f;
+ m_VhoverHeight = 0;
+ m_VhoverEfficiency = 0;
+ m_VhoverTimescale = 1000;
+ m_VehicleBuoyancy = 0;
+ // // m_linearDeflectionEfficiency = 1;
+ // // m_linearDeflectionTimescale = 2;
+ // // m_angularDeflectionEfficiency = 0;
+ // m_angularDeflectionTimescale = 10;
+ m_verticalAttractionEfficiency = 1;
+ m_verticalAttractionTimescale = 10;
+ // m_bankingEfficiency = -0.2f;
+ // m_bankingMix = 1;
+ // m_bankingTimescale = 1;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
+ m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_UP_ONLY |
+ VehicleFlag.LIMIT_MOTOR_UP);
+ break;
+ case Vehicle.TYPE_BOAT:
+ m_linearFrictionTimescale = new Vector3(10, 3, 2);
+ m_angularFrictionTimescale = new Vector3(10,10,10);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 5;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 4;
+ m_angularMotorDecayTimescale = 4;
+ m_VhoverHeight = 0;
+ m_VhoverEfficiency = 0.5f;
+ m_VhoverTimescale = 2;
+ m_VehicleBuoyancy = 1;
+ // m_linearDeflectionEfficiency = 0.5f;
+ // m_linearDeflectionTimescale = 3;
+ // m_angularDeflectionEfficiency = 0.5f;
+ // m_angularDeflectionTimescale = 5;
+ m_verticalAttractionEfficiency = 0.5f;
+ m_verticalAttractionTimescale = 5;
+ // m_bankingEfficiency = -0.3f;
+ // m_bankingMix = 0.8f;
+ // m_bankingTimescale = 1;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.LIMIT_ROLL_ONLY |
+ VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
+ m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY |
+ VehicleFlag.LIMIT_MOTOR_UP);
+ break;
+ case Vehicle.TYPE_AIRPLANE:
+ m_linearFrictionTimescale = new Vector3(200, 10, 5);
+ m_angularFrictionTimescale = new Vector3(20, 20, 20);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 2;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 4;
+ m_angularMotorDecayTimescale = 4;
+ m_VhoverHeight = 0;
+ m_VhoverEfficiency = 0.5f;
+ m_VhoverTimescale = 1000;
+ m_VehicleBuoyancy = 0;
+ // m_linearDeflectionEfficiency = 0.5f;
+ // m_linearDeflectionTimescale = 3;
+ // m_angularDeflectionEfficiency = 1;
+ // m_angularDeflectionTimescale = 2;
+ m_verticalAttractionEfficiency = 0.9f;
+ m_verticalAttractionTimescale = 2;
+ // m_bankingEfficiency = 1;
+ // m_bankingMix = 0.7f;
+ // m_bankingTimescale = 2;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
+ VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
+ m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
+ break;
+ case Vehicle.TYPE_BALLOON:
+ m_linearFrictionTimescale = new Vector3(5, 5, 5);
+ m_angularFrictionTimescale = new Vector3(10, 10, 10);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 5;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 6;
+ m_angularMotorDecayTimescale = 10;
+ m_VhoverHeight = 5;
+ m_VhoverEfficiency = 0.8f;
+ m_VhoverTimescale = 10;
+ m_VehicleBuoyancy = 1;
+ // m_linearDeflectionEfficiency = 0;
+ // m_linearDeflectionTimescale = 5;
+ // m_angularDeflectionEfficiency = 0;
+ // m_angularDeflectionTimescale = 5;
+ m_verticalAttractionEfficiency = 1;
+ m_verticalAttractionTimescale = 1000;
+ // m_bankingEfficiency = 0;
+ // m_bankingMix = 0.7f;
+ // m_bankingTimescale = 5;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
+ VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
+ m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
+ break;
+
+ }
+ }//end SetDefaultsForType
+
+ internal void Enable(IntPtr pBody, OdeScene pParentScene)
+ {
+//Console.WriteLine("Enable m_type=" + m_type + " m_VehicleBuoyancy=" + m_VehicleBuoyancy);
+ if (m_type == Vehicle.TYPE_NONE)
+ return;
+
+ m_body = pBody;
+ //KF: This used to set up the linear and angular joints
+ }
+
+ internal void Step(float pTimestep, OdeScene pParentScene)
+ {
+ if (m_body == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
+ return;
+ frcount++; // used to limit debug comment output
+ if (frcount > 100)
+ frcount = 0;
+
+ MoveLinear(pTimestep, pParentScene);
+ MoveAngular(pTimestep);
+ }// end Step
+
+ private void MoveLinear(float pTimestep, OdeScene _pParentScene)
+ {
+ if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant
+ {
+ if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body);
+
+ // add drive to body
+ Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
+ m_lastLinearVelocityVector += (addAmount*10); // lastLinearVelocityVector is the current body velocity vector?
+
+ // This will work temporarily, but we really need to compare speed on an axis
+ // KF: Limit body velocity to applied velocity?
+ if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X))
+ m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X;
+ if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirectionLASTSET.Y))
+ m_lastLinearVelocityVector.Y = m_linearMotorDirectionLASTSET.Y;
+ if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z))
+ m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z;
+
+ // decay applied velocity
+ Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep)));
+ //Console.WriteLine("decay: " + decayfraction);
+ m_linearMotorDirection -= m_linearMotorDirection * decayfraction;
+ //Console.WriteLine("actual: " + m_linearMotorDirection);
+ }
+ else
+ { // requested is not significant
+ // if what remains of applied is small, zero it.
+ if (m_lastLinearVelocityVector.ApproxEquals(Vector3.Zero, 0.01f))
+ m_lastLinearVelocityVector = Vector3.Zero;
+ }
+
+
+ // convert requested object velocity to world-referenced vector
+ m_dir = m_lastLinearVelocityVector;
+ d.Quaternion rot = d.BodyGetQuaternion(Body);
+ Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
+ m_dir *= rotq; // apply obj rotation to velocity vector
+
+ // add Gravity andBuoyancy
+ // KF: So far I have found no good method to combine a script-requested
+ // .Z velocity and gravity. Therefore only 0g will used script-requested
+ // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
+ Vector3 grav = Vector3.Zero;
+ if(m_VehicleBuoyancy < 1.0f)
+ {
+ // There is some gravity, make a gravity force vector
+ // that is applied after object velocity.
+ d.Mass objMass;
+ d.BodyGetMass(Body, out objMass);
+ // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
+ grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy);
+ // Preserve the current Z velocity
+ d.Vector3 vel_now = d.BodyGetLinearVel(Body);
+ m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
+ } // else its 1.0, no gravity.
+
+ // Check if hovering
+ if( (m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0)
+ {
+ // We should hover, get the target height
+ d.Vector3 pos = d.BodyGetPosition(Body);
+ if((m_flags & VehicleFlag.HOVER_WATER_ONLY) == VehicleFlag.HOVER_WATER_ONLY)
+ {
+ m_VhoverTargetHeight = _pParentScene.GetWaterLevel() + m_VhoverHeight;
+ }
+ else if((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) == VehicleFlag.HOVER_TERRAIN_ONLY)
+ {
+ m_VhoverTargetHeight = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight;
+ }
+ else if((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == VehicleFlag.HOVER_GLOBAL_HEIGHT)
+ {
+ m_VhoverTargetHeight = m_VhoverHeight;
+ }
+
+ if((m_flags & VehicleFlag.HOVER_UP_ONLY) == VehicleFlag.HOVER_UP_ONLY)
+ {
+ // If body is aready heigher, use its height as target height
+ if(pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z;
+ }
+
+// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped
+// m_VhoverTimescale = 0f; // time to acheive height
+// pTimestep is time since last frame,in secs
+ float herr0 = pos.Z - m_VhoverTargetHeight;
+//if(frcount == 0) Console.WriteLine("herr0=" + herr0);
+ // Replace Vertical speed with correction figure if significant
+ if(Math.Abs(herr0) > 0.01f )
+ {
+ d.Mass objMass;
+ d.BodyGetMass(Body, out objMass);
+ m_dir.Z = - ( (herr0 * pTimestep * 50.0f) / m_VhoverTimescale);
+ // m_VhoverEfficiency is not yet implemented
+ }
+ else
+ {
+ m_dir.Z = 0f;
+ }
+ }
+
+ // Apply velocity
+ d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z);
+//if(frcount == 0) Console.WriteLine("Move " + Body + ":"+ m_dir.X + " " + m_dir.Y + " " + m_dir.Z);
+ // apply gravity force
+ d.BodyAddForce(Body, grav.X, grav.Y, grav.Z);
+//if(frcount == 0) Console.WriteLine("Force " + Body + ":" + grav.X + " " + grav.Y + " " + grav.Z);
+
+
+ // apply friction
+ Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
+ m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
+ } // end MoveLinear()
+
+ private void MoveAngular(float pTimestep)
+ {
+
+ // m_angularMotorDirection is the latest value from the script, and is decayed here
+ // m_angularMotorDirectionLASTSET is the latest value from the script
+ // m_lastAngularVelocityVector is what is being applied to the Body, varied up and down here
+
+ if (!m_angularMotorDirection.ApproxEquals(Vector3.Zero, 0.01f))
+ {
+ if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body);
+ // ramp up to new value
+ Vector3 addAmount = m_angularMotorDirection / (m_angularMotorTimescale / pTimestep);
+ m_lastAngularVelocityVector += (addAmount * 10f);
+//if(frcount == 0) Console.WriteLine("add: " + addAmount);
+
+ // limit applied value to what was set by script
+ // This will work temporarily, but we really need to compare speed on an axis
+ if (Math.Abs(m_lastAngularVelocityVector.X) > Math.Abs(m_angularMotorDirectionLASTSET.X))
+ m_lastAngularVelocityVector.X = m_angularMotorDirectionLASTSET.X;
+ if (Math.Abs(m_lastAngularVelocityVector.Y) > Math.Abs(m_angularMotorDirectionLASTSET.Y))
+ m_lastAngularVelocityVector.Y = m_angularMotorDirectionLASTSET.Y;
+ if (Math.Abs(m_lastAngularVelocityVector.Z) > Math.Abs(m_angularMotorDirectionLASTSET.Z))
+ m_lastAngularVelocityVector.Z = m_angularMotorDirectionLASTSET.Z;
+
+ // decay the requested value
+ Vector3 decayfraction = ((Vector3.One / (m_angularMotorDecayTimescale / pTimestep)));
+ //Console.WriteLine("decay: " + decayfraction);
+ m_angularMotorDirection -= m_angularMotorDirection * decayfraction;
+ //Console.WriteLine("actual: " + m_linearMotorDirection);
+ }
+ // KF: m_lastAngularVelocityVector is rotational speed in rad/sec ?
+
+ // Vertical attractor section
+
+// d.Mass objMass;
+// d.BodyGetMass(Body, out objMass);
+// float servo = 100f * objMass.mass * m_verticalAttractionEfficiency / (m_verticalAttractionTimescale * pTimestep);
+ float servo = 0.1f * m_verticalAttractionEfficiency / (m_verticalAttractionTimescale * pTimestep);
+ // get present body rotation
+ d.Quaternion rot = d.BodyGetQuaternion(Body);
+ Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
+ // make a vector pointing up
+ Vector3 verterr = Vector3.Zero;
+ verterr.Z = 1.0f;
+ // rotate it to Body Angle
+ verterr = verterr * rotq;
+ // verterr.X and .Y are the World error ammounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1.
+ // As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go
+ // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body.
+ if (verterr.Z < 0.0f)
+ {
+ verterr.X = 2.0f - verterr.X;
+ verterr.Y = 2.0f - verterr.Y;
+ }
+ // Error is 0 (no error) to +/- 2 (max error)
+ // scale it by servo
+ verterr = verterr * servo;
+
+ // rotate to object frame
+ // verterr = verterr * rotq;
+
+ // As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so
+ // Change Body angular velocity X based on Y, and Y based on X. Z is not changed.
+ m_lastAngularVelocityVector.X += verterr.Y;
+ m_lastAngularVelocityVector.Y -= verterr.X;
+/*
+if(frcount == 0)
+ {
+// Console.WriteLine("AngleMotor " + m_lastAngularVelocityVector);
+ Console.WriteLine(String.Format("VA Body:{0} servo:{1} err:<{2},{3},{4}> VAE:{5}",
+ Body, servo, verterr.X, verterr.Y, verterr.Z, m_verticalAttractionEfficiency));
+ }
+ */
+ d.BodySetAngularVel (Body, m_lastAngularVelocityVector.X, m_lastAngularVelocityVector.Y, m_lastAngularVelocityVector.Z);
+ // apply friction
+ Vector3 decayamount = Vector3.One / (m_angularFrictionTimescale / pTimestep);
+ m_lastAngularVelocityVector -= m_lastAngularVelocityVector * decayamount;
+
+ } //end MoveAngular
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
new file mode 100644
index 0000000..78b15be
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
@@ -0,0 +1,673 @@
+/*
+ * 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.
+ *
+ * Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
+ * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
+ * ODEPrim.cs contains methods dealing with Prim editing, Prim
+ * characteristics and Kinetic motion.
+ * ODEDynamics.cs contains methods dealing with Prim Physical motion
+ * (dynamics) and the associated settings. Old Linear and angular
+ * motors for dynamic motion have been replace with MoveLinear()
+ * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
+ * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
+ * switch between 'VEHICLE' parameter use and general dynamics
+ * settings use.
+ *
+ */
+
+/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
+ * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
+ * ODEPrim.cs contains methods dealing with Prim editing, Prim
+ * characteristics and Kinetic motion.
+ * ODEDynamics.cs contains methods dealing with Prim Physical motion
+ * (dynamics) and the associated settings. Old Linear and angular
+ * motors for dynamic motion have been replace with MoveLinear()
+ * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
+ * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
+ * switch between 'VEHICLE' parameter use and general dynamics
+ * settings use.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using log4net;
+using OpenMetaverse;
+using Ode.NET;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ public class ODEDynamics
+ {
+ public Vehicle Type
+ {
+ get { return m_type; }
+ }
+
+ public IntPtr Body
+ {
+ get { return m_body; }
+ }
+
+ private int frcount = 0; // Used to limit dynamics debug output to
+ // every 100th frame
+
+ // private OdeScene m_parentScene = null;
+ private IntPtr m_body = IntPtr.Zero;
+// private IntPtr m_jointGroup = IntPtr.Zero;
+// private IntPtr m_aMotor = IntPtr.Zero;
+
+
+ // Vehicle properties
+ private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind
+ // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier
+ private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings:
+ // HOVER_TERRAIN_ONLY
+ // HOVER_GLOBAL_HEIGHT
+ // NO_DEFLECTION_UP
+ // HOVER_WATER_ONLY
+ // HOVER_UP_ONLY
+ // LIMIT_MOTOR_UP
+ // LIMIT_ROLL_ONLY
+
+ // Linear properties
+ private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time
+ private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL
+ private Vector3 m_dir = Vector3.Zero; // velocity applied to body
+ private Vector3 m_linearFrictionTimescale = Vector3.Zero;
+ private float m_linearMotorDecayTimescale = 0;
+ private float m_linearMotorTimescale = 0;
+ private Vector3 m_lastLinearVelocityVector = Vector3.Zero;
+ // private bool m_LinearMotorSetLastFrame = false;
+ // private Vector3 m_linearMotorOffset = Vector3.Zero;
+
+ //Angular properties
+ private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor
+ private int m_angularMotorApply = 0; // application frame counter
+ private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity
+ private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate
+ private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate
+ private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
+ private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
+ // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body
+
+ //Deflection properties
+ // private float m_angularDeflectionEfficiency = 0;
+ // private float m_angularDeflectionTimescale = 0;
+ // private float m_linearDeflectionEfficiency = 0;
+ // private float m_linearDeflectionTimescale = 0;
+
+ //Banking properties
+ // private float m_bankingEfficiency = 0;
+ // private float m_bankingMix = 0;
+ // private float m_bankingTimescale = 0;
+
+ //Hover and Buoyancy properties
+ private float m_VhoverHeight = 0f;
+// private float m_VhoverEfficiency = 0f;
+ private float m_VhoverTimescale = 0f;
+ private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
+ private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle.
+ // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
+ // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
+ // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.
+
+ //Attractor properties
+ private float m_verticalAttractionEfficiency = 1.0f; // damped
+ private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
+
+
+
+
+
+ internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
+ {
+ switch (pParam)
+ {
+ case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_angularDeflectionEfficiency = pValue;
+ break;
+ case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_angularDeflectionTimescale = pValue;
+ break;
+ case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_angularMotorDecayTimescale = pValue;
+ break;
+ case Vehicle.ANGULAR_MOTOR_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_angularMotorTimescale = pValue;
+ break;
+ case Vehicle.BANKING_EFFICIENCY:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_bankingEfficiency = pValue;
+ break;
+ case Vehicle.BANKING_MIX:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_bankingMix = pValue;
+ break;
+ case Vehicle.BANKING_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_bankingTimescale = pValue;
+ break;
+ case Vehicle.BUOYANCY:
+ if (pValue < -1f) pValue = -1f;
+ if (pValue > 1f) pValue = 1f;
+ m_VehicleBuoyancy = pValue;
+ break;
+// case Vehicle.HOVER_EFFICIENCY:
+// if (pValue < 0f) pValue = 0f;
+// if (pValue > 1f) pValue = 1f;
+// m_VhoverEfficiency = pValue;
+// break;
+ case Vehicle.HOVER_HEIGHT:
+ m_VhoverHeight = pValue;
+ break;
+ case Vehicle.HOVER_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_VhoverTimescale = pValue;
+ break;
+ case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_linearDeflectionEfficiency = pValue;
+ break;
+ case Vehicle.LINEAR_DEFLECTION_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ // m_linearDeflectionTimescale = pValue;
+ break;
+ case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_linearMotorDecayTimescale = pValue;
+ break;
+ case Vehicle.LINEAR_MOTOR_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_linearMotorTimescale = pValue;
+ break;
+ case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
+ if (pValue < 0.1f) pValue = 0.1f; // Less goes unstable
+ if (pValue > 1.0f) pValue = 1.0f;
+ m_verticalAttractionEfficiency = pValue;
+ break;
+ case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
+ if (pValue < 0.01f) pValue = 0.01f;
+ m_verticalAttractionTimescale = pValue;
+ break;
+
+ // These are vector properties but the engine lets you use a single float value to
+ // set all of the components to the same value
+ case Vehicle.ANGULAR_FRICTION_TIMESCALE:
+ m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue);
+ break;
+ case Vehicle.ANGULAR_MOTOR_DIRECTION:
+ m_angularMotorDirection = new Vector3(pValue, pValue, pValue);
+ m_angularMotorApply = 10;
+ break;
+ case Vehicle.LINEAR_FRICTION_TIMESCALE:
+ m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue);
+ break;
+ case Vehicle.LINEAR_MOTOR_DIRECTION:
+ m_linearMotorDirection = new Vector3(pValue, pValue, pValue);
+ m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue);
+ break;
+ case Vehicle.LINEAR_MOTOR_OFFSET:
+ // m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
+ break;
+
+ }
+
+ }//end ProcessFloatVehicleParam
+
+ internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue)
+ {
+ switch (pParam)
+ {
+ case Vehicle.ANGULAR_FRICTION_TIMESCALE:
+ m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ case Vehicle.ANGULAR_MOTOR_DIRECTION:
+ m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ // Limit requested angular speed to 2 rps= 4 pi rads/sec
+ if(m_angularMotorDirection.X > 12.56f) m_angularMotorDirection.X = 12.56f;
+ if(m_angularMotorDirection.X < - 12.56f) m_angularMotorDirection.X = - 12.56f;
+ if(m_angularMotorDirection.Y > 12.56f) m_angularMotorDirection.Y = 12.56f;
+ if(m_angularMotorDirection.Y < - 12.56f) m_angularMotorDirection.Y = - 12.56f;
+ if(m_angularMotorDirection.Z > 12.56f) m_angularMotorDirection.Z = 12.56f;
+ if(m_angularMotorDirection.Z < - 12.56f) m_angularMotorDirection.Z = - 12.56f;
+ m_angularMotorApply = 10;
+ break;
+ case Vehicle.LINEAR_FRICTION_TIMESCALE:
+ m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ case Vehicle.LINEAR_MOTOR_DIRECTION:
+ m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ case Vehicle.LINEAR_MOTOR_OFFSET:
+ // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ break;
+ }
+
+ }//end ProcessVectorVehicleParam
+
+ internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue)
+ {
+ switch (pParam)
+ {
+ case Vehicle.REFERENCE_FRAME:
+ // m_referenceFrame = pValue;
+ break;
+ }
+
+ }//end ProcessRotationVehicleParam
+
+ internal void ProcessTypeChange(Vehicle pType)
+ {
+ // Set Defaults For Type
+ m_type = pType;
+ switch (pType)
+ {
+ case Vehicle.TYPE_SLED:
+ m_linearFrictionTimescale = new Vector3(30, 1, 1000);
+ m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 1000;
+ m_linearMotorDecayTimescale = 120;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 1000;
+ m_angularMotorDecayTimescale = 120;
+ m_VhoverHeight = 0;
+// m_VhoverEfficiency = 1;
+ m_VhoverTimescale = 10;
+ m_VehicleBuoyancy = 0;
+ // m_linearDeflectionEfficiency = 1;
+ // m_linearDeflectionTimescale = 1;
+ // m_angularDeflectionEfficiency = 1;
+ // m_angularDeflectionTimescale = 1000;
+ // m_bankingEfficiency = 0;
+ // m_bankingMix = 1;
+ // m_bankingTimescale = 10;
+ // m_referenceFrame = Quaternion.Identity;
+ 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);
+ m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 1;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 1;
+ m_angularMotorDecayTimescale = 0.8f;
+ m_VhoverHeight = 0;
+// m_VhoverEfficiency = 0;
+ m_VhoverTimescale = 1000;
+ m_VehicleBuoyancy = 0;
+ // // m_linearDeflectionEfficiency = 1;
+ // // m_linearDeflectionTimescale = 2;
+ // // m_angularDeflectionEfficiency = 0;
+ // m_angularDeflectionTimescale = 10;
+ m_verticalAttractionEfficiency = 1f;
+ m_verticalAttractionTimescale = 10f;
+ // m_bankingEfficiency = -0.2f;
+ // m_bankingMix = 1;
+ // m_bankingTimescale = 1;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
+ m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_UP_ONLY |
+ VehicleFlag.LIMIT_MOTOR_UP);
+ break;
+ case Vehicle.TYPE_BOAT:
+ m_linearFrictionTimescale = new Vector3(10, 3, 2);
+ m_angularFrictionTimescale = new Vector3(10,10,10);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 5;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 4;
+ m_angularMotorDecayTimescale = 4;
+ m_VhoverHeight = 0;
+// m_VhoverEfficiency = 0.5f;
+ m_VhoverTimescale = 2;
+ m_VehicleBuoyancy = 1;
+ // m_linearDeflectionEfficiency = 0.5f;
+ // m_linearDeflectionTimescale = 3;
+ // m_angularDeflectionEfficiency = 0.5f;
+ // m_angularDeflectionTimescale = 5;
+ m_verticalAttractionEfficiency = 0.5f;
+ m_verticalAttractionTimescale = 5f;
+ // m_bankingEfficiency = -0.3f;
+ // m_bankingMix = 0.8f;
+ // m_bankingTimescale = 1;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.LIMIT_ROLL_ONLY |
+ VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
+ m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY |
+ VehicleFlag.LIMIT_MOTOR_UP);
+ break;
+ case Vehicle.TYPE_AIRPLANE:
+ m_linearFrictionTimescale = new Vector3(200, 10, 5);
+ m_angularFrictionTimescale = new Vector3(20, 20, 20);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 2;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 4;
+ m_angularMotorDecayTimescale = 4;
+ m_VhoverHeight = 0;
+// m_VhoverEfficiency = 0.5f;
+ m_VhoverTimescale = 1000;
+ m_VehicleBuoyancy = 0;
+ // m_linearDeflectionEfficiency = 0.5f;
+ // m_linearDeflectionTimescale = 3;
+ // m_angularDeflectionEfficiency = 1;
+ // m_angularDeflectionTimescale = 2;
+ m_verticalAttractionEfficiency = 0.9f;
+ m_verticalAttractionTimescale = 2f;
+ // m_bankingEfficiency = 1;
+ // m_bankingMix = 0.7f;
+ // m_bankingTimescale = 2;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
+ VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
+ m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
+ break;
+ case Vehicle.TYPE_BALLOON:
+ m_linearFrictionTimescale = new Vector3(5, 5, 5);
+ m_angularFrictionTimescale = new Vector3(10, 10, 10);
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorTimescale = 5;
+ m_linearMotorDecayTimescale = 60;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorTimescale = 6;
+ m_angularMotorDecayTimescale = 10;
+ m_VhoverHeight = 5;
+// m_VhoverEfficiency = 0.8f;
+ m_VhoverTimescale = 10;
+ m_VehicleBuoyancy = 1;
+ // m_linearDeflectionEfficiency = 0;
+ // m_linearDeflectionTimescale = 5;
+ // m_angularDeflectionEfficiency = 0;
+ // m_angularDeflectionTimescale = 5;
+ m_verticalAttractionEfficiency = 1f;
+ m_verticalAttractionTimescale = 100f;
+ // m_bankingEfficiency = 0;
+ // m_bankingMix = 0.7f;
+ // m_bankingTimescale = 5;
+ // m_referenceFrame = Quaternion.Identity;
+ m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
+ VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
+ m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
+ break;
+
+ }
+ }//end SetDefaultsForType
+
+ internal void Enable(IntPtr pBody, OdeScene pParentScene)
+ {
+ if (m_type == Vehicle.TYPE_NONE)
+ return;
+
+ m_body = pBody;
+ }
+
+ internal void Step(float pTimestep, OdeScene pParentScene)
+ {
+ if (m_body == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
+ return;
+ frcount++; // used to limit debug comment output
+ if (frcount > 100)
+ frcount = 0;
+
+ MoveLinear(pTimestep, pParentScene);
+ MoveAngular(pTimestep);
+ }// end Step
+
+ private void MoveLinear(float pTimestep, OdeScene _pParentScene)
+ {
+ if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant
+ {
+ if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body);
+
+ // add drive to body
+ Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
+ m_lastLinearVelocityVector += (addAmount*10); // lastLinearVelocityVector is the current body velocity vector?
+
+ // This will work temporarily, but we really need to compare speed on an axis
+ // KF: Limit body velocity to applied velocity?
+ if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X))
+ m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X;
+ if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirectionLASTSET.Y))
+ m_lastLinearVelocityVector.Y = m_linearMotorDirectionLASTSET.Y;
+ if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z))
+ m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z;
+
+ // decay applied velocity
+ Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep)));
+ //Console.WriteLine("decay: " + decayfraction);
+ m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f;
+ //Console.WriteLine("actual: " + m_linearMotorDirection);
+ }
+ else
+ { // requested is not significant
+ // if what remains of applied is small, zero it.
+ if (m_lastLinearVelocityVector.ApproxEquals(Vector3.Zero, 0.01f))
+ m_lastLinearVelocityVector = Vector3.Zero;
+ }
+
+
+ // convert requested object velocity to world-referenced vector
+ m_dir = m_lastLinearVelocityVector;
+ d.Quaternion rot = d.BodyGetQuaternion(Body);
+ Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
+ m_dir *= rotq; // apply obj rotation to velocity vector
+
+ // add Gravity and Buoyancy
+ // KF: So far I have found no good method to combine a script-requested
+ // .Z velocity and gravity. Therefore only 0g will used script-requested
+ // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
+ Vector3 grav = Vector3.Zero;
+ if(m_VehicleBuoyancy < 1.0f)
+ {
+ // There is some gravity, make a gravity force vector
+ // that is applied after object velocity.
+ d.Mass objMass;
+ d.BodyGetMass(Body, out objMass);
+ // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
+ grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy);
+ // Preserve the current Z velocity
+ d.Vector3 vel_now = d.BodyGetLinearVel(Body);
+ m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
+ } // else its 1.0, no gravity.
+
+ // Check if hovering
+ if( (m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0)
+ {
+ // We should hover, get the target height
+ d.Vector3 pos = d.BodyGetPosition(Body);
+ if((m_flags & VehicleFlag.HOVER_WATER_ONLY) == VehicleFlag.HOVER_WATER_ONLY)
+ {
+ m_VhoverTargetHeight = _pParentScene.GetWaterLevel() + m_VhoverHeight;
+ }
+ else if((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) == VehicleFlag.HOVER_TERRAIN_ONLY)
+ {
+ m_VhoverTargetHeight = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight;
+ }
+ else if((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == VehicleFlag.HOVER_GLOBAL_HEIGHT)
+ {
+ m_VhoverTargetHeight = m_VhoverHeight;
+ }
+
+ if((m_flags & VehicleFlag.HOVER_UP_ONLY) == VehicleFlag.HOVER_UP_ONLY)
+ {
+ // If body is aready heigher, use its height as target height
+ if(pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z;
+ }
+
+// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped
+// m_VhoverTimescale = 0f; // time to acheive height
+// pTimestep is time since last frame,in secs
+ float herr0 = pos.Z - m_VhoverTargetHeight;
+ // Replace Vertical speed with correction figure if significant
+ if(Math.Abs(herr0) > 0.01f )
+ {
+ d.Mass objMass;
+ d.BodyGetMass(Body, out objMass);
+ m_dir.Z = - ( (herr0 * pTimestep * 50.0f) / m_VhoverTimescale);
+ //KF: m_VhoverEfficiency is not yet implemented
+ }
+ else
+ {
+ m_dir.Z = 0f;
+ }
+ }
+
+ // Apply velocity
+ d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z);
+ // apply gravity force
+ d.BodyAddForce(Body, grav.X, grav.Y, grav.Z);
+
+
+ // apply friction
+ Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
+ m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
+ } // end MoveLinear()
+
+ private void MoveAngular(float pTimestep)
+ {
+ /*
+ private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor
+ private int m_angularMotorApply = 0; // application frame counter
+ private float m_angularMotorVelocity = 0; // current angular motor velocity (ramps up and down)
+ private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate
+ private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate
+ private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
+ private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
+ */
+//if(frcount == 0) Console.WriteLine("MoveAngular ");
+
+ // Get what the body is doing, this includes 'external' influences
+ d.Vector3 angularVelocity = d.BodyGetAngularVel(Body);
+ // Vector3 angularVelocity = Vector3.Zero;
+
+ if (m_angularMotorApply > 0)
+ {
+ // ramp up to new value
+ // 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);
+
+ m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected
+ // velocity may still be acheived.
+ }
+ else
+ {
+ // no motor recently applied, keep the body velocity
+ /* m_angularMotorVelocity.X = angularVelocity.X;
+ m_angularMotorVelocity.Y = angularVelocity.Y;
+ m_angularMotorVelocity.Z = angularVelocity.Z; */
+
+ // and decay the velocity
+ m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep);
+ } // end motor section
+
+
+ // Vertical attractor section
+ Vector3 vertattr = Vector3.Zero;
+
+ if(m_verticalAttractionTimescale < 300)
+ {
+ float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep);
+ // get present body rotation
+ d.Quaternion rot = d.BodyGetQuaternion(Body);
+ Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
+ // make a vector pointing up
+ Vector3 verterr = Vector3.Zero;
+ verterr.Z = 1.0f;
+ // rotate it to Body Angle
+ verterr = verterr * rotq;
+ // verterr.X and .Y are the World error ammounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1.
+ // As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go
+ // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body.
+ if (verterr.Z < 0.0f)
+ {
+ verterr.X = 2.0f - verterr.X;
+ verterr.Y = 2.0f - verterr.Y;
+ }
+ // Error is 0 (no error) to +/- 2 (max error)
+ // scale it by VAservo
+ verterr = verterr * VAservo;
+//if(frcount == 0) Console.WriteLine("VAerr=" + verterr);
+
+ // As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so
+ // Change Body angular velocity X based on Y, and Y based on X. Z is not changed.
+ vertattr.X = verterr.Y;
+ vertattr.Y = - verterr.X;
+ vertattr.Z = 0f;
+
+ // scaling appears better usingsquare-law
+ float bounce = 1.0f - (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency);
+ vertattr.X += bounce * angularVelocity.X;
+ vertattr.Y += bounce * angularVelocity.Y;
+
+ } // else vertical attractor is off
+
+ // m_lastVertAttractor = vertattr;
+
+ // Bank section tba
+ // Deflection section tba
+
+ // Sum velocities
+ m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // tba: + bank + deflection
+
+ if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
+ {
+ if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body);
+ }
+ else
+ {
+ m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
+ }
+
+ // apply friction
+ Vector3 decayamount = Vector3.One / (m_angularFrictionTimescale / pTimestep);
+ m_lastAngularVelocity -= m_lastAngularVelocity * decayamount;
+
+ // Apply to the body
+ d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
+
+ } //end MoveAngular
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
new file mode 100644
index 0000000..983431d
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -0,0 +1,3271 @@
+/* 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.
+ *
+ * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
+ * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
+ * ODEPrim.cs contains methods dealing with Prim editing, Prim
+ * characteristics and Kinetic motion.
+ * ODEDynamics.cs contains methods dealing with Prim Physical motion
+ * (dynamics) and the associated settings. Old Linear and angular
+ * motors for dynamic motion have been replace with MoveLinear()
+ * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
+ * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
+ * switch between 'VEHICLE' parameter use and general dynamics
+ * settings use.
+ */
+
+/*
+ * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
+ * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
+ * ODEPrim.cs contains methods dealing with Prim editing, Prim
+ * characteristics and Kinetic motion.
+ * ODEDynamics.cs contains methods dealing with Prim Physical motion
+ * (dynamics) and the associated settings. Old Linear and angular
+ * motors for dynamic motion have been replace with MoveLinear()
+ * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
+ * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
+ * switch between 'VEHICLE' parameter use and general dynamics
+ * settings use.
+ */
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Threading;
+using log4net;
+using OpenMetaverse;
+using Ode.NET;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ ///
+ /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves.
+ ///
+
+ public class OdePrim : PhysicsActor
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private Vector3 _position;
+ private Vector3 _velocity;
+ private Vector3 _torque;
+ private Vector3 m_lastVelocity;
+ private Vector3 m_lastposition;
+ private Quaternion m_lastorientation = new Quaternion();
+ private Vector3 m_rotationalVelocity;
+ private Vector3 _size;
+ private Vector3 _acceleration;
+ // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
+ private Quaternion _orientation;
+ private Vector3 m_taintposition;
+ private Vector3 m_taintsize;
+ private Vector3 m_taintVelocity;
+ private Vector3 m_taintTorque;
+ private Quaternion m_taintrot;
+ private Vector3 m_angularlock = Vector3.One;
+ private Vector3 m_taintAngularLock = Vector3.One;
+ private IntPtr Amotor = IntPtr.Zero;
+
+ private Vector3 m_PIDTarget;
+ private float m_PIDTau;
+ private float PID_D = 35f;
+ private float PID_G = 25f;
+ private bool m_usePID = false;
+
+ private Quaternion m_APIDTarget = new Quaternion();
+ private float m_APIDStrength = 0.5f;
+ private float m_APIDDamping = 0.5f;
+ private bool m_useAPID = false;
+
+ // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
+ // and are for non-VEHICLES only.
+
+ private float m_PIDHoverHeight;
+ private float m_PIDHoverTau;
+ private bool m_useHoverPID;
+ private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
+ private float m_targetHoverHeight;
+ private float m_groundHeight;
+ private float m_waterHeight;
+ private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
+
+ // private float m_tensor = 5f;
+ private int body_autodisable_frames = 20;
+
+
+ private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
+ | CollisionCategories.Space
+ | CollisionCategories.Body
+ | CollisionCategories.Character
+ );
+ private bool m_taintshape;
+ private bool m_taintPhysics;
+ private bool m_collidesLand = true;
+ private bool m_collidesWater;
+ public bool m_returnCollisions;
+
+ // Default we're a Geometry
+ private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
+
+ // Default, Collide with Other Geometries, spaces and Bodies
+ private CollisionCategories m_collisionFlags = m_default_collisionFlags;
+
+ public bool m_taintremove;
+ public bool m_taintdisable;
+ public bool m_disabled;
+ public bool m_taintadd;
+ public bool m_taintselected;
+ public bool m_taintCollidesWater;
+
+ public uint m_localID;
+
+ //public GCHandle gc;
+ private CollisionLocker ode;
+
+ private bool m_taintforce = false;
+ private bool m_taintaddangularforce = false;
+ private Vector3 m_force;
+ private List m_forcelist = new List();
+ private List m_angularforcelist = new List();
+
+ private IMesh _mesh;
+ private PrimitiveBaseShape _pbs;
+ private OdeScene _parent_scene;
+ public IntPtr m_targetSpace = IntPtr.Zero;
+ public IntPtr prim_geom;
+ public IntPtr prev_geom;
+ public IntPtr _triMeshData;
+
+ private IntPtr _linkJointGroup = IntPtr.Zero;
+ private PhysicsActor _parent;
+ private PhysicsActor m_taintparent;
+
+ private List childrenPrim = new List();
+
+ private bool iscolliding;
+ private bool m_isphysical;
+ private bool m_isSelected;
+
+ internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
+
+ private bool m_throttleUpdates;
+ private int throttleCounter;
+ public int m_interpenetrationcount;
+ public float m_collisionscore;
+ public int m_roundsUnderMotionThreshold;
+ private int m_crossingfailures;
+
+ public bool outofBounds;
+ private float m_density = 10.000006836f; // Aluminum g/cm3;
+
+ public bool _zeroFlag;
+ private bool m_lastUpdateSent;
+
+ public IntPtr Body = IntPtr.Zero;
+ public String m_primName;
+ private Vector3 _target_velocity;
+ public d.Mass pMass;
+
+ public int m_eventsubscription;
+ private CollisionEventUpdate CollisionEventsThisFrame;
+
+ private IntPtr m_linkJoint = IntPtr.Zero;
+
+ public volatile bool childPrim;
+
+ private ODEDynamics m_vehicle;
+
+ internal int m_material = (int)Material.Wood;
+
+ private int frcount = 0; // Used to limit dynamics debug output to
+
+
+ public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
+ Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
+ {
+ m_vehicle = new ODEDynamics();
+ //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
+ ode = dode;
+ if (!pos.IsFinite())
+ {
+ pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
+ parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
+ m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
+ }
+ _position = pos;
+ m_taintposition = pos;
+ PID_D = parent_scene.bodyPIDD;
+ PID_G = parent_scene.bodyPIDG;
+ m_density = parent_scene.geomDefaultDensity;
+ // m_tensor = parent_scene.bodyMotorJointMaxforceTensor;
+ body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
+
+
+ prim_geom = IntPtr.Zero;
+ prev_geom = IntPtr.Zero;
+
+ if (!pos.IsFinite())
+ {
+ size = new Vector3(0.5f, 0.5f, 0.5f);
+ m_log.Warn("[PHYSICS]: Got nonFinite Object create Size");
+ }
+
+ if (size.X <= 0) size.X = 0.01f;
+ if (size.Y <= 0) size.Y = 0.01f;
+ if (size.Z <= 0) size.Z = 0.01f;
+
+ _size = size;
+ m_taintsize = _size;
+
+ if (!QuaternionIsFinite(rotation))
+ {
+ rotation = Quaternion.Identity;
+ m_log.Warn("[PHYSICS]: Got nonFinite Object create Rotation");
+ }
+
+ _orientation = rotation;
+ m_taintrot = _orientation;
+ _mesh = mesh;
+ _pbs = pbs;
+
+ _parent_scene = parent_scene;
+ m_targetSpace = (IntPtr)0;
+
+ if (pos.Z < 0)
+ m_isphysical = false;
+ else
+ {
+ m_isphysical = pisPhysical;
+ // If we're physical, we need to be in the master space for now.
+ // linksets *should* be in a space together.. but are not currently
+ if (m_isphysical)
+ m_targetSpace = _parent_scene.space;
+ }
+ m_primName = primName;
+ m_taintadd = true;
+ _parent_scene.AddPhysicsActorTaint(this);
+ // don't do .add() here; old geoms get recycled with the same hash
+ }
+
+ public override int PhysicsActorType
+ {
+ get { return (int) ActorTypes.Prim; }
+ set { return; }
+ }
+
+ public override bool SetAlwaysRun
+ {
+ get { return false; }
+ set { return; }
+ }
+
+ public override uint LocalID
+ {
+ set {
+ //m_log.Info("[PHYSICS]: Setting TrackerID: " + value);
+ m_localID = value; }
+ }
+
+ public override bool Grabbed
+ {
+ set { return; }
+ }
+
+ public override bool Selected
+ {
+ set {
+
+
+ // This only makes the object not collidable if the object
+ // is physical or the object is modified somehow *IN THE FUTURE*
+ // without this, if an avatar selects prim, they can walk right
+ // through it while it's selected
+ m_collisionscore = 0;
+ if ((m_isphysical && !_zeroFlag) || !value)
+ {
+ m_taintselected = value;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_taintselected = value;
+ m_isSelected = value;
+ }
+ if(m_isSelected) disableBodySoft();
+ }
+ }
+
+ public void SetGeom(IntPtr geom)
+ {
+ prev_geom = prim_geom;
+ prim_geom = geom;
+//Console.WriteLine("SetGeom to " + prim_geom + " for " + m_primName);
+ if (prim_geom != IntPtr.Zero)
+ {
+ d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+ }
+
+ if (childPrim)
+ {
+ if (_parent != null && _parent is OdePrim)
+ {
+ OdePrim parent = (OdePrim)_parent;
+//Console.WriteLine("SetGeom calls ChildSetGeom");
+ parent.ChildSetGeom(this);
+ }
+ }
+ //m_log.Warn("Setting Geom to: " + prim_geom);
+ }
+
+
+
+ public void enableBodySoft()
+ {
+ if (!childPrim)
+ {
+ if (m_isphysical && Body != IntPtr.Zero)
+ {
+ d.BodyEnable(Body);
+ if (m_vehicle.Type != Vehicle.TYPE_NONE)
+ m_vehicle.Enable(Body, _parent_scene);
+ }
+
+ m_disabled = false;
+ }
+ }
+
+ public void disableBodySoft()
+ {
+ m_disabled = true;
+
+ if (m_isphysical && Body != IntPtr.Zero)
+ {
+ d.BodyDisable(Body);
+ }
+ }
+
+ public void enableBody()
+ {
+ // Don't enable this body if we're a child prim
+ // this should be taken care of in the parent function not here
+ if (!childPrim)
+ {
+ // Sets the geom to a body
+ Body = d.BodyCreate(_parent_scene.world);
+
+ setMass();
+ d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
+ d.Quaternion myrot = new d.Quaternion();
+ myrot.X = _orientation.X;
+ myrot.Y = _orientation.Y;
+ myrot.Z = _orientation.Z;
+ myrot.W = _orientation.W;
+ d.BodySetQuaternion(Body, ref myrot);
+ d.GeomSetBody(prim_geom, Body);
+ m_collisionCategories |= CollisionCategories.Body;
+ m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
+
+ d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+
+ d.BodySetAutoDisableFlag(Body, true);
+ d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
+
+ // disconnect from world gravity so we can apply buoyancy
+ d.BodySetGravityMode (Body, false);
+
+ m_interpenetrationcount = 0;
+ m_collisionscore = 0;
+ m_disabled = false;
+
+ // The body doesn't already have a finite rotation mode set here
+ if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null)
+ {
+ createAMotor(m_angularlock);
+ }
+ if (m_vehicle.Type != Vehicle.TYPE_NONE)
+ {
+ m_vehicle.Enable(Body, _parent_scene);
+ }
+
+ _parent_scene.addActivePrim(this);
+ }
+ }
+
+ #region Mass Calculation
+
+ private float CalculateMass()
+ {
+ float volume = 0;
+
+ // No material is passed to the physics engines yet.. soo..
+ // we're using the m_density constant in the class definition
+
+ float returnMass = 0;
+
+ switch (_pbs.ProfileShape)
+ {
+ case ProfileShape.Square:
+ // Profile Volume
+
+ volume = _size.X*_size.Y*_size.Z;
+
+ // If the user has 'hollowed out'
+ // ProfileHollow is one of those 0 to 50000 values :P
+ // we like percentages better.. so turning into a percentage
+
+ if (((float) _pbs.ProfileHollow/50000f) > 0.0)
+ {
+ float hollowAmount = (float) _pbs.ProfileHollow/50000f;
+
+ // calculate the hollow volume by it's shape compared to the prim shape
+ float hollowVolume = 0;
+ switch (_pbs.HollowShape)
+ {
+ case HollowShape.Square:
+ case HollowShape.Same:
+ // Cube Hollow volume calculation
+ float hollowsizex = _size.X*hollowAmount;
+ float hollowsizey = _size.Y*hollowAmount;
+ float hollowsizez = _size.Z*hollowAmount;
+ hollowVolume = hollowsizex*hollowsizey*hollowsizez;
+ break;
+
+ case HollowShape.Circle:
+ // Hollow shape is a perfect cyllinder in respect to the cube's scale
+ // Cyllinder hollow volume calculation
+ float hRadius = _size.X/2;
+ float hLength = _size.Z;
+
+ // pi * r2 * h
+ hollowVolume = ((float) (Math.PI*Math.Pow(hRadius, 2)*hLength)*hollowAmount);
+ break;
+
+ case HollowShape.Triangle:
+ // Equilateral Triangular Prism volume hollow calculation
+ // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y
+
+ float aLength = _size.Y;
+ // 1/2 abh
+ hollowVolume = (float) ((0.5*aLength*_size.X*_size.Z)*hollowAmount);
+ break;
+
+ default:
+ hollowVolume = 0;
+ break;
+ }
+ volume = volume - hollowVolume;
+ }
+
+ break;
+ case ProfileShape.Circle:
+ if (_pbs.PathCurve == (byte)Extrusion.Straight)
+ {
+ // Cylinder
+ float volume1 = (float)(Math.PI * Math.Pow(_size.X/2, 2) * _size.Z);
+ float volume2 = (float)(Math.PI * Math.Pow(_size.Y/2, 2) * _size.Z);
+
+ // Approximating the cylinder's irregularity.
+ if (volume1 > volume2)
+ {
+ volume = (float)volume1 - (volume1 - volume2);
+ }
+ else if (volume2 > volume1)
+ {
+ volume = (float)volume2 - (volume2 - volume1);
+ }
+ else
+ {
+ // Regular cylinder
+ volume = volume1;
+ }
+ }
+ else
+ {
+ // We don't know what the shape is yet, so use default
+ volume = _size.X * _size.Y * _size.Z;
+ }
+ // If the user has 'hollowed out'
+ // ProfileHollow is one of those 0 to 50000 values :P
+ // we like percentages better.. so turning into a percentage
+
+ if (((float)_pbs.ProfileHollow / 50000f) > 0.0)
+ {
+ float hollowAmount = (float)_pbs.ProfileHollow / 50000f;
+
+ // calculate the hollow volume by it's shape compared to the prim shape
+ float hollowVolume = 0;
+ switch (_pbs.HollowShape)
+ {
+ case HollowShape.Same:
+ case HollowShape.Circle:
+ // Hollow shape is a perfect cyllinder in respect to the cube's scale
+ // Cyllinder hollow volume calculation
+ float hRadius = _size.X / 2;
+ float hLength = _size.Z;
+
+ // pi * r2 * h
+ hollowVolume = ((float)(Math.PI * Math.Pow(hRadius, 2) * hLength) * hollowAmount);
+ break;
+
+ case HollowShape.Square:
+ // Cube Hollow volume calculation
+ float hollowsizex = _size.X * hollowAmount;
+ float hollowsizey = _size.Y * hollowAmount;
+ float hollowsizez = _size.Z * hollowAmount;
+ hollowVolume = hollowsizex * hollowsizey * hollowsizez;
+ break;
+
+ case HollowShape.Triangle:
+ // Equilateral Triangular Prism volume hollow calculation
+ // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y
+
+ float aLength = _size.Y;
+ // 1/2 abh
+ hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount);
+ break;
+
+ default:
+ hollowVolume = 0;
+ break;
+ }
+ volume = volume - hollowVolume;
+ }
+ break;
+
+ case ProfileShape.HalfCircle:
+ if (_pbs.PathCurve == (byte)Extrusion.Curve1)
+ {
+ if (_size.X == _size.Y && _size.Y == _size.Z)
+ {
+ // regular sphere
+ // v = 4/3 * pi * r^3
+ float sradius3 = (float)Math.Pow((_size.X / 2), 3);
+ volume = (float)((4f / 3f) * Math.PI * sradius3);
+ }
+ else
+ {
+ // we treat this as a box currently
+ volume = _size.X * _size.Y * _size.Z;
+ }
+ }
+ else
+ {
+ // We don't know what the shape is yet, so use default
+ volume = _size.X * _size.Y * _size.Z;
+ }
+ break;
+
+ case ProfileShape.EquilateralTriangle:
+ /*
+ v = (abs((xB*yA-xA*yB)+(xC*yB-xB*yC)+(xA*yC-xC*yA))/2) * h
+
+ // seed mesh
+ Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f);
+ Vertex PM = new Vertex(+0.5f, 0f, 0.0f);
+ Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f);
+ */
+ float xA = -0.25f * _size.X;
+ float yA = -0.45f * _size.Y;
+
+ float xB = 0.5f * _size.X;
+ float yB = 0;
+
+ float xC = -0.25f * _size.X;
+ float yC = 0.45f * _size.Y;
+
+ volume = (float)((Math.Abs((xB * yA - xA * yB) + (xC * yB - xB * yC) + (xA * yC - xC * yA)) / 2) * _size.Z);
+
+ // If the user has 'hollowed out'
+ // ProfileHollow is one of those 0 to 50000 values :P
+ // we like percentages better.. so turning into a percentage
+ float fhollowFactor = ((float)_pbs.ProfileHollow / 1.9f);
+ if (((float)fhollowFactor / 50000f) > 0.0)
+ {
+ float hollowAmount = (float)fhollowFactor / 50000f;
+
+ // calculate the hollow volume by it's shape compared to the prim shape
+ float hollowVolume = 0;
+ switch (_pbs.HollowShape)
+ {
+ case HollowShape.Same:
+ case HollowShape.Triangle:
+ // Equilateral Triangular Prism volume hollow calculation
+ // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y
+
+ float aLength = _size.Y;
+ // 1/2 abh
+ hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount);
+ break;
+
+ case HollowShape.Square:
+ // Cube Hollow volume calculation
+ float hollowsizex = _size.X * hollowAmount;
+ float hollowsizey = _size.Y * hollowAmount;
+ float hollowsizez = _size.Z * hollowAmount;
+ hollowVolume = hollowsizex * hollowsizey * hollowsizez;
+ break;
+
+ case HollowShape.Circle:
+ // Hollow shape is a perfect cyllinder in respect to the cube's scale
+ // Cyllinder hollow volume calculation
+ float hRadius = _size.X / 2;
+ float hLength = _size.Z;
+
+ // pi * r2 * h
+ hollowVolume = ((float)((Math.PI * Math.Pow(hRadius, 2) * hLength)/2) * hollowAmount);
+ break;
+
+ default:
+ hollowVolume = 0;
+ break;
+ }
+ volume = volume - hollowVolume;
+ }
+ break;
+
+ default:
+ // we don't have all of the volume formulas yet so
+ // use the common volume formula for all
+ volume = _size.X*_size.Y*_size.Z;
+ break;
+ }
+
+ // Calculate Path cut effect on volume
+ // Not exact, in the triangle hollow example
+ // They should never be zero or less then zero..
+ // we'll ignore it if it's less then zero
+
+ // ProfileEnd and ProfileBegin are values
+ // from 0 to 50000
+
+ // Turning them back into percentages so that I can cut that percentage off the volume
+
+ float PathCutEndAmount = _pbs.ProfileEnd;
+ float PathCutStartAmount = _pbs.ProfileBegin;
+ if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f)
+ {
+ float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount)/50000f);
+
+ // Check the return amount for sanity
+ if (pathCutAmount >= 0.99f)
+ pathCutAmount = 0.99f;
+
+ volume = volume - (volume*pathCutAmount);
+ }
+ UInt16 taperX = _pbs.PathScaleX;
+ UInt16 taperY = _pbs.PathScaleY;
+ float taperFactorX = 0;
+ float taperFactorY = 0;
+
+ // Mass = density * volume
+ if (taperX != 100)
+ {
+ if (taperX > 100)
+ {
+ taperFactorX = 1.0f - ((float)taperX / 200);
+ //m_log.Warn("taperTopFactorX: " + extr.taperTopFactorX.ToString());
+ }
+ else
+ {
+ taperFactorX = 1.0f - ((100 - (float)taperX) / 100);
+ //m_log.Warn("taperBotFactorX: " + extr.taperBotFactorX.ToString());
+ }
+ volume = (float)volume * ((taperFactorX / 3f) + 0.001f);
+ }
+
+ if (taperY != 100)
+ {
+ if (taperY > 100)
+ {
+ taperFactorY = 1.0f - ((float)taperY / 200);
+ //m_log.Warn("taperTopFactorY: " + extr.taperTopFactorY.ToString());
+ }
+ else
+ {
+ taperFactorY = 1.0f - ((100 - (float)taperY) / 100);
+ //m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString());
+ }
+ volume = (float)volume * ((taperFactorY / 3f) + 0.001f);
+ }
+ returnMass = m_density*volume;
+ if (returnMass <= 0) returnMass = 0.0001f;//ckrinke: Mass must be greater then zero.
+
+
+
+ // Recursively calculate mass
+ bool HasChildPrim = false;
+ lock (childrenPrim)
+ {
+ if (childrenPrim.Count > 0)
+ {
+ HasChildPrim = true;
+ }
+
+ }
+ if (HasChildPrim)
+ {
+ OdePrim[] childPrimArr = new OdePrim[0];
+
+ lock (childrenPrim)
+ childPrimArr = childrenPrim.ToArray();
+
+ for (int i = 0; i < childPrimArr.Length; i++)
+ {
+ if (childPrimArr[i] != null && !childPrimArr[i].m_taintremove)
+ returnMass += childPrimArr[i].CalculateMass();
+ // failsafe, this shouldn't happen but with OpenSim, you never know :)
+ if (i > 256)
+ break;
+ }
+ }
+ if (returnMass > _parent_scene.maximumMassObject)
+ returnMass = _parent_scene.maximumMassObject;
+ return returnMass;
+ }// end CalculateMass
+
+ #endregion
+
+ public void setMass()
+ {
+ if (Body != (IntPtr) 0)
+ {
+ float newmass = CalculateMass();
+
+ //m_log.Info("[PHYSICS]: New Mass: " + newmass.ToString());
+
+ d.MassSetBoxTotal(out pMass, newmass, _size.X, _size.Y, _size.Z);
+ d.BodySetMass(Body, ref pMass);
+ }
+ }
+
+ public void disableBody()
+ {
+ //this kills the body so things like 'mesh' can re-create it.
+ lock (this)
+ {
+ if (!childPrim)
+ {
+ if (Body != IntPtr.Zero)
+ {
+ _parent_scene.remActivePrim(this);
+ m_collisionCategories &= ~CollisionCategories.Body;
+ m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+ }
+
+
+ d.BodyDestroy(Body);
+ lock (childrenPrim)
+ {
+ if (childrenPrim.Count > 0)
+ {
+ foreach (OdePrim prm in childrenPrim)
+ {
+ _parent_scene.remActivePrim(prm);
+ prm.Body = IntPtr.Zero;
+ }
+ }
+ }
+ Body = IntPtr.Zero;
+ }
+ }
+ else
+ {
+ _parent_scene.remActivePrim(this);
+
+ m_collisionCategories &= ~CollisionCategories.Body;
+ m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+ }
+
+
+ Body = IntPtr.Zero;
+ }
+ }
+ m_disabled = true;
+ m_collisionscore = 0;
+ }
+
+ private static Dictionary m_MeshToTriMeshMap = new Dictionary();
+
+ public void setMesh(OdeScene parent_scene, IMesh mesh)
+ {
+ // This sleeper is there to moderate how long it takes between
+ // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
+
+ //Thread.Sleep(10);
+
+ //Kill Body so that mesh can re-make the geom
+ if (IsPhysical && Body != IntPtr.Zero)
+ {
+ if (childPrim)
+ {
+ if (_parent != null)
+ {
+ OdePrim parent = (OdePrim)_parent;
+ parent.ChildDelink(this);
+ }
+ }
+ else
+ {
+ disableBody();
+ }
+ }
+
+ IntPtr vertices, indices;
+ int vertexCount, indexCount;
+ int vertexStride, triStride;
+ mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap
+ mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
+
+ mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
+ if (m_MeshToTriMeshMap.ContainsKey(mesh))
+ {
+ _triMeshData = m_MeshToTriMeshMap[mesh];
+ }
+ else
+ {
+ _triMeshData = d.GeomTriMeshDataCreate();
+
+ d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
+ d.GeomTriMeshDataPreprocess(_triMeshData);
+ m_MeshToTriMeshMap[mesh] = _triMeshData;
+ }
+
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ try
+ {
+ if (prim_geom == IntPtr.Zero)
+ {
+ SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
+ }
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Error("[PHYSICS]: MESH LOCKED");
+ return;
+ }
+
+
+ // if (IsPhysical && Body == (IntPtr) 0)
+ // {
+ // Recreate the body
+ // m_interpenetrationcount = 0;
+ // m_collisionscore = 0;
+
+ // enableBody();
+ // }
+ }
+
+ public void ProcessTaints(float timestep)
+ {
+//Console.WriteLine("ProcessTaints for " + m_primName );
+ if (m_taintadd)
+ {
+ changeadd(timestep);
+ }
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ if (!_position.ApproxEquals(m_taintposition, 0f))
+ changemove(timestep);
+
+ if (m_taintrot != _orientation)
+ {
+ if(childPrim && IsPhysical) // For physical child prim...
+ {
+ rotate(timestep);
+ // KF: ODE will also rotate the parent prim!
+ // so rotate the root back to where it was
+ OdePrim parent = (OdePrim)_parent;
+ parent.rotate(timestep);
+ }
+ else
+ {
+ //Just rotate the prim
+ rotate(timestep);
+ }
+ }
+ //
+
+ if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent))
+ changePhysicsStatus(timestep);
+ //
+
+ if (!_size.ApproxEquals(m_taintsize,0f))
+ changesize(timestep);
+ //
+
+ if (m_taintshape)
+ changeshape(timestep);
+ //
+
+ if (m_taintforce)
+ changeAddForce(timestep);
+
+ if (m_taintaddangularforce)
+ changeAddAngularForce(timestep);
+
+ if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
+ changeSetTorque(timestep);
+
+ if (m_taintdisable)
+ changedisable(timestep);
+
+ if (m_taintselected != m_isSelected)
+ changeSelectedStatus(timestep);
+
+ if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
+ changevelocity(timestep);
+
+ if (m_taintparent != _parent)
+ changelink(timestep);
+
+ if (m_taintCollidesWater != m_collidesWater)
+ changefloatonwater(timestep);
+
+ if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
+ changeAngularLock(timestep);
+
+ }
+ else
+ {
+ m_log.Error("[PHYSICS]: The scene reused a disposed PhysActor! *waves finger*, Don't be evil. A couple of things can cause this. An improper prim breakdown(be sure to set prim_geom to zero after d.GeomDestroy! An improper buildup (creating the geom failed). Or, the Scene Reused a physics actor after disposing it.)");
+ }
+ }
+
+
+ private void changeAngularLock(float timestep)
+ {
+ // do we have a Physical object?
+ if (Body != IntPtr.Zero)
+ {
+ //Check that we have a Parent
+ //If we have a parent then we're not authorative here
+ if (_parent == null)
+ {
+ if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
+ {
+ //d.BodySetFiniteRotationMode(Body, 0);
+ //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
+ createAMotor(m_taintAngularLock);
+ }
+ else
+ {
+ if (Amotor != IntPtr.Zero)
+ {
+ d.JointDestroy(Amotor);
+ Amotor = IntPtr.Zero;
+ }
+ }
+ }
+ }
+ // Store this for later in case we get turned into a separate body
+ m_angularlock = m_taintAngularLock;
+
+ }
+
+ private void changelink(float timestep)
+ {
+ // If the newly set parent is not null
+ // create link
+ if (_parent == null && m_taintparent != null)
+ {
+ if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim)
+ {
+ OdePrim obj = (OdePrim)m_taintparent;
+ //obj.disableBody();
+//Console.WriteLine("changelink calls ParentPrim");
+ obj.ParentPrim(this);
+
+ /*
+ if (obj.Body != (IntPtr)0 && Body != (IntPtr)0 && obj.Body != Body)
+ {
+ _linkJointGroup = d.JointGroupCreate(0);
+ m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup);
+ d.JointAttach(m_linkJoint, obj.Body, Body);
+ d.JointSetFixed(m_linkJoint);
+ }
+ */
+ }
+ }
+ // If the newly set parent is null
+ // destroy link
+ else if (_parent != null && m_taintparent == null)
+ {
+//Console.WriteLine(" changelink B");
+
+ if (_parent is OdePrim)
+ {
+ OdePrim obj = (OdePrim)_parent;
+ obj.ChildDelink(this);
+ childPrim = false;
+ //_parent = null;
+ }
+
+ /*
+ if (Body != (IntPtr)0 && _linkJointGroup != (IntPtr)0)
+ d.JointGroupDestroy(_linkJointGroup);
+
+ _linkJointGroup = (IntPtr)0;
+ m_linkJoint = (IntPtr)0;
+ */
+ }
+
+ _parent = m_taintparent;
+ m_taintPhysics = m_isphysical;
+ }
+
+ // I'm the parent
+ // prim is the child
+ public void ParentPrim(OdePrim prim)
+ {
+//Console.WriteLine("ParentPrim " + m_primName);
+ if (this.m_localID != prim.m_localID)
+ {
+ if (Body == IntPtr.Zero)
+ {
+ Body = d.BodyCreate(_parent_scene.world);
+ setMass();
+ }
+ if (Body != IntPtr.Zero)
+ {
+ lock (childrenPrim)
+ {
+ if (!childrenPrim.Contains(prim))
+ {
+//Console.WriteLine("childrenPrim.Add " + prim);
+ childrenPrim.Add(prim);
+
+ foreach (OdePrim prm in childrenPrim)
+ {
+ d.Mass m2;
+ d.MassSetZero(out m2);
+ d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z);
+
+
+ d.Quaternion quat = new d.Quaternion();
+ quat.W = prm._orientation.W;
+ quat.X = prm._orientation.X;
+ quat.Y = prm._orientation.Y;
+ quat.Z = prm._orientation.Z;
+
+ d.Matrix3 mat = new d.Matrix3();
+ d.RfromQ(out mat, ref quat);
+ d.MassRotate(ref m2, ref mat);
+ d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z);
+ d.MassAdd(ref pMass, ref m2);
+ }
+ foreach (OdePrim prm in childrenPrim)
+ {
+
+ prm.m_collisionCategories |= CollisionCategories.Body;
+ prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
+
+ if (prm.prim_geom == IntPtr.Zero)
+ {
+ m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet");
+ continue;
+ }
+//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + m_primName);
+ d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
+ d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
+
+
+ d.Quaternion quat = new d.Quaternion();
+ quat.W = prm._orientation.W;
+ quat.X = prm._orientation.X;
+ quat.Y = prm._orientation.Y;
+ quat.Z = prm._orientation.Z;
+
+ d.Matrix3 mat = new d.Matrix3();
+ d.RfromQ(out mat, ref quat);
+ if (Body != IntPtr.Zero)
+ {
+ d.GeomSetBody(prm.prim_geom, Body);
+ prm.childPrim = true;
+ d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z);
+ //d.GeomSetOffsetPosition(prim.prim_geom,
+ // (Position.X - prm.Position.X) - pMass.c.X,
+ // (Position.Y - prm.Position.Y) - pMass.c.Y,
+ // (Position.Z - prm.Position.Z) - pMass.c.Z);
+ d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat);
+ //d.GeomSetOffsetRotation(prm.prim_geom, ref mat);
+ d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
+ d.BodySetMass(Body, ref pMass);
+ }
+ else
+ {
+ m_log.Debug("[PHYSICS]:I ain't got no boooooooooddy, no body");
+ }
+
+
+ prm.m_interpenetrationcount = 0;
+ prm.m_collisionscore = 0;
+ prm.m_disabled = false;
+
+ // The body doesn't already have a finite rotation mode set here
+ if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
+ {
+ prm.createAMotor(m_angularlock);
+ }
+ prm.Body = Body;
+ _parent_scene.addActivePrim(prm);
+ }
+ m_collisionCategories |= CollisionCategories.Body;
+ m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
+
+//Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + m_primName);
+ d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
+//Console.WriteLine(" Post GeomSetCategoryBits 2");
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+
+
+ d.Quaternion quat2 = new d.Quaternion();
+ quat2.W = _orientation.W;
+ quat2.X = _orientation.X;
+ quat2.Y = _orientation.Y;
+ quat2.Z = _orientation.Z;
+
+ d.Matrix3 mat2 = new d.Matrix3();
+ d.RfromQ(out mat2, ref quat2);
+ d.GeomSetBody(prim_geom, Body);
+ d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z);
+ //d.GeomSetOffsetPosition(prim.prim_geom,
+ // (Position.X - prm.Position.X) - pMass.c.X,
+ // (Position.Y - prm.Position.Y) - pMass.c.Y,
+ // (Position.Z - prm.Position.Z) - pMass.c.Z);
+ //d.GeomSetOffsetRotation(prim_geom, ref mat2);
+ d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
+ d.BodySetMass(Body, ref pMass);
+
+ d.BodySetAutoDisableFlag(Body, true);
+ d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
+
+
+ m_interpenetrationcount = 0;
+ m_collisionscore = 0;
+ m_disabled = false;
+
+ // The body doesn't already have a finite rotation mode set here
+ if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
+ {
+ createAMotor(m_angularlock);
+ }
+ d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
+ if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Enable(Body, _parent_scene);
+ _parent_scene.addActivePrim(this);
+ }
+ }
+ }
+ }
+
+ }
+
+ private void ChildSetGeom(OdePrim odePrim)
+ {
+ //if (m_isphysical && Body != IntPtr.Zero)
+ lock (childrenPrim)
+ {
+ foreach (OdePrim prm in childrenPrim)
+ {
+ //prm.childPrim = true;
+ prm.disableBody();
+ //prm.m_taintparent = null;
+ //prm._parent = null;
+ //prm.m_taintPhysics = false;
+ //prm.m_disabled = true;
+ //prm.childPrim = false;
+ }
+ }
+ disableBody();
+
+
+ if (Body != IntPtr.Zero)
+ {
+ _parent_scene.remActivePrim(this);
+ }
+
+ lock (childrenPrim)
+ {
+ foreach (OdePrim prm in childrenPrim)
+ {
+//Console.WriteLine("ChildSetGeom calls ParentPrim");
+ ParentPrim(prm);
+ }
+ }
+
+ }
+
+ private void ChildDelink(OdePrim odePrim)
+ {
+ // Okay, we have a delinked child.. need to rebuild the body.
+ lock (childrenPrim)
+ {
+ foreach (OdePrim prm in childrenPrim)
+ {
+ prm.childPrim = true;
+ prm.disableBody();
+ //prm.m_taintparent = null;
+ //prm._parent = null;
+ //prm.m_taintPhysics = false;
+ //prm.m_disabled = true;
+ //prm.childPrim = false;
+ }
+ }
+ disableBody();
+
+ lock (childrenPrim)
+ {
+ //Console.WriteLine("childrenPrim.Remove " + odePrim);
+ childrenPrim.Remove(odePrim);
+ }
+
+
+
+
+ if (Body != IntPtr.Zero)
+ {
+ _parent_scene.remActivePrim(this);
+ }
+
+
+
+ lock (childrenPrim)
+ {
+ foreach (OdePrim prm in childrenPrim)
+ {
+//Console.WriteLine("ChildDelink calls ParentPrim");
+ ParentPrim(prm);
+ }
+ }
+
+
+ }
+
+ private void changeSelectedStatus(float timestep)
+ {
+ if (m_taintselected)
+ {
+ m_collisionCategories = CollisionCategories.Selected;
+ m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
+
+ // We do the body disable soft twice because 'in theory' a collision could have happened
+ // in between the disabling and the collision properties setting
+ // which would wake the physical body up from a soft disabling and potentially cause it to fall
+ // through the ground.
+
+ // NOTE FOR JOINTS: this doesn't always work for jointed assemblies because if you select
+ // just one part of the assembly, the rest of the assembly is non-selected and still simulating,
+ // so that causes the selected part to wake up and continue moving.
+
+ // even if you select all parts of a jointed assembly, it is not guaranteed that the entire
+ // assembly will stop simulating during the selection, because of the lack of atomicity
+ // of select operations (their processing could be interrupted by a thread switch, causing
+ // simulation to continue before all of the selected object notifications trickle down to
+ // the physics engine).
+
+ // e.g. we select 100 prims that are connected by joints. non-atomically, the first 50 are
+ // selected and disabled. then, due to a thread switch, the selection processing is
+ // interrupted and the physics engine continues to simulate, so the last 50 items, whose
+ // selection was not yet processed, continues to simulate. this wakes up ALL of the
+ // first 50 again. then the last 50 are disabled. then the first 50, which were just woken
+ // up, start simulating again, which in turn wakes up the last 50.
+
+ if (m_isphysical)
+ {
+ disableBodySoft();
+ }
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+ }
+
+ if (m_isphysical)
+ {
+ disableBodySoft();
+ }
+ }
+ else
+ {
+ m_collisionCategories = CollisionCategories.Geom;
+
+ if (m_isphysical)
+ m_collisionCategories |= CollisionCategories.Body;
+
+ m_collisionFlags = m_default_collisionFlags;
+
+ if (m_collidesLand)
+ m_collisionFlags |= CollisionCategories.Land;
+ if (m_collidesWater)
+ m_collisionFlags |= CollisionCategories.Water;
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+ }
+ if (m_isphysical)
+ {
+ if (Body != IntPtr.Zero)
+ {
+ d.BodySetLinearVel(Body, 0f, 0f, 0f);
+ d.BodySetForce(Body, 0, 0, 0);
+ enableBodySoft();
+ }
+ }
+ }
+
+ resetCollisionAccounting();
+ m_isSelected = m_taintselected;
+ }//end changeSelectedStatus
+
+ public void ResetTaints()
+ {
+ m_taintposition = _position;
+ m_taintrot = _orientation;
+ m_taintPhysics = m_isphysical;
+ m_taintselected = m_isSelected;
+ m_taintsize = _size;
+ m_taintshape = false;
+ m_taintforce = false;
+ m_taintdisable = false;
+ m_taintVelocity = Vector3.Zero;
+ }
+
+ public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
+ {
+//Console.WriteLine("CreateGeom:");
+ if (_mesh != null)
+ {
+ setMesh(_parent_scene, _mesh);
+ }
+ else
+ {
+ if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1)
+ {
+ if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
+ {
+ if (((_size.X / 2f) > 0f))
+ {
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ try
+ {
+//Console.WriteLine(" CreateGeom 1");
+ SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2));
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
+ ode.dunlock(_parent_scene.world);
+ return;
+ }
+ }
+ else
+ {
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ try
+ {
+//Console.WriteLine(" CreateGeom 2");
+ SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
+ ode.dunlock(_parent_scene.world);
+ return;
+ }
+ }
+ }
+ else
+ {
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ try
+ {
+//Console.WriteLine(" CreateGeom 3");
+ SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
+ ode.dunlock(_parent_scene.world);
+ return;
+ }
+ }
+ }
+
+ else
+ {
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ try
+ {
+//Console.WriteLine(" CreateGeom 4");
+ SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
+ ode.dunlock(_parent_scene.world);
+ return;
+ }
+ }
+ }
+ }
+
+ public void changeadd(float timestep)
+ {
+ int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
+ IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position);
+
+ if (targetspace == IntPtr.Zero)
+ targetspace = _parent_scene.createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]);
+
+ m_targetSpace = targetspace;
+
+ if (_mesh == null)
+ {
+ if (_parent_scene.needsMeshing(_pbs))
+ {
+ // Don't need to re-enable body.. it's done in SetMesh
+ _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical);
+ // createmesh returns null when it's a shape that isn't a cube.
+ // m_log.Debug(m_localID);
+ }
+ }
+
+
+ lock (_parent_scene.OdeLock)
+ {
+//Console.WriteLine("changeadd 1");
+ CreateGeom(m_targetSpace, _mesh);
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
+ d.Quaternion myrot = new d.Quaternion();
+ myrot.X = _orientation.X;
+ myrot.Y = _orientation.Y;
+ myrot.Z = _orientation.Z;
+ myrot.W = _orientation.W;
+ d.GeomSetQuaternion(prim_geom, ref myrot);
+ }
+
+ if (m_isphysical && Body == IntPtr.Zero)
+ {
+ enableBody();
+ }
+ }
+
+ _parent_scene.geom_name_map[prim_geom] = this.m_primName;
+ _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
+
+ changeSelectedStatus(timestep);
+
+ m_taintadd = false;
+ }
+
+ public void changemove(float timestep)
+ {
+ if (m_isphysical)
+ {
+
+ if (!m_disabled && !m_taintremove && !childPrim)
+ {
+ if (Body == IntPtr.Zero)
+ enableBody();
+ //Prim auto disable after 20 frames,
+ //if you move it, re-enable the prim manually.
+ if (_parent != null)
+ {
+ if (m_linkJoint != IntPtr.Zero)
+ {
+ d.JointDestroy(m_linkJoint);
+ m_linkJoint = IntPtr.Zero;
+ }
+ }
+ if (Body != IntPtr.Zero)
+ {
+ d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
+
+ if (_parent != null)
+ {
+ OdePrim odParent = (OdePrim)_parent;
+ if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0 && Body != odParent.Body)
+ {
+// KF: Fixed Joints were removed? Anyway - this Console.WriteLine does not show up, so routine is not used??
+Console.WriteLine(" JointCreateFixed");
+ m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup);
+ d.JointAttach(m_linkJoint, Body, odParent.Body);
+ d.JointSetFixed(m_linkJoint);
+ }
+ }
+ d.BodyEnable(Body);
+ if (m_vehicle.Type != Vehicle.TYPE_NONE)
+ {
+ m_vehicle.Enable(Body, _parent_scene);
+ }
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Body Still null after enableBody(). This is a crash scenario.");
+ }
+ }
+ //else
+ // {
+ //m_log.Debug("[BUG]: race!");
+ //}
+ }
+ else
+ {
+ // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
+ // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+
+ IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
+ m_targetSpace = tempspace;
+
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ if (prim_geom != IntPtr.Zero)
+ {
+ d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
+
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ d.SpaceAdd(m_targetSpace, prim_geom);
+ }
+ }
+
+ changeSelectedStatus(timestep);
+
+ resetCollisionAccounting();
+ m_taintposition = _position;
+ }
+
+ public void Move(float timestep)
+ {
+ float fx = 0;
+ float fy = 0;
+ float fz = 0;
+
+ frcount++; // used to limit debug comment output
+ if (frcount > 100)
+ frcount = 0;
+
+ if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims.
+ {
+//if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle.Type +
+ // " usePID=" + m_usePID + " seHover=" + m_useHoverPID + " useAPID=" + m_useAPID);
+ if (m_vehicle.Type != Vehicle.TYPE_NONE)
+ {
+ // 'VEHICLES' are dealt with in ODEDynamics.cs
+ m_vehicle.Step(timestep, _parent_scene);
+ }
+ else
+ {
+ if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
+ // NON-'VEHICLES' are dealt with here
+ if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
+ {
+ d.Vector3 avel2 = d.BodyGetAngularVel(Body);
+ if (m_angularlock.X == 1)
+ avel2.X = 0;
+ if (m_angularlock.Y == 1)
+ avel2.Y = 0;
+ if (m_angularlock.Z == 1)
+ avel2.Z = 0;
+ d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
+ }
+ //float PID_P = 900.0f;
+
+ float m_mass = CalculateMass();
+
+// fz = 0f;
+ //m_log.Info(m_collisionFlags.ToString());
+
+
+ //KF: m_buoyancy is set by llSetBuoyancy() and is for non-vehicle.
+ // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
+ // NB Prims in ODE are no subject to global gravity
+ fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; // force = acceleration * mass
+
+ if (m_usePID)
+ {
+//if(frcount == 0) Console.WriteLine("PID " + m_primName);
+ // KF - this is for object MoveToTarget.
+
+ //if (!d.BodyIsEnabled(Body))
+ //d.BodySetForce(Body, 0f, 0f, 0f);
+
+ // no lock; for now it's only called from within Simulate()
+
+ // If the PID Controller isn't active then we set our force
+ // calculating base velocity to the current position
+
+ if ((m_PIDTau < 1) && (m_PIDTau != 0))
+ {
+ //PID_G = PID_G / m_PIDTau;
+ m_PIDTau = 1;
+ }
+
+ if ((PID_G - m_PIDTau) <= 0)
+ {
+ PID_G = m_PIDTau + 1;
+ }
+ //PidStatus = true;
+
+ // PhysicsVector vec = new PhysicsVector();
+ d.Vector3 vel = d.BodyGetLinearVel(Body);
+
+ d.Vector3 pos = d.BodyGetPosition(Body);
+ _target_velocity =
+ new Vector3(
+ (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
+ (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
+ (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
+ );
+
+ // if velocity is zero, use position control; otherwise, velocity control
+
+ if (_target_velocity.ApproxEquals(Vector3.Zero,0.1f))
+ {
+ // keep track of where we stopped. No more slippin' & slidin'
+
+ // We only want to deactivate the PID Controller if we think we want to have our surrogate
+ // react to the physics scene by moving it's position.
+ // Avatar to Avatar collisions
+ // Prim to avatar collisions
+
+ //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
+ //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
+ //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
+ d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
+ d.BodySetLinearVel(Body, 0, 0, 0);
+ d.BodyAddForce(Body, 0, 0, fz);
+ return;
+ }
+ else
+ {
+ _zeroFlag = false;
+
+ // We're flying and colliding with something
+ fx = ((_target_velocity.X) - vel.X) * (PID_D);
+ fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
+
+ // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
+
+ fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
+ }
+ } // end if (m_usePID)
+
+ // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller
+ if (m_useHoverPID && !m_usePID)
+ {
+//Console.WriteLine("Hover " + m_primName);
+
+ // If we're using the PID controller, then we have no gravity
+ fz = (-1 * _parent_scene.gravityz) * m_mass;
+
+ // no lock; for now it's only called from within Simulate()
+
+ // If the PID Controller isn't active then we set our force
+ // calculating base velocity to the current position
+
+ if ((m_PIDTau < 1))
+ {
+ PID_G = PID_G / m_PIDTau;
+ }
+
+ if ((PID_G - m_PIDTau) <= 0)
+ {
+ PID_G = m_PIDTau + 1;
+ }
+
+
+ // Where are we, and where are we headed?
+ d.Vector3 pos = d.BodyGetPosition(Body);
+ d.Vector3 vel = d.BodyGetLinearVel(Body);
+
+
+ // Non-Vehicles have a limited set of Hover options.
+ // determine what our target height really is based on HoverType
+ switch (m_PIDHoverType)
+ {
+ case PIDHoverType.Ground:
+ m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
+ m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
+ break;
+ case PIDHoverType.GroundAndWater:
+ m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
+ m_waterHeight = _parent_scene.GetWaterLevel();
+ if (m_groundHeight > m_waterHeight)
+ {
+ m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
+ }
+ else
+ {
+ m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
+ }
+ break;
+
+ } // end switch (m_PIDHoverType)
+
+
+ _target_velocity =
+ new Vector3(0.0f, 0.0f,
+ (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
+ );
+
+ // if velocity is zero, use position control; otherwise, velocity control
+
+ if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
+ {
+ // keep track of where we stopped. No more slippin' & slidin'
+
+ // We only want to deactivate the PID Controller if we think we want to have our surrogate
+ // react to the physics scene by moving it's position.
+ // Avatar to Avatar collisions
+ // Prim to avatar collisions
+
+ d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
+ d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
+ d.BodyAddForce(Body, 0, 0, fz);
+ //KF this prevents furthur motions return;
+ }
+ else
+ {
+ _zeroFlag = false;
+
+ // We're flying and colliding with something
+ fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
+ }
+ } // end m_useHoverPID && !m_usePID
+
+ if (m_useAPID)
+ {
+ // RotLookAt, apparently overrides all other rotation sources. Inputs:
+ // Quaternion m_APIDTarget
+ // float m_APIDStrength // From SL experiments, this is the time to get there
+ // float m_APIDDamping // From SL experiments, this is damping, 1.0 = damped, 0.1 = wobbly
+ // Also in SL the mass of the object has no effect on time to get there.
+ // Factors:
+//if(frcount == 0) Console.WriteLine("APID ");
+ // get present body rotation
+ float limit = 1.0f;
+ float scaler = 50f; // adjusts damping time
+ float RLAservo = 0f;
+
+ d.Quaternion rot = d.BodyGetQuaternion(Body);
+ Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
+ Quaternion rot_diff = Quaternion.Inverse(rotq) * m_APIDTarget;
+ float diff_angle;
+ Vector3 diff_axis;
+ rot_diff.GetAxisAngle(out diff_axis, out diff_angle);
+ diff_axis.Normalize();
+ if(diff_angle > 0.01f) // diff_angle is always +ve
+ {
+// PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
+ Vector3 rotforce = new Vector3(diff_axis.X, diff_axis.Y, diff_axis.Z);
+ rotforce = rotforce * rotq;
+ if(diff_angle > limit) diff_angle = limit; // cap the rotate rate
+// RLAservo = timestep / m_APIDStrength * m_mass * scaler;
+ // rotforce = rotforce * RLAservo * diff_angle ;
+ // d.BodyAddRelTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
+ RLAservo = timestep / m_APIDStrength * scaler;
+ rotforce = rotforce * RLAservo * diff_angle ;
+ d.BodySetAngularVel (Body, rotforce.X, rotforce.Y, rotforce.Z);
+//Console.WriteLine("axis= " + diff_axis + " angle= " + diff_angle + "servo= " + RLAservo);
+ }
+//if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo + " angle= " + diff_angle);
+ } // end m_useAPID
+
+ fx *= m_mass;
+ fy *= m_mass;
+ //fz *= m_mass;
+
+ fx += m_force.X;
+ fy += m_force.Y;
+ fz += m_force.Z;
+
+ //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
+ if (fx != 0 || fy != 0 || fz != 0)
+ {
+ //m_taintdisable = true;
+ //base.RaiseOutOfBounds(Position);
+ //d.BodySetLinearVel(Body, fx, fy, 0f);
+ if (!d.BodyIsEnabled(Body))
+ {
+ // A physical body at rest on a surface will auto-disable after a while,
+ // this appears to re-enable it incase the surface it is upon vanishes,
+ // and the body should fall again.
+ d.BodySetLinearVel(Body, 0f, 0f, 0f);
+ d.BodySetForce(Body, 0, 0, 0);
+ enableBodySoft();
+ }
+
+ // 35x10 = 350n times the mass per second applied maximum.
+ float nmax = 35f * m_mass;
+ float nmin = -35f * m_mass;
+
+
+ if (fx > nmax)
+ fx = nmax;
+ if (fx < nmin)
+ fx = nmin;
+ if (fy > nmax)
+ fy = nmax;
+ if (fy < nmin)
+ fy = nmin;
+ d.BodyAddForce(Body, fx, fy, fz);
+//Console.WriteLine("AddForce " + fx + "," + fy + "," + fz);
+ }
+ }
+ }
+ else
+ { // is not physical, or is not a body or is selected
+ // _zeroPosition = d.BodyGetPosition(Body);
+ return;
+//Console.WriteLine("Nothing " + m_primName);
+
+ }
+ }
+
+
+
+ public void rotate(float timestep)
+ {
+ d.Quaternion myrot = new d.Quaternion();
+ myrot.X = _orientation.X;
+ myrot.Y = _orientation.Y;
+ myrot.Z = _orientation.Z;
+ myrot.W = _orientation.W;
+ if (Body != IntPtr.Zero)
+ {
+ // KF: If this is a root prim do BodySet
+ d.BodySetQuaternion(Body, ref myrot);
+ if (m_isphysical)
+ {
+ if (!m_angularlock.ApproxEquals(Vector3.One, 0f))
+ createAMotor(m_angularlock);
+ }
+ }
+ else
+ {
+ // daughter prim, do Geom set
+ d.GeomSetQuaternion(prim_geom, ref myrot);
+ }
+
+ resetCollisionAccounting();
+ m_taintrot = _orientation;
+ }
+
+ private void resetCollisionAccounting()
+ {
+ m_collisionscore = 0;
+ m_interpenetrationcount = 0;
+ m_disabled = false;
+ }
+
+ public void changedisable(float timestep)
+ {
+ m_disabled = true;
+ if (Body != IntPtr.Zero)
+ {
+ d.BodyDisable(Body);
+ Body = IntPtr.Zero;
+ }
+
+ m_taintdisable = false;
+ }
+
+ public void changePhysicsStatus(float timestep)
+ {
+ if (m_isphysical == true)
+ {
+ if (Body == IntPtr.Zero)
+ {
+ if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
+ {
+ changeshape(2f);
+ }
+ else
+ {
+ enableBody();
+ }
+ }
+ }
+ else
+ {
+ if (Body != IntPtr.Zero)
+ {
+ if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
+ {
+
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ try
+ {
+ d.GeomDestroy(prim_geom);
+ prim_geom = IntPtr.Zero;
+ _mesh = null;
+ }
+ catch (System.AccessViolationException)
+ {
+ prim_geom = IntPtr.Zero;
+ m_log.Error("[PHYSICS]: PrimGeom dead");
+ }
+ }
+//Console.WriteLine("changePhysicsStatus for " + m_primName );
+ changeadd(2f);
+ }
+ if (childPrim)
+ {
+ if (_parent != null)
+ {
+ OdePrim parent = (OdePrim)_parent;
+ parent.ChildDelink(this);
+ }
+ }
+ else
+ {
+ disableBody();
+ }
+ }
+ }
+
+ changeSelectedStatus(timestep);
+
+ resetCollisionAccounting();
+ m_taintPhysics = m_isphysical;
+ }
+
+ public void changesize(float timestamp)
+ {
+
+ string oldname = _parent_scene.geom_name_map[prim_geom];
+
+ if (_size.X <= 0) _size.X = 0.01f;
+ if (_size.Y <= 0) _size.Y = 0.01f;
+ if (_size.Z <= 0) _size.Z = 0.01f;
+
+ // Cleanup of old prim geometry
+ if (_mesh != null)
+ {
+ // Cleanup meshing here
+ }
+ //kill body to rebuild
+ if (IsPhysical && Body != IntPtr.Zero)
+ {
+ if (childPrim)
+ {
+ if (_parent != null)
+ {
+ OdePrim parent = (OdePrim)_parent;
+ parent.ChildDelink(this);
+ }
+ }
+ else
+ {
+ disableBody();
+ }
+ }
+ if (d.SpaceQuery(m_targetSpace, prim_geom))
+ {
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ d.SpaceRemove(m_targetSpace, prim_geom);
+ }
+ d.GeomDestroy(prim_geom);
+ prim_geom = IntPtr.Zero;
+ // we don't need to do space calculation because the client sends a position update also.
+
+ // Construction of new prim
+ if (_parent_scene.needsMeshing(_pbs))
+ {
+ float meshlod = _parent_scene.meshSculptLOD;
+
+ if (IsPhysical)
+ meshlod = _parent_scene.MeshSculptphysicalLOD;
+ // Don't need to re-enable body.. it's done in SetMesh
+
+ IMesh mesh = null;
+
+ if (_parent_scene.needsMeshing(_pbs))
+ mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
+
+ //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
+//Console.WriteLine("changesize 1");
+ CreateGeom(m_targetSpace, mesh);
+
+
+ }
+ else
+ {
+ _mesh = null;
+//Console.WriteLine("changesize 2");
+ CreateGeom(m_targetSpace, _mesh);
+ }
+
+ d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
+ d.Quaternion myrot = new d.Quaternion();
+ myrot.X = _orientation.X;
+ myrot.Y = _orientation.Y;
+ myrot.Z = _orientation.Z;
+ myrot.W = _orientation.W;
+ d.GeomSetQuaternion(prim_geom, ref myrot);
+
+ //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
+ if (IsPhysical && Body == IntPtr.Zero && !childPrim)
+ {
+ // Re creates body on size.
+ // EnableBody also does setMass()
+ enableBody();
+ d.BodyEnable(Body);
+ }
+
+ _parent_scene.geom_name_map[prim_geom] = oldname;
+
+ changeSelectedStatus(timestamp);
+ if (childPrim)
+ {
+ if (_parent is OdePrim)
+ {
+ OdePrim parent = (OdePrim)_parent;
+ parent.ChildSetGeom(this);
+ }
+ }
+ resetCollisionAccounting();
+ m_taintsize = _size;
+ }
+
+
+
+ public void changefloatonwater(float timestep)
+ {
+ m_collidesWater = m_taintCollidesWater;
+
+ if (prim_geom != IntPtr.Zero)
+ {
+ if (m_collidesWater)
+ {
+ m_collisionFlags |= CollisionCategories.Water;
+ }
+ else
+ {
+ m_collisionFlags &= ~CollisionCategories.Water;
+ }
+ d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
+ }
+ }
+
+ public void changeshape(float timestamp)
+ {
+ string oldname = _parent_scene.geom_name_map[prim_geom];
+
+ // Cleanup of old prim geometry and Bodies
+ if (IsPhysical && Body != IntPtr.Zero)
+ {
+ if (childPrim)
+ {
+ if (_parent != null)
+ {
+ OdePrim parent = (OdePrim)_parent;
+ parent.ChildDelink(this);
+ }
+ }
+ else
+ {
+ disableBody();
+ }
+ }
+ try
+ {
+ d.GeomDestroy(prim_geom);
+ }
+ catch (System.AccessViolationException)
+ {
+ prim_geom = IntPtr.Zero;
+ m_log.Error("[PHYSICS]: PrimGeom dead");
+ }
+ prim_geom = IntPtr.Zero;
+ // we don't need to do space calculation because the client sends a position update also.
+ if (_size.X <= 0) _size.X = 0.01f;
+ if (_size.Y <= 0) _size.Y = 0.01f;
+ if (_size.Z <= 0) _size.Z = 0.01f;
+ // Construction of new prim
+
+ if (_parent_scene.needsMeshing(_pbs))
+ {
+ // Don't need to re-enable body.. it's done in SetMesh
+ float meshlod = _parent_scene.meshSculptLOD;
+
+ if (IsPhysical)
+ meshlod = _parent_scene.MeshSculptphysicalLOD;
+
+ IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
+ // createmesh returns null when it doesn't mesh.
+ CreateGeom(m_targetSpace, mesh);
+ }
+ else
+ {
+ _mesh = null;
+//Console.WriteLine("changeshape");
+ CreateGeom(m_targetSpace, null);
+ }
+
+ d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
+ d.Quaternion myrot = new d.Quaternion();
+ //myrot.W = _orientation.w;
+ myrot.W = _orientation.W;
+ myrot.X = _orientation.X;
+ myrot.Y = _orientation.Y;
+ myrot.Z = _orientation.Z;
+ d.GeomSetQuaternion(prim_geom, ref myrot);
+
+ //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
+ if (IsPhysical && Body == IntPtr.Zero)
+ {
+ // Re creates body on size.
+ // EnableBody also does setMass()
+ enableBody();
+ if (Body != IntPtr.Zero)
+ {
+ d.BodyEnable(Body);
+ }
+ }
+ _parent_scene.geom_name_map[prim_geom] = oldname;
+
+ changeSelectedStatus(timestamp);
+ if (childPrim)
+ {
+ if (_parent is OdePrim)
+ {
+ OdePrim parent = (OdePrim)_parent;
+ parent.ChildSetGeom(this);
+ }
+ }
+ resetCollisionAccounting();
+ m_taintshape = false;
+ }
+
+ public void changeAddForce(float timestamp)
+ {
+ if (!m_isSelected)
+ {
+ lock (m_forcelist)
+ {
+ //m_log.Info("[PHYSICS]: dequeing forcelist");
+ if (IsPhysical)
+ {
+ Vector3 iforce = Vector3.Zero;
+ int i = 0;
+ try
+ {
+ for (i = 0; i < m_forcelist.Count; i++)
+ {
+
+ iforce = iforce + (m_forcelist[i] * 100);
+ }
+ }
+ catch (IndexOutOfRangeException)
+ {
+ m_forcelist = new List();
+ m_collisionscore = 0;
+ m_interpenetrationcount = 0;
+ m_taintforce = false;
+ return;
+ }
+ catch (ArgumentOutOfRangeException)
+ {
+ m_forcelist = new List();
+ m_collisionscore = 0;
+ m_interpenetrationcount = 0;
+ m_taintforce = false;
+ return;
+ }
+ d.BodyEnable(Body);
+ d.BodyAddForce(Body, iforce.X, iforce.Y, iforce.Z);
+ }
+ m_forcelist.Clear();
+ }
+
+ m_collisionscore = 0;
+ m_interpenetrationcount = 0;
+ }
+
+ m_taintforce = false;
+
+ }
+
+
+
+ public void changeSetTorque(float timestamp)
+ {
+ if (!m_isSelected)
+ {
+ if (IsPhysical && Body != IntPtr.Zero)
+ {
+ d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z);
+ }
+ }
+
+ m_taintTorque = Vector3.Zero;
+ }
+
+ public void changeAddAngularForce(float timestamp)
+ {
+ if (!m_isSelected)
+ {
+ lock (m_angularforcelist)
+ {
+ //m_log.Info("[PHYSICS]: dequeing forcelist");
+ if (IsPhysical)
+ {
+ Vector3 iforce = Vector3.Zero;
+ for (int i = 0; i < m_angularforcelist.Count; i++)
+ {
+ iforce = iforce + (m_angularforcelist[i] * 100);
+ }
+ d.BodyEnable(Body);
+ d.BodyAddTorque(Body, iforce.X, iforce.Y, iforce.Z);
+
+ }
+ m_angularforcelist.Clear();
+ }
+
+ m_collisionscore = 0;
+ m_interpenetrationcount = 0;
+ }
+
+ m_taintaddangularforce = false;
+ }
+
+ private void changevelocity(float timestep)
+ {
+ if (!m_isSelected)
+ {
+ Thread.Sleep(20);
+ if (IsPhysical)
+ {
+ if (Body != IntPtr.Zero)
+ {
+ d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
+ }
+ }
+
+ //resetCollisionAccounting();
+ }
+ m_taintVelocity = Vector3.Zero;
+ }
+
+ public override bool IsPhysical
+ {
+ get { return m_isphysical; }
+ set {
+ m_isphysical = value;
+ if (!m_isphysical) // Zero the remembered last velocity
+ m_lastVelocity = Vector3.Zero;
+ }
+ }
+
+ public void setPrimForRemoval()
+ {
+ m_taintremove = true;
+ }
+
+ public override bool Flying
+ {
+ // no flying prims for you
+ get { return false; }
+ set { }
+ }
+
+ public override bool IsColliding
+ {
+ get { return iscolliding; }
+ set { iscolliding = value; }
+ }
+
+ public override bool CollidingGround
+ {
+ get { return false; }
+ set { return; }
+ }
+
+ public override bool CollidingObj
+ {
+ get { return false; }
+ set { return; }
+ }
+
+ public override bool ThrottleUpdates
+ {
+ get { return m_throttleUpdates; }
+ set { m_throttleUpdates = value; }
+ }
+
+ public override bool Stopped
+ {
+ get { return _zeroFlag; }
+ }
+
+ public override Vector3 Position
+ {
+ get { return _position; }
+
+ set { _position = value;
+ //m_log.Info("[PHYSICS]: " + _position.ToString());
+ }
+ }
+
+ public override Vector3 Size
+ {
+ get { return _size; }
+ set
+ {
+ if (value.IsFinite())
+ {
+ _size = value;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got NaN Size on object");
+ }
+ }
+ }
+
+ public override float Mass
+ {
+ get { return CalculateMass(); }
+ }
+
+ public override Vector3 Force
+ {
+ //get { return Vector3.Zero; }
+ get { return m_force; }
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_force = value;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: NaN in Force Applied to an Object");
+ }
+ }
+ }
+
+ public override int VehicleType
+ {
+ get { return (int)m_vehicle.Type; }
+ set { m_vehicle.ProcessTypeChange((Vehicle)value); }
+ }
+
+ public override void VehicleFloatParam(int param, float value)
+ {
+ m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value);
+ }
+
+ public override void VehicleVectorParam(int param, Vector3 value)
+ {
+ m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value);
+ }
+
+ public override void VehicleRotationParam(int param, Quaternion rotation)
+ {
+ m_vehicle.ProcessRotationVehicleParam((Vehicle) param, rotation);
+ }
+
+ public override void SetVolumeDetect(int param)
+ {
+ lock (_parent_scene.OdeLock)
+ {
+ m_isVolumeDetect = (param!=0);
+ }
+ }
+
+ public override Vector3 CenterOfMass
+ {
+ get { return Vector3.Zero; }
+ }
+
+ public override Vector3 GeometricCenter
+ {
+ get { return Vector3.Zero; }
+ }
+
+ public override PrimitiveBaseShape Shape
+ {
+ set
+ {
+ _pbs = value;
+ m_taintshape = true;
+ }
+ }
+
+ public override Vector3 Velocity
+ {
+ get
+ {
+ // Averate previous velocity with the new one so
+ // client object interpolation works a 'little' better
+ if (_zeroFlag)
+ return Vector3.Zero;
+
+ Vector3 returnVelocity = Vector3.Zero;
+ returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
+ returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2;
+ returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2;
+ return returnVelocity;
+ }
+ set
+ {
+ if (value.IsFinite())
+ {
+ _velocity = value;
+
+ m_taintVelocity = value;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got NaN Velocity in Object");
+ }
+
+ }
+ }
+
+ public override Vector3 Torque
+ {
+ get
+ {
+ if (!m_isphysical || Body == IntPtr.Zero)
+ return Vector3.Zero;
+
+ return _torque;
+ }
+
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_taintTorque = value;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got NaN Torque in Object");
+ }
+ }
+ }
+
+ public override float CollisionScore
+ {
+ get { return m_collisionscore; }
+ set { m_collisionscore = value; }
+ }
+
+ public override bool Kinematic
+ {
+ get { return false; }
+ set { }
+ }
+
+ public override Quaternion Orientation
+ {
+ get { return _orientation; }
+ set
+ {
+ if (QuaternionIsFinite(value))
+ {
+ _orientation = value;
+ }
+ else
+ m_log.Warn("[PHYSICS]: Got NaN quaternion Orientation from Scene in Object");
+
+ }
+ }
+
+ internal static bool QuaternionIsFinite(Quaternion q)
+ {
+ if (Single.IsNaN(q.X) || Single.IsInfinity(q.X))
+ return false;
+ if (Single.IsNaN(q.Y) || Single.IsInfinity(q.Y))
+ return false;
+ if (Single.IsNaN(q.Z) || Single.IsInfinity(q.Z))
+ return false;
+ if (Single.IsNaN(q.W) || Single.IsInfinity(q.W))
+ return false;
+ return true;
+ }
+
+ public override Vector3 Acceleration
+ {
+ get { return _acceleration; }
+ }
+
+
+ public void SetAcceleration(Vector3 accel)
+ {
+ _acceleration = accel;
+ }
+
+ public override void AddForce(Vector3 force, bool pushforce)
+ {
+ if (force.IsFinite())
+ {
+ lock (m_forcelist)
+ m_forcelist.Add(force);
+
+ m_taintforce = true;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got Invalid linear force vector from Scene in Object");
+ }
+ //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
+ }
+
+ public override void AddAngularForce(Vector3 force, bool pushforce)
+ {
+ if (force.IsFinite())
+ {
+ m_angularforcelist.Add(force);
+ m_taintaddangularforce = true;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got Invalid Angular force vector from Scene in Object");
+ }
+ }
+
+ public override Vector3 RotationalVelocity
+ {
+ get
+ {
+ Vector3 pv = Vector3.Zero;
+ if (_zeroFlag)
+ return pv;
+ m_lastUpdateSent = false;
+
+ if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
+ return pv;
+
+ return m_rotationalVelocity;
+ }
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_rotationalVelocity = value;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got NaN RotationalVelocity in Object");
+ }
+ }
+ }
+
+ public override void CrossingFailure()
+ {
+ m_crossingfailures++;
+ if (m_crossingfailures > _parent_scene.geomCrossingFailuresBeforeOutofbounds)
+ {
+ base.RaiseOutOfBounds(_position);
+ return;
+ }
+ else if (m_crossingfailures == _parent_scene.geomCrossingFailuresBeforeOutofbounds)
+ {
+ m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName);
+ }
+ }
+
+ public override float Buoyancy
+ {
+ get { return m_buoyancy; }
+ set { m_buoyancy = value; }
+ }
+
+ public override void link(PhysicsActor obj)
+ {
+ m_taintparent = obj;
+ }
+
+ public override void delink()
+ {
+ m_taintparent = null;
+ }
+
+ public override void LockAngularMotion(Vector3 axis)
+ {
+ // reverse the zero/non zero values for ODE.
+ if (axis.IsFinite())
+ {
+ axis.X = (axis.X > 0) ? 1f : 0f;
+ axis.Y = (axis.Y > 0) ? 1f : 0f;
+ axis.Z = (axis.Z > 0) ? 1f : 0f;
+ m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
+ m_taintAngularLock = axis;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got NaN locking axis from Scene on Object");
+ }
+ }
+
+ public void UpdatePositionAndVelocity()
+ {
+ // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
+ if (_parent == null)
+ {
+ Vector3 pv = Vector3.Zero;
+ bool lastZeroFlag = _zeroFlag;
+ if (Body != (IntPtr)0) // FIXME -> or if it is a joint
+ {
+ d.Vector3 vec = d.BodyGetPosition(Body);
+ d.Quaternion ori = d.BodyGetQuaternion(Body);
+ d.Vector3 vel = d.BodyGetLinearVel(Body);
+ d.Vector3 rotvel = d.BodyGetAngularVel(Body);
+ d.Vector3 torque = d.BodyGetTorque(Body);
+ _torque = new Vector3(torque.X, torque.Y, torque.Z);
+ Vector3 l_position = Vector3.Zero;
+ Quaternion l_orientation = Quaternion.Identity;
+
+ // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
+ //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
+ //if (vec.Y < 0.0f) { vec.Y = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
+ //if (vec.X > 255.95f) { vec.X = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
+ //if (vec.Y > 255.95f) { vec.Y = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
+
+ m_lastposition = _position;
+ m_lastorientation = _orientation;
+
+ l_position.X = vec.X;
+ l_position.Y = vec.Y;
+ l_position.Z = vec.Z;
+ l_orientation.X = ori.X;
+ l_orientation.Y = ori.Y;
+ l_orientation.Z = ori.Z;
+ l_orientation.W = ori.W;
+
+// if(l_position.Y != m_lastposition.Y){
+// Console.WriteLine("UP&V {0} {1}", m_primName, l_position);
+// }
+
+ if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f)
+ {
+ //base.RaiseOutOfBounds(l_position);
+
+ if (m_crossingfailures < _parent_scene.geomCrossingFailuresBeforeOutofbounds)
+ {
+ _position = l_position;
+ //_parent_scene.remActivePrim(this);
+ if (_parent == null)
+ base.RequestPhysicsterseUpdate();
+ return;
+ }
+ else
+ {
+ if (_parent == null)
+ base.RaiseOutOfBounds(l_position);
+ return;
+ }
+ }
+
+ if (l_position.Z < 0)
+ {
+ // This is so prim that get lost underground don't fall forever and suck up
+ //
+ // Sim resources and memory.
+ // Disables the prim's movement physics....
+ // It's a hack and will generate a console message if it fails.
+
+ //IsPhysical = false;
+ if (_parent == null)
+ base.RaiseOutOfBounds(_position);
+
+ _acceleration.X = 0;
+ _acceleration.Y = 0;
+ _acceleration.Z = 0;
+
+ _velocity.X = 0;
+ _velocity.Y = 0;
+ _velocity.Z = 0;
+ m_rotationalVelocity.X = 0;
+ m_rotationalVelocity.Y = 0;
+ m_rotationalVelocity.Z = 0;
+
+ if (_parent == null)
+ base.RequestPhysicsterseUpdate();
+
+ m_throttleUpdates = false;
+ throttleCounter = 0;
+ _zeroFlag = true;
+ //outofBounds = true;
+ }
+
+ //float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation));
+//Console.WriteLine("Adiff " + m_primName + " = " + Adiff);
+ if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02)
+ && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02)
+ && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)
+// && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.01))
+ && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.0001)) // KF 0.01 is far to large
+ {
+ _zeroFlag = true;
+//Console.WriteLine("ZFT 2");
+ m_throttleUpdates = false;
+ }
+ else
+ {
+ //m_log.Debug(Math.Abs(m_lastposition.X - l_position.X).ToString());
+ _zeroFlag = false;
+ m_lastUpdateSent = false;
+ //m_throttleUpdates = false;
+ }
+
+ if (_zeroFlag)
+ {
+ _velocity.X = 0.0f;
+ _velocity.Y = 0.0f;
+ _velocity.Z = 0.0f;
+
+ _acceleration.X = 0;
+ _acceleration.Y = 0;
+ _acceleration.Z = 0;
+
+ //_orientation.w = 0f;
+ //_orientation.X = 0f;
+ //_orientation.Y = 0f;
+ //_orientation.Z = 0f;
+ m_rotationalVelocity.X = 0;
+ m_rotationalVelocity.Y = 0;
+ m_rotationalVelocity.Z = 0;
+ if (!m_lastUpdateSent)
+ {
+ m_throttleUpdates = false;
+ throttleCounter = 0;
+ m_rotationalVelocity = pv;
+
+ if (_parent == null)
+ {
+ base.RequestPhysicsterseUpdate();
+ }
+
+ m_lastUpdateSent = true;
+ }
+ }
+ else
+ {
+ if (lastZeroFlag != _zeroFlag)
+ {
+ if (_parent == null)
+ {
+ base.RequestPhysicsterseUpdate();
+ }
+ }
+
+ m_lastVelocity = _velocity;
+
+ _position = l_position;
+
+ _velocity.X = vel.X;
+ _velocity.Y = vel.Y;
+ _velocity.Z = vel.Z;
+
+ _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
+ _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f);
+ //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
+
+ if (_velocity.ApproxEquals(pv, 0.5f))
+ {
+ m_rotationalVelocity = pv;
+ }
+ else
+ {
+ m_rotationalVelocity = new Vector3(rotvel.X, rotvel.Y, rotvel.Z);
+ }
+
+ //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
+ _orientation.X = ori.X;
+ _orientation.Y = ori.Y;
+ _orientation.Z = ori.Z;
+ _orientation.W = ori.W;
+ m_lastUpdateSent = false;
+ if (!m_throttleUpdates || throttleCounter > _parent_scene.geomUpdatesPerThrottledUpdate)
+ {
+ if (_parent == null)
+ {
+ base.RequestPhysicsterseUpdate();
+ }
+ }
+ else
+ {
+ throttleCounter++;
+ }
+ }
+ m_lastposition = l_position;
+ }
+ else
+ {
+ // Not a body.. so Make sure the client isn't interpolating
+ _velocity.X = 0;
+ _velocity.Y = 0;
+ _velocity.Z = 0;
+
+ _acceleration.X = 0;
+ _acceleration.Y = 0;
+ _acceleration.Z = 0;
+
+ m_rotationalVelocity.X = 0;
+ m_rotationalVelocity.Y = 0;
+ m_rotationalVelocity.Z = 0;
+ _zeroFlag = true;
+ }
+ }
+ }
+
+ public override bool FloatOnWater
+ {
+ set {
+ m_taintCollidesWater = value;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ }
+
+ public override void SetMomentum(Vector3 momentum)
+ {
+ }
+
+ public override Vector3 PIDTarget
+ {
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_PIDTarget = value;
+ }
+ else
+ m_log.Warn("[PHYSICS]: Got NaN PIDTarget from Scene on Object");
+ }
+ }
+ public override bool PIDActive { set { m_usePID = value; } }
+ public override float PIDTau { set { m_PIDTau = value; } }
+
+ // For RotLookAt
+ public override Quaternion APIDTarget { set { m_APIDTarget = value; } }
+ public override bool APIDActive { set { m_useAPID = value; } }
+ public override float APIDStrength { set { m_APIDStrength = value; } }
+ public override float APIDDamping { set { m_APIDDamping = value; } }
+
+ public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } }
+ public override bool PIDHoverActive { set { m_useHoverPID = value; } }
+ public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
+ public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
+
+ private void createAMotor(Vector3 axis)
+ {
+ if (Body == IntPtr.Zero)
+ return;
+
+ if (Amotor != IntPtr.Zero)
+ {
+ d.JointDestroy(Amotor);
+ Amotor = IntPtr.Zero;
+ }
+
+ float axisnum = 3;
+
+ axisnum = (axisnum - (axis.X + axis.Y + axis.Z));
+
+ // PhysicsVector totalSize = new PhysicsVector(_size.X, _size.Y, _size.Z);
+
+
+ // Inverse Inertia Matrix, set the X, Y, and/r Z inertia to 0 then invert it again.
+ d.Mass objMass;
+ d.MassSetZero(out objMass);
+ DMassCopy(ref pMass, ref objMass);
+
+ //m_log.DebugFormat("1-{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, ", objMass.I.M00, objMass.I.M01, objMass.I.M02, objMass.I.M10, objMass.I.M11, objMass.I.M12, objMass.I.M20, objMass.I.M21, objMass.I.M22);
+
+ Matrix4 dMassMat = FromDMass(objMass);
+
+ Matrix4 mathmat = Inverse(dMassMat);
+
+ /*
+ //m_log.DebugFormat("2-{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, ", mathmat[0, 0], mathmat[0, 1], mathmat[0, 2], mathmat[1, 0], mathmat[1, 1], mathmat[1, 2], mathmat[2, 0], mathmat[2, 1], mathmat[2, 2]);
+
+ mathmat = Inverse(mathmat);
+
+
+ objMass = FromMatrix4(mathmat, ref objMass);
+ //m_log.DebugFormat("3-{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, ", objMass.I.M00, objMass.I.M01, objMass.I.M02, objMass.I.M10, objMass.I.M11, objMass.I.M12, objMass.I.M20, objMass.I.M21, objMass.I.M22);
+
+ mathmat = Inverse(mathmat);
+ */
+ if (axis.X == 0)
+ {
+ mathmat.M33 = 50.0000001f;
+ //objMass.I.M22 = 0;
+ }
+ if (axis.Y == 0)
+ {
+ mathmat.M22 = 50.0000001f;
+ //objMass.I.M11 = 0;
+ }
+ if (axis.Z == 0)
+ {
+ mathmat.M11 = 50.0000001f;
+ //objMass.I.M00 = 0;
+ }
+
+
+
+ mathmat = Inverse(mathmat);
+ objMass = FromMatrix4(mathmat, ref objMass);
+ //m_log.DebugFormat("4-{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, ", objMass.I.M00, objMass.I.M01, objMass.I.M02, objMass.I.M10, objMass.I.M11, objMass.I.M12, objMass.I.M20, objMass.I.M21, objMass.I.M22);
+
+ //return;
+ if (d.MassCheck(ref objMass))
+ {
+ d.BodySetMass(Body, ref objMass);
+ }
+ else
+ {
+ //m_log.Debug("[PHYSICS]: Mass invalid, ignoring");
+ }
+
+ if (axisnum <= 0)
+ return;
+ // int dAMotorEuler = 1;
+
+ Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
+ d.JointAttach(Amotor, Body, IntPtr.Zero);
+ d.JointSetAMotorMode(Amotor, 0);
+
+ d.JointSetAMotorNumAxes(Amotor,(int)axisnum);
+ int i = 0;
+
+ if (axis.X == 0)
+ {
+ d.JointSetAMotorAxis(Amotor, i, 0, 1, 0, 0);
+ i++;
+ }
+
+ if (axis.Y == 0)
+ {
+ d.JointSetAMotorAxis(Amotor, i, 0, 0, 1, 0);
+ i++;
+ }
+
+ if (axis.Z == 0)
+ {
+ d.JointSetAMotorAxis(Amotor, i, 0, 0, 0, 1);
+ i++;
+ }
+
+ for (int j = 0; j < (int)axisnum; j++)
+ {
+ //d.JointSetAMotorAngle(Amotor, j, 0);
+ }
+
+ //d.JointSetAMotorAngle(Amotor, 1, 0);
+ //d.JointSetAMotorAngle(Amotor, 2, 0);
+
+ // These lowstops and high stops are effectively (no wiggle room)
+ d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0f);
+ //d.JointSetAMotorParam(Amotor, (int) dParam.Vel, 9000f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax, Mass * 50f);//
+
+ }
+
+ public Matrix4 FromDMass(d.Mass pMass)
+ {
+ Matrix4 obj;
+ obj.M11 = pMass.I.M00;
+ obj.M12 = pMass.I.M01;
+ obj.M13 = pMass.I.M02;
+ obj.M14 = 0;
+ obj.M21 = pMass.I.M10;
+ obj.M22 = pMass.I.M11;
+ obj.M23 = pMass.I.M12;
+ obj.M24 = 0;
+ obj.M31 = pMass.I.M20;
+ obj.M32 = pMass.I.M21;
+ obj.M33 = pMass.I.M22;
+ obj.M34 = 0;
+ obj.M41 = 0;
+ obj.M42 = 0;
+ obj.M43 = 0;
+ obj.M44 = 1;
+ return obj;
+ }
+
+ public d.Mass FromMatrix4(Matrix4 pMat, ref d.Mass obj)
+ {
+ obj.I.M00 = pMat[0, 0];
+ obj.I.M01 = pMat[0, 1];
+ obj.I.M02 = pMat[0, 2];
+ obj.I.M10 = pMat[1, 0];
+ obj.I.M11 = pMat[1, 1];
+ obj.I.M12 = pMat[1, 2];
+ obj.I.M20 = pMat[2, 0];
+ obj.I.M21 = pMat[2, 1];
+ obj.I.M22 = pMat[2, 2];
+ return obj;
+ }
+
+ public override void SubscribeEvents(int ms)
+ {
+ m_eventsubscription = ms;
+ _parent_scene.addCollisionEventReporting(this);
+ }
+
+ public override void UnSubscribeEvents()
+ {
+ _parent_scene.remCollisionEventReporting(this);
+ m_eventsubscription = 0;
+ }
+
+ public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
+ {
+ if (CollisionEventsThisFrame == null)
+ CollisionEventsThisFrame = new CollisionEventUpdate();
+ CollisionEventsThisFrame.addCollider(CollidedWith, contact);
+ }
+
+ public void SendCollisions()
+ {
+ if (CollisionEventsThisFrame == null)
+ return;
+
+ base.SendCollisionUpdate(CollisionEventsThisFrame);
+
+ if (CollisionEventsThisFrame.m_objCollisionList.Count == 0)
+ CollisionEventsThisFrame = null;
+ else
+ CollisionEventsThisFrame = new CollisionEventUpdate();
+ }
+
+ public override bool SubscribedEvents()
+ {
+ if (m_eventsubscription > 0)
+ return true;
+ return false;
+ }
+
+ public static Matrix4 Inverse(Matrix4 pMat)
+ {
+ if (determinant3x3(pMat) == 0)
+ {
+ return Matrix4.Identity; // should probably throw an error. singluar matrix inverse not possible
+ }
+
+
+
+ return (Adjoint(pMat) / determinant3x3(pMat));
+ }
+
+ public static Matrix4 Adjoint(Matrix4 pMat)
+ {
+ Matrix4 adjointMatrix = new Matrix4();
+ for (int i=0; i<4; i++)
+ {
+ for (int j=0; j<4; j++)
+ {
+ Matrix4SetValue(ref adjointMatrix, i, j, (float)(Math.Pow(-1, i + j) * (determinant3x3(Minor(pMat, i, j)))));
+ }
+ }
+
+ adjointMatrix = Transpose(adjointMatrix);
+ return adjointMatrix;
+ }
+
+ public static Matrix4 Minor(Matrix4 matrix, int iRow, int iCol)
+ {
+ Matrix4 minor = new Matrix4();
+ int m = 0, n = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ if (i == iRow)
+ continue;
+ n = 0;
+ for (int j = 0; j < 4; j++)
+ {
+ if (j == iCol)
+ continue;
+ Matrix4SetValue(ref minor, m,n, matrix[i, j]);
+ n++;
+ }
+ m++;
+ }
+ return minor;
+ }
+
+ public static Matrix4 Transpose(Matrix4 pMat)
+ {
+ Matrix4 transposeMatrix = new Matrix4();
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ Matrix4SetValue(ref transposeMatrix, i, j, pMat[j, i]);
+ return transposeMatrix;
+ }
+
+ public static void Matrix4SetValue(ref Matrix4 pMat, int r, int c, float val)
+ {
+ switch (r)
+ {
+ case 0:
+ switch (c)
+ {
+ case 0:
+ pMat.M11 = val;
+ break;
+ case 1:
+ pMat.M12 = val;
+ break;
+ case 2:
+ pMat.M13 = val;
+ break;
+ case 3:
+ pMat.M14 = val;
+ break;
+ }
+
+ break;
+ case 1:
+ switch (c)
+ {
+ case 0:
+ pMat.M21 = val;
+ break;
+ case 1:
+ pMat.M22 = val;
+ break;
+ case 2:
+ pMat.M23 = val;
+ break;
+ case 3:
+ pMat.M24 = val;
+ break;
+ }
+
+ break;
+ case 2:
+ switch (c)
+ {
+ case 0:
+ pMat.M31 = val;
+ break;
+ case 1:
+ pMat.M32 = val;
+ break;
+ case 2:
+ pMat.M33 = val;
+ break;
+ case 3:
+ pMat.M34 = val;
+ break;
+ }
+
+ break;
+ case 3:
+ switch (c)
+ {
+ case 0:
+ pMat.M41 = val;
+ break;
+ case 1:
+ pMat.M42 = val;
+ break;
+ case 2:
+ pMat.M43 = val;
+ break;
+ case 3:
+ pMat.M44 = val;
+ break;
+ }
+
+ break;
+ }
+ }
+ private static float determinant3x3(Matrix4 pMat)
+ {
+ float det = 0;
+ float diag1 = pMat[0, 0]*pMat[1, 1]*pMat[2, 2];
+ float diag2 = pMat[0, 1]*pMat[2, 1]*pMat[2, 0];
+ float diag3 = pMat[0, 2]*pMat[1, 0]*pMat[2, 1];
+ float diag4 = pMat[2, 0]*pMat[1, 1]*pMat[0, 2];
+ float diag5 = pMat[2, 1]*pMat[1, 2]*pMat[0, 0];
+ float diag6 = pMat[2, 2]*pMat[1, 0]*pMat[0, 1];
+
+ det = diag1 + diag2 + diag3 - (diag4 + diag5 + diag6);
+ return det;
+
+ }
+
+ private static void DMassCopy(ref d.Mass src, ref d.Mass dst)
+ {
+ dst.c.W = src.c.W;
+ dst.c.X = src.c.X;
+ dst.c.Y = src.c.Y;
+ dst.c.Z = src.c.Z;
+ dst.mass = src.mass;
+ dst.I.M00 = src.I.M00;
+ dst.I.M01 = src.I.M01;
+ dst.I.M02 = src.I.M02;
+ dst.I.M10 = src.I.M10;
+ dst.I.M11 = src.I.M11;
+ dst.I.M12 = src.I.M12;
+ dst.I.M20 = src.I.M20;
+ dst.I.M21 = src.I.M21;
+ dst.I.M22 = src.I.M22;
+ }
+
+ public override void SetMaterial(int pMaterial)
+ {
+ m_material = pMaterial;
+ }
+
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/ChOdePlugin/ODERayCastRequestManager.cs
new file mode 100644
index 0000000..7314107
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODERayCastRequestManager.cs
@@ -0,0 +1,375 @@
+/*
+ * 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.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+using OpenMetaverse;
+using OpenSim.Region.Physics.Manager;
+using Ode.NET;
+using log4net;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ ///
+ /// Processes raycast requests as ODE is in a state to be able to do them.
+ /// This ensures that it's thread safe and there will be no conflicts.
+ /// Requests get returned by a different thread then they were requested by.
+ ///
+ public class ODERayCastRequestManager
+ {
+ ///
+ /// Pending Raycast Requests
+ ///
+ protected List m_PendingRequests = new List();
+
+ ///
+ /// Scene that created this object.
+ ///
+ private OdeScene m_scene;
+
+ ///
+ /// ODE contact array to be filled by the collision testing
+ ///
+ d.ContactGeom[] contacts = new d.ContactGeom[5];
+
+ ///
+ /// ODE near callback delegate
+ ///
+ private d.NearCallback nearCallback;
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private List m_contactResults = new List();
+
+
+ public ODERayCastRequestManager(OdeScene pScene)
+ {
+ m_scene = pScene;
+ nearCallback = near;
+
+ }
+
+ ///
+ /// Queues a raycast
+ ///
+ /// Origin of Ray
+ /// Ray normal
+ /// Ray length
+ /// Return method to send the results
+ public void QueueRequest(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod)
+ {
+ lock (m_PendingRequests)
+ {
+ ODERayCastRequest req = new ODERayCastRequest();
+ req.callbackMethod = retMethod;
+ req.length = length;
+ req.Normal = direction;
+ req.Origin = position;
+
+ m_PendingRequests.Add(req);
+ }
+ }
+
+ ///
+ /// Process all queued raycast requests
+ ///
+ /// Time in MS the raycasts took to process.
+ public int ProcessQueuedRequests()
+ {
+ int time = System.Environment.TickCount;
+ lock (m_PendingRequests)
+ {
+ if (m_PendingRequests.Count > 0)
+ {
+ ODERayCastRequest[] reqs = m_PendingRequests.ToArray();
+ for (int i = 0; i < reqs.Length; i++)
+ {
+ if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast
+ RayCast(reqs[i]); // if there isn't anyone to send results
+ }
+ /*
+ foreach (ODERayCastRequest req in m_PendingRequests)
+ {
+ if (req.callbackMethod != null) // quick optimization here, don't raycast
+ RayCast(req); // if there isn't anyone to send results to
+
+ }
+ */
+ m_PendingRequests.Clear();
+ }
+ }
+
+ lock (m_contactResults)
+ m_contactResults.Clear();
+
+ return System.Environment.TickCount - time;
+ }
+
+ ///
+ /// Method that actually initiates the raycast
+ ///
+ ///
+ private void RayCast(ODERayCastRequest req)
+ {
+ // Create the ray
+ IntPtr ray = d.CreateRay(m_scene.space, req.length);
+ d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z);
+
+ // Collide test
+ d.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback);
+
+ // Remove Ray
+ d.GeomDestroy(ray);
+
+
+ // Define default results
+ bool hitYN = false;
+ uint hitConsumerID = 0;
+ float distance = 999999999999f;
+ Vector3 closestcontact = new Vector3(99999f, 99999f, 99999f);
+ Vector3 snormal = Vector3.Zero;
+
+ // Find closest contact and object.
+ lock (m_contactResults)
+ {
+ foreach (ContactResult cResult in m_contactResults)
+ {
+ if (Vector3.Distance(req.Origin, cResult.Pos) < Vector3.Distance(req.Origin, closestcontact))
+ {
+ closestcontact = cResult.Pos;
+ hitConsumerID = cResult.ConsumerID;
+ distance = cResult.Depth;
+ hitYN = true;
+ snormal = cResult.Normal;
+ }
+ }
+
+ m_contactResults.Clear();
+ }
+
+ // Return results
+ if (req.callbackMethod != null)
+ req.callbackMethod(hitYN, closestcontact, hitConsumerID, distance, snormal);
+ }
+
+ // This is the standard Near. Uses space AABBs to speed up detection.
+ private void near(IntPtr space, IntPtr g1, IntPtr g2)
+ {
+
+ //Don't test against heightfield Geom, or you'll be sorry!
+
+ /*
+ terminate called after throwing an instance of 'std::bad_alloc'
+ what(): std::bad_alloc
+ Stacktrace:
+
+ at (wrapper managed-to-native) Ode.NET.d.Collide (intptr,intptr,int,Ode.NET.d/ContactGeom[],int) <0x00004>
+ at (wrapper managed-to-native) Ode.NET.d.Collide (intptr,intptr,int,Ode.NET.d/ContactGeom[],int) <0xffffffff>
+ at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.near (intptr,intptr,intptr) <0x00280>
+ at (wrapper native-to-managed) OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.near (intptr,intptr,intptr) <0xfff
+ fffff>
+ at (wrapper managed-to-native) Ode.NET.d.SpaceCollide2 (intptr,intptr,intptr,Ode.NET.d/NearCallback) <0x00004>
+ at (wrapper managed-to-native) Ode.NET.d.SpaceCollide2 (intptr,intptr,intptr,Ode.NET.d/NearCallback) <0xffffffff>
+ at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.RayCast (OpenSim.Region.Physics.OdePlugin.ODERayCastRequest) <
+ 0x00114>
+ at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.ProcessQueuedRequests () <0x000eb>
+ at OpenSim.Region.Physics.OdePlugin.OdeScene.Simulate (single) <0x017e6>
+ at OpenSim.Region.Framework.Scenes.SceneGraph.UpdatePhysics (double) <0x00042>
+ at OpenSim.Region.Framework.Scenes.Scene.Update () <0x0039e>
+ at OpenSim.Region.Framework.Scenes.Scene.Heartbeat (object) <0x00019>
+ at (wrapper runtime-invoke) object.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>
+
+ Native stacktrace:
+
+ mono [0x80d2a42]
+ [0xb7f5840c]
+ /lib/i686/cmov/libc.so.6(abort+0x188) [0xb7d1a018]
+ /usr/lib/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x158) [0xb45fc988]
+ /usr/lib/libstdc++.so.6 [0xb45fa865]
+ /usr/lib/libstdc++.so.6 [0xb45fa8a2]
+ /usr/lib/libstdc++.so.6 [0xb45fa9da]
+ /usr/lib/libstdc++.so.6(_Znwj+0x83) [0xb45fb033]
+ /usr/lib/libstdc++.so.6(_Znaj+0x1d) [0xb45fb11d]
+ libode.so(_ZN13dxHeightfield23dCollideHeightfieldZoneEiiiiP6dxGeomiiP12dContactGeomi+0xd04) [0xb46678e4]
+ libode.so(_Z19dCollideHeightfieldP6dxGeomS0_iP12dContactGeomi+0x54b) [0xb466832b]
+ libode.so(dCollide+0x102) [0xb46571b2]
+ [0x95cfdec9]
+ [0x8ea07fe1]
+ [0xab260146]
+ libode.so [0xb465a5c4]
+ libode.so(_ZN11dxHashSpace8collide2EPvP6dxGeomPFvS0_S2_S2_E+0x75) [0xb465bcf5]
+ libode.so(dSpaceCollide2+0x177) [0xb465ac67]
+ [0x95cf978e]
+ [0x8ea07945]
+ [0x95cf2bbc]
+ [0xab2787e7]
+ [0xab419fb3]
+ [0xab416657]
+ [0xab415bda]
+ [0xb609b08e]
+ mono(mono_runtime_delegate_invoke+0x34) [0x8192534]
+ mono [0x81a2f0f]
+ mono [0x81d28b6]
+ mono [0x81ea2c6]
+ /lib/i686/cmov/libpthread.so.0 [0xb7e744c0]
+ /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb7dcd6de]
+ */
+
+ // Exclude heightfield geom
+
+ if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
+ return;
+ if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass || d.GeomGetClass(g2) == d.GeomClassID.HeightfieldClass)
+ return;
+
+ // Raytest against AABBs of spaces first, then dig into the spaces it hits for actual geoms.
+ if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
+ {
+ if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
+ return;
+
+ // Separating static prim geometry spaces.
+ // We'll be calling near recursivly if one
+ // of them is a space to find all of the
+ // contact points in the space
+ try
+ {
+ d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to collide test a space");
+ return;
+ }
+ //Colliding a space or a geom with a space or a geom. so drill down
+
+ //Collide all geoms in each space..
+ //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback);
+ //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback);
+ return;
+ }
+
+ if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
+ return;
+
+ int count = 0;
+ try
+ {
+
+ if (g1 == g2)
+ return; // Can't collide with yourself
+
+ lock (contacts)
+ {
+ count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
+ }
+ }
+ catch (SEHException)
+ {
+ m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[PHYSICS]: Unable to collide test an object: {0}", e.Message);
+ return;
+ }
+
+ PhysicsActor p1 = null;
+ PhysicsActor p2 = null;
+
+ if (g1 != IntPtr.Zero)
+ m_scene.actor_name_map.TryGetValue(g1, out p1);
+
+ if (g2 != IntPtr.Zero)
+ m_scene.actor_name_map.TryGetValue(g1, out p2);
+
+ // Loop over contacts, build results.
+ for (int i = 0; i < count; i++)
+ {
+ if (p1 != null) {
+ if (p1 is OdePrim)
+ {
+ ContactResult collisionresult = new ContactResult();
+
+ collisionresult.ConsumerID = ((OdePrim)p1).m_localID;
+ collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z);
+ collisionresult.Depth = contacts[i].depth;
+ collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y,
+ contacts[i].normal.Z);
+ lock (m_contactResults)
+ m_contactResults.Add(collisionresult);
+ }
+ }
+
+ if (p2 != null)
+ {
+ if (p2 is OdePrim)
+ {
+ ContactResult collisionresult = new ContactResult();
+
+ collisionresult.ConsumerID = ((OdePrim)p2).m_localID;
+ collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z);
+ collisionresult.Depth = contacts[i].depth;
+ collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y,
+ contacts[i].normal.Z);
+
+ lock (m_contactResults)
+ m_contactResults.Add(collisionresult);
+ }
+ }
+
+
+ }
+
+ }
+
+ ///
+ /// Dereference the creator scene so that it can be garbage collected if needed.
+ ///
+ internal void Dispose()
+ {
+ m_scene = null;
+ }
+ }
+
+ public struct ODERayCastRequest
+ {
+ public Vector3 Origin;
+ public Vector3 Normal;
+ public float length;
+ public RaycastCallback callbackMethod;
+ }
+
+ public struct ContactResult
+ {
+ public Vector3 Pos;
+ public float Depth;
+ public uint ConsumerID;
+ public Vector3 Normal;
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePhysicsJoint.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePhysicsJoint.cs
new file mode 100644
index 0000000..b4a3c48
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdePhysicsJoint.cs
@@ -0,0 +1,48 @@
+/*
+ * 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 OpenMetaverse;
+using Ode.NET;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+using OpenSim.Region.Physics.OdePlugin;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ class OdePhysicsJoint : PhysicsJoint
+ {
+ public override bool IsInPhysicsEngine
+ {
+ get
+ {
+ return (jointID != IntPtr.Zero);
+ }
+ }
+ public IntPtr jointID;
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
new file mode 100644
index 0000000..f48649e
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
@@ -0,0 +1,3865 @@
+/*
+ * 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.
+ */
+
+//#define USE_DRAWSTUFF
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Threading;
+using System.IO;
+using System.Diagnostics;
+using log4net;
+using Nini.Config;
+using Ode.NET;
+#if USE_DRAWSTUFF
+using Drawstuff.NET;
+#endif
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+using OpenMetaverse;
+
+//using OpenSim.Region.Physics.OdePlugin.Meshing;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ ///
+ /// ODE plugin
+ ///
+ public class OdePlugin : IPhysicsPlugin
+ {
+ //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+
+ private CollisionLocker ode;
+ private OdeScene _mScene;
+
+ public OdePlugin()
+ {
+ ode = new CollisionLocker();
+ }
+
+ public bool Init()
+ {
+ return true;
+ }
+
+ public PhysicsScene GetScene(String sceneIdentifier)
+ {
+ if (_mScene == null)
+ {
+ // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
+ // http://opensimulator.org/mantis/view.php?id=2750).
+ d.InitODE();
+
+ _mScene = new OdeScene(ode, sceneIdentifier);
+ }
+ return (_mScene);
+ }
+
+ public string GetName()
+ {
+ return ("ChODE");
+ }
+
+ public void Dispose()
+ {
+ }
+ }
+
+ public enum StatusIndicators : int
+ {
+ Generic = 0,
+ Start = 1,
+ End = 2
+ }
+
+ public struct sCollisionData
+ {
+ public uint ColliderLocalId;
+ public uint CollidedWithLocalId;
+ public int NumberOfCollisions;
+ public int CollisionType;
+ public int StatusIndicator;
+ public int lastframe;
+ }
+
+ [Flags]
+ public enum CollisionCategories : int
+ {
+ Disabled = 0,
+ Geom = 0x00000001,
+ Body = 0x00000002,
+ Space = 0x00000004,
+ Character = 0x00000008,
+ Land = 0x00000010,
+ Water = 0x00000020,
+ Wind = 0x00000040,
+ Sensor = 0x00000080,
+ Selected = 0x00000100
+ }
+
+ ///
+ /// Material type for a primitive
+ ///
+ public enum Material : int
+ {
+ ///
+ Stone = 0,
+ ///
+ Metal = 1,
+ ///
+ Glass = 2,
+ ///
+ Wood = 3,
+ ///
+ Flesh = 4,
+ ///
+ Plastic = 5,
+ ///
+ Rubber = 6
+
+ }
+
+ public sealed class OdeScene : PhysicsScene
+ {
+ private readonly ILog m_log;
+ // private Dictionary m_storedCollisions = new Dictionary();
+
+ CollisionLocker ode;
+
+ private Random fluidRandomizer = new Random(Environment.TickCount);
+
+ private const uint m_regionWidth = Constants.RegionSize;
+ private const uint m_regionHeight = Constants.RegionSize;
+
+ private float ODE_STEPSIZE = 0.020f;
+ private float metersInSpace = 29.9f;
+ private float m_timeDilation = 1.0f;
+
+ public float gravityx = 0f;
+ public float gravityy = 0f;
+ public float gravityz = -9.8f;
+
+ private float contactsurfacelayer = 0.001f;
+
+ private int worldHashspaceLow = -4;
+ private int worldHashspaceHigh = 128;
+
+ private int smallHashspaceLow = -4;
+ private int smallHashspaceHigh = 66;
+
+ private float waterlevel = 0f;
+ private int framecount = 0;
+ //private int m_returncollisions = 10;
+
+ private readonly IntPtr contactgroup;
+
+ internal IntPtr LandGeom;
+ internal IntPtr WaterGeom;
+
+ private float nmTerrainContactFriction = 255.0f;
+ private float nmTerrainContactBounce = 0.1f;
+ private float nmTerrainContactERP = 0.1025f;
+
+ private float mTerrainContactFriction = 75f;
+ private float mTerrainContactBounce = 0.1f;
+ private float mTerrainContactERP = 0.05025f;
+
+ private float nmAvatarObjectContactFriction = 250f;
+ private float nmAvatarObjectContactBounce = 0.1f;
+
+ private float mAvatarObjectContactFriction = 75f;
+ private float mAvatarObjectContactBounce = 0.1f;
+
+ private float avPIDD = 3200f;
+ private float avPIDP = 1400f;
+ private float avCapRadius = 0.37f;
+ private float avStandupTensor = 2000000f;
+ private bool avCapsuleTilted = true; // true = old compatibility mode with leaning capsule; false = new corrected mode
+ public bool IsAvCapsuleTilted { get { return avCapsuleTilted; } set { avCapsuleTilted = value; } }
+ private float avDensity = 80f;
+ private float avHeightFudgeFactor = 0.52f;
+ private float avMovementDivisorWalk = 1.3f;
+ private float avMovementDivisorRun = 0.8f;
+ private float minimumGroundFlightOffset = 3f;
+ public float maximumMassObject = 10000.01f;
+
+ public bool meshSculptedPrim = true;
+ public bool forceSimplePrimMeshing = false;
+
+ public float meshSculptLOD = 32;
+ public float MeshSculptphysicalLOD = 16;
+
+ public float geomDefaultDensity = 10.000006836f;
+
+ public int geomContactPointsStartthrottle = 3;
+ public int geomUpdatesPerThrottledUpdate = 15;
+
+ public float bodyPIDD = 35f;
+ public float bodyPIDG = 25;
+
+ public int geomCrossingFailuresBeforeOutofbounds = 5;
+
+ public float bodyMotorJointMaxforceTensor = 2;
+
+ public int bodyFramesAutoDisable = 20;
+
+
+
+ private float[] _watermap;
+ private bool m_filterCollisions = true;
+
+ private d.NearCallback nearCallback;
+ public d.TriCallback triCallback;
+ public d.TriArrayCallback triArrayCallback;
+ private readonly HashSet _characters = new HashSet();
+ private readonly HashSet _prims = new HashSet();
+ private readonly HashSet _activeprims = new HashSet();
+ private readonly HashSet _taintedPrimH = new HashSet();
+ private readonly Object _taintedPrimLock = new Object();
+ private readonly List _taintedPrimL = new List();
+ private readonly HashSet _taintedActors = new HashSet();
+ private readonly List _perloopContact = new List();
+ private readonly List _collisionEventPrim = new List();
+ private readonly HashSet _badCharacter = new HashSet();
+ public Dictionary geom_name_map = new Dictionary();
+ public Dictionary actor_name_map = new Dictionary();
+ private bool m_NINJA_physics_joints_enabled = false;
+ //private Dictionary jointpart_name_map = new Dictionary();
+ private readonly Dictionary> joints_connecting_actor = new Dictionary>();
+ private d.ContactGeom[] contacts;
+ private readonly List requestedJointsToBeCreated = new List(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active
+ private readonly List pendingJoints = new List(); // can lock for longer. accessed only by OdeScene.
+ private readonly List activeJoints = new List(); // can lock for longer. accessed only by OdeScene.
+ private readonly List requestedJointsToBeDeleted = new List(); // lock only briefly. accessed by external code (to request deletion of joints) and by OdeScene.Simulate() to move those joints out of pending/active
+ private Object externalJointRequestsLock = new Object();
+ private readonly Dictionary SOPName_to_activeJoint = new Dictionary();
+ private readonly Dictionary SOPName_to_pendingJoint = new Dictionary();
+ private readonly DoubleDictionary RegionTerrain = new DoubleDictionary();
+ private readonly Dictionary TerrainHeightFieldHeights = new Dictionary();
+
+ private d.Contact contact;
+ private d.Contact TerrainContact;
+ private d.Contact AvatarMovementprimContact;
+ private d.Contact AvatarMovementTerrainContact;
+ private d.Contact WaterContact;
+ private d.Contact[,] m_materialContacts;
+
+//Ckrinke: Comment out until used. We declare it, initialize it, but do not use it
+//Ckrinke private int m_randomizeWater = 200;
+ private int m_physicsiterations = 10;
+ private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
+ private readonly PhysicsActor PANull = new NullPhysicsActor();
+ private float step_time = 0.0f;
+//Ckrinke: Comment out until used. We declare it, initialize it, but do not use it
+//Ckrinke private int ms = 0;
+ public IntPtr world;
+ //private bool returncollisions = false;
+ // private uint obj1LocalID = 0;
+ private uint obj2LocalID = 0;
+ //private int ctype = 0;
+ private OdeCharacter cc1;
+ private OdePrim cp1;
+ private OdeCharacter cc2;
+ private OdePrim cp2;
+ //private int cStartStop = 0;
+ //private string cDictKey = "";
+
+ public IntPtr space;
+
+ //private IntPtr tmpSpace;
+ // split static geometry collision handling into spaces of 30 meters
+ public IntPtr[,] staticPrimspace;
+
+ public Object OdeLock;
+
+ public IMesher mesher;
+
+ private IConfigSource m_config;
+
+ public bool physics_logging = false;
+ public int physics_logging_interval = 0;
+ public bool physics_logging_append_existing_logfile = false;
+
+ public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f);
+ public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f);
+
+ // TODO: unused: private uint heightmapWidth = m_regionWidth + 1;
+ // TODO: unused: private uint heightmapHeight = m_regionHeight + 1;
+ // TODO: unused: private uint heightmapWidthSamples;
+ // TODO: unused: private uint heightmapHeightSamples;
+
+ private volatile int m_global_contactcount = 0;
+
+ private Vector3 m_worldOffset = Vector3.Zero;
+ public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
+ private PhysicsScene m_parentScene = null;
+
+ private ODERayCastRequestManager m_rayCastManager;
+
+ ///
+ /// Initiailizes the scene
+ /// Sets many properties that ODE requires to be stable
+ /// These settings need to be tweaked 'exactly' right or weird stuff happens.
+ ///
+ public OdeScene(CollisionLocker dode, string sceneIdentifier)
+ {
+ m_log
+ = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + sceneIdentifier);
+
+ OdeLock = new Object();
+ ode = dode;
+ nearCallback = near;
+ triCallback = TriCallback;
+ triArrayCallback = TriArrayCallback;
+ m_rayCastManager = new ODERayCastRequestManager(this);
+ lock (OdeLock)
+ {
+ // Create the world and the first space
+ world = d.WorldCreate();
+ space = d.HashSpaceCreate(IntPtr.Zero);
+
+
+ contactgroup = d.JointGroupCreate(0);
+ //contactgroup
+
+ d.WorldSetAutoDisableFlag(world, false);
+ #if USE_DRAWSTUFF
+
+ Thread viewthread = new Thread(new ParameterizedThreadStart(startvisualization));
+ viewthread.Start();
+ #endif
+ }
+
+
+ _watermap = new float[258 * 258];
+
+ // Zero out the prim spaces array (we split our space into smaller spaces so
+ // we can hit test less.
+ }
+
+#if USE_DRAWSTUFF
+ public void startvisualization(object o)
+ {
+ ds.Functions fn;
+ fn.version = ds.VERSION;
+ fn.start = new ds.CallbackFunction(start);
+ fn.step = new ds.CallbackFunction(step);
+ fn.command = new ds.CallbackFunction(command);
+ fn.stop = null;
+ fn.path_to_textures = "./textures";
+ string[] args = new string[0];
+ ds.SimulationLoop(args.Length, args, 352, 288, ref fn);
+ }
+#endif
+
+ // Initialize the mesh plugin
+ public override void Initialise(IMesher meshmerizer, IConfigSource config)
+ {
+ mesher = meshmerizer;
+ m_config = config;
+ // Defaults
+
+ if (Environment.OSVersion.Platform == PlatformID.Unix)
+ {
+ avPIDD = 3200.0f;
+ avPIDP = 1400.0f;
+ avStandupTensor = 2000000f;
+ }
+ else
+ {
+ avPIDD = 2200.0f;
+ avPIDP = 900.0f;
+ avStandupTensor = 550000f;
+ }
+
+ int contactsPerCollision = 80;
+
+ if (m_config != null)
+ {
+ IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"];
+ if (physicsconfig != null)
+ {
+ gravityx = physicsconfig.GetFloat("world_gravityx", 0f);
+ gravityy = physicsconfig.GetFloat("world_gravityy", 0f);
+ gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f);
+
+ worldHashspaceLow = physicsconfig.GetInt("world_hashspace_size_low", -4);
+ worldHashspaceHigh = physicsconfig.GetInt("world_hashspace_size_high", 128);
+
+ metersInSpace = physicsconfig.GetFloat("meters_in_small_space", 29.9f);
+ smallHashspaceLow = physicsconfig.GetInt("small_hashspace_size_low", -4);
+ smallHashspaceHigh = physicsconfig.GetInt("small_hashspace_size_high", 66);
+
+ contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", 0.001f);
+
+ nmTerrainContactFriction = physicsconfig.GetFloat("nm_terraincontact_friction", 255.0f);
+ nmTerrainContactBounce = physicsconfig.GetFloat("nm_terraincontact_bounce", 0.1f);
+ nmTerrainContactERP = physicsconfig.GetFloat("nm_terraincontact_erp", 0.1025f);
+
+ mTerrainContactFriction = physicsconfig.GetFloat("m_terraincontact_friction", 75f);
+ mTerrainContactBounce = physicsconfig.GetFloat("m_terraincontact_bounce", 0.05f);
+ mTerrainContactERP = physicsconfig.GetFloat("m_terraincontact_erp", 0.05025f);
+
+ nmAvatarObjectContactFriction = physicsconfig.GetFloat("objectcontact_friction", 250f);
+ nmAvatarObjectContactBounce = physicsconfig.GetFloat("objectcontact_bounce", 0.2f);
+
+ mAvatarObjectContactFriction = physicsconfig.GetFloat("m_avatarobjectcontact_friction", 75f);
+ mAvatarObjectContactBounce = physicsconfig.GetFloat("m_avatarobjectcontact_bounce", 0.1f);
+
+ ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f);
+ m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10);
+
+ avDensity = physicsconfig.GetFloat("av_density", 80f);
+ avHeightFudgeFactor = physicsconfig.GetFloat("av_height_fudge_factor", 0.52f);
+ avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f);
+ avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f);
+ avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f);
+ avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", false);
+
+ contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80);
+
+ geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
+ geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
+ geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5);
+
+ geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f);
+ bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20);
+
+ bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f);
+ bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f);
+
+ forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing);
+ meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true);
+ meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f);
+ MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f);
+ m_filterCollisions = physicsconfig.GetBoolean("filter_collisions", false);
+
+ if (Environment.OSVersion.Platform == PlatformID.Unix)
+ {
+ avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f);
+ avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 900.0f);
+ avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 550000f);
+ bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_linux", 5f);
+ }
+ else
+ {
+ avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f);
+ avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f);
+ avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f);
+ bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_win", 5f);
+ }
+
+ physics_logging = physicsconfig.GetBoolean("physics_logging", false);
+ physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0);
+ physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false);
+
+ m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false);
+ minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f);
+ maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 10000.01f);
+ }
+ }
+
+ contacts = new d.ContactGeom[contactsPerCollision];
+
+ staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)];
+
+ // Centeral contact friction and bounce
+ // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why
+ // an avatar falls through in Z but not in X or Y when walking on a prim.
+ contact.surface.mode |= d.ContactFlags.SoftERP;
+ contact.surface.mu = nmAvatarObjectContactFriction;
+ contact.surface.bounce = nmAvatarObjectContactBounce;
+ contact.surface.soft_cfm = 0.010f;
+ contact.surface.soft_erp = 0.010f;
+
+ // Terrain contact friction and Bounce
+ // This is the *non* moving version. Use this when an avatar
+ // isn't moving to keep it in place better
+ TerrainContact.surface.mode |= d.ContactFlags.SoftERP;
+ TerrainContact.surface.mu = nmTerrainContactFriction;
+ TerrainContact.surface.bounce = nmTerrainContactBounce;
+ TerrainContact.surface.soft_erp = nmTerrainContactERP;
+
+ WaterContact.surface.mode |= (d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM);
+ WaterContact.surface.mu = 0f; // No friction
+ WaterContact.surface.bounce = 0.0f; // No bounce
+ WaterContact.surface.soft_cfm = 0.010f;
+ WaterContact.surface.soft_erp = 0.010f;
+
+ // Prim contact friction and bounce
+ // THis is the *non* moving version of friction and bounce
+ // Use this when an avatar comes in contact with a prim
+ // and is moving
+ AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction;
+ AvatarMovementprimContact.surface.bounce = mAvatarObjectContactBounce;
+
+ // Terrain contact friction bounce and various error correcting calculations
+ // Use this when an avatar is in contact with the terrain and moving.
+ AvatarMovementTerrainContact.surface.mode |= d.ContactFlags.SoftERP;
+ AvatarMovementTerrainContact.surface.mu = mTerrainContactFriction;
+ AvatarMovementTerrainContact.surface.bounce = mTerrainContactBounce;
+ AvatarMovementTerrainContact.surface.soft_erp = mTerrainContactERP;
+
+
+ /*
+
+ Stone = 0,
+ ///
+ Metal = 1,
+ ///
+ Glass = 2,
+ ///
+ Wood = 3,
+ ///
+ Flesh = 4,
+ ///
+ Plastic = 5,
+ ///
+ Rubber = 6
+ */
+
+ m_materialContacts = new d.Contact[7,2];
+
+ m_materialContacts[(int)Material.Stone, 0] = new d.Contact();
+ m_materialContacts[(int)Material.Stone, 0].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Stone, 0].surface.mu = nmAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Stone, 0].surface.bounce = nmAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Stone, 0].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Stone, 0].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Stone, 1] = new d.Contact();
+ m_materialContacts[(int)Material.Stone, 1].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Stone, 1].surface.mu = mAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Stone, 1].surface.bounce = mAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Stone, 1].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Stone, 1].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Metal, 0] = new d.Contact();
+ m_materialContacts[(int)Material.Metal, 0].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Metal, 0].surface.mu = nmAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Metal, 0].surface.bounce = nmAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Metal, 0].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Metal, 0].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Metal, 1] = new d.Contact();
+ m_materialContacts[(int)Material.Metal, 1].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Metal, 1].surface.mu = mAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Metal, 1].surface.bounce = mAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Metal, 1].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Metal, 1].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Glass, 0] = new d.Contact();
+ m_materialContacts[(int)Material.Glass, 0].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Glass, 0].surface.mu = 1f;
+ m_materialContacts[(int)Material.Glass, 0].surface.bounce = 0.5f;
+ m_materialContacts[(int)Material.Glass, 0].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Glass, 0].surface.soft_erp = 0.010f;
+
+ /*
+ private float nmAvatarObjectContactFriction = 250f;
+ private float nmAvatarObjectContactBounce = 0.1f;
+
+ private float mAvatarObjectContactFriction = 75f;
+ private float mAvatarObjectContactBounce = 0.1f;
+ */
+ m_materialContacts[(int)Material.Glass, 1] = new d.Contact();
+ m_materialContacts[(int)Material.Glass, 1].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Glass, 1].surface.mu = 1f;
+ m_materialContacts[(int)Material.Glass, 1].surface.bounce = 0.5f;
+ m_materialContacts[(int)Material.Glass, 1].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Glass, 1].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Wood, 0] = new d.Contact();
+ m_materialContacts[(int)Material.Wood, 0].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Wood, 0].surface.mu = nmAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Wood, 0].surface.bounce = nmAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Wood, 0].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Wood, 0].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Wood, 1] = new d.Contact();
+ m_materialContacts[(int)Material.Wood, 1].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Wood, 1].surface.mu = mAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Wood, 1].surface.bounce = mAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Wood, 1].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Wood, 1].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Flesh, 0] = new d.Contact();
+ m_materialContacts[(int)Material.Flesh, 0].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Flesh, 0].surface.mu = nmAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Flesh, 0].surface.bounce = nmAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Flesh, 0].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Flesh, 0].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Flesh, 1] = new d.Contact();
+ m_materialContacts[(int)Material.Flesh, 1].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Flesh, 1].surface.mu = mAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Flesh, 1].surface.bounce = mAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Flesh, 1].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Flesh, 1].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Plastic, 0] = new d.Contact();
+ m_materialContacts[(int)Material.Plastic, 0].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Plastic, 0].surface.mu = nmAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Plastic, 0].surface.bounce = nmAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Plastic, 0].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Plastic, 0].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Plastic, 1] = new d.Contact();
+ m_materialContacts[(int)Material.Plastic, 1].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Plastic, 1].surface.mu = mAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Plastic, 1].surface.bounce = mAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Plastic, 1].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Plastic, 1].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Rubber, 0] = new d.Contact();
+ m_materialContacts[(int)Material.Rubber, 0].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Rubber, 0].surface.mu = nmAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Rubber, 0].surface.bounce = nmAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Rubber, 0].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Rubber, 0].surface.soft_erp = 0.010f;
+
+ m_materialContacts[(int)Material.Rubber, 1] = new d.Contact();
+ m_materialContacts[(int)Material.Rubber, 1].surface.mode |= d.ContactFlags.SoftERP;
+ m_materialContacts[(int)Material.Rubber, 1].surface.mu = mAvatarObjectContactFriction;
+ m_materialContacts[(int)Material.Rubber, 1].surface.bounce = mAvatarObjectContactBounce;
+ m_materialContacts[(int)Material.Rubber, 1].surface.soft_cfm = 0.010f;
+ m_materialContacts[(int)Material.Rubber, 1].surface.soft_erp = 0.010f;
+
+ d.HashSpaceSetLevels(space, worldHashspaceLow, worldHashspaceHigh);
+
+ // Set the gravity,, don't disable things automatically (we set it explicitly on some things)
+
+ d.WorldSetGravity(world, gravityx, gravityy, gravityz);
+ d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
+
+ d.WorldSetLinearDamping(world, 256f);
+ d.WorldSetAngularDamping(world, 256f);
+ d.WorldSetAngularDampingThreshold(world, 256f);
+ d.WorldSetLinearDampingThreshold(world, 256f);
+ d.WorldSetMaxAngularSpeed(world, 256f);
+
+ // Set how many steps we go without running collision testing
+ // This is in addition to the step size.
+ // Essentially Steps * m_physicsiterations
+ d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
+ //d.WorldSetContactMaxCorrectingVel(world, 1000.0f);
+
+
+
+ for (int i = 0; i < staticPrimspace.GetLength(0); i++)
+ {
+ for (int j = 0; j < staticPrimspace.GetLength(1); j++)
+ {
+ staticPrimspace[i, j] = IntPtr.Zero;
+ }
+ }
+ }
+
+ internal void waitForSpaceUnlock(IntPtr space)
+ {
+ //if (space != IntPtr.Zero)
+ //while (d.SpaceLockQuery(space)) { } // Wait and do nothing
+ }
+
+ ///
+ /// Debug space message for printing the space that a prim/avatar is in.
+ ///
+ ///
+ /// Returns which split up space the given position is in.
+ public string whichspaceamIin(Vector3 pos)
+ {
+ return calculateSpaceForGeom(pos).ToString();
+ }
+
+ #region Collision Detection
+
+ ///
+ /// This is our near callback. A geometry is near a body
+ ///
+ /// The space that contains the geoms. Remember, spaces are also geoms
+ /// a geometry or space
+ /// another geometry or space
+ private void near(IntPtr space, IntPtr g1, IntPtr g2)
+ {
+ // no lock here! It's invoked from within Simulate(), which is thread-locked
+
+ // Test if we're colliding a geom with a space.
+ // If so we have to drill down into the space recursively
+
+ if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
+ {
+ if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
+ return;
+
+ // Separating static prim geometry spaces.
+ // We'll be calling near recursivly if one
+ // of them is a space to find all of the
+ // contact points in the space
+ try
+ {
+ d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to collide test a space");
+ return;
+ }
+ //Colliding a space or a geom with a space or a geom. so drill down
+
+ //Collide all geoms in each space..
+ //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback);
+ //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback);
+ return;
+ }
+
+ if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
+ return;
+
+ IntPtr b1 = d.GeomGetBody(g1);
+ IntPtr b2 = d.GeomGetBody(g2);
+
+ // d.GeomClassID id = d.GeomGetClass(g1);
+
+ String name1 = null;
+ String name2 = null;
+
+ if (!geom_name_map.TryGetValue(g1, out name1))
+ {
+ name1 = "null";
+ }
+ if (!geom_name_map.TryGetValue(g2, out name2))
+ {
+ name2 = "null";
+ }
+
+ //if (id == d.GeomClassId.TriMeshClass)
+ //{
+ // m_log.InfoFormat("near: A collision was detected between {1} and {2}", 0, name1, name2);
+ //m_log.Debug("near: A collision was detected between {1} and {2}", 0, name1, name2);
+ //}
+
+ // Figure out how many contact points we have
+ int count = 0;
+ try
+ {
+ // Colliding Geom To Geom
+ // This portion of the function 'was' blatantly ripped off from BoxStack.cs
+
+ if (g1 == g2)
+ return; // Can't collide with yourself
+
+ if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
+ return;
+
+ lock (contacts)
+ {
+ count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
+ if (count > contacts.Length)
+ m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
+ }
+ }
+ catch (SEHException)
+ {
+ m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
+ ode.drelease(world);
+ base.TriggerPhysicsBasedRestart();
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[PHYSICS]: Unable to collide test an object: {0}", e.Message);
+ return;
+ }
+
+ PhysicsActor p1;
+ PhysicsActor p2;
+
+ if (!actor_name_map.TryGetValue(g1, out p1))
+ {
+ p1 = PANull;
+ }
+
+ if (!actor_name_map.TryGetValue(g2, out p2))
+ {
+ p2 = PANull;
+ }
+
+ ContactPoint maxDepthContact = new ContactPoint();
+ if (p1.CollisionScore + count >= float.MaxValue)
+ p1.CollisionScore = 0;
+ p1.CollisionScore += count;
+
+ if (p2.CollisionScore + count >= float.MaxValue)
+ p2.CollisionScore = 0;
+ p2.CollisionScore += count;
+
+ for (int i = 0; i < count; i++)
+ {
+ d.ContactGeom curContact = contacts[i];
+
+ if (curContact.depth > maxDepthContact.PenetrationDepth)
+ {
+ maxDepthContact = new ContactPoint(
+ new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
+ new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
+ curContact.depth
+ );
+ }
+
+ //m_log.Warn("[CCOUNT]: " + count);
+ IntPtr joint;
+ // If we're colliding with terrain, use 'TerrainContact' instead of contact.
+ // allows us to have different settings
+
+ // We only need to test p2 for 'jump crouch purposes'
+ if (p2 is OdeCharacter && p1.PhysicsActorType == (int)ActorTypes.Prim)
+ {
+ // Testing if the collision is at the feet of the avatar
+
+ //m_log.DebugFormat("[PHYSICS]: {0} - {1} - {2} - {3}", curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f));
+ if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f))
+ p2.IsColliding = true;
+ }
+ else
+ {
+ p2.IsColliding = true;
+ }
+
+ //if ((framecount % m_returncollisions) == 0)
+
+ switch (p1.PhysicsActorType)
+ {
+ case (int)ActorTypes.Agent:
+ p2.CollidingObj = true;
+ break;
+ case (int)ActorTypes.Prim:
+ if (p2.Velocity.LengthSquared() > 0.0f)
+ p2.CollidingObj = true;
+ break;
+ case (int)ActorTypes.Unknown:
+ p2.CollidingGround = true;
+ break;
+ default:
+ p2.CollidingGround = true;
+ break;
+ }
+
+ // we don't want prim or avatar to explode
+
+ #region InterPenetration Handling - Unintended physics explosions
+# region disabled code1
+
+ if (curContact.depth >= 0.08f)
+ {
+ //This is disabled at the moment only because it needs more tweaking
+ //It will eventually be uncommented
+ /*
+ if (contact.depth >= 1.00f)
+ {
+ //m_log.Debug("[PHYSICS]: " + contact.depth.ToString());
+ }
+
+ //If you interpenetrate a prim with an agent
+ if ((p2.PhysicsActorType == (int) ActorTypes.Agent &&
+ p1.PhysicsActorType == (int) ActorTypes.Prim) ||
+ (p1.PhysicsActorType == (int) ActorTypes.Agent &&
+ p2.PhysicsActorType == (int) ActorTypes.Prim))
+ {
+
+ //contact.depth = contact.depth * 4.15f;
+ /*
+ if (p2.PhysicsActorType == (int) ActorTypes.Agent)
+ {
+ p2.CollidingObj = true;
+ contact.depth = 0.003f;
+ p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f);
+ OdeCharacter character = (OdeCharacter) p2;
+ character.SetPidStatus(true);
+ contact.pos = new d.Vector3(contact.pos.X + (p1.Size.X / 2), contact.pos.Y + (p1.Size.Y / 2), contact.pos.Z + (p1.Size.Z / 2));
+
+ }
+ else
+ {
+
+ //contact.depth = 0.0000000f;
+ }
+ if (p1.PhysicsActorType == (int) ActorTypes.Agent)
+ {
+
+ p1.CollidingObj = true;
+ contact.depth = 0.003f;
+ p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f);
+ contact.pos = new d.Vector3(contact.pos.X + (p2.Size.X / 2), contact.pos.Y + (p2.Size.Y / 2), contact.pos.Z + (p2.Size.Z / 2));
+ OdeCharacter character = (OdeCharacter)p1;
+ character.SetPidStatus(true);
+ }
+ else
+ {
+
+ //contact.depth = 0.0000000f;
+ }
+
+
+
+ }
+*/
+ // If you interpenetrate a prim with another prim
+ /*
+ if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim)
+ {
+ #region disabledcode2
+ //OdePrim op1 = (OdePrim)p1;
+ //OdePrim op2 = (OdePrim)p2;
+ //op1.m_collisionscore++;
+ //op2.m_collisionscore++;
+
+ //if (op1.m_collisionscore > 8000 || op2.m_collisionscore > 8000)
+ //{
+ //op1.m_taintdisable = true;
+ //AddPhysicsActorTaint(p1);
+ //op2.m_taintdisable = true;
+ //AddPhysicsActorTaint(p2);
+ //}
+
+ //if (contact.depth >= 0.25f)
+ //{
+ // Don't collide, one or both prim will expld.
+
+ //op1.m_interpenetrationcount++;
+ //op2.m_interpenetrationcount++;
+ //interpenetrations_before_disable = 200;
+ //if (op1.m_interpenetrationcount >= interpenetrations_before_disable)
+ //{
+ //op1.m_taintdisable = true;
+ //AddPhysicsActorTaint(p1);
+ //}
+ //if (op2.m_interpenetrationcount >= interpenetrations_before_disable)
+ //{
+ // op2.m_taintdisable = true;
+ //AddPhysicsActorTaint(p2);
+ //}
+
+ //contact.depth = contact.depth / 8f;
+ //contact.normal = new d.Vector3(0, 0, 1);
+ //}
+ //if (op1.m_disabled || op2.m_disabled)
+ //{
+ //Manually disabled objects stay disabled
+ //contact.depth = 0f;
+ //}
+ #endregion
+ }
+ */
+#endregion
+ if (curContact.depth >= 1.00f)
+ {
+ //m_log.Info("[P]: " + contact.depth.ToString());
+ if ((p2.PhysicsActorType == (int) ActorTypes.Agent &&
+ p1.PhysicsActorType == (int) ActorTypes.Unknown) ||
+ (p1.PhysicsActorType == (int) ActorTypes.Agent &&
+ p2.PhysicsActorType == (int) ActorTypes.Unknown))
+ {
+ if (p2.PhysicsActorType == (int) ActorTypes.Agent)
+ {
+ if (p2 is OdeCharacter)
+ {
+ OdeCharacter character = (OdeCharacter) p2;
+
+ //p2.CollidingObj = true;
+ curContact.depth = 0.00000003f;
+ p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f);
+ curContact.pos =
+ new d.Vector3(curContact.pos.X + (p1.Size.X/2),
+ curContact.pos.Y + (p1.Size.Y/2),
+ curContact.pos.Z + (p1.Size.Z/2));
+ character.SetPidStatus(true);
+ }
+ }
+
+
+ if (p1.PhysicsActorType == (int) ActorTypes.Agent)
+ {
+ if (p1 is OdeCharacter)
+ {
+ OdeCharacter character = (OdeCharacter) p1;
+
+ //p2.CollidingObj = true;
+ curContact.depth = 0.00000003f;
+ p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f);
+ curContact.pos =
+ new d.Vector3(curContact.pos.X + (p1.Size.X/2),
+ curContact.pos.Y + (p1.Size.Y/2),
+ curContact.pos.Z + (p1.Size.Z/2));
+ character.SetPidStatus(true);
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ // Logic for collision handling
+ // Note, that if *all* contacts are skipped (VolumeDetect)
+ // The prim still detects (and forwards) collision events but
+ // appears to be phantom for the world
+ Boolean skipThisContact = false;
+
+ if ((p1 is OdePrim) && (((OdePrim)p1).m_isVolumeDetect))
+ skipThisContact = true; // No collision on volume detect prims
+
+ if (!skipThisContact && (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect))
+ skipThisContact = true; // No collision on volume detect prims
+
+ if (!skipThisContact && curContact.depth < 0f)
+ skipThisContact = true;
+
+ if (!skipThisContact && checkDupe(curContact, p2.PhysicsActorType))
+ skipThisContact = true;
+
+ const int maxContactsbeforedeath = 4000;
+ joint = IntPtr.Zero;
+
+ if (!skipThisContact)
+ {
+ // If we're colliding against terrain
+ if (name1 == "Terrain" || name2 == "Terrain")
+ {
+ // If we're moving
+ if ((p2.PhysicsActorType == (int) ActorTypes.Agent) &&
+ (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
+ {
+ // Use the movement terrain contact
+ AvatarMovementTerrainContact.geom = curContact;
+ _perloopContact.Add(curContact);
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
+ m_global_contactcount++;
+ }
+ }
+ else
+ {
+ if (p2.PhysicsActorType == (int)ActorTypes.Agent)
+ {
+ // Use the non moving terrain contact
+ TerrainContact.geom = curContact;
+ _perloopContact.Add(curContact);
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
+ m_global_contactcount++;
+ }
+ }
+ else
+ {
+ if (p2.PhysicsActorType == (int)ActorTypes.Prim && p1.PhysicsActorType == (int)ActorTypes.Prim)
+ {
+ // prim prim contact
+ // int pj294950 = 0;
+ int movintYN = 0;
+ int material = (int) Material.Wood;
+ // prim terrain contact
+ if (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)
+ {
+ movintYN = 1;
+ }
+
+ if (p2 is OdePrim)
+ material = ((OdePrim)p2).m_material;
+
+ //m_log.DebugFormat("Material: {0}", material);
+ m_materialContacts[material, movintYN].geom = curContact;
+ _perloopContact.Add(curContact);
+
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]);
+ m_global_contactcount++;
+
+ }
+
+ }
+ else
+ {
+
+ int movintYN = 0;
+ // prim terrain contact
+ if (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)
+ {
+ movintYN = 1;
+ }
+
+ int material = (int)Material.Wood;
+
+ if (p2 is OdePrim)
+ material = ((OdePrim)p2).m_material;
+ //m_log.DebugFormat("Material: {0}", material);
+ m_materialContacts[material, movintYN].geom = curContact;
+ _perloopContact.Add(curContact);
+
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]);
+ m_global_contactcount++;
+
+ }
+ }
+ }
+ }
+ //if (p2.PhysicsActorType == (int)ActorTypes.Prim)
+ //{
+ //m_log.Debug("[PHYSICS]: prim contacting with ground");
+ //}
+ }
+ else if (name1 == "Water" || name2 == "Water")
+ {
+ /*
+ if ((p2.PhysicsActorType == (int) ActorTypes.Prim))
+ {
+ }
+ else
+ {
+ }
+ */
+ //WaterContact.surface.soft_cfm = 0.0000f;
+ //WaterContact.surface.soft_erp = 0.00000f;
+ if (curContact.depth > 0.1f)
+ {
+ curContact.depth *= 52;
+ //contact.normal = new d.Vector3(0, 0, 1);
+ //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f);
+ }
+ WaterContact.geom = curContact;
+ _perloopContact.Add(curContact);
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
+ m_global_contactcount++;
+ }
+ //m_log.Info("[PHYSICS]: Prim Water Contact" + contact.depth);
+ }
+ else
+ {
+ // we're colliding with prim or avatar
+ // check if we're moving
+ if ((p2.PhysicsActorType == (int)ActorTypes.Agent))
+ {
+ if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
+ {
+ // Use the Movement prim contact
+ AvatarMovementprimContact.geom = curContact;
+ _perloopContact.Add(curContact);
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
+ m_global_contactcount++;
+ }
+ }
+ else
+ {
+ // Use the non movement contact
+ contact.geom = curContact;
+ _perloopContact.Add(curContact);
+
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref contact);
+ m_global_contactcount++;
+ }
+ }
+ }
+ else if (p2.PhysicsActorType == (int)ActorTypes.Prim)
+ {
+ //p1.PhysicsActorType
+ int material = (int)Material.Wood;
+
+ if (p2 is OdePrim)
+ material = ((OdePrim)p2).m_material;
+
+ //m_log.DebugFormat("Material: {0}", material);
+ m_materialContacts[material, 0].geom = curContact;
+ _perloopContact.Add(curContact);
+
+ if (m_global_contactcount < maxContactsbeforedeath)
+ {
+ joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]);
+ m_global_contactcount++;
+
+ }
+ }
+ }
+
+ if (m_global_contactcount < maxContactsbeforedeath && joint != IntPtr.Zero) // stack collide!
+ {
+ d.JointAttach(joint, b1, b2);
+ m_global_contactcount++;
+ }
+
+ }
+ collision_accounting_events(p1, p2, maxDepthContact);
+ if (count > geomContactPointsStartthrottle)
+ {
+ // If there are more then 3 contact points, it's likely
+ // that we've got a pile of objects, so ...
+ // We don't want to send out hundreds of terse updates over and over again
+ // so lets throttle them and send them again after it's somewhat sorted out.
+ p2.ThrottleUpdates = true;
+ }
+ //m_log.Debug(count.ToString());
+ //m_log.Debug("near: A collision was detected between {1} and {2}", 0, name1, name2);
+ }
+ }
+
+ private bool checkDupe(d.ContactGeom contactGeom, int atype)
+ {
+ bool result = false;
+ //return result;
+ if (!m_filterCollisions)
+ return false;
+
+ ActorTypes at = (ActorTypes)atype;
+ lock (_perloopContact)
+ {
+ foreach (d.ContactGeom contact in _perloopContact)
+ {
+ //if ((contact.g1 == contactGeom.g1 && contact.g2 == contactGeom.g2))
+ //{
+ // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2)
+ if (at == ActorTypes.Agent)
+ {
+ if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+ {
+
+ if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
+ {
+ //contactGeom.depth *= .00005f;
+ //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+ // m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+ result = true;
+ break;
+ }
+ else
+ {
+ //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+ }
+ }
+ else
+ {
+ //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+ //int i = 0;
+ }
+ }
+ else if (at == ActorTypes.Prim)
+ {
+ //d.AABB aabb1 = new d.AABB();
+ //d.AABB aabb2 = new d.AABB();
+
+ //d.GeomGetAABB(contactGeom.g2, out aabb2);
+ //d.GeomGetAABB(contactGeom.g1, out aabb1);
+ //aabb1.
+ if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+ {
+ if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
+ {
+ if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
+ {
+ result = true;
+ break;
+ }
+ }
+ //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+ //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+ }
+
+ }
+
+ //}
+
+ }
+ }
+ return result;
+ }
+
+ private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
+ {
+ // obj1LocalID = 0;
+ //returncollisions = false;
+ obj2LocalID = 0;
+ //ctype = 0;
+ //cStartStop = 0;
+ if (!p2.SubscribedEvents() && !p1.SubscribedEvents())
+ return;
+
+ switch ((ActorTypes)p2.PhysicsActorType)
+ {
+ case ActorTypes.Agent:
+ cc2 = (OdeCharacter)p2;
+
+ // obj1LocalID = cc2.m_localID;
+ switch ((ActorTypes)p1.PhysicsActorType)
+ {
+ case ActorTypes.Agent:
+ cc1 = (OdeCharacter)p1;
+ obj2LocalID = cc1.m_localID;
+ cc1.AddCollisionEvent(cc2.m_localID, contact);
+ //ctype = (int)CollisionCategories.Character;
+
+ //if (cc1.CollidingObj)
+ //cStartStop = (int)StatusIndicators.Generic;
+ //else
+ //cStartStop = (int)StatusIndicators.Start;
+
+ //returncollisions = true;
+ break;
+ case ActorTypes.Prim:
+ if (p1 is OdePrim)
+ {
+ cp1 = (OdePrim) p1;
+ obj2LocalID = cp1.m_localID;
+ cp1.AddCollisionEvent(cc2.m_localID, contact);
+ }
+ //ctype = (int)CollisionCategories.Geom;
+
+ //if (cp1.CollidingObj)
+ //cStartStop = (int)StatusIndicators.Generic;
+ //else
+ //cStartStop = (int)StatusIndicators.Start;
+
+ //returncollisions = true;
+ break;
+
+ case ActorTypes.Ground:
+ case ActorTypes.Unknown:
+ obj2LocalID = 0;
+ //ctype = (int)CollisionCategories.Land;
+ //returncollisions = true;
+ break;
+ }
+
+ cc2.AddCollisionEvent(obj2LocalID, contact);
+ break;
+ case ActorTypes.Prim:
+
+ if (p2 is OdePrim)
+ {
+ cp2 = (OdePrim) p2;
+
+ // obj1LocalID = cp2.m_localID;
+ switch ((ActorTypes) p1.PhysicsActorType)
+ {
+ case ActorTypes.Agent:
+ if (p1 is OdeCharacter)
+ {
+ cc1 = (OdeCharacter) p1;
+ obj2LocalID = cc1.m_localID;
+ cc1.AddCollisionEvent(cp2.m_localID, contact);
+ //ctype = (int)CollisionCategories.Character;
+
+ //if (cc1.CollidingObj)
+ //cStartStop = (int)StatusIndicators.Generic;
+ //else
+ //cStartStop = (int)StatusIndicators.Start;
+ //returncollisions = true;
+ }
+ break;
+ case ActorTypes.Prim:
+
+ if (p1 is OdePrim)
+ {
+ cp1 = (OdePrim) p1;
+ obj2LocalID = cp1.m_localID;
+ cp1.AddCollisionEvent(cp2.m_localID, contact);
+ //ctype = (int)CollisionCategories.Geom;
+
+ //if (cp1.CollidingObj)
+ //cStartStop = (int)StatusIndicators.Generic;
+ //else
+ //cStartStop = (int)StatusIndicators.Start;
+
+ //returncollisions = true;
+ }
+ break;
+
+ case ActorTypes.Ground:
+ case ActorTypes.Unknown:
+ obj2LocalID = 0;
+ //ctype = (int)CollisionCategories.Land;
+
+ //returncollisions = true;
+ break;
+ }
+
+ cp2.AddCollisionEvent(obj2LocalID, contact);
+ }
+ break;
+ }
+ //if (returncollisions)
+ //{
+
+ //lock (m_storedCollisions)
+ //{
+ //cDictKey = obj1LocalID.ToString() + obj2LocalID.ToString() + cStartStop.ToString() + ctype.ToString();
+ //if (m_storedCollisions.ContainsKey(cDictKey))
+ //{
+ //sCollisionData objd = m_storedCollisions[cDictKey];
+ //objd.NumberOfCollisions += 1;
+ //objd.lastframe = framecount;
+ //m_storedCollisions[cDictKey] = objd;
+ //}
+ //else
+ //{
+ //sCollisionData objd = new sCollisionData();
+ //objd.ColliderLocalId = obj1LocalID;
+ //objd.CollidedWithLocalId = obj2LocalID;
+ //objd.CollisionType = ctype;
+ //objd.NumberOfCollisions = 1;
+ //objd.lastframe = framecount;
+ //objd.StatusIndicator = cStartStop;
+ //m_storedCollisions.Add(cDictKey, objd);
+ //}
+ //}
+ // }
+ }
+
+ public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount)
+ {
+ /* String name1 = null;
+ String name2 = null;
+
+ if (!geom_name_map.TryGetValue(trimesh, out name1))
+ {
+ name1 = "null";
+ }
+ if (!geom_name_map.TryGetValue(refObject, out name2))
+ {
+ name2 = "null";
+ }
+
+ m_log.InfoFormat("TriArrayCallback: A collision was detected between {1} and {2}", 0, name1, name2);
+ */
+ return 1;
+ }
+
+ public int TriCallback(IntPtr trimesh, IntPtr refObject, int triangleIndex)
+ {
+ String name1 = null;
+ String name2 = null;
+
+ if (!geom_name_map.TryGetValue(trimesh, out name1))
+ {
+ name1 = "null";
+ }
+
+ if (!geom_name_map.TryGetValue(refObject, out name2))
+ {
+ name2 = "null";
+ }
+
+ // m_log.InfoFormat("TriCallback: A collision was detected between {1} and {2}. Index was {3}", 0, name1, name2, triangleIndex);
+
+ d.Vector3 v0 = new d.Vector3();
+ d.Vector3 v1 = new d.Vector3();
+ d.Vector3 v2 = new d.Vector3();
+
+ d.GeomTriMeshGetTriangle(trimesh, 0, ref v0, ref v1, ref v2);
+ // m_log.DebugFormat("Triangle {0} is <{1},{2},{3}>, <{4},{5},{6}>, <{7},{8},{9}>", triangleIndex, v0.X, v0.Y, v0.Z, v1.X, v1.Y, v1.Z, v2.X, v2.Y, v2.Z);
+
+ return 1;
+ }
+
+ ///
+ /// This is our collision testing routine in ODE
+ ///
+ ///
+ private void collision_optimized(float timeStep)
+ {
+ _perloopContact.Clear();
+
+ lock (_characters)
+ {
+ foreach (OdeCharacter chr in _characters)
+ {
+ // Reset the collision values to false
+ // since we don't know if we're colliding yet
+
+ // For some reason this can happen. Don't ask...
+ //
+ if (chr == null)
+ continue;
+
+ if (chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero)
+ continue;
+
+ chr.IsColliding = false;
+ chr.CollidingGround = false;
+ chr.CollidingObj = false;
+
+ // test the avatar's geometry for collision with the space
+ // This will return near and the space that they are the closest to
+ // And we'll run this again against the avatar and the space segment
+ // This will return with a bunch of possible objects in the space segment
+ // and we'll run it again on all of them.
+ try
+ {
+ d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to space collide");
+ }
+ //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
+ //if (chr.Position.Z + (chr.Velocity.Z * timeStep) < terrainheight + 10)
+ //{
+ //chr.Position.Z = terrainheight + 10.0f;
+ //forcedZ = true;
+ //}
+ }
+ }
+
+ lock (_activeprims)
+ {
+ List removeprims = null;
+ foreach (OdePrim chr in _activeprims)
+ {
+ if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
+ {
+ try
+ {
+ lock (chr)
+ {
+ if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false)
+ {
+ d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
+ }
+ else
+ {
+ if (removeprims == null)
+ {
+ removeprims = new List();
+ }
+ removeprims.Add(chr);
+ m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!");
+ }
+ }
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Warn("[PHYSICS]: Unable to space collide");
+ }
+ }
+ }
+ if (removeprims != null)
+ {
+ foreach (OdePrim chr in removeprims)
+ {
+ _activeprims.Remove(chr);
+ }
+ }
+ }
+
+ _perloopContact.Clear();
+ }
+
+ #endregion
+
+ public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
+ {
+ m_worldOffset = offset;
+ WorldExtents = new Vector2(extents.X, extents.Y);
+ m_parentScene = pScene;
+
+ }
+
+ // Recovered for use by fly height. Kitto Flora
+ public float GetTerrainHeightAtXY(float x, float y)
+ {
+
+ int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
+ int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
+
+ IntPtr heightFieldGeom = IntPtr.Zero;
+
+ if (RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom))
+ {
+ if (heightFieldGeom != IntPtr.Zero)
+ {
+ if (TerrainHeightFieldHeights.ContainsKey(heightFieldGeom))
+ {
+
+ int index;
+
+
+ if ((int)x > WorldExtents.X || (int)y > WorldExtents.Y ||
+ (int)x < 0.001f || (int)y < 0.001f)
+ return 0;
+
+ x = x - offsetX;
+ y = y - offsetY;
+
+ index = (int)((int)x * ((int)Constants.RegionSize + 2) + (int)y);
+
+ if (index < TerrainHeightFieldHeights[heightFieldGeom].Length)
+ {
+ //m_log.DebugFormat("x{0} y{1} = {2}", x, y, (float)TerrainHeightFieldHeights[heightFieldGeom][index]);
+ return (float)TerrainHeightFieldHeights[heightFieldGeom][index];
+ }
+
+ else
+ return 0f;
+ }
+ else
+ {
+ return 0f;
+ }
+
+ }
+ else
+ {
+ return 0f;
+ }
+
+ }
+ else
+ {
+ return 0f;
+ }
+
+
+ }
+// End recovered. Kitto Flora
+
+ public void addCollisionEventReporting(PhysicsActor obj)
+ {
+ lock (_collisionEventPrim)
+ {
+ if (!_collisionEventPrim.Contains(obj))
+ _collisionEventPrim.Add(obj);
+ }
+ }
+
+ public void remCollisionEventReporting(PhysicsActor obj)
+ {
+ lock (_collisionEventPrim)
+ {
+ if (!_collisionEventPrim.Contains(obj))
+ _collisionEventPrim.Remove(obj);
+ }
+ }
+
+ #region Add/Remove Entities
+
+ public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
+ {
+ Vector3 pos;
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z;
+ OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun);
+ newAv.Flying = isFlying;
+ newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset;
+
+ return newAv;
+ }
+
+ public void AddCharacter(OdeCharacter chr)
+ {
+ lock (_characters)
+ {
+ if (!_characters.Contains(chr))
+ {
+ _characters.Add(chr);
+ if (chr.bad)
+ m_log.DebugFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
+ }
+ }
+ }
+
+ public void RemoveCharacter(OdeCharacter chr)
+ {
+ lock (_characters)
+ {
+ if (_characters.Contains(chr))
+ {
+ _characters.Remove(chr);
+ }
+ }
+ }
+ public void BadCharacter(OdeCharacter chr)
+ {
+ lock (_badCharacter)
+ {
+ if (!_badCharacter.Contains(chr))
+ _badCharacter.Add(chr);
+ }
+ }
+
+ public override void RemoveAvatar(PhysicsActor actor)
+ {
+ //m_log.Debug("[PHYSICS]:ODELOCK");
+ ((OdeCharacter) actor).Destroy();
+
+ }
+
+ private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
+ IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
+ {
+
+ Vector3 pos = position;
+ Vector3 siz = size;
+ Quaternion rot = rotation;
+
+ OdePrim newPrim;
+ lock (OdeLock)
+ {
+ newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, ode);
+
+ lock (_prims)
+ _prims.Add(newPrim);
+ }
+
+ return newPrim;
+ }
+
+ public void addActivePrim(OdePrim activatePrim)
+ {
+ // adds active prim.. (ones that should be iterated over in collisions_optimized
+ lock (_activeprims)
+ {
+ if (!_activeprims.Contains(activatePrim))
+ _activeprims.Add(activatePrim);
+ //else
+ // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
+ }
+ }
+
+ public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
+ Vector3 size, Quaternion rotation) //To be removed
+ {
+ return AddPrimShape(primName, pbs, position, size, rotation, false);
+ }
+
+ public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
+ Vector3 size, Quaternion rotation, bool isPhysical)
+ {
+ PhysicsActor result;
+ IMesh mesh = null;
+
+ if (needsMeshing(pbs))
+ mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical);
+
+ result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical);
+
+ return result;
+ }
+
+ public override float TimeDilation
+ {
+ get { return m_timeDilation; }
+ }
+
+ public override bool SupportsNINJAJoints
+ {
+ get { return m_NINJA_physics_joints_enabled; }
+ }
+
+ // internal utility function: must be called within a lock (OdeLock)
+ private void InternalAddActiveJoint(PhysicsJoint joint)
+ {
+ activeJoints.Add(joint);
+ SOPName_to_activeJoint.Add(joint.ObjectNameInScene, joint);
+ }
+
+ // internal utility function: must be called within a lock (OdeLock)
+ private void InternalAddPendingJoint(OdePhysicsJoint joint)
+ {
+ pendingJoints.Add(joint);
+ SOPName_to_pendingJoint.Add(joint.ObjectNameInScene, joint);
+ }
+
+ // internal utility function: must be called within a lock (OdeLock)
+ private void InternalRemovePendingJoint(PhysicsJoint joint)
+ {
+ pendingJoints.Remove(joint);
+ SOPName_to_pendingJoint.Remove(joint.ObjectNameInScene);
+ }
+
+ // internal utility function: must be called within a lock (OdeLock)
+ private void InternalRemoveActiveJoint(PhysicsJoint joint)
+ {
+ activeJoints.Remove(joint);
+ SOPName_to_activeJoint.Remove(joint.ObjectNameInScene);
+ }
+
+ public override void DumpJointInfo()
+ {
+ string hdr = "[NINJA] JOINTINFO: ";
+ foreach (PhysicsJoint j in pendingJoints)
+ {
+ m_log.Debug(hdr + " pending joint, Name: " + j.ObjectNameInScene + " raw parms:" + j.RawParams);
+ }
+ m_log.Debug(hdr + pendingJoints.Count + " total pending joints");
+ foreach (string jointName in SOPName_to_pendingJoint.Keys)
+ {
+ m_log.Debug(hdr + " pending joints dict contains Name: " + jointName);
+ }
+ m_log.Debug(hdr + SOPName_to_pendingJoint.Keys.Count + " total pending joints dict entries");
+ foreach (PhysicsJoint j in activeJoints)
+ {
+ m_log.Debug(hdr + " active joint, Name: " + j.ObjectNameInScene + " raw parms:" + j.RawParams);
+ }
+ m_log.Debug(hdr + activeJoints.Count + " total active joints");
+ foreach (string jointName in SOPName_to_activeJoint.Keys)
+ {
+ m_log.Debug(hdr + " active joints dict contains Name: " + jointName);
+ }
+ m_log.Debug(hdr + SOPName_to_activeJoint.Keys.Count + " total active joints dict entries");
+
+ m_log.Debug(hdr + " Per-body joint connectivity information follows.");
+ m_log.Debug(hdr + joints_connecting_actor.Keys.Count + " bodies are connected by joints.");
+ foreach (string actorName in joints_connecting_actor.Keys)
+ {
+ m_log.Debug(hdr + " Actor " + actorName + " has the following joints connecting it");
+ foreach (PhysicsJoint j in joints_connecting_actor[actorName])
+ {
+ m_log.Debug(hdr + " * joint Name: " + j.ObjectNameInScene + " raw parms:" + j.RawParams);
+ }
+ m_log.Debug(hdr + joints_connecting_actor[actorName].Count + " connecting joints total for this actor");
+ }
+ }
+
+ public override void RequestJointDeletion(string ObjectNameInScene)
+ {
+ lock (externalJointRequestsLock)
+ {
+ if (!requestedJointsToBeDeleted.Contains(ObjectNameInScene)) // forbid same deletion request from entering twice to prevent spurious deletions processed asynchronously
+ {
+ requestedJointsToBeDeleted.Add(ObjectNameInScene);
+ }
+ }
+ }
+
+ private void DeleteRequestedJoints()
+ {
+ List myRequestedJointsToBeDeleted;
+ lock (externalJointRequestsLock)
+ {
+ // make a local copy of the shared list for processing (threading issues)
+ myRequestedJointsToBeDeleted = new List(requestedJointsToBeDeleted);
+ }
+
+ foreach (string jointName in myRequestedJointsToBeDeleted)
+ {
+ lock (OdeLock)
+ {
+ //m_log.Debug("[NINJA] trying to deleting requested joint " + jointName);
+ if (SOPName_to_activeJoint.ContainsKey(jointName) || SOPName_to_pendingJoint.ContainsKey(jointName))
+ {
+ OdePhysicsJoint joint = null;
+ if (SOPName_to_activeJoint.ContainsKey(jointName))
+ {
+ joint = SOPName_to_activeJoint[jointName] as OdePhysicsJoint;
+ InternalRemoveActiveJoint(joint);
+ }
+ else if (SOPName_to_pendingJoint.ContainsKey(jointName))
+ {
+ joint = SOPName_to_pendingJoint[jointName] as OdePhysicsJoint;
+ InternalRemovePendingJoint(joint);
+ }
+
+ if (joint != null)
+ {
+ //m_log.Debug("joint.BodyNames.Count is " + joint.BodyNames.Count + " and contents " + joint.BodyNames);
+ for (int iBodyName = 0; iBodyName < 2; iBodyName++)
+ {
+ string bodyName = joint.BodyNames[iBodyName];
+ if (bodyName != "NULL")
+ {
+ joints_connecting_actor[bodyName].Remove(joint);
+ if (joints_connecting_actor[bodyName].Count == 0)
+ {
+ joints_connecting_actor.Remove(bodyName);
+ }
+ }
+ }
+
+ DoJointDeactivated(joint);
+ if (joint.jointID != IntPtr.Zero)
+ {
+ d.JointDestroy(joint.jointID);
+ joint.jointID = IntPtr.Zero;
+ //DoJointErrorMessage(joint, "successfully destroyed joint " + jointName);
+ }
+ else
+ {
+ //m_log.Warn("[NINJA] Ignoring re-request to destroy joint " + jointName);
+ }
+ }
+ else
+ {
+ // DoJointErrorMessage(joint, "coult not find joint to destroy based on name " + jointName);
+ }
+ }
+ else
+ {
+ // DoJointErrorMessage(joint, "WARNING - joint removal failed, joint " + jointName);
+ }
+ }
+ }
+
+ // remove processed joints from the shared list
+ lock (externalJointRequestsLock)
+ {
+ foreach (string jointName in myRequestedJointsToBeDeleted)
+ {
+ requestedJointsToBeDeleted.Remove(jointName);
+ }
+ }
+ }
+
+ // for pending joints we don't know if their associated bodies exist yet or not.
+ // the joint is actually created during processing of the taints
+ private void CreateRequestedJoints()
+ {
+ List myRequestedJointsToBeCreated;
+ lock (externalJointRequestsLock)
+ {
+ // make a local copy of the shared list for processing (threading issues)
+ myRequestedJointsToBeCreated = new List(requestedJointsToBeCreated);
+ }
+
+ foreach (PhysicsJoint joint in myRequestedJointsToBeCreated)
+ {
+ lock (OdeLock)
+ {
+ if (SOPName_to_pendingJoint.ContainsKey(joint.ObjectNameInScene) && SOPName_to_pendingJoint[joint.ObjectNameInScene] != null)
+ {
+ DoJointErrorMessage(joint, "WARNING: ignoring request to re-add already pending joint Name:" + joint.ObjectNameInScene + " type:" + joint.Type + " parms: " + joint.RawParams + " pos: " + joint.Position + " rot:" + joint.Rotation);
+ continue;
+ }
+ if (SOPName_to_activeJoint.ContainsKey(joint.ObjectNameInScene) && SOPName_to_activeJoint[joint.ObjectNameInScene] != null)
+ {
+ DoJointErrorMessage(joint, "WARNING: ignoring request to re-add already active joint Name:" + joint.ObjectNameInScene + " type:" + joint.Type + " parms: " + joint.RawParams + " pos: " + joint.Position + " rot:" + joint.Rotation);
+ continue;
+ }
+
+ InternalAddPendingJoint(joint as OdePhysicsJoint);
+
+ if (joint.BodyNames.Count >= 2)
+ {
+ for (int iBodyName = 0; iBodyName < 2; iBodyName++)
+ {
+ string bodyName = joint.BodyNames[iBodyName];
+ if (bodyName != "NULL")
+ {
+ if (!joints_connecting_actor.ContainsKey(bodyName))
+ {
+ joints_connecting_actor.Add(bodyName, new List());
+ }
+ joints_connecting_actor[bodyName].Add(joint);
+ }
+ }
+ }
+ }
+ }
+
+ // remove processed joints from shared list
+ lock (externalJointRequestsLock)
+ {
+ foreach (PhysicsJoint joint in myRequestedJointsToBeCreated)
+ {
+ requestedJointsToBeCreated.Remove(joint);
+ }
+ }
+
+ }
+
+ // public function to add an request for joint creation
+ // this joint will just be added to a waiting list that is NOT processed during the main
+ // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests.
+
+ public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
+ Quaternion rotation, string parms, List bodyNames, string trackedBodyName, Quaternion localRotation)
+
+ {
+
+ OdePhysicsJoint joint = new OdePhysicsJoint();
+ joint.ObjectNameInScene = objectNameInScene;
+ joint.Type = jointType;
+ joint.Position = position;
+ joint.Rotation = rotation;
+ joint.RawParams = parms;
+ joint.BodyNames = new List(bodyNames);
+ joint.TrackedBodyName = trackedBodyName;
+ joint.LocalRotation = localRotation;
+ joint.jointID = IntPtr.Zero;
+ joint.ErrorMessageCount = 0;
+
+ lock (externalJointRequestsLock)
+ {
+ if (!requestedJointsToBeCreated.Contains(joint)) // forbid same creation request from entering twice
+ {
+ requestedJointsToBeCreated.Add(joint);
+ }
+ }
+ return joint;
+ }
+
+ private void RemoveAllJointsConnectedToActor(PhysicsActor actor)
+ {
+ //m_log.Debug("RemoveAllJointsConnectedToActor: start");
+ if (actor.SOPName != null && joints_connecting_actor.ContainsKey(actor.SOPName) && joints_connecting_actor[actor.SOPName] != null)
+ {
+
+ List jointsToRemove = new List();
+ //TODO: merge these 2 loops (originally it was needed to avoid altering a list being iterated over, but it is no longer needed due to the joint request queue mechanism)
+ foreach (PhysicsJoint j in joints_connecting_actor[actor.SOPName])
+ {
+ jointsToRemove.Add(j);
+ }
+ foreach (PhysicsJoint j in jointsToRemove)
+ {
+ //m_log.Debug("RemoveAllJointsConnectedToActor: about to request deletion of " + j.ObjectNameInScene);
+ RequestJointDeletion(j.ObjectNameInScene);
+ //m_log.Debug("RemoveAllJointsConnectedToActor: done request deletion of " + j.ObjectNameInScene);
+ j.TrackedBodyName = null; // *IMMEDIATELY* prevent any further movement of this joint (else a deleted actor might cause spurious tracking motion of the joint for a few frames, leading to the joint proxy object disappearing)
+ }
+ }
+ }
+
+ public override void RemoveAllJointsConnectedToActorThreadLocked(PhysicsActor actor)
+ {
+ //m_log.Debug("RemoveAllJointsConnectedToActorThreadLocked: start");
+ lock (OdeLock)
+ {
+ //m_log.Debug("RemoveAllJointsConnectedToActorThreadLocked: got lock");
+ RemoveAllJointsConnectedToActor(actor);
+ }
+ }
+
+ // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
+ public override Vector3 GetJointAnchor(PhysicsJoint joint)
+ {
+ Debug.Assert(joint.IsInPhysicsEngine);
+ d.Vector3 pos = new d.Vector3();
+
+ if (!(joint is OdePhysicsJoint))
+ {
+ DoJointErrorMessage(joint, "warning: non-ODE joint requesting anchor: " + joint.ObjectNameInScene);
+ }
+ else
+ {
+ OdePhysicsJoint odeJoint = (OdePhysicsJoint)joint;
+ switch (odeJoint.Type)
+ {
+ case PhysicsJointType.Ball:
+ d.JointGetBallAnchor(odeJoint.jointID, out pos);
+ break;
+ case PhysicsJointType.Hinge:
+ d.JointGetHingeAnchor(odeJoint.jointID, out pos);
+ break;
+ }
+ }
+ return new Vector3(pos.X, pos.Y, pos.Z);
+ }
+
+ // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
+ // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function
+ // appears to be unreliable. Fortunately we can compute the joint axis ourselves by
+ // keeping track of the joint's original orientation relative to one of the involved bodies.
+ public override Vector3 GetJointAxis(PhysicsJoint joint)
+ {
+ Debug.Assert(joint.IsInPhysicsEngine);
+ d.Vector3 axis = new d.Vector3();
+
+ if (!(joint is OdePhysicsJoint))
+ {
+ DoJointErrorMessage(joint, "warning: non-ODE joint requesting anchor: " + joint.ObjectNameInScene);
+ }
+ else
+ {
+ OdePhysicsJoint odeJoint = (OdePhysicsJoint)joint;
+ switch (odeJoint.Type)
+ {
+ case PhysicsJointType.Ball:
+ DoJointErrorMessage(joint, "warning - axis requested for ball joint: " + joint.ObjectNameInScene);
+ break;
+ case PhysicsJointType.Hinge:
+ d.JointGetHingeAxis(odeJoint.jointID, out axis);
+ break;
+ }
+ }
+ return new Vector3(axis.X, axis.Y, axis.Z);
+ }
+
+
+ public void remActivePrim(OdePrim deactivatePrim)
+ {
+ lock (_activeprims)
+ {
+ _activeprims.Remove(deactivatePrim);
+ }
+ }
+
+ public override void RemovePrim(PhysicsActor prim)
+ {
+ if (prim is OdePrim)
+ {
+ lock (OdeLock)
+ {
+ OdePrim p = (OdePrim) prim;
+
+ p.setPrimForRemoval();
+ AddPhysicsActorTaint(prim);
+ //RemovePrimThreadLocked(p);
+ }
+ }
+ }
+
+ ///
+ /// This is called from within simulate but outside the locked portion
+ /// We need to do our own locking here
+ /// Essentially, we need to remove the prim from our space segment, whatever segment it's in.
+ ///
+ /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory
+ /// that the space was using.
+ ///
+ ///
+ public void RemovePrimThreadLocked(OdePrim prim)
+ {
+//Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName);
+ lock (prim)
+ {
+ remCollisionEventReporting(prim);
+ lock (ode)
+ {
+ if (prim.prim_geom != IntPtr.Zero)
+ {
+ prim.ResetTaints();
+
+ if (prim.IsPhysical)
+ {
+ prim.disableBody();
+ if (prim.childPrim)
+ {
+ prim.childPrim = false;
+ prim.Body = IntPtr.Zero;
+ prim.m_disabled = true;
+ prim.IsPhysical = false;
+ }
+
+
+ }
+ // we don't want to remove the main space
+
+ // If the geometry is in the targetspace, remove it from the target space
+ //m_log.Warn(prim.m_targetSpace);
+
+ //if (prim.m_targetSpace != IntPtr.Zero)
+ //{
+ //if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
+ //{
+
+ //if (d.GeomIsSpace(prim.m_targetSpace))
+ //{
+ //waitForSpaceUnlock(prim.m_targetSpace);
+ //d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
+ prim.m_targetSpace = IntPtr.Zero;
+ //}
+ //else
+ //{
+ // m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
+ //((OdePrim)prim).m_targetSpace.ToString());
+ //}
+
+ //}
+ //}
+ //m_log.Warn(prim.prim_geom);
+ try
+ {
+ if (prim.prim_geom != IntPtr.Zero)
+ {
+ d.GeomDestroy(prim.prim_geom);
+ prim.prim_geom = IntPtr.Zero;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene");
+ }
+ }
+ catch (AccessViolationException)
+ {
+ m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed.");
+ }
+ lock (_prims)
+ _prims.Remove(prim);
+
+ //If there are no more geometries in the sub-space, we don't need it in the main space anymore
+ //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
+ //{
+ //if (prim.m_targetSpace != null)
+ //{
+ //if (d.GeomIsSpace(prim.m_targetSpace))
+ //{
+ //waitForSpaceUnlock(prim.m_targetSpace);
+ //d.SpaceRemove(space, prim.m_targetSpace);
+ // free up memory used by the space.
+ //d.SpaceDestroy(prim.m_targetSpace);
+ //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
+ //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
+ //}
+ //else
+ //{
+ //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
+ //((OdePrim) prim).m_targetSpace.ToString());
+ //}
+ //}
+ //}
+
+ if (SupportsNINJAJoints)
+ {
+ RemoveAllJointsConnectedToActorThreadLocked(prim);
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region Space Separation Calculation
+
+ ///
+ /// Takes a space pointer and zeros out the array we're using to hold the spaces
+ ///
+ ///
+ public void resetSpaceArrayItemToZero(IntPtr pSpace)
+ {
+ for (int x = 0; x < staticPrimspace.GetLength(0); x++)
+ {
+ for (int y = 0; y < staticPrimspace.GetLength(1); y++)
+ {
+ if (staticPrimspace[x, y] == pSpace)
+ staticPrimspace[x, y] = IntPtr.Zero;
+ }
+ }
+ }
+
+ public void resetSpaceArrayItemToZero(int arrayitemX, int arrayitemY)
+ {
+ staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero;
+ }
+
+ ///
+ /// Called when a static prim moves. Allocates a space for the prim based on its position
+ ///
+ /// the pointer to the geom that moved
+ /// the position that the geom moved to
+ /// a pointer to the space it was in before it was moved.
+ /// a pointer to the new space it's in
+ public IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace)
+ {
+ // Called from setting the Position and Size of an ODEPrim so
+ // it's already in locked space.
+
+ // we don't want to remove the main space
+ // we don't need to test physical here because this function should
+ // never be called if the prim is physical(active)
+
+ // All physical prim end up in the root space
+ //Thread.Sleep(20);
+ if (currentspace != space)
+ {
+ //m_log.Info("[SPACE]: C:" + currentspace.ToString() + " g:" + geom.ToString());
+ //if (currentspace == IntPtr.Zero)
+ //{
+ //int adfadf = 0;
+ //}
+ if (d.SpaceQuery(currentspace, geom) && currentspace != IntPtr.Zero)
+ {
+ if (d.GeomIsSpace(currentspace))
+ {
+ waitForSpaceUnlock(currentspace);
+ d.SpaceRemove(currentspace, geom);
+ }
+ else
+ {
+ m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + currentspace +
+ " Geom:" + geom);
+ }
+ }
+ else
+ {
+ IntPtr sGeomIsIn = d.GeomGetSpace(geom);
+ if (sGeomIsIn != IntPtr.Zero)
+ {
+ if (d.GeomIsSpace(currentspace))
+ {
+ waitForSpaceUnlock(sGeomIsIn);
+ d.SpaceRemove(sGeomIsIn, geom);
+ }
+ else
+ {
+ m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+ sGeomIsIn + " Geom:" + geom);
+ }
+ }
+ }
+
+ //If there are no more geometries in the sub-space, we don't need it in the main space anymore
+ if (d.SpaceGetNumGeoms(currentspace) == 0)
+ {
+ if (currentspace != IntPtr.Zero)
+ {
+ if (d.GeomIsSpace(currentspace))
+ {
+ waitForSpaceUnlock(currentspace);
+ waitForSpaceUnlock(space);
+ d.SpaceRemove(space, currentspace);
+ // free up memory used by the space.
+
+ //d.SpaceDestroy(currentspace);
+ resetSpaceArrayItemToZero(currentspace);
+ }
+ else
+ {
+ m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+ currentspace + " Geom:" + geom);
+ }
+ }
+ }
+ }
+ else
+ {
+ // this is a physical object that got disabled. ;.;
+ if (currentspace != IntPtr.Zero && geom != IntPtr.Zero)
+ {
+ if (d.SpaceQuery(currentspace, geom))
+ {
+ if (d.GeomIsSpace(currentspace))
+ {
+ waitForSpaceUnlock(currentspace);
+ d.SpaceRemove(currentspace, geom);
+ }
+ else
+ {
+ m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+ currentspace + " Geom:" + geom);
+ }
+ }
+ else
+ {
+ IntPtr sGeomIsIn = d.GeomGetSpace(geom);
+ if (sGeomIsIn != IntPtr.Zero)
+ {
+ if (d.GeomIsSpace(sGeomIsIn))
+ {
+ waitForSpaceUnlock(sGeomIsIn);
+ d.SpaceRemove(sGeomIsIn, geom);
+ }
+ else
+ {
+ m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+ sGeomIsIn + " Geom:" + geom);
+ }
+ }
+ }
+ }
+ }
+
+ // The routines in the Position and Size sections do the 'inserting' into the space,
+ // so all we have to do is make sure that the space that we're putting the prim into
+ // is in the 'main' space.
+ int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos);
+ IntPtr newspace = calculateSpaceForGeom(pos);
+
+ if (newspace == IntPtr.Zero)
+ {
+ newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]);
+ d.HashSpaceSetLevels(newspace, smallHashspaceLow, smallHashspaceHigh);
+ }
+
+ return newspace;
+ }
+
+ ///
+ /// Creates a new space at X Y
+ ///
+ ///
+ ///
+ /// A pointer to the created space
+ public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY)
+ {
+ // creating a new space for prim and inserting it into main space.
+ staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero);
+ d.GeomSetCategoryBits(staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY], (int)CollisionCategories.Space);
+ waitForSpaceUnlock(space);
+ d.SpaceSetSublevel(space, 1);
+ d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]);
+ return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY];
+ }
+
+ ///
+ /// Calculates the space the prim should be in by its position
+ ///
+ ///
+ /// a pointer to the space. This could be a new space or reused space.
+ public IntPtr calculateSpaceForGeom(Vector3 pos)
+ {
+ int[] xyspace = calculateSpaceArrayItemFromPos(pos);
+ //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
+ return staticPrimspace[xyspace[0], xyspace[1]];
+ }
+
+ ///
+ /// Holds the space allocation logic
+ ///
+ ///
+ /// an array item based on the position
+ public int[] calculateSpaceArrayItemFromPos(Vector3 pos)
+ {
+ int[] returnint = new int[2];
+
+ returnint[0] = (int) (pos.X/metersInSpace);
+
+ if (returnint[0] > ((int) (259f/metersInSpace)))
+ returnint[0] = ((int) (259f/metersInSpace));
+ if (returnint[0] < 0)
+ returnint[0] = 0;
+
+ returnint[1] = (int) (pos.Y/metersInSpace);
+ if (returnint[1] > ((int) (259f/metersInSpace)))
+ returnint[1] = ((int) (259f/metersInSpace));
+ if (returnint[1] < 0)
+ returnint[1] = 0;
+
+ return returnint;
+ }
+
+ #endregion
+
+ ///
+ /// Routine to figure out if we need to mesh this prim with our mesher
+ ///
+ ///
+ ///
+ public bool needsMeshing(PrimitiveBaseShape pbs)
+ {
+ // most of this is redundant now as the mesher will return null if it cant mesh a prim
+ // but we still need to check for sculptie meshing being enabled so this is the most
+ // convenient place to do it for now...
+
+ // //if (pbs.PathCurve == (byte)Primitive.PathCurve.Circle && pbs.ProfileCurve == (byte)Primitive.ProfileCurve.Circle && pbs.PathScaleY <= 0.75f)
+ // //m_log.Debug("needsMeshing: " + " pathCurve: " + pbs.PathCurve.ToString() + " profileCurve: " + pbs.ProfileCurve.ToString() + " pathScaleY: " + Primitive.UnpackPathScale(pbs.PathScaleY).ToString());
+ int iPropertiesNotSupportedDefault = 0;
+
+ if (pbs.SculptEntry && !meshSculptedPrim)
+ {
+#if SPAM
+ m_log.Warn("NonMesh");
+#endif
+ return false;
+ }
+
+ // if it's a standard box or sphere with no cuts, hollows, twist or top shear, return false since ODE can use an internal representation for the prim
+ if (!forceSimplePrimMeshing)
+ {
+ if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight)
+ || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1
+ && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z))
+ {
+
+ if (pbs.ProfileBegin == 0 && pbs.ProfileEnd == 0
+ && pbs.ProfileHollow == 0
+ && pbs.PathTwist == 0 && pbs.PathTwistBegin == 0
+ && pbs.PathBegin == 0 && pbs.PathEnd == 0
+ && pbs.PathTaperX == 0 && pbs.PathTaperY == 0
+ && pbs.PathScaleX == 100 && pbs.PathScaleY == 100
+ && pbs.PathShearX == 0 && pbs.PathShearY == 0)
+ {
+#if SPAM
+ m_log.Warn("NonMesh");
+#endif
+ return false;
+ }
+ }
+ }
+
+ if (pbs.ProfileHollow != 0)
+ iPropertiesNotSupportedDefault++;
+
+ if ((pbs.PathTwistBegin != 0) || (pbs.PathTwist != 0))
+ iPropertiesNotSupportedDefault++;
+
+ if ((pbs.ProfileBegin != 0) || pbs.ProfileEnd != 0)
+ iPropertiesNotSupportedDefault++;
+
+ if ((pbs.PathScaleX != 100) || (pbs.PathScaleY != 100))
+ iPropertiesNotSupportedDefault++;
+
+ if ((pbs.PathShearX != 0) || (pbs.PathShearY != 0))
+ iPropertiesNotSupportedDefault++;
+
+ if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight)
+ iPropertiesNotSupportedDefault++;
+
+ if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 && (pbs.Scale.X != pbs.Scale.Y || pbs.Scale.Y != pbs.Scale.Z || pbs.Scale.Z != pbs.Scale.X))
+ iPropertiesNotSupportedDefault++;
+
+ if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte) Extrusion.Curve1)
+ iPropertiesNotSupportedDefault++;
+
+ // test for torus
+ if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
+ {
+ if (pbs.PathCurve == (byte)Extrusion.Curve1)
+ {
+ iPropertiesNotSupportedDefault++;
+ }
+ }
+ else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
+ {
+ if (pbs.PathCurve == (byte)Extrusion.Straight)
+ {
+ iPropertiesNotSupportedDefault++;
+ }
+
+ // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
+ else if (pbs.PathCurve == (byte)Extrusion.Curve1)
+ {
+ iPropertiesNotSupportedDefault++;
+ }
+ }
+ else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
+ {
+ if (pbs.PathCurve == (byte)Extrusion.Curve1 || pbs.PathCurve == (byte)Extrusion.Curve2)
+ {
+ iPropertiesNotSupportedDefault++;
+ }
+ }
+ else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
+ {
+ if (pbs.PathCurve == (byte)Extrusion.Straight)
+ {
+ iPropertiesNotSupportedDefault++;
+ }
+ else if (pbs.PathCurve == (byte)Extrusion.Curve1)
+ {
+ iPropertiesNotSupportedDefault++;
+ }
+ }
+
+
+ if (iPropertiesNotSupportedDefault == 0)
+ {
+#if SPAM
+ m_log.Warn("NonMesh");
+#endif
+ return false;
+ }
+#if SPAM
+ m_log.Debug("Mesh");
+#endif
+ return true;
+ }
+
+ ///
+ /// Called after our prim properties are set Scale, position etc.
+ /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex
+ /// This assures us that we have no race conditions
+ ///
+ ///
+ public override void AddPhysicsActorTaint(PhysicsActor prim)
+ {
+
+ if (prim is OdePrim)
+ {
+ OdePrim taintedprim = ((OdePrim) prim);
+ lock (_taintedPrimLock)
+ {
+ if (!(_taintedPrimH.Contains(taintedprim)))
+ {
+//Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.m_primName);
+ _taintedPrimH.Add(taintedprim); // HashSet for searching
+ _taintedPrimL.Add(taintedprim); // List for ordered readout
+ }
+ }
+ return;
+ }
+ else if (prim is OdeCharacter)
+ {
+ OdeCharacter taintedchar = ((OdeCharacter)prim);
+ lock (_taintedActors)
+ {
+ if (!(_taintedActors.Contains(taintedchar)))
+ {
+ _taintedActors.Add(taintedchar);
+ if (taintedchar.bad)
+ m_log.DebugFormat("[PHYSICS]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid);
+ }
+ }
+ }
+ }
+
+ ///
+ /// This is our main simulate loop
+ /// It's thread locked by a Mutex in the scene.
+ /// It holds Collisions, it instructs ODE to step through the physical reactions
+ /// It moves the objects around in memory
+ /// It calls the methods that report back to the object owners.. (scenepresence, SceneObjectGroup)
+ ///
+ ///
+ ///
+ public override float Simulate(float timeStep)
+ {
+ if (framecount >= int.MaxValue)
+ framecount = 0;
+
+ //if (m_worldOffset != Vector3.Zero)
+ // return 0;
+
+ framecount++;
+
+ float fps = 0;
+ //m_log.Info(timeStep.ToString());
+ step_time += timeStep;
+
+ // If We're loaded down by something else,
+ // or debugging with the Visual Studio project on pause
+ // skip a few frames to catch up gracefully.
+ // without shooting the physicsactors all over the place
+
+ if (step_time >= m_SkipFramesAtms)
+ {
+ // Instead of trying to catch up, it'll do 5 physics frames only
+ step_time = ODE_STEPSIZE;
+ m_physicsiterations = 5;
+ }
+ else
+ {
+ m_physicsiterations = 10;
+ }
+
+ if (SupportsNINJAJoints)
+ {
+ DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
+ CreateRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
+ }
+
+ lock (OdeLock)
+ {
+ // Process 10 frames if the sim is running normal..
+ // process 5 frames if the sim is running slow
+ //try
+ //{
+ //d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
+ //}
+ //catch (StackOverflowException)
+ //{
+ // m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
+ // ode.drelease(world);
+ //base.TriggerPhysicsBasedRestart();
+ //}
+
+ int i = 0;
+
+ // Figure out the Frames Per Second we're going at.
+ //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size
+
+ fps = (step_time / ODE_STEPSIZE) * 1000;
+ // HACK: Using a time dilation of 1.0 to debug rubberbanding issues
+ //m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f);
+
+ step_time = 0.09375f;
+
+ while (step_time > 0.0f)
+ {
+ //lock (ode)
+ //{
+ //if (!ode.lockquery())
+ //{
+ // ode.dlock(world);
+ try
+ {
+ // Insert, remove Characters
+ bool processedtaints = false;
+
+ lock (_taintedActors)
+ {
+ if (_taintedActors.Count > 0)
+ {
+ foreach (OdeCharacter character in _taintedActors)
+ {
+
+ character.ProcessTaints(timeStep);
+
+ processedtaints = true;
+ //character.m_collisionscore = 0;
+ }
+
+ if (processedtaints)
+ _taintedActors.Clear();
+ }
+ }
+
+ // Modify other objects in the scene.
+ processedtaints = false;
+
+ lock (_taintedPrimLock)
+ {
+ foreach (OdePrim prim in _taintedPrimL)
+ {
+ if (prim.m_taintremove)
+ {
+ //Console.WriteLine("Simulate calls RemovePrimThreadLocked");
+ RemovePrimThreadLocked(prim);
+ }
+ else
+ {
+ //Console.WriteLine("Simulate calls ProcessTaints");
+ prim.ProcessTaints(timeStep);
+ }
+ processedtaints = true;
+ prim.m_collisionscore = 0;
+
+ // This loop can block up the Heartbeat for a very long time on large regions.
+ // We need to let the Watchdog know that the Heartbeat is not dead
+ // NOTE: This is currently commented out, but if things like OAR loading are
+ // timing the heartbeat out we will need to uncomment it
+ //Watchdog.UpdateThread();
+ }
+
+ if (SupportsNINJAJoints)
+ {
+ // Create pending joints, if possible
+
+ // joints can only be processed after ALL bodies are processed (and exist in ODE), since creating
+ // a joint requires specifying the body id of both involved bodies
+ if (pendingJoints.Count > 0)
+ {
+ List successfullyProcessedPendingJoints = new List();
+ //DoJointErrorMessage(joints_connecting_actor, "taint: " + pendingJoints.Count + " pending joints");
+ foreach (PhysicsJoint joint in pendingJoints)
+ {
+ //DoJointErrorMessage(joint, "taint: time to create joint with parms: " + joint.RawParams);
+ string[] jointParams = joint.RawParams.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);
+ List jointBodies = new List();
+ bool allJointBodiesAreReady = true;
+ foreach (string jointParam in jointParams)
+ {
+ if (jointParam == "NULL")
+ {
+ //DoJointErrorMessage(joint, "attaching NULL joint to world");
+ jointBodies.Add(IntPtr.Zero);
+ }
+ else
+ {
+ //DoJointErrorMessage(joint, "looking for prim name: " + jointParam);
+ bool foundPrim = false;
+ lock (_prims)
+ {
+ foreach (OdePrim prim in _prims) // FIXME: inefficient
+ {
+ if (prim.SOPName == jointParam)
+ {
+ //DoJointErrorMessage(joint, "found for prim name: " + jointParam);
+ if (prim.IsPhysical && prim.Body != IntPtr.Zero)
+ {
+ jointBodies.Add(prim.Body);
+ foundPrim = true;
+ break;
+ }
+ else
+ {
+ DoJointErrorMessage(joint, "prim name " + jointParam +
+ " exists but is not (yet) physical; deferring joint creation. " +
+ "IsPhysical property is " + prim.IsPhysical +
+ " and body is " + prim.Body);
+ foundPrim = false;
+ break;
+ }
+ }
+ }
+ }
+ if (foundPrim)
+ {
+ // all is fine
+ }
+ else
+ {
+ allJointBodiesAreReady = false;
+ break;
+ }
+ }
+ }
+ if (allJointBodiesAreReady)
+ {
+ //DoJointErrorMessage(joint, "allJointBodiesAreReady for " + joint.ObjectNameInScene + " with parms " + joint.RawParams);
+ if (jointBodies[0] == jointBodies[1])
+ {
+ DoJointErrorMessage(joint, "ERROR: joint cannot be created; the joint bodies are the same, body1==body2. Raw body is " + jointBodies[0] + ". raw parms: " + joint.RawParams);
+ }
+ else
+ {
+ switch (joint.Type)
+ {
+ case PhysicsJointType.Ball:
+ {
+ IntPtr odeJoint;
+ //DoJointErrorMessage(joint, "ODE creating ball joint ");
+ odeJoint = d.JointCreateBall(world, IntPtr.Zero);
+ //DoJointErrorMessage(joint, "ODE attaching ball joint: " + odeJoint + " with b1:" + jointBodies[0] + " b2:" + jointBodies[1]);
+ d.JointAttach(odeJoint, jointBodies[0], jointBodies[1]);
+ //DoJointErrorMessage(joint, "ODE setting ball anchor: " + odeJoint + " to vec:" + joint.Position);
+ d.JointSetBallAnchor(odeJoint,
+ joint.Position.X,
+ joint.Position.Y,
+ joint.Position.Z);
+ //DoJointErrorMessage(joint, "ODE joint setting OK");
+ //DoJointErrorMessage(joint, "The ball joint's bodies are here: b0: ");
+ //DoJointErrorMessage(joint, "" + (jointBodies[0] != IntPtr.Zero ? "" + d.BodyGetPosition(jointBodies[0]) : "fixed environment"));
+ //DoJointErrorMessage(joint, "The ball joint's bodies are here: b1: ");
+ //DoJointErrorMessage(joint, "" + (jointBodies[1] != IntPtr.Zero ? "" + d.BodyGetPosition(jointBodies[1]) : "fixed environment"));
+
+ if (joint is OdePhysicsJoint)
+ {
+ ((OdePhysicsJoint)joint).jointID = odeJoint;
+ }
+ else
+ {
+ DoJointErrorMessage(joint, "WARNING: non-ode joint in ODE!");
+ }
+ }
+ break;
+ case PhysicsJointType.Hinge:
+ {
+ IntPtr odeJoint;
+ //DoJointErrorMessage(joint, "ODE creating hinge joint ");
+ odeJoint = d.JointCreateHinge(world, IntPtr.Zero);
+ //DoJointErrorMessage(joint, "ODE attaching hinge joint: " + odeJoint + " with b1:" + jointBodies[0] + " b2:" + jointBodies[1]);
+ d.JointAttach(odeJoint, jointBodies[0], jointBodies[1]);
+ //DoJointErrorMessage(joint, "ODE setting hinge anchor: " + odeJoint + " to vec:" + joint.Position);
+ d.JointSetHingeAnchor(odeJoint,
+ joint.Position.X,
+ joint.Position.Y,
+ joint.Position.Z);
+ // We use the orientation of the x-axis of the joint's coordinate frame
+ // as the axis for the hinge.
+
+ // Therefore, we must get the joint's coordinate frame based on the
+ // joint.Rotation field, which originates from the orientation of the
+ // joint's proxy object in the scene.
+
+ // The joint's coordinate frame is defined as the transformation matrix
+ // that converts a vector from joint-local coordinates into world coordinates.
+ // World coordinates are defined as the XYZ coordinate system of the sim,
+ // as shown in the top status-bar of the viewer.
+
+ // Once we have the joint's coordinate frame, we extract its X axis (AtAxis)
+ // and use that as the hinge axis.
+
+ //joint.Rotation.Normalize();
+ Matrix4 proxyFrame = Matrix4.CreateFromQuaternion(joint.Rotation);
+
+ // Now extract the X axis of the joint's coordinate frame.
+
+ // Do not try to use proxyFrame.AtAxis or you will become mired in the
+ // tar pit of transposed, inverted, and generally messed-up orientations.
+ // (In other words, Matrix4.AtAxis() is borked.)
+ // Vector3 jointAxis = proxyFrame.AtAxis; <--- this path leadeth to madness
+
+ // Instead, compute the X axis of the coordinate frame by transforming
+ // the (1,0,0) vector. At least that works.
+
+ //m_log.Debug("PHY: making axis: complete matrix is " + proxyFrame);
+ Vector3 jointAxis = Vector3.Transform(Vector3.UnitX, proxyFrame);
+ //m_log.Debug("PHY: making axis: hinge joint axis is " + jointAxis);
+ //DoJointErrorMessage(joint, "ODE setting hinge axis: " + odeJoint + " to vec:" + jointAxis);
+ d.JointSetHingeAxis(odeJoint,
+ jointAxis.X,
+ jointAxis.Y,
+ jointAxis.Z);
+ //d.JointSetHingeParam(odeJoint, (int)dParam.CFM, 0.1f);
+ if (joint is OdePhysicsJoint)
+ {
+ ((OdePhysicsJoint)joint).jointID = odeJoint;
+ }
+ else
+ {
+ DoJointErrorMessage(joint, "WARNING: non-ode joint in ODE!");
+ }
+ }
+ break;
+ }
+ successfullyProcessedPendingJoints.Add(joint);
+ }
+ }
+ else
+ {
+ DoJointErrorMessage(joint, "joint could not yet be created; still pending");
+ }
+ }
+ foreach (PhysicsJoint successfullyProcessedJoint in successfullyProcessedPendingJoints)
+ {
+ //DoJointErrorMessage(successfullyProcessedJoint, "finalizing succesfully procsssed joint " + successfullyProcessedJoint.ObjectNameInScene + " parms " + successfullyProcessedJoint.RawParams);
+ //DoJointErrorMessage(successfullyProcessedJoint, "removing from pending");
+ InternalRemovePendingJoint(successfullyProcessedJoint);
+ //DoJointErrorMessage(successfullyProcessedJoint, "adding to active");
+ InternalAddActiveJoint(successfullyProcessedJoint);
+ //DoJointErrorMessage(successfullyProcessedJoint, "done");
+ }
+ }
+ }
+
+ if (processedtaints)
+//Console.WriteLine("Simulate calls Clear of _taintedPrim list");
+ _taintedPrimH.Clear();
+ _taintedPrimL.Clear();
+ }
+
+ // Move characters
+ lock (_characters)
+ {
+ List defects = new List();
+ foreach (OdeCharacter actor in _characters)
+ {
+ if (actor != null)
+ actor.Move(timeStep, defects);
+ }
+ if (0 != defects.Count)
+ {
+ foreach (OdeCharacter defect in defects)
+ {
+ RemoveCharacter(defect);
+ }
+ }
+ }
+
+ // Move other active objects
+ lock (_activeprims)
+ {
+ foreach (OdePrim prim in _activeprims)
+ {
+ prim.m_collisionscore = 0;
+ prim.Move(timeStep);
+ }
+ }
+
+ //if ((framecount % m_randomizeWater) == 0)
+ // randomizeWater(waterlevel);
+
+ //int RayCastTimeMS = m_rayCastManager.ProcessQueuedRequests();
+ m_rayCastManager.ProcessQueuedRequests();
+
+ collision_optimized(timeStep);
+
+ lock (_collisionEventPrim)
+ {
+ foreach (PhysicsActor obj in _collisionEventPrim)
+ {
+ if (obj == null)
+ continue;
+
+ switch ((ActorTypes)obj.PhysicsActorType)
+ {
+ case ActorTypes.Agent:
+ OdeCharacter cobj = (OdeCharacter)obj;
+ cobj.AddCollisionFrameTime(100);
+ cobj.SendCollisions();
+ break;
+ case ActorTypes.Prim:
+ OdePrim pobj = (OdePrim)obj;
+ pobj.SendCollisions();
+ break;
+ }
+ }
+ }
+
+ //if (m_global_contactcount > 5)
+ //{
+ // m_log.DebugFormat("[PHYSICS]: Contacts:{0}", m_global_contactcount);
+ //}
+
+ m_global_contactcount = 0;
+
+ d.WorldQuickStep(world, ODE_STEPSIZE);
+ d.JointGroupEmpty(contactgroup);
+ //ode.dunlock(world);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e);
+ ode.dunlock(world);
+ }
+
+ step_time -= ODE_STEPSIZE;
+ i++;
+ //}
+ //else
+ //{
+ //fps = 0;
+ //}
+ //}
+ }
+
+ lock (_characters)
+ {
+ foreach (OdeCharacter actor in _characters)
+ {
+ if (actor != null)
+ {
+ if (actor.bad)
+ m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
+ actor.UpdatePositionAndVelocity();
+ }
+ }
+ }
+
+ lock (_badCharacter)
+ {
+ if (_badCharacter.Count > 0)
+ {
+ foreach (OdeCharacter chr in _badCharacter)
+ {
+ RemoveCharacter(chr);
+ }
+ _badCharacter.Clear();
+ }
+ }
+
+ lock (_activeprims)
+ {
+ //if (timeStep < 0.2f)
+ {
+ foreach (OdePrim actor in _activeprims)
+ {
+ if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag))
+ {
+ actor.UpdatePositionAndVelocity();
+
+ if (SupportsNINJAJoints)
+ {
+ // If an actor moved, move its joint proxy objects as well.
+ // There seems to be an event PhysicsActor.OnPositionUpdate that could be used
+ // for this purpose but it is never called! So we just do the joint
+ // movement code here.
+
+ if (actor.SOPName != null &&
+ joints_connecting_actor.ContainsKey(actor.SOPName) &&
+ joints_connecting_actor[actor.SOPName] != null &&
+ joints_connecting_actor[actor.SOPName].Count > 0)
+ {
+ foreach (PhysicsJoint affectedJoint in joints_connecting_actor[actor.SOPName])
+ {
+ if (affectedJoint.IsInPhysicsEngine)
+ {
+ DoJointMoved(affectedJoint);
+ }
+ else
+ {
+ DoJointErrorMessage(affectedJoint, "a body connected to a joint was moved, but the joint doesn't exist yet! this will lead to joint error. joint was: " + affectedJoint.ObjectNameInScene + " parms:" + affectedJoint.RawParams);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //DumpJointInfo();
+
+ // Finished with all sim stepping. If requested, dump world state to file for debugging.
+ // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
+ // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
+ if (physics_logging && (physics_logging_interval>0) && (framecount % physics_logging_interval == 0))
+ {
+ string fname = "state-" + world.ToString() + ".DIF"; // give each physics world a separate filename
+ string prefix = "world" + world.ToString(); // prefix for variable names in exported .DIF file
+
+ if (physics_logging_append_existing_logfile)
+ {
+ string header = "-------------- START OF PHYSICS FRAME " + framecount.ToString() + " --------------";
+ TextWriter fwriter = File.AppendText(fname);
+ fwriter.WriteLine(header);
+ fwriter.Close();
+ }
+ d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
+ }
+ }
+
+ return fps;
+ }
+
+ public override void GetResults()
+ {
+ }
+
+ public override bool IsThreaded
+ {
+ // for now we won't be multithreaded
+ get { return (false); }
+ }
+
+ #region ODE Specific Terrain Fixes
+ public float[] ResizeTerrain512NearestNeighbour(float[] heightMap)
+ {
+ float[] returnarr = new float[262144];
+ float[,] resultarr = new float[(int)WorldExtents.X, (int)WorldExtents.Y];
+
+ // Filling out the array into its multi-dimensional components
+ for (int y = 0; y < WorldExtents.Y; y++)
+ {
+ for (int x = 0; x < WorldExtents.X; x++)
+ {
+ resultarr[y, x] = heightMap[y * (int)WorldExtents.Y + x];
+ }
+ }
+
+ // Resize using Nearest Neighbour
+
+ // This particular way is quick but it only works on a multiple of the original
+
+ // The idea behind this method can be described with the following diagrams
+ // second pass and third pass happen in the same loop really.. just separated
+ // them to show what this does.
+
+ // First Pass
+ // ResultArr:
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+
+ // Second Pass
+ // ResultArr2:
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+
+ // Third pass fills in the blanks
+ // ResultArr2:
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+
+ // X,Y = .
+ // X+1,y = ^
+ // X,Y+1 = *
+ // X+1,Y+1 = #
+
+ // Filling in like this;
+ // .*
+ // ^#
+ // 1st .
+ // 2nd *
+ // 3rd ^
+ // 4th #
+ // on single loop.
+
+ float[,] resultarr2 = new float[512, 512];
+ for (int y = 0; y < WorldExtents.Y; y++)
+ {
+ for (int x = 0; x < WorldExtents.X; x++)
+ {
+ resultarr2[y * 2, x * 2] = resultarr[y, x];
+
+ if (y < WorldExtents.Y)
+ {
+ resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x];
+ }
+ if (x < WorldExtents.X)
+ {
+ resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x];
+ }
+ if (x < WorldExtents.X && y < WorldExtents.Y)
+ {
+ resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x];
+ }
+ }
+ }
+
+ //Flatten out the array
+ int i = 0;
+ for (int y = 0; y < 512; y++)
+ {
+ for (int x = 0; x < 512; x++)
+ {
+ if (resultarr2[y, x] <= 0)
+ returnarr[i] = 0.0000001f;
+ else
+ returnarr[i] = resultarr2[y, x];
+
+ i++;
+ }
+ }
+
+ return returnarr;
+ }
+
+ public float[] ResizeTerrain512Interpolation(float[] heightMap)
+ {
+ float[] returnarr = new float[262144];
+ float[,] resultarr = new float[512,512];
+
+ // Filling out the array into its multi-dimensional components
+ for (int y = 0; y < 256; y++)
+ {
+ for (int x = 0; x < 256; x++)
+ {
+ resultarr[y, x] = heightMap[y * 256 + x];
+ }
+ }
+
+ // Resize using interpolation
+
+ // This particular way is quick but it only works on a multiple of the original
+
+ // The idea behind this method can be described with the following diagrams
+ // second pass and third pass happen in the same loop really.. just separated
+ // them to show what this does.
+
+ // First Pass
+ // ResultArr:
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+ // 1,1,1,1,1,1
+
+ // Second Pass
+ // ResultArr2:
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+ // ,,,,,,,,,,
+ // 1,,1,,1,,1,,1,,1,
+
+ // Third pass fills in the blanks
+ // ResultArr2:
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+ // 1,1,1,1,1,1,1,1,1,1,1,1
+
+ // X,Y = .
+ // X+1,y = ^
+ // X,Y+1 = *
+ // X+1,Y+1 = #
+
+ // Filling in like this;
+ // .*
+ // ^#
+ // 1st .
+ // 2nd *
+ // 3rd ^
+ // 4th #
+ // on single loop.
+
+ float[,] resultarr2 = new float[512,512];
+ for (int y = 0; y < (int)Constants.RegionSize; y++)
+ {
+ for (int x = 0; x < (int)Constants.RegionSize; x++)
+ {
+ resultarr2[y*2, x*2] = resultarr[y, x];
+
+ if (y < (int)Constants.RegionSize)
+ {
+ if (y + 1 < (int)Constants.RegionSize)
+ {
+ if (x + 1 < (int)Constants.RegionSize)
+ {
+ resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] +
+ resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
+ }
+ else
+ {
+ resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x])/2);
+ }
+ }
+ else
+ {
+ resultarr2[(y*2) + 1, x*2] = resultarr[y, x];
+ }
+ }
+ if (x < (int)Constants.RegionSize)
+ {
+ if (x + 1 < (int)Constants.RegionSize)
+ {
+ if (y + 1 < (int)Constants.RegionSize)
+ {
+ resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
+ resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
+ }
+ else
+ {
+ resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1])/2);
+ }
+ }
+ else
+ {
+ resultarr2[y*2, (x*2) + 1] = resultarr[y, x];
+ }
+ }
+ if (x < (int)Constants.RegionSize && y < (int)Constants.RegionSize)
+ {
+ if ((x + 1 < (int)Constants.RegionSize) && (y + 1 < (int)Constants.RegionSize))
+ {
+ resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
+ resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
+ }
+ else
+ {
+ resultarr2[(y*2) + 1, (x*2) + 1] = resultarr[y, x];
+ }
+ }
+ }
+ }
+ //Flatten out the array
+ int i = 0;
+ for (int y = 0; y < 512; y++)
+ {
+ for (int x = 0; x < 512; x++)
+ {
+ if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x]))
+ {
+ m_log.Warn("[PHYSICS]: Non finite heightfield element detected. Setting it to 0");
+ resultarr2[y, x] = 0;
+ }
+ returnarr[i] = resultarr2[y, x];
+ i++;
+ }
+ }
+
+ return returnarr;
+ }
+
+ #endregion
+
+ public override void SetTerrain(float[] heightMap)
+ {
+ if (m_worldOffset != Vector3.Zero && m_parentScene != null)
+ {
+ if (m_parentScene is OdeScene)
+ {
+ ((OdeScene)m_parentScene).SetTerrain(heightMap, m_worldOffset);
+ }
+ }
+ else
+ {
+ SetTerrain(heightMap, m_worldOffset);
+ }
+ }
+
+ public void SetTerrain(float[] heightMap, Vector3 pOffset)
+ {
+ // this._heightmap[i] = (double)heightMap[i];
+ // dbm (danx0r) -- creating a buffer zone of one extra sample all around
+ //_origheightmap = heightMap;
+
+ float[] _heightmap;
+
+ // zero out a heightmap array float array (single dimension [flattened]))
+ //if ((int)Constants.RegionSize == 256)
+ // _heightmap = new float[514 * 514];
+ //else
+
+ _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))];
+
+ uint heightmapWidth = Constants.RegionSize + 1;
+ uint heightmapHeight = Constants.RegionSize + 1;
+
+ uint heightmapWidthSamples;
+
+ uint heightmapHeightSamples;
+
+ //if (((int)Constants.RegionSize) == 256)
+ //{
+ // heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2;
+ // heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2;
+ // heightmapWidth++;
+ // heightmapHeight++;
+ //}
+ //else
+ //{
+
+ heightmapWidthSamples = (uint)Constants.RegionSize + 1;
+ heightmapHeightSamples = (uint)Constants.RegionSize + 1;
+ //}
+
+ const float scale = 1.0f;
+ const float offset = 0.0f;
+ const float thickness = 0.2f;
+ const int wrap = 0;
+
+ int regionsize = (int) Constants.RegionSize + 2;
+ //Double resolution
+ //if (((int)Constants.RegionSize) == 256)
+ // heightMap = ResizeTerrain512Interpolation(heightMap);
+
+
+ // if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256)
+ // regionsize = 512;
+
+ float hfmin = 2000;
+ float hfmax = -2000;
+
+ for (int x = 0; x < heightmapWidthSamples; x++)
+ {
+ for (int y = 0; y < heightmapHeightSamples; y++)
+ {
+ int xx = Util.Clip(x - 1, 0, regionsize - 1);
+ int yy = Util.Clip(y - 1, 0, regionsize - 1);
+
+
+ float val= heightMap[yy * (int)Constants.RegionSize + xx];
+ _heightmap[x * ((int)Constants.RegionSize + 2) + y] = val;
+
+ hfmin = (val < hfmin) ? val : hfmin;
+ hfmax = (val > hfmax) ? val : hfmax;
+ }
+ }
+
+
+
+
+ lock (OdeLock)
+ {
+ IntPtr GroundGeom = IntPtr.Zero;
+ if (RegionTerrain.TryGetValue(pOffset, out GroundGeom))
+ {
+ RegionTerrain.Remove(pOffset);
+ if (GroundGeom != IntPtr.Zero)
+ {
+ if (TerrainHeightFieldHeights.ContainsKey(GroundGeom))
+ {
+ TerrainHeightFieldHeights.Remove(GroundGeom);
+ }
+ d.SpaceRemove(space, GroundGeom);
+ d.GeomDestroy(GroundGeom);
+ }
+
+ }
+ IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
+ d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth + 1, heightmapHeight + 1,
+ (int)heightmapWidthSamples + 1, (int)heightmapHeightSamples + 1, scale,
+ offset, thickness, wrap);
+ d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
+ GroundGeom = d.CreateHeightfield(space, HeightmapData, 1);
+ if (GroundGeom != IntPtr.Zero)
+ {
+ d.GeomSetCategoryBits(GroundGeom, (int)(CollisionCategories.Land));
+ d.GeomSetCollideBits(GroundGeom, (int)(CollisionCategories.Space));
+
+ }
+ geom_name_map[GroundGeom] = "Terrain";
+
+ d.Matrix3 R = new d.Matrix3();
+
+ Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f);
+ Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f);
+ //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1));
+
+ q1 = q1 * q2;
+ //q1 = q1 * q3;
+ Vector3 v3;
+ float angle;
+ q1.GetAxisAngle(out v3, out angle);
+
+ d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
+ d.GeomSetRotation(GroundGeom, ref R);
+ d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)) - 1, (pOffset.Y + ((int)Constants.RegionSize * 0.5f)) - 1, 0);
+ IntPtr testGround = IntPtr.Zero;
+ if (RegionTerrain.TryGetValue(pOffset, out testGround))
+ {
+ RegionTerrain.Remove(pOffset);
+ }
+ RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
+ TerrainHeightFieldHeights.Add(GroundGeom,_heightmap);
+
+ }
+ }
+
+ public override void DeleteTerrain()
+ {
+ }
+
+ public float GetWaterLevel()
+ {
+ return waterlevel;
+ }
+
+ public override bool SupportsCombining()
+ {
+ return true;
+ }
+
+ public override void UnCombine(PhysicsScene pScene)
+ {
+ IntPtr localGround = IntPtr.Zero;
+// float[] localHeightfield;
+ bool proceed = false;
+ List geomDestroyList = new List();
+
+ lock (OdeLock)
+ {
+ if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround))
+ {
+ foreach (IntPtr geom in TerrainHeightFieldHeights.Keys)
+ {
+ if (geom == localGround)
+ {
+// localHeightfield = TerrainHeightFieldHeights[geom];
+ proceed = true;
+ }
+ else
+ {
+ geomDestroyList.Add(geom);
+ }
+ }
+
+ if (proceed)
+ {
+ m_worldOffset = Vector3.Zero;
+ WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
+ m_parentScene = null;
+
+ foreach (IntPtr g in geomDestroyList)
+ {
+ // removingHeightField needs to be done or the garbage collector will
+ // collect the terrain data before we tell ODE to destroy it causing
+ // memory corruption
+ if (TerrainHeightFieldHeights.ContainsKey(g))
+ {
+// float[] removingHeightField = TerrainHeightFieldHeights[g];
+ TerrainHeightFieldHeights.Remove(g);
+
+ if (RegionTerrain.ContainsKey(g))
+ {
+ RegionTerrain.Remove(g);
+ }
+
+ d.GeomDestroy(g);
+ //removingHeightField = new float[0];
+ }
+ }
+
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data.");
+
+ }
+ }
+ }
+ }
+
+ public override void SetWaterLevel(float baseheight)
+ {
+ waterlevel = baseheight;
+ randomizeWater(waterlevel);
+ }
+
+ public void randomizeWater(float baseheight)
+ {
+ const uint heightmapWidth = m_regionWidth + 2;
+ const uint heightmapHeight = m_regionHeight + 2;
+ const uint heightmapWidthSamples = m_regionWidth + 2;
+ const uint heightmapHeightSamples = m_regionHeight + 2;
+ const float scale = 1.0f;
+ const float offset = 0.0f;
+ const float thickness = 2.9f;
+ const int wrap = 0;
+
+ for (int i = 0; i < (258 * 258); i++)
+ {
+ _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f);
+ // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f));
+ }
+
+ lock (OdeLock)
+ {
+ if (WaterGeom != IntPtr.Zero)
+ {
+ d.SpaceRemove(space, WaterGeom);
+ }
+ IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
+ d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight,
+ (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale,
+ offset, thickness, wrap);
+ d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
+ WaterGeom = d.CreateHeightfield(space, HeightmapData, 1);
+ if (WaterGeom != IntPtr.Zero)
+ {
+ d.GeomSetCategoryBits(WaterGeom, (int)(CollisionCategories.Water));
+ d.GeomSetCollideBits(WaterGeom, (int)(CollisionCategories.Space));
+
+ }
+ geom_name_map[WaterGeom] = "Water";
+
+ d.Matrix3 R = new d.Matrix3();
+
+ Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f);
+ Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f);
+ //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1));
+
+ q1 = q1 * q2;
+ //q1 = q1 * q3;
+ Vector3 v3;
+ float angle;
+ q1.GetAxisAngle(out v3, out angle);
+
+ d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
+ d.GeomSetRotation(WaterGeom, ref R);
+ d.GeomSetPosition(WaterGeom, 128, 128, 0);
+
+ }
+
+ }
+
+ public override void Dispose()
+ {
+ m_rayCastManager.Dispose();
+ m_rayCastManager = null;
+
+ lock (OdeLock)
+ {
+ lock (_prims)
+ {
+ foreach (OdePrim prm in _prims)
+ {
+ RemovePrim(prm);
+ }
+ }
+
+ //foreach (OdeCharacter act in _characters)
+ //{
+ //RemoveAvatar(act);
+ //}
+ d.WorldDestroy(world);
+ //d.CloseODE();
+ }
+ }
+ public override Dictionary GetTopColliders()
+ {
+ Dictionary returncolliders = new Dictionary();
+ int cnt = 0;
+ lock (_prims)
+ {
+ foreach (OdePrim prm in _prims)
+ {
+ if (prm.CollisionScore > 0)
+ {
+ returncolliders.Add(prm.m_localID, prm.CollisionScore);
+ cnt++;
+ prm.CollisionScore = 0f;
+ if (cnt > 25)
+ {
+ break;
+ }
+ }
+ }
+ }
+ return returncolliders;
+ }
+
+ public override bool SupportsRayCast()
+ {
+ return true;
+ }
+
+ public override void RaycastWorld(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod)
+ {
+ if (retMethod != null)
+ {
+ m_rayCastManager.QueueRequest(position, direction, length, retMethod);
+ }
+ }
+
+#if USE_DRAWSTUFF
+ // Keyboard callback
+ public void command(int cmd)
+ {
+ IntPtr geom;
+ d.Mass mass;
+ d.Vector3 sides = new d.Vector3(d.RandReal() * 0.5f + 0.1f, d.RandReal() * 0.5f + 0.1f, d.RandReal() * 0.5f + 0.1f);
+
+
+
+ Char ch = Char.ToLower((Char)cmd);
+ switch ((Char)ch)
+ {
+ case 'w':
+ try
+ {
+ Vector3 rotate = (new Vector3(1, 0, 0) * Quaternion.CreateFromEulers(hpr.Z * Utils.DEG_TO_RAD, hpr.Y * Utils.DEG_TO_RAD, hpr.X * Utils.DEG_TO_RAD));
+
+ xyz.X += rotate.X; xyz.Y += rotate.Y; xyz.Z += rotate.Z;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ }
+ catch (ArgumentException)
+ { hpr.X = 0; }
+ break;
+
+ case 'a':
+ hpr.X++;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ break;
+
+ case 's':
+ try
+ {
+ Vector3 rotate2 = (new Vector3(-1, 0, 0) * Quaternion.CreateFromEulers(hpr.Z * Utils.DEG_TO_RAD, hpr.Y * Utils.DEG_TO_RAD, hpr.X * Utils.DEG_TO_RAD));
+
+ xyz.X += rotate2.X; xyz.Y += rotate2.Y; xyz.Z += rotate2.Z;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ }
+ catch (ArgumentException)
+ { hpr.X = 0; }
+ break;
+ case 'd':
+ hpr.X--;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ break;
+ case 'r':
+ xyz.Z++;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ break;
+ case 'f':
+ xyz.Z--;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ break;
+ case 'e':
+ xyz.Y++;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ break;
+ case 'q':
+ xyz.Y--;
+ ds.SetViewpoint(ref xyz, ref hpr);
+ break;
+ }
+ }
+
+ public void step(int pause)
+ {
+
+ ds.SetColor(1.0f, 1.0f, 0.0f);
+ ds.SetTexture(ds.Texture.Wood);
+ lock (_prims)
+ {
+ foreach (OdePrim prm in _prims)
+ {
+ //IntPtr body = d.GeomGetBody(prm.prim_geom);
+ if (prm.prim_geom != IntPtr.Zero)
+ {
+ d.Vector3 pos;
+ d.GeomCopyPosition(prm.prim_geom, out pos);
+ //d.BodyCopyPosition(body, out pos);
+
+ d.Matrix3 R;
+ d.GeomCopyRotation(prm.prim_geom, out R);
+ //d.BodyCopyRotation(body, out R);
+
+
+ d.Vector3 sides = new d.Vector3();
+ sides.X = prm.Size.X;
+ sides.Y = prm.Size.Y;
+ sides.Z = prm.Size.Z;
+
+ ds.DrawBox(ref pos, ref R, ref sides);
+ }
+ }
+ }
+ ds.SetColor(1.0f, 0.0f, 0.0f);
+ lock (_characters)
+ {
+ foreach (OdeCharacter chr in _characters)
+ {
+ if (chr.Shell != IntPtr.Zero)
+ {
+ IntPtr body = d.GeomGetBody(chr.Shell);
+
+ d.Vector3 pos;
+ d.GeomCopyPosition(chr.Shell, out pos);
+ //d.BodyCopyPosition(body, out pos);
+
+ d.Matrix3 R;
+ d.GeomCopyRotation(chr.Shell, out R);
+ //d.BodyCopyRotation(body, out R);
+
+ ds.DrawCapsule(ref pos, ref R, chr.Size.Z, 0.35f);
+ d.Vector3 sides = new d.Vector3();
+ sides.X = 0.5f;
+ sides.Y = 0.5f;
+ sides.Z = 0.5f;
+
+ ds.DrawBox(ref pos, ref R, ref sides);
+ }
+ }
+ }
+ }
+
+ public void start(int unused)
+ {
+ ds.SetViewpoint(ref xyz, ref hpr);
+ }
+#endif
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/ChOdePlugin/Tests/ODETestClass.cs
new file mode 100644
index 0000000..69e2d03
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/Tests/ODETestClass.cs
@@ -0,0 +1,122 @@
+/*
+ * 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 Nini.Config;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+using log4net;
+using System.Reflection;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ [TestFixture]
+ public class ODETestClass
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private OdePlugin cbt;
+ private PhysicsScene ps;
+ private IMeshingPlugin imp;
+
+ [SetUp]
+ public void Initialize()
+ {
+ // Loading ODEPlugin
+ cbt = new OdePlugin();
+ // Loading Zero Mesher
+ imp = new ZeroMesherPlugin();
+ // Getting Physics Scene
+ ps = cbt.GetScene("test");
+ // Initializing Physics Scene.
+ ps.Initialise(imp.GetMesher(),null);
+ float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize];
+ for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++)
+ {
+ _heightmap[i] = 21f;
+ }
+ ps.SetTerrain(_heightmap);
+ }
+
+ [TearDown]
+ public void Terminate()
+ {
+ ps.DeleteTerrain();
+ ps.Dispose();
+
+ }
+
+ [Test]
+ public void CreateAndDropPhysicalCube()
+ {
+ PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox();
+ Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
+ Vector3 size = new Vector3(0.5f, 0.5f, 0.5f);
+ Quaternion rot = Quaternion.Identity;
+ PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true);
+ OdePrim oprim = (OdePrim)prim;
+ OdeScene pscene = (OdeScene) ps;
+
+ Assert.That(oprim.m_taintadd);
+
+ prim.LocalID = 5;
+
+ for (int i = 0; i < 58; i++)
+ {
+ ps.Simulate(0.133f);
+
+ Assert.That(oprim.prim_geom != (IntPtr)0);
+
+ Assert.That(oprim.m_targetSpace != (IntPtr)0);
+
+ //Assert.That(oprim.m_targetSpace == pscene.space);
+ m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space);
+
+ Assert.That(!oprim.m_taintadd);
+ m_log.Info("Prim Position (" + oprim.m_localID + "): " + prim.Position.ToString());
+
+ // Make sure we're above the ground
+ //Assert.That(prim.Position.Z > 20f);
+ //m_log.Info("PrimCollisionScore (" + oprim.m_localID + "): " + oprim.m_collisionscore);
+
+ // Make sure we've got a Body
+ Assert.That(oprim.Body != (IntPtr)0);
+ //m_log.Info(
+ }
+
+ // Make sure we're not somewhere above the ground
+ Assert.That(prim.Position.Z < 21.5f);
+
+ ps.RemovePrim(prim);
+ Assert.That(oprim.m_taintremove);
+ ps.Simulate(0.133f);
+ Assert.That(oprim.Body == (IntPtr)0);
+ }
+ }
+}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/drawstuff.cs b/OpenSim/Region/Physics/ChOdePlugin/drawstuff.cs
new file mode 100644
index 0000000..87ca446
--- /dev/null
+++ b/OpenSim/Region/Physics/ChOdePlugin/drawstuff.cs
@@ -0,0 +1,98 @@
+/*
+ * Copyright ODE
+ * Ode.NET - .NET bindings for ODE
+ * Jason Perkins (starkos@industriousone.com)
+ * Licensed under the New BSD
+ * Part of the OpenDynamicsEngine
+Open Dynamics Engine
+Copyright (c) 2001-2007, Russell L. Smith.
+All rights reserved.
+
+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 names of ODE's copyright owner 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+"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 COPYRIGHT
+OWNER OR 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.Runtime.InteropServices;
+using Ode.NET;
+
+namespace Drawstuff.NET
+{
+#if dDOUBLE
+ using dReal = System.Double;
+#else
+ using dReal = System.Single;
+#endif
+
+ public static class ds
+ {
+ public const int VERSION = 2;
+
+ public enum Texture
+ {
+ None,
+ Wood
+ }
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void CallbackFunction(int arg);
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Functions
+ {
+ public int version;
+ public CallbackFunction start;
+ public CallbackFunction step;
+ public CallbackFunction command;
+ public CallbackFunction stop;
+ public string path_to_textures;
+ }
+
+ [DllImport("drawstuff", EntryPoint = "dsDrawBox")]
+ public static extern void DrawBox(ref d.Vector3 pos, ref d.Matrix3 R, ref d.Vector3 sides);
+
+ [DllImport("drawstuff", EntryPoint = "dsDrawCapsule")]
+ public static extern void DrawCapsule(ref d.Vector3 pos, ref d.Matrix3 R, dReal length, dReal radius);
+
+ [DllImport("drawstuff", EntryPoint = "dsDrawConvex")]
+ public static extern void DrawConvex(ref d.Vector3 pos, ref d.Matrix3 R, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons);
+
+ [DllImport("drawstuff", EntryPoint = "dsSetColor")]
+ public static extern void SetColor(float red, float green, float blue);
+
+ [DllImport("drawstuff", EntryPoint = "dsSetTexture")]
+ public static extern void SetTexture(Texture texture);
+
+ [DllImport("drawstuff", EntryPoint = "dsSetViewpoint")]
+ public static extern void SetViewpoint(ref d.Vector3 xyz, ref d.Vector3 hpr);
+
+ [DllImport("drawstuff", EntryPoint = "dsSimulationLoop")]
+ public static extern void SimulationLoop(int argc, string[] argv, int window_width, int window_height, ref Functions fn);
+ }
+}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index b99baa2..06ed8fb 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -1197,26 +1197,13 @@ namespace OpenSim.Region.Physics.OdePlugin
public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } }
- public override Quaternion APIDTarget
- {
- set { return; }
- }
+ public override Quaternion APIDTarget{ set { return; } }
- public override bool APIDActive
- {
- set { return; }
- }
+ public override bool APIDActive{ set { return; } }
- public override float APIDStrength
- {
- set { return; }
- }
-
- public override float APIDDamping
- {
- set { return; }
- }
+ public override float APIDStrength{ set { return; } }
+ public override float APIDDamping{ set { return; } }
public override void SubscribeEvents(int ms)
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 78b15be..39cdc0f 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -23,19 +23,6 @@
* 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.
- *
- * Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
- * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
- * ODEPrim.cs contains methods dealing with Prim editing, Prim
- * characteristics and Kinetic motion.
- * ODEDynamics.cs contains methods dealing with Prim Physical motion
- * (dynamics) and the associated settings. Old Linear and angular
- * motors for dynamic motion have been replace with MoveLinear()
- * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
- * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
- * switch between 'VEHICLE' parameter use and general dynamics
- * settings use.
- *
*/
/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
@@ -133,7 +120,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// private float m_VhoverEfficiency = 0f;
private float m_VhoverTimescale = 0f;
private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
- private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle.
+ private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle.
// Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
// KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
// Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.
@@ -492,7 +479,7 @@ namespace OpenSim.Region.Physics.OdePlugin
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
m_dir *= rotq; // apply obj rotation to velocity vector
- // add Gravity and Buoyancy
+ // add Gravity andBuoyancy
// KF: So far I have found no good method to combine a script-requested
// .Z velocity and gravity. Therefore only 0g will used script-requested
// .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
@@ -574,7 +561,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
*/
-//if(frcount == 0) Console.WriteLine("MoveAngular ");
// Get what the body is doing, this includes 'external' influences
d.Vector3 angularVelocity = d.BodyGetAngularVel(Body);
@@ -650,7 +636,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Deflection section tba
// Sum velocities
- m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // tba: + bank + deflection
+ m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection
if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
{
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 688be83..3eb3b28 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -21,18 +21,6 @@
* 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.
- *
- * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
- * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
- * ODEPrim.cs contains methods dealing with Prim editing, Prim
- * characteristics and Kinetic motion.
- * ODEDynamics.cs contains methods dealing with Prim Physical motion
- * (dynamics) and the associated settings. Old Linear and angular
- * motors for dynamic motion have been replace with MoveLinear()
- * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
- * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_ is to
- * switch between 'VEHICLE' parameter use and general dynamics
- * settings use.
*/
/*
@@ -93,12 +81,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_PIDTau;
private float PID_D = 35f;
private float PID_G = 25f;
- private bool m_usePID = false;
-
- private Quaternion m_APIDTarget = new Quaternion();
- private float m_APIDStrength = 0.5f;
- private float m_APIDDamping = 0.5f;
- private bool m_useAPID = false;
+ private bool m_usePID;
// KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
// and are for non-VEHICLES only.
@@ -199,9 +182,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private ODEDynamics m_vehicle;
internal int m_material = (int)Material.Wood;
-
- private int frcount = 0; // Used to limit dynamics debug output to
-
public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
@@ -1581,14 +1561,9 @@ Console.WriteLine(" JointCreateFixed");
float fy = 0;
float fz = 0;
- frcount++; // used to limit debug comment output
- if (frcount > 100)
- frcount = 0;
if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims.
{
-//if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle.Type +
- // " usePID=" + m_usePID + " seHover=" + m_useHoverPID + " useAPID=" + m_useAPID);
if (m_vehicle.Type != Vehicle.TYPE_NONE)
{
// 'VEHICLES' are dealt with in ODEDynamics.cs
@@ -1596,6 +1571,7 @@ Console.WriteLine(" JointCreateFixed");
}
else
{
+//Console.WriteLine("Move " + m_primName);
if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
// NON-'VEHICLES' are dealt with here
if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
@@ -1617,18 +1593,21 @@ Console.WriteLine(" JointCreateFixed");
//m_log.Info(m_collisionFlags.ToString());
- //KF: m_buoyancy is set by llSetBuoyancy() and is for non-vehicle.
+ //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
+ // would come from SceneObjectPart.cs, public void SetBuoyancy(float fvalue) , PhysActor.Buoyancy = fvalue; ??
// m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
- // NB Prims in ODE are no subject to global gravity
- fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; // force = acceleration * mass
+ // gravityz multiplier = 1 - m_buoyancy
+ fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass;
if (m_usePID)
{
-//if(frcount == 0) Console.WriteLine("PID " + m_primName);
- // KF - this is for object MoveToTarget.
-
+//Console.WriteLine("PID " + m_primName);
+ // KF - this is for object move? eg. llSetPos() ?
//if (!d.BodyIsEnabled(Body))
//d.BodySetForce(Body, 0f, 0f, 0f);
+ // If we're using the PID controller, then we have no gravity
+ //fz = (-1 * _parent_scene.gravityz) * m_mass; //KF: ?? Prims have no global gravity,so simply...
+ fz = 0f;
// no lock; for now it's only called from within Simulate()
@@ -1763,7 +1742,7 @@ Console.WriteLine(" JointCreateFixed");
d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
d.BodyAddForce(Body, 0, 0, fz);
- //KF this prevents furthur motions return;
+ return;
}
else
{
@@ -1772,46 +1751,8 @@ Console.WriteLine(" JointCreateFixed");
// We're flying and colliding with something
fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
}
- } // end m_useHoverPID && !m_usePID
-
- if (m_useAPID)
- {
- // RotLookAt, apparently overrides all other rotation sources. Inputs:
- // Quaternion m_APIDTarget
- // float m_APIDStrength // From SL experiments, this is the time to get there
- // float m_APIDDamping // From SL experiments, this is damping, 1.0 = damped, 0.1 = wobbly
- // Also in SL the mass of the object has no effect on time to get there.
- // Factors:
-//if(frcount == 0) Console.WriteLine("APID ");
- // get present body rotation
- float limit = 1.0f;
- float scaler = 50f; // adjusts damping time
- float RLAservo = 0f;
-
- d.Quaternion rot = d.BodyGetQuaternion(Body);
- Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
- Quaternion rot_diff = Quaternion.Inverse(rotq) * m_APIDTarget;
- float diff_angle;
- Vector3 diff_axis;
- rot_diff.GetAxisAngle(out diff_axis, out diff_angle);
- diff_axis.Normalize();
- if(diff_angle > 0.01f) // diff_angle is always +ve
- {
-// PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
- Vector3 rotforce = new Vector3(diff_axis.X, diff_axis.Y, diff_axis.Z);
- rotforce = rotforce * rotq;
- if(diff_angle > limit) diff_angle = limit; // cap the rotate rate
-// RLAservo = timestep / m_APIDStrength * m_mass * scaler;
- // rotforce = rotforce * RLAservo * diff_angle ;
- // d.BodyAddRelTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
- RLAservo = timestep / m_APIDStrength * scaler;
- rotforce = rotforce * RLAservo * diff_angle ;
- d.BodySetAngularVel (Body, rotforce.X, rotforce.Y, rotforce.Z);
-//Console.WriteLine("axis= " + diff_axis + " angle= " + diff_angle + "servo= " + RLAservo);
- }
-//if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo + " angle= " + diff_angle);
- } // end m_useAPID
-
+ }
+
fx *= m_mass;
fy *= m_mass;
//fz *= m_mass;
@@ -2673,7 +2614,7 @@ Console.WriteLine(" JointCreateFixed");
m_lastposition = _position;
m_lastorientation = _orientation;
-
+
l_position.X = vec.X;
l_position.Y = vec.Y;
l_position.Z = vec.Z;
@@ -2681,10 +2622,6 @@ Console.WriteLine(" JointCreateFixed");
l_orientation.Y = ori.Y;
l_orientation.Z = ori.Z;
l_orientation.W = ori.W;
-
-// if(l_position.Y != m_lastposition.Y){
-// Console.WriteLine("UP&V {0} {1}", m_primName, l_position);
-// }
if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f)
{
@@ -2885,17 +2822,20 @@ Console.WriteLine(" JointCreateFixed");
}
public override bool PIDActive { set { m_usePID = value; } }
public override float PIDTau { set { m_PIDTau = value; } }
-
- // For RotLookAt
- public override Quaternion APIDTarget { set { m_APIDTarget = value; } }
- public override bool APIDActive { set { m_useAPID = value; } }
- public override float APIDStrength { set { m_APIDStrength = value; } }
- public override float APIDDamping { set { m_APIDDamping = value; } }
public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } }
public override bool PIDHoverActive { set { m_useHoverPID = value; } }
public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
+
+ public override Quaternion APIDTarget{ set { return; } }
+
+ public override bool APIDActive{ set { return; } }
+
+ public override float APIDStrength{ set { return; } }
+
+ public override float APIDDamping{ set { return; } }
+
private void createAMotor(Vector3 axis)
{
--
cgit v1.1
From b53b87166940ca0fca4ae2190649e18102c886ec Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 22 Dec 2009 06:25:32 +0100
Subject: Add a data path for error messages
---
OpenSim/Framework/Capabilities/Caps.cs | 21 +++++++++++++--------
.../Framework/Interfaces/IEntityInventory.cs | 2 ++
.../Region/Framework/Interfaces/IScriptModule.cs | 3 +++
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 18 ++++++++++++------
.../Framework/Scenes/SceneObjectPartInventory.cs | 22 ++++++++++++++++++++++
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 5 +++++
6 files changed, 57 insertions(+), 14 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index 1f1ac78..74c6ab0 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Framework.Capabilities
public delegate UUID UpdateItem(UUID itemID, byte[] data);
- public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data);
+ public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
public delegate void NewInventoryItem(UUID userID, InventoryItemBase item);
@@ -54,7 +54,7 @@ namespace OpenSim.Framework.Capabilities
public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data);
- public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID,
+ public delegate ArrayList TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID,
bool isScriptRunning, byte[] data);
public delegate InventoryCollection FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
@@ -940,11 +940,13 @@ namespace OpenSim.Framework.Capabilities
/// Prim containing item to update
/// Signals whether the script to update is currently running
/// New asset data
- public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data)
+ public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors)
{
if (TaskScriptUpdatedCall != null)
{
- TaskScriptUpdatedCall(m_agentID, itemID, primID, isScriptRunning, data);
+ ArrayList e = TaskScriptUpdatedCall(m_agentID, itemID, primID, isScriptRunning, data);
+ foreach (Object item in e)
+ errors.Add(item);
}
}
@@ -1174,17 +1176,20 @@ namespace OpenSim.Framework.Capabilities
// data, path, param));
string res = String.Empty;
- LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete();
+ LLSDTaskScriptUploadComplete uploadComplete = new LLSDTaskScriptUploadComplete();
+ ArrayList errors = new ArrayList();
handlerUpdateTaskScript = OnUpLoad;
if (handlerUpdateTaskScript != null)
{
- handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data);
+ handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data, ref errors);
}
- uploadComplete.item_id = inventoryItemID;
- uploadComplete.task_id = primID;
+ uploadComplete.new_asset = inventoryItemID;
+ uploadComplete.compiled = errors.Count > 0 ? false : true;
uploadComplete.state = "complete";
+ uploadComplete.errors = new OSDArray();
+ uploadComplete.errors.Array = errors;
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 89a45da..67395fa 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -26,6 +26,7 @@
*/
using System.Collections.Generic;
+using System.Collections;
using OpenMetaverse;
using OpenSim.Framework;
@@ -71,6 +72,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// Start all the scripts contained in this entity's inventory
///
void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
+ ArrayList GetScriptErrors(UUID itemID);
///
/// Stop all the scripts in this entity.
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 98efcbe..e90b300 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -26,6 +26,7 @@
*/
using System;
+using System.Collections;
using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces
@@ -39,5 +40,7 @@ namespace OpenSim.Region.Framework.Interfaces
bool PostScriptEvent(UUID itemID, string name, Object[] args);
bool PostObjectEvent(UUID itemID, string name, Object[] args);
+
+ ArrayList GetScriptErrors(UUID itemID);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 7ca779a..bce7d32 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Collections;
using System.Reflection;
using System.Text;
using System.Timers;
@@ -215,13 +216,13 @@ namespace OpenSim.Region.Framework.Scenes
/// The prim which contains the item to update
/// Indicates whether the script to update is currently running
///
- public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId,
+ public ArrayList CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId,
UUID primId, bool isScriptRunning, byte[] data)
{
if (!Permissions.CanEditScript(itemId, primId, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
- return;
+ return new ArrayList();
}
// Retrieve group
@@ -234,7 +235,7 @@ namespace OpenSim.Region.Framework.Scenes
"Prim inventory update requested for item ID {0} in prim ID {1} but this prim does not exist",
itemId, primId);
- return;
+ return new ArrayList();
}
// Retrieve item
@@ -247,7 +248,7 @@ namespace OpenSim.Region.Framework.Scenes
+ " but the item does not exist in this inventory",
itemId, part.Name, part.UUID);
- return;
+ return new ArrayList();
}
AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data);
@@ -264,29 +265,33 @@ namespace OpenSim.Region.Framework.Scenes
part.GetProperties(remoteClient);
// Trigger rerunning of script (use TriggerRezScript event, see RezScript)
+ ArrayList errors = new ArrayList();
+
if (isScriptRunning)
{
// Needs to determine which engine was running it and use that
//
part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0);
+ errors = part.Inventory.GetScriptErrors(item.ItemID);
}
else
{
remoteClient.SendAgentAlertMessage("Script saved", false);
}
+ return errors;
}
///
/// CapsUpdateTaskInventoryScriptAsset(IClientAPI, UUID, UUID, bool, byte[])
///
- public void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId,
+ public ArrayList CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId,
UUID primId, bool isScriptRunning, byte[] data)
{
ScenePresence avatar;
if (TryGetAvatar(avatarId, out avatar))
{
- CapsUpdateTaskInventoryScriptAsset(
+ return CapsUpdateTaskInventoryScriptAsset(
avatar.ControllingClient, itemId, primId, isScriptRunning, data);
}
else
@@ -295,6 +300,7 @@ namespace OpenSim.Region.Framework.Scenes
"[PRIM INVENTORY]: " +
"Avatar {0} cannot be found to update its prim item asset",
avatarId);
+ return new ArrayList();
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index cdd23bd..c3c6342 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -29,6 +29,7 @@ using System;
using System.Xml;
using System.IO;
using System.Collections.Generic;
+using System.Collections;
using System.Reflection;
using OpenMetaverse;
using log4net;
@@ -210,6 +211,27 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public ArrayList GetScriptErrors(UUID itemID)
+ {
+ ArrayList ret = new ArrayList();
+
+ IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces();
+ if (engines == null) // No engine at all
+ return ret;
+
+ foreach (IScriptModule e in engines)
+ {
+ if (e != null)
+ {
+ ArrayList errors = e.GetScriptErrors(itemID);
+ foreach (Object line in errors)
+ ret.Add(line);
+ }
+ }
+
+ return ret;
+ }
+
///
/// Stop all the scripts in this prim.
///
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 2a9a2db..31684ae 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1552,5 +1552,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return true;
}
+
+ public ArrayList GetScriptErrors(UUID itemID)
+ {
+ return new ArrayList();
+ }
}
}
--
cgit v1.1
From bde26a8282cf7d3e173413a49a88f25a6bee0db1 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Tue, 22 Dec 2009 06:43:03 +0100
Subject: Add missing file
---
.../Capabilities/LLSDTaskScriptUploadComplete.cs | 54 ++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 OpenSim/Framework/Capabilities/LLSDTaskScriptUploadComplete.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Capabilities/LLSDTaskScriptUploadComplete.cs b/OpenSim/Framework/Capabilities/LLSDTaskScriptUploadComplete.cs
new file mode 100644
index 0000000..d308831
--- /dev/null
+++ b/OpenSim/Framework/Capabilities/LLSDTaskScriptUploadComplete.cs
@@ -0,0 +1,54 @@
+/*
+ * 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 OpenMetaverse;
+using System;
+using System.Collections;
+
+namespace OpenSim.Framework.Capabilities
+{
+ [OSDMap]
+ public class LLSDTaskScriptUploadComplete
+ {
+ ///
+ /// The task inventory item that was updated
+ ///
+ public UUID new_asset;
+
+ ///
+ /// Was it compiled?
+ ///
+ public bool compiled;
+
+ ///
+ /// State of the upload. So far have only even seen this set to "complete"
+ ///
+ public string state;
+
+ public OSDArray errors;
+ }
+}
--
cgit v1.1
From b575bf25245102fd43d025081b249cb730b865ac Mon Sep 17 00:00:00 2001
From: CasperW
Date: Wed, 23 Dec 2009 14:14:20 +0100
Subject: Added some null reference and deleted group checks to certain
functions to fix region crash scenarios.
---
.../Shared/Api/Implementation/LSL_Api.cs | 114 +++++++++++++++------
1 file changed, 85 insertions(+), 29 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2da498a..84c2722 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -221,7 +221,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public List GetLinkParts(int linkType)
{
- List ret = new List();
+ List ret = new List();
+ if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
+ return ret;
ret.Add(m_host);
switch (linkType)
@@ -1136,7 +1138,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
public void llSetStatus(int status, int value)
- {
+ {
+ if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
+ return;
m_host.AddScriptLPS(1);
int statusrotationaxis = 0;
@@ -1290,7 +1294,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetScale(SceneObjectPart part, LSL_Vector scale)
- {
+ {
// TODO: this needs to trigger a persistance save as well
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
return;
@@ -1349,7 +1353,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
Color4 texcolor;
if (face >= 0 && face < GetNumberOfSides(part))
@@ -1386,7 +1393,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
public void SetTexGen(SceneObjectPart part, int face,int style)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
MappingType textype;
textype = MappingType.Default;
@@ -1416,7 +1426,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
public void SetGlow(SceneObjectPart part, int face, float glow)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
if (face >= 0 && face < GetNumberOfSides(part))
{
@@ -1441,7 +1454,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
Shininess sval = new Shininess();
@@ -1491,7 +1506,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
public void SetFullBright(SceneObjectPart part, int face, bool bright)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
if (face >= 0 && face < GetNumberOfSides(part))
{
@@ -1558,7 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetAlpha(SceneObjectPart part, double alpha, int face)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
Color4 texcolor;
if (face >= 0 && face < GetNumberOfSides(part))
@@ -1603,8 +1624,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
///
protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
float wind, float tension, LSL_Vector Force)
- {
- if (part == null)
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
return;
if (flexi)
@@ -1638,8 +1659,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
///
///
protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
- {
- if (part == null)
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
return;
if (light)
@@ -1724,7 +1745,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetTexture(SceneObjectPart part, string texture, int face)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
UUID textureID=new UUID();
if (!UUID.TryParse(texture, out textureID))
@@ -1769,7 +1793,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
if (face >= 0 && face < GetNumberOfSides(part))
{
@@ -1805,7 +1832,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
if (face >= 0 && face < GetNumberOfSides(part))
{
@@ -1841,7 +1871,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void RotateTexture(SceneObjectPart part, double rotation, int face)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
Primitive.TextureEntry tex = part.Shape.Textures;
if (face >= 0 && face < GetNumberOfSides(part))
{
@@ -1911,7 +1944,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
// Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
LSL_Vector currentPos = llGetLocalPos();
@@ -2005,7 +2041,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetRot(SceneObjectPart part, Quaternion rot)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
part.UpdateRotation(rot);
// Update rotation does not move the object in the physics scene if it's a linkset.
@@ -6500,8 +6539,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
- {
- ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
+ {
+ ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return shapeBlock;
if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6570,7 +6611,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
ObjectShapePacket.ObjectDataBlock shapeBlock;
shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6618,7 +6662,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
ObjectShapePacket.ObjectDataBlock shapeBlock;
shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6659,7 +6706,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
ObjectShapePacket.ObjectDataBlock shapeBlock;
shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6779,7 +6829,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
UUID sculptId;
@@ -6813,14 +6866,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
public void llSetPrimitiveParams(LSL_List rules)
- {
+ {
m_host.AddScriptLPS(1);
SetPrimParams(m_host, rules);
}
public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
- {
- m_host.AddScriptLPS(1);
+ {
+ m_host.AddScriptLPS(1);
List parts = GetLinkParts(linknumber);
@@ -6829,7 +6882,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
- {
+ {
+ if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
+ return;
+
int idx = 0;
while (idx < rules.Length)
--
cgit v1.1
From a9f4d7a29c0f5b3ee10b46b9a27c5d10c7e71eb3 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Wed, 23 Dec 2009 17:34:08 +0100
Subject: Add a debugger tag to stop Visual Studio from breaking
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 8376846..c831c69 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1264,6 +1264,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return UUID.Zero;
}
+ [DebuggerNonUserCode]
public void SetState(UUID itemID, string newState)
{
IScriptInstance instance = GetInstance(itemID);
--
cgit v1.1
From 7f699fca9a34cd0f3525534bdbc04c8b8ee975fe Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 24 Dec 2009 18:18:14 +0100
Subject: Add the body to the LSL List Size property
---
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 38 +++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 1fc31c5..faf9c40 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -422,7 +422,8 @@ namespace OpenSim.Region.ScriptEngine.Shared
public int Length
{
- get {
+ get
+ {
if (m_data == null)
m_data=new Object[0];
return m_data.Length;
@@ -431,7 +432,40 @@ namespace OpenSim.Region.ScriptEngine.Shared
public int Size
{
- get { return 0; }
+ get
+ {
+ if (m_data == null)
+ m_data=new Object[0];
+
+ int size = 0;
+
+ foreach (Object o in m_data)
+ {
+ if (o is LSL_Types.LSLInteger)
+ size += 4;
+ else if (o is LSL_Types.LSLFloat)
+ size += 8;
+ else if (o is LSL_Types.LSLString)
+ size += ((LSL_Types.LSLString)o).m_string.Length;
+ else if (o is LSL_Types.key)
+ size += ((LSL_Types.key)o).value.Length;
+ else if (o is LSL_Types.Vector3)
+ size += 32;
+ else if (o is LSL_Types.Quaternion)
+ size += 64;
+ else if (o is int)
+ size += 4;
+ else if (o is string)
+ size += ((string)o).Length;
+ else if (o is float)
+ size += 8;
+ else if (o is double)
+ size += 16;
+ else
+ throw new Exception("Unknown type in List.Size: " + o.GetType().ToString());
+ }
+ return size;
+ }
}
public object[] Data
--
cgit v1.1
From e7439efc74a1cc0daedc51eb25ae66cd03db70b5 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Thu, 24 Dec 2009 19:19:44 -0500
Subject: Recover out-of-region objects during db load.
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 24 ++++++++++++++++++++++++
OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 4 +++-
3 files changed, 28 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index a7d34f5..7274a06 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.6.91CM";
+ private const string VERSION_NUMBER = "0.6.92Ch";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index b0fb8b3..998d598 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -222,6 +222,30 @@ namespace OpenSim.Region.Framework.Scenes
protected internal bool AddRestoredSceneObject(
SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
{
+ // KF: Check for out-of-region, move inside and make static.
+ Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X,
+ sceneObject.RootPart.GroupPosition.Y,
+ sceneObject.RootPart.GroupPosition.Z);
+ if (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 ||
+ npos.X > Constants.RegionSize ||
+ npos.Y > Constants.RegionSize)
+ {
+ if (npos.X < 0.0) npos.X = 1.0f;
+ if (npos.Y < 0.0) npos.Y = 1.0f;
+ if (npos.Z < 0.0) npos.Z = 0.0f;
+ if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f;
+ if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f;
+
+ foreach (SceneObjectPart part in sceneObject.Children.Values)
+ {
+ part.GroupPosition = npos;
+ }
+ sceneObject.RootPart.Velocity = Vector3.Zero;
+ sceneObject.RootPart.AngularVelocity = Vector3.Zero;
+ sceneObject.RootPart.Acceleration = Vector3.Zero;
+ sceneObject.RootPart.Velocity = Vector3.Zero;
+ }
+
if (!alreadyPersisted)
{
sceneObject.ForceInventoryPersistence();
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 983431d..0179240 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -215,6 +215,7 @@ namespace OpenSim.Region.Physics.OdePlugin
parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
}
+
_position = pos;
m_taintposition = pos;
PID_D = parent_scene.bodyPIDD;
@@ -254,7 +255,8 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene = parent_scene;
m_targetSpace = (IntPtr)0;
- if (pos.Z < 0)
+// if (pos.Z < 0)
+ if (pos.Z < parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y))
m_isphysical = false;
else
{
--
cgit v1.1
From b19e5643171d9a081426026c0e96c84c3e7f97b2 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 25 Dec 2009 23:20:30 +0000
Subject: Restore version suffix.
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 7274a06..4844a66 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.6.92Ch";
+ private const string VERSION_NUMBER = "0.6.92CM";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
{
--
cgit v1.1
From 59f683066a60a99111cc032ee122dfe709c78440 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 25 Dec 2009 23:23:49 +0000
Subject: Set version back to core version (base) and suffix CM. Please DO NOT
CHANGE THIS in the repo. This is the Caremninster repo and the number follows
CORE. Always.
---
OpenSim/Framework/Servers/VersionInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 4844a66..f618047 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.6.92CM";
+ private const string VERSION_NUMBER = "0.6.8CM";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour
{
--
cgit v1.1
From 43c303e27a93f07022ed0b151ca6945e34169ee9 Mon Sep 17 00:00:00 2001
From: root
Date: Sat, 26 Dec 2009 03:24:46 +0100
Subject: Make the GenericTableHandler work as intended
---
OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 9b8a001..4dfc324 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Data.MySQL
{
- public class MySQLGenericTableHandler : MySqlFramework where T: struct
+ public class MySQLGenericTableHandler : MySqlFramework where T: class, new()
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -63,7 +63,7 @@ namespace OpenSim.Data.MySQL
}
Type t = typeof(T);
- FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
+ FieldInfo[] fields = t.GetFields(BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);
@@ -165,7 +165,11 @@ namespace OpenSim.Data.MySQL
new Dictionary();
foreach (string col in m_ColumnNames)
+ {
data[col] = reader[col].ToString();
+ if (data[col] == null)
+ data[col] = String.Empty;
+ }
m_DataField.SetValue(row, data);
}
@@ -218,6 +222,8 @@ namespace OpenSim.Data.MySQL
query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values ('" + String.Join("','", values.ToArray()) + "')";
+ cmd.CommandText = query;
+
if (ExecuteNonQuery(cmd) > 0)
return true;
--
cgit v1.1
From 7371c7662a05d2c1dae1c110905817bb873cf934 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Sat, 26 Dec 2009 18:14:12 +0100
Subject: Fix for landing points. Only one scenario is not fully covered by
this change, and that is people who teleport from neighbouring regions, who
won't get affected by the landing point.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 2 +
.../Framework/Scenes/SceneCommunicationService.cs | 47 +++++++++++++++++-----
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 25 ++++++++++--
3 files changed, 59 insertions(+), 15 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 265129c..37734f4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3460,6 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// Honor parcel landing type and position.
+ /*
ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
if (land != null)
{
@@ -3468,6 +3469,7 @@ namespace OpenSim.Region.Framework.Scenes
agent.startpos = land.LandData.UserLocation;
}
}
+ */// This is now handled properly in ScenePresence.MakeRootAgent
}
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index e649139..0a02d39 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -706,17 +706,42 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.DebugFormat(
"[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
- position, m_regionInfo.RegionName);
-
- // Teleport within the same region
- if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
- {
- Vector3 emergencyPos = new Vector3(128, 128, 128);
-
- m_log.WarnFormat(
- "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
- position, avatar.Name, avatar.UUID, emergencyPos);
- position = emergencyPos;
+ position, m_regionInfo.RegionName);
+
+ // Teleport within the same region
+ if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
+ {
+ Vector3 emergencyPos = new Vector3(128, 128, 128);
+
+ m_log.WarnFormat(
+ "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
+ position, avatar.Name, avatar.UUID, emergencyPos);
+ position = emergencyPos;
+ }
+
+ Vector3 currentPos = avatar.AbsolutePosition;
+ ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y);
+ ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y);
+ if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0)
+ {
+ if (srcLand.LandData.LocalID == destLand.LandData.LocalID)
+ {
+ //TPing within the same parcel. If the landing point is restricted, block the TP.
+ //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
+ if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
+ {
+ avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false);
+ position = currentPos;
+ }
+ }
+ else
+ {
+ //Tping to a different parcel. Respect the landing point on the destination parcel.
+ if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
+ {
+ position = destLand.LandData.UserLocation;
+ }
+ }
}
// TODO: Get proper AVG Height
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a3ad7ca..c3bc96a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -836,9 +836,24 @@ namespace OpenSim.Region.Framework.Scenes
{
Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
pos.Y = crossedBorder.BorderLine.Z - 1;
+ }
+
+ //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet.
+ //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent,
+ //they'll bypass the landing point. But I can't think of any decent way of fixing this.
+ if (KnownChildRegionHandles.Count == 0)
+ {
+ ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
+ if (land != null)
+ {
+ //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
+ if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid)
+ {
+ pos = land.LandData.UserLocation;
+ }
+ }
}
-
if (pos.X < 0 || pos.Y < 0 || pos.Z < 0)
{
Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
@@ -973,9 +988,10 @@ namespace OpenSim.Region.Framework.Scenes
public void Teleport(Vector3 pos)
{
bool isFlying = false;
- if (m_physicsActor != null)
- isFlying = m_physicsActor.Flying;
+ if (m_physicsActor != null)
+ isFlying = m_physicsActor.Flying;
+
RemoveFromPhysicalScene();
Velocity = Vector3.Zero;
AbsolutePosition = pos;
@@ -986,7 +1002,8 @@ namespace OpenSim.Region.Framework.Scenes
SetHeight(m_appearance.AvatarHeight);
}
- SendTerseUpdateToAllClients();
+ SendTerseUpdateToAllClients();
+
}
public void TeleportWithMomentum(Vector3 pos)
--
cgit v1.1
From a6c93ce875c9e563de791002b309a3285266d597 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Sat, 26 Dec 2009 22:55:18 +0100
Subject: Make sure that we're not bounds checking attachments. 'Cos otherwise
your hair will end up on your bum. Seen that before?
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 998d598..34a92fe 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -226,9 +226,9 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X,
sceneObject.RootPart.GroupPosition.Y,
sceneObject.RootPart.GroupPosition.Z);
- if (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 ||
+ if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 ||
npos.X > Constants.RegionSize ||
- npos.Y > Constants.RegionSize)
+ npos.Y > Constants.RegionSize))
{
if (npos.X < 0.0) npos.X = 1.0f;
if (npos.Y < 0.0) npos.Y = 1.0f;
--
cgit v1.1
From a18f4964cf43095a12dd6c91f606a7f28b0af4df Mon Sep 17 00:00:00 2001
From: root
Date: Sun, 27 Dec 2009 01:32:23 +0100
Subject: Correct some issues with the last commit
---
OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 58b95d7..b2bd5f6 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -205,7 +205,8 @@ namespace OpenSim.Data.MySQL
foreach (FieldInfo fi in m_Fields.Values)
{
names.Add(fi.Name);
- values.Add(fi.GetValue(row).ToString());
+ values.Add("?" + fi.Name);
+ cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString());
}
if (m_DataField != null)
--
cgit v1.1
From 19a5e606b38372e882c13e27d6459ee703e07570 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Sun, 27 Dec 2009 07:08:16 +0100
Subject: Convert some remaining legacy lock()s for m_parts in SceneObjectGroup
to ReaderWriteLockSlim, hopefully fixes a native crash
---
.../Framework/Scenes/SceneObjectGroup.Inventory.cs | 24 ++++++++++++----------
1 file changed, 13 insertions(+), 11 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 5a06bdb..65ce13a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -46,12 +46,12 @@ namespace OpenSim.Region.Framework.Scenes
///
public void ForceInventoryPersistence()
{
- lock (m_parts)
+ lockPartsForRead(true);
+ List values = new List(m_parts.Values);
+ lockPartsForRead(false);
+ foreach (SceneObjectPart part in values)
{
- foreach (SceneObjectPart part in m_parts.Values)
- {
- part.Inventory.ForceInventoryPersistence();
- }
+ part.Inventory.ForceInventoryPersistence();
}
}
@@ -75,14 +75,16 @@ namespace OpenSim.Region.Framework.Scenes
/// Stop the scripts contained in all the prims in this group
///
public void RemoveScriptInstances()
- {
- lock (m_parts)
+ {
+ lockPartsForRead(true);
+ List values = new List(m_parts.Values);
+ lockPartsForRead(false);
+
+ foreach (SceneObjectPart part in values)
{
- foreach (SceneObjectPart part in m_parts.Values)
- {
- part.Inventory.RemoveScriptInstances();
- }
+ part.Inventory.RemoveScriptInstances();
}
+
}
///
--
cgit v1.1
From d321d23afe62e0e00f774901be3e1d1d0eda8c15 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 27 Dec 2009 16:01:36 +0000
Subject: Fix the spelling :/
---
OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index aeb97eb..8a5f209 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4840,9 +4840,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UserProfile.FirstLifeImage = Properties.FLImageID;
UserProfile.Image = Properties.ImageID;
UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
- Userprofile.Flags &= ~3;
- Userprofile.Flags |= Properties.AllowPublish ? 1 : 0;
- Userprofile.Flags |= Properties.MaturePublish ? 2 : 0;
+ UserProfile.Flags &= ~3;
+ UserProfile.Flags |= Properties.AllowPublish ? 1 : 0;
+ UserProfile.Flags |= Properties.MaturePublish ? 2 : 0;
handlerUpdateAvatarProperties(this, UserProfile);
}
--
cgit v1.1
From 045a44b1afb8a72da922eaea7b4d0ca1833bc9dd Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 27 Dec 2009 16:07:13 +0000
Subject: One should not copy/paste so much :)
---
OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 8a5f209..ba81d05 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4840,9 +4840,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UserProfile.FirstLifeImage = Properties.FLImageID;
UserProfile.Image = Properties.ImageID;
UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
- UserProfile.Flags &= ~3;
- UserProfile.Flags |= Properties.AllowPublish ? 1 : 0;
- UserProfile.Flags |= Properties.MaturePublish ? 2 : 0;
+ UserProfile.UserFlags &= ~3;
+ UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
+ UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
handlerUpdateAvatarProperties(this, UserProfile);
}
--
cgit v1.1
From 8ad8bd6282210c8ce0c00704edb3c55654ad2fc2 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 27 Dec 2009 17:52:27 +0100
Subject: Fix up the new Sirikata cient view
---
OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs
index e8d1889..4700bf2 100644
--- a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs
+++ b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs
@@ -449,7 +449,7 @@ namespace OpenSim.Client.Sirikata.ClientStack
throw new System.NotImplementedException();
}
- public void SendGenericMessage(string method, List message)
+ public void SendGenericMessage(string method, List message)
{
throw new System.NotImplementedException();
}
--
cgit v1.1
From 06f639b8f345e075259d8b2ebfa96b9ed2174766 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 30 Dec 2009 00:27:01 +0100
Subject: Fix a timer list locking issue causing XMREngine deadlocks
---
.../Shared/Api/Implementation/Plugins/Timer.cs | 32 ++++++++++++----------
1 file changed, 17 insertions(+), 15 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index eeb59d9..2fd33fe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
if (Timers.Count == 0)
return;
+ Dictionary.ValueCollection tvals;
lock (TimerListLock)
{
// Go through all timers
- Dictionary.ValueCollection tvals = Timers.Values;
- foreach (TimerClass ts in tvals)
+ tvals = Timers.Values;
+ }
+
+ foreach (TimerClass ts in tvals)
+ {
+ // Time has passed?
+ if (ts.next < DateTime.Now.Ticks)
{
- // Time has passed?
- if (ts.next < DateTime.Now.Ticks)
- {
- //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
- // Add it to queue
- m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
- new EventParams("timer", new Object[0],
- new DetectParams[0]));
- // set next interval
-
- //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
- ts.next = DateTime.Now.Ticks + ts.interval;
- }
+ //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
+ // Add it to queue
+ m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
+ new EventParams("timer", new Object[0],
+ new DetectParams[0]));
+ // set next interval
+
+ //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
+ ts.next = DateTime.Now.Ticks + ts.interval;
}
}
}
--
cgit v1.1
From 8f0d6d6b5c2a66681cc80f33d10b0635a1257b25 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 30 Dec 2009 00:36:16 +0000
Subject: Fix an omission in LSL that causes a viewer crash
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c9d6742..3a229c2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6363,6 +6363,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSLError("First parameter to llDialog needs to be a key");
return;
}
+ if (buttons.Length < 1)
+ {
+ LSLError("No less than 1 button can be shown");
+ return;
+ }
if (buttons.Length > 12)
{
LSLError("No more than 12 buttons can be shown");
--
cgit v1.1
From cbe0841bc96d9ec834b06a0a012a50323698f719 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 30 Dec 2009 20:13:18 +0000
Subject: Revert "Merge branch 'master' into careminster"
This reverts commit 596af3f600462fb1e467714e5b898c10aa3d838b.
---
.../Scenes/Animation/ScenePresenceAnimator.cs | 8 ---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 57 ++-------------
.../RegionCombinerModule/RegionCombinerModule.cs | 82 ----------------------
3 files changed, 4 insertions(+), 143 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 8f62855..e98f0e7 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -161,18 +161,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix);
// Check control flags
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS);
bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS);
bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG);
-=======
- bool heldForward =
- (((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) || ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS));
- bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
- bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
- bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
->>>>>>> master:OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
//bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
//bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT;
bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index f05fe59..c3bc96a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -173,12 +173,8 @@ namespace OpenSim.Region.Framework.Scenes
protected RegionInfo m_regionInfo;
protected ulong crossingFromRegion;
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
private readonly Vector3[] Dir_Vectors = new Vector3[11];
private bool m_isNudging = false;
-=======
- private readonly Vector3[] Dir_Vectors = new Vector3[9];
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
// Position of agent's camera in world (region cordinates)
protected Vector3 m_CameraCenter;
@@ -247,13 +243,9 @@ namespace OpenSim.Region.Framework.Scenes
DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS,
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS,
DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG,
-=======
- DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
}
@@ -735,43 +727,27 @@ namespace OpenSim.Region.Framework.Scenes
Dir_Vectors[3] = -Vector3.UnitY; //RIGHT
Dir_Vectors[4] = Vector3.UnitZ; //UP
Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE
Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE
Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE
Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE
Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
-=======
- Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
- Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD
- Dir_Vectors[7] = -Vector3.UnitX; //BACK
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
}
private Vector3[] GetWalkDirectionVectors()
{
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
Vector3[] vector = new Vector3[11];
-=======
- Vector3[] vector = new Vector3[9];
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD
vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK
vector[2] = Vector3.UnitY; //LEFT
vector[3] = -Vector3.UnitY; //RIGHT
vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE
vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE
vector[8] = Vector3.UnitY; //LEFT_NUDGE
vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE
-=======
- vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
- vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z) * 2); //FORWARD Nudge
- vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK Nudge
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
return vector;
}
@@ -1387,18 +1363,12 @@ namespace OpenSim.Region.Framework.Scenes
else
dirVectors = Dir_Vectors;
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
bool[] isNudge = GetDirectionIsNudge();
-=======
- // The fact that m_movementflag is a byte needs to be fixed
- // it really should be a uint
- uint nudgehack = 250;
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
{
if (((uint)flags & (uint)DCF) != 0)
@@ -1408,47 +1378,28 @@ namespace OpenSim.Region.Framework.Scenes
try
{
agent_control_v3 += dirVectors[i];
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
if (isNudge[i] == false)
{
Nudging = false;
}
-=======
- //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]);
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
}
catch (IndexOutOfRangeException)
{
// Why did I get this?
}
- if ((m_movementflag & (byte)(uint)DCF) == 0)
+ if ((m_movementflag & (uint)DCF) == 0)
{
- if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
- {
- m_movementflag |= (byte)nudgehack;
- }
m_movementflag += (byte)(uint)DCF;
update_movementflag = true;
}
}
else
{
- if ((m_movementflag & (byte)(uint)DCF) != 0 ||
- ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
- && ((m_movementflag & (byte)nudgehack) == nudgehack))
- ) // This or is for Nudge forward
+ if ((m_movementflag & (uint)DCF) != 0)
{
- m_movementflag -= ((byte)(uint)DCF);
-
+ m_movementflag -= (byte)(uint)DCF;
update_movementflag = true;
- /*
- if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
- && ((m_movementflag & (byte)nudgehack) == nudgehack))
- {
- m_log.Debug("Removed Hack flag");
- }
- */
}
else
{
@@ -1589,7 +1540,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0))
+ if (update_movementflag)
Animator.UpdateMovementAnimations();
m_scene.EventManager.TriggerOnClientMovement(this);
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
index 1a99c83..92f060b 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
@@ -88,89 +88,7 @@ namespace OpenSim.Region.RegionCombinerModule
public void RegionLoaded(Scene scene)
{
if (enabledYN)
- {
RegionLoadedDoWork(scene);
-
- scene.EventManager.OnNewPresence += NewPresence;
- }
- }
-
- private void NewPresence(ScenePresence presence)
- {
- if (presence.IsChildAgent)
- {
- byte[] throttleData;
-
- try
- {
- throttleData = presence.ControllingClient.GetThrottlesPacked(1);
- }
- catch (NotImplementedException)
- {
- return;
- }
-
- if (throttleData == null)
- return;
-
- if (throttleData.Length == 0)
- return;
-
- if (throttleData.Length != 28)
- return;
-
- byte[] adjData;
- int pos = 0;
-
- if (!BitConverter.IsLittleEndian)
- {
- byte[] newData = new byte[7 * 4];
- Buffer.BlockCopy(throttleData, 0, newData, 0, 7 * 4);
-
- for (int i = 0; i < 7; i++)
- Array.Reverse(newData, i * 4, 4);
-
- adjData = newData;
- }
- else
- {
- adjData = throttleData;
- }
-
- // 0.125f converts from bits to bytes
- int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
- int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
- int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
- int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
- int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
- int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
- int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
- // State is a subcategory of task that we allocate a percentage to
-
-
- //int total = resend + land + wind + cloud + task + texture + asset;
-
- byte[] data = new byte[7 * 4];
- int ii = 0;
-
- Buffer.BlockCopy(Utils.FloatToBytes(resend), 0, data, ii, 4); ii += 4;
- Buffer.BlockCopy(Utils.FloatToBytes(land * 50), 0, data, ii, 4); ii += 4;
- Buffer.BlockCopy(Utils.FloatToBytes(wind), 0, data, ii, 4); ii += 4;
- Buffer.BlockCopy(Utils.FloatToBytes(cloud), 0, data, ii, 4); ii += 4;
- Buffer.BlockCopy(Utils.FloatToBytes(task), 0, data, ii, 4); ii += 4;
- Buffer.BlockCopy(Utils.FloatToBytes(texture), 0, data, ii, 4); ii += 4;
- Buffer.BlockCopy(Utils.FloatToBytes(asset), 0, data, ii, 4);
-
- try
- {
- presence.ControllingClient.SetChildAgentThrottle(data);
- }
- catch (NotImplementedException)
- {
- return;
- }
-
- }
}
private void RegionLoadedDoWork(Scene scene)
--
cgit v1.1
From 5e103f2b2eb51c35b435f6850fc088f1f905d9dd Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 30 Dec 2009 20:26:22 +0000
Subject: Revert "Merge branch 'master' into careminster"
This reverts commit d49d44923d1be38f6fff12706b156562c6060566.
---
.../Scenes/Animation/ScenePresenceAnimator.cs | 5 +----
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 ------------------
2 files changed, 1 insertion(+), 22 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 6c64484..e98f0e7 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -151,10 +151,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
const float PREJUMP_DELAY = 0.25f;
#region Inputs
- if (m_scenePresence.SitGround)
- {
- return "SIT_GROUND_CONSTRAINED";
- }
+
AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags;
PhysicsActor actor = m_scenePresence.PhysicsActor;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ee76cb6..c3bc96a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -129,7 +129,6 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3? m_forceToApply;
private uint m_requestedSitTargetID;
private UUID m_requestedSitTargetUUID;
- public bool SitGround = false;
private SendCourseLocationsMethod m_sendCourseLocationsMethod;
@@ -1300,17 +1299,8 @@ namespace OpenSim.Region.Framework.Scenes
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
{
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.
Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
-=======
- // TODO: This doesn't prevent the user from walking yet.
- // Setting parent ID would fix this, if we knew what value
- // to use. Or we could add a m_isSitting variable.
- //Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
- SitGround = true;
-
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
}
// In the future, these values might need to go global.
@@ -1550,11 +1540,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
-<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/ScenePresence.cs
if (update_movementflag)
-=======
- if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround)
->>>>>>> master:OpenSim/Region/Framework/Scenes/ScenePresence.cs
Animator.UpdateMovementAnimations();
m_scene.EventManager.TriggerOnClientMovement(this);
@@ -1665,12 +1651,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public void StandUp()
{
- if (SitGround)
- SitGround = false;
-
if (m_parentID != 0)
{
- m_log.Debug("StandupCode Executed");
SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
if (part != null)
{
--
cgit v1.1
From 9602227eb6d26cf76d8c88ac86558218ca11e918 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 31 Dec 2009 06:19:22 +0100
Subject: Add a small delay in NewAgentConnection to fix an issue with Hippo
(and possibly other cleints) getting their data mixed up.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2091bf0..2e34d1c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3414,6 +3414,9 @@ namespace OpenSim.Region.Framework.Scenes
CapsModule.AddCapsHandler(agent.AgentID);
+ if ((teleportFlags & ((uint)TeleportFlags.ViaLandmark | (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.ViaLandmark | (uint)TeleportFlags.Default)) != 0)
+ System.Threading.Thread.Sleep(2000);
+
if (!agent.child)
{
if (TestBorderCross(agent.startpos,Cardinals.E))
--
cgit v1.1
From 3f901d313bfd11070d5260f867c8a73c14f2d109 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Thu, 31 Dec 2009 16:07:36 -0500
Subject: Vehicle Linear parameter adjustments
---
OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs | 40 ++++++++++++---
OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 12 +++--
OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 61 +++++++++++++----------
3 files changed, 75 insertions(+), 38 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
index 78b15be..ef2dccc 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
@@ -83,6 +83,12 @@ namespace OpenSim.Region.Physics.OdePlugin
// private IntPtr m_jointGroup = IntPtr.Zero;
// private IntPtr m_aMotor = IntPtr.Zero;
+ // Correction factors, to match Sl
+ private static float m_linearVelocityFactor = 0.9f;
+ private static float m_linearAttackFactor = 0.4f;
+ private static float m_linearDecayFactor = 0.5f;
+ private static float m_linearFrictionFactor = 1.2f;
+
// Vehicle properties
private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind
@@ -98,7 +104,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Linear properties
private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time
- private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL
+ private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL, for max limiting
private Vector3 m_dir = Vector3.Zero; // velocity applied to body
private Vector3 m_linearFrictionTimescale = Vector3.Zero;
private float m_linearMotorDecayTimescale = 0;
@@ -267,8 +273,9 @@ namespace OpenSim.Region.Physics.OdePlugin
m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
break;
case Vehicle.LINEAR_MOTOR_DIRECTION:
- m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
- m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z);
+ pValue *= m_linearVelocityFactor;
+ m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); // velocity requested by LSL, decayed by time
+ m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z); // velocity requested by LSL, for max limiting
break;
case Vehicle.LINEAR_MOTOR_OFFSET:
// m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
@@ -453,6 +460,17 @@ namespace OpenSim.Region.Physics.OdePlugin
MoveAngular(pTimestep);
}// end Step
+ internal void Halt()
+ { // Kill all motions, when non-physical
+ m_linearMotorDirection = Vector3.Zero;
+ m_linearMotorDirectionLASTSET = Vector3.Zero;
+ m_dir = Vector3.Zero;
+ m_lastLinearVelocityVector = Vector3.Zero;
+ m_angularMotorDirection = Vector3.Zero;
+ m_angularMotorVelocity = Vector3.Zero;
+ m_lastAngularVelocity = Vector3.Zero;
+ }
+
private void MoveLinear(float pTimestep, OdeScene _pParentScene)
{
if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant
@@ -460,9 +478,15 @@ namespace OpenSim.Region.Physics.OdePlugin
if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body);
// add drive to body
- Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
- m_lastLinearVelocityVector += (addAmount*10); // lastLinearVelocityVector is the current body velocity vector?
-
+ float linfactor = m_linearMotorTimescale/pTimestep;
+ // Linear accel
+ Vector3 addAmount1 = (m_linearMotorDirection/linfactor) * 0.8f;
+ // Differential accel
+ Vector3 addAmount2 = ((m_linearMotorDirection - m_lastLinearVelocityVector)/linfactor) * 1.6f;
+ // SL correction
+ Vector3 addAmount = (addAmount1 + addAmount2) * m_linearAttackFactor;
+ m_lastLinearVelocityVector += addAmount; // lastLinearVelocityVector is the current body velocity vector
+//if(frcount == 0) Console.WriteLine("AL {0} + AD {1} AS{2} V {3}", addAmount1, addAmount2, addAmount, m_lastLinearVelocityVector);
// This will work temporarily, but we really need to compare speed on an axis
// KF: Limit body velocity to applied velocity?
if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X))
@@ -475,7 +499,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// decay applied velocity
Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep)));
//Console.WriteLine("decay: " + decayfraction);
- m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f;
+ m_linearMotorDirection -= m_linearMotorDirection * decayfraction * m_linearDecayFactor;
//Console.WriteLine("actual: " + m_linearMotorDirection);
}
else
@@ -560,7 +584,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// apply friction
Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
- m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
+ m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount * m_linearFrictionFactor;
} // end MoveLinear()
private void MoveAngular(float pTimestep)
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 0179240..6e6b44f 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -2296,11 +2296,15 @@ Console.WriteLine(" JointCreateFixed");
public override bool IsPhysical
{
get { return m_isphysical; }
- set {
+ set
+ {
m_isphysical = value;
- if (!m_isphysical) // Zero the remembered last velocity
- m_lastVelocity = Vector3.Zero;
- }
+ if (!m_isphysical)
+ { // Zero the remembered last velocity
+ m_lastVelocity = Vector3.Zero;
+ if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Halt();
+ }
+ }
}
public void setPrimForRemoval()
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
index f48649e..60786d4 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
@@ -229,7 +229,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public int bodyFramesAutoDisable = 20;
-
+ protected DateTime m_lastframe = DateTime.UtcNow;
private float[] _watermap;
private bool m_filterCollisions = true;
@@ -2639,13 +2639,20 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (framecount >= int.MaxValue)
framecount = 0;
-
//if (m_worldOffset != Vector3.Zero)
// return 0;
framecount++;
-
- float fps = 0;
+
+ DateTime now = DateTime.UtcNow;
+ TimeSpan SinceLastFrame = now - m_lastframe;
+ m_lastframe = now;
+ float realtime = (float)SinceLastFrame.TotalSeconds;
+// Console.WriteLine("ts={0} rt={1}", timeStep, realtime);
+ timeStep = realtime;
+
+ // float fps = 1.0f / realtime;
+ float fps = 0.0f; // number of ODE steps in this Simulate step
//m_log.Info(timeStep.ToString());
step_time += timeStep;
@@ -2691,11 +2698,11 @@ namespace OpenSim.Region.Physics.OdePlugin
// Figure out the Frames Per Second we're going at.
//(step_time == 0.004f, there's 250 of those per second. Times the step time/step size
- fps = (step_time / ODE_STEPSIZE) * 1000;
+ // fps = (step_time / ODE_STEPSIZE) * 1000;
// HACK: Using a time dilation of 1.0 to debug rubberbanding issues
//m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f);
- step_time = 0.09375f;
+ // step_time = 0.09375f;
while (step_time > 0.0f)
{
@@ -2716,7 +2723,7 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (OdeCharacter character in _taintedActors)
{
- character.ProcessTaints(timeStep);
+ character.ProcessTaints(ODE_STEPSIZE);
processedtaints = true;
//character.m_collisionscore = 0;
@@ -2725,7 +2732,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (processedtaints)
_taintedActors.Clear();
}
- }
+ } // end lock _taintedActors
// Modify other objects in the scene.
processedtaints = false;
@@ -2742,7 +2749,7 @@ namespace OpenSim.Region.Physics.OdePlugin
else
{
//Console.WriteLine("Simulate calls ProcessTaints");
- prim.ProcessTaints(timeStep);
+ prim.ProcessTaints(ODE_STEPSIZE);
}
processedtaints = true;
prim.m_collisionscore = 0;
@@ -2767,7 +2774,8 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (PhysicsJoint joint in pendingJoints)
{
//DoJointErrorMessage(joint, "taint: time to create joint with parms: " + joint.RawParams);
- string[] jointParams = joint.RawParams.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);
+ string[] jointParams = joint.RawParams.Split(" ".ToCharArray(),
+ System.StringSplitOptions.RemoveEmptyEntries);
List jointBodies = new List();
bool allJointBodiesAreReady = true;
foreach (string jointParam in jointParams)
@@ -2934,13 +2942,13 @@ namespace OpenSim.Region.Physics.OdePlugin
//DoJointErrorMessage(successfullyProcessedJoint, "done");
}
}
- }
+ } // end SupportsNINJAJoints
if (processedtaints)
//Console.WriteLine("Simulate calls Clear of _taintedPrim list");
- _taintedPrimH.Clear();
+ _taintedPrimH.Clear(); // ??? if this only ???
_taintedPrimL.Clear();
- }
+ } // end lock _taintedPrimLock
// Move characters
lock (_characters)
@@ -2949,7 +2957,7 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (OdeCharacter actor in _characters)
{
if (actor != null)
- actor.Move(timeStep, defects);
+ actor.Move(ODE_STEPSIZE, defects);
}
if (0 != defects.Count)
{
@@ -2958,7 +2966,7 @@ namespace OpenSim.Region.Physics.OdePlugin
RemoveCharacter(defect);
}
}
- }
+ } // end lock _characters
// Move other active objects
lock (_activeprims)
@@ -2966,9 +2974,9 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (OdePrim prim in _activeprims)
{
prim.m_collisionscore = 0;
- prim.Move(timeStep);
+ prim.Move(ODE_STEPSIZE);
}
- }
+ } // end lock _activeprims
//if ((framecount % m_randomizeWater) == 0)
// randomizeWater(waterlevel);
@@ -2976,7 +2984,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//int RayCastTimeMS = m_rayCastManager.ProcessQueuedRequests();
m_rayCastManager.ProcessQueuedRequests();
- collision_optimized(timeStep);
+ collision_optimized(ODE_STEPSIZE);
lock (_collisionEventPrim)
{
@@ -2998,7 +3006,7 @@ namespace OpenSim.Region.Physics.OdePlugin
break;
}
}
- }
+ } // end lock _collisionEventPrim
//if (m_global_contactcount > 5)
//{
@@ -3009,8 +3017,9 @@ namespace OpenSim.Region.Physics.OdePlugin
d.WorldQuickStep(world, ODE_STEPSIZE);
d.JointGroupEmpty(contactgroup);
+ fps++;
//ode.dunlock(world);
- }
+ } // end try
catch (Exception e)
{
m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e);
@@ -3025,7 +3034,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//fps = 0;
//}
//}
- }
+ } // end while (step_time > 0.0f)
lock (_characters)
{
@@ -3090,7 +3099,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
}
- }
+ } // end lock _activeprims
//DumpJointInfo();
@@ -3111,10 +3120,10 @@ namespace OpenSim.Region.Physics.OdePlugin
}
d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
}
- }
-
- return fps;
- }
+ } // end lock OdeLock
+
+ return fps * 1000.0f; //NB This is a FRAME COUNT, not a time! AND is divide by 1000 in SimStatusReporter!
+ } // end Simulate
public override void GetResults()
{
--
cgit v1.1
From 71fdc24f5c3d5805e185aac949e38f3c8058e03e Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sat, 2 Jan 2010 21:21:31 +0100
Subject: Add virtual method StateChange to ScriptBaseClass
---
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index a44abb0..b138da3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -128,6 +128,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_InitialValues = GetVars();
}
+ public virtual void StateChange(string newState)
+ {
+ }
+
public void Close()
{
// m_sponser.Close();
--
cgit v1.1
From 1121919b57e1495d0357d59e010a865b91757bfb Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 3 Jan 2010 22:02:36 +0000
Subject: Solve conflict
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 -------
1 file changed, 7 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index eda3d60..a14e3ad 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2910,13 +2910,6 @@ namespace OpenSim.Region.Framework.Scenes
SetText(text);
}
- public void StopLookAt()
- {
- m_parentGroup.stopLookAt();
-
- m_parentGroup.ScheduleGroupForTerseUpdate();
- }
-
public void StopMoveToTarget()
{
m_parentGroup.stopMoveToTarget();
--
cgit v1.1
From 53d3f46add698dd862c018e614778c1c19b0eda4 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 4 Jan 2010 18:47:47 +0000
Subject: First stage port of the XInventoryService
---
OpenSim/Data/IXInventoryData.cs | 82 ++++
OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 5 +
OpenSim/Data/MySQL/MySQLXInventoryData.cs | 113 +++++
.../Services/InventoryService/XInventoryService.cs | 474 +++++++++++++++++++++
4 files changed, 674 insertions(+)
create mode 100644 OpenSim/Data/IXInventoryData.cs
create mode 100644 OpenSim/Data/MySQL/MySQLXInventoryData.cs
create mode 100644 OpenSim/Services/InventoryService/XInventoryService.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs
new file mode 100644
index 0000000..88174d9
--- /dev/null
+++ b/OpenSim/Data/IXInventoryData.cs
@@ -0,0 +1,82 @@
+/*
+ * 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 OpenMetaverse;
+using OpenSim.Framework;
+
+namespace OpenSim.Data
+{
+ public class XInventoryFolder
+ {
+ public string folderName;
+ public int type;
+ public int version;
+ public UUID folderID;
+ public UUID agentID;
+ public UUID parentFolderID;
+ }
+
+ public class XInventoryItem
+ {
+ public UUID assetID;
+ public int assetType;
+ public string inventoryName;
+ public string inventoryDescription;
+ public int inventoryNextPermissions;
+ public int inventoryCurrentPermissions;
+ public int invType;
+ public UUID creatorID;
+ public int inventoryBasePermissions;
+ public int inventoryEveryOnePermissions;
+ public int salePrice;
+ public int saleType;
+ public int creationDate;
+ public UUID groupID;
+ public bool groupOwned;
+ public int flags;
+ public UUID inventoryID;
+ public UUID avatarID;
+ public UUID parentFolderID;
+ public int inventoryGroupPermissions;
+ }
+
+ public interface IXInventoryData
+ {
+ XInventoryFolder[] GetFolders(string[] fields, string[] vals);
+ XInventoryItem[] GetItems(string[] fields, string[] vals);
+
+ bool StoreFolder(XInventoryFolder folder);
+ bool StoreItem(XInventoryItem item);
+
+ bool DeleteFolders(string field, string val);
+ bool DeleteItems(string field, string val);
+
+ bool MoveItem(string principalID, string id, string newParent);
+ }
+}
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index b2bd5f6..fdb98eb 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -153,6 +153,11 @@ namespace OpenSim.Data.MySQL
UUID.TryParse(reader[name].ToString(), out uuid);
m_Fields[name].SetValue(row, uuid);
}
+ else if (m_Fields[name].GetValue(row) is int)
+ {
+ int v = Convert.ToInt32(reader[name]);
+ m_Fields[name].SetValue(row, v);
+ }
else
{
m_Fields[name].SetValue(row, reader[name]);
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
new file mode 100644
index 0000000..dd3e6ea
--- /dev/null
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -0,0 +1,113 @@
+/*
+ * 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.Data;
+using System.Reflection;
+using System.Collections.Generic;
+using log4net;
+using MySql.Data.MySqlClient;
+using OpenMetaverse;
+using OpenSim.Framework;
+
+namespace OpenSim.Data.MySQL
+{
+ ///
+ /// A MySQL Interface for the Asset Server
+ ///
+ public class MySQLXInventoryData : IXInventoryData
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private MySQLGenericTableHandler m_Folders;
+ private MySqlItemHandler m_Items;
+
+ public MySQLXInventoryData(string conn, string realm)
+ {
+ m_Folders = new MySQLGenericTableHandler(
+ conn, "inventoryfolders", "InventoryStore");
+ m_Items = new MySqlItemHandler(
+ conn, "inventoryitems", String.Empty);
+ }
+
+ public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
+ {
+ return m_Folders.Get(fields, vals);
+ }
+
+ public XInventoryItem[] GetItems(string[] fields, string[] vals)
+ {
+ return m_Items.Get(fields, vals);
+ }
+
+ public bool StoreFolder(XInventoryFolder folder)
+ {
+ return m_Folders.Store(folder);
+ }
+
+ public bool StoreItem(XInventoryItem item)
+ {
+ return m_Items.Store(item);
+ }
+
+ public bool DeleteFolders(string field, string val)
+ {
+ return m_Folders.Delete(field, val);
+ }
+
+ public bool DeleteItems(string field, string val)
+ {
+ return m_Items.Delete(field, val);
+ }
+
+ public bool MoveItem(string principalID, string id, string newParent)
+ {
+ return m_Items.MoveItem(principalID, id, newParent);
+ }
+ }
+
+ public class MySqlItemHandler : MySQLGenericTableHandler
+ {
+ public MySqlItemHandler(string c, string t, string m) :
+ base(c, t, m)
+ {
+ }
+
+ public bool MoveItem(string principalID, string id, string newParent)
+ {
+ MySqlCommand cmd = new MySqlCommand();
+
+ cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where agentID = ?AgentID and folderID = ?FolderID");
+ cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
+ cmd.Parameters.AddWithValue("?FolderID", id);
+ cmd.Parameters.AddWithValue("?AgentID", principalID);
+
+ return ExecuteNonQuery(cmd) == 0 ? false : true;
+ }
+ }
+}
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
new file mode 100644
index 0000000..1e7f206
--- /dev/null
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -0,0 +1,474 @@
+/*
+ * 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 OpenMetaverse;
+using log4net;
+using Nini.Config;
+using System.Reflection;
+using OpenSim.Services.Base;
+using OpenSim.Services.Interfaces;
+using OpenSim.Data;
+using OpenSim.Framework;
+
+namespace OpenSim.Services.InventoryService
+{
+ public class XInventoryService : ServiceBase, IInventoryService
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ protected IXInventoryData m_Database;
+
+ public XInventoryService(IConfigSource config) : base(config)
+ {
+ string dllName = String.Empty;
+ string connString = String.Empty;
+ //string realm = "Inventory"; // OSG version doesn't use this
+
+ //
+ // Try reading the [InventoryService] section first, if it exists
+ //
+ IConfig authConfig = config.Configs["InventoryService"];
+ if (authConfig != null)
+ {
+ dllName = authConfig.GetString("StorageProvider", dllName);
+ connString = authConfig.GetString("ConnectionString", connString);
+ // realm = authConfig.GetString("Realm", realm);
+ }
+
+ //
+ // Try reading the [DatabaseService] section, if it exists
+ //
+ IConfig dbConfig = config.Configs["DatabaseService"];
+ if (dbConfig != null)
+ {
+ if (dllName == String.Empty)
+ dllName = dbConfig.GetString("StorageProvider", String.Empty);
+ if (connString == String.Empty)
+ connString = dbConfig.GetString("ConnectionString", String.Empty);
+ }
+
+ //
+ // We tried, but this doesn't exist. We can't proceed.
+ //
+ if (dllName == String.Empty)
+ throw new Exception("No StorageProvider configured");
+
+ 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");
+ }
+
+ public bool CreateUserInventory(UUID principalID)
+ {
+ // This is braindeaad. We can't ever communicate that we fixed
+ // an existing inventory. Well, just return root folder status,
+ // but check sanity anyway.
+ //
+ bool result = false;
+
+ InventoryFolderBase rootFolder = GetRootFolder(principalID);
+
+ if (rootFolder == null)
+ {
+ rootFolder = ConvertToOpenSim(CreateFolder(principalID, UUID.Zero, (int)AssetType.Folder, "My Inventory"));
+ result = true;
+ }
+
+ XInventoryFolder[] sysFolders = GetSystemFolders(principalID);
+
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Animation, "Animations");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Bodypart, "Body Parts");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Clothing, "Clothing");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Gesture, "Gestures");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Landmark, "Landmarks");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.LostAndFoundFolder, "Lost And Found");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Notecard, "Notecards");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Object, "Objects");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.SnapshotFolder, "Photo Album");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.LSLText, "Scripts");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Sound, "Sounds");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.Texture, "Textures");
+ if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; }))
+ CreateFolder(principalID, rootFolder.ID, (int)AssetType.TrashFolder, "Trash");
+
+ return result;
+ }
+
+ private XInventoryFolder CreateFolder(UUID principalID, UUID parentID, int type, string name)
+ {
+ XInventoryFolder newFolder = new XInventoryFolder();
+
+ newFolder.folderName = name;
+ newFolder.type = type;
+ newFolder.version = 1;
+ newFolder.folderID = UUID.Random();
+ newFolder.agentID = principalID;
+ newFolder.parentFolderID = parentID;
+
+ m_Database.StoreFolder(newFolder);
+
+ return newFolder;
+ }
+
+ private XInventoryFolder[] GetSystemFolders(UUID principalID)
+ {
+ XInventoryFolder[] allFolders = m_Database.GetFolders(
+ new string[] { "agentID" },
+ new string[] { principalID.ToString() });
+
+ XInventoryFolder[] sysFolders = Array.FindAll(
+ allFolders,
+ delegate (XInventoryFolder f)
+ {
+ if (f.type > 0)
+ return true;
+ return false;
+ });
+
+ return sysFolders;
+ }
+
+ public List GetInventorySkeleton(UUID principalID)
+ {
+ XInventoryFolder[] allFolders = m_Database.GetFolders(
+ new string[] { "agentID" },
+ new string[] { principalID.ToString() });
+
+ if (allFolders.Length == 0)
+ return null;
+
+ List folders = new List();
+
+ foreach (XInventoryFolder x in allFolders)
+ folders.Add(ConvertToOpenSim(x));
+
+ return folders;
+ }
+
+ public InventoryFolderBase GetRootFolder(UUID principalID)
+ {
+ XInventoryFolder[] folders = m_Database.GetFolders(
+ new string[] { "agentID", "parentFolderID"},
+ new string[] { principalID.ToString(), UUID.Zero.ToString() });
+
+ if (folders.Length == 0)
+ return null;
+
+ return ConvertToOpenSim(folders[0]);
+ }
+
+ public InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
+ {
+ XInventoryFolder[] folders = m_Database.GetFolders(
+ new string[] { "agentID", "type"},
+ new string[] { principalID.ToString(), ((int)type).ToString() });
+
+ if (folders.Length == 0)
+ return null;
+
+ return ConvertToOpenSim(folders[0]);
+ }
+
+ public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
+ {
+ InventoryCollection inventory = new InventoryCollection();
+ inventory.UserID = principalID;
+ inventory.Folders = new List();
+ inventory.Items = new List();
+
+ XInventoryFolder[] folders = m_Database.GetFolders(
+ new string[] { "agentID", "parentFolderID"},
+ new string[] { principalID.ToString(), UUID.Zero.ToString() });
+
+ foreach (XInventoryFolder x in folders)
+ inventory.Folders.Add(ConvertToOpenSim(x));
+
+ XInventoryItem[] items = m_Database.GetItems(
+ new string[] { "avatarID", "parentFolderID"},
+ new string[] { principalID.ToString(), UUID.Zero.ToString() });
+
+ foreach (XInventoryItem i in items)
+ inventory.Items.Add(ConvertToOpenSim(i));
+
+ return inventory;
+ }
+
+ public List GetFolderItems(UUID principalID, UUID folderID)
+ {
+ List invItems = new List();
+
+ XInventoryItem[] items = m_Database.GetItems(
+ new string[] { "avatarID", "parentFolderID"},
+ new string[] { principalID.ToString(), UUID.Zero.ToString() });
+
+ foreach (XInventoryItem i in items)
+ invItems.Add(ConvertToOpenSim(i));
+
+ return invItems;
+ }
+
+ public bool AddFolder(InventoryFolderBase folder)
+ {
+ XInventoryFolder xFolder = ConvertFromOpenSim(folder);
+ return m_Database.StoreFolder(xFolder);
+ }
+
+ public bool UpdateFolder(InventoryFolderBase folder)
+ {
+ return AddFolder(folder);
+ }
+
+ public bool MoveFolder(InventoryFolderBase folder)
+ {
+ XInventoryFolder[] x = m_Database.GetFolders(
+ new string[] { "folderID" },
+ new string[] { folder.ID.ToString() });
+
+ if (x.Length == 0)
+ return false;
+
+ x[0].parentFolderID = folder.ParentID;
+
+ return m_Database.StoreFolder(x[0]);
+ }
+
+ // We don't check the principal's ID here
+ //
+ public bool DeleteFolders(UUID principalID, List folderIDs)
+ {
+ foreach (UUID id in folderIDs)
+ {
+ InventoryFolderBase f = new InventoryFolderBase();
+ f.ID = id;
+ PurgeFolder(f);
+ m_Database.DeleteFolders("folderID", id.ToString());
+ }
+
+ return true;
+ }
+
+ public bool PurgeFolder(InventoryFolderBase folder)
+ {
+ XInventoryFolder[] subFolders = m_Database.GetFolders(
+ new string[] { "parentFolderID" },
+ new string[] { folder.ID.ToString() });
+
+ foreach (XInventoryFolder x in subFolders)
+ PurgeFolder(ConvertToOpenSim(x));
+
+ m_Database.DeleteItems("parentFolderID", folder.ID.ToString());
+
+ return true;
+ }
+
+ public bool AddItem(InventoryItemBase item)
+ {
+ return m_Database.StoreItem(ConvertFromOpenSim(item));
+ }
+
+ public bool UpdateItem(InventoryItemBase item)
+ {
+ return m_Database.StoreItem(ConvertFromOpenSim(item));
+ }
+
+ public bool MoveItems(UUID principalID, List items)
+ {
+ foreach (InventoryItemBase i in items)
+ {
+ m_Database.MoveItem(principalID.ToString(), i.ID.ToString(),
+ i.Folder.ToString());
+ }
+
+ return true;
+ }
+
+ public bool DeleteItems(UUID principalID, List itemIDs)
+ {
+ foreach (UUID id in itemIDs)
+ m_Database.DeleteItems("inventoryID", id.ToString());
+
+ return true;
+ }
+
+ public InventoryItemBase GetItem(InventoryItemBase item)
+ {
+ XInventoryItem[] items = m_Database.GetItems(
+ new string[] { "inventoryID" },
+ new string[] { item.ID.ToString() });
+
+ if (items.Length == 0)
+ return null;
+
+ return ConvertToOpenSim(items[0]);
+ }
+
+ public InventoryFolderBase GetFolder(InventoryFolderBase folder)
+ {
+ XInventoryFolder[] folders = m_Database.GetFolders(
+ new string[] { "folderID"},
+ new string[] { folder.ID.ToString() });
+
+ if (folders.Length == 0)
+ return null;
+
+ return ConvertToOpenSim(folders[0]);
+ }
+
+ public List GetActiveGestures(UUID userId)
+ {
+ return null;
+ }
+
+ public int GetAssetPermissions(UUID userID, UUID assetID)
+ {
+ return 0;
+ }
+
+ // CM never needed those. Left unimplemented.
+ // Obsolete in core
+ //
+ public InventoryCollection GetUserInventory(UUID userID)
+ {
+ return null;
+ }
+ public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
+ {
+ }
+
+ // Unused.
+ //
+ public bool HasInventoryForUser(UUID userID)
+ {
+ return false;
+ }
+
+ // CM Helpers
+ //
+ private InventoryFolderBase ConvertToOpenSim(XInventoryFolder folder)
+ {
+ InventoryFolderBase newFolder = new InventoryFolderBase();
+
+ newFolder.ParentID = folder.parentFolderID;
+ newFolder.Type = (short)folder.type;
+ newFolder.Version = (ushort)folder.version;
+ newFolder.Name = folder.folderName;
+ newFolder.Owner = folder.agentID;
+ newFolder.ID = folder.folderID;
+
+ return newFolder;
+ }
+
+ private XInventoryFolder ConvertFromOpenSim(InventoryFolderBase folder)
+ {
+ XInventoryFolder newFolder = new XInventoryFolder();
+
+ newFolder.parentFolderID = folder.ParentID;
+ newFolder.type = (int)folder.Type;
+ newFolder.version = (int)folder.Version;
+ newFolder.folderName = folder.Name;
+ newFolder.agentID = folder.Owner;
+ newFolder.folderID = folder.ID;
+
+ return newFolder;
+ }
+
+ private InventoryItemBase ConvertToOpenSim(XInventoryItem item)
+ {
+ InventoryItemBase newItem = new InventoryItemBase();
+
+ newItem.AssetID = item.assetID;
+ newItem.AssetType = item.assetType;
+ newItem.Name = item.inventoryName;
+ newItem.Owner = item.avatarID;
+ newItem.ID = item.inventoryID;
+ newItem.InvType = item.invType;
+ newItem.Folder = item.parentFolderID;
+ newItem.CreatorId = item.creatorID.ToString();
+ newItem.Description = item.inventoryDescription;
+ newItem.NextPermissions = (uint)item.inventoryNextPermissions;
+ newItem.CurrentPermissions = (uint)item.inventoryCurrentPermissions;
+ newItem.BasePermissions = (uint)item.inventoryBasePermissions;
+ newItem.EveryOnePermissions = (uint)item.inventoryEveryOnePermissions;
+ newItem.GroupPermissions = (uint)item.inventoryGroupPermissions;
+ newItem.GroupID = item.groupID;
+ newItem.GroupOwned = item.groupOwned;
+ newItem.SalePrice = item.salePrice;
+ newItem.SaleType = (byte)item.saleType;
+ newItem.Flags = (uint)item.flags;
+ newItem.CreationDate = item.creationDate;
+
+ return newItem;
+ }
+
+ private XInventoryItem ConvertFromOpenSim(InventoryItemBase item)
+ {
+ XInventoryItem newItem = new XInventoryItem();
+
+ newItem.assetID = item.AssetID;
+ newItem.assetType = item.AssetType;
+ newItem.inventoryName = item.Name;
+ newItem.avatarID = item.Owner;
+ newItem.inventoryID = item.ID;
+ newItem.invType = item.InvType;
+ newItem.parentFolderID = item.Folder;
+ newItem.creatorID = item.CreatorIdAsUuid;
+ newItem.inventoryDescription = item.Description;
+ newItem.inventoryNextPermissions = (int)item.NextPermissions;
+ newItem.inventoryCurrentPermissions = (int)item.CurrentPermissions;
+ newItem.inventoryBasePermissions = (int)item.BasePermissions;
+ newItem.inventoryEveryOnePermissions = (int)item.EveryOnePermissions;
+ newItem.inventoryGroupPermissions = (int)item.GroupPermissions;
+ newItem.groupID = item.GroupID;
+ newItem.groupOwned = item.GroupOwned;
+ newItem.salePrice = item.SalePrice;
+ newItem.saleType = (int)item.SaleType;
+ newItem.flags = (int)item.Flags;
+ newItem.creationDate = item.CreationDate;
+
+ return newItem;
+ }
+ }
+}
--
cgit v1.1
From 0907d5d69e10ba5be79a6d03366ce3cfa59c0bec Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 4 Jan 2010 20:52:44 +0000
Subject: Finish conversion if XInventoryService
---
OpenSim/Data/IXInventoryData.cs | 4 +-
OpenSim/Data/MySQL/MySQLXInventoryData.cs | 55 +++++++++++++++++---
.../Services/InventoryService/XInventoryService.cs | 58 +++++++++++++++++-----
3 files changed, 98 insertions(+), 19 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs
index 88174d9..cd9273e 100644
--- a/OpenSim/Data/IXInventoryData.cs
+++ b/OpenSim/Data/IXInventoryData.cs
@@ -77,6 +77,8 @@ namespace OpenSim.Data
bool DeleteFolders(string field, string val);
bool DeleteItems(string field, string val);
- bool MoveItem(string principalID, string id, string newParent);
+ bool MoveItem(string id, string newParent);
+ XInventoryItem[] GetActiveGestures(UUID principalID);
+ int GetAssetPermissions(UUID principalID, UUID assetID);
}
}
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index dd3e6ea..0eebc9c 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -85,9 +85,19 @@ namespace OpenSim.Data.MySQL
return m_Items.Delete(field, val);
}
- public bool MoveItem(string principalID, string id, string newParent)
+ public bool MoveItem(string id, string newParent)
{
- return m_Items.MoveItem(principalID, id, newParent);
+ return m_Items.MoveItem(id, newParent);
+ }
+
+ public XInventoryItem[] GetActiveGestures(UUID principalID)
+ {
+ return m_Items.GetActiveGestures(principalID);
+ }
+
+ public int GetAssetPermissions(UUID principalID, UUID assetID)
+ {
+ return m_Items.GetAssetPermissions(principalID, assetID);
}
}
@@ -98,16 +108,49 @@ namespace OpenSim.Data.MySQL
{
}
- public bool MoveItem(string principalID, string id, string newParent)
+ public bool MoveItem(string id, string newParent)
{
MySqlCommand cmd = new MySqlCommand();
- cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where agentID = ?AgentID and folderID = ?FolderID");
+ cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
- cmd.Parameters.AddWithValue("?FolderID", id);
- cmd.Parameters.AddWithValue("?AgentID", principalID);
+ cmd.Parameters.AddWithValue("?InventoryID", id);
return ExecuteNonQuery(cmd) == 0 ? false : true;
}
+
+ public XInventoryItem[] GetActiveGestures(UUID principalID)
+ {
+ MySqlCommand cmd = new MySqlCommand();
+ cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm);
+
+ cmd.Parameters.AddWithValue("?uuid", principalID.ToString());
+ cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
+
+ return DoQuery(cmd);
+ }
+
+ public int GetAssetPermissions(UUID principalID, UUID assetID)
+ {
+ MySqlCommand cmd = new MySqlCommand();
+
+ cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
+ cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
+ cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
+
+ IDataReader reader = ExecuteReader(cmd);
+
+ int perms = 0;
+
+ if (reader.Read())
+ {
+ perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
+ }
+
+ reader.Close();
+ CloseReaderCommand(cmd);
+
+ return perms;
+ }
}
}
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index 1e7f206..2c79c77 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -183,7 +183,10 @@ namespace OpenSim.Services.InventoryService
List folders = new List();
foreach (XInventoryFolder x in allFolders)
+ {
+ m_log.DebugFormat("[INVENTORY]: Adding folder {0} to skeleton", x.folderName);
folders.Add(ConvertToOpenSim(x));
+ }
return folders;
}
@@ -214,35 +217,48 @@ namespace OpenSim.Services.InventoryService
public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
{
+ // This method doesn't receive a valud principal id from the
+ // connector. So we disregard the principal and look
+ // by ID.
+ //
+ m_log.DebugFormat("[INVENTORY]: Fetch contents for folder {0}", folderID.ToString());
InventoryCollection inventory = new InventoryCollection();
inventory.UserID = principalID;
inventory.Folders = new List();
inventory.Items = new List();
XInventoryFolder[] folders = m_Database.GetFolders(
- new string[] { "agentID", "parentFolderID"},
- new string[] { principalID.ToString(), UUID.Zero.ToString() });
+ new string[] { "parentFolderID"},
+ new string[] { folderID.ToString() });
foreach (XInventoryFolder x in folders)
+ {
+ m_log.DebugFormat("[INVENTORY]: Adding folder {0} to response", x.folderName);
inventory.Folders.Add(ConvertToOpenSim(x));
+ }
XInventoryItem[] items = m_Database.GetItems(
- new string[] { "avatarID", "parentFolderID"},
- new string[] { principalID.ToString(), UUID.Zero.ToString() });
+ new string[] { "parentFolderID"},
+ new string[] { folderID.ToString() });
foreach (XInventoryItem i in items)
+ {
+ m_log.DebugFormat("[INVENTORY]: Adding item {0} to response", i.inventoryName);
inventory.Items.Add(ConvertToOpenSim(i));
+ }
return inventory;
}
public List GetFolderItems(UUID principalID, UUID folderID)
{
+ // Since we probably don't get a valid principal here, either ...
+ //
List invItems = new List();
XInventoryItem[] items = m_Database.GetItems(
- new string[] { "avatarID", "parentFolderID"},
- new string[] { principalID.ToString(), UUID.Zero.ToString() });
+ new string[] { "parentFolderID"},
+ new string[] { UUID.Zero.ToString() });
foreach (XInventoryItem i in items)
invItems.Add(ConvertToOpenSim(i));
@@ -279,6 +295,8 @@ namespace OpenSim.Services.InventoryService
//
public bool DeleteFolders(UUID principalID, List folderIDs)
{
+ // Ignore principal ID, it's bogus at connector level
+ //
foreach (UUID id in folderIDs)
{
InventoryFolderBase f = new InventoryFolderBase();
@@ -297,7 +315,10 @@ namespace OpenSim.Services.InventoryService
new string[] { folder.ID.ToString() });
foreach (XInventoryFolder x in subFolders)
+ {
PurgeFolder(ConvertToOpenSim(x));
+ m_Database.DeleteFolders("folderID", x.folderID.ToString());
+ }
m_Database.DeleteItems("parentFolderID", folder.ID.ToString());
@@ -316,10 +337,11 @@ namespace OpenSim.Services.InventoryService
public bool MoveItems(UUID principalID, List items)
{
+ // Principal is b0rked. *sigh*
+ //
foreach (InventoryItemBase i in items)
{
- m_Database.MoveItem(principalID.ToString(), i.ID.ToString(),
- i.Folder.ToString());
+ m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString());
}
return true;
@@ -327,6 +349,8 @@ namespace OpenSim.Services.InventoryService
public bool DeleteItems(UUID principalID, List itemIDs)
{
+ // Just use the ID... *facepalms*
+ //
foreach (UUID id in itemIDs)
m_Database.DeleteItems("inventoryID", id.ToString());
@@ -357,14 +381,24 @@ namespace OpenSim.Services.InventoryService
return ConvertToOpenSim(folders[0]);
}
- public List GetActiveGestures(UUID userId)
+ public List GetActiveGestures(UUID principalID)
{
- return null;
+ XInventoryItem[] items = m_Database.GetActiveGestures(principalID);
+
+ if (items.Length == 0)
+ return null;
+
+ List ret = new List();
+
+ foreach (XInventoryItem x in items)
+ ret.Add(ConvertToOpenSim(x));
+
+ return ret;
}
- public int GetAssetPermissions(UUID userID, UUID assetID)
+ public int GetAssetPermissions(UUID principalID, UUID assetID)
{
- return 0;
+ return m_Database.GetAssetPermissions(principalID, assetID);
}
// CM never needed those. Left unimplemented.
--
cgit v1.1
From 3724a38ab4694c75288cbf4ba848bd9894b5231d Mon Sep 17 00:00:00 2001
From: Melanie
Date: Tue, 5 Jan 2010 15:39:53 +0000
Subject: Allow estate managers (if estate_owner_is_god is set) to actually
enter god mode. Allow god modification of objects if the object owner is the
same god that wants to modify, this allows you to regain perms on your own
objects after IAR import messed them up.
---
OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index e837e9a..f66f01f 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -596,7 +596,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return objectOwnerMask;
// Estate users should be able to edit anything in the sim
- if (IsEstateManager(user) && m_RegionOwnerIsGod && !IsAdministrator(objectOwner))
+ if (IsEstateManager(user) && m_RegionOwnerIsGod && (!IsAdministrator(objectOwner)) || objectOwner == user)
return objectOwnerMask;
// Admin should be able to edit anything in the sim (including admin objects)
@@ -888,6 +888,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
+ if (IsEstateManager(user) && m_RegionOwnerIsGod)
+ return true;
+
return IsAdministrator(user);
}
--
cgit v1.1
From 71adb37fa87f0ad8fa42c8156529bf72814fde58 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Thu, 7 Jan 2010 23:58:19 -0500
Subject: Fix llRotBetween
---
.../Shared/Api/Implementation/LSL_Api.cs | 56 +++++++++++++++++++++-
1 file changed, 54 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 76c79da..1469e7e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -722,6 +722,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
//A and B should both be normalized
m_host.AddScriptLPS(1);
+ /* This method is more accurate than the SL one, and thus causes problems
+ for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
+
double dotProduct = LSL_Vector.Dot(a, b);
LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
@@ -738,8 +741,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
- }
-
+ */
+
+ // This method mimics the 180 errors found in SL
+ // See www.euclideanspace.com... angleBetween
+ LSL_Vector vec_a = a;
+ LSL_Vector vec_b = b;
+
+ // Eliminate zero length
+ LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
+ LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
+ if (vec_a_mag < 0.00001 ||
+ vec_b_mag < 0.00001)
+ {
+ return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
+ }
+
+ // Normalize
+ vec_a = llVecNorm(vec_a);
+ vec_b = llVecNorm(vec_b);
+
+ // Calculate axis and rotation angle
+ LSL_Vector axis = vec_a % vec_b;
+ LSL_Float cos_theta = vec_a * vec_b;
+
+ // Check if parallel
+ if (cos_theta > 0.99999)
+ {
+ return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
+ }
+
+ // Check if anti-parallel
+ else if (cos_theta < -0.99999)
+ {
+ LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
+ if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
+ return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
+ }
+ else // other rotation
+ {
+ LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
+ axis = llVecNorm(axis);
+ double x, y, z, s, t;
+ s = Math.Cos(theta);
+ t = Math.Sin(theta);
+ x = axis.x * t;
+ y = axis.y * t;
+ z = axis.z * t;
+ return new LSL_Rotation(x,y,z,s);
+ }
+ }
+
public void llWhisper(int channelID, string text)
{
m_host.AddScriptLPS(1);
--
cgit v1.1
From a2aadb78a919323d62a5b4a44c0899b63641788b Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Fri, 8 Jan 2010 23:12:11 -0500
Subject: Maintain control() event stream
---
OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index afd5f86..0eed284 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4792,6 +4792,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
(x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
(x.CameraUpAxis != lastarg.CameraUpAxis) ||
(x.ControlFlags != lastarg.ControlFlags) ||
+ (x.ControlFlags != 0) ||
(x.Far != lastarg.Far) ||
(x.Flags != lastarg.Flags) ||
(x.State != lastarg.State) ||
--
cgit v1.1
From a87d7a12967b50fe83ebbaa7b57e531eb93158a2 Mon Sep 17 00:00:00 2001
From: Careminster Staff
Date: Wed, 13 Jan 2010 22:45:17 -0600
Subject: Adds Land Banning.
---
.../CoreModules/World/Land/LandManagementModule.cs | 130 +++++++++++++--------
.../Region/CoreModules/World/Land/LandObject.cs | 48 ++++++--
2 files changed, 120 insertions(+), 58 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 9b39b09..d9b36a5 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -264,20 +264,57 @@ namespace OpenSim.Region.CoreModules.World.Land
return parcelsNear;
}
- public void SendYouAreBannedNotice(ScenePresence avatar)
+ public void KickUserOffOfParcel(ScenePresence avatar)
{
- if (AllowedForcefulBans)
+ if (avatar.GodLevel == 0)
{
- avatar.ControllingClient.SendAlertMessage(
- "You are not allowed on this parcel because you are banned. Please go away.");
-
- avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition;
- avatar.PhysicsActor.Velocity = Vector3.Zero;
+ List parcelsNear = ParcelsNearPoint(avatar.AbsolutePosition);
+ foreach (ILandObject check in parcelsNear)
+ {
+ if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
+ {
+ Vector3 target = check.LandData.UserLocation;
+ avatar.TeleportWithMomentum(target);
+ return;
+ }
+ }
}
- else
+ }
+ public void MoveUserOutOfParcel(ScenePresence avatar)
+ {
+ if (avatar.GodLevel == 0)
{
- avatar.ControllingClient.SendAlertMessage(
- "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim!");
+ ILandObject land = m_scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
+ List parcelsNear = new List();
+
+ for (int x = -2; x <= 2; x += 2)
+ {
+ ILandObject check = GetLandObject(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y);
+ if (check != null)
+ {
+ if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
+ {
+ Vector3 target = new Vector3(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
+ avatar.TeleportWithMomentum(target);
+ avatar.Velocity = new Vector3(-avatar.Velocity.X - 5, avatar.Velocity.Y, avatar.Velocity.Z);
+ return;
+ }
+ }
+ }
+ for (int y = -2; y <= 2; y += 2)
+ {
+ ILandObject check = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y);
+ if (check != null)
+ {
+ if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
+ {
+ Vector3 target = new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y, avatar.AbsolutePosition.Z);
+ avatar.TeleportWithMomentum(target);
+ avatar.Velocity = new Vector3(avatar.Velocity.X, -avatar.Velocity.Y - 5, avatar.Velocity.Z);
+ return;
+ }
+ }
+ }
}
}
@@ -297,16 +334,7 @@ namespace OpenSim.Region.CoreModules.World.Land
{
if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
{
- SendYouAreBannedNotice(avatar);
- }
- else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
- {
- avatar.ControllingClient.SendAlertMessage(
- "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!).");
- }
- else
- {
- avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
+ MoveUserOutOfParcel(avatar);
}
}
else
@@ -317,28 +345,47 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
- public void SendOutNearestBanLine(IClientAPI avatar)
+ public void SendOutNearestBanLine(ScenePresence avatar)
{
- List avatars = m_scene.GetAvatars();
- foreach (ScenePresence presence in avatars)
+ ILandObject checkBan = null;
+ for (int x = -2; x <= 2; x += 2)
{
- if (presence.UUID == avatar.AgentId)
+ checkBan = GetLandObject(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y);
+ if (checkBan != null)
{
- List checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition);
- foreach (ILandObject checkBan in checkLandParcels)
+ if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
{
- if (checkBan.IsBannedFromLand(avatar.AgentId))
+ if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
{
- checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar);
- return; //Only send one
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ return;
}
- if (checkBan.IsRestrictedFromLand(avatar.AgentId))
+ if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
{
- checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar);
- return; //Only send one
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ return;
+ }
+ }
+ }
+ }
+ for (int y = -2; y <= 2; y += 2)
+ {
+ checkBan = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y);
+ if (checkBan != null)
+ {
+ if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
+ {
+ if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
+ {
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ return;
+ }
+ if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
+ {
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ return;
}
}
- return;
}
}
}
@@ -385,25 +432,14 @@ namespace OpenSim.Region.CoreModules.World.Land
if (clientAvatar != null)
{
SendLandUpdate(clientAvatar);
- SendOutNearestBanLine(remote_client);
+ SendOutNearestBanLine(clientAvatar);
ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
if (parcel != null)
{
if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
- clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
- {
- EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
- m_scene.RegionInfo.RegionID);
- //They are going under the safety line!
- if (!parcel.IsBannedFromLand(clientAvatar.UUID))
- {
- clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
- }
- }
- else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
parcel.IsBannedFromLand(clientAvatar.UUID))
{
- SendYouAreBannedNotice(clientAvatar);
+ MoveUserOutOfParcel(clientAvatar);
}
}
}
@@ -451,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Land
if (land != null)
{
- if (agentID == land.LandData.OwnerID)
+ if (m_scene.Permissions.CanEditParcel(agentID, land))
{
land.UpdateAccessList(flags, entries, remote_client);
}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 1fa8630..1c65965 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -267,11 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Land
public bool IsEitherBannedOrRestricted(UUID avatar)
{
- if (IsBannedFromLand(avatar))
- {
- return true;
- }
- else if (IsRestrictedFromLand(avatar))
+ if (IsRestrictedFromLand(avatar) || IsBannedFromLand(avatar))
{
return true;
}
@@ -280,7 +276,8 @@ namespace OpenSim.Region.CoreModules.World.Land
public bool IsBannedFromLand(UUID avatar)
{
- if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0)
+ ScenePresence SP = m_scene.GetScenePresence(avatar);
+ if ((LandData.Flags & (uint)ParcelFlags.UseBanList) > 0)
{
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
entry.AgentID = avatar;
@@ -288,8 +285,22 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.Time = new DateTime();
if (LandData.ParcelAccessList.Contains(entry))
{
- //They are banned, so lets send them a notice about this parcel
- return true;
+ if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) > 0)
+ {
+ if (LandData.GroupID == SP.ControllingClient.ActiveGroupId)
+ {
+ return false;
+ }
+ else
+ {
+ //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
+ return true;
+ }
+ }
+ else
+ {
+ return true;
+ }
}
}
return false;
@@ -297,7 +308,8 @@ namespace OpenSim.Region.CoreModules.World.Land
public bool IsRestrictedFromLand(UUID avatar)
{
- if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0)
+ ScenePresence SP = m_scene.GetScenePresence(avatar);
+ if ((LandData.Flags & (uint)ParcelFlags.UseAccessList) > 0)
{
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
entry.AgentID = avatar;
@@ -305,8 +317,22 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.Time = new DateTime();
if (!LandData.ParcelAccessList.Contains(entry))
{
- //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
- return true;
+ if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) > 0)
+ {
+ if (LandData.GroupID == SP.ControllingClient.ActiveGroupId)
+ {
+ return false;
+ }
+ else
+ {
+ //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
+ return true;
+ }
+ }
+ else
+ {
+ return true;
+ }
}
}
return false;
--
cgit v1.1
From 884410501e50f0abb09ef1339ac74e22c2dfd39f Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 15 Jan 2010 20:19:06 +0000
Subject: Allow renaming of items that contain no-mod items
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 18ec25f..dd4c14b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1803,8 +1803,13 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- item.BasePermissions = objectGroup.GetEffectivePermissions();
- item.CurrentPermissions = objectGroup.GetEffectivePermissions();
+ uint ownerPerms = objectGroup.GetEffectivePermissions();
+ if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0)
+ ownerPerms |= (uint)PermissionMask.Modify;
+
+ item.BasePermissions = ownerPerms;
+ item.CurrentPermissions = ownerPerms;
+
item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
item.GroupPermissions = objectGroup.RootPart.GroupMask;
--
cgit v1.1
From 44d523518af31075c77653eacc7489220db4abaa Mon Sep 17 00:00:00 2001
From: Careminster Staff
Date: Sun, 17 Jan 2010 19:23:36 -0600
Subject: Adds land ejection and freezing. Adds more checks to land banning.
---
.../CoreModules/World/Land/LandManagementModule.cs | 442 +++++++++++++++++++--
1 file changed, 419 insertions(+), 23 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index d9b36a5..23da1ae 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -81,6 +81,8 @@ namespace OpenSim.Region.CoreModules.World.Land
private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
private bool m_allowedForcefulBans = true;
+ private string DefultGodParcelGroup;
+ private string DefultGodParcelName;
// caches ExtendedLandData
private Cache parcelInfoCache;
@@ -153,6 +155,10 @@ namespace OpenSim.Region.CoreModules.World.Land
client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
client.OnParcelDwellRequest += ClientOnParcelDwellRequest;
client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
+ client.OnParcelGodMark += ClientOnParcelGodMark;
+ client.OnSimWideDeletes += ClientOnSimWideDeletes;
+ client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
+ client.OnParcelEjectUser += ClientOnParcelEjectUser;
EntityBase presenceEntity;
if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -264,22 +270,7 @@ namespace OpenSim.Region.CoreModules.World.Land
return parcelsNear;
}
- public void KickUserOffOfParcel(ScenePresence avatar)
- {
- if (avatar.GodLevel == 0)
- {
- List parcelsNear = ParcelsNearPoint(avatar.AbsolutePosition);
- foreach (ILandObject check in parcelsNear)
- {
- if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
- {
- Vector3 target = check.LandData.UserLocation;
- avatar.TeleportWithMomentum(target);
- return;
- }
- }
- }
- }
+
public void MoveUserOutOfParcel(ScenePresence avatar)
{
if (avatar.GodLevel == 0)
@@ -296,7 +287,6 @@ namespace OpenSim.Region.CoreModules.World.Land
{
Vector3 target = new Vector3(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
avatar.TeleportWithMomentum(target);
- avatar.Velocity = new Vector3(-avatar.Velocity.X - 5, avatar.Velocity.Y, avatar.Velocity.Z);
return;
}
}
@@ -310,11 +300,73 @@ namespace OpenSim.Region.CoreModules.World.Land
{
Vector3 target = new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y, avatar.AbsolutePosition.Z);
avatar.TeleportWithMomentum(target);
- avatar.Velocity = new Vector3(avatar.Velocity.X, -avatar.Velocity.Y - 5, avatar.Velocity.Z);
return;
}
}
}
+ List allParcels = new List();
+ allParcels = AllParcels();
+ if (allParcels.Count != 1)
+ {
+ foreach (ILandObject parcel in allParcels)
+ {
+ if (parcel.IsEitherBannedOrRestricted(avatar.UUID) != true)
+ {
+ Vector3 temptarget = parcel.LandData.UserLocation;
+ if (parcel.ContainsPoint((int)parcel.LandData.UserLocation.X, (int)parcel.LandData.UserLocation.Y))
+ {
+ avatar.TeleportWithMomentum(temptarget);
+ return;
+ }
+ else
+ {
+ for (int x = 0; x <= Constants.RegionSize / 3; x += 3)
+ {
+ for (int y = 0; y <= Constants.RegionSize / 3; y += 3)
+ {
+ if (parcel.ContainsPoint(x, y))
+ {
+ temptarget = new Vector3(x, y, avatar.AbsolutePosition.Z);
+ avatar.TeleportWithMomentum(temptarget);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ //Move to region side
+ if (avatar.AbsolutePosition.X > avatar.AbsolutePosition.Y)
+ {
+ if (avatar.AbsolutePosition.X > .5 * Constants.RegionSize)
+ {
+ Vector3 target = new Vector3(Constants.RegionSize, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); ;
+ avatar.TeleportWithMomentum(target);
+ return;
+ }
+ else
+ {
+ Vector3 target = new Vector3(0, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); ;
+ avatar.TeleportWithMomentum(target);
+ return;
+ }
+ }
+ else
+ {
+ if (avatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
+ {
+ Vector3 target = new Vector3(avatar.AbsolutePosition.X, Constants.RegionSize, avatar.AbsolutePosition.Z); ;
+ avatar.TeleportWithMomentum(target);
+ return;
+ }
+ else
+ {
+ Vector3 target = new Vector3(avatar.AbsolutePosition.X, 0, avatar.AbsolutePosition.Z); ;
+ avatar.TeleportWithMomentum(target);
+ return;
+ }
+ }
}
}
@@ -357,12 +409,12 @@ namespace OpenSim.Region.CoreModules.World.Land
{
if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
{
- checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
return;
}
if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
{
- checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
return;
}
}
@@ -377,12 +429,12 @@ namespace OpenSim.Region.CoreModules.World.Land
{
if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
{
- checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
return;
}
if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
{
- checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar.ControllingClient);
+ checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
return;
}
}
@@ -490,6 +542,18 @@ namespace OpenSim.Region.CoreModules.World.Land
if (m_scene.Permissions.CanEditParcel(agentID, land))
{
land.UpdateAccessList(flags, entries, remote_client);
+ List presences = ((Scene)remote_client.Scene).GetAvatars();
+ foreach (ScenePresence presence in presences)
+ {
+ land = GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
+ if (land != null)
+ {
+ if (land.IsEitherBannedOrRestricted(presence.UUID))
+ {
+ MoveUserOutOfParcel(presence);
+ }
+ }
+ }
}
}
else
@@ -1055,7 +1119,25 @@ namespace OpenSim.Region.CoreModules.World.Land
m_landList.TryGetValue(localID, out land);
}
- if (land != null) land.UpdateLandProperties(args, remote_client);
+ if (land != null)
+ {
+ land.UpdateLandProperties(args, remote_client);
+ if ((args.ParcelFlags & (uint)(ParcelFlags.UseBanList | ParcelFlags.UseAccessList | ParcelFlags.UseAccessGroup | ParcelFlags.UsePassList)) != 0)
+ {
+ List presences = ((Scene)remote_client.Scene).GetAvatars();
+ foreach (ScenePresence presence in presences)
+ {
+ land = GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
+ if (land != null)
+ {
+ if (land.IsEitherBannedOrRestricted(presence.UUID))
+ {
+ MoveUserOutOfParcel(presence);
+ }
+ }
+ }
+ }
+ }
}
public void ClientOnParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
@@ -1473,5 +1555,319 @@ namespace OpenSim.Region.CoreModules.World.Land
UpdateLandObject(localID, land.LandData);
}
+ public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
+ {
+ ILandObject land = null;
+ List Land = ((Scene)client.Scene).LandChannel.AllParcels();
+ foreach (ILandObject landObject in Land)
+ {
+ if (landObject.LandData.LocalID == landID)
+ {
+ land = landObject;
+ }
+ }
+ land.DeedToGroup(new UUID(DefultGodParcelGroup));
+ land.LandData.Name = DefultGodParcelName;
+ land.SendLandUpdateToAvatarsOverMe();
+ }
+ private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
+ {
+ ScenePresence SP;
+ ((Scene)client.Scene).TryGetAvatar(client.AgentId, out SP);
+ List returns = new List();
+ if (SP.GodLevel != 0)
+ {
+ if (flags == 0) //All parcels, scripted or not
+ {
+ ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
+ {
+ if (e.OwnerID == targetID)
+ {
+ returns.Add(e);
+ }
+ }
+ );
+ }
+ if (flags == 4) //All parcels, scripted object
+ {
+ ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
+ {
+ if (e.OwnerID == targetID)
+ {
+ if (e.scriptScore >= 0.01)
+ {
+ returns.Add(e);
+ }
+ }
+ }
+ );
+ }
+ if (flags == 4) //not target parcel, scripted object
+ {
+ ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
+ {
+ if (e.OwnerID == targetID)
+ {
+ ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
+ if (landobject.LandData.OwnerID != e.OwnerID)
+ {
+ if (e.scriptScore >= 0.01)
+ {
+ returns.Add(e);
+ }
+ }
+ }
+ }
+ );
+ }
+ foreach (SceneObjectGroup ol in returns)
+ {
+ ReturnObject(ol, client);
+ }
+ }
+ }
+ public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
+ {
+ SceneObjectGroup[] objs = new SceneObjectGroup[1];
+ objs[0] = obj;
+ ((Scene)client.Scene).returnObjects(objs, client.AgentId);
+ }
+
+ Dictionary Timers = new Dictionary();
+
+ public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
+ {
+ ScenePresence targetAvatar = null;
+ ((Scene)client.Scene).TryGetAvatar(target, out targetAvatar);
+ ScenePresence parcelManager = null;
+ ((Scene)client.Scene).TryGetAvatar(client.AgentId, out parcelManager);
+ System.Threading.Timer Timer;
+
+ if (targetAvatar.GodLevel == 0)
+ {
+ ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
+ if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
+ return;
+ if (flags == 0)
+ {
+ targetAvatar.AllowMovement = false;
+ targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
+ System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
+ Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
+ Timers.Add(targetAvatar.UUID, Timer);
+ }
+ else
+ {
+ targetAvatar.AllowMovement = true;
+ targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
+ Timers.TryGetValue(targetAvatar.UUID, out Timer);
+ Timers.Remove(targetAvatar.UUID);
+ Timer.Dispose();
+ }
+ }
+ }
+ private void OnEndParcelFrozen(object avatar)
+ {
+ ScenePresence targetAvatar = (ScenePresence)avatar;
+ targetAvatar.AllowMovement = true;
+ System.Threading.Timer Timer;
+ Timers.TryGetValue(targetAvatar.UUID, out Timer);
+ Timers.Remove(targetAvatar.UUID);
+ targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
+ }
+
+
+ public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
+ {
+ ScenePresence targetAvatar = null;
+ ((Scene)client.Scene).TryGetAvatar(target, out targetAvatar);
+ ScenePresence parcelManager = null;
+ ((Scene)client.Scene).TryGetAvatar(client.AgentId, out parcelManager);
+ //Just eject
+ if (flags == 0)
+ {
+ if (targetAvatar.GodLevel == 0)
+ {
+ ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
+ if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
+ return;
+
+ Vector3 position = new Vector3(0, 0, 0);
+ List allParcels = new List();
+ allParcels = AllParcels();
+ if (allParcels.Count != 1)
+ {
+ foreach (ILandObject parcel in allParcels)
+ {
+ if (parcel.LandData.GlobalID != land.LandData.GlobalID)
+ {
+ if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
+ {
+ for (int x = 1; x <= Constants.RegionSize; x += 2)
+ {
+ for (int y = 1; y <= Constants.RegionSize; y += 2)
+ {
+ if (parcel.ContainsPoint(x, y))
+ {
+ position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
+ targetAvatar.TeleportWithMomentum(position);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Vector3 targetVector;
+ if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
+ {
+ if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
+ {
+ targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
+ return;
+ }
+ else
+ {
+ targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
+ return;
+ }
+ }
+ else
+ {
+ if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
+ {
+ targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
+ return;
+ }
+ else
+ {
+ targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
+ return;
+ }
+ }
+ }
+ }
+ //Eject and ban
+ if (flags == 1)
+ {
+ if (targetAvatar.GodLevel == 0)
+ {
+ ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
+ if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
+ return;
+
+ Vector3 position = new Vector3(0, 0, 0);
+ List allParcels = new List();
+ allParcels = AllParcels();
+ if (allParcels.Count != 1)
+ {
+ foreach (ILandObject parcel in allParcels)
+ {
+ if (parcel.LandData.GlobalID != land.LandData.GlobalID)
+ {
+ if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
+ {
+ for (int x = 1; x <= Constants.RegionSize; x += 2)
+ {
+ for (int y = 1; y <= Constants.RegionSize; y += 2)
+ {
+ if (parcel.ContainsPoint(x, y))
+ {
+ position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
+ targetAvatar.TeleportWithMomentum(position);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
+ ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
+ entry.AgentID = targetAvatar.UUID;
+ entry.Flags = AccessList.Ban;
+ entry.Time = new DateTime();
+ land.LandData.ParcelAccessList.Add(entry);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Vector3 targetVector;
+ if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
+ {
+ if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
+ {
+ targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
+ ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
+ entry.AgentID = targetAvatar.UUID;
+ entry.Flags = AccessList.Ban;
+ entry.Time = new DateTime();
+ land.LandData.ParcelAccessList.Add(entry);
+ return;
+ }
+ else
+ {
+ targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
+ ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
+ entry.AgentID = targetAvatar.UUID;
+ entry.Flags = AccessList.Ban;
+ entry.Time = new DateTime();
+ land.LandData.ParcelAccessList.Add(entry);
+ return;
+ }
+ }
+ else
+ {
+ if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
+ {
+ targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
+ ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
+ entry.AgentID = targetAvatar.UUID;
+ entry.Flags = AccessList.Ban;
+ entry.Time = new DateTime();
+ land.LandData.ParcelAccessList.Add(entry);
+ return;
+ }
+ else
+ {
+ targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
+ targetAvatar.TeleportWithMomentum(targetVector);
+ targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
+ parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
+ ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
+ entry.AgentID = targetAvatar.UUID;
+ entry.Flags = AccessList.Ban;
+ entry.Time = new DateTime();
+ land.LandData.ParcelAccessList.Add(entry);
+ return;
+ }
+ }
+ }
+ }
+ }
}
}
--
cgit v1.1
From f4e30664e6b327257db196512f0b6e304399214b Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 18 Jan 2010 01:55:45 +0000
Subject: Fix a typo
---
OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 23da1ae..6a0e8d1 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -81,8 +81,8 @@ namespace OpenSim.Region.CoreModules.World.Land
private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
private bool m_allowedForcefulBans = true;
- private string DefultGodParcelGroup;
- private string DefultGodParcelName;
+ private string DefaultGodParcelGroup;
+ private string DefaultGodParcelName;
// caches ExtendedLandData
private Cache parcelInfoCache;
@@ -1566,8 +1566,8 @@ namespace OpenSim.Region.CoreModules.World.Land
land = landObject;
}
}
- land.DeedToGroup(new UUID(DefultGodParcelGroup));
- land.LandData.Name = DefultGodParcelName;
+ land.DeedToGroup(new UUID(DefaultGodParcelGroup));
+ land.LandData.Name = DefaultGodParcelName;
land.SendLandUpdateToAvatarsOverMe();
}
private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
--
cgit v1.1
From 51bb31156502c391ac84aa207fce125a4299d755 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 18 Jan 2010 02:53:31 +0000
Subject: Add chat banning. Staff patch
---
.../Region/CoreModules/Avatar/Chat/ChatModule.cs | 51 +++++++++++++++++++++-
1 file changed, 49 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index e3e8718..acc3a78 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
private int m_shoutdistance = 100;
private int m_whisperdistance = 10;
private List m_scenes = new List();
+ private List FreezeCache = new List();
private string m_adminPrefix = "";
internal object m_syncy = new object();
@@ -172,7 +173,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
return;
}
- DeliverChatToAvatars(ChatSourceType.Agent, c);
+ if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
+ {
+ if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
+ c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
+ }
+ else
+ {
+ DeliverChatToAvatars(ChatSourceType.Agent, c);
+ }
}
public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -232,7 +241,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
s.ForEachScenePresence(
delegate(ScenePresence presence)
{
- TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType);
+ ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
+ if (Presencecheck != null)
+ {
+ if (Presencecheck.IsEitherBannedOrRestricted(c.SenderUUID) != true)
+ {
+ TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType);
+ }
+ }
+
}
);
}
@@ -322,5 +339,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully);
}
+
+ Dictionary Timers = new Dictionary();
+ public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
+ {
+ System.Threading.Timer Timer;
+ if (flags == 0)
+ {
+ FreezeCache.Add(target.ToString());
+ System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
+ Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
+ Timers.Add(target, Timer);
+ }
+ else
+ {
+ FreezeCache.Remove(target.ToString());
+ Timers.TryGetValue(target, out Timer);
+ Timers.Remove(target);
+ Timer.Dispose();
+ }
+ }
+
+ private void OnEndParcelFrozen(object avatar)
+ {
+ UUID target = (UUID)avatar;
+ FreezeCache.Remove(target.ToString());
+ System.Threading.Timer Timer;
+ Timers.TryGetValue(target, out Timer);
+ Timers.Remove(target);
+ Timer.Dispose();
+ }
}
}
--
cgit v1.1
From d9c48e70a9a01f56135ede2cef9ec45c7dddf567 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 18 Jan 2010 17:56:27 +0100
Subject: Fix a major security problem with osSetDynamicTexture which allowed
the deletion of /any/ asset.
---
.../Scripting/DynamicTexture/DynamicTextureModule.cs | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index f51d0c2..679c871 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -358,11 +358,18 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
// tmptex.DefaultTexture.Fullbright = true;
part.UpdateTexture(tmptex);
- }
-
- if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
- {
- scene.AssetService.Delete(oldID.ToString());
+ }
+
+ if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
+ {
+ if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString());
+ if (oldAsset != null)
+ {
+ if (oldAsset.Temporary == true)
+ {
+ scene.AssetService.Delete(oldID.ToString());
+ }
+ }
}
}
--
cgit v1.1
From 6772c9d2b6d05c985174f514aa8df2aacd33a201 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 18 Jan 2010 17:35:49 +0000
Subject: Comment the asset deletion handler. It can be abused and is not
currently needed.
---
OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
index 3f33da6..f33bb90 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
@@ -63,7 +63,7 @@ namespace OpenSim.Server.Handlers.Asset
if (p.Length > 0)
{
- result = m_AssetService.Delete(p[0]);
+ // result = m_AssetService.Delete(p[0]);
}
XmlSerializer xs = new XmlSerializer(typeof(bool));
--
cgit v1.1
From 24056dc98ba94b32ac98cc0a3b1b85d5f8ef3de6 Mon Sep 17 00:00:00 2001
From: Careminster Staff
Date: Mon, 18 Jan 2010 16:23:13 -0600
Subject: Adds example to OpenSim.ini.example for Admin Default Parcel settings
---
OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 6a0e8d1..28669b9 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Land
private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
private bool m_allowedForcefulBans = true;
- private string DefaultGodParcelGroup;
+ private UUID DefaultGodParcelGroup;
private string DefaultGodParcelName;
// caches ExtendedLandData
@@ -96,6 +96,12 @@ namespace OpenSim.Region.CoreModules.World.Land
public void Initialise(IConfigSource source)
{
+ IConfig cnf = source.Configs["LandManagement"];
+ if (cnf == null)
+ {
+ DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
+ DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
+ }
}
public void AddRegion(Scene scene)
@@ -1566,7 +1572,7 @@ namespace OpenSim.Region.CoreModules.World.Land
land = landObject;
}
}
- land.DeedToGroup(new UUID(DefaultGodParcelGroup));
+ land.DeedToGroup(DefaultGodParcelGroup);
land.LandData.Name = DefaultGodParcelName;
land.SendLandUpdateToAvatarsOverMe();
}
--
cgit v1.1
From 496a8a4f7ca5422daa30913595b6b1a03fa8a59a Mon Sep 17 00:00:00 2001
From: CasperW
Date: Wed, 20 Jan 2010 22:14:43 +0100
Subject: Fixed an issue with PayPrice sometimes being shared between multiple
objects
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +-
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 13 +++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a7c14cf..4c97467 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: This needs to be persisted in next XML version update!
[XmlIgnore]
- public readonly int[] PayPrice = {-2,-2,-2,-2,-2};
+ public int[] PayPrice = {-2,-2,-2,-2,-2};
[XmlIgnore]
public PhysicsActor PhysActor;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 085d61f..a5aecd8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -8946,12 +8946,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSLError("List must have at least 4 elements");
return;
}
- m_host.ParentGroup.RootPart.PayPrice[0]=price;
-
- m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0];
- m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1];
- m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2];
- m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3];
+ int[] nPrice = new int[5];
+ nPrice[0]=price;
+ nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0];
+ nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1];
+ nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2];
+ nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3];
+ m_host.ParentGroup.RootPart.PayPrice = nPrice;
m_host.ParentGroup.HasGroupChanged = true;
}
--
cgit v1.1
From 66692f90e3b70ccdec8c148342578cd54acc4406 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Thu, 21 Jan 2010 14:39:11 -0500
Subject: ChODE Object Linear Motion update
---
OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs | 187 ++++++++++++----------
OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 2 +-
2 files changed, 102 insertions(+), 87 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
index ef2dccc..9e145ec 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
@@ -82,13 +82,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private IntPtr m_body = IntPtr.Zero;
// private IntPtr m_jointGroup = IntPtr.Zero;
// private IntPtr m_aMotor = IntPtr.Zero;
-
- // Correction factors, to match Sl
- private static float m_linearVelocityFactor = 0.9f;
- private static float m_linearAttackFactor = 0.4f;
- private static float m_linearDecayFactor = 0.5f;
- private static float m_linearFrictionFactor = 1.2f;
-
// Vehicle properties
private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind
@@ -103,15 +96,15 @@ namespace OpenSim.Region.Physics.OdePlugin
// LIMIT_ROLL_ONLY
// Linear properties
- private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time
- private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL, for max limiting
- private Vector3 m_dir = Vector3.Zero; // velocity applied to body
- private Vector3 m_linearFrictionTimescale = Vector3.Zero;
- private float m_linearMotorDecayTimescale = 0;
- private float m_linearMotorTimescale = 0;
- private Vector3 m_lastLinearVelocityVector = Vector3.Zero;
- // private bool m_LinearMotorSetLastFrame = false;
- // private Vector3 m_linearMotorOffset = Vector3.Zero;
+ private Vector3 m_linearMotorDirection = Vector3.Zero; // (was m_linearMotorDirectionLASTSET) the (local) Velocity
+ //requested by LSL
+ private float m_linearMotorTimescale = 0; // Motor Attack rate set by LSL
+ private float m_linearMotorDecayTimescale = 0; // Motor Decay rate set by LSL
+ private Vector3 m_linearFrictionTimescale = Vector3.Zero; // General Friction set by LSL
+
+ private Vector3 m_lLinMotorDVel = Vector3.Zero; // decayed motor
+ private Vector3 m_lLinObjectVel = Vector3.Zero; // local frame object velocity
+ private Vector3 m_wLinObjectVel = Vector3.Zero; // world frame object velocity
//Angular properties
private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor
@@ -241,7 +234,7 @@ namespace OpenSim.Region.Physics.OdePlugin
break;
case Vehicle.LINEAR_MOTOR_DIRECTION:
m_linearMotorDirection = new Vector3(pValue, pValue, pValue);
- m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue);
+ UpdateLinDecay();
break;
case Vehicle.LINEAR_MOTOR_OFFSET:
// m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
@@ -273,9 +266,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
break;
case Vehicle.LINEAR_MOTOR_DIRECTION:
- pValue *= m_linearVelocityFactor;
- m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); // velocity requested by LSL, decayed by time
- m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z); // velocity requested by LSL, for max limiting
+ m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); // velocity requested by LSL, for max limiting
+ UpdateLinDecay();
break;
case Vehicle.LINEAR_MOTOR_OFFSET:
// m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
@@ -304,7 +296,7 @@ namespace OpenSim.Region.Physics.OdePlugin
case Vehicle.TYPE_SLED:
m_linearFrictionTimescale = new Vector3(30, 1, 1000);
m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
- m_linearMotorDirection = Vector3.Zero;
+// m_lLinMotorVel = Vector3.Zero;
m_linearMotorTimescale = 1000;
m_linearMotorDecayTimescale = 120;
m_angularMotorDirection = Vector3.Zero;
@@ -330,7 +322,7 @@ namespace OpenSim.Region.Physics.OdePlugin
case Vehicle.TYPE_CAR:
m_linearFrictionTimescale = new Vector3(100, 2, 1000);
m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
- m_linearMotorDirection = Vector3.Zero;
+// m_lLinMotorVel = Vector3.Zero;
m_linearMotorTimescale = 1;
m_linearMotorDecayTimescale = 60;
m_angularMotorDirection = Vector3.Zero;
@@ -357,7 +349,7 @@ namespace OpenSim.Region.Physics.OdePlugin
case Vehicle.TYPE_BOAT:
m_linearFrictionTimescale = new Vector3(10, 3, 2);
m_angularFrictionTimescale = new Vector3(10,10,10);
- m_linearMotorDirection = Vector3.Zero;
+// m_lLinMotorVel = Vector3.Zero;
m_linearMotorTimescale = 5;
m_linearMotorDecayTimescale = 60;
m_angularMotorDirection = Vector3.Zero;
@@ -385,7 +377,7 @@ namespace OpenSim.Region.Physics.OdePlugin
case Vehicle.TYPE_AIRPLANE:
m_linearFrictionTimescale = new Vector3(200, 10, 5);
m_angularFrictionTimescale = new Vector3(20, 20, 20);
- m_linearMotorDirection = Vector3.Zero;
+// m_lLinMotorVel = Vector3.Zero;
m_linearMotorTimescale = 2;
m_linearMotorDecayTimescale = 60;
m_angularMotorDirection = Vector3.Zero;
@@ -412,7 +404,6 @@ namespace OpenSim.Region.Physics.OdePlugin
case Vehicle.TYPE_BALLOON:
m_linearFrictionTimescale = new Vector3(5, 5, 5);
m_angularFrictionTimescale = new Vector3(10, 10, 10);
- m_linearMotorDirection = Vector3.Zero;
m_linearMotorTimescale = 5;
m_linearMotorDecayTimescale = 60;
m_angularMotorDirection = Vector3.Zero;
@@ -453,7 +444,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_body == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
return;
frcount++; // used to limit debug comment output
- if (frcount > 100)
+ if (frcount > 24)
frcount = 0;
MoveLinear(pTimestep, pParentScene);
@@ -463,63 +454,90 @@ namespace OpenSim.Region.Physics.OdePlugin
internal void Halt()
{ // Kill all motions, when non-physical
m_linearMotorDirection = Vector3.Zero;
- m_linearMotorDirectionLASTSET = Vector3.Zero;
- m_dir = Vector3.Zero;
- m_lastLinearVelocityVector = Vector3.Zero;
+ m_lLinMotorDVel = Vector3.Zero;
+ m_lLinObjectVel = Vector3.Zero;
+ m_wLinObjectVel = Vector3.Zero;
m_angularMotorDirection = Vector3.Zero;
m_angularMotorVelocity = Vector3.Zero;
m_lastAngularVelocity = Vector3.Zero;
}
+
+ private void UpdateLinDecay()
+ {
+ if (Math.Abs(m_linearMotorDirection.X) > Math.Abs(m_lLinMotorDVel.X)) m_lLinMotorDVel.X = m_linearMotorDirection.X;
+ if (Math.Abs(m_linearMotorDirection.Y) > Math.Abs(m_lLinMotorDVel.Y)) m_lLinMotorDVel.Y = m_linearMotorDirection.Y;
+ if (Math.Abs(m_linearMotorDirection.Z) > Math.Abs(m_lLinMotorDVel.Z)) m_lLinMotorDVel.Z = m_linearMotorDirection.Z;
+ } // else let the motor decay on its own
private void MoveLinear(float pTimestep, OdeScene _pParentScene)
{
- if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant
- {
- if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body);
+ Vector3 acceleration = new Vector3(0f, 0f, 0f);
- // add drive to body
- float linfactor = m_linearMotorTimescale/pTimestep;
- // Linear accel
- Vector3 addAmount1 = (m_linearMotorDirection/linfactor) * 0.8f;
- // Differential accel
- Vector3 addAmount2 = ((m_linearMotorDirection - m_lastLinearVelocityVector)/linfactor) * 1.6f;
- // SL correction
- Vector3 addAmount = (addAmount1 + addAmount2) * m_linearAttackFactor;
- m_lastLinearVelocityVector += addAmount; // lastLinearVelocityVector is the current body velocity vector
-//if(frcount == 0) Console.WriteLine("AL {0} + AD {1} AS{2} V {3}", addAmount1, addAmount2, addAmount, m_lastLinearVelocityVector);
- // This will work temporarily, but we really need to compare speed on an axis
- // KF: Limit body velocity to applied velocity?
- if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X))
- m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X;
- if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirectionLASTSET.Y))
- m_lastLinearVelocityVector.Y = m_linearMotorDirectionLASTSET.Y;
- if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z))
- m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z;
-
- // decay applied velocity
- Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep)));
- //Console.WriteLine("decay: " + decayfraction);
- m_linearMotorDirection -= m_linearMotorDirection * decayfraction * m_linearDecayFactor;
- //Console.WriteLine("actual: " + m_linearMotorDirection);
- }
- else
- { // requested is not significant
- // if what remains of applied is small, zero it.
- if (m_lastLinearVelocityVector.ApproxEquals(Vector3.Zero, 0.01f))
- m_lastLinearVelocityVector = Vector3.Zero;
- }
-
-
- // convert requested object velocity to world-referenced vector
- m_dir = m_lastLinearVelocityVector;
d.Quaternion rot = d.BodyGetQuaternion(Body);
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
- m_dir *= rotq; // apply obj rotation to velocity vector
+ Quaternion irotq = Quaternion.Inverse(rotq);
+ d.Vector3 velnow = d.BodyGetLinearVel(Body); // this is in world frame
+ Vector3 vel_now = new Vector3(velnow.X, velnow.Y, velnow.Z);
+ acceleration = vel_now - m_wLinObjectVel;
+ m_lLinObjectVel = vel_now * irotq;
+
+ if (m_linearMotorDecayTimescale < 300.0f) //setting of 300 or more disables decay rate
+ {
+ if ( Vector3.Mag(m_lLinMotorDVel) < 1.0f)
+ {
+ float decayfactor = m_linearMotorDecayTimescale/pTimestep;
+ Vector3 decayAmount = (m_lLinMotorDVel/decayfactor);
+ m_lLinMotorDVel -= decayAmount;
+ }
+ else
+ {
+ float decayfactor = 3.0f - (0.57f * (float)Math.Log((double)(m_linearMotorDecayTimescale)));
+ Vector3 decel = Vector3.Normalize(m_lLinMotorDVel) * decayfactor * pTimestep;
+ m_lLinMotorDVel -= decel;
+ }
+ if (m_lLinMotorDVel.ApproxEquals(Vector3.Zero, 0.01f))
+ {
+ m_lLinMotorDVel = Vector3.Zero;
+ }
+ else
+ {
+ if (Math.Abs(m_lLinMotorDVel.X) < Math.Abs(m_lLinObjectVel.X)) m_lLinObjectVel.X = m_lLinMotorDVel.X;
+ if (Math.Abs(m_lLinMotorDVel.Y) < Math.Abs(m_lLinObjectVel.Y)) m_lLinObjectVel.Y = m_lLinMotorDVel.Y;
+ if (Math.Abs(m_lLinMotorDVel.Z) < Math.Abs(m_lLinObjectVel.Z)) m_lLinObjectVel.Z = m_lLinMotorDVel.Z;
+ }
+ }
- // add Gravity and Buoyancy
- // KF: So far I have found no good method to combine a script-requested
- // .Z velocity and gravity. Therefore only 0g will used script-requested
- // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
+ if ( (! m_lLinMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) || (! m_lLinObjectVel.ApproxEquals(Vector3.Zero, 0.01f)) )
+ {
+ if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body);
+ if (m_linearMotorTimescale < 300.0f)
+ {
+ Vector3 attack_error = m_lLinMotorDVel - m_lLinObjectVel;
+ float linfactor = m_linearMotorTimescale/pTimestep;
+ Vector3 attackAmount = (attack_error/linfactor) * 1.3f;
+ m_lLinObjectVel += attackAmount;
+ }
+ if (m_linearFrictionTimescale.X < 300.0f)
+ {
+ float fricfactor = m_linearFrictionTimescale.X / pTimestep;
+ float fricX = m_lLinObjectVel.X / fricfactor;
+ m_lLinObjectVel.X -= fricX;
+ }
+ if (m_linearFrictionTimescale.Y < 300.0f)
+ {
+ float fricfactor = m_linearFrictionTimescale.Y / pTimestep;
+ float fricY = m_lLinObjectVel.Y / fricfactor;
+ m_lLinObjectVel.Y -= fricY;
+ }
+ if (m_linearFrictionTimescale.Z < 300.0f)
+ {
+ float fricfactor = m_linearFrictionTimescale.Z / pTimestep;
+ float fricZ = m_lLinObjectVel.Z / fricfactor;
+ m_lLinObjectVel.Z -= fricZ;
+ }
+ }
+ m_wLinObjectVel = m_lLinObjectVel * rotq;
+ // Add Gravity and Buoyancy
Vector3 grav = Vector3.Zero;
if(m_VehicleBuoyancy < 1.0f)
{
@@ -528,10 +546,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.Mass objMass;
d.BodyGetMass(Body, out objMass);
// m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
- grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy);
- // Preserve the current Z velocity
- d.Vector3 vel_now = d.BodyGetLinearVel(Body);
- m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
+ grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy); // Applied later as a force
} // else its 1.0, no gravity.
// Check if hovering
@@ -567,24 +582,24 @@ namespace OpenSim.Region.Physics.OdePlugin
{
d.Mass objMass;
d.BodyGetMass(Body, out objMass);
- m_dir.Z = - ( (herr0 * pTimestep * 50.0f) / m_VhoverTimescale);
+ m_wLinObjectVel.Z = - ( (herr0 * pTimestep * 50.0f) / m_VhoverTimescale);
//KF: m_VhoverEfficiency is not yet implemented
}
else
{
- m_dir.Z = 0f;
+ m_wLinObjectVel.Z = 0f;
}
}
-
+ else
+ { // not hovering, Gravity rules
+ m_wLinObjectVel.Z = vel_now.Z;
+//if(frcount == 0) Console.WriteLine(" Z {0} a.Z {1}", m_wLinObjectVel.Z, acceleration.Z);
+ }
// Apply velocity
- d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z);
+ d.BodySetLinearVel(Body, m_wLinObjectVel.X, m_wLinObjectVel.Y, m_wLinObjectVel.Z);
// apply gravity force
d.BodyAddForce(Body, grav.X, grav.Y, grav.Z);
-
-
- // apply friction
- Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
- m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount * m_linearFrictionFactor;
+//if(frcount == 0) Console.WriteLine("Grav {0}", grav);
} // end MoveLinear()
private void MoveAngular(float pTimestep)
@@ -633,7 +648,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if(m_verticalAttractionTimescale < 300)
{
- float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep);
+ float VAservo = 0.0167f / (m_verticalAttractionTimescale * pTimestep);
// get present body rotation
d.Quaternion rot = d.BodyGetQuaternion(Body);
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
index 60786d4..deb6164 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
@@ -229,7 +229,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public int bodyFramesAutoDisable = 20;
- protected DateTime m_lastframe = DateTime.UtcNow;
+ private DateTime m_lastframe = DateTime.UtcNow;
private float[] _watermap;
private bool m_filterCollisions = true;
--
cgit v1.1
From 1abb70cc73c997c08a416fecf689b83453f853d0 Mon Sep 17 00:00:00 2001
From: Kitto Flora
Date: Thu, 21 Jan 2010 19:31:02 -0500
Subject: Add glue for llSetVehicleFlags(), llRemoveVehicleFlags(). ChODE: Add
associated methods.
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 +++++++++++++++++-
.../Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs | 10 ++++++++++
.../BulletDotNETPlugin/BulletDotNETCharacter.cs | 10 ++++++++++
.../Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | 10 ++++++++++
.../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 10 ++++++++++
OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | 10 ++++++++++
OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs | 10 ++++++++++
OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 12 +++++++++++-
OpenSim/Region/Physics/Manager/PhysicsActor.cs | 12 ++++++++++++
OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 10 ++++++++++
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 10 ++++++++++
OpenSim/Region/Physics/POSPlugin/POSCharacter.cs | 10 ++++++++++
OpenSim/Region/Physics/POSPlugin/POSPrim.cs | 10 ++++++++++
OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 20 ++++++++++++++++++++
.../Shared/Api/Implementation/LSL_Api.cs | 16 ++++++++++++++--
15 files changed, 174 insertions(+), 4 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4c97467..04be9fc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2963,7 +2963,23 @@ namespace OpenSim.Region.Framework.Scenes
PhysActor.VehicleRotationParam(param, rotation);
}
}
-
+
+ public void SetVehicleFlags(int flags)
+ {
+ if (PhysActor != null)
+ {
+ PhysActor.VehicleFlagsSet(flags);
+ }
+ }
+
+ public void RemoveVehicleFlags(int flags)
+ {
+ if (PhysActor != null)
+ {
+ PhysActor.VehicleFlagsRemove(flags);
+ }
+ }
+
public void SetGroup(UUID groupID, IClientAPI client)
{
_groupID = groupID;
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
index 31366db..25b9099 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
@@ -184,7 +184,17 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
index a3344dd..120d040 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
@@ -361,7 +361,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index 9603ea4..f430def 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -396,7 +396,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{
//TODO:
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
//TODO: GhostObject
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index d5d146e..9113ebe 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -984,7 +984,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
index aa0acb7..2eb519f 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
@@ -733,7 +733,17 @@ namespace OpenSim.Region.Physics.OdePlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
index 9e145ec..14d5caa 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
@@ -286,7 +286,17 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}//end ProcessRotationVehicleParam
+
+ internal void ProcessFlagsVehicleSet(int flags)
+ {
+ m_flags |= (VehicleFlag)flags;
+ }
+ internal void ProcessFlagsVehicleRemove(int flags)
+ {
+ m_flags &= ~((VehicleFlag)flags);
+ }
+
internal void ProcessTypeChange(Vehicle pType)
{
// Set Defaults For Type
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 6e6b44f..29a3dd9 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -2415,7 +2415,17 @@ Console.WriteLine(" JointCreateFixed");
{
m_vehicle.ProcessRotationVehicleParam((Vehicle) param, rotation);
}
-
+
+ public override void VehicleFlagsSet(int flags)
+ {
+ m_vehicle.ProcessFlagsVehicleSet(flags);
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ m_vehicle.ProcessFlagsVehicleRemove(flags);
+ }
+
public override void SetVolumeDetect(int param)
{
lock (_parent_scene.OdeLock)
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 9c192ed..f43de48 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -208,6 +208,8 @@ namespace OpenSim.Region.Physics.Manager
public abstract void VehicleFloatParam(int param, float value);
public abstract void VehicleVectorParam(int param, Vector3 value);
public abstract void VehicleRotationParam(int param, Quaternion rotation);
+ public abstract void VehicleFlagsSet(int flags);
+ public abstract void VehicleFlagsRemove(int flags);
public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
@@ -351,7 +353,17 @@ namespace OpenSim.Region.Physics.Manager
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index a38fccc..b713142 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -733,7 +733,17 @@ namespace OpenSim.Region.Physics.OdePlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 567fd0e..010d97f 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -2352,6 +2352,16 @@ Console.WriteLine(" JointCreateFixed");
{
m_vehicle.ProcessRotationVehicleParam((Vehicle) param, rotation);
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+
+ }
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
index 566b4e7..491e200 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
@@ -181,7 +181,17 @@ namespace OpenSim.Region.Physics.POSPlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
index edccf47..f8d49f9 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
@@ -138,7 +138,17 @@ namespace OpenSim.Region.Physics.POSPlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index 24eb6b1..e54065c 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -370,7 +370,17 @@ namespace OpenSim.Region.Physics.PhysXPlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
@@ -774,7 +784,17 @@ namespace OpenSim.Region.Physics.PhysXPlugin
{
}
+
+ public override void VehicleFlagsSet(int flags)
+ {
+
+ }
+
+ public override void VehicleFlagsRemove(int flags)
+ {
+ }
+
public override void SetVolumeDetect(int param)
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index a5aecd8..33218aa 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6315,13 +6315,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetVehicleFlags(int flags)
{
m_host.AddScriptLPS(1);
- NotImplemented("llSetVehicleFlags");
+ if (m_host.ParentGroup != null)
+ {
+ if (!m_host.ParentGroup.IsDeleted)
+ {
+ m_host.ParentGroup.RootPart.SetVehicleFlags(flags);
+ }
+ }
}
public void llRemoveVehicleFlags(int flags)
{
m_host.AddScriptLPS(1);
- NotImplemented("llRemoveVehicleFlags");
+ if (m_host.ParentGroup != null)
+ {
+ if (!m_host.ParentGroup.IsDeleted)
+ {
+ m_host.ParentGroup.RootPart.RemoveVehicleFlags(flags);
+ }
+ }
}
public void llSitTarget(LSL_Vector offset, LSL_Rotation rot)
--
cgit v1.1
From e9c9a74e0ade505ee8d8d8e7790141f758a65f61 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Tue, 26 Jan 2010 15:12:41 +0000
Subject: Some merge fixups
---
.../Avatar/InstantMessage/OfflineMessageModule.cs | 9 +++++----
.../Framework/Scenes/SceneObjectGroup.Inventory.cs | 4 ++--
.../Framework/Scenes/SceneObjectPartInventory.cs | 2 +-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 18 +++---------------
4 files changed, 11 insertions(+), 22 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 3e86848..8f289c0 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -180,11 +180,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void RetrieveInstantMessages(IClientAPI client)
{
- if (m_RestURL != "")
- {
- m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);
+ if (m_RestURL == String.Empty)
+ return;
+
+ m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);
- List msglist = SynchronousRestObjectPoster.BeginPostObject>(
+ List msglist = SynchronousRestObjectPoster.BeginPostObject>(
"POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
if (msglist != null)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index aea005e..8b58b3e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -74,7 +74,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Stop the scripts contained in all the prims in this group
///
- public void RemoveScriptInstances()
+ public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
{
lockPartsForRead(true);
List values = new List(m_parts.Values);
@@ -82,7 +82,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectPart part in values)
{
- part.Inventory.RemoveScriptInstances();
+ part.Inventory.RemoveScriptInstances(sceneObjectBeingDeleted);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 1de0092..9661775 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -249,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if ((int)InventoryType.LSL == item.InvType)
{
- RemoveScriptInstance(item.ItemID);
+ RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
m_part.RemoveScriptEvents(item.ItemID);
}
}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 73850e1..35d57d8 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -885,12 +885,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.ClearQueue();
instance.Stop(0);
- SceneObjectPart part =
- m_Scene.GetSceneObjectPart(localID);
-
- if (part != null)
- part.RemoveScriptEvents(itemID);
-
// bool objectRemoved = false;
lock (m_PrimObjects)
@@ -923,18 +917,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance = null;
-<<<<<<< HEAD:OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
if (handlerObjectRemoved != null)
+ {
+ SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
handlerObjectRemoved(part.UUID);
-=======
- ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
- if (handlerObjectRemoved != null)
- {
- SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
- handlerObjectRemoved(part.UUID);
- }
->>>>>>> master:OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+ }
CleanAssemblies();
--
cgit v1.1
From 862caa72a80b597ccbf1ae82300af89f9103dbf9 Mon Sep 17 00:00:00 2001
From: Revolution
Date: Wed, 27 Jan 2010 21:08:55 -0600
Subject: Fixes terrain editing. Changes ThrottleOutPacketType to task instead
of land.
---
OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 33210d7..64e45d0 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1098,7 +1098,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
layerpack.Header.Reliable = true;
- OutPacket(layerpack, ThrottleOutPacketType.Land);
+ OutPacket(layerpack, ThrottleOutPacketType.Task);
}
catch (Exception e)
{
--
cgit v1.1
From cfca9e1e811f6cdea6b7c3338f7f783a07f8e0ac Mon Sep 17 00:00:00 2001
From: Melanie
Date: Fri, 29 Jan 2010 07:20:13 +0000
Subject: Revert "Updates all IRegionModules to the new style region modules."
This reverts commit ec3c31e61e5e540f822891110df9bc978655bbaf.
---
.../LoadRegions/LoadRegionsPlugin.cs | 4 +-
OpenSim/Client/MXP/MXPModule.cs | 36 ++--
.../AssetTransaction/AssetTransactionModule.cs | 35 +---
.../Agent/Capabilities/CapabilitiesModule.cs | 2 +-
.../Region/CoreModules/Agent/IPBan/IPBanModule.cs | 40 ++--
.../Agent/TextureDownload/TextureDownloadModule.cs | 33 +---
.../Agent/TextureSender/J2KDecoderModule.cs | 33 +---
.../Region/CoreModules/Agent/Xfer/XferModule.cs | 30 +--
.../Avatar/AvatarFactory/AvatarFactoryModule.cs | 29 +--
.../CoreModules/Avatar/Combat/CombatModule.cs | 32 +---
.../CoreModules/Avatar/Dialog/DialogModule.cs | 32 +---
.../CoreModules/Avatar/Friends/FriendsModule.cs | 54 ++----
.../CoreModules/Avatar/Gestures/GesturesModule.cs | 30 +--
.../Region/CoreModules/Avatar/Gods/GodsModule.cs | 28 +--
.../CoreModules/Avatar/Groups/GroupsModule.cs | 35 +---
.../Avatar/InstantMessage/InstantMessageModule.cs | 53 ++----
.../Avatar/InstantMessage/MessageTransferModule.cs | 54 ++----
.../Avatar/InstantMessage/MuteListModule.cs | 48 ++---
.../Avatar/InstantMessage/OfflineMessageModule.cs | 41 ++--
.../Avatar/InstantMessage/PresenceModule.cs | 61 ++----
.../Inventory/Archiver/InventoryArchiverModule.cs | 35 +---
.../Inventory/Transfer/InventoryTransferModule.cs | 63 ++----
.../Region/CoreModules/Avatar/Lure/LureModule.cs | 61 ++----
.../CoreModules/Avatar/ObjectCaps/ObjectAdd.cs | 55 ++----
.../Avatar/Profiles/AvatarProfilesModule.cs | 32 ++--
.../Framework/EventQueue/EventQueueGetModule.cs | 40 ++--
.../Framework/Monitoring/MonitorModule.cs | 103 ++++------
.../Hypergrid/HGStandaloneLoginModule.cs | 83 +++-----
OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs | 31 ++-
.../InterGrid/OpenGridProtocolModule.cs | 100 ++++------
.../DynamicTexture/DynamicTextureModule.cs | 60 ++----
.../Scripting/EMailModules/EmailModule.cs | 32 +---
.../Scripting/HttpRequest/ScriptsHttpRequests.cs | 36 ++--
.../CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 -
.../Scripting/LoadImageURL/LoadImageURLModule.cs | 37 ++--
.../Scripting/VectorRender/VectorRenderModule.cs | 41 ++--
.../Scripting/WorldComm/WorldCommModule.cs | 33 ++--
.../CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | 51 +----
.../Asset/AssetServiceInConnectorModule.cs | 2 +-
.../Grid/HypergridServiceInConnectorModule.cs | 2 +-
.../Inventory/InventoryServiceInConnectorModule.cs | 2 +-
.../Land/LandServiceInConnectorModule.cs | 2 +-
.../Neighbour/NeighbourServiceInConnectorModule.cs | 2 +-
.../SimulationServiceInConnectorModule.cs | 2 +-
.../Interregion/LocalInterregionComms.cs | 4 +-
.../Interregion/RESTInterregionComms.cs | 16 +-
.../CoreModules/World/Archiver/ArchiverModule.cs | 1 -
.../Region/CoreModules/World/Cloud/CloudModule.cs | 30 +--
.../World/Estate/EstateManagementModule.cs | 58 +++---
.../World/Permissions/PermissionsModule.cs | 212 ++++++++-------------
.../Region/CoreModules/World/Sound/SoundModule.cs | 33 +---
OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 96 +++++-----
.../World/Vegetation/VegetationModule.cs | 27 +--
.../Region/CoreModules/World/Wind/WindModule.cs | 45 ++---
.../CoreModules/World/WorldMap/MapImageModule.cs | 30 +--
.../CoreModules/World/WorldMap/MapSearchModule.cs | 35 +---
OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 55 +++---
.../Region/Framework/Interfaces/ICloudModule.cs | 2 +-
.../Region/Framework/Interfaces/IEmailModule.cs | 2 +-
.../Region/Framework/Interfaces/IEstateModule.cs | 2 +-
OpenSim/Region/Framework/Interfaces/ISunModule.cs | 2 +-
OpenSim/Region/Framework/Interfaces/IWindModule.cs | 2 +-
.../InternetRelayClientView/IRCStackModule.cs | 32 +---
.../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 72 ++-----
.../ContentManagementModule.cs | 47 ++---
.../Scripting/Minimodule/MRMModule.cs | 64 +++----
.../RegionReadyModule/RegionReadyModule.cs | 6 +-
.../ScriptModuleComms/ScriptModuleCommsModule.cs | 1 -
.../XmlRpcRouterModule/XmlRpcGridRouterModule.cs | 28 +--
.../XmlRpcRouterModule/XmlRpcRouterModule.cs | 30 +--
.../FreeswitchServiceInConnectorModule.cs | 2 +-
.../SvnSerialiser/SvnBackupModule.cs | 28 +--
.../Region/OptionalModules/World/NPC/NPCModule.cs | 28 +--
.../World/TreePopulator/TreePopulatorModule.cs | 41 ++--
OpenSim/Region/UserStatistics/WebStatsModule.cs | 33 ++--
OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 9 +-
76 files changed, 879 insertions(+), 1811 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
index 64863c5..6fd3d30 100644
--- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
+++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
@@ -99,7 +99,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source);
RegionInfo[] regionsToLoad = regionLoader.LoadRegions();
- /*m_log.Info("[LOADREGIONSPLUGIN]: Loading specific shared modules...");
+ m_log.Info("[LOADREGIONSPLUGIN]: Loading specific shared modules...");
m_log.Info("[LOADREGIONSPLUGIN]: DynamicTextureModule...");
m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule());
m_log.Info("[LOADREGIONSPLUGIN]: InstantMessageModule...");
@@ -111,7 +111,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule...");
m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule());
m_log.Info("[LOADREGIONSPLUGIN]: Done.");
- */
+
if (!CheckRegionsForSanity(regionsToLoad))
{
m_log.Error("[LOADREGIONS]: Halting startup due to conflicts in region configurations");
diff --git a/OpenSim/Client/MXP/MXPModule.cs b/OpenSim/Client/MXP/MXPModule.cs
index 47417ab..0b442cc 100644
--- a/OpenSim/Client/MXP/MXPModule.cs
+++ b/OpenSim/Client/MXP/MXPModule.cs
@@ -31,7 +31,6 @@ using System.Reflection;
using System.Text;
using System.Timers;
using log4net;
-using Mono.Addins;
using MXP;
using Nini.Config;
using OpenMetaverse;
@@ -45,8 +44,7 @@ namespace OpenSim.Client.MXP
/**
* MXP Client Module which adds MXP support to client / region communication.
*/
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class MXPModule : ISharedRegionModule
+ public class MXPModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -59,23 +57,15 @@ namespace OpenSim.Client.MXP
private readonly Dictionary m_scenes = new Dictionary();
private bool m_shutdown;
- public void Initialise(IConfigSource source)
- {
- m_config = source;
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource source)
{
if (!m_scenes.ContainsKey(scene.RegionInfo.RegionID))
m_scenes.Add(scene.RegionInfo.RegionID, scene);
+
+ m_config = source;
}
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
if (m_config.Configs["MXP"] != null)
{
@@ -86,7 +76,7 @@ namespace OpenSim.Client.MXP
m_port = con.GetInt("Port", m_port);
- m_server = new MXPPacketServer(m_port, m_scenes, m_config.Configs["StandAlone"].GetBoolean("accounts_authenticate", true));
+ m_server = new MXPPacketServer(m_port, m_scenes,m_config.Configs["StandAlone"].GetBoolean("accounts_authenticate",true));
m_ticker = new Timer(100);
m_ticker.AutoReset = false;
@@ -99,14 +89,6 @@ namespace OpenSim.Client.MXP
}
}
- public void RemoveRegion(Scene scene)
- {
- }
-
- public void PostInitialise()
- {
- }
-
void ticker_Elapsed(object sender, ElapsedEventArgs e)
{
try
@@ -139,5 +121,11 @@ namespace OpenSim.Client.MXP
{
get { return "MXP ClientStack Module"; }
}
+
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
}
}
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
index 7012037..1077f4a 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -27,7 +27,6 @@
using System;
using System.Collections.Generic;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -36,8 +35,7 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class AssetTransactionModule : ISharedRegionModule, IAgentAssetTransactions
+ public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions
{
private readonly Dictionary RegisteredScenes = new Dictionary();
private bool m_dumpAssetsToFile = false;
@@ -61,14 +59,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
//m_log.Debug("creating AgentAssetTransactionModule");
}
- #region ISharedRegionModule Members
+ #region IRegionModule Members
- public void Initialise(IConfigSource config)
- {
-
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource config)
{
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
@@ -86,23 +79,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
m_scene = scene;
}
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- if (RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
- RegisteredScenes.Remove(scene.RegionInfo.RegionID);
- scene.UnregisterModuleInterface(this);
- scene.EventManager.OnNewClient -= NewClient;
- }
-
public void PostInitialise()
{
}
@@ -116,6 +92,11 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
get { return "AgentTransactionModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
#endregion
public void NewClient(IClientAPI client)
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
index 886173f..2a1355b 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
public void RemoveRegion(Scene scene)
{
- scene.UnregisterModuleInterface(this);
+ m_scene.UnregisterModuleInterface(this);
}
public void PostInitialise() {}
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
index f7f2eff..bfe2a71 100644
--- a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
@@ -29,7 +29,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
-using Mono.Addins;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
@@ -37,27 +36,21 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Agent.IPBan
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class IPBanModule : ISharedRegionModule
+ public class IPBanModule : IRegionModule
{
- #region Implementation of ISharedRegionModule
+ #region Implementation of IRegionModule
private List m_bans = new List();
- private Dictionary SceneBanners = new Dictionary();
- public void Initialise(IConfigSource source)
+ public void Initialise(Scene scene, IConfigSource source)
{
- }
-
- public void AddRegion(Scene scene)
- {
- SceneBanners.Add(scene, new SceneBanner(scene, m_bans));
+ new SceneBanner(scene, m_bans);
lock (m_bans)
{
foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans)
{
- if (!String.IsNullOrEmpty(ban.BannedHostIPMask))
+ if (!String.IsNullOrEmpty(ban.BannedHostIPMask))
m_bans.Add(ban.BannedHostIPMask);
if (!String.IsNullOrEmpty(ban.BannedHostNameMask))
m_bans.Add(ban.BannedHostNameMask);
@@ -65,12 +58,7 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
}
}
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
if (File.Exists("bans.txt"))
{
@@ -82,18 +70,9 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
}
}
- public void RemoveRegion(Scene scene)
- {
- if(SceneBanners.ContainsKey(scene))
- SceneBanners.Remove(scene);
- }
-
- public void PostInitialise()
- {
- }
-
public void Close()
{
+
}
public string Name
@@ -101,6 +80,11 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
get { return "IPBanModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
#endregion
///
diff --git a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
index c4d84cb..71ff28c 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -42,8 +41,7 @@ using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Agent.TextureDownload
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class TextureDownloadModule : INonSharedRegionModule
+ public class TextureDownloadModule : IRegionModule
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -67,14 +65,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureDownload
{
}
- #region INonSharedRegionModule Members
+ #region IRegionModule Members
- public void Initialise(IConfigSource config)
- {
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource config)
{
+
if (m_scene == null)
{
//m_log.Debug("Creating Texture download module");
@@ -95,23 +90,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureDownload
}
}
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
}
- public void RemoveRegion(Scene scene)
- {
- if(m_scenes.Contains(scene))
- m_scenes.Remove(scene);
- scene.EventManager.OnNewClient -= NewClient;
- scene.EventManager.OnRemovePresence -= EventManager_OnRemovePresence;
- }
-
public void Close()
{
}
@@ -121,6 +103,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureDownload
get { return "TextureDownloadModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+
#endregion
///
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index ff87493..7ac8bed 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -32,7 +32,6 @@ using System.Reflection;
using System.Text;
using System.Threading;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.Imaging;
@@ -46,8 +45,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
{
public delegate void J2KDecodeDelegate(UUID assetID);
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class J2KDecoderModule : ISharedRegionModule, IJ2KDecoder
+ public class J2KDecoderModule : IRegionModule, IJ2KDecoder
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -60,19 +58,16 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
/// Reference to a scene (doesn't matter which one as long as it can load the cache module)
private Scene m_scene;
- #region ISharedRegionModule
+ #region IRegionModule
public string Name { get { return "J2KDecoderModule"; } }
-
- public J2KDecoderModule()
- {
- }
+ public bool IsSharedModule { get { return true; } }
- public void Initialise(IConfigSource source)
+ public J2KDecoderModule()
{
}
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource source)
{
if (m_scene == null)
m_scene = scene;
@@ -80,30 +75,16 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
scene.RegisterModuleInterface(this);
}
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void RegionLoaded(Scene scene)
- {
- m_cache = m_scene.RequestModuleInterface();
- }
-
- public void RemoveRegion(Scene scene)
- {
- scene.UnregisterModuleInterface(this);
- }
-
public void PostInitialise()
{
+ m_cache = m_scene.RequestModuleInterface();
}
public void Close()
{
}
- #endregion
+ #endregion IRegionModule
#region IJ2KDecoder
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
index d062361..ef7dce8 100644
--- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
@@ -27,7 +27,6 @@
using System;
using System.Collections.Generic;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -36,8 +35,7 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Agent.Xfer
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class XferModule : INonSharedRegionModule, IXfer
+ public class XferModule : IRegionModule, IXfer
{
private Scene m_scene;
private Dictionary Requests = new Dictionary();
@@ -54,13 +52,9 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
public DateTime timeStamp;
}
- #region INonSharedRegionModule Members
+ #region IRegionModule Members
- public void Initialise(IConfigSource config)
- {
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
@@ -68,21 +62,10 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
m_scene.RegisterModuleInterface(this);
}
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
}
- public void RemoveRegion(Scene scene)
- {
- scene.EventManager.OnNewClient -= NewClient;
- scene.UnregisterModuleInterface(this);
- }
-
public void Close()
{
}
@@ -92,6 +75,11 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
get { return "XferModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+
#endregion
#region IXfer Members
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 6bbbd56..35c59aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -28,7 +28,6 @@
using System;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -39,8 +38,7 @@ using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class AvatarFactoryModule : IAvatarFactory, ISharedRegionModule
+ public class AvatarFactoryModule : IAvatarFactory, IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene = null;
@@ -77,16 +75,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return appearance;
}
- public void Initialise(IConfigSource source)
- {
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource source)
{
scene.RegisterModuleInterface(this);
scene.EventManager.OnNewClient += NewClient;
@@ -95,18 +84,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
m_scene = scene;
}
- }
- public void RegionLoaded(Scene scene)
- {
}
- public void RemoveRegion(Scene scene)
- {
- scene.UnregisterModuleInterface(this);
- scene.EventManager.OnNewClient -= NewClient;
- }
-
public void PostInitialise()
{
}
@@ -120,6 +100,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
get { return "Default Avatar Factory"; }
}
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+
public void NewClient(IClientAPI client)
{
client.OnAvatarNowWearing += AvatarIsWearing;
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index b7d12aa..61b6d65 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -27,7 +27,6 @@
using System;
using System.Collections.Generic;
-using Mono.Addins;
using Nini.Config;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@@ -35,8 +34,7 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class CombatModule : ISharedRegionModule
+ public class CombatModule : IRegionModule
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -55,17 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
///
///
///
- public void Initialise(IConfigSource config)
- {
-
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource config)
{
lock (m_scenel)
{
@@ -83,17 +71,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
}
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- scene.EventManager.OnAvatarKilled -= KillAvatar;
- scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
- m_scenel.Remove(scene.RegionInfo.RegionHandle);
- }
-
public void PostInitialise()
{
}
@@ -107,6 +84,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
get { return "CombatModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar)
{
if (killerObjectLocalID == 0)
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index ecffc7a..72ec869 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -25,11 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -39,46 +37,28 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.Dialog
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class DialogModule : ISharedRegionModule, IDialogModule
+ public class DialogModule : IRegionModule, IDialogModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_scene;
- public void Initialise(IConfigSource source)
- {
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
m_scene.RegisterModuleInterface(this);
-
+
m_scene.AddCommand(
this, "alert", "alert ", "Send an alert to a user", HandleAlertConsoleCommand);
m_scene.AddCommand(
this, "alert general", "alert general ", "Send an alert to everyone", HandleAlertConsoleCommand);
}
-
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- scene.UnregisterModuleInterface(this);
- }
-
- public void PostInitialise() { }
+
+ public void PostInitialise() {}
public void Close() {}
public string Name { get { return "Dialog Module"; } }
+ public bool IsSharedModule { get { return false; } }
public void SendAlertToUser(IClientAPI client, string message)
{
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 7254180..086d4fe 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using System.Net;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
@@ -82,8 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
- Terminate Friendship messages (single)
*/
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class FriendsModule : ISharedRegionModule, IFriendsModule
+ public class FriendsModule : IRegionModule, IFriendsModule
{
private class Transaction
{
@@ -113,23 +111,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private IGridService m_gridServices = null;
- #region ISharedRegionModule Members
+ #region IRegionModule Members
- public void Initialise(IConfigSource config)
- {
-
- }
-
- public void PostInitialise()
- {
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource config)
{
lock (m_scenes)
{
@@ -144,9 +128,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle))
m_scenes[scene.RegionInfo.RegionHandle] = scene;
}
-
+
scene.RegisterModuleInterface(this);
-
+
scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
@@ -154,34 +138,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
scene.EventManager.OnClientClosed += ClientClosed;
}
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
if (m_scenes.Count > 0)
{
- m_TransferModule = scene.RequestModuleInterface();
- m_gridServices = scene.GridService;
+ m_TransferModule = m_initialScene.RequestModuleInterface();
+ m_gridServices = m_initialScene.GridService;
}
if (m_TransferModule == null)
m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work");
}
- public void RemoveRegion(Scene scene)
- {
- MainServer.Instance.RemoveXmlRPCHandler("presence_update_bulk");
- MainServer.Instance.RemoveXmlRPCHandler("terminate_friend");
-
- if (m_scenes.ContainsKey(scene.RegionInfo.RegionHandle))
- m_scenes.Remove(scene.RegionInfo.RegionHandle);
-
- scene.UnregisterModuleInterface(this);
-
- scene.EventManager.OnNewClient -= OnNewClient;
- scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
- scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
- scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
- scene.EventManager.OnClientClosed -= ClientClosed;
- }
-
public void Close()
{
}
@@ -191,6 +158,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
get { return "FriendsModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
#endregion
#region IInterregionFriendsComms
diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
index c306f94..8ce5092 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
@@ -25,10 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -39,41 +37,23 @@ using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Gestures
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class GesturesModule : INonSharedRegionModule
+ public class GesturesModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_scene;
- public void Initialise(IConfigSource source)
- {
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
+
m_scene.EventManager.OnNewClient += OnNewClient;
}
-
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- if(m_scene == scene)
- m_scene = null;
- scene.EventManager.OnNewClient -= OnNewClient;
- }
+ public void PostInitialise() {}
public void Close() {}
public string Name { get { return "Gestures Module"; } }
+ public bool IsSharedModule { get { return false; } }
private void OnNewClient(IClientAPI client)
{
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 3914f2e..50171a3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -25,9 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
using System.Collections.Generic;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -36,8 +34,7 @@ using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Gods
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class GodsModule : INonSharedRegionModule, IGodsModule
+ public class GodsModule : IRegionModule, IGodsModule
{
/// Special UUID for actions that apply to all agents
private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb");
@@ -45,34 +42,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
protected Scene m_scene;
protected IDialogModule m_dialogModule;
- public void Initialise(IConfigSource source)
- {
-
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
m_dialogModule = m_scene.RequestModuleInterface();
m_scene.RegisterModuleInterface(this);
}
-
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- scene.UnregisterModuleInterface(this);
- }
+ public void PostInitialise() {}
public void Close() {}
public string Name { get { return "Gods Module"; } }
+ public bool IsSharedModule { get { return false; } }
public void RequestGodlikePowers(
UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient)
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
index 7ff8d30..31363e5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
@@ -25,11 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -38,8 +36,7 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.Groups
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class GroupsModule : ISharedRegionModule
+ public class GroupsModule : IRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -58,9 +55,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
private static GroupMembershipData osGroup =
new GroupMembershipData();
- #region ISharedRegionModule Members
+ #region IRegionModule Members
- public void Initialise(IConfigSource config)
+ public void Initialise(Scene scene, IConfigSource config)
{
IConfig groupsConfig = config.Configs["Groups"];
@@ -79,15 +76,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
if (groupsConfig.GetString("Module", "Default") != "Default")
return;
}
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
- public void AddRegion(Scene scene)
- {
lock (m_SceneList)
{
if (!m_SceneList.Contains(scene))
@@ -110,19 +99,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
}
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- if (m_SceneList.Contains(scene))
- m_SceneList.Remove(scene);
- scene.EventManager.OnNewClient -= OnNewClient;
- scene.EventManager.OnClientClosed -= OnClientClosed;
- scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
- }
-
public void PostInitialise()
{
}
@@ -147,6 +123,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
get { return "GroupsModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
#endregion
private void OnNewClient(IClientAPI client)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index e1bde4b..9a68749 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -24,12 +24,9 @@
* (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.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -39,8 +36,7 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class InstantMessageModule : ISharedRegionModule
+ public class InstantMessageModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -51,11 +47,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private readonly List m_scenes = new List();
- #region ISharedRegionModule Members
+ #region IRegionModule Members
private IMessageTransferModule m_TransferModule = null;
- public void Initialise(IConfigSource config)
+ public void Initialise(Scene scene, IConfigSource config)
{
if (config.Configs["Messaging"] != null)
{
@@ -66,15 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
}
m_enabled = true;
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
- public void AddRegion(Scene scene)
- {
lock (m_scenes)
{
if (!m_scenes.Contains(scene))
@@ -86,27 +74,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
}
}
- public void RegionLoaded(Scene scene)
- {
- if (!m_enabled)
- return;
-
- m_TransferModule =
- m_scenes[0].RequestModuleInterface();
-
- if (m_TransferModule == null)
- m_log.Error("[INSTANT MESSAGE]: No message transfer module, " +
- "IM will not work!");
- }
-
- public void RemoveRegion(Scene scene)
- {
- if (m_scenes.Contains(scene))
- m_scenes.Remove(scene);
- scene.EventManager.OnClientConnect -= OnClientConnect;
- scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
- }
-
void OnClientConnect(IClientCore client)
{
IClientIM clientIM;
@@ -118,6 +85,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
public void PostInitialise()
{
+ if (!m_enabled)
+ return;
+
+ m_TransferModule =
+ m_scenes[0].RequestModuleInterface();
+
+ if (m_TransferModule == null)
+ m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+
+ "IM will not work!");
}
public void Close()
@@ -129,6 +105,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
get { return "InstantMessageModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
#endregion
public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 16bdfdd..e5159b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
using System.Net;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
@@ -41,8 +40,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule
+ public class MessageTransferModule : IRegionModule, IMessageTransferModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -52,9 +50,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
protected Dictionary m_UserRegionMap = new Dictionary();
public event UndeliveredMessage OnUndeliveredMessage;
- private bool m_enabled = true;
- public virtual void Initialise(IConfigSource config)
+ public virtual void Initialise(Scene scene, IConfigSource config)
{
IConfig cnf = config.Configs["Messaging"];
if (cnf != null && cnf.GetString(
@@ -62,49 +59,27 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
"MessageTransferModule")
{
m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration");
- m_enabled = false;
+ return;
}
cnf = config.Configs["Startup"];
if (cnf != null)
m_Gridmode = cnf.GetBoolean("gridmode", false);
- }
- public Type ReplaceableInterface
- {
- get { return null; }
- }
+ // m_Enabled = true;
- public void AddRegion(Scene scene)
- {
- if (m_enabled)
+ lock (m_Scenes)
{
- lock (m_Scenes)
+ if (m_Scenes.Count == 0)
{
- if (m_Scenes.Count == 0)
- {
- MainServer.Instance.AddXmlRPCHandler(
- "grid_instant_message", processXMLRPCGridInstantMessage);
- }
-
- m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active");
- scene.RegisterModuleInterface(this);
- m_Scenes.Add(scene);
+ MainServer.Instance.AddXmlRPCHandler(
+ "grid_instant_message", processXMLRPCGridInstantMessage);
}
- }
- }
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- if (m_Scenes.Contains(scene))
- m_Scenes.Remove(scene);
- MainServer.Instance.RemoveXmlRPCHandler(
- "grid_instant_message");
- scene.UnregisterModuleInterface(this);
+ m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active");
+ scene.RegisterModuleInterface(this);
+ m_Scenes.Add(scene);
+ }
}
public virtual void PostInitialise()
@@ -120,6 +95,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
get { return "MessageTransferModule"; }
}
+ public virtual bool IsSharedModule
+ {
+ get { return true; }
+ }
+
public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result)
{
UUID toAgentID = new UUID(im.toAgentID);
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
index 3570495..2d4a635 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
@@ -28,7 +28,6 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -40,8 +39,7 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.MuteList
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class MuteListModule : ISharedRegionModule
+ public class MuteListModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -49,7 +47,7 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
private List m_SceneList = new List();
private string m_RestURL = String.Empty;
- public void Initialise(IConfigSource config)
+ public void Initialise(Scene scene, IConfigSource config)
{
if (!enabled)
return;
@@ -68,24 +66,19 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
enabled = false;
return;
}
- m_RestURL = cnf.GetString("MuteListURL", "");
- if (m_RestURL == "")
- {
- m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling");
- enabled = false;
- return;
- }
- }
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
- {
lock (m_SceneList)
{
+ if (m_SceneList.Count == 0)
+ {
+ m_RestURL = cnf.GetString("MuteListURL", "");
+ if (m_RestURL == "")
+ {
+ m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling");
+ enabled = false;
+ return;
+ }
+ }
if (!m_SceneList.Contains(scene))
m_SceneList.Add(scene);
@@ -93,18 +86,6 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
}
}
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- if (m_SceneList.Contains(scene))
- m_SceneList.Remove(scene);
-
- scene.EventManager.OnNewClient -= OnNewClient;
- }
-
public void PostInitialise()
{
if (!enabled)
@@ -121,6 +102,11 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
get { return "MuteListModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
public void Close()
{
}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 8f289c0..0727fa9 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -28,7 +28,6 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -41,8 +40,7 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class OfflineMessageModule : ISharedRegionModule
+ public class OfflineMessageModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -51,7 +49,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private string m_RestURL = String.Empty;
private bool m_ForwardOfflineGroupMessages = true;
- public void Initialise(IConfigSource config)
+ public void Initialise(Scene scene, IConfigSource config)
{
if (!enabled)
return;
@@ -85,23 +83,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
return;
}
}
- }
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
+ if (!m_SceneList.Contains(scene))
+ m_SceneList.Add(scene);
- public void AddRegion(Scene scene)
- {
- if (!m_SceneList.Contains(scene))
- m_SceneList.Add(scene);
-
- scene.EventManager.OnNewClient += OnNewClient;
+ scene.EventManager.OnNewClient += OnNewClient;
+ }
}
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
if (!enabled)
return;
@@ -131,22 +120,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled");
}
- public void RemoveRegion(Scene scene)
- {
- if (m_SceneList.Contains(scene))
- m_SceneList.Remove(scene);
- scene.EventManager.OnNewClient -= OnNewClient;
- }
-
- public void PostInitialise()
- {
- }
-
public string Name
{
get { return "OfflineMessageModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return true; }
+ }
+
public void Close()
{
}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
index f5498f4..f5ab454 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
@@ -24,14 +24,11 @@
* (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;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
@@ -42,8 +39,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class PresenceModule : ISharedRegionModule, IPresenceModule
+ public class PresenceModule : IRegionModule, IPresenceModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -63,7 +59,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
public event PresenceChange OnPresenceChange;
public event BulkPresenceData OnBulkPresenceData;
- public void Initialise(IConfigSource config)
+ public void Initialise(Scene scene, IConfigSource config)
{
lock (m_Scenes)
{
@@ -82,38 +78,28 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
m_Gridmode = cnf.GetBoolean("gridmode", false);
m_Enabled = true;
- }
- }
- }
- public Type ReplaceableInterface
- {
- get { return null; }
- }
+ m_initialScene = scene;
+ }
- public void AddRegion(Scene scene)
- {
- if (m_Enabled)
- {
- m_initialScene = scene;
if (m_Gridmode)
NotifyMessageServerOfStartup(scene);
m_Scenes.Add(scene);
+ }
- scene.RegisterModuleInterface(this);
+ scene.RegisterModuleInterface(this);
- scene.EventManager.OnNewClient += OnNewClient;
- scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene;
- scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
- }
+ scene.EventManager.OnNewClient += OnNewClient;
+ scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene;
+ scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
}
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
}
- public void RemoveRegion(Scene scene)
+ public void Close()
{
if (!m_Gridmode || !m_Enabled)
return;
@@ -130,28 +116,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
}
}
- NotifyMessageServerOfShutdown(scene);
- if(m_Scenes.Contains(scene))
- m_Scenes.Remove(scene);
-
- scene.UnregisterModuleInterface(this);
-
- scene.EventManager.OnNewClient -= OnNewClient;
- scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
- scene.EventManager.OnMakeChildAgent -= OnMakeChildAgent;
- }
-
- public void PostInitialise()
- {
+ lock (m_Scenes)
+ {
+ foreach (Scene scene in m_Scenes)
+ NotifyMessageServerOfShutdown(scene);
+ }
}
- public void Close()
+ public string Name
{
+ get { return "PresenceModule"; }
}
- public string Name
+ public bool IsSharedModule
{
- get { return "PresenceModule"; }
+ get { return true; }
}
public void RequestBulkPresenceData(UUID[] users)
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index a04ab22..ecd60bd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -42,11 +41,10 @@ using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
///
/// This module loads and saves OpenSimulator inventory archives
///
- public class InventoryArchiverModule : ISharedRegionModule, IInventoryArchiverModule
+ public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -84,28 +82,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
DisablePresenceChecks = disablePresenceChecks;
}
- public void Initialise(IConfigSource source)
- {
-
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
+ public void Initialise(Scene scene, IConfigSource source)
{
if (m_scenes.Count == 0)
{
scene.RegisterModuleInterface(this);
OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted;
-
+
scene.AddCommand(
this, "load iar",
"load iar []",
- "Load user inventory archive.", HandleLoadInvConsoleCommand);
-
+ "Load user inventory archive.", HandleLoadInvConsoleCommand);
+
scene.AddCommand(
this, "save iar",
"save iar []",
@@ -113,21 +101,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_aScene = scene;
}
-
+
m_scenes[scene.RegionInfo.RegionID] = scene;
}
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- scene.UnregisterModuleInterface(this);
- if(m_scenes.ContainsKey(scene.RegionInfo.RegionID))
- m_scenes.Remove(scene.RegionInfo.RegionID);
- }
-
public void PostInitialise() {}
public void Close() {}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index abf440e..b60b32b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -29,7 +29,6 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -40,8 +39,7 @@ using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule
+ public class InventoryTransferModule : IInventoryTransferModule, IRegionModule
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -52,11 +50,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
new Dictionary();
private IMessageTransferModule m_TransferModule = null;
- private bool m_enabled = true;
- #region ISharedRegionModule Members
+ #region IRegionModule Members
- public void Initialise(IConfigSource config)
+ public void Initialise(Scene scene, IConfigSource config)
{
if (config.Configs["Messaging"] != null)
{
@@ -65,61 +62,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
if (config.Configs["Messaging"].GetString(
"InventoryTransferModule", "InventoryTransferModule") !=
"InventoryTransferModule")
- m_enabled = false;
+ return;
}
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
- public void AddRegion(Scene scene)
- {
- if (m_enabled)
+ if (!m_Scenelist.Contains(scene))
{
- if (!m_Scenelist.Contains(scene))
- {
- m_Scenelist.Add(scene);
+ m_Scenelist.Add(scene);
- scene.RegisterModuleInterface(this);
+ scene.RegisterModuleInterface(this);
- scene.EventManager.OnNewClient += OnNewClient;
- scene.EventManager.OnClientClosed += ClientLoggedOut;
- scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
- }
+ scene.EventManager.OnNewClient += OnNewClient;
+ scene.EventManager.OnClientClosed += ClientLoggedOut;
+ scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
}
}
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
- if (m_enabled)
+ if (m_Scenelist.Count > 0)
{
- if (m_Scenelist.Count > 0)
- {
- m_TransferModule = m_Scenelist[0].RequestModuleInterface();
- if (m_TransferModule == null)
- m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only");
- }
+ m_TransferModule = m_Scenelist[0].RequestModuleInterface();
+ if (m_TransferModule == null)
+ m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only");
}
}
- public void RemoveRegion(Scene scene)
- {
- if (m_Scenelist.Contains(scene))
- m_Scenelist.Remove(scene);
-
- scene.UnregisterModuleInterface(this);
-
- scene.EventManager.OnNewClient -= OnNewClient;
- scene.EventManager.OnClientClosed -= ClientLoggedOut;
- scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
- }
-
- public void PostInitialise()
- {
- }
-
public void Close()
{
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index 973d27f..261bd6c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -29,7 +29,6 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -38,72 +37,36 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.Lure
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class LureModule : ISharedRegionModule
+ public class LureModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly List m_scenes = new List();
- private bool m_enabled = true;
-
private IMessageTransferModule m_TransferModule = null;
- public void Initialise(IConfigSource config)
+ public void Initialise(Scene scene, IConfigSource config)
{
if (config.Configs["Messaging"] != null)
{
if (config.Configs["Messaging"].GetString(
"LureModule", "LureModule") !=
"LureModule")
- m_enabled = false;
+ return;
}
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
- public void AddRegion(Scene scene)
- {
- if (m_enabled)
+ lock (m_scenes)
{
- lock (m_scenes)
+ if (!m_scenes.Contains(scene))
{
- if (!m_scenes.Contains(scene))
- {
- m_scenes.Add(scene);
- scene.EventManager.OnNewClient += OnNewClient;
- scene.EventManager.OnIncomingInstantMessage +=
- OnGridInstantMessage;
- }
+ m_scenes.Add(scene);
+ scene.EventManager.OnNewClient += OnNewClient;
+ scene.EventManager.OnIncomingInstantMessage +=
+ OnGridInstantMessage;
}
}
}
- public void RegionLoaded(Scene scene)
- {
- if (m_enabled)
- {
- m_TransferModule =
- m_scenes[0].RequestModuleInterface();
-
- if (m_TransferModule == null)
- m_log.Error("[INSTANT MESSAGE]: No message transfer module, " +
- "lures will not work!");
- }
- }
-
- public void RemoveRegion(Scene scene)
- {
- if (m_scenes.Contains(scene))
- m_scenes.Remove(scene);
- scene.EventManager.OnNewClient -= OnNewClient;
- scene.EventManager.OnIncomingInstantMessage -=
- OnGridInstantMessage;
- }
-
void OnNewClient(IClientAPI client)
{
client.OnInstantMessage += OnInstantMessage;
@@ -113,6 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
public void PostInitialise()
{
+ m_TransferModule =
+ m_scenes[0].RequestModuleInterface();
+
+ if (m_TransferModule == null)
+ m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+
+ "lures will not work!");
}
public void Close()
diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs
index 748b42c..63a93aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs
+++ b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs
@@ -29,7 +29,6 @@ using System;
using System.Collections;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@@ -42,54 +41,24 @@ using Caps=OpenSim.Framework.Capabilities.Caps;
namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class ObjectAdd : ISharedRegionModule
+ public class ObjectAdd : IRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
- #region ISharedRegionModule Members
+ #region IRegionModule Members
- public void Initialise(IConfigSource pSource)
+ public void Initialise(Scene pScene, IConfigSource pSource)
{
-
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void AddRegion(Scene scene)
- {
- m_scene = scene;
+ m_scene = pScene;
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
}
- public void RegionLoaded(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
- scene.EventManager.OnRegisterCaps -= RegisterCaps;
- }
-
public void PostInitialise()
{
}
- public void Close()
- {
-
- }
-
- public string Name
- {
- get { return "ObjectAddModule"; }
- }
-
public void RegisterCaps(UUID agentID, Caps caps)
{
UUID capuuid = UUID.Random();
@@ -379,6 +348,22 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
Array.Reverse(resultbytes);
return String.Format("{0}",Convert.ToBase64String(resultbytes));
}
+
+ public void Close()
+ {
+
+ }
+
+ public string Name
+ {
+ get { return "ObjectAddModule"; }
+ }
+
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+
#endregion
}
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
index 7fcb0e1..8cf58c6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
@@ -30,7 +30,6 @@ using System.Collections;
using System.Globalization;
using System.Reflection;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
@@ -39,17 +38,20 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.Profiles
{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class AvatarProfilesModule : INonSharedRegionModule
+ public class AvatarProfilesModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IProfileModule m_profileModule = null;
private bool m_enabled = true;
- #region INonSharedRegionModule Members
+ public AvatarProfilesModule()
+ {
+ }
- public void Initialise(IConfigSource config)
+ #region IRegionModule Members
+
+ public void Initialise(Scene scene, IConfigSource config)
{
IConfig profileConfig = config.Configs["Profile"];
if (profileConfig != null)
@@ -60,31 +62,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
return;
}
}
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
- public void AddRegion(Scene scene)
- {
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
}
- public void RegionLoaded(Scene scene)
+ public void PostInitialise()
{
if (!m_enabled)
return;
m_profileModule = m_scene.RequestModuleInterface();
}
- public void RemoveRegion(Scene scene)
- {
- scene.EventManager.OnNewClient -= NewClient;
- }
-
public void Close()
{
}
@@ -94,6 +83,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
get { return "AvatarProfilesModule"; }
}
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+
#endregion
public void NewClient(IClientAPI client)
diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
index 1ee6f0d..0c6cb1b 100644
--- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
@@ -32,7 +32,6 @@ using System.Net;
using System.Reflection;
using System.Threading;
using log4net;
-using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.Packets;
@@ -53,13 +52,11 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
public OSDMap body;
}
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class EventQueueGetModule : IEventQueue, INonSharedRegionModule
+ public class EventQueueGetModule : IEventQueue, IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_scene = null;
private IConfigSource m_gConfig;
- private IConfig m_startupConfig;
bool enabledYN = false;
private Dictionary m_ids = new Dictionary();
@@ -68,31 +65,23 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
private Dictionary m_QueueUUIDAvatarMapping = new Dictionary