avinationmerge
UbitUmarov 2012-10-16 11:26:05 +01:00
parent 1e03344411
commit 91b83fd45e
3 changed files with 82 additions and 67 deletions

View File

@ -32,7 +32,9 @@ namespace OpenSim.Region.Physics.OdePlugin
FailMask = 0xC0, // 11000000 FailMask = 0xC0, // 11000000
AssetFailed = 0x40, // 01000000 AssetFailed = 0x40, // 01000000
MeshFailed = 0x80 // 10000000 MeshFailed = 0x80, // 10000000
MeshNoColide = FailMask | needAsset
} }
public enum meshWorkerCmnds : byte public enum meshWorkerCmnds : byte
@ -119,13 +121,10 @@ namespace OpenSim.Region.Physics.OdePlugin
case meshWorkerCmnds.changefull: case meshWorkerCmnds.changefull:
case meshWorkerCmnds.changeshapetype: case meshWorkerCmnds.changeshapetype:
case meshWorkerCmnds.changesize: case meshWorkerCmnds.changesize:
GetMesh(nextRep);
if (CreateActorPhysRep(nextRep) && m_scene.haveActor(nextRep.actor)) if (CreateActorPhysRep(nextRep) && m_scene.haveActor(nextRep.actor))
m_scene.AddChange(nextRep.actor, changes.PhysRepData, nextRep); m_scene.AddChange(nextRep.actor, changes.PhysRepData, nextRep);
break; break;
case meshWorkerCmnds.addnew:
if (CreateActorPhysRep(nextRep))
m_scene.AddChange(nextRep.actor, changes.AddPhysRep, nextRep);
break;
case meshWorkerCmnds.getmesh: case meshWorkerCmnds.getmesh:
DoRepDataGetMesh(nextRep); DoRepDataGetMesh(nextRep);
break; break;
@ -155,13 +154,13 @@ namespace OpenSim.Region.Physics.OdePlugin
repData.size = size; repData.size = size;
repData.shapetype = shapetype; repData.shapetype = shapetype;
CheckMeshDone(repData); CheckMesh(repData);
CalcVolumeData(repData); CalcVolumeData(repData);
m_scene.AddChange(actor, changes.PhysRepData, repData); m_scene.AddChange(actor, changes.PhysRepData, repData);
return; return;
} }
public void NewActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs, public ODEPhysRepData NewActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs,
Vector3 size, byte shapetype) Vector3 size, byte shapetype)
{ {
ODEPhysRepData repData = new ODEPhysRepData(); ODEPhysRepData repData = new ODEPhysRepData();
@ -170,21 +169,17 @@ namespace OpenSim.Region.Physics.OdePlugin
repData.size = size; repData.size = size;
repData.shapetype = shapetype; repData.shapetype = shapetype;
CheckMeshDone(repData); CheckMesh(repData);
CalcVolumeData(repData); CalcVolumeData(repData);
m_scene.AddChange(actor, changes.AddPhysRep, repData); m_scene.AddChange(actor, changes.AddPhysRep, repData);
return repData;
} }
public void RequestMesh(ODEPhysRepData repData) public void RequestMesh(ODEPhysRepData repData)
{ {
repData.mesh = null; repData.mesh = null;
if (repData.meshState == MeshState.needMesh) if (repData.meshState == MeshState.needAsset)
{
repData.comand = meshWorkerCmnds.changefull;
createqueue.Enqueue(repData);
}
else if (repData.meshState == MeshState.needAsset)
{ {
PrimitiveBaseShape pbs = repData.pbs; PrimitiveBaseShape pbs = repData.pbs;
@ -196,9 +191,7 @@ namespace OpenSim.Region.Physics.OdePlugin
return; return;
} }
if (pbs.SculptTexture != repData.assetID) repData.assetID = pbs.SculptTexture;
return;
repData.meshState = MeshState.loadingAsset; repData.meshState = MeshState.loadingAsset;
repData.comand = meshWorkerCmnds.getmesh; repData.comand = meshWorkerCmnds.getmesh;
@ -209,7 +202,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// creates and prepares a mesh to use and calls parameters estimation // creates and prepares a mesh to use and calls parameters estimation
public bool CreateActorPhysRep(ODEPhysRepData repData) public bool CreateActorPhysRep(ODEPhysRepData repData)
{ {
getMesh(repData);
IMesh mesh = repData.mesh; IMesh mesh = repData.mesh;
if (mesh != null) if (mesh != null)
@ -270,6 +262,15 @@ namespace OpenSim.Region.Physics.OdePlugin
if (repData.assetID != repData.pbs.SculptTexture) if (repData.assetID != repData.pbs.SculptTexture)
return; return;
// check if it is in cache
GetMesh(repData);
if (repData.meshState != MeshState.needAsset)
{
CreateActorPhysRep(repData);
m_scene.AddChange(repData.actor, changes.PhysRepData, repData);
return;
}
RequestAssetDelegate assetProvider = m_scene.RequestAssetMethod; RequestAssetDelegate assetProvider = m_scene.RequestAssetMethod;
if (assetProvider == null) if (assetProvider == null)
return; return;
@ -400,7 +401,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// see if we need a mesh and if so if we have a cached one // see if we need a mesh and if so if we have a cached one
// called with a new repData // called with a new repData
public bool CheckMeshDone(ODEPhysRepData repData) public void CheckMesh(ODEPhysRepData repData)
{ {
PhysicsActor actor = repData.actor; PhysicsActor actor = repData.actor;
PrimitiveBaseShape pbs = repData.pbs; PrimitiveBaseShape pbs = repData.pbs;
@ -408,7 +409,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!needsMeshing(pbs)) if (!needsMeshing(pbs))
{ {
repData.meshState = MeshState.noNeed; repData.meshState = MeshState.noNeed;
return true; return;
} }
IMesh mesh = null; IMesh mesh = null;
@ -441,25 +442,34 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
repData.meshState = MeshState.MeshFailed; repData.meshState = MeshState.MeshFailed;
return;
} }
else else
{
repData.meshState = MeshState.needMesh; repData.meshState = MeshState.needMesh;
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex, true);
return false; if (mesh == null)
{
repData.meshState = MeshState.MeshFailed;
return;
}
}
} }
repData.meshState = MeshState.AssetOK;
repData.mesh = mesh; repData.mesh = mesh;
if (pbs.SculptEntry) if (pbs.SculptEntry)
{ {
repData.meshState = MeshState.AssetOK;
repData.assetID = pbs.SculptTexture; repData.assetID = pbs.SculptTexture;
} }
pbs.SculptData = Utils.EmptyBytes; pbs.SculptData = Utils.EmptyBytes;
return true; return ;
} }
public bool getMesh(ODEPhysRepData repData) public void GetMesh(ODEPhysRepData repData)
{ {
PhysicsActor actor = repData.actor; PhysicsActor actor = repData.actor;
@ -469,17 +479,20 @@ namespace OpenSim.Region.Physics.OdePlugin
repData.hasOBB = false; repData.hasOBB = false;
if (!needsMeshing(pbs)) if (!needsMeshing(pbs))
return false; {
repData.meshState = MeshState.noNeed;
return;
}
if (repData.meshState == MeshState.MeshFailed) if (repData.meshState == MeshState.MeshFailed)
return false; return;
if (pbs.SculptEntry) if (pbs.SculptEntry)
{ {
if (repData.meshState == MeshState.AssetFailed) if (repData.meshState == MeshState.AssetFailed)
{ {
if (pbs.SculptTexture == repData.assetID) if (pbs.SculptTexture == repData.assetID)
return true; return;
} }
} }
@ -500,27 +513,23 @@ namespace OpenSim.Region.Physics.OdePlugin
clod = (int)LevelOfDetail.Low; clod = (int)LevelOfDetail.Low;
} }
// check cached mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex, true);
mesh = m_mesher.GetMesh(actor.Name, pbs, size, clod, true, convex);
if (mesh == null) if (mesh == null)
{ {
if (pbs.SculptEntry) if (pbs.SculptEntry)
{ {
if (pbs.SculptTexture == UUID.Zero) if (pbs.SculptTexture == UUID.Zero)
return false; return;
repData.assetID = pbs.SculptTexture; repData.assetID = pbs.SculptTexture;
repData.meshState = MeshState.AssetOK;
if (pbs.SculptData == null || pbs.SculptData.Length == 0) if (pbs.SculptData == null || pbs.SculptData.Length == 0)
{ {
repData.meshState = MeshState.needAsset; repData.meshState = MeshState.needAsset;
return false; return;
} }
} }
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex,true);
} }
repData.mesh = mesh; repData.mesh = mesh;
@ -533,12 +542,12 @@ namespace OpenSim.Region.Physics.OdePlugin
else else
repData.meshState = MeshState.MeshFailed; repData.meshState = MeshState.MeshFailed;
return false; return;
} }
repData.meshState = MeshState.AssetOK; repData.meshState = MeshState.AssetOK;
return true; return;
} }
private void CalculateBasicPrimVolume(ODEPhysRepData repData) private void CalculateBasicPrimVolume(ODEPhysRepData repData)

