aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-03-23 11:00:52 -0700
committerRobert Adams2013-03-25 15:40:43 -0700
commit953090fd62c2f8647d0e04bc3890a04a7076dbad (patch)
treeaf514b520cd7f5f9edc7de5d4ede87e5ea7cb476 /OpenSim
parentBulletSim: parameterize C# HACD hull creation. Add feature of reducing max hu... (diff)
downloadopensim-SC-953090fd62c2f8647d0e04bc3890a04a7076dbad.zip
opensim-SC-953090fd62c2f8647d0e04bc3890a04a7076dbad.tar.gz
opensim-SC-953090fd62c2f8647d0e04bc3890a04a7076dbad.tar.bz2
opensim-SC-953090fd62c2f8647d0e04bc3890a04a7076dbad.tar.xz
BulletSim: fix possible race condition where an prim's asset can be requested quicker than the asset fetcher returns and thus falsely reporting that an asset was not fetched and defaulting the assset to a bounding box.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs12
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs21
3 files changed, 24 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index f953c1e..6bb88c7 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -86,7 +86,7 @@ public abstract class BSPhysObject : PhysicsActor
86 PhysBody = new BulletBody(localID); 86 PhysBody = new BulletBody(localID);
87 PhysShape = new BulletShape(); 87 PhysShape = new BulletShape();
88 88
89 LastAssetBuildFailed = false; 89 PrimAssetState = PrimAssetCondition.Unknown;
90 90
91 // Default material type. Also sets Friction, Restitution and Density. 91 // Default material type. Also sets Friction, Restitution and Density.
92 SetMaterial((int)MaterialAttributes.Material.Wood); 92 SetMaterial((int)MaterialAttributes.Material.Wood);
@@ -133,9 +133,13 @@ public abstract class BSPhysObject : PhysicsActor
133 // Reference to the physical shape (btCollisionShape) of this object 133 // Reference to the physical shape (btCollisionShape) of this object
134 public BulletShape PhysShape; 134 public BulletShape PhysShape;
135 135
136 // 'true' if the mesh's underlying asset failed to build. 136 // The physical representation of the prim might require an asset fetch.
137 // This will keep us from looping after the first time the build failed. 137 // The asset state is first 'Unknown' then 'Waiting' then either 'Failed' or 'Fetched'.
138 public bool LastAssetBuildFailed { get; set; } 138 public enum PrimAssetCondition
139 {
140 Unknown, Waiting, Failed, Fetched
141 }
142 public PrimAssetCondition PrimAssetState { get; set; }
139 143
140 // The objects base shape information. Null if not a prim type shape. 144 // The objects base shape information. Null if not a prim type shape.
141 public PrimitiveBaseShape BaseShape { get; protected set; } 145 public PrimitiveBaseShape BaseShape { get; protected set; }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 2cbbe9a..6a5461a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -155,7 +155,7 @@ public class BSPrim : BSPhysObject
155 public override PrimitiveBaseShape Shape { 155 public override PrimitiveBaseShape Shape {
156 set { 156 set {
157 BaseShape = value; 157 BaseShape = value;
158 LastAssetBuildFailed = false; 158 PrimAssetState = PrimAssetCondition.Unknown;
159 ForceBodyShapeRebuild(false); 159 ForceBodyShapeRebuild(false);
160 } 160 }
161 } 161 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 457f204..a6e20a8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -930,11 +930,15 @@ public sealed class BSShapeCollection : IDisposable
930 return newShape; 930 return newShape;
931 931
932 // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset 932 // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset
933 if (prim.BaseShape.SculptEntry && !prim.LastAssetBuildFailed && prim.BaseShape.SculptTexture != OMV.UUID.Zero) 933 if (prim.BaseShape.SculptEntry
934 && prim.PrimAssetState != BSPhysObject.PrimAssetCondition.Failed
935 && prim.PrimAssetState != BSPhysObject.PrimAssetCondition.Waiting
936 && prim.BaseShape.SculptTexture != OMV.UUID.Zero
937 )
934 { 938 {
935 DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lastFailed={1}", prim.LocalID, prim.LastAssetBuildFailed); 939 DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset", prim.LocalID);
936 // This will prevent looping through this code as we keep trying to get the failed shape 940 // Multiple requestors will know we're waiting for this asset
937 prim.LastAssetBuildFailed = true; 941 prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting;
938 942
939 BSPhysObject xprim = prim; 943 BSPhysObject xprim = prim;
940 Util.FireAndForget(delegate 944 Util.FireAndForget(delegate
@@ -945,7 +949,7 @@ public sealed class BSShapeCollection : IDisposable
945 BSPhysObject yprim = xprim; // probably not necessary, but, just in case. 949 BSPhysObject yprim = xprim; // probably not necessary, but, just in case.
946 assetProvider(yprim.BaseShape.SculptTexture, delegate(AssetBase asset) 950 assetProvider(yprim.BaseShape.SculptTexture, delegate(AssetBase asset)
947 { 951 {
948 bool assetFound = false; // DEBUG DEBUG 952 bool assetFound = false;
949 string mismatchIDs = String.Empty; // DEBUG DEBUG 953 string mismatchIDs = String.Empty; // DEBUG DEBUG
950 if (asset != null && yprim.BaseShape.SculptEntry) 954 if (asset != null && yprim.BaseShape.SculptEntry)
951 { 955 {
@@ -963,6 +967,10 @@ public sealed class BSShapeCollection : IDisposable
963 mismatchIDs = yprim.BaseShape.SculptTexture.ToString() + "/" + asset.ID; 967 mismatchIDs = yprim.BaseShape.SculptTexture.ToString() + "/" + asset.ID;
964 } 968 }
965 } 969 }
970 if (assetFound)
971 yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched;
972 else
973 yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
966 DetailLog("{0},BSShapeCollection,fetchAssetCallback,found={1},isSculpt={2},ids={3}", 974 DetailLog("{0},BSShapeCollection,fetchAssetCallback,found={1},isSculpt={2},ids={3}",
967 yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs ); 975 yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs );
968 976
@@ -970,6 +978,7 @@ public sealed class BSShapeCollection : IDisposable
970 } 978 }
971 else 979 else
972 { 980 {
981 xprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
973 PhysicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}", 982 PhysicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}",
974 LogHeader, PhysicsScene.Name); 983 LogHeader, PhysicsScene.Name);
975 } 984 }
@@ -977,7 +986,7 @@ public sealed class BSShapeCollection : IDisposable
977 } 986 }
978 else 987 else
979 { 988 {
980 if (prim.LastAssetBuildFailed) 989 if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Failed)
981 { 990 {
982 PhysicsScene.Logger.ErrorFormat("{0} Mesh failed to fetch asset. lID={1}, texture={2}", 991 PhysicsScene.Logger.ErrorFormat("{0} Mesh failed to fetch asset. lID={1}, texture={2}",
983 LogHeader, prim.LocalID, prim.BaseShape.SculptTexture); 992 LogHeader, prim.LocalID, prim.BaseShape.SculptTexture);