Merge branch 'master' into careminster

avinationmerge
Melanie 2013-07-04 22:32:58 +01:00
commit 5ddcc25ee9
31 changed files with 398 additions and 190 deletions

View File

@ -50,6 +50,7 @@ namespace OpenSim.Data
public interface IGridUserData
{
GridUserData Get(string userID);
GridUserData[] GetAll(string query);
bool Store(GridUserData data);
}
}

View File

@ -50,7 +50,7 @@ namespace OpenSim.Data.MSSQL
{
}
public GridUserData Get(string userID)
public new GridUserData Get(string userID)
{
GridUserData[] ret = Get("UserID", userID);
@ -60,5 +60,10 @@ namespace OpenSim.Data.MSSQL
return ret[0];
}
public GridUserData[] GetAll(string userID)
{
return base.Get(String.Format("UserID LIKE '{0}%'", userID));
}
}
}

View File

@ -46,7 +46,7 @@ namespace OpenSim.Data.MySQL
public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {}
public GridUserData Get(string userID)
public new GridUserData Get(string userID)
{
GridUserData[] ret = Get("UserID", userID);
@ -56,6 +56,9 @@ namespace OpenSim.Data.MySQL
return ret[0];
}
public GridUserData[] GetAll(string userID)
{
return base.Get(String.Format("UserID LIKE '{0}%'", userID));
}
}
}

View File

@ -9,7 +9,7 @@ CREATE TABLE `Friends` (
`Offered` VARCHAR(32) NOT NULL DEFAULT 0,
PRIMARY KEY(`PrincipalID`, `Friend`),
KEY(`PrincipalID`)
);
) ENGINE=InnoDB;
COMMIT;

View File

@ -56,6 +56,10 @@ namespace OpenSim.Data.SQLite
return ret[0];
}
public GridUserData[] GetAll(string userID)
{
return base.Get(String.Format("UserID LIKE '{0}%'", userID));
}
}
}

View File

@ -226,18 +226,6 @@ namespace OpenSim
"Force the update of all objects on clients",
HandleForceUpdate);
m_console.Commands.AddCommand("Debug", false, "debug packet",
"debug packet <level> [<avatar-first-name> <avatar-last-name>]",
"Turn on packet debugging",
"If level > 255 then all incoming and outgoing packets are logged.\n"
+ "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n"
+ "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n"
+ "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n"
+ "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n"
+ "If level <= 0 then no packets are logged.\n"
+ "If an avatar name is given then only packets from that avatar are logged",
Debug);
m_console.Commands.AddCommand("General", false, "change region",
"change region <region name>",
"Change current console region", ChangeSelectedRegion);
@ -701,45 +689,6 @@ namespace OpenSim
RefreshPrompt();
}
/// <summary>
/// Turn on some debugging values for OpenSim.
/// </summary>
/// <param name="args"></param>
protected void Debug(string module, string[] args)
{
if (args.Length == 1)
return;
switch (args[1])
{
case "packet":
string name = null;
if (args.Length == 5)
name = string.Format("{0} {1}", args[3], args[4]);
if (args.Length > 2)
{
int newDebug;
if (int.TryParse(args[2], out newDebug))
{
SceneManager.SetDebugPacketLevelOnCurrentScene(newDebug, name);
// We provide user information elsewhere if any clients had their debug level set.
// MainConsole.Instance.OutputFormat("Debug packet level set to {0}", newDebug);
}
else
{
MainConsole.Instance.Output("Usage: debug packet 0..255");
}
}
break;
default:
MainConsole.Instance.Output("Unknown debug command");
break;
}
}
// see BaseOpenSimServer
/// <summary>
/// Many commands list objects for debugging. Some of the types are listed here

View File

@ -424,7 +424,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// foreign user is visiting, we need to try again after the first fail to the local
// asset service.
string assetServerURL = string.Empty;
if (InventoryAccessModule.IsForeignUser(AgentID, out assetServerURL))
if (InventoryAccessModule.IsForeignUser(AgentID, out assetServerURL) && !string.IsNullOrEmpty(assetServerURL))
{
if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("="))
assetServerURL = assetServerURL + "/";

View File

