From 48d8fbc9aedb3247a1dfd25be1b7dfbdd8719790 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 7 Oct 2012 08:53:55 +0100 Subject: bug fix + make costs visible for testing --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 +++-- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 17 +++++++ .../Region/Physics/UbitOdePlugin/ODEMeshWorker.cs | 40 ++++++++-------- OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 56 +++++++++++++++------- 4 files changed, 85 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 633cd3b..66d85c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1583,7 +1583,9 @@ namespace OpenSim.Region.Framework.Scenes float cost = 0.1f; if (PhysActor != null) -// cost += PhysActor.Cost; + cost = PhysActor.PhysicsCost; + else + cost = 0.1f; if ((Flags & PrimFlags.Physics) != 0) cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 @@ -1596,9 +1598,12 @@ namespace OpenSim.Region.Framework.Scenes { get { - - - return 0.1f; + float cost; + if (PhysActor != null) + cost = PhysActor.StreamCost; + else + cost = 1.0f; + return 1.0f; } } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index a2c72c3..14f65b8 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -315,6 +315,23 @@ namespace OpenSim.Region.Physics.Manager } } + + public virtual float PhysicsCost + { + get + { + return 0.1f; + } + } + + public virtual float StreamCost + { + get + { + return 1.0f; + } + } + /// /// Velocity of this actor. /// diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs index 3fcbb1b..6bdc089 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs @@ -40,8 +40,6 @@ namespace OpenSim.Region.Physics.OdePlugin public float volume; - public float physCost; - public float streamCost; public byte shapetype; public bool hasOBB; public bool hasMeshVolume; @@ -121,8 +119,14 @@ namespace OpenSim.Region.Physics.OdePlugin public void Stop() { - m_running = false; - m_thread.Abort(); + try + { + m_thread.Abort(); + createqueue.Clear(); + } + catch + { + } } public void ChangeActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs, @@ -172,10 +176,15 @@ namespace OpenSim.Region.Physics.OdePlugin if (repData.assetState != AssetState.needAsset) return; + repData.mesh = null; + if (repData.assetID == null || repData.assetID == UUID.Zero) + { + repData.assetState = AssetState.noNeedAsset; + repData.comand = meshWorkerCmnds.changefull; + createqueue.Enqueue(repData); return; - - repData.mesh = null; + } repData.assetState = AssetState.loadingAsset; @@ -211,9 +220,6 @@ namespace OpenSim.Region.Physics.OdePlugin repData.OBBOffset = mesh.GetCentroid(); repData.OBB = mesh.GetOBB(); repData.hasOBB = true; - repData.physCost = 0.0013f * (float)indexCount; - // todo - repData.streamCost = 1.0f; mesh.releaseSourceMeshData(); } } @@ -427,11 +433,14 @@ namespace OpenSim.Region.Physics.OdePlugin if (pbs.SculptTexture != null && pbs.SculptTexture != UUID.Zero) { repData.assetID = pbs.SculptTexture; - repData.assetState = AssetState.needAsset; + repData.assetState = AssetState.needAsset; } else repData.assetState = AssetState.AssetFailed; } + else + repData.assetState = AssetState.needAsset; + return false; } @@ -828,14 +837,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (repData.hasOBB) { Vector3 OBB = repData.OBB; - float pc = repData.physCost; - float psf = OBB.X * (OBB.Y + OBB.Z) + OBB.Y * OBB.Z; - psf *= 1.33f * .2f; - pc *= psf; - if (pc < 0.1f) - pc = 0.1f; - - repData.physCost = pc; } else { @@ -846,9 +847,6 @@ namespace OpenSim.Region.Physics.OdePlugin repData.OBB = OBB; repData.OBBOffset = Vector3.Zero; - - repData.physCost = 0.1f; - repData.streamCost = 1.0f; } CalculateBasicPrimVolume(repData); diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index cbe129a..4c16f8e 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -277,7 +277,23 @@ namespace OpenSim.Region.Physics.OdePlugin cdata.mu *= veh.FrictionFactor; // cdata.mu *= 0; } - } + } + + public override float PhysicsCost + { + get + { + return m_physCost; + } + } + + public override float StreamCost + { + get + { + return m_streamCost; + } + } public override int PhysicsActorType { @@ -1373,6 +1389,11 @@ namespace OpenSim.Region.Physics.OdePlugin m_mesh = null; return false; } + + m_physCost = 0.0013f * (float)indexCount; + // todo + m_streamCost = 1.0f; + return true; } @@ -1386,7 +1407,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_assetState == AssetState.AssetFailed) m_NoColide = true; - else if (m_mesh != null) + else if(m_mesh != null) { if (GetMeshGeom()) hasMesh = true; @@ -2058,7 +2079,23 @@ namespace OpenSim.Region.Physics.OdePlugin m_OBBOffset.Y, m_OBBOffset.Z); - primOOBradiusSQ = m_OBBOffset.LengthSquared(); + primOOBradiusSQ = m_OBB.LengthSquared(); + + if (_triMeshData != IntPtr.Zero) + { + float pc = m_physCost; + float psf = primOOBradiusSQ; + psf *= 1.33f * .2f; + pc *= psf; + if (pc < 0.1f) + pc = 0.1f; + + m_physCost = pc; + } + else + m_physCost = 0.1f; + + m_streamCost = 1.0f; } #endregion @@ -2717,10 +2754,6 @@ namespace OpenSim.Region.Physics.OdePlugin m_OBBOffset = repData.OBBOffset; m_OBB = repData.OBB; -// m_NoColide = repData.NoColide; - m_physCost = repData.physCost; - m_streamCost = repData.streamCost; - primVolume = repData.volume; CreateGeom(); @@ -2793,9 +2826,6 @@ namespace OpenSim.Region.Physics.OdePlugin m_OBBOffset = repData.OBBOffset; m_OBB = repData.OBB; - m_physCost = repData.physCost; - m_streamCost = repData.streamCost; - primVolume = repData.volume; CreateGeom(); @@ -2806,14 +2836,8 @@ namespace OpenSim.Region.Physics.OdePlugin UpdatePrimBodyData(); - try - { _parent_scene.actor_name_map[prim_geom] = this; - } - catch - { - } d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); d.Quaternion myrot = new d.Quaternion(); -- cgit v1.1