diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
7 files changed, 59 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index 17ebed2..aca1ed4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | |||
@@ -1311,7 +1311,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1311 | /* TODO */ | 1311 | /* TODO */ |
1312 | ConfigurationParameters[] configparms = new ConfigurationParameters[1]; | 1312 | ConfigurationParameters[] configparms = new ConfigurationParameters[1]; |
1313 | configparms[0] = parms; | 1313 | configparms[0] = parms; |
1314 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | 1314 | Vector3 worldExtent = maxPosition; |
1315 | m_maxCollisions = maxCollisions; | 1315 | m_maxCollisions = maxCollisions; |
1316 | m_maxUpdatesPerFrame = maxUpdates; | 1316 | m_maxUpdatesPerFrame = maxUpdates; |
1317 | specialCollisionObjects = new Dictionary<uint, GhostObject>(); | 1317 | specialCollisionObjects = new Dictionary<uint, GhostObject>(); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 15b7090..edec949 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -376,18 +376,19 @@ public class BSPrim : BSPhysObject | |||
376 | { | 376 | { |
377 | bool ret = false; | 377 | bool ret = false; |
378 | 378 | ||
379 | uint wayOutThere = Constants.RegionSize * Constants.RegionSize; | 379 | int wayOverThere = -1000; |
380 | int wayOutThere = 10000; | ||
380 | // There have been instances of objects getting thrown way out of bounds and crashing | 381 | // There have been instances of objects getting thrown way out of bounds and crashing |
381 | // the border crossing code. | 382 | // the border crossing code. |
382 | if ( RawPosition.X < -Constants.RegionSize || RawPosition.X > wayOutThere | 383 | if ( RawPosition.X < wayOverThere || RawPosition.X > wayOutThere |
383 | || RawPosition.Y < -Constants.RegionSize || RawPosition.Y > wayOutThere | 384 | || RawPosition.Y < wayOverThere || RawPosition.X > wayOutThere |
384 | || RawPosition.Z < -Constants.RegionSize || RawPosition.Z > wayOutThere) | 385 | || RawPosition.Z < wayOverThere || RawPosition.X > wayOutThere) |
385 | { | 386 | { |
386 | RawPosition = new OMV.Vector3(10, 10, 50); | 387 | RawPosition = new OMV.Vector3(10, 10, 50); |
387 | ZeroMotion(inTaintTime); | 388 | ZeroMotion(inTaintTime); |
388 | ret = true; | 389 | ret = true; |
389 | } | 390 | } |
390 | if (RawVelocity.LengthSquared() > BSParam.MaxLinearVelocity) | 391 | if (RawVelocity.LengthSquared() > BSParam.MaxLinearVelocitySquared) |
391 | { | 392 | { |
392 | RawVelocity = Util.ClampV(RawVelocity, BSParam.MaxLinearVelocity); | 393 | RawVelocity = Util.ClampV(RawVelocity, BSParam.MaxLinearVelocity); |
393 | ret = true; | 394 | ret = true; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index b3dfa41..fe014fc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -208,8 +208,17 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
208 | Name = EngineType + "/" + RegionName; | 208 | Name = EngineType + "/" + RegionName; |
209 | } | 209 | } |
210 | 210 | ||
211 | // Old version of initialization that assumes legacy sized regions (256x256) | ||
211 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 212 | public override void Initialise(IMesher meshmerizer, IConfigSource config) |
212 | { | 213 | { |
214 | m_log.ErrorFormat("{0} WARNING WARNING WARNING! BulletSim initialized without region extent specification. Terrain will be messed up."); | ||
215 | Vector3 regionExtent = new Vector3( Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); | ||
216 | Initialise(meshmerizer, config, regionExtent); | ||
217 | |||
218 | } | ||
219 | |||
220 | public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) | ||
221 | { | ||
213 | mesher = meshmerizer; | 222 | mesher = meshmerizer; |
214 | _taintOperations = new List<TaintCallbackEntry>(); | 223 | _taintOperations = new List<TaintCallbackEntry>(); |
215 | _postTaintOperations = new Dictionary<string, TaintCallbackEntry>(); | 224 | _postTaintOperations = new Dictionary<string, TaintCallbackEntry>(); |
@@ -250,13 +259,13 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
250 | // a child in a mega-region. | 259 | // a child in a mega-region. |
251 | // Bullet actually doesn't care about the extents of the simulated | 260 | // Bullet actually doesn't care about the extents of the simulated |
252 | // area. It tracks active objects no matter where they are. | 261 | // area. It tracks active objects no matter where they are. |
253 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | 262 | Vector3 worldExtent = regionExtent; |
254 | 263 | ||
255 | World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray); | 264 | World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray); |
256 | 265 | ||
257 | Constraints = new BSConstraintCollection(World); | 266 | Constraints = new BSConstraintCollection(World); |
258 | 267 | ||
259 | TerrainManager = new BSTerrainManager(this); | 268 | TerrainManager = new BSTerrainManager(this, worldExtent); |
260 | TerrainManager.CreateInitialGroundPlaneAndTerrain(); | 269 | TerrainManager.CreateInitialGroundPlaneAndTerrain(); |
261 | 270 | ||
262 | // Put some informational messages into the log file. | 271 | // Put some informational messages into the log file. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 006a9c1..fbe320b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -71,7 +71,7 @@ public abstract class BSShape | |||
71 | lastReferenced = DateTime.Now; | 71 | lastReferenced = DateTime.Now; |
72 | } | 72 | } |
73 | 73 | ||
74 | // Called when this shape is being used again. | 74 | // Called when this shape is done being used. |
75 | protected virtual void DecrementReference() | 75 | protected virtual void DecrementReference() |
76 | { | 76 | { |
77 | referenceCount--; | 77 | referenceCount--; |
@@ -866,6 +866,8 @@ public class BSShapeHull : BSShape | |||
866 | public class BSShapeCompound : BSShape | 866 | public class BSShapeCompound : BSShape |
867 | { | 867 | { |
868 | private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]"; | 868 | private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]"; |
869 | public static Dictionary<string, BSShapeCompound> CompoundShapes = new Dictionary<string, BSShapeCompound>(); | ||
870 | |||
869 | public BSShapeCompound(BulletShape pShape) : base(pShape) | 871 | public BSShapeCompound(BulletShape pShape) : base(pShape) |
870 | { | 872 | { |
871 | } | 873 | } |
@@ -873,7 +875,9 @@ public class BSShapeCompound : BSShape | |||
873 | { | 875 | { |
874 | // Base compound shapes are not shared so this returns a raw shape. | 876 | // Base compound shapes are not shared so this returns a raw shape. |
875 | // A built compound shape can be reused in linksets. | 877 | // A built compound shape can be reused in linksets. |
876 | return new BSShapeCompound(CreatePhysicalCompoundShape(physicsScene)); | 878 | BSShapeCompound ret = new BSShapeCompound(CreatePhysicalCompoundShape(physicsScene)); |
879 | CompoundShapes.Add(ret.AddrString, ret); | ||
880 | return ret; | ||
877 | } | 881 | } |
878 | public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) | 882 | public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) |
879 | { | 883 | { |
@@ -911,10 +915,21 @@ public class BSShapeCompound : BSShape | |||
911 | BulletShape childShape = physicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(physShapeInfo, ii); | 915 | BulletShape childShape = physicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(physShapeInfo, ii); |
912 | DereferenceAnonCollisionShape(physicsScene, childShape); | 916 | DereferenceAnonCollisionShape(physicsScene, childShape); |
913 | } | 917 | } |
918 | |||
919 | lock (CompoundShapes) | ||
920 | CompoundShapes.Remove(physShapeInfo.AddrString); | ||
914 | physicsScene.PE.DeleteCollisionShape(physicsScene.World, physShapeInfo); | 921 | physicsScene.PE.DeleteCollisionShape(physicsScene.World, physShapeInfo); |
915 | } | 922 | } |
916 | } | 923 | } |
917 | } | 924 | } |
925 | public static bool TryGetCompoundByPtr(BulletShape pShape, out BSShapeCompound outCompound) | ||
926 | { | ||
927 | lock (CompoundShapes) | ||
928 | { | ||
929 | string addr = pShape.AddrString; | ||
930 | return CompoundShapes.TryGetValue(addr, out outCompound); | ||
931 | } | ||
932 | } | ||
918 | private static BulletShape CreatePhysicalCompoundShape(BSScene physicsScene) | 933 | private static BulletShape CreatePhysicalCompoundShape(BSScene physicsScene) |
919 | { | 934 | { |
920 | BulletShape cShape = physicsScene.PE.CreateCompoundShape(physicsScene.World, false); | 935 | BulletShape cShape = physicsScene.PE.CreateCompoundShape(physicsScene.World, false); |
@@ -926,10 +941,13 @@ public class BSShapeCompound : BSShape | |||
926 | private void DereferenceAnonCollisionShape(BSScene physicsScene, BulletShape pShape) | 941 | private void DereferenceAnonCollisionShape(BSScene physicsScene, BulletShape pShape) |
927 | { | 942 | { |
928 | // TODO: figure a better way to go through all the shape types and find a possible instance. | 943 | // TODO: figure a better way to go through all the shape types and find a possible instance. |
944 | physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,shape={1}", | ||
945 | BSScene.DetailLogZero, pShape); | ||
929 | BSShapeMesh meshDesc; | 946 | BSShapeMesh meshDesc; |
930 | if (BSShapeMesh.TryGetMeshByPtr(pShape, out meshDesc)) | 947 | if (BSShapeMesh.TryGetMeshByPtr(pShape, out meshDesc)) |
931 | { | 948 | { |
932 | meshDesc.Dereference(physicsScene); | 949 | meshDesc.Dereference(physicsScene); |
950 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundMesh,shape={1}", BSScene.DetailLogZero, pShape); | ||
933 | } | 951 | } |
934 | else | 952 | else |
935 | { | 953 | { |
@@ -937,13 +955,15 @@ public class BSShapeCompound : BSShape | |||
937 | if (BSShapeHull.TryGetHullByPtr(pShape, out hullDesc)) | 955 | if (BSShapeHull.TryGetHullByPtr(pShape, out hullDesc)) |
938 | { | 956 | { |
939 | hullDesc.Dereference(physicsScene); | 957 | hullDesc.Dereference(physicsScene); |
958 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundHull,shape={1}", BSScene.DetailLogZero, pShape); | ||
940 | } | 959 | } |
941 | else | 960 | else |
942 | { | 961 | { |
943 | BSShapeConvexHull chullDesc; | 962 | BSShapeConvexHull chullDesc; |
944 | if (BSShapeConvexHull.TryGetHullByPtr(pShape, out chullDesc)) | 963 | if (BSShapeConvexHull.TryGetConvexHullByPtr(pShape, out chullDesc)) |
945 | { | 964 | { |
946 | chullDesc.Dereference(physicsScene); | 965 | chullDesc.Dereference(physicsScene); |
966 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundConvexHull,shape={1}", BSScene.DetailLogZero, pShape); | ||
947 | } | 967 | } |
948 | else | 968 | else |
949 | { | 969 | { |
@@ -951,20 +971,23 @@ public class BSShapeCompound : BSShape | |||
951 | if (BSShapeGImpact.TryGetGImpactByPtr(pShape, out gImpactDesc)) | 971 | if (BSShapeGImpact.TryGetGImpactByPtr(pShape, out gImpactDesc)) |
952 | { | 972 | { |
953 | gImpactDesc.Dereference(physicsScene); | 973 | gImpactDesc.Dereference(physicsScene); |
974 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundgImpact,shape={1}", BSScene.DetailLogZero, pShape); | ||
954 | } | 975 | } |
955 | else | 976 | else |
956 | { | 977 | { |
957 | // Didn't find it in the lists of specific types. It could be compound. | 978 | // Didn't find it in the lists of specific types. It could be compound. |
958 | if (physicsScene.PE.IsCompound(pShape)) | 979 | BSShapeCompound compoundDesc; |
980 | if (BSShapeCompound.TryGetCompoundByPtr(pShape, out compoundDesc)) | ||
959 | { | 981 | { |
960 | BSShapeCompound recursiveCompound = new BSShapeCompound(pShape); | 982 | compoundDesc.Dereference(physicsScene); |
961 | recursiveCompound.Dereference(physicsScene); | 983 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,recursiveCompoundShape,shape={1}", BSScene.DetailLogZero, pShape); |
962 | } | 984 | } |
963 | else | 985 | else |
964 | { | 986 | { |
965 | // If none of the above, maybe it is a simple native shape. | 987 | // If none of the above, maybe it is a simple native shape. |
966 | if (physicsScene.PE.IsNativeShape(pShape)) | 988 | if (physicsScene.PE.IsNativeShape(pShape)) |
967 | { | 989 | { |
990 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,assumingNative,shape={1}", BSScene.DetailLogZero, pShape); | ||
968 | BSShapeNative nativeShape = new BSShapeNative(pShape); | 991 | BSShapeNative nativeShape = new BSShapeNative(pShape); |
969 | nativeShape.Dereference(physicsScene); | 992 | nativeShape.Dereference(physicsScene); |
970 | } | 993 | } |
@@ -1021,6 +1044,8 @@ public class BSShapeConvexHull : BSShape | |||
1021 | convexShape = physicsScene.PE.BuildConvexHullShapeFromMesh(physicsScene.World, baseMesh.physShapeInfo); | 1044 | convexShape = physicsScene.PE.BuildConvexHullShapeFromMesh(physicsScene.World, baseMesh.physShapeInfo); |
1022 | convexShape.shapeKey = newMeshKey; | 1045 | convexShape.shapeKey = newMeshKey; |
1023 | ConvexHulls.Add(convexShape.shapeKey, retConvexHull); | 1046 | ConvexHulls.Add(convexShape.shapeKey, retConvexHull); |
1047 | physicsScene.DetailLog("{0},BSShapeConvexHull.GetReference,addingNewlyCreatedShape,shape={1}", | ||
1048 | BSScene.DetailLogZero, convexShape); | ||
1024 | } | 1049 | } |
1025 | 1050 | ||
1026 | // Done with the base mesh | 1051 | // Done with the base mesh |
@@ -1049,7 +1074,7 @@ public class BSShapeConvexHull : BSShape | |||
1049 | } | 1074 | } |
1050 | } | 1075 | } |
1051 | // Loop through all the known hulls and return the description based on the physical address. | 1076 | // Loop through all the known hulls and return the description based on the physical address. |
1052 | public static bool TryGetHullByPtr(BulletShape pShape, out BSShapeConvexHull outHull) | 1077 | public static bool TryGetConvexHullByPtr(BulletShape pShape, out BSShapeConvexHull outHull) |
1053 | { | 1078 | { |
1054 | bool ret = false; | 1079 | bool ret = false; |
1055 | BSShapeConvexHull foundDesc = null; | 1080 | BSShapeConvexHull foundDesc = null; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs index 8888d6d..d70b2fb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | |||
@@ -58,7 +58,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
58 | { | 58 | { |
59 | initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; | 59 | initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; |
60 | } | 60 | } |
61 | m_mapInfo = new BulletHMapInfo(id, initialMap); | 61 | m_mapInfo = new BulletHMapInfo(id, initialMap, regionSize.X, regionSize.Y); |
62 | m_mapInfo.minCoords = minTerrainCoords; | 62 | m_mapInfo.minCoords = minTerrainCoords; |
63 | m_mapInfo.maxCoords = maxTerrainCoords; | 63 | m_mapInfo.maxCoords = maxTerrainCoords; |
64 | m_mapInfo.terrainRegionBase = TerrainBase; | 64 | m_mapInfo.terrainRegionBase = TerrainBase; |
@@ -72,7 +72,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
72 | Vector3 minCoords, Vector3 maxCoords) | 72 | Vector3 minCoords, Vector3 maxCoords) |
73 | : base(physicsScene, regionBase, id) | 73 | : base(physicsScene, regionBase, id) |
74 | { | 74 | { |
75 | m_mapInfo = new BulletHMapInfo(id, initialMap); | 75 | m_mapInfo = new BulletHMapInfo(id, initialMap, maxCoords.X - minCoords.X, maxCoords.Y - minCoords.Y); |
76 | m_mapInfo.minCoords = minCoords; | 76 | m_mapInfo.minCoords = minCoords; |
77 | m_mapInfo.maxCoords = maxCoords; | 77 | m_mapInfo.maxCoords = maxCoords; |
78 | m_mapInfo.minZ = minCoords.Z; | 78 | m_mapInfo.minZ = minCoords.Z; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 441d2d3..3013077 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -111,9 +111,11 @@ public sealed class BSTerrainManager : IDisposable | |||
111 | private Vector3 m_worldMax; | 111 | private Vector3 m_worldMax; |
112 | private PhysicsScene MegaRegionParentPhysicsScene { get; set; } | 112 | private PhysicsScene MegaRegionParentPhysicsScene { get; set; } |
113 | 113 | ||
114 | public BSTerrainManager(BSScene physicsScene) | 114 | public BSTerrainManager(BSScene physicsScene, Vector3 regionSize) |
115 | { | 115 | { |
116 | m_physicsScene = physicsScene; | 116 | m_physicsScene = physicsScene; |
117 | DefaultRegionSize = regionSize; | ||
118 | |||
117 | m_terrains = new Dictionary<Vector3,BSTerrainPhys>(); | 119 | m_terrains = new Dictionary<Vector3,BSTerrainPhys>(); |
118 | 120 | ||
119 | // Assume one region of default size | 121 | // Assume one region of default size |
@@ -268,7 +270,7 @@ public sealed class BSTerrainManager : IDisposable | |||
268 | { | 270 | { |
269 | // There is already a terrain in this spot. Free the old and build the new. | 271 | // There is already a terrain in this spot. Free the old and build the new. |
270 | DetailLog("{0},BSTErrainManager.UpdateTerrain:UpdateExisting,call,id={1},base={2},minC={3},maxC={4}", | 272 | DetailLog("{0},BSTErrainManager.UpdateTerrain:UpdateExisting,call,id={1},base={2},minC={3},maxC={4}", |
271 | BSScene.DetailLogZero, id, terrainRegionBase, minCoords, minCoords); | 273 | BSScene.DetailLogZero, id, terrainRegionBase, minCoords, maxCoords); |
272 | 274 | ||
273 | // Remove old terrain from the collection | 275 | // Remove old terrain from the collection |
274 | m_terrains.Remove(terrainRegionBase); | 276 | m_terrains.Remove(terrainRegionBase); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index 971ff9f..3425d9e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | |||
@@ -165,14 +165,15 @@ public class BulletConstraint | |||
165 | // than making copies. | 165 | // than making copies. |
166 | public class BulletHMapInfo | 166 | public class BulletHMapInfo |
167 | { | 167 | { |
168 | public BulletHMapInfo(uint id, float[] hm) { | 168 | public BulletHMapInfo(uint id, float[] hm, float pSizeX, float pSizeY) { |
169 | ID = id; | 169 | ID = id; |
170 | heightMap = hm; | 170 | heightMap = hm; |
171 | terrainRegionBase = OMV.Vector3.Zero; | 171 | terrainRegionBase = OMV.Vector3.Zero; |
172 | minCoords = new OMV.Vector3(100f, 100f, 25f); | 172 | minCoords = new OMV.Vector3(100f, 100f, 25f); |
173 | maxCoords = new OMV.Vector3(101f, 101f, 26f); | 173 | maxCoords = new OMV.Vector3(101f, 101f, 26f); |
174 | minZ = maxZ = 0f; | 174 | minZ = maxZ = 0f; |
175 | sizeX = sizeY = 256f; | 175 | sizeX = pSizeX; |
176 | sizeY = pSizeY; | ||
176 | } | 177 | } |
177 | public uint ID; | 178 | public uint ID; |
178 | public float[] heightMap; | 179 | public float[] heightMap; |