@ -34,6 +34,7 @@ using System.Net.Sockets;
using System.Reflection;
using System.Threading;
using log4net;
using NDesk.Options;
using Nini.Config;
using OpenMetaverse.Packets;
using OpenSim.Framework;
@ -102,10 +103,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// </summary>
public class LLUDPServer : OpenSimUDPBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>Maximum transmission unit, or UDP packet size, for the LLUDP protocol</summary>
public const int MTU = 1400;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Default packet debug level given to new clients
/// </summary>
public int DefaultClientPacketDebugLevel { get; set; }
/// <summary>The measured resolution of Environment.TickCount</summary>
public readonly float TickCountResolution;
@ -515,6 +521,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (UsePools)
EnablePoolStats();
MainConsole.Instance.Commands.AddCommand(
"Debug", false, "debug lludp packet",
"debug lludp packet [--default] <level> [<avatar-first-name> <avatar-last-name>]",
"Turn on packet debugging",
"If level > 255 then all incoming and outgoing packets are logged.\n"
+ "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n"
+ "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n"
+ "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n"
+ "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n"
+ "If level <= 0 then no packets are logged.\n"
+ "If --default is specified then the level becomes the default logging level for all subsequent agents.\n"
+ "In this case, you cannot also specify an avatar name.\n"
+ "If an avatar name is given then only packets from that avatar are logged.",
HandlePacketCommand);
MainConsole.Instance.Commands.AddCommand(
"Debug",
false,
@ -556,8 +577,68 @@ namespace OpenSim.Region.ClientStack.LindenUDP
HandleStatusCommand);
}
private void HandlePacketCommand(string module, string[] args)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
bool setAsDefaultLevel = false;
OptionSet optionSet = new OptionSet().Add("default", o => setAsDefaultLevel = o != null);
List<string> filteredArgs = optionSet.Parse(args);
string name = null;
if (filteredArgs.Count == 6)
{
if (!setAsDefaultLevel)
{
name = string.Format("{0} {1}", filteredArgs[4], filteredArgs[5]);
}
else
{
MainConsole.Instance.OutputFormat("ERROR: Cannot specify a user name when setting default logging level");
return;
}
}
if (filteredArgs.Count > 3)
{
int newDebug;
if (int.TryParse(filteredArgs[3], out newDebug))
{
if (setAsDefaultLevel)
{
DefaultClientPacketDebugLevel = newDebug;
MainConsole.Instance.OutputFormat(
"Debug packet debug for new clients set to {0}", DefaultClientPacketDebugLevel);
}
else
{
m_scene.ForEachScenePresence(sp =>
{
if (name == null || sp.Name == name)
{
MainConsole.Instance.OutputFormat(
"Packet debug for {0} ({1}) set to {2} in {3}",
sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_scene.Name);
sp.ControllingClient.DebugPacketLevel = newDebug;
}
});
}
}
else
{
MainConsole.Instance.Output("Usage: debug lludp packet [--default] 0..255 [<first-name> <last-name>]");
}
}
}
private void HandleStartCommand(string module, string[] args)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
if (args.Length != 4)
{
MainConsole.Instance.Output("Usage: debug lludp start <in|out|all>");
@ -575,6 +656,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void HandleStopCommand(string module, string[] args)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
if (args.Length != 4)
{
MainConsole.Instance.Output("Usage: debug lludp stop <in|out|all>");
@ -592,6 +676,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void HandlePoolCommand(string module, string[] args)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
if (args.Length != 4)
{
MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
@ -624,6 +711,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void HandleStatusCommand(string module, string[] args)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
MainConsole.Instance.OutputFormat(
"IN LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningInbound ? "enabled" : "disabled");
@ -631,6 +721,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
"OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled");
MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_scene.Name, UsePools ? "on" : "off");
MainConsole.Instance.OutputFormat(
"Packet debug level for new clients is {0}", DefaultClientPacketDebugLevel);
}
public bool HandlesRegion(Location x)
@ -1544,6 +1637,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler;
client.DebugPacketLevel = DefaultClientPacketDebugLevel;
((LLClientView)client).DisableFacelights = m_disableFacelights;

View File

@ -498,6 +498,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
{
m_log.DebugFormat("[FRIENDS]: Entering StatusNotify for {0}", userID);
List<string> friendStringIds = friendList.ConvertAll<string>(friend => friend.Friend);
List<string> remoteFriendStringIds = new List<string>();
foreach (string friendStringId in friendStringIds)
@ -523,12 +525,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
foreach (PresenceInfo friendSession in friendSessions)
{
// let's guard against sessions-gone-bad
if (friendSession.RegionID != UUID.Zero)
if (friendSession != null && friendSession.RegionID != UUID.Zero)
{
m_log.DebugFormat("[FRIENDS]: Get region {0}", friendSession.RegionID);
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
//m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName);
m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online);
if (region != null)
{
m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online);
}
}
else
m_log.DebugFormat("[FRIENDS]: friend session is null or the region is UUID.Zero");
}
}

