From 90274434c62ecf7184b609940db4b7059ffdc4e2 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 9 Nov 2007 13:45:42 +0000 Subject: [PATCH] * Moved BulletX off of the 'constant terse update' method. It now only sends terse updates when needed. * Removed the 'constant poll method' from SceneObjectPart.cs - It was bad :P * Updated some Masses in ODE to help large prim slow down by friction easier. --- .../Environment/Scenes/SceneObjectPart.cs | 11 +++++--- .../Physics/BulletXPlugin/BulletXPlugin.cs | 26 +++++++++++++++++++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 15 ++++++++--- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index f54b52f3db..7575fad2a7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -603,11 +603,14 @@ namespace OpenSim.Region.Environment.Scenes { AddTerseUpdateToAllAvatars(); ClearUpdateSchedule(); - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0) - { + + // This causes the Scene to 'poll' physical objects every couple of frames + // bad, so it's been replaced by an event driven method. + //if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0) + //{ // Only send the constant terse updates on physical objects! - ScheduleTerseUpdate(); - } + //ScheduleTerseUpdate(); + //} } else { diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index cdccc70f87..2e6e40fad8 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -819,6 +819,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin internal protected virtual void ReSize(PhysicsVector _newSize) { } + public virtual void ScheduleTerseUpdate() + { + base.RequestPhysicsterseUpdate(); + } #endregion } @@ -1003,6 +1007,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin //For now all prims have the same density, all prims are made of water. Be water my friend! :D private const float _density = 1000.0f; private BulletXScene _parent_scene; + private PhysicsVector m_prev_position = new PhysicsVector(0, 0, 0); + private bool m_lastUpdateSent = false; public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs, bool isPhysical) @@ -1148,8 +1154,28 @@ namespace OpenSim.Region.Physics.BulletXPlugin if (_physical) //Updates properties. Prim updates its properties physically { _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); + _velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity); _orientation = BulletXMaths.XnaQuaternionToAxiomQuaternion(rigidBody.Orientation); + + if ((Math.Abs(m_prev_position.X - _position.X) < 0.03) + && (Math.Abs(m_prev_position.Y - _position.Y) < 0.03) + && (Math.Abs(m_prev_position.Z - _position.Z) < 0.03)) + { + if (!m_lastUpdateSent) + { + _velocity = new PhysicsVector(0, 0, 0); + base.ScheduleTerseUpdate(); + m_lastUpdateSent = true; + } + } + else + { + m_lastUpdateSent = false; + base.ScheduleTerseUpdate(); + + } + m_prev_position = _position; } else //Doesn't updates properties. That's a cancel { diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 4750e54556..79f51a1a03 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -124,7 +124,8 @@ namespace OpenSim.Region.Physics.OdePlugin space = d.HashSpaceCreate(IntPtr.Zero); contactgroup = d.JointGroupCreate(0); //contactgroup - + + d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f); d.WorldSetAutoDisableFlag(world, false); d.WorldSetContactSurfaceLayer(world, 0.001f); @@ -936,7 +937,7 @@ namespace OpenSim.Region.Physics.OdePlugin private String m_primName; private PhysicsVector _target_velocity; public d.Mass pMass; - private const float MassMultiplier = 500f; // Ref: Water: 1000kg.. this iset to 500 + private const float MassMultiplier = 150f; // Ref: Water: 1000kg.. this iset to 500 private int debugcounter = 0; @@ -1361,7 +1362,7 @@ namespace OpenSim.Region.Physics.OdePlugin //System.Console.WriteLine(Math.Abs(m_lastposition.X - l_position.X).ToString()); _zeroFlag = false; } - m_lastposition = l_position; + if (_zeroFlag) @@ -1379,6 +1380,11 @@ namespace OpenSim.Region.Physics.OdePlugin m_rotationalVelocity.X = 0; m_rotationalVelocity.Y = 0; m_rotationalVelocity.Z = 0; + if (!m_lastUpdateSent) + { + base.RequestPhysicsterseUpdate(); + m_lastUpdateSent = true; + } } else @@ -1399,9 +1405,10 @@ namespace OpenSim.Region.Physics.OdePlugin _orientation.x = ori.X; _orientation.y = ori.Y; _orientation.z = ori.Z; + m_lastUpdateSent = false; base.RequestPhysicsterseUpdate(); } - + m_lastposition = l_position; } else {