From 89d342b5ce9ac5d9fc4fd493eead8e050f99c91a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 Oct 2012 08:14:52 +0100 Subject: [PATCH] more changes and more non active code --- OpenSim/Region/Physics/UbitMeshing/Mesh.cs | 10 +- .../Physics/UbitOdePlugin/ODEMeshWorker.cs | 11 +- .../Region/Physics/UbitOdePlugin/ODEPrim.cs | 140 +++++++++++++++--- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 12 +- 4 files changed, 144 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs index 47e0cf4dcb..c31ec0818f 100644 --- a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs +++ b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs @@ -89,8 +89,6 @@ namespace OpenSim.Region.Physics.Meshing m_obbYmax = float.MinValue; m_obbZmin = float.MaxValue; m_obbZmax = float.MinValue; - - } public int RefCount { get; set; } @@ -99,8 +97,6 @@ namespace OpenSim.Region.Physics.Meshing public void Scale(Vector3 scale) { - - } public Mesh Clone() @@ -113,6 +109,12 @@ namespace OpenSim.Region.Physics.Meshing } result.m_centroid = m_centroid; result.m_centroidDiv = m_centroidDiv; + result.m_obbXmin = m_obbXmin; + result.m_obbXmax = m_obbXmax; + result.m_obbYmin = m_obbYmin; + result.m_obbYmax = m_obbYmax; + result.m_obbZmin = m_obbZmin; + result.m_obbZmax = m_obbZmax; return result; } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs index 9bf3667460..702c336713 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs @@ -304,7 +304,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (GetTriMeshGeo(repData)) hasMesh = true; else - repData.canColide = false; + repData.NoColide = true; } if (!hasMesh) @@ -350,6 +350,15 @@ namespace OpenSim.Region.Physics.OdePlugin return repData; } + public void ChangeActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs, + Vector3 size, byte shapetype, MeshWorkerChange what) + { + ODEPhysRepData repData = CreateActorPhysRep(actor, pbs, null, size, shapetype); + repData.changed |= what; + if (repData != null && actor != null) + ((OdePrim)actor).AddChange(changes.PhysRepData, repData); + } + private void CalculateBasicPrimVolume(ODEPhysRepData repData) { PrimitiveBaseShape _pbs = repData.pbs; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index f328066d4d..7650571e25 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -104,9 +104,6 @@ namespace OpenSim.Region.Physics.OdePlugin private float m_PIDTau; private bool m_usePID; - // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), - // and are for non-VEHICLES only. - private float m_PIDHoverHeight; private float m_PIDHoverTau; private bool m_useHoverPID; @@ -395,6 +392,8 @@ namespace OpenSim.Region.Physics.OdePlugin if (value.IsFinite()) { AddChange(changes.Size, value); + +// _parent_scene.m_meshWorker.ChangeActorPhysRep(this, _pbs, value, m_shapetype, MeshWorkerChange.size); } else { @@ -529,6 +528,7 @@ namespace OpenSim.Region.Physics.OdePlugin set { AddChange(changes.Shape, value); +// _parent_scene.m_meshWorker.ChangeActorPhysRep(this, value, _size, m_shapetype, MeshWorkerChange.shape); } } @@ -542,10 +542,10 @@ namespace OpenSim.Region.Physics.OdePlugin { m_shapetype = value; AddChange(changes.Shape, null); +// _parent_scene.m_meshWorker.ChangeActorPhysRep(this, _pbs, _size, value, MeshWorkerChange.shapetype); } } - public override Vector3 Velocity { get @@ -1529,7 +1529,6 @@ namespace OpenSim.Region.Physics.OdePlugin { if (prim_geom != IntPtr.Zero) { -// _parent_scene.geom_name_map.Remove(prim_geom); _parent_scene.actor_name_map.Remove(prim_geom); try { @@ -1539,11 +1538,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomTriMeshDataDestroy(_triMeshData); _triMeshData = IntPtr.Zero; } - } - - - // catch (System.AccessViolationException) catch (Exception e) { m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction failed for {0} exception {1}", Name, e); @@ -1557,23 +1552,19 @@ namespace OpenSim.Region.Physics.OdePlugin m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction BAD {0}", Name); } - if (m_mesh != null) + lock (m_meshlock) { - _parent_scene.mesher.ReleaseMesh(m_mesh); - m_mesh = null; + if (m_mesh != null) + { + _parent_scene.mesher.ReleaseMesh(m_mesh); + m_mesh = null; + } } Body = IntPtr.Zero; hasOOBoffsetFromMesh = false; } -/* - private void ChildSetGeom(OdePrim odePrim) - { - // well.. - DestroyBody(); - MakeBody(); - } -*/ + //sets non physical prim m_targetSpace to right space in spaces grid for static prims // should only be called for non physical prims unless they are becoming non physical private void SetInStaticSpace(OdePrim prim) @@ -1636,9 +1627,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (Body != IntPtr.Zero) { -// d.BodyDestroy(Body); -// Body = IntPtr.Zero; - // do a more complet destruction DestroyBody(); m_log.Warn("[PHYSICS]: MakeBody called having a body"); } @@ -2500,6 +2488,26 @@ namespace OpenSim.Region.Physics.OdePlugin primOOBradiusSQ = primOOBsize.LengthSquared(); } + private void UpdatePrimBodyData() + { + primMass = m_density * primVolume; + + if (primMass <= 0) + primMass = 0.0001f;//ckrinke: Mass must be greater then zero. + if (primMass > _parent_scene.maximumMassObject) + primMass = _parent_scene.maximumMassObject; + + _mass = primMass; // just in case + + d.MassSetBoxTotal(out primdMass, primMass, primOOBsize.X, primOOBsize.Y, primOOBsize.Z); + + d.MassTranslate(ref primdMass, + primOOBoffset.X, + primOOBoffset.Y, + primOOBoffset.Z); + + primOOBradiusSQ = primOOBsize.LengthSquared(); + } #endregion @@ -3232,6 +3240,86 @@ namespace OpenSim.Region.Physics.OdePlugin changeprimsizeshape(); } + + private void changePhysRepData(ODEPhysRepData repData) + { + CheckDelaySelect(); + + OdePrim parent = (OdePrim)_parent; + + bool chp = childPrim; + + if (chp) + { + if (parent != null) + { + parent.DestroyBody(); + } + } + else + { + DestroyBody(); + } + + RemoveGeom(); + + prim_geom = repData.geo; + _triMeshData = repData.triMeshData; + _size = repData.size; + _pbs = repData.pbs; + m_mesh = repData.mesh; + m_shapetype = repData.shapetype; + + hasOOBoffsetFromMesh = repData.hasOBB; + primOOBoffset = repData.OBBOffset; + primOOBsize = repData.OBB; + + m_NoColide = repData.NoColide; +// m_physCost = repData.physCost; +// m_streamCost = repData.streamCost; + + primVolume = repData.volume; + m_targetSpace = repData.curSpace; + + UpdatePrimBodyData(); + + _parent_scene.actor_name_map[prim_geom] = this; + + if (prim_geom != IntPtr.Zero) + { + d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + d.Quaternion myrot = new d.Quaternion(); + myrot.X = _orientation.X; + myrot.Y = _orientation.Y; + myrot.Z = _orientation.Z; + myrot.W = _orientation.W; + d.GeomSetQuaternion(prim_geom, ref myrot); + } + + if (m_isphysical) + { + if (chp) + { + if (parent != null) + { + parent.MakeBody(); + } + } + else + MakeBody(); + } + + else + { + SetInStaticSpace(this); + UpdateCollisionCatFlags(); + ApplyCollisionCatFlags(); + } + + resetCollisionAccounting(); + } + + private void changeFloatOnWater(bool newval) { m_collidesWater = newval; @@ -3989,6 +4077,10 @@ namespace OpenSim.Region.Physics.OdePlugin changeShape((PrimitiveBaseShape)arg); break; + case changes.PhysRepData: + changePhysRepData((ODEPhysRepData) arg); + break; + case changes.CollidesWater: changeFloatOnWater((bool)arg); break; @@ -4077,6 +4169,8 @@ namespace OpenSim.Region.Physics.OdePlugin donullchange(); break; + + default: donullchange(); break; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index d426112596..d758c85334 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -77,8 +77,9 @@ namespace OpenSim.Region.Physics.OdePlugin public float physCost = 0.0f; public float streamCost = 0; + public MeshWorkerChange changed; public byte shapetype = 0; - public bool canColide = true; + public bool NoColide = false; public bool hasOBB = false; public bool hasMeshVolume = false; } @@ -132,6 +133,14 @@ namespace OpenSim.Region.Physics.OdePlugin light = 7 // compatibility with old viewers } + [Flags] + public enum MeshWorkerChange : uint + { + none = 0, + size = 1, + shape = 2, + shapetype = 3, + } public enum changes : int { @@ -170,6 +179,7 @@ namespace OpenSim.Region.Physics.OdePlugin Size, Shape, + PhysRepData, CollidesWater, VolumeDtc,