View File

@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
{
// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID);
m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID);
// First, let's divide the friends on a per-domain basis
Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>();
@ -348,31 +348,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
return null;
}
// public override FriendInfo[] GetFriendsFromService(IClientAPI client)
// {
//// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name);
// Boolean agentIsLocal = true;
// if (UserManagementModule != null)
// agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId);
public override FriendInfo[] GetFriendsFromService(IClientAPI client)
{
// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name);
Boolean agentIsLocal = true;
if (UserManagementModule != null)
agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId);
// if (agentIsLocal)
// return base.GetFriendsFromService(client);
if (agentIsLocal)
return base.GetFriendsFromService(client);
// FriendInfo[] finfos = new FriendInfo[0];
// // Foreigner
// AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
// if (agentClientCircuit != null)
// {
// //[XXX] string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
FriendInfo[] finfos = new FriendInfo[0];
// Foreigner
AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
if (agentClientCircuit != null)
{
// Note that this is calling a different interface than base; this one calls with a string param!
finfos = FriendsService.GetFriends(client.AgentId.ToString());
m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, client.AgentId.ToString());
}
// finfos = FriendsService.GetFriends(client.AgentId.ToString());
// m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, client.AgentId.ToString());
// }
// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name);
//// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name);
// return finfos;
// }
return finfos;
}
protected override bool StoreRights(UUID agentID, UUID friendID, int rights)
{

View File

@ -73,6 +73,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
private AssetMetadata FetchMetadata(string url, UUID assetID)
{
if (string.IsNullOrEmpty(url))
return null;
if (!url.EndsWith("/") && !url.EndsWith("="))
url = url + "/";
@ -92,6 +95,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
if (asset == null)
{
if (string.IsNullOrEmpty(url))
return null;
if (!url.EndsWith("/") && !url.EndsWith("="))
url = url + "/";
@ -109,6 +115,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
public bool PostAsset(string url, AssetBase asset)
{
if (string.IsNullOrEmpty(url))
return false;
if (asset != null)
{
if (!url.EndsWith("/") && !url.EndsWith("="))

View File

@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
{
m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
//if (fromTaskID.Equals(UUID.Zero))
//{
@ -297,7 +297,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (m_Scene.TryGetScenePresence(userID, out sp))
{
AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
{
assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString();
assetServerURL = assetServerURL.Trim(new char[] { '/' });

View File

@ -135,7 +135,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); });
}
void EventManager_OnNewClient(IClientAPI client)
{
client.OnConnectionClosed += new Action<IClientAPI>(HandleConnectionClosed);
@ -151,6 +150,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
{
// m_log.DebugFormat(
// "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}",
// uuid, remote_client.Name);
if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid))
{
remote_client.SendNameReply(uuid, "Mr", "OpenSim");
@ -319,8 +322,34 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
}
else
{
// Let's try the GridUser service
GridUserInfo uInfo = m_Scenes[0].GridUserService.GetGridUserInfo(uuid.ToString());
if (uInfo != null)
{
string url, first, last, tmp;
UUID u;
if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out u, out url, out first, out last, out tmp))
{
AddUser(uuid, first, last, url);
if (m_UserCache.ContainsKey(uuid))
{
names[0] = m_UserCache[uuid].FirstName;
names[1] = m_UserCache[uuid].LastName;
return true;
}
}
else
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID);
}
else
{
m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid);
}
names[0] = "Unknown";
names[1] = "UserUMMTGUN3";
names[1] = "UserUMMTGUN7";
return false;
}
@ -474,7 +503,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
//m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
UserData oldUser;
//lock the whole block - prevent concurrent update
lock (m_UserCache)
m_UserCache.TryGetValue(id, out oldUser);
@ -512,7 +540,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
UserData user = new UserData();
user.Id = id;
if (creatorData != null && creatorData != string.Empty)
if (!string.IsNullOrEmpty(creatorData))
{
//creatorData = <endpoint>;<name>
@ -536,8 +564,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
}
else
{
// Temporarily add unknown user entries of this type into the cache so that we can distinguish
// this source from other recent (hopefully resolved) bugs that fail to retrieve a user name binding
// TODO: Can be removed when GUN* unknown users have definitely dropped significantly or
// disappeared.
user.FirstName = "Unknown";
user.LastName = "UserUMMAU";
user.LastName = "UserUMMAU3";
}
AddUserInternal(user);

