From 00a1f0bab0d764017677672c19d4509c1af3e622 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 16 May 2008 20:16:33 +0000 Subject: * This finishes the ODE options section of the OpenSim.ini.example. I've added 44 configurable options! * This includes if you want to mesh sculpties and the Level of detail on the sculptie meshing for non physical and a separate LOD on physical sculpties. * The options range from gravity.. to avatar movement speed, to friction management.. to object density.. to update throttling. --- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 2 +- OpenSim/Region/Physics/Manager/IMesher.cs | 2 +- OpenSim/Region/Physics/Manager/ZeroMesher.cs | 2 +- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 9 ++- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 9 ++- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 90 +++++++++++++--------- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 50 +++++++++++- bin/OpenSim.ini.example | 34 ++++++++ 8 files changed, 150 insertions(+), 48 deletions(-) diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 5ced2d1..fcff04e 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -612,7 +612,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin } else { - IMesh mesh = mesher.CreateMesh(primName, pbs, size); + IMesh mesh = mesher.CreateMesh(primName, pbs, size, 32f); result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); } break; diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs index d52b4e4..ee498c5 100644 --- a/OpenSim/Region/Physics/Manager/IMesher.cs +++ b/OpenSim/Region/Physics/Manager/IMesher.cs @@ -33,7 +33,7 @@ namespace OpenSim.Region.Physics.Manager { public interface IMesher { - IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size); + IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod); } public interface IVertex diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs index b759213..8362630 100644 --- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs +++ b/OpenSim/Region/Physics/Manager/ZeroMesher.cs @@ -60,7 +60,7 @@ namespace OpenSim.Region.Physics.Manager public class ZeroMesher : IMesher { - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) { return null; } diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 4bf12c9..ba4f941 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -1295,9 +1295,9 @@ namespace OpenSim.Region.Physics.Meshing return m; } - private SculptMesh CreateSculptMesh(string primName, PrimitiveBaseShape primShape, PhysicsVector size) + private SculptMesh CreateSculptMesh(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) { - SculptMesh sm = new SculptMesh(primShape.SculptData); + SculptMesh sm = new SculptMesh(primShape.SculptData, lod); // Scale the mesh based on our prim scale foreach (Vertex v in sm.vertices) { @@ -1422,12 +1422,13 @@ namespace OpenSim.Region.Physics.Meshing } } - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) { Mesh mesh = null; if (primShape.SculptEntry && primShape.SculptType != (byte)0 && primShape.SculptData.Length > 0) { - SculptMesh smesh = CreateSculptMesh(primName, primShape, size); + + SculptMesh smesh = CreateSculptMesh(primName, primShape, size, lod); mesh = (Mesh)smesh; CalcNormals(mesh); } diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index 924c4d3..1c4db15 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -48,8 +48,11 @@ namespace OpenSim.Region.Physics.Meshing private int lod = 32; private const float RANGE = 128.0f; - public SculptMesh(byte[] jpegData) + public SculptMesh(byte[] jpegData, float _lod) { + if (_lod == 2f || _lod == 4f || _lod == 8f || _lod == 16f || _lod == 32f || _lod == 64f) + lod = (int)_lod; + idata = OpenJPEG.DecodeToImage(jpegData); if (idata != null) { @@ -61,6 +64,10 @@ namespace OpenSim.Region.Physics.Meshing LoadPoles(); processSculptTexture(); + + bLOD.Dispose(); + bBitmap.Dispose(); + idata.Dispose(); } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index f1886e4..1f9a6b6 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -65,6 +65,13 @@ namespace OpenSim.Region.Physics.OdePlugin private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); private float m_PIDTau = 0f; + private float PID_D = 35f; + private float PID_G = 25f; + private float m_tensor = 5f; + private int body_autodisable_frames = 20; + + + private bool m_usePID = false; private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom @@ -94,7 +101,7 @@ namespace OpenSim.Region.Physics.OdePlugin public uint m_localID = 0; - public GCHandle gc; + //public GCHandle gc; private CollisionLocker ode; private bool m_taintforce = false; @@ -147,11 +154,16 @@ namespace OpenSim.Region.Physics.OdePlugin { _target_velocity = new PhysicsVector(0, 0, 0); - gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); + //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); ode = dode; _velocity = new PhysicsVector(); _position = pos; m_taintposition = pos; + PID_D = parent_scene.bodyPIDD; + PID_G = parent_scene.bodyPIDG; + m_density = parent_scene.geomDefaultDensity; + m_tensor = parent_scene.bodyMotorJointMaxforceTensor; + body_autodisable_frames = parent_scene.bodyFramesAutoDisable; //if (_position.X > 257) //{ //_position.X = 257; @@ -306,7 +318,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetAutoDisableFlag(Body, true); - d.BodySetAutoDisableSteps(Body, 20); + d.BodySetAutoDisableSteps(Body, body_autodisable_frames); m_interpenetrationcount = 0; m_collisionscore = 0; @@ -677,6 +689,7 @@ namespace OpenSim.Region.Physics.OdePlugin Thread.Sleep(10); + //Kill Body so that mesh can re-make the geom if (IsPhysical && Body != (IntPtr) 0) { @@ -799,7 +812,7 @@ namespace OpenSim.Region.Physics.OdePlugin { d.JointDestroy(Amotor); Amotor = (IntPtr)0; - } + } } } } @@ -951,7 +964,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (_parent_scene.needsMeshing(_pbs)) { // Don't need to re-enable body.. it's done in SetMesh - _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size); + _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD); // createmesh returns null when it's a shape that isn't a cube. } } @@ -1138,7 +1151,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (IsPhysical && Body != (IntPtr)0 && !m_isSelected) { - float PID_D = 2200.0f; + //float PID_P = 900.0f; @@ -1177,21 +1190,8 @@ namespace OpenSim.Region.Physics.OdePlugin // If the PID Controller isn't active then we set our force // calculating base velocity to the current position - if (Environment.OSVersion.Platform == PlatformID.Unix) - { - PID_D = 3200.0f; - //PID_P = 1400.0f; - } - else - { - PID_D = 2200.0f; - //PID_P = 900.0f; - } - PID_D = 35f; - - - //PID_P = 1.0f; - float PID_G = 25; + + if ((m_PIDTau < 1)) { @@ -1333,13 +1333,27 @@ namespace OpenSim.Region.Physics.OdePlugin { if (Body == (IntPtr)0) { - enableBody(); + if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) + { + changeshape(2f); + } + else + { + enableBody(); + } } } else { if (Body != (IntPtr)0) { + if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) + { + if (prim_geom != IntPtr.Zero) + d.GeomDestroy(prim_geom); + + changeadd(2f); + } disableBody(); } } @@ -1386,8 +1400,12 @@ namespace OpenSim.Region.Physics.OdePlugin // Construction of new prim if (_parent_scene.needsMeshing(_pbs)) { + float meshlod = _parent_scene.meshSculptLOD; + + if (IsPhysical) + meshlod = _parent_scene.MeshSculptphysicalLOD; // Don't need to re-enable body.. it's done in SetMesh - IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); + IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod); // createmesh returns null when it's a shape that isn't a cube. if (mesh != null) { @@ -1556,10 +1574,16 @@ namespace OpenSim.Region.Physics.OdePlugin if (_size.Y <= 0) _size.Y = 0.01f; if (_size.Z <= 0) _size.Z = 0.01f; // Construction of new prim + if (_parent_scene.needsMeshing(_pbs)) { // Don't need to re-enable body.. it's done in SetMesh - IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); + float meshlod = _parent_scene.meshSculptLOD; + + if (IsPhysical) + meshlod = _parent_scene.MeshSculptphysicalLOD; + + IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod); // createmesh returns null when it's a shape that isn't a cube. if (mesh != null) { @@ -1910,12 +1934,12 @@ namespace OpenSim.Region.Physics.OdePlugin public override void CrossingFailure() { m_crossingfailures++; - if (m_crossingfailures > 5) + if (m_crossingfailures > _parent_scene.geomCrossingFailuresBeforeOutofbounds) { base.RaiseOutOfBounds(_position); return; } - else if (m_crossingfailures == 5) + else if (m_crossingfailures == _parent_scene.geomCrossingFailuresBeforeOutofbounds) { m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName); } @@ -1982,7 +2006,7 @@ namespace OpenSim.Region.Physics.OdePlugin { //base.RaiseOutOfBounds(l_position); - if (m_crossingfailures < 5) + if (m_crossingfailures < _parent_scene.geomCrossingFailuresBeforeOutofbounds) { _position = l_position; //_parent_scene.remActivePrim(this); @@ -2107,7 +2131,7 @@ namespace OpenSim.Region.Physics.OdePlugin _orientation.y = ori.Y; _orientation.z = ori.Z; m_lastUpdateSent = false; - if (!m_throttleUpdates || throttleCounter > 15) + if (!m_throttleUpdates || throttleCounter > _parent_scene.geomUpdatesPerThrottledUpdate) { if (_parent == null) base.RequestPhysicsterseUpdate(); @@ -2164,15 +2188,7 @@ namespace OpenSim.Region.Physics.OdePlugin Amotor = IntPtr.Zero; } - float m_tensor = 0f; - if (Environment.OSVersion.Platform == PlatformID.Unix) - { - m_tensor = 2f; - } - else - { - m_tensor = 5f; - } + float axisnum = 3; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index c663fb0..70f0785 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -171,6 +171,25 @@ namespace OpenSim.Region.Physics.OdePlugin private float avMovementDivisorWalk = 1.3f; private float avMovementDivisorRun = 0.8f; + public bool meshSculptedPrim = true; + + public float meshSculptLOD = 32; + public float MeshSculptphysicalLOD = 16; + + public float geomDefaultDensity = 10.000006836f; + + public int geomContactPointsStartthrottle = 3; + public int geomUpdatesPerThrottledUpdate = 15; + + public float bodyPIDD = 35f; + public float bodyPIDG = 25; + + public int geomCrossingFailuresBeforeOutofbounds = 5; + + public float bodyMotorJointMaxforceTensor = 2; + + public int bodyFramesAutoDisable = 20; + private float[] _heightmap; private float[] _watermap; @@ -320,17 +339,35 @@ namespace OpenSim.Region.Physics.OdePlugin avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); + geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); + geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); + geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_faiures_before_outofbounds", 5); + + geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f); + bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20); + + bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f); + bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f); + + meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true); + meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f); + MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f); + + if (Environment.OSVersion.Platform == PlatformID.Unix) { avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 3200.0f); avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 1400.0f); avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 2000000f); + bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_linux", 2f); + } else { avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f); + bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_win", 5f); } } } @@ -765,7 +802,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointAttach(joint, b1, b2); } collision_accounting_events(p1, p2, max_collision_depth); - if (count > 3) + if (count > geomContactPointsStartthrottle) { // If there are more then 3 contact points, it's likely // that we've got a pile of objects @@ -1117,7 +1154,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// support simple box & hollow box now; later, more shapes if (needsMeshing(pbs)) { - mesh = mesher.CreateMesh(primName, pbs, size); + mesh = mesher.CreateMesh(primName, pbs, size, 32f); } break; @@ -1474,6 +1511,11 @@ namespace OpenSim.Region.Physics.OdePlugin /// public bool needsMeshing(PrimitiveBaseShape pbs) { + if (pbs.SculptEntry && !meshSculptedPrim) + { + return false; + } + if (pbs.ProfileHollow != 0) return true; @@ -1495,7 +1537,9 @@ namespace OpenSim.Region.Physics.OdePlugin return true; if (pbs.ProfileShape == ProfileShape.EquilateralTriangle) - return true; + return true; + + return false; } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 43bf251..f264248 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -242,6 +242,40 @@ av_movement_divisor_walk = 1.3 ; speed of movement with Always Run on av_movement_divisor_run = 0.8 +; # Object options +; used in the mass calculation. +geometry_default_density = 10.000006836 + +; amount of ODE steps where object is non moving for ODE to automatically put it to sleep +body_frames_auto_disable = 20 + +; used to control llMove2Target +body_pid_derivative = 35 +body_pid_gain = 25 + +; amount of time a geom/body will try to cross a region border before it gets disabled +geom_crossing_faiures_before_outofbounds = 5 + +; start throttling the object updates if object comes in contact with 3 or more other objects +geom_contactpoints_start_throttling = 3 + +; send 1 update for every x updates below when throttled +geom_updates_before_throttled_update = 15 + +; Used for llSetStatus. How rigid the object rotation is held on the axis specified +body_motor_joint_maxforce_tensor_linux = 2 +body_motor_joint_maxforce_tensor_win = 5 + +; # Sculpted Prim settings + +; Do we want to mesh sculpted prim to collide like they look? +mesh_sculpted_prim = true + +; number^2 non-physical level of detail of the sculpt texture. 32x32 - 1024 verticies +mesh_lod = 32 + +; number^2 physical level of detail of the sculpt texture. 16x16 - 256 verticies +mesh_physical_lod = 16 [RemoteAdmin] enabled = false -- cgit v1.1