diff options
author | Robert Adams | 2012-10-22 16:33:21 -0700 |
---|---|---|
committer | Robert Adams | 2012-10-22 22:24:59 -0700 |
commit | 14eeb8b31b865f7b1927703028b03b6f61693cb6 (patch) | |
tree | 3139a56a535d1919a8cb4b6d93a66e3100866c51 | |
parent | BulletSim: fix problem of not rebuilding shape by clearing last rebuild faile... (diff) | |
download | opensim-SC-14eeb8b31b865f7b1927703028b03b6f61693cb6.zip opensim-SC-14eeb8b31b865f7b1927703028b03b6f61693cb6.tar.gz opensim-SC-14eeb8b31b865f7b1927703028b03b6f61693cb6.tar.bz2 opensim-SC-14eeb8b31b865f7b1927703028b03b6f61693cb6.tar.xz |
BulletSim: fix bug that caused error (and a crash on 32 bit Linux) when mesh assets weren't already in the cache. Comment cleanups.
8 files changed, 51 insertions, 35 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index b58745a..f017cdd 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | |||
@@ -34,6 +34,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
34 | 34 | ||
35 | public abstract class BSConstraint : IDisposable | 35 | public abstract class BSConstraint : IDisposable |
36 | { | 36 | { |
37 | private static string LogHeader = "[BULLETSIM CONSTRAINT]"; | ||
38 | |||
37 | protected BulletSim m_world; | 39 | protected BulletSim m_world; |
38 | protected BulletBody m_body1; | 40 | protected BulletBody m_body1; |
39 | protected BulletBody m_body2; | 41 | protected BulletBody m_body2; |
@@ -124,7 +126,7 @@ public abstract class BSConstraint : IDisposable | |||
124 | } | 126 | } |
125 | else | 127 | else |
126 | { | 128 | { |
127 | m_world.physicsScene.Logger.ErrorFormat("[BULLETSIM CONSTRAINT] CalculateTransforms failed. A={0}, B={1}", Body1.ID, Body2.ID); | 129 | m_world.physicsScene.Logger.ErrorFormat("{0} CalculateTransforms failed. A={1}, B={2}", LogHeader, Body1.ID, Body2.ID); |
128 | } | 130 | } |
129 | } | 131 | } |
130 | return ret; | 132 | return ret; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index f71f3b0..117c878 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -464,8 +464,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
464 | // Set the prim's inertia to zero. The vehicle code handles that and this | 464 | // Set the prim's inertia to zero. The vehicle code handles that and this |
465 | // removes the motion and torque actions introduced by Bullet. | 465 | // removes the motion and torque actions introduced by Bullet. |
466 | Vector3 inertia = Vector3.Zero; | 466 | Vector3 inertia = Vector3.Zero; |
467 | BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia); | 467 | // comment out for DEBUG test |
468 | BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr); | 468 | // BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia); |
469 | // BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr); | ||
469 | } | 470 | } |
470 | 471 | ||
471 | // One step of the vehicle properties for the next 'pTimestep' seconds. | 472 | // One step of the vehicle properties for the next 'pTimestep' seconds. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 2e6b104..c984824 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -165,6 +165,9 @@ public abstract class BSLinkset | |||
165 | bool ret = false; | 165 | bool ret = false; |
166 | lock (m_linksetActivityLock) | 166 | lock (m_linksetActivityLock) |
167 | { | 167 | { |
168 | if (m_children.Contains(child)) | ||
169 | ret = true; | ||
170 | /* | ||
168 | foreach (BSPhysObject bp in m_children) | 171 | foreach (BSPhysObject bp in m_children) |
169 | { | 172 | { |
170 | if (child.LocalID == bp.LocalID) | 173 | if (child.LocalID == bp.LocalID) |
@@ -173,6 +176,7 @@ public abstract class BSLinkset | |||
173 | break; | 176 | break; |
174 | } | 177 | } |
175 | } | 178 | } |
179 | */ | ||
176 | } | 180 | } |
177 | return ret; | 181 | return ret; |
178 | } | 182 | } |
@@ -196,21 +200,20 @@ public abstract class BSLinkset | |||
196 | // Called at taint-time! | 200 | // Called at taint-time! |
197 | public abstract bool MakeStatic(BSPhysObject child); | 201 | public abstract bool MakeStatic(BSPhysObject child); |
198 | 202 | ||
199 | // If the software is handling the movement of all the objects in a linkset | 203 | // Called when a parameter update comes from the physics engine for any object |
200 | // (like if one doesn't use constraints for static linksets), this is called | 204 | // of the linkset is received. |
201 | // when an update for the root of the linkset is received. | ||
202 | // Called at taint-time!! | 205 | // Called at taint-time!! |
203 | public abstract void UpdateProperties(BSPhysObject physObject); | 206 | public abstract void UpdateProperties(BSPhysObject physObject); |
204 | 207 | ||
205 | // Routine used when rebuilding the body of the root of the linkset | 208 | // Routine used when rebuilding the body of the root of the linkset |
206 | // Destroy all the constraints have have been made to root. | 209 | // Destroy all the constraints have have been made to root. |
207 | // This is called when the root body is changing. | 210 | // This is called when the root body is changing. |
208 | // Returns 'true' of something eas actually removed and would need restoring | 211 | // Returns 'true' of something was actually removed and would need restoring |
209 | // Called at taint-time!! | 212 | // Called at taint-time!! |
210 | public abstract bool RemoveBodyDependencies(BSPrim child); | 213 | public abstract bool RemoveBodyDependencies(BSPrim child); |
211 | 214 | ||
212 | // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', | 215 | // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', |
213 | // this routine will restore the removed constraints. | 216 | // this routine will restore the removed constraints. |
214 | // Called at taint-time!! | 217 | // Called at taint-time!! |
215 | public abstract void RestoreBodyDependencies(BSPrim child); | 218 | public abstract void RestoreBodyDependencies(BSPrim child); |
216 | 219 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 8eeeb73..8a750b5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | |||
@@ -46,9 +46,8 @@ public class BSLinksetConstraints : BSLinkset | |||
46 | // May be called at runtime or taint-time (just pass the appropriate flag). | 46 | // May be called at runtime or taint-time (just pass the appropriate flag). |
47 | public override void Refresh(BSPhysObject requestor, bool inTaintTime) | 47 | public override void Refresh(BSPhysObject requestor, bool inTaintTime) |
48 | { | 48 | { |
49 | // If there are no children, not physical or not root, I am not the one that recomputes the constraints | 49 | // If there are no children or not root, I am not the one that recomputes the constraints |
50 | // (For the moment, static linksets do create constraints so remove the test for physical.) | 50 | if (!HasAnyChildren || !IsRoot(requestor)) |
51 | if (!HasAnyChildren || /*!requestor.IsPhysical ||*/ !IsRoot(requestor)) | ||
52 | return; | 51 | return; |
53 | 52 | ||
54 | BSScene.TaintCallback refreshOperation = delegate() | 53 | BSScene.TaintCallback refreshOperation = delegate() |
@@ -85,20 +84,10 @@ public class BSLinksetConstraints : BSLinkset | |||
85 | return false; | 84 | return false; |
86 | } | 85 | } |
87 | 86 | ||
88 | // If the software is handling the movement of all the objects in a linkset | ||
89 | // (like if one doesn't use constraints for static linksets), this is called | ||
90 | // when an update for the root of the linkset is received. | ||
91 | // Called at taint-time!! | 87 | // Called at taint-time!! |
92 | public override void UpdateProperties(BSPhysObject physObject) | 88 | public override void UpdateProperties(BSPhysObject updated) |
93 | { | 89 | { |
94 | // The root local properties have been updated. Apply to the children if appropriate. | 90 | // Nothing to do for constraints on property updates |
95 | if (IsRoot(physObject) && HasAnyChildren) | ||
96 | { | ||
97 | if (!physObject.IsPhysical) | ||
98 | { | ||
99 | // TODO: implement software linkset update for static object linksets | ||
100 | } | ||
101 | } | ||
102 | } | 91 | } |
103 | 92 | ||
104 | // Routine used when rebuilding the body of the root of the linkset | 93 | // Routine used when rebuilding the body of the root of the linkset |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 3c5e6e5..8401c69 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -399,7 +399,7 @@ public sealed class BSPrim : BSPhysObject | |||
399 | { | 399 | { |
400 | // Done at taint time so we're sure the physics engine is not using the variables | 400 | // Done at taint time so we're sure the physics engine is not using the variables |
401 | // Vehicle code changes the parameters for this vehicle type. | 401 | // Vehicle code changes the parameters for this vehicle type. |
402 | this._vehicle.ProcessTypeChange(type); | 402 | _vehicle.ProcessTypeChange(type); |
403 | }); | 403 | }); |
404 | } | 404 | } |
405 | } | 405 | } |
@@ -1246,12 +1246,13 @@ public sealed class BSPrim : BSPhysObject | |||
1246 | FillShapeInfo(out shapeData); | 1246 | FillShapeInfo(out shapeData); |
1247 | 1247 | ||
1248 | // If this prim is part of a linkset, we must remove and restore the physical | 1248 | // If this prim is part of a linkset, we must remove and restore the physical |
1249 | // links of the body is rebuilt. | 1249 | // links if the body is rebuilt. |
1250 | bool needToRestoreLinkset = false; | 1250 | bool needToRestoreLinkset = false; |
1251 | 1251 | ||
1252 | // Create the correct physical representation for this type of object. | 1252 | // Create the correct physical representation for this type of object. |
1253 | // Updates BSBody and BSShape with the new information. | 1253 | // Updates BSBody and BSShape with the new information. |
1254 | // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. | 1254 | // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. |
1255 | // Returns 'true' if either the body or the shape was changed. | ||
1255 | PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, BaseShape, | 1256 | PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, BaseShape, |
1256 | null, delegate(BulletBody dBody) | 1257 | null, delegate(BulletBody dBody) |
1257 | { | 1258 | { |
@@ -1355,7 +1356,7 @@ public sealed class BSPrim : BSPhysObject | |||
1355 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", | 1356 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", |
1356 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); | 1357 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); |
1357 | 1358 | ||
1358 | // BulletSimAPI.DumpRigidBody2(Scene.World.Ptr, BSBody.Ptr); | 1359 | BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, BSBody.ptr); // DEBUG DEBUG DEBUG |
1359 | 1360 | ||
1360 | base.RequestPhysicsterseUpdate(); | 1361 | base.RequestPhysicsterseUpdate(); |
1361 | } | 1362 | } |
@@ -1368,8 +1369,8 @@ public sealed class BSPrim : BSPhysObject | |||
1368 | entprop.Acceleration, entprop.RotationalVelocity); | 1369 | entprop.Acceleration, entprop.RotationalVelocity); |
1369 | } | 1370 | } |
1370 | */ | 1371 | */ |
1371 | // The linkset implimentation might want to know about this. | ||
1372 | 1372 | ||
1373 | // The linkset implimentation might want to know about this. | ||
1373 | Linkset.UpdateProperties(this); | 1374 | Linkset.UpdateProperties(this); |
1374 | } | 1375 | } |
1375 | } | 1376 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 233f1ca..48ee6f6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -716,6 +716,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
716 | } | 716 | } |
717 | catch (Exception e) | 717 | catch (Exception e) |
718 | { | 718 | { |
719 | DetailLog("{0},BSScene.ProcessTaints,doTaintException,id={1}", DetailLogZero, oneCallback.ident); // DEBUG DEBUG DEBUG | ||
719 | m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, oneCallback.ident, e); | 720 | m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, oneCallback.ident, e); |
720 | } | 721 | } |
721 | } | 722 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 89d0d3e..b1833c5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
36 | { | 36 | { |
37 | public class BSShapeCollection : IDisposable | 37 | public class BSShapeCollection : IDisposable |
38 | { | 38 | { |
39 | // private static string LogHeader = "[BULLETSIM SHAPE COLLECTION]"; | 39 | private static string LogHeader = "[BULLETSIM SHAPE COLLECTION]"; |
40 | 40 | ||
41 | protected BSScene PhysicsScene { get; set; } | 41 | protected BSScene PhysicsScene { get; set; } |
42 | 42 | ||
@@ -434,16 +434,26 @@ public class BSShapeCollection : IDisposable | |||
434 | ShapeData shapeData, ShapeData.FixedShapeKey shapeKey) | 434 | ShapeData shapeData, ShapeData.FixedShapeKey shapeKey) |
435 | { | 435 | { |
436 | BulletShape newShape; | 436 | BulletShape newShape; |
437 | // Need to make sure the passed shape information is for the native type. | ||
438 | ShapeData nativeShapeData = shapeData; | ||
439 | nativeShapeData.Type = shapeType; | ||
440 | nativeShapeData.MeshKey = (ulong)shapeKey; | ||
441 | nativeShapeData.HullKey = (ulong)shapeKey; | ||
437 | 442 | ||
438 | if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR) | 443 | if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR) |
439 | { | 444 | { |
440 | newShape = new BulletShape( | 445 | newShape = new BulletShape( |
441 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1.0f, 1.0f, shapeData.Scale), | 446 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1.0f, 1.0f, nativeShapeData.Scale), shapeType); |
442 | shapeType); | 447 | DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", nativeShapeData.ID, nativeShapeData.Scale); |
443 | } | 448 | } |
444 | else | 449 | else |
445 | { | 450 | { |
446 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType); | 451 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType); |
452 | } | ||
453 | if (newShape.ptr == IntPtr.Zero) | ||
454 | { | ||
455 | PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", | ||
456 | LogHeader, nativeShapeData.ID, nativeShapeData.Type); | ||
447 | } | 457 | } |
448 | newShape.shapeKey = (System.UInt64)shapeKey; | 458 | newShape.shapeKey = (System.UInt64)shapeKey; |
449 | newShape.isNativeShape = true; | 459 | newShape.isNativeShape = true; |
@@ -716,6 +726,8 @@ public class BSShapeCollection : IDisposable | |||
716 | { | 726 | { |
717 | prim.LastAssetBuildFailed = true; | 727 | prim.LastAssetBuildFailed = true; |
718 | BSPhysObject xprim = prim; | 728 | BSPhysObject xprim = prim; |
729 | DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lID={1},lastFailed={2}", | ||
730 | LogHeader, shapeData.ID.ToString("X"), prim.LastAssetBuildFailed); | ||
719 | Util.FireAndForget(delegate | 731 | Util.FireAndForget(delegate |
720 | { | 732 | { |
721 | RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; | 733 | RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; |
@@ -732,16 +744,25 @@ public class BSShapeCollection : IDisposable | |||
732 | yprim.BaseShape.SculptData = asset.Data; | 744 | yprim.BaseShape.SculptData = asset.Data; |
733 | // This will cause the prim to see that the filler shape is not the right | 745 | // This will cause the prim to see that the filler shape is not the right |
734 | // one and try again to build the object. | 746 | // one and try again to build the object. |
747 | // No race condition with the native sphere setting since the rebuild is at taint time. | ||
735 | yprim.ForceBodyShapeRebuild(false); | 748 | yprim.ForceBodyShapeRebuild(false); |
736 | 749 | ||
737 | }); | 750 | }); |
738 | } | 751 | } |
739 | }); | 752 | }); |
740 | } | 753 | } |
754 | else | ||
755 | { | ||
756 | if (prim.LastAssetBuildFailed) | ||
757 | { | ||
758 | PhysicsScene.Logger.ErrorFormat("{0} Mesh failed to fetch asset. lID={1}, texture={2}", | ||
759 | LogHeader, shapeData.ID, pbs.SculptTexture); | ||
760 | } | ||
761 | } | ||
741 | 762 | ||
742 | // While we figure out the real problem, stick a simple native shape on the object. | 763 | // While we figure out the real problem, stick a simple native shape on the object. |
743 | BulletShape fillinShape = | 764 | BulletShape fillinShape = |
744 | BuildPhysicalNativeShape(ShapeData.PhysicsShapeType.SHAPE_SPHERE, shapeData, ShapeData.FixedShapeKey.KEY_SPHERE); | 765 | BuildPhysicalNativeShape(ShapeData.PhysicsShapeType.SHAPE_BOX, shapeData, ShapeData.FixedShapeKey.KEY_BOX); |
745 | 766 | ||
746 | return fillinShape; | 767 | return fillinShape; |
747 | } | 768 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 4106534..ae267e3 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -201,9 +201,7 @@ public class BSTerrainManager | |||
201 | // If called with a mapInfo in m_heightMaps and there is an existing terrain body, a new | 201 | // If called with a mapInfo in m_heightMaps and there is an existing terrain body, a new |
202 | // terrain shape is created and added to the body. | 202 | // terrain shape is created and added to the body. |
203 | // This call is most often used to update the heightMap and parameters of the terrain. | 203 | // This call is most often used to update the heightMap and parameters of the terrain. |
204 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when | 204 | // (The above does suggest that some simplification/refactoring is in order.) |
205 | // calling this routine from initialization or taint-time routines) or whether to delay | ||
206 | // all the unmanaged activities to taint-time. | ||
207 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool inTaintTime) | 205 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool inTaintTime) |
208 | { | 206 | { |
209 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},inTaintTime={3}", | 207 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},inTaintTime={3}", |