Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim

This commit is contained in:
Melanie
2013-06-23 01:49:45 +01:00
38 changed files with 967 additions and 961 deletions

View File

@@ -124,6 +124,7 @@ namespace OpenSim
workerThreads = workerThreadsMax;
m_log.InfoFormat("[OPENSIM MAIN]: Limiting worker threads to {0}",workerThreads);
}
// Increase the number of IOCP threads available.
// Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17)
if (iocpThreads < iocpThreadsMin)

View File

@@ -372,7 +372,7 @@ namespace OpenSim
"Unload a module", HandleModules);
}
public override void ShutdownSpecific()
protected override void ShutdownSpecific()
{
if (m_shutdownCommandsFile != String.Empty)
{

View File

@@ -231,10 +231,7 @@ namespace OpenSim
}
if (m_console != null)
{
StatsManager.RegisterConsoleCommands(m_console);
AddPluginCommands(m_console);
}
}
protected virtual void AddPluginCommands(ICommandConsole console)
@@ -880,7 +877,7 @@ namespace OpenSim
/// <summary>
/// Performs any last-minute sanity checking and shuts down the region server
/// </summary>
public override void ShutdownSpecific()
protected override void ShutdownSpecific()
{
if (proxyUrl.Length > 0)
{
@@ -900,6 +897,8 @@ namespace OpenSim
{
m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e);
}
base.ShutdownSpecific();
}
/// <summary>

View File

@@ -34,6 +34,7 @@ using log4net;
using Nini.Config;
using Mono.Addins;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
using OpenSim.Framework.Servers;
@@ -44,8 +45,6 @@ using OpenSim.Framework.Capabilities;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using OpenSim.Capabilities.Handlers;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Region.ClientStack.Linden
{
@@ -64,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden
public List<UUID> folders;
}
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;

View File

@@ -33,6 +33,7 @@ using NUnit.Framework;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
@@ -69,6 +70,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{
base.SetUp();
m_scene = new SceneHelpers().SetupScene();
StatsManager.SimExtraStats = new SimExtraStatsCollector();
}
/// <summary>
@@ -210,8 +212,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID);
Assert.That(spAfterAckTimeout, Is.Null);
// TestHelpers.DisableLogging();
}
// /// <summary>

View File

@@ -182,7 +182,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
"POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
if (msglist == null)
{
m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list.");
return;
}
foreach (GridInstantMessage im in msglist)
{

View File

@@ -53,8 +53,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private int m_levelHGTeleport = 0;
private string m_ThisHomeURI;
private GatekeeperServiceConnector m_GatekeeperConnector;
private IUserAgentService m_UAS;
protected bool m_RestrictAppearanceAbroad;
protected string m_AccountName;
@@ -143,6 +145,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
}
}
moduleConfig = source.Configs["Hypergrid"];
if (moduleConfig != null)
{
m_ThisHomeURI = moduleConfig.GetString("HomeURI", string.Empty);
if (m_ThisHomeURI != string.Empty && !m_ThisHomeURI.EndsWith("/"))
m_ThisHomeURI += '/';
}
}
public override void AddRegion(Scene scene)
@@ -194,7 +204,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
base.RegionLoaded(scene);
if (m_Enabled)
{
m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
m_UAS = scene.RequestModuleInterface<IUserAgentService>();
}
}
public override void RemoveRegion(Scene scene)
@@ -272,8 +285,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (agentCircuit.ServiceURLs.ContainsKey("HomeURI"))
{
string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver);
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
IUserAgentService connector;
if (userAgentDriver.Equals(m_ThisHomeURI) && m_UAS != null)
connector = m_UAS;
else
connector = new UserAgentServiceConnector(userAgentDriver);
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, false, out reason);
logout = success; // flag for later logout from this grid; this is an HG TP
if (success)

View File

