Compare commits

...

12 Commits

Author SHA1 Message Date
KittoFlora
7f0f5060ec Clean up messages in ODE 2009-11-19 20:13:26 +01:00
KittoFlora
4c10826caa Fix merge conflicts 2009-11-16 02:12:56 +01:00
KittoFlora
873c9098d8 Merge branch 'careminster' into tests 2009-11-16 01:40:15 +01:00
Melanie
6ce5080049 Merge branch 'master' into careminster 2009-11-15 22:38:22 +00:00
Melanie
b9546d12f2 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
2009-11-15 21:20:42 +00:00
Melanie
a49c524c9e Add the ability to send messages to users ir regions via remote admin 2009-11-15 20:22:15 +00:00
Melanie
b7f1fc116e Prevent a nullref if a recipient of a group message gas left the scene 2009-11-15 20:21:46 +00:00
unknown
28aa8010b2 - 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 2009-11-15 19:40:58 +00:00
KittoFlora
c09eb00031 Merge branch 'vehicles' into tests 2009-10-27 23:32:39 +01:00
KittoFlora
1113b3b6eb Merge branch 'vehicles' into tests
Conflicts:

	OpenSim/Region/Physics/Manager/PhysicsActor.cs
	OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
2009-10-27 22:42:55 +01:00
KittoFlora
a81a16f22f llRotLookAt Pt 2 2009-10-27 19:56:39 +01:00
KittoFlora
8428b25939 Add llRotLookat pt1. 2009-10-26 00:10:23 +01:00
20 changed files with 472 additions and 99 deletions

View File

@@ -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<IDialogModule>();
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)
{

View File

@@ -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);
}
/// <summary>
@@ -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);
}
/// <summary>
/// Sends a set of four patches (x, x+1, ..., x+3) to the client
/// </summary>
/// <param name="map">heightmap</param>
/// <param name="px">X coordinate for patches 0..12</param>
/// <param name="py">Y coordinate for patches 0..15</param>
// 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;
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;
// Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
// OutPacket(layerpack, ThrottleOutPacketType.Land);
// }
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);
}
}
/// <summary>
/// Sends a specified patch to a client

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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;
/// <summary>Category this packet belongs to</summary>
public ThrottleOutPacketType Category;
/// <summary>The type of packet so its delivery method can be determined</summary>
public PacketType Type;
/// <summary>
/// Default constructor
/// </summary>

View File

@@ -164,19 +164,22 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
List<GridInstantMessage>msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>(
"POST", m_RestURL+"/RetrieveMessages/", client.AgentId);
foreach (GridInstantMessage im in msglist)
if (msglist != null)
{
// client.SendInstantMessage(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);
// 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);
}
}
}

View File

@@ -1734,6 +1734,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;
}
}
}
/// <summary>
/// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
/// </summary>

View File

@@ -1064,14 +1064,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Clear all pending updates of parts to clients
/// </summary>
private void ClearUpdateSchedule()
{
m_updateFlag = 0;
}
private void SendObjectPropertiesToClient(UUID AgentID)
{
ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
@@ -2183,6 +2175,11 @@ namespace OpenSim.Region.Framework.Scenes
ParentGroup.HasGroupChanged = true;
ScheduleFullUpdate();
}
public void RotLookAt(Quaternion target, float strength, float damping)
{
m_parentGroup.rotLookAt(target, strength, damping);
}
/// <summary>
/// Schedules this prim for a full update
@@ -2387,8 +2384,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 +2398,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 +2416,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
}
}
}
@@ -2680,6 +2679,13 @@ namespace OpenSim.Region.Framework.Scenes
SetText(text);
}
public void StopLookAt()
{
m_parentGroup.stopLookAt();
m_parentGroup.ScheduleGroupForTerseUpdate();
}
public void StopMoveToTarget()
{
m_parentGroup.stopMoveToTarget();

View File

@@ -303,6 +303,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)
{
}

View File

@@ -619,6 +619,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; } }
/// <summary>
/// Adds the force supplied to the Target Velocity

View File

@@ -565,6 +565,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(Vector3 force, bool pushforce)
{

View File

@@ -1238,6 +1238,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)
{

View File

@@ -243,7 +243,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(Vector3 force, bool pushforce);
public abstract void AddAngularForce(Vector3 force, bool pushforce);
public abstract void SetMomentum(Vector3 momentum);
@@ -476,6 +481,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(Vector3 momentum)
{

View File

@@ -1196,6 +1196,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)
{

View File

@@ -23,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_<other> is to
* switch between 'VEHICLE' parameter use and general dynamics
* settings use.
*
*/
/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
@@ -120,7 +133,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.
@@ -479,7 +492,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.
@@ -561,6 +574,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);
@@ -636,7 +650,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))
{

View File

@@ -21,6 +21,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_<other> is to
* switch between 'VEHICLE' parameter use and general dynamics
* settings use.
*/
/*
@@ -81,7 +93,12 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_PIDTau;
private float PID_D = 35f;
private float PID_G = 25f;
private bool m_usePID;
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.
@@ -182,6 +199,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, Vector3 pos, Vector3 size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
@@ -1558,9 +1578,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
@@ -1568,7 +1593,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.ApproxEquals(Vector3.Zero, 0.003f))
@@ -1590,21 +1614,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() ?
//if(frcount == 0) Console.WriteLine("PID " + m_primName);
// 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()
@@ -1739,7 +1760,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
{
@@ -1748,8 +1769,46 @@ 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;
@@ -2782,6 +2841,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; } }

View File

@@ -304,6 +304,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)
{

View File

@@ -299,6 +299,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)
{

View File

@@ -498,6 +498,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)
{
@@ -780,6 +802,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)
{

View File

@@ -2698,11 +2698,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)
@@ -3046,12 +3056,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);