When a mesh object is added to a scene, delay adding the physics actor until the sculpt data has been added to the shape (possibly via an async asset service request)

This prevents spurious 'no asset data' for meshes added on startup.
bulletsim
Justin Clark-Casey (justincc) 2011-07-12 02:33:09 +01:00
parent dbd954d701
commit df0e5cc9fe
5 changed files with 39 additions and 29 deletions

View File

@ -1751,8 +1751,9 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart rootPart = group.GetChildPart(group.UUID); SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.Flags &= ~PrimFlags.Scripted; rootPart.Flags &= ~PrimFlags.Scripted;
rootPart.TrimPermissions(); rootPart.TrimPermissions();
group.CheckSculptAndLoad();
//rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); // Don't do this here - it will get done later on when sculpt data is loaded.
// group.CheckSculptAndLoad();
} }
m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");

View File

@ -1896,7 +1896,12 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); // If this part is a sculpt then delay the physics update until we've asynchronously loaded the
// mesh data.
if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
CheckSculptAndLoad();
else
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
} }
} }
} }

View File

@ -638,7 +638,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float profileEnd; float profileEnd;
if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible) if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible)
{ {
taperX1 = _pbs.PathScaleX * 0.01f; taperX1 = _pbs.PathScaleX * 0.01f;
if (taperX1 > 1.0f) if (taperX1 > 1.0f)
taperX1 = 2.0f - taperX1; taperX1 = 2.0f - taperX1;
@ -648,9 +648,9 @@ namespace OpenSim.Region.Physics.OdePlugin
if (taperY1 > 1.0f) if (taperY1 > 1.0f)
taperY1 = 2.0f - taperY1; taperY1 = 2.0f - taperY1;
taperY = 1.0f - taperY1; taperY = 1.0f - taperY1;
} }
else else
{ {
taperX = _pbs.PathTaperX * 0.01f; taperX = _pbs.PathTaperX * 0.01f;
if (taperX < 0.0f) if (taperX < 0.0f)
taperX = -taperX; taperX = -taperX;
@ -660,9 +660,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (taperY < 0.0f) if (taperY < 0.0f)
taperY = -taperY; taperY = -taperY;
taperY1 = 1.0f - taperY; taperY1 = 1.0f - taperY;
}
}
volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY); volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY);
@ -859,7 +857,9 @@ namespace OpenSim.Region.Physics.OdePlugin
public void ProcessTaints(float timestep) public void ProcessTaints(float timestep)
{ {
//Console.WriteLine("ProcessTaints for " + Name); #if SPAM
Console.WriteLine("ZProcessTaints for " + Name);
#endif
if (m_taintadd) if (m_taintadd)
{ {
changeadd(timestep); changeadd(timestep);
@ -1323,7 +1323,9 @@ namespace OpenSim.Region.Physics.OdePlugin
public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
{ {
//Console.WriteLine("CreateGeom:"); #if SPAM
Console.WriteLine("CreateGeom:");
#endif
if (_mesh != null) if (_mesh != null)
{ {
setMesh(_parent_scene, _mesh); setMesh(_parent_scene, _mesh);
@ -1944,7 +1946,6 @@ Console.WriteLine(" JointCreateFixed");
if (_parent_scene.needsMeshing(_pbs)) if (_parent_scene.needsMeshing(_pbs))
mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
//IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
#if SPAM #if SPAM
Console.WriteLine("changesize 1"); Console.WriteLine("changesize 1");
#endif #endif
@ -2056,8 +2057,8 @@ Console.WriteLine("changesize 2");
if (IsPhysical) if (IsPhysical)
meshlod = _parent_scene.MeshSculptphysicalLOD; meshlod = _parent_scene.MeshSculptphysicalLOD;
IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
// createmesh returns null when it doesn't mesh. // createmesh returns null when it doesn't mesh.
IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
#if SPAM #if SPAM
Console.WriteLine("changeshape needed meshing"); Console.WriteLine("changeshape needed meshing");
#endif #endif

View File

@ -1723,20 +1723,21 @@ namespace OpenSim.Region.Physics.OdePlugin
PhysicsActor result; PhysicsActor result;
IMesh mesh = null; IMesh mesh = null;
if (needsMeshing(pbs)) // Don't create the mesh here - wait until the mesh data is loaded from the asset store.
{ // if (needsMeshing(pbs))
try // {
{ // try
mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); // {
} // mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical);
catch(Exception e) // }
{ // catch(Exception e)
m_log.ErrorFormat("[PHYSICS]: Exception while meshing prim {0}.", primName); // {
m_log.Debug(e.ToString()); // m_log.ErrorFormat("[PHYSICS]: Exception while meshing prim {0}.", primName);
mesh = null; // m_log.Debug(e.ToString());
return null; // mesh = null;
} // return null;
} // }
// }
result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical);
@ -2590,7 +2591,9 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (!(_taintedPrimH.Contains(taintedprim))) if (!(_taintedPrimH.Contains(taintedprim)))
{ {
//Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.m_primName); #if SPAM
Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
#endif
_taintedPrimH.Add(taintedprim); // HashSet for searching _taintedPrimH.Add(taintedprim); // HashSet for searching
_taintedPrimL.Add(taintedprim); // List for ordered readout _taintedPrimL.Add(taintedprim); // List for ordered readout
} }