@@ -194,7 +194,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return false;
// Try local first
if (m_localBackend.IsLocalRegion(destination.RegionHandle))
if (m_localBackend.IsLocalRegion(destination.RegionID))
return m_localBackend.UpdateAgent(destination, cAgentData);
return m_remoteConnector.UpdateAgent(destination, cAgentData);
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return false;
// Try local first
if (m_localBackend.IsLocalRegion(destination.RegionHandle))
if (m_localBackend.IsLocalRegion(destination.RegionID))
return m_localBackend.UpdateAgent(destination, cAgentData);
return m_remoteConnector.UpdateAgent(destination, cAgentData);
@@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return true;
// else do the remote thing
if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
if (!m_localBackend.IsLocalRegion(destination.RegionID))
return m_remoteConnector.RetrieveAgent(destination, id, out agent);
return false;
@@ -273,7 +273,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
return true;
// else do the remote thing
if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
if (!m_localBackend.IsLocalRegion(destination.RegionID))
return m_remoteConnector.CloseAgent(destination, id);
return false;
@@ -296,7 +296,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
}
// else do the remote thing
if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
if (!m_localBackend.IsLocalRegion(destination.RegionID))
return m_remoteConnector.CreateObject(destination, newPosition, sog, isLocalCall);
return false;

View File

@@ -81,14 +81,14 @@ namespace OpenSim.Region.CoreModules.World.Land
set { m_landData = value; }
}
public IPrimCounts PrimCounts { get; set; }
public UUID RegionUUID
{
get { return m_scene.RegionInfo.RegionID; }
}
public Vector3 StartPoint
{
get
@@ -101,11 +101,11 @@ namespace OpenSim.Region.CoreModules.World.Land
return new Vector3(x * 4, y * 4, 0);
}
}
return new Vector3(-1, -1, -1);
}
}
}
public Vector3 EndPoint
{
get
@@ -116,15 +116,15 @@ namespace OpenSim.Region.CoreModules.World.Land
{
if (LandBitmap[x, y])
{
return new Vector3(x * 4, y * 4, 0);
}
return new Vector3(x * 4 + 4, y * 4 + 4, 0);
}
}
}
}
return new Vector3(-1, -1, -1);
}
}
#region Constructors
public LandObject(UUID owner_id, bool is_group_owned, Scene scene)

View File

@@ -326,7 +326,7 @@ namespace OpenSim.Region.Framework.Scenes
// Update item with new asset
item.AssetID = asset.FullID;
if (group.UpdateInventoryItem(item))
remoteClient.SendAgentAlertMessage("Script saved", false);
remoteClient.SendAlertMessage("Script saved");
part.SendPropertiesToClient(remoteClient);
@@ -342,7 +342,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
remoteClient.SendAgentAlertMessage("Script saved", false);
remoteClient.SendAlertMessage("Script saved");
}
// Tell anyone managing scripts that a script has been reloaded/changed
@@ -1616,11 +1616,11 @@ namespace OpenSim.Region.Framework.Scenes
remoteClient, part, transactionID, currentItem);
if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
remoteClient.SendAgentAlertMessage("Notecard saved", false);
remoteClient.SendAlertMessage("Notecard saved");
else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
remoteClient.SendAgentAlertMessage("Script saved", false);
remoteClient.SendAlertMessage("Script saved");
else
remoteClient.SendAgentAlertMessage("Item saved", false);
remoteClient.SendAlertMessage("Item saved");
}
// Base ALWAYS has move

View File

