shapetype support on chOde so it can also request a simple convex hull 'mesh'

avinationmerge
UbitUmarov 2012-03-21 12:57:46 +00:00
parent 312f0c6970
commit 316f272b62
2 changed files with 46 additions and 34 deletions

View File

@ -179,6 +179,9 @@ namespace OpenSim.Region.Physics.OdePlugin
public bool m_outofBounds;
private float m_density = 10.000006836f; // Aluminum g/cm3;
private byte m_shapetype;
private byte m_taintshapetype;
public bool _zeroFlag; // if body has been stopped
private bool m_lastUpdateSent;
@ -315,7 +318,8 @@ namespace OpenSim.Region.Physics.OdePlugin
}
public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical,bool pisPhantom, CollisionLocker dode, uint localid)
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical,
bool pisPhantom,byte shapetype, CollisionLocker dode, uint localid)
{
m_localID = localid;
ode = dode;
@ -360,6 +364,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_taintrot = _orientation;
_mesh = mesh;
_pbs = pbs;
m_shapetype = shapetype;
m_taintshapetype = shapetype;
_parent_scene = parent_scene;
m_targetSpace = (IntPtr)0;
@ -605,6 +611,19 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
public override byte PhysicsShapeType
{
get
{
return m_shapetype;
}
set
{
m_taintshapetype = value;
_parent_scene.AddPhysicsActorTaint(this);
}
}
public override Vector3 Velocity
{
get
@ -1535,6 +1554,12 @@ namespace OpenSim.Region.Physics.OdePlugin
changesize(timestep);
//
if(m_taintshapetype != m_shapetype)
{
m_shapetype = m_taintshapetype;
changeshape(timestep);
}
if (m_taintshape)
changeshape(timestep);
//
@ -2476,9 +2501,16 @@ namespace OpenSim.Region.Physics.OdePlugin
if (IsPhysical)
meshlod = _parent_scene.MeshSculptphysicalLOD;
bool convex;
if (m_shapetype == 2)
convex = true;
else
convex = false;
try
{
mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true);
mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true, convex);
}
catch
{

View File

@ -1720,7 +1720,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
IMesh mesh, PrimitiveBaseShape pbs, bool isphysical, uint localid)
IMesh mesh, PrimitiveBaseShape pbs, bool isphysical, bool isphantom, byte shapetype, uint localid)
{
Vector3 pos = position;
@ -1730,27 +1730,7 @@ namespace OpenSim.Region.Physics.OdePlugin
OdePrim newPrim;
lock (OdeLock)
{
newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical,false, ode, localid);
lock (_prims)
_prims.Add(newPrim);
}
return newPrim;
}
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, siz, rot, mesh, pbs, isphysical, isphantom, ode, localid);
newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs, isphysical, isphantom, shapetype, ode, localid);
lock (_prims)
_prims.Add(newPrim);
@ -1781,7 +1761,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (needsMeshing(pbs))
mesh = mesher.CreateMesh(primName, pbs, size, (int)LevelOfDetail.High, true);
result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, localid);
result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical,false,0, localid);
return result;
}
@ -1795,25 +1775,25 @@ namespace OpenSim.Region.Physics.OdePlugin
if (needsMeshing(pbs))
mesh = mesher.CreateMesh(primName, pbs, size, (int)LevelOfDetail.High, true);
result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, isPhantom, localid);
result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, isPhantom,0, localid);
return result;
}
/*
public override PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position,
uint localid, byte[] sdata)
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapetype, uint localid)
{
PhysicsActor result;
IMesh mesh = null;
result = AddPrim(primName, position, parent,
pbs, localid, sdata);
if (needsMeshing(pbs))
mesh = mesher.CreateMesh(primName, pbs, size, (int)LevelOfDetail.High, true);
result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, isPhantom, shapetype, localid);
return result;
}
*/
public override float TimeDilation
{
get { return m_timeDilation; }