From cb55056e3bb0d34e51d8efa60cb8ef82484af900 Mon Sep 17 00:00:00 2001 From: gareth Date: Fri, 2 Mar 2007 22:17:39 +0000 Subject: Began implementing basic physics engine plugin framework --- src/Config.cs | 11 ++++++----- src/Main.cs | 5 +++-- src/world/PhysicsEngine.cs | 21 +++++++++++++++++++++ src/world/World.cs | 18 +++++++++++++----- 4 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 src/world/PhysicsEngine.cs diff --git a/src/Config.cs b/src/Config.cs index d4a0797..f85e4d5 100644 --- a/src/Config.cs +++ b/src/Config.cs @@ -106,18 +106,19 @@ namespace OpenSim } public World LoadWorld() { - IObjectSet world_result = db.Get(typeof(OpenSim.world.World)); - if(world_result.Count==1) { + Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB"); + // IObjectSet world_result = db.Get(typeof(OpenSim.world.World)); + // if(world_result.Count==1) { Console.WriteLine("Config.cs:LoadWorld() - Found an OpenSim.world.World object in local database, loading"); - return (World)world_result.Next(); - } else { + //return (World)world_result.Next(); + // } else { Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one"); World blank = new World(); Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk"); db.Set(blank); db.Commit(); return blank; - } + // } } public void LoadFromGrid() { diff --git a/src/Main.cs b/src/Main.cs index 6075035..146d837 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -50,7 +50,6 @@ namespace OpenSim public static SimConfig cfg; public static World local_world; private static Thread MainListener; - private static Thread PingRespponder; public static Socket Server; private static IPEndPoint ServerIncoming; private static byte[] RecvBuffer = new byte[4096]; @@ -68,7 +67,7 @@ namespace OpenSim sim = new OpenSim_Main(); sim.Startup(); while(true) { - Thread.Sleep(1000); + local_world.DoStuff(); } } @@ -91,6 +90,8 @@ namespace OpenSim MainListener = new Thread(new ThreadStart(MainServerListener)); MainListener.Start(); + Console.WriteLine("Main.cs:Startup() - Starting up main world loop"); + local_world.InitLoop(); } private void OnReceivedData(IAsyncResult result) { diff --git a/src/world/PhysicsEngine.cs b/src/world/PhysicsEngine.cs new file mode 100644 index 0000000..5bc52de --- /dev/null +++ b/src/world/PhysicsEngine.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.world +{ + public class PhysicsEngine + { + + public PhysicsEngine() { + } + + public void Startup() { + Console.WriteLine("PhysicsEngine.cs:Startup() - DOING NOTHING, DUMMY FUNCTION!"); + } + + } +} diff --git a/src/world/World.cs b/src/world/World.cs index ebbd61e..f02f73f 100644 --- a/src/world/World.cs +++ b/src/world/World.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using libsecondlife; using libsecondlife.Packets; using System.Collections.Generic; @@ -13,6 +14,7 @@ namespace OpenSim.world public ScriptEngine Scripts; public TerrainDecode terrainengine = new TerrainDecode(); public uint _localNumber=0; + public PhysicsEngine physics; private Random Rand = new Random(); @@ -28,13 +30,19 @@ namespace OpenSim.world LandMap[i] = 21.4989f; } - Console.WriteLine("World.cs - Creating script engine instance"); - // Initialise this only after the world has loaded - Scripts = new ScriptEngine(this); } - public void Update() - { + public void InitLoop() { + Console.WriteLine("World.cs:StartLoop() - Initialising physics"); + this.physics = new PhysicsEngine(); + physics.Startup(); + } + + public void DoStuff() { + Thread.Sleep(1000); + } + + public void Update() { foreach (libsecondlife.LLUUID UUID in Entities.Keys) { Entities[UUID].update(); -- cgit v1.1