View File

@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
{
ConsoleDisplayList cdl = new ConsoleDisplayList();
cdl.AddRow("Name", so.Name);
cdl.AddRow("Descrition", so.Description);
cdl.AddRow("Description", so.Description);
cdl.AddRow("Local ID", so.LocalId);
cdl.AddRow("UUID", so.UUID);
cdl.AddRow("Location", string.Format("{0} @ {1}", so.AbsolutePosition, so.Scene.Name));

View File

@ -5091,6 +5091,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RegionHandleRequest(IClientAPI client, UUID regionID)
{
m_log.DebugFormat("[SCENE]: RegionHandleRequest {0}", regionID);
ulong handle = 0;
if (regionID == RegionInfo.RegionID)
handle = RegionInfo.RegionHandle;

View File

@ -420,29 +420,6 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
/// <summary>
/// Set the debug packet level on each current scene. This level governs which packets are printed out to the
/// console.
/// </summary>
/// <param name="newDebug"></param>
/// <param name="name">Name of avatar to debug</param>
public void SetDebugPacketLevelOnCurrentScene(int newDebug, string name)
{
ForEachSelectedScene(scene =>
scene.ForEachScenePresence(sp =>
{
if (name == null || sp.Name == name)
{
m_log.DebugFormat(
"Packet debug for {0} ({1}) set to {2}",
sp.Name, sp.IsChildAgent ? "child" : "root", newDebug);
sp.ControllingClient.DebugPacketLevel = newDebug;
}
})
);
}
public List<ScenePresence> GetCurrentSceneAvatars()
{
List<ScenePresence> avatars = new List<ScenePresence>();

View File

@ -50,7 +50,8 @@ public class BSActorMoveToTarget : BSActor
// BSActor.isActive
public override bool isActive
{
get { return Enabled; }
// MoveToTarget only works on physical prims
get { return Enabled && m_controllingPrim.IsPhysicallyActive; }
}
// Release any connections and resources used by the actor.
@ -102,16 +103,28 @@ public class BSActorMoveToTarget : BSActor
// We're taking over after this.
m_controllingPrim.ZeroMotion(true);
m_targetMotor = new BSVMotor("BSActorMoveToTargget.Activate",
m_controllingPrim.MoveToTargetTau, // timeScale
BSMotor.Infinite, // decay time scale
1f // efficiency
/* Someday use the PID controller
m_targetMotor = new BSPIDVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString());
m_targetMotor.TimeScale = m_controllingPrim.MoveToTargetTau;
m_targetMotor.Efficiency = 1f;
*/
m_targetMotor = new BSVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString(),
m_controllingPrim.MoveToTargetTau, // timeScale
BSMotor.Infinite, // decay time scale
1f // efficiency
);
m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages.
m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget);
m_targetMotor.SetCurrent(m_controllingPrim.RawPosition);
m_physicsScene.BeforeStep += Mover;
// m_physicsScene.BeforeStep += Mover;
m_physicsScene.BeforeStep += Mover2;
}
else
{
// If already allocated, make sure the target and other paramters are current
m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget);
m_targetMotor.SetCurrent(m_controllingPrim.RawPosition);
}
}
@ -119,12 +132,16 @@ public class BSActorMoveToTarget : BSActor
{
if (m_targetMotor != null)
{
m_physicsScene.BeforeStep -= Mover;
// m_physicsScene.BeforeStep -= Mover;
m_physicsScene.BeforeStep -= Mover2;
m_targetMotor = null;
}
}
// Called just before the simulation step. Update the vertical position for hoverness.
// Origional mover that set the objects position to move to the target.
// The problem was that gravity would keep trying to push the object down so
// the overall downward velocity would increase to infinity.
// Called just before the simulation step.
private void Mover(float timeStep)
{
// Don't do hovering while the object is selected.
@ -142,6 +159,7 @@ public class BSActorMoveToTarget : BSActor
m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,zeroMovement,movePos={1},pos={2},mass={3}",
m_controllingPrim.LocalID, movePosition, m_controllingPrim.RawPosition, m_controllingPrim.Mass);
m_controllingPrim.ForcePosition = m_targetMotor.TargetValue;
m_controllingPrim.ForceVelocity = OMV.Vector3.Zero;
// Setting the position does not cause the physics engine to generate a property update. Force it.
m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
}
@ -151,7 +169,51 @@ public class BSActorMoveToTarget : BSActor
// Setting the position does not cause the physics engine to generate a property update. Force it.
m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
}
m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,move,fromPos={1},movePos={2}", m_controllingPrim.LocalID, origPosition, movePosition);
m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,move,fromPos={1},movePos={2}",
m_controllingPrim.LocalID, origPosition, movePosition);
}
// Version of mover that applies forces to move the physical object to the target.
// Also overcomes gravity so the object doesn't just drop to the ground.
// Called just before the simulation step.
private void Mover2(float timeStep)
{
// Don't do hovering while the object is selected.
if (!isActive)
return;
OMV.Vector3 origPosition = m_controllingPrim.RawPosition; // DEBUG DEBUG (for printout below)
OMV.Vector3 addedForce = OMV.Vector3.Zero;
// CorrectionVector is the movement vector required this step
OMV.Vector3 correctionVector = m_targetMotor.Step(timeStep, m_controllingPrim.RawPosition);
// If we are very close to our target, turn off the movement motor.
if (m_targetMotor.ErrorIsZero())
{
m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover3,zeroMovement,pos={1},mass={2}",
m_controllingPrim.LocalID, m_controllingPrim.RawPosition, m_controllingPrim.Mass);
m_controllingPrim.ForcePosition = m_targetMotor.TargetValue;
m_controllingPrim.ForceVelocity = OMV.Vector3.Zero;
// Setting the position does not cause the physics engine to generate a property update. Force it.
m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
}
else
{
// First force to move us there -- the motor return a timestep scaled value.
addedForce = correctionVector / timeStep;
// Remove the existing velocity (only the moveToTarget force counts)
addedForce -= m_controllingPrim.RawVelocity;
// Overcome gravity.
addedForce -= m_controllingPrim.Gravity;
// Add enough force to overcome the mass of the object
addedForce *= m_controllingPrim.Mass;
m_controllingPrim.AddForce(addedForce, false /* pushForce */, true /* inTaintTime */);
}
m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover3,move,fromPos={1},addedForce={2}",
m_controllingPrim.LocalID, origPosition, addedForce);
}
}
}

