From 21a76a619f62e76f366d8bfa1f37f776cfb92fa3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 11 Mar 2012 06:32:06 +0000 Subject: [PATCH] initial steps to support physical phantoms --- OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 8 ++++- .../Region/Physics/ChOdePlugin/OdePlugin.cs | 33 +++++++++++++++---- .../Region/Physics/Manager/PhysicsActor.cs | 2 ++ .../Region/Physics/Manager/PhysicsScene.cs | 9 +++-- .../Region/Physics/UbitOdePlugin/ODEPrim.cs | 6 +++- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 28 ++++++++++++++-- 6 files changed, 73 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 3ed3b5a3c8..42a408ee37 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs @@ -131,6 +131,7 @@ namespace OpenSim.Region.Physics.OdePlugin public bool m_disabled; public bool m_taintadd; public bool m_taintselected; + public bool m_taintphantom; public bool m_taintCollidesWater; public uint m_localID; @@ -161,6 +162,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool iscolliding; private bool m_isphysical; + private bool m_isphantom; private bool m_isSelected; private bool m_NoColide; // for now only for internal use for bad meshs @@ -311,8 +313,9 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintvehicledata = vdata; _parent_scene.AddPhysicsActorTaint(this); } + public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size, - Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode, uint localid) + Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical,bool pisPhantom, CollisionLocker dode, uint localid) { m_localID = localid; ode = dode; @@ -373,6 +376,9 @@ namespace OpenSim.Region.Physics.OdePlugin m_targetSpace = _parent_scene.space; } + m_isphantom = pisPhantom; + m_taintphantom = pisPhantom; + _triMeshData = IntPtr.Zero; m_NoColide = false; diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs index 05f6faec5f..ea89d87f40 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs @@ -1730,7 +1730,7 @@ namespace OpenSim.Region.Physics.OdePlugin OdePrim newPrim; lock (OdeLock) { - newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, ode, localid); + newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical,false, ode, localid); lock (_prims) _prims.Add(newPrim); @@ -1738,23 +1738,27 @@ namespace OpenSim.Region.Physics.OdePlugin return newPrim; } -/* - private PhysicsActor AddPrim(String name, Vector3 position, PhysicsActor parent, - PrimitiveBaseShape pbs, uint localid, byte[] sdata) + + private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, + IMesh mesh, PrimitiveBaseShape pbs, bool isphysical, bool isphantom, uint localid) { + Vector3 pos = position; + Vector3 siz = size; + Quaternion rot = rotation; OdePrim newPrim; lock (OdeLock) { - newPrim = new OdePrim(name, this, pos, parent, pbs, ode, localid, sdata); + newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, isphantom, ode, localid); + lock (_prims) _prims.Add(newPrim); } return newPrim; } -*/ + public void addActivePrim(OdePrim activatePrim) { @@ -1781,6 +1785,23 @@ namespace OpenSim.Region.Physics.OdePlugin return result; } + + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, + Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid) + { + PhysicsActor result; + IMesh mesh = null; + + if (needsMeshing(pbs)) + mesh = mesher.CreateMesh(primName, pbs, size, (int)LevelOfDetail.High, true); + + result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, isPhantom, localid); + + return result; + } + + + /* public override PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position, uint localid, byte[] sdata) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 1a0c2a76c1..46f5b6f7c9 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -170,6 +170,8 @@ namespace OpenSim.Region.Physics.Manager public abstract Vector3 Size { get; set; } + public bool Phantom { get; set; } + public abstract PrimitiveBaseShape Shape { set; } uint m_baseLocalID; diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 0346d4e2f0..eca6a0f4c2 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -122,9 +122,6 @@ namespace OpenSim.Region.Physics.Manager /// public abstract void RemovePrim(PhysicsActor prim); - //public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, - // Vector3 size, Quaternion rotation); //To be removed - Actually removed! - public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, uint localid); @@ -134,6 +131,12 @@ namespace OpenSim.Region.Physics.Manager return null; } + public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, + Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid) + { + return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid); + } + public virtual float TimeDilation { get { return 1.0f; } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 563d527dcd..63b29bac9b 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -65,6 +65,7 @@ namespace OpenSim.Region.Physics.OdePlugin private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_isphysical; + private bool m_isPhantom; private bool m_fakeisphysical; protected bool m_building; @@ -831,9 +832,10 @@ namespace OpenSim.Region.Physics.OdePlugin public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size, - Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) + Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical,bool pisPhantom,uint plocalID) { Name = primName; + LocalID = plocalID; m_vehicle = null; @@ -908,6 +910,8 @@ namespace OpenSim.Region.Physics.OdePlugin m_isSelected = false; m_delaySelect = false; + m_isPhantom = pisPhantom; + mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu; bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 14516f98ed..b111172c48 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -1140,12 +1140,29 @@ namespace OpenSim.Region.Physics.OdePlugin OdePrim newPrim; lock (OdeLock) { - newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical); + newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical,false,localID); + + lock (_prims) + _prims.Add(newPrim); + } + return newPrim; + } + + private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, + PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, uint localID) + { + Vector3 pos = position; + Vector3 siz = size; + Quaternion rot = rotation; + + OdePrim newPrim; + lock (OdeLock) + { + newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical,isPhantom,localID); lock (_prims) _prims.Add(newPrim); } - newPrim.LocalID = localID; return newPrim; } @@ -1168,6 +1185,13 @@ namespace OpenSim.Region.Physics.OdePlugin } } + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, + Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid) + { + return AddPrim(primName, position, size, rotation, pbs, isPhysical, isPhantom, localid); + } + + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, uint localid) {