View File

@ -1104,7 +1104,12 @@ namespace OpenSim.Region.Physics.OdePlugin
m_building = true; // control must set this to false when done m_building = true; // control must set this to false when done
_parent_scene.m_meshWorker.NewActorPhysRep(this, _pbs, _size, m_shapetype); // get basic mass parameters
ODEPhysRepData repData = _parent_scene.m_meshWorker.NewActorPhysRep(this, _pbs, _size, m_shapetype);
primVolume = repData.volume;
UpdatePrimBodyData();
} }
private void resetCollisionAccounting() private void resetCollisionAccounting()
@ -1466,7 +1471,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_NoColide = false; m_NoColide = false;
if ((m_meshState & MeshState.FailMask) != 0) if ((m_meshState & MeshState.MeshNoColide) != 0)
m_NoColide = true; m_NoColide = true;
else if(m_mesh != null) else if(m_mesh != null)

View File

@ -1729,6 +1729,17 @@ namespace OpenSim.Region.Physics.OdePlugin
ODEchangeitem item; ODEchangeitem item;
d.WorldSetQuickStepNumIterations(world, curphysiteractions);
while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
{
try
{
// clear pointer/counter to contacts to pass into joints
m_global_contactcount = 0;
if (ChangesQueue.Count > 0) if (ChangesQueue.Count > 0)
{ {
int ttmpstart = Util.EnvironmentTickCount(); int ttmpstart = Util.EnvironmentTickCount();
@ -1757,16 +1768,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
d.WorldSetQuickStepNumIterations(world, curphysiteractions);
while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
{
try
{
// clear pointer/counter to contacts to pass into joints
m_global_contactcount = 0;
// Move characters // Move characters
lock (_characters) lock (_characters)
{ {