View File

@ -626,7 +626,7 @@ public sealed class BSCharacter : BSPhysObject
OMV.Vector3 addForce = force / PhysScene.LastTimeStep;
AddForce(addForce, pushforce, false);
}
private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
public override void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
if (force.IsFinite())
{
OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);

View File

@ -1276,7 +1276,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
VehicleAddForce(appliedGravity);
VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={3}",
VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}",
ControllingPrim.LocalID, m_VehicleGravity,
ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity);
}

View File

@ -33,14 +33,6 @@ using OMV = OpenMetaverse;
namespace OpenSim.Region.Physics.BulletSPlugin
{
// A BSPrim can get individual information about its linkedness attached
// to it through an instance of a subclass of LinksetInfo.
// Each type of linkset will define the information needed for its type.
public abstract class BSLinksetInfo
{
public virtual void Clear() { }
}
public abstract class BSLinkset
{
// private static string LogHeader = "[BULLETSIM LINKSET]";
@ -56,15 +48,15 @@ public abstract class BSLinkset
{
BSLinkset ret = null;
switch ((int)BSParam.LinksetImplementation)
switch (parent.LinksetType)
{
case (int)LinksetImplementation.Constraint:
case LinksetImplementation.Constraint:
ret = new BSLinksetConstraints(physScene, parent);
break;
case (int)LinksetImplementation.Compound:
case LinksetImplementation.Compound:
ret = new BSLinksetCompound(physScene, parent);
break;
case (int)LinksetImplementation.Manual:
case LinksetImplementation.Manual:
// ret = new BSLinksetManual(physScene, parent);
break;
default:

View File

@ -238,7 +238,6 @@ public sealed class BSLinksetCompound : BSLinkset
// there will already be a rebuild scheduled.
DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}",
updated.LocalID, whichUpdated);
updated.LinksetInfo = null; // setting to 'null' causes relative position to be recomputed.
ScheduleRebuild(updated);
}
}
@ -294,7 +293,6 @@ public sealed class BSLinksetCompound : BSLinkset
child.LocalID, child.PhysBody.AddrString);
// Cause the child's body to be rebuilt and thus restored to normal operation
child.LinksetInfo = null;
child.ForceBodyShapeRebuild(false);
if (!HasAnyChildren)

