From b7d596a6af51bea7dba642cdc768ac5ff77af5f3 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 28 Nov 2007 06:18:07 +0000 Subject: * Restaring the sim works fine in grid mode now. Sims announce themselves to their neighbors when they start up. Neighbors get this message and tell their agents that there's a new sim up. * Certain unrecoverable physics based crashes in ODE are now hooked up to the 'restart the sim' routine. --- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 17 +++++++++++++++++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 22 ++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 651992c..635b208 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -32,12 +32,29 @@ using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Manager { + public delegate void physicsCrash(); + public abstract class PhysicsScene { + // The only thing that should register for this event is the InnerScene + // Anything else could cause problems. + + public event physicsCrash OnPhysicsCrash; + public static PhysicsScene Null { get { return new NullPhysicsScene(); } } + public virtual void TriggerPhysicsBasedRestart() + { + physicsCrash handler = OnPhysicsCrash; + if (handler != null) + { + OnPhysicsCrash(); + } + + } + public abstract void Initialise(IMesher meshmerizer); diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index ec7d04d..7193886 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -32,6 +32,7 @@ using Axiom.Math; using Ode.NET; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; + //using OpenSim.Region.Physics.OdePlugin.Meshing; namespace OpenSim.Region.Physics.OdePlugin @@ -234,9 +235,16 @@ namespace OpenSim.Region.Physics.OdePlugin //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); } - int count; - + int count = 0; + try + { count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); + } + catch (System.Runtime.InteropServices.SEHException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("PHYSICS", "The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); + base.TriggerPhysicsBasedRestart(); + } for (int i = 0; i < count; i++) { @@ -805,8 +813,14 @@ namespace OpenSim.Region.Physics.OdePlugin { // Process 10 frames if the sim is running normal.. // process 5 frames if the sim is running slow - d.WorldSetQuickStepNumIterations(world, m_physicsiterations); - + try{ + d.WorldSetQuickStepNumIterations(world, m_physicsiterations); + } + catch (System.StackOverflowException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("PHYSICS", "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); + base.TriggerPhysicsBasedRestart(); + } int i = 0; while (step_time > 0.0f) -- cgit v1.1