aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs87
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs9
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs53
3 files changed, 82 insertions, 67 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs
index 768b0e6..73dd2fd 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs
@@ -32,7 +32,9 @@ namespace OpenSim.Region.Physics.OdePlugin
32 32
33 FailMask = 0xC0, // 11000000 33 FailMask = 0xC0, // 11000000
34 AssetFailed = 0x40, // 01000000 34 AssetFailed = 0x40, // 01000000
35 MeshFailed = 0x80 // 10000000 35 MeshFailed = 0x80, // 10000000
36
37 MeshNoColide = FailMask | needAsset
36 } 38 }
37 39
38 public enum meshWorkerCmnds : byte 40 public enum meshWorkerCmnds : byte
@@ -119,13 +121,10 @@ namespace OpenSim.Region.Physics.OdePlugin
119 case meshWorkerCmnds.changefull: 121 case meshWorkerCmnds.changefull:
120 case meshWorkerCmnds.changeshapetype: 122 case meshWorkerCmnds.changeshapetype:
121 case meshWorkerCmnds.changesize: 123 case meshWorkerCmnds.changesize:
124 GetMesh(nextRep);
122 if (CreateActorPhysRep(nextRep) && m_scene.haveActor(nextRep.actor)) 125 if (CreateActorPhysRep(nextRep) && m_scene.haveActor(nextRep.actor))
123 m_scene.AddChange(nextRep.actor, changes.PhysRepData, nextRep); 126 m_scene.AddChange(nextRep.actor, changes.PhysRepData, nextRep);
124 break; 127 break;
125 case meshWorkerCmnds.addnew:
126 if (CreateActorPhysRep(nextRep))
127 m_scene.AddChange(nextRep.actor, changes.AddPhysRep, nextRep);
128 break;
129 case meshWorkerCmnds.getmesh: 128 case meshWorkerCmnds.getmesh:
130 DoRepDataGetMesh(nextRep); 129 DoRepDataGetMesh(nextRep);
131 break; 130 break;
@@ -155,13 +154,13 @@ namespace OpenSim.Region.Physics.OdePlugin
155 repData.size = size; 154 repData.size = size;
156 repData.shapetype = shapetype; 155 repData.shapetype = shapetype;
157 156
158 CheckMeshDone(repData); 157 CheckMesh(repData);
159 CalcVolumeData(repData); 158 CalcVolumeData(repData);
160 m_scene.AddChange(actor, changes.PhysRepData, repData); 159 m_scene.AddChange(actor, changes.PhysRepData, repData);
161 return; 160 return;
162 } 161 }
163 162
164 public void NewActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs, 163 public ODEPhysRepData NewActorPhysRep(PhysicsActor actor, PrimitiveBaseShape pbs,
165 Vector3 size, byte shapetype) 164 Vector3 size, byte shapetype)
166 { 165 {
167 ODEPhysRepData repData = new ODEPhysRepData(); 166 ODEPhysRepData repData = new ODEPhysRepData();
@@ -170,21 +169,17 @@ namespace OpenSim.Region.Physics.OdePlugin
170 repData.size = size; 169 repData.size = size;
171 repData.shapetype = shapetype; 170 repData.shapetype = shapetype;
172 171
173 CheckMeshDone(repData); 172 CheckMesh(repData);
174 CalcVolumeData(repData); 173 CalcVolumeData(repData);
175 m_scene.AddChange(actor, changes.AddPhysRep, repData); 174 m_scene.AddChange(actor, changes.AddPhysRep, repData);
175 return repData;
176 } 176 }
177 177
178 public void RequestMesh(ODEPhysRepData repData) 178 public void RequestMesh(ODEPhysRepData repData)
179 { 179 {
180 repData.mesh = null; 180 repData.mesh = null;
181 181
182 if (repData.meshState == MeshState.needMesh) 182 if (repData.meshState == MeshState.needAsset)
183 {
184 repData.comand = meshWorkerCmnds.changefull;
185 createqueue.Enqueue(repData);
186 }
187 else if (repData.meshState == MeshState.needAsset)
188 { 183 {
189 PrimitiveBaseShape pbs = repData.pbs; 184 PrimitiveBaseShape pbs = repData.pbs;
190 185
@@ -196,9 +191,7 @@ namespace OpenSim.Region.Physics.OdePlugin
196 return; 191 return;
197 } 192 }
198 193
199 if (pbs.SculptTexture != repData.assetID) 194 repData.assetID = pbs.SculptTexture;
200 return;
201
202 repData.meshState = MeshState.loadingAsset; 195 repData.meshState = MeshState.loadingAsset;
203 196
204 repData.comand = meshWorkerCmnds.getmesh; 197 repData.comand = meshWorkerCmnds.getmesh;
@@ -209,7 +202,6 @@ namespace OpenSim.Region.Physics.OdePlugin
209 // creates and prepares a mesh to use and calls parameters estimation 202 // creates and prepares a mesh to use and calls parameters estimation
210 public bool CreateActorPhysRep(ODEPhysRepData repData) 203 public bool CreateActorPhysRep(ODEPhysRepData repData)
211 { 204 {
212 getMesh(repData);
213 IMesh mesh = repData.mesh; 205 IMesh mesh = repData.mesh;
214 206
215 if (mesh != null) 207 if (mesh != null)
@@ -270,6 +262,15 @@ namespace OpenSim.Region.Physics.OdePlugin
270 if (repData.assetID != repData.pbs.SculptTexture) 262 if (repData.assetID != repData.pbs.SculptTexture)
271 return; 263 return;
272 264
265 // check if it is in cache
266 GetMesh(repData);
267 if (repData.meshState != MeshState.needAsset)
268 {
269 CreateActorPhysRep(repData);
270 m_scene.AddChange(repData.actor, changes.PhysRepData, repData);
271 return;
272 }
273
273 RequestAssetDelegate assetProvider = m_scene.RequestAssetMethod; 274 RequestAssetDelegate assetProvider = m_scene.RequestAssetMethod;
274 if (assetProvider == null) 275 if (assetProvider == null)
275 return; 276 return;
@@ -400,7 +401,7 @@ namespace OpenSim.Region.Physics.OdePlugin
400 401
401 // see if we need a mesh and if so if we have a cached one 402 // see if we need a mesh and if so if we have a cached one
402 // called with a new repData 403 // called with a new repData
403 public bool CheckMeshDone(ODEPhysRepData repData) 404 public void CheckMesh(ODEPhysRepData repData)
404 { 405 {
405 PhysicsActor actor = repData.actor; 406 PhysicsActor actor = repData.actor;
406 PrimitiveBaseShape pbs = repData.pbs; 407 PrimitiveBaseShape pbs = repData.pbs;
@@ -408,7 +409,7 @@ namespace OpenSim.Region.Physics.OdePlugin
408 if (!needsMeshing(pbs)) 409 if (!needsMeshing(pbs))
409 { 410 {
410 repData.meshState = MeshState.noNeed; 411 repData.meshState = MeshState.noNeed;
411 return true; 412 return;
412 } 413 }
413 414
414 IMesh mesh = null; 415 IMesh mesh = null;
@@ -437,29 +438,38 @@ namespace OpenSim.Region.Physics.OdePlugin
437 if (pbs.SculptTexture != null && pbs.SculptTexture != UUID.Zero) 438 if (pbs.SculptTexture != null && pbs.SculptTexture != UUID.Zero)
438 { 439 {
439 repData.assetID = pbs.SculptTexture; 440 repData.assetID = pbs.SculptTexture;
440 repData.meshState = MeshState.needAsset; 441 repData.meshState = MeshState.needAsset;
441 } 442 }
442 else 443 else
443 repData.meshState = MeshState.MeshFailed; 444 repData.meshState = MeshState.MeshFailed;
445
446 return;
444 } 447 }
445 else 448 else
449 {
446 repData.meshState = MeshState.needMesh; 450 repData.meshState = MeshState.needMesh;
447 451 mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex, true);
448 return false; 452 if (mesh == null)
453 {
454 repData.meshState = MeshState.MeshFailed;
455 return;
456 }
457 }
449 } 458 }
450 459
460 repData.meshState = MeshState.AssetOK;
451 repData.mesh = mesh; 461 repData.mesh = mesh;
462
452 if (pbs.SculptEntry) 463 if (pbs.SculptEntry)
453 { 464 {
454 repData.meshState = MeshState.AssetOK;
455 repData.assetID = pbs.SculptTexture; 465 repData.assetID = pbs.SculptTexture;
456 } 466 }
457 467
458 pbs.SculptData = Utils.EmptyBytes; 468 pbs.SculptData = Utils.EmptyBytes;
459 return true; 469 return ;
460 } 470 }
461 471
462 public bool getMesh(ODEPhysRepData repData) 472 public void GetMesh(ODEPhysRepData repData)
463 { 473 {
464 PhysicsActor actor = repData.actor; 474 PhysicsActor actor = repData.actor;
465 475
@@ -469,17 +479,20 @@ namespace OpenSim.Region.Physics.OdePlugin
469 repData.hasOBB = false; 479 repData.hasOBB = false;
470 480
471 if (!needsMeshing(pbs)) 481 if (!needsMeshing(pbs))
472 return false; 482 {
483 repData.meshState = MeshState.noNeed;
484 return;
485 }
473 486
474 if (repData.meshState == MeshState.MeshFailed) 487 if (repData.meshState == MeshState.MeshFailed)
475 return false; 488 return;
476 489
477 if (pbs.SculptEntry) 490 if (pbs.SculptEntry)
478 { 491 {
479 if (repData.meshState == MeshState.AssetFailed) 492 if (repData.meshState == MeshState.AssetFailed)
480 { 493 {
481 if (pbs.SculptTexture == repData.assetID) 494 if (pbs.SculptTexture == repData.assetID)
482 return true; 495 return;
483 } 496 }
484 } 497 }
485 498
@@ -500,27 +513,23 @@ namespace OpenSim.Region.Physics.OdePlugin
500 clod = (int)LevelOfDetail.Low; 513 clod = (int)LevelOfDetail.Low;
501 } 514 }
502 515
503 // check cached 516 mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex, true);
504 mesh = m_mesher.GetMesh(actor.Name, pbs, size, clod, true, convex); 517
505
506 if (mesh == null) 518 if (mesh == null)
507 { 519 {
508 if (pbs.SculptEntry) 520 if (pbs.SculptEntry)
509 { 521 {
510 if (pbs.SculptTexture == UUID.Zero) 522 if (pbs.SculptTexture == UUID.Zero)
511 return false; 523 return;
512 524
513 repData.assetID = pbs.SculptTexture; 525 repData.assetID = pbs.SculptTexture;
514 repData.meshState = MeshState.AssetOK;
515 526
516 if (pbs.SculptData == null || pbs.SculptData.Length == 0) 527 if (pbs.SculptData == null || pbs.SculptData.Length == 0)
517 { 528 {
518 repData.meshState = MeshState.needAsset; 529 repData.meshState = MeshState.needAsset;
519 return false; 530 return;
520 } 531 }
521 } 532 }
522
523 mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex,true);
524 } 533 }
525 534
526 repData.mesh = mesh; 535 repData.mesh = mesh;
@@ -533,12 +542,12 @@ namespace OpenSim.Region.Physics.OdePlugin
533 else 542 else
534 repData.meshState = MeshState.MeshFailed; 543 repData.meshState = MeshState.MeshFailed;
535 544
536 return false; 545 return;
537 } 546 }
538 547
539 repData.meshState = MeshState.AssetOK; 548 repData.meshState = MeshState.AssetOK;
540 549
541 return true; 550 return;
542 } 551 }
543 552
544 private void CalculateBasicPrimVolume(ODEPhysRepData repData) 553 private void CalculateBasicPrimVolume(ODEPhysRepData repData)
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index f083d38..ce67cc4 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -1104,7 +1104,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1104 1104
1105 m_building = true; // control must set this to false when done 1105 m_building = true; // control must set this to false when done
1106 1106
1107 _parent_scene.m_meshWorker.NewActorPhysRep(this, _pbs, _size, m_shapetype); 1107 // get basic mass parameters
1108 ODEPhysRepData repData = _parent_scene.m_meshWorker.NewActorPhysRep(this, _pbs, _size, m_shapetype);
1109
1110 primVolume = repData.volume;
1111
1112 UpdatePrimBodyData();
1108 } 1113 }
1109 1114
1110 private void resetCollisionAccounting() 1115 private void resetCollisionAccounting()
@@ -1466,7 +1471,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1466 1471
1467 m_NoColide = false; 1472 m_NoColide = false;
1468 1473
1469 if ((m_meshState & MeshState.FailMask) != 0) 1474 if ((m_meshState & MeshState.MeshNoColide) != 0)
1470 m_NoColide = true; 1475 m_NoColide = true;
1471 1476
1472 else if(m_mesh != null) 1477 else if(m_mesh != null)
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 6592e6c..b98f177 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -1729,33 +1729,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1729 1729
1730 ODEchangeitem item; 1730 ODEchangeitem item;
1731 1731
1732 if (ChangesQueue.Count > 0)
1733 {
1734 int ttmpstart = Util.EnvironmentTickCount();
1735 int ttmp;
1736 1732
1737 while (ChangesQueue.Dequeue(out item))
1738 {
1739 if (item.actor != null)
1740 {
1741 try
1742 {
1743 if (item.actor is OdeCharacter)
1744 ((OdeCharacter)item.actor).DoAChange(item.what, item.arg);
1745 else if (((OdePrim)item.actor).DoAChange(item.what, item.arg))
1746 RemovePrimThreadLocked((OdePrim)item.actor);
1747 }
1748 catch
1749 {
1750 m_log.WarnFormat("[PHYSICS]: doChange failed for a actor {0} {1}",
1751 item.actor.Name, item.what.ToString());
1752 }
1753 }
1754 ttmp = Util.EnvironmentTickCountSubtract(ttmpstart);
1755 if (ttmp > 20)
1756 break;
1757 }
1758 }
1759 1733
1760 d.WorldSetQuickStepNumIterations(world, curphysiteractions); 1734 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1761 1735
@@ -1766,6 +1740,33 @@ namespace OpenSim.Region.Physics.OdePlugin
1766 // clear pointer/counter to contacts to pass into joints 1740 // clear pointer/counter to contacts to pass into joints
1767 m_global_contactcount = 0; 1741 m_global_contactcount = 0;
1768 1742
1743 if (ChangesQueue.Count > 0)
1744 {
1745 int ttmpstart = Util.EnvironmentTickCount();
1746 int ttmp;
1747
1748 while (ChangesQueue.Dequeue(out item))
1749 {
1750 if (item.actor != null)
1751 {
1752 try
1753 {
1754 if (item.actor is OdeCharacter)
1755 ((OdeCharacter)item.actor).DoAChange(item.what, item.arg);
1756 else if (((OdePrim)item.actor).DoAChange(item.what, item.arg))
1757 RemovePrimThreadLocked((OdePrim)item.actor);
1758 }
1759 catch
1760 {
1761 m_log.WarnFormat("[PHYSICS]: doChange failed for a actor {0} {1}",
1762 item.actor.Name, item.what.ToString());
1763 }
1764 }
1765 ttmp = Util.EnvironmentTickCountSubtract(ttmpstart);
1766 if (ttmp > 20)
1767 break;
1768 }
1769 }
1769 1770
1770 // Move characters 1771 // Move characters
1771 lock (_characters) 1772 lock (_characters)