@@ -1,339 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenMetaverse.StructuredData;
namespace OpenSim.Region.OptionalModules.Framework.Monitoring
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ServerStatistics")]
public class ServerStats : ISharedRegionModule
{
private readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private readonly string LogHeader = "[SERVER STATS]";
public bool Enabled = false;
private static Dictionary<string, Stat> RegisteredStats = new Dictionary<string, Stat>();
public readonly string CategoryServer = "server";
public readonly string ContainerProcessor = "processor";
public readonly string ContainerMemory = "memory";
public readonly string ContainerNetwork = "network";
public readonly string ContainerProcess = "process";
public string NetworkInterfaceTypes = "Ethernet";
readonly int performanceCounterSampleInterval = 500;
int lastperformanceCounterSampleTime = 0;
private class PerfCounterControl
{
public PerformanceCounter perfCounter;
public int lastFetch;
public string name;
public PerfCounterControl(PerformanceCounter pPc)
: this(pPc, String.Empty)
{
}
public PerfCounterControl(PerformanceCounter pPc, string pName)
{
perfCounter = pPc;
lastFetch = 0;
name = pName;
}
}
PerfCounterControl processorPercentPerfCounter = null;
#region ISharedRegionModule
// IRegionModuleBase.Name
public string Name { get { return "Server Stats"; } }
// IRegionModuleBase.ReplaceableInterface
public Type ReplaceableInterface { get { return null; } }
// IRegionModuleBase.Initialize
public void Initialise(IConfigSource source)
{
IConfig cfg = source.Configs["Monitoring"];
if (cfg != null)
Enabled = cfg.GetBoolean("ServerStatsEnabled", true);
if (Enabled)
{
NetworkInterfaceTypes = cfg.GetString("NetworkInterfaceTypes", "Ethernet");
}
}
// IRegionModuleBase.Close
public void Close()
{
if (RegisteredStats.Count > 0)
{
foreach (Stat stat in RegisteredStats.Values)
{
StatsManager.DeregisterStat(stat);
stat.Dispose();
}
RegisteredStats.Clear();
}
}
// IRegionModuleBase.AddRegion
public void AddRegion(Scene scene)
{
}
// IRegionModuleBase.RemoveRegion
public void RemoveRegion(Scene scene)
{
}
// IRegionModuleBase.RegionLoaded
public void RegionLoaded(Scene scene)
{
}
// ISharedRegionModule.PostInitialize
public void PostInitialise()
{
if (RegisteredStats.Count == 0)
{
RegisterServerStats();
}
}
#endregion ISharedRegionModule
private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act)
{
string desc = pDesc;
if (desc == null)
desc = pName;
Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info);
StatsManager.RegisterStat(stat);
RegisteredStats.Add(pName, stat);
}
public void RegisterServerStats()
{
lastperformanceCounterSampleTime = Util.EnvironmentTickCount();
PerformanceCounter tempPC;
Stat tempStat;
string tempName;
try
{
tempName = "CPUPercent";
tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total");
processorPercentPerfCounter = new PerfCounterControl(tempPC);
// A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy.
tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor,
StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter, Util.IsWindows() ? 1 : -1); },
StatVerbosity.Info);
StatsManager.RegisterStat(tempStat);
RegisteredStats.Add(tempName, tempStat);
MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; });
MakeStat("UserProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; });
MakeStat("PrivilegedProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; });
MakeStat("Threads", null, "threads", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().Threads.Count; });
}
catch (Exception e)
{
m_log.ErrorFormat("{0} Exception creating 'Process': {1}", LogHeader, e);
}
try
{
List<string> okInterfaceTypes = new List<string>(NetworkInterfaceTypes.Split(','));
IEnumerable<NetworkInterface> nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface nic in nics)
{
if (nic.OperationalStatus != OperationalStatus.Up)
continue;
string nicInterfaceType = nic.NetworkInterfaceType.ToString();
if (!okInterfaceTypes.Contains(nicInterfaceType))
{
m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'.",
LogHeader, nic.Name, nicInterfaceType);
m_log.DebugFormat("{0} To include, add to comma separated list in [Monitoring]NetworkInterfaceTypes={1}",
LogHeader, NetworkInterfaceTypes);
continue;
}
if (nic.Supports(NetworkInterfaceComponent.IPv4))
{
IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics();
if (nicStats != null)
{
MakeStat("BytesRcvd/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); });
MakeStat("BytesSent/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); });
MakeStat("TotalBytes/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); });
}
}
// TODO: add IPv6 (it may actually happen someday)
}
}
catch (Exception e)
{
m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e);
}
MakeStat("ProcessMemory", null, "MB", ContainerMemory,
(s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; });
MakeStat("ObjectMemory", null, "MB", ContainerMemory,
(s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; });
MakeStat("LastMemoryChurn", null, "MB/sec", ContainerMemory,
(s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); });
MakeStat("AverageMemoryChurn", null, "MB/sec", ContainerMemory,
(s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); });
}
// Notes on performance counters:
// "How To Read Performance Counters": http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx
// "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c
// "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters
private delegate double PerfCounterNextValue();
private void GetNextValue(Stat stat, PerfCounterControl perfControl)
{
GetNextValue(stat, perfControl, 1.0);
}
private void GetNextValue(Stat stat, PerfCounterControl perfControl, double factor)
{
if (Util.EnvironmentTickCountSubtract(perfControl.lastFetch) > performanceCounterSampleInterval)
{
if (perfControl != null && perfControl.perfCounter != null)
{
try
{
// Kludge for factor to run double duty. If -1, subtract the value from one
if (factor == -1)
stat.Value = 1 - perfControl.perfCounter.NextValue();
else
stat.Value = perfControl.perfCounter.NextValue() / factor;
}
catch (Exception e)
{
m_log.ErrorFormat("{0} Exception on NextValue fetching {1}: {2}", LogHeader, stat.Name, e);
}
perfControl.lastFetch = Util.EnvironmentTickCount();
}
}
}
// Lookup the nic that goes with this stat and set the value by using a fetch action.
// Not sure about closure with delegates inside delegates.
private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat);
private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor)
{
// Get the one nic that has the name of this stat
IEnumerable<NetworkInterface> nics = NetworkInterface.GetAllNetworkInterfaces().Where(
(network) => network.Name == stat.Description);
try
{
foreach (NetworkInterface nic in nics)
{
IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics();
if (intrStats != null)
{
double newVal = Math.Round(getter(intrStats) / factor, 3);
stat.Value = newVal;
}
break;
}
}
catch
{
// There are times interfaces go away so we just won't update the stat for this
m_log.ErrorFormat("{0} Exception fetching stat on interface '{1}'", LogHeader, stat.Description);
}
}
}
public class ServerStatsAggregator : Stat
{
public ServerStatsAggregator(
string shortName,
string name,
string description,
string unitName,
string category,
string container
)
: base(
shortName,
name,
description,
unitName,
category,
container,
StatType.Push,
MeasuresOfInterest.None,
null,
StatVerbosity.Info)
{
}
public override string ToConsoleString()
{
StringBuilder sb = new StringBuilder();
return sb.ToString();
}
public override OSDMap ToOSDMap()
{
OSDMap ret = new OSDMap();
return ret;
}
}
}