View File

@ -144,7 +144,6 @@ public class BSVMotor : BSMotor
Vector3 correction = Vector3.Zero;
Vector3 error = TargetValue - CurrentValue;
LastError = error;
if (!ErrorIsZero(error))
{
correction = StepError(timeStep, error);
@ -179,6 +178,7 @@ public class BSVMotor : BSMotor
MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}",
BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue);
}
LastError = error;
return correction;
}
@ -293,7 +293,6 @@ public class BSFMotor : BSMotor
float correction = 0f;
float error = TargetValue - CurrentValue;
LastError = error;
if (!ErrorIsZero(error))
{
correction = StepError(timeStep, error);
@ -328,6 +327,7 @@ public class BSFMotor : BSMotor
MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}",
BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue);
}
LastError = error;
return CurrentValue;
}
@ -363,7 +363,7 @@ public class BSFMotor : BSMotor
// ============================================================================
// ============================================================================
// Proportional, Integral, Derivitive Motor
// Proportional, Integral, Derivitive ("PID") Motor
// Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors.
public class BSPIDVMotor : BSVMotor
{
@ -434,15 +434,14 @@ public class BSPIDVMotor : BSVMotor
// A simple derivitive is the rate of change from the last error.
Vector3 derivitive = (error - LastError) * timeStep;
LastError = error;
// Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError)
Vector3 ret = error * timeStep * proportionFactor * FactorMix.X
+ RunningIntegration * integralFactor * FactorMix.Y
+ derivitive * derivFactor * FactorMix.Z
Vector3 ret = error / TimeScale * timeStep * proportionFactor * FactorMix.X
+ RunningIntegration / TimeScale * integralFactor * FactorMix.Y
+ derivitive / TimeScale * derivFactor * FactorMix.Z
;
MDetailLog("{0},BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}",
MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}",
BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret);
return ret;

View File

@ -706,7 +706,7 @@ public static class BSParam
new ParameterDefn<float>("ResetBroadphasePool", "Setting this is any value resets the broadphase collision pool",
0f,
(s) => { return 0f; },
(s,v) => { BSParam.ResetBroadphasePoolTainted(s, v); } ),
(s,v) => { BSParam.ResetBroadphasePoolTainted(s, v, false /* inTaintTime */); } ),
new ParameterDefn<float>("ResetConstraintSolver", "Setting this is any value resets the constraint solver",
0f,
(s) => { return 0f; },
@ -792,10 +792,10 @@ public static class BSParam
// =====================================================================
// There are parameters that, when set, cause things to happen in the physics engine.
// This causes the broadphase collision cache to be cleared.
private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v)
private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v, bool inTaintTime)
{
BSScene physScene = pPhysScene;
physScene.TaintedObject("BSParam.ResetBroadphasePoolTainted", delegate()
physScene.TaintedObject(inTaintTime, "BSParam.ResetBroadphasePoolTainted", delegate()
{
physScene.PE.ResetBroadphasePool(physScene.World);
});

View File

@ -210,6 +210,7 @@ public abstract class BSPhysObject : PhysicsActor
AddAngularForce(force, pushforce, false);
}
public abstract void AddAngularForce(OMV.Vector3 force, bool pushforce, bool inTaintTime);
public abstract void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime);
public abstract OMV.Vector3 ForceRotationalVelocity { get; set; }

