From 40a52b0f55828bfa564e1b044aa99ebff76a2b7e Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 2 Mar 2007 18:12:54 +0000 Subject: A example of how the physics plugins might work --- src/world/World.cs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/world/World.cs') diff --git a/src/world/World.cs b/src/world/World.cs index ebbd61e..920220f 100644 --- a/src/world/World.cs +++ b/src/world/World.cs @@ -3,6 +3,7 @@ using libsecondlife; using libsecondlife.Packets; using System.Collections.Generic; using System.Text; +using PhysicsManager; namespace OpenSim.world { @@ -13,6 +14,8 @@ namespace OpenSim.world public ScriptEngine Scripts; public TerrainDecode terrainengine = new TerrainDecode(); public uint _localNumber=0; + private PhysicsScene phyScene; + private float timeStep= 0.1f; private Random Rand = new Random(); @@ -32,9 +35,30 @@ namespace OpenSim.world // Initialise this only after the world has loaded Scripts = new ScriptEngine(this); } - + + public PhysicsScene PhysScene + { + set + { + this.phyScene = value; + } + } + public void Update() { + if(this.phyScene.IsThreaded) + { + this.phyScene.GetResults(); + + } + + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + Entities[UUID].addFroces(); + } + + this.phyScene.Simulate(timeStep); + foreach (libsecondlife.LLUUID UUID in Entities.Keys) { Entities[UUID].update(); @@ -55,7 +79,9 @@ namespace OpenSim.world this.Entities.Add(AgentClient.AgentID, NewAvatar); Console.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); NewAvatar.SendRegionHandshake(this); - this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user + + NewAvatar.PhysActor = this.phyScene.AddAvatar(new PhysicsVector(NewAvatar.position.x, NewAvatar.position.y, NewAvatar.position.z)); + //this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user } public bool Backup() { -- cgit v1.1