Add very basic test which invokes the scene update loop once and checks the frame number.
This makes Scene.Update() match its original description of performing a single update, which also matches the semantics of SOG and ScenePresence.0.7.1-dev
parent
e774679f62
commit
88da253c94
|
@ -129,7 +129,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
protected ICapabilitiesModule m_capsModule;
|
protected ICapabilitiesModule m_capsModule;
|
||||||
// Central Update Loop
|
// Central Update Loop
|
||||||
protected int m_fps = 10;
|
protected int m_fps = 10;
|
||||||
protected uint m_frame;
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current scene frame number
|
||||||
|
/// </summary>
|
||||||
|
public uint Frame
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
protected set;
|
||||||
|
}
|
||||||
|
|
||||||
protected float m_timespan = 0.089f;
|
protected float m_timespan = 0.089f;
|
||||||
protected DateTime m_lastupdate = DateTime.UtcNow;
|
protected DateTime m_lastupdate = DateTime.UtcNow;
|
||||||
|
|
||||||
|
@ -1183,6 +1192,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
while (!shuttingdown)
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
m_lastUpdate = Util.EnvironmentTickCount();
|
m_lastUpdate = Util.EnvironmentTickCount();
|
||||||
|
@ -1200,25 +1210,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Watchdog.RemoveThread();
|
Watchdog.RemoveThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs per-frame updates on the scene, this should be the central scene loop
|
|
||||||
/// </summary>
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
|
||||||
float physicsFPS;
|
|
||||||
int maintc;
|
|
||||||
|
|
||||||
while (!shuttingdown)
|
|
||||||
{
|
{
|
||||||
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
|
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
|
||||||
physicsFPS = 0f;
|
float physicsFPS = 0f;
|
||||||
|
|
||||||
maintc = Util.EnvironmentTickCount();
|
int maintc = Util.EnvironmentTickCount();
|
||||||
int tmpFrameMS = maintc;
|
int tmpFrameMS = maintc;
|
||||||
tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
|
tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
|
||||||
|
|
||||||
// Increment the frame counter
|
// Increment the frame counter
|
||||||
++m_frame;
|
++Frame;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1227,16 +1229,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// Update SceneObjectGroups that have scheduled themselves for updates
|
// Update SceneObjectGroups that have scheduled themselves for updates
|
||||||
// Objects queue their updates onto all scene presences
|
// Objects queue their updates onto all scene presences
|
||||||
if (m_frame % m_update_objects == 0)
|
if (Frame % m_update_objects == 0)
|
||||||
m_sceneGraph.UpdateObjectGroups();
|
m_sceneGraph.UpdateObjectGroups();
|
||||||
|
|
||||||
// Run through all ScenePresences looking for updates
|
// Run through all ScenePresences looking for updates
|
||||||
// Presence updates and queued object updates for each presence are sent to clients
|
// Presence updates and queued object updates for each presence are sent to clients
|
||||||
if (m_frame % m_update_presences == 0)
|
if (Frame % m_update_presences == 0)
|
||||||
m_sceneGraph.UpdatePresences();
|
m_sceneGraph.UpdatePresences();
|
||||||
|
|
||||||
// Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
|
// Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
|
||||||
if (m_frame % m_update_coarse_locations == 0)
|
if (Frame % m_update_coarse_locations == 0)
|
||||||
{
|
{
|
||||||
List<Vector3> coarseLocations;
|
List<Vector3> coarseLocations;
|
||||||
List<UUID> avatarUUIDs;
|
List<UUID> avatarUUIDs;
|
||||||
|
@ -1249,18 +1251,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
int tmpPhysicsMS2 = Util.EnvironmentTickCount();
|
int tmpPhysicsMS2 = Util.EnvironmentTickCount();
|
||||||
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
|
if ((Frame % m_update_physics == 0) && m_physics_enabled)
|
||||||
m_sceneGraph.UpdatePreparePhysics();
|
m_sceneGraph.UpdatePreparePhysics();
|
||||||
physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
|
physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
|
||||||
|
|
||||||
// Apply any pending avatar force input to the avatar's velocity
|
// Apply any pending avatar force input to the avatar's velocity
|
||||||
if (m_frame % m_update_entitymovement == 0)
|
if (Frame % m_update_entitymovement == 0)
|
||||||
m_sceneGraph.UpdateScenePresenceMovement();
|
m_sceneGraph.UpdateScenePresenceMovement();
|
||||||
|
|
||||||
// Perform the main physics update. This will do the actual work of moving objects and avatars according to their
|
// Perform the main physics update. This will do the actual work of moving objects and avatars according to their
|
||||||
// velocity
|
// velocity
|
||||||
int tmpPhysicsMS = Util.EnvironmentTickCount();
|
int tmpPhysicsMS = Util.EnvironmentTickCount();
|
||||||
if (m_frame % m_update_physics == 0)
|
if (Frame % m_update_physics == 0)
|
||||||
{
|
{
|
||||||
if (m_physics_enabled)
|
if (m_physics_enabled)
|
||||||
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
|
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
|
||||||
|
@ -1270,7 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
|
physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
|
||||||
|
|
||||||
// Delete temp-on-rez stuff
|
// Delete temp-on-rez stuff
|
||||||
if (m_frame % 1000 == 0 && !m_cleaningTemps)
|
if (Frame % 1000 == 0 && !m_cleaningTemps)
|
||||||
{
|
{
|
||||||
int tmpTempOnRezMS = Util.EnvironmentTickCount();
|
int tmpTempOnRezMS = Util.EnvironmentTickCount();
|
||||||
m_cleaningTemps = true;
|
m_cleaningTemps = true;
|
||||||
|
@ -1280,28 +1282,28 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (RegionStatus != RegionStatus.SlaveScene)
|
if (RegionStatus != RegionStatus.SlaveScene)
|
||||||
{
|
{
|
||||||
if (m_frame % m_update_events == 0)
|
if (Frame % m_update_events == 0)
|
||||||
{
|
{
|
||||||
int evMS = Util.EnvironmentTickCount();
|
int evMS = Util.EnvironmentTickCount();
|
||||||
UpdateEvents();
|
UpdateEvents();
|
||||||
eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
|
eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_frame % m_update_backup == 0)
|
if (Frame % m_update_backup == 0)
|
||||||
{
|
{
|
||||||
int backMS = Util.EnvironmentTickCount();
|
int backMS = Util.EnvironmentTickCount();
|
||||||
UpdateStorageBackup();
|
UpdateStorageBackup();
|
||||||
backupMS = Util.EnvironmentTickCountSubtract(backMS);
|
backupMS = Util.EnvironmentTickCountSubtract(backMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_frame % m_update_terrain == 0)
|
if (Frame % m_update_terrain == 0)
|
||||||
{
|
{
|
||||||
int terMS = Util.EnvironmentTickCount();
|
int terMS = Util.EnvironmentTickCount();
|
||||||
UpdateTerrain();
|
UpdateTerrain();
|
||||||
terrainMS = Util.EnvironmentTickCountSubtract(terMS);
|
terrainMS = Util.EnvironmentTickCountSubtract(terMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (m_frame % m_update_land == 0)
|
//if (Frame % m_update_land == 0)
|
||||||
//{
|
//{
|
||||||
// int ldMS = Util.EnvironmentTickCount();
|
// int ldMS = Util.EnvironmentTickCount();
|
||||||
// UpdateLand();
|
// UpdateLand();
|
||||||
|
@ -1312,7 +1314,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
|
otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
|
||||||
lastCompletedFrame = Util.EnvironmentTickCount();
|
lastCompletedFrame = Util.EnvironmentTickCount();
|
||||||
|
|
||||||
// if (m_frame%m_update_avatars == 0)
|
// if (Frame%m_update_avatars == 0)
|
||||||
// UpdateInWorldTime();
|
// UpdateInWorldTime();
|
||||||
StatsReporter.AddPhysicsFPS(physicsFPS);
|
StatsReporter.AddPhysicsFPS(physicsFPS);
|
||||||
StatsReporter.AddTimeDilation(TimeDilation);
|
StatsReporter.AddTimeDilation(TimeDilation);
|
||||||
|
@ -1328,7 +1330,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
|
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoginsDisabled && m_frame == 20)
|
if (LoginsDisabled && Frame == 20)
|
||||||
{
|
{
|
||||||
// In 99.9% of cases it is a bad idea to manually force garbage collection. However,
|
// In 99.9% of cases it is a bad idea to manually force garbage collection. However,
|
||||||
// this is a rare case where we know we have just went through a long cycle of heap
|
// this is a rare case where we know we have just went through a long cycle of heap
|
||||||
|
@ -1378,9 +1380,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// Tell the watchdog that this thread is still alive
|
// Tell the watchdog that this thread is still alive
|
||||||
Watchdog.UpdateThread();
|
Watchdog.UpdateThread();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void AddGroupTarget(SceneObjectGroup grp)
|
public void AddGroupTarget(SceneObjectGroup grp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -116,9 +116,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
|
agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
|
||||||
agent.child = true;
|
agent.child = true;
|
||||||
|
|
||||||
if (scene.PresenceService == null)
|
|
||||||
Console.WriteLine("Presence Service is null");
|
|
||||||
|
|
||||||
scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
|
scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
|
||||||
|
|
||||||
string reason;
|
string reason;
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Timers;
|
||||||
|
using Timer=System.Timers.Timer;
|
||||||
|
using Nini.Config;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NUnit.Framework.SyntaxHelpers;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Communications;
|
||||||
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||||
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
|
||||||
|
using OpenSim.Tests.Common;
|
||||||
|
using OpenSim.Tests.Common.Mock;
|
||||||
|
using OpenSim.Tests.Common.Setup;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Scene presence tests
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture]
|
||||||
|
public class SceneTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Very basic scene update test. Should become more elaborate with time.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestUpdateScene()
|
||||||
|
{
|
||||||
|
TestHelper.InMethod();
|
||||||
|
|
||||||
|
Scene scene = SceneSetupHelpers.SetupScene();
|
||||||
|
scene.Update();
|
||||||
|
|
||||||
|
Assert.That(scene.Frame, Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue