From e02a2e31e0e8a189b63e60dc402ac0ccd3bae876 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 20 Jun 2008 04:57:32 +0000 Subject: * Patch from nlin to enable DIF state file writing from the ODEPlugin * Rebuilt libode.so, ode.dll * If you roll your own ODE library, make sure to update your opensim-libs. --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs') diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 787cb12..81e03ca 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; +using System.IO; using Axiom.Math; using log4net; using Nini.Config; @@ -247,6 +248,11 @@ namespace OpenSim.Region.Physics.OdePlugin private IConfigSource m_config; + public bool physics_logging = false; + public int physics_logging_interval = 0; + public bool physics_logging_append_existing_logfile = false; + + /// /// Initiailizes the scene /// Sets many properties that ODE requires to be stable @@ -370,6 +376,10 @@ namespace OpenSim.Region.Physics.OdePlugin avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f); bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_win", 5f); } + + physics_logging = physicsconfig.GetBoolean("physics_logging", false); + physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); + physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false); } } @@ -1759,7 +1769,25 @@ namespace OpenSim.Region.Physics.OdePlugin } } } + + + // Finished with all sim stepping. If requested, dump world state to file for debugging. + // TODO: This call to the export function is already inside lock(OdeLock) - but is an extra lock needed? + // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots? + if(physics_logging && (physics_logging_interval>0) && (framecount % physics_logging_interval == 0) ) { + string fname = "state-" + world.ToString() + ".DIF"; // give each physics world a separate filename + string prefix = "world" + world.ToString(); // prefix for variable names in exported .DIF file + + if(physics_logging_append_existing_logfile) { + string header = "-------------- START OF PHYSICS FRAME " + framecount.ToString() + " --------------"; + TextWriter fwriter = File.AppendText(fname); + fwriter.WriteLine(header); + fwriter.Close(); + } + d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); + } } + return fps; } -- cgit v1.1