View File

@@ -43,8 +43,14 @@ public class BSActorAvatarMove : BSActor
// Set to true if we think we're going up stairs.
// This state is remembered because collisions will turn on and off as we go up stairs.
int m_walkingUpStairs;
// The amount the step up is applying. Used to smooth stair walking.
float m_lastStepUp;
// Jumping happens over several frames. If use applies up force while colliding, start the
// jump and allow the jump to continue for this number of frames.
int m_jumpFrames = 0;
float m_jumpVelocity = 0f;
public BSActorAvatarMove(BSScene physicsScene, BSPhysObject pObj, string actorName)
: base(physicsScene, pObj, actorName)
{
@@ -206,17 +212,45 @@ public class BSActorAvatarMove : BSActor
if (m_controllingPrim.Friction != BSParam.AvatarFriction)
{
// Probably starting up walking. Set friction to moving friction.
// Probably starting to walk. Set friction to moving friction.
m_controllingPrim.Friction = BSParam.AvatarFriction;
m_physicsScene.PE.SetFriction(m_controllingPrim.PhysBody, m_controllingPrim.Friction);
}
// If falling, we keep the world's downward vector no matter what the other axis specify.
// The check for RawVelocity.Z < 0 makes jumping work (temporary upward force).
if (!m_controllingPrim.Flying && !m_controllingPrim.IsColliding)
{
if (m_controllingPrim.RawVelocity.Z < 0)
stepVelocity.Z = m_controllingPrim.RawVelocity.Z;
}
// Colliding and not flying with an upward force. The avatar must be trying to jump.
if (!m_controllingPrim.Flying && m_controllingPrim.IsColliding && stepVelocity.Z > 0)
{
// We allow the upward force to happen for this many frames.
m_jumpFrames = BSParam.AvatarJumpFrames;
m_jumpVelocity = stepVelocity.Z;
}
// The case where the avatar is not colliding and is not flying is special.
// The avatar is either falling or jumping and the user can be applying force to the avatar
// (force in some direction or force up or down).
// If the avatar has negative Z velocity and is not colliding, presume we're falling and keep the velocity.
// If the user is trying to apply upward force but we're not colliding, assume the avatar
// is trying to jump and don't apply the upward force if not touching the ground any more.
if (!m_controllingPrim.Flying && !m_controllingPrim.IsColliding)
{
// If upward velocity is being applied, this must be a jump and only allow that to go on so long
if (m_jumpFrames > 0)
{
// Since not touching the ground, only apply upward force for so long.
m_jumpFrames--;
stepVelocity.Z = m_jumpVelocity;
}
else
{
// Since we're not affected by anything, whatever vertical motion the avatar has, continue that.
stepVelocity.Z = m_controllingPrim.RawVelocity.Z;
}
// DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
}
@@ -241,7 +275,7 @@ public class BSActorAvatarMove : BSActor
m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs,IsColliding={1},flying={2},targSpeed={3},collisions={4},avHeight={5}",
m_controllingPrim.LocalID, m_controllingPrim.IsColliding, m_controllingPrim.Flying,
m_controllingPrim.TargetVelocitySpeed, m_controllingPrim.CollisionsLastTick.Count, m_controllingPrim.Size.Z);
// This test is done if moving forward, not flying and is colliding with something.
// Check for stairs climbing if colliding, not flying and moving forward
if ( m_controllingPrim.IsColliding
&& !m_controllingPrim.Flying

View File

@@ -209,7 +209,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
m_VhoverTimescale = Math.Max(pValue, 0.01f);
break;
case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
m_linearDeflectionEfficiency = Math.Max(pValue, 0.01f);
m_linearDeflectionEfficiency = ClampInRange(0f, pValue, 1f);
break;
case Vehicle.LINEAR_DEFLECTION_TIMESCALE:
m_linearDeflectionTimescale = Math.Max(pValue, 0.01f);
@@ -707,7 +707,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
private Vector3 m_knownRotationalVelocity;
private Vector3 m_knownRotationalForce;
private Vector3 m_knownRotationalImpulse;
private Vector3 m_knownForwardVelocity; // vehicle relative forward speed
private const int m_knownChangedPosition = 1 << 0;
private const int m_knownChangedVelocity = 1 << 1;
@@ -719,7 +718,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
private const int m_knownChangedRotationalImpulse = 1 << 7;
private const int m_knownChangedTerrainHeight = 1 << 8;
private const int m_knownChangedWaterLevel = 1 << 9;
private const int m_knownChangedForwardVelocity = 1 <<10;
public void ForgetKnownVehicleProperties()
{
@@ -923,12 +921,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
get
{
if ((m_knownHas & m_knownChangedForwardVelocity) == 0)
{
m_knownForwardVelocity = VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
m_knownHas |= m_knownChangedForwardVelocity;
}
return m_knownForwardVelocity;
return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
}
}
private float VehicleForwardSpeed
@@ -981,6 +974,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
ComputeLinearVelocity(pTimestep);
ComputeLinearDeflection(pTimestep);
ComputeLinearTerrainHeightCorrection(pTimestep);
ComputeLinearHover(pTimestep);
@@ -1026,12 +1021,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{
// Step the motor from the current value. Get the correction needed this step.
Vector3 origVelW = VehicleVelocity; // DEBUG
Vector3 currentVelV = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
Vector3 currentVelV = VehicleForwardVelocity;
Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVelV);
// Friction reduces vehicle motion
Vector3 frictionFactorW = ComputeFrictionFactor(m_linearFrictionTimescale, pTimestep);
linearMotorCorrectionV -= (currentVelV * frictionFactorW);
// Friction reduces vehicle motion based on absolute speed. Slow vehicle down by friction.
Vector3 frictionFactorV = ComputeFrictionFactor(m_linearFrictionTimescale, pTimestep);
linearMotorCorrectionV -= (currentVelV * frictionFactorV);
// Motor is vehicle coordinates. Rotate it to world coordinates
Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation;
@@ -1046,11 +1041,38 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// Add this correction to the velocity to make it faster/slower.
VehicleVelocity += linearMotorVelocityW;
VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6}",
ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV,
linearMotorVelocityW, VehicleVelocity, frictionFactorW);
linearMotorVelocityW, VehicleVelocity, frictionFactorV);
}
//Given a Deflection Effiency and a Velocity, Returns a Velocity that is Partially Deflected onto the X Axis
//Clamped so that a DeflectionTimescale of less then 1 does not increase force over original velocity
private void ComputeLinearDeflection(float pTimestep)
{
Vector3 linearDeflectionV = Vector3.Zero;
Vector3 velocityV = VehicleForwardVelocity;
// Velocity in Y and Z dimensions is movement to the side or turning.
// Compute deflection factor from the to the side and rotational velocity
linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y);
linearDeflectionV.Z = SortedClampInRange(0, (velocityV.Z * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Z);
// Velocity to the side and around is corrected and moved into the forward direction
linearDeflectionV.X += Math.Abs(linearDeflectionV.Y);
linearDeflectionV.X += Math.Abs(linearDeflectionV.Z);
// Scale the deflection to the fractional simulation time
linearDeflectionV *= pTimestep;
// Subtract the sideways and rotational velocity deflection factors while adding the correction forward
linearDeflectionV *= new Vector3(1,-1,-1);
// Correciont is vehicle relative. Convert to world coordinates and add to the velocity
VehicleVelocity += linearDeflectionV * VehicleOrientation;
VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}",
ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV);
}
public void ComputeLinearTerrainHeightCorrection(float pTimestep)
@@ -1652,6 +1674,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin
return frictionFactor;
}
private float SortedClampInRange(float clampa, float val, float clampb)
{
if (clampa > clampb)
{
float temp = clampa;
clampa = clampb;
clampb = temp;
}
return ClampInRange(clampa, val, clampb);
}
private float ClampInRange(float low, float val, float high)
{
return Math.Max(low, Math.Min(val, high));

View File

@@ -134,6 +134,7 @@ public static class BSParam
public static float AvatarHeightMidFudge { get; private set; }
public static float AvatarHeightHighFudge { get; private set; }
public static float AvatarContactProcessingThreshold { get; private set; }
public static int AvatarJumpFrames { get; private set; }
public static float AvatarBelowGroundUpCorrectionMeters { get; private set; }
public static float AvatarStepHeight { get; private set; }
public static float AvatarStepApproachFactor { get; private set; }
@@ -567,6 +568,8 @@ public static class BSParam
0.1f ),
new ParameterDefn<float>("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground",
1.0f ),
new ParameterDefn<int>("AvatarJumpFrames", "Number of frames to allow jump forces. Changes jump height.",
4 ),
new ParameterDefn<float>("AvatarStepHeight", "Height of a step obstacle to consider step correction",
0.6f ) ,
new ParameterDefn<float>("AvatarStepApproachFactor", "Factor to control angle of approach to step (0=straight on)",