View File

@ -70,18 +70,17 @@ public class BSPrim : BSPhysObject
private int CrossingFailures { get; set; }
// Keep a handle to the vehicle actor so it is easy to set parameters on same.
public BSDynamics VehicleActor;
public const string VehicleActorName = "BasicVehicle";
// Parameters for the hover actor
public const string HoverActorName = "HoverActor";
public const string HoverActorName = "BSPrim.HoverActor";
// Parameters for the axis lock actor
public const String LockedAxisActorName = "BSPrim.LockedAxis";
// Parameters for the move to target actor
public const string MoveToTargetActorName = "MoveToTargetActor";
public const string MoveToTargetActorName = "BSPrim.MoveToTargetActor";
// Parameters for the setForce and setTorque actors
public const string SetForceActorName = "SetForceActor";
public const string SetTorqueActorName = "SetTorqueActor";
public const string SetForceActorName = "BSPrim.SetForceActor";
public const string SetTorqueActorName = "BSPrim.SetTorqueActor";
public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
@ -100,9 +99,8 @@ public class BSPrim : BSPhysObject
_isPhysical = pisPhysical;
_isVolumeDetect = false;
// We keep a handle to the vehicle actor so we can set vehicle parameters later.
VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName);
PhysicalActors.Add(VehicleActorName, VehicleActor);
// Add a dynamic vehicle to our set of actors that can move this prim.
PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName));
_mass = CalculateMass();
@ -450,6 +448,9 @@ public class BSPrim : BSPhysObject
Gravity = ComputeGravity(Buoyancy);
PhysScene.PE.SetGravity(PhysBody, Gravity);
OMV.Vector3 currentScale = PhysScene.PE.GetLocalScaling(PhysShape.physShapeInfo); // DEBUG DEBUG
DetailLog("{0},BSPrim.UpdateMassProperties,currentScale{1},shape={2}", LocalID, currentScale, PhysShape.physShapeInfo); // DEBUG DEBUG
Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass);
PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia);
PhysScene.PE.UpdateInertiaTensor(PhysBody);
@ -502,9 +503,25 @@ public class BSPrim : BSPhysObject
}
}
// Find and return a handle to the current vehicle actor.
// Return 'null' if there is no vehicle actor.
public BSDynamics GetVehicleActor()
{
BSDynamics ret = null;
BSActor actor;
if (PhysicalActors.TryGetActor(VehicleActorName, out actor))
{
ret = actor as BSDynamics;
}
return ret;
}
public override int VehicleType {
get {
return (int)VehicleActor.Type;
int ret = (int)Vehicle.TYPE_NONE;
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
ret = (int)vehicleActor.Type;
return ret;
}
set {
Vehicle type = (Vehicle)value;
@ -515,8 +532,12 @@ public class BSPrim : BSPhysObject
// change all the parameters. Like a plane changing to CAR when on the
// ground. In this case, don't want to zero motion.
// ZeroMotion(true /* inTaintTime */);
VehicleActor.ProcessTypeChange(type);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessTypeChange(type);
ActivateIfPhysical(false);
}
});
}
}
@ -524,31 +545,47 @@ public class BSPrim : BSPhysObject
{
PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
{
VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
}
});
}
public override void VehicleVectorParam(int param, OMV.Vector3 value)
{
PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
{
VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
}
});
}
public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
{
PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
{
VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
ActivateIfPhysical(false);
}
});
}
public override void VehicleFlags(int param, bool remove)
{
PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate()
{
VehicleActor.ProcessVehicleFlags(param, remove);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessVehicleFlags(param, remove);
}
});
}
@ -1040,6 +1077,20 @@ public class BSPrim : BSPhysObject
}
}
public override OMV.Vector3 PIDTarget
{
set
{
base.PIDTarget = value;
BSActor actor;
if (PhysicalActors.TryGetActor(MoveToTargetActorName, out actor))
{
// if the actor exists, tell it to refresh its values.
actor.Refresh();
}
}
}
// Used for llSetHoverHeight and maybe vehicle height
// Hover Height will override MoveTo target's Z
public override bool PIDHoverActive {
@ -1063,7 +1114,7 @@ public class BSPrim : BSPhysObject
// Applying a force just adds this to the total force on the object.
// This added force will only last the next simulation tick.
public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
public override void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
// for an object, doesn't matter if force is a pushforce or not
if (IsPhysicallyActive)
{

View File

@ -41,12 +41,15 @@ public class BSPrimLinkable : BSPrimDisplaced
// The index of this child prim.
public int LinksetChildIndex { get; set; }
public BSLinksetInfo LinksetInfo { get; set; }
public BSLinkset.LinksetImplementation LinksetType { get; set; }
public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
: base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
{
// Default linkset implementation for this prim
LinksetType = (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation;
Linkset = BSLinkset.Factory(PhysScene, this);
PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()

View File

@ -223,8 +223,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// can be left in and every call doesn't have to check for null.
if (m_physicsLoggingEnabled)
{
PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes);
PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output error messages.
PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush);
PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages.
}
else
{
@ -1106,8 +1106,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
public void DetailLog(string msg, params Object[] args)
{
PhysicsLogging.Write(msg, args);
// Add the Flush() if debugging crashes. Gets all the messages written out.
if (m_physicsLoggingDoFlush) PhysicsLogging.Flush();
}
// Used to fill in the LocalID when there isn't one. It's the correct number of characters.
public const string DetailLogZero = "0000000000";

View File

@ -114,21 +114,25 @@ public class BasicVehicles : OpenSimTestCase
// Instead the appropriate values are set and calls are made just the parts of the
// controller we want to exercise. Stepping the physics engine then applies
// the actions of that one feature.
TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
TestVehicle.VehicleActor.enableAngularVerticalAttraction = true;
TestVehicle.IsPhysical = true;
PhysicsScene.ProcessTaints();
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
for (int ii = 0; ii < simSteps; ii++)
BSDynamics vehicleActor = TestVehicle.GetVehicleActor();
if (vehicleActor != null)
{
TestVehicle.VehicleActor.ForgetKnownVehicleProperties();
TestVehicle.VehicleActor.ComputeAngularVerticalAttraction();
TestVehicle.VehicleActor.PushKnownChanged();
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
vehicleActor.enableAngularVerticalAttraction = true;
PhysicsScene.Simulate(simulationTimeStep);
TestVehicle.IsPhysical = true;
PhysicsScene.ProcessTaints();
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
for (int ii = 0; ii < simSteps; ii++)
{
vehicleActor.ForgetKnownVehicleProperties();
vehicleActor.ComputeAngularVerticalAttraction();
vehicleActor.PushKnownChanged();
PhysicsScene.Simulate(simulationTimeStep);
}
}
TestVehicle.IsPhysical = false;

View File

@ -185,10 +185,12 @@ namespace OpenSim.Server.Handlers.GridUser
GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(user);
Dictionary<string, object> result = new Dictionary<string, object>();
result["result"] = guinfo.ToKeyValuePairs();
if (guinfo != null)
result["result"] = guinfo.ToKeyValuePairs();
else
result["result"] = "null";
string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID USER HANDLER]: resp string: {0}", xmlString);
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
}

View File

@ -46,12 +46,28 @@ namespace OpenSim.Services.UserAccountService
public GridUserService(IConfigSource config) : base(config)
{
m_log.Debug("[USER GRID SERVICE]: Starting user grid service");
m_log.Debug("[GRID USER SERVICE]: Starting user grid service");
}
public virtual GridUserInfo GetGridUserInfo(string userID)
{
GridUserData d = m_Database.Get(userID);
GridUserData d = null;
if (userID.Length > 36) // it's a UUI
d = m_Database.Get(userID);
else // it's a UUID
{
GridUserData[] ds = m_Database.GetAll(userID);
if (ds == null)
return null;
if (ds.Length > 0)
{
d = ds[0];
foreach (GridUserData dd in ds)
if (dd.UserID.Length > d.UserID.Length) // find the longest
d = dd;
}
}
if (d == null)
return null;

View File

@ -1602,6 +1602,7 @@
<Reference name="System.Drawing"/>
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="NDesk.Options" path="../../../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../../../bin/"/>