more changes and more non active code

avinationmerge
UbitUmarov 2012-10-04 08:14:52 +01:00
parent 113549c2e9
commit 89d342b5ce
4 changed files with 144 additions and 29 deletions

View File

@ -89,8 +89,6 @@ namespace OpenSim.Region.Physics.Meshing
m_obbYmax = float.MinValue; m_obbYmax = float.MinValue;
m_obbZmin = float.MaxValue; m_obbZmin = float.MaxValue;
m_obbZmax = float.MinValue; m_obbZmax = float.MinValue;
} }
public int RefCount { get; set; } public int RefCount { get; set; }
@ -99,8 +97,6 @@ namespace OpenSim.Region.Physics.Meshing
public void Scale(Vector3 scale) public void Scale(Vector3 scale)
{ {
} }
public Mesh Clone() public Mesh Clone()
@ -113,6 +109,12 @@ namespace OpenSim.Region.Physics.Meshing
} }
result.m_centroid = m_centroid; result.m_centroid = m_centroid;
result.m_centroidDiv = m_centroidDiv; 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; return result;
} }

View File

@ -304,7 +304,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (GetTriMeshGeo(repData)) if (GetTriMeshGeo(repData))
hasMesh = true; hasMesh = true;
else else
repData.canColide = false; repData.NoColide = true;
} }
if (!hasMesh) if (!hasMesh)
@ -350,6 +350,15 @@ namespace OpenSim.Region.Physics.OdePlugin
return repData; 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) private void CalculateBasicPrimVolume(ODEPhysRepData repData)
{ {
PrimitiveBaseShape _pbs = repData.pbs; PrimitiveBaseShape _pbs = repData.pbs;

View File

@ -104,9 +104,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_PIDTau; private float m_PIDTau;
private bool m_usePID; 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_PIDHoverHeight;
private float m_PIDHoverTau; private float m_PIDHoverTau;
private bool m_useHoverPID; private bool m_useHoverPID;
@ -395,6 +392,8 @@ namespace OpenSim.Region.Physics.OdePlugin
if (value.IsFinite()) if (value.IsFinite())
{ {
AddChange(changes.Size, value); AddChange(changes.Size, value);
// _parent_scene.m_meshWorker.ChangeActorPhysRep(this, _pbs, value, m_shapetype, MeshWorkerChange.size);
} }
else else
{ {
@ -529,6 +528,7 @@ namespace OpenSim.Region.Physics.OdePlugin
set set
{ {
AddChange(changes.Shape, value); 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; m_shapetype = value;
AddChange(changes.Shape, null); AddChange(changes.Shape, null);
// _parent_scene.m_meshWorker.ChangeActorPhysRep(this, _pbs, _size, value, MeshWorkerChange.shapetype);
} }
} }
public override Vector3 Velocity public override Vector3 Velocity
{ {
get get
@ -1529,7 +1529,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
{ {
// _parent_scene.geom_name_map.Remove(prim_geom);
_parent_scene.actor_name_map.Remove(prim_geom); _parent_scene.actor_name_map.Remove(prim_geom);
try try
{ {
@ -1539,11 +1538,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomTriMeshDataDestroy(_triMeshData); d.GeomTriMeshDataDestroy(_triMeshData);
_triMeshData = IntPtr.Zero; _triMeshData = IntPtr.Zero;
} }
} }
// catch (System.AccessViolationException)
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction failed for {0} exception {1}", Name, 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); m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction BAD {0}", Name);
} }
if (m_mesh != null) lock (m_meshlock)
{ {
_parent_scene.mesher.ReleaseMesh(m_mesh); if (m_mesh != null)
m_mesh = null; {
_parent_scene.mesher.ReleaseMesh(m_mesh);
m_mesh = null;
}
} }
Body = IntPtr.Zero; Body = IntPtr.Zero;
hasOOBoffsetFromMesh = false; 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 //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 // should only be called for non physical prims unless they are becoming non physical
private void SetInStaticSpace(OdePrim prim) private void SetInStaticSpace(OdePrim prim)
@ -1636,9 +1627,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero) if (Body != IntPtr.Zero)
{ {
// d.BodyDestroy(Body);
// Body = IntPtr.Zero;
// do a more complet destruction
DestroyBody(); DestroyBody();
m_log.Warn("[PHYSICS]: MakeBody called having a body"); m_log.Warn("[PHYSICS]: MakeBody called having a body");
} }
@ -2500,6 +2488,26 @@ namespace OpenSim.Region.Physics.OdePlugin
primOOBradiusSQ = primOOBsize.LengthSquared(); 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 #endregion
@ -3232,6 +3240,86 @@ namespace OpenSim.Region.Physics.OdePlugin
changeprimsizeshape(); 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) private void changeFloatOnWater(bool newval)
{ {
m_collidesWater = newval; m_collidesWater = newval;
@ -3989,6 +4077,10 @@ namespace OpenSim.Region.Physics.OdePlugin
changeShape((PrimitiveBaseShape)arg); changeShape((PrimitiveBaseShape)arg);
break; break;
case changes.PhysRepData:
changePhysRepData((ODEPhysRepData) arg);
break;
case changes.CollidesWater: case changes.CollidesWater:
changeFloatOnWater((bool)arg); changeFloatOnWater((bool)arg);
break; break;
@ -4077,6 +4169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
donullchange(); donullchange();
break; break;
default: default:
donullchange(); donullchange();
break; break;

View File

@ -77,8 +77,9 @@ namespace OpenSim.Region.Physics.OdePlugin
public float physCost = 0.0f; public float physCost = 0.0f;
public float streamCost = 0; public float streamCost = 0;
public MeshWorkerChange changed;
public byte shapetype = 0; public byte shapetype = 0;
public bool canColide = true; public bool NoColide = false;
public bool hasOBB = false; public bool hasOBB = false;
public bool hasMeshVolume = false; public bool hasMeshVolume = false;
} }
@ -132,6 +133,14 @@ namespace OpenSim.Region.Physics.OdePlugin
light = 7 // compatibility with old viewers light = 7 // compatibility with old viewers
} }
[Flags]
public enum MeshWorkerChange : uint
{
none = 0,
size = 1,
shape = 2,
shapetype = 3,
}
public enum changes : int public enum changes : int
{ {
@ -170,6 +179,7 @@ namespace OpenSim.Region.Physics.OdePlugin
Size, Size,
Shape, Shape,
PhysRepData,
CollidesWater, CollidesWater,
VolumeDtc, VolumeDtc,