aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs5
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs3
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs19
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapes.cs74
4 files changed, 99 insertions, 2 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 5ebeace..2ac68e3 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -87,6 +87,7 @@ public static class BSParam
87 public static bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects 87 public static bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects
88 public static bool ShouldRemoveZeroWidthTriangles { get; private set; } 88 public static bool ShouldRemoveZeroWidthTriangles { get; private set; }
89 public static bool ShouldUseBulletHACD { get; set; } 89 public static bool ShouldUseBulletHACD { get; set; }
90 public static bool ShouldUseSingleConvexHullForPrims { get; set; }
90 91
91 public static float TerrainImplementation { get; private set; } 92 public static float TerrainImplementation { get; private set; }
92 public static int TerrainMeshMagnification { get; private set; } 93 public static int TerrainMeshMagnification { get; private set; }
@@ -342,6 +343,10 @@ public static class BSParam
342 false, 343 false,
343 (s) => { return ShouldUseBulletHACD; }, 344 (s) => { return ShouldUseBulletHACD; },
344 (s,v) => { ShouldUseBulletHACD = v; } ), 345 (s,v) => { ShouldUseBulletHACD = v; } ),
346 new ParameterDefn<bool>("ShouldUseSingleConvexHullForPrims", "If true, use a single convex hull shape for physical prims",
347 true,
348 (s) => { return ShouldUseSingleConvexHullForPrims; },
349 (s,v) => { ShouldUseSingleConvexHullForPrims = v; } ),
345 350
346 new ParameterDefn<int>("CrossingFailuresBeforeOutOfBounds", "How forgiving we are about getting into adjactent regions", 351 new ParameterDefn<int>("CrossingFailuresBeforeOutOfBounds", "How forgiving we are about getting into adjactent regions",
347 5, 352 5,
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 8e05b58..a4a8794 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -316,7 +316,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
316 break; 316 break;
317 case "bulletxna": 317 case "bulletxna":
318 ret = new BSAPIXNA(engineName, this); 318 ret = new BSAPIXNA(engineName, this);
319 // Disable some features that are not implemented in BulletXNA
320 m_log.InfoFormat("{0} Disabling some physics features not implemented by BulletXNA", LogHeader);
319 BSParam.ShouldUseBulletHACD = false; 321 BSParam.ShouldUseBulletHACD = false;
322 BSParam.ShouldUseSingleConvexHullForPrims = false;
320 break; 323 break;
321 } 324 }
322 325
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 809435d..794857c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -226,8 +226,23 @@ public sealed class BSShapeCollection : IDisposable
226 // made. Native shapes work in either case. 226 // made. Native shapes work in either case.
227 if (prim.IsPhysical && BSParam.ShouldUseHullsForPhysicalObjects) 227 if (prim.IsPhysical && BSParam.ShouldUseHullsForPhysicalObjects)
228 { 228 {
229 // Update prim.BSShape to reference a hull of this shape. 229 // Use a simple, single mesh convex hull shape if the object is simple enough
230 BSShape potentialHull = BSShapeHull.GetReference(m_physicsScene, false /*forceRebuild*/, prim); 230 BSShape potentialHull = null;
231
232 PrimitiveBaseShape pbs = prim.BaseShape;
233 if (BSParam.ShouldUseSingleConvexHullForPrims
234 && pbs != null
235 && !pbs.SculptEntry
236 && PrimHasNoCuts(pbs)
237 )
238 {
239 potentialHull = BSShapeConvexHull.GetReference(m_physicsScene, false /* forceRebuild */, prim);
240 }
241 else
242 {
243 potentialHull = BSShapeHull.GetReference(m_physicsScene, false /*forceRebuild*/, prim);
244 }
245
231 // If the current shape is not what is on the prim at the moment, time to change. 246 // If the current shape is not what is on the prim at the moment, time to change.
232 if (!prim.PhysShape.HasPhysicalShape 247 if (!prim.PhysShape.HasPhysicalShape
233 || potentialHull.ShapeType != prim.PhysShape.ShapeType 248 || potentialHull.ShapeType != prim.PhysShape.ShapeType
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
index 3346626..9ef2923 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
@@ -832,6 +832,80 @@ public class BSShapeCompound : BSShape
832} 832}
833 833
834// ============================================================================================================ 834// ============================================================================================================
835public class BSShapeConvexHull : BSShape
836{
837 private static string LogHeader = "[BULLETSIM SHAPE CONVEX HULL]";
838 public static Dictionary<System.UInt64, BSShapeConvexHull> ConvexHulls = new Dictionary<System.UInt64, BSShapeConvexHull>();
839
840 public BSShapeConvexHull(BulletShape pShape) : base(pShape)
841 {
842 }
843 public static BSShape GetReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim)
844 {
845 float lod;
846 System.UInt64 newMeshKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod);
847
848 physicsScene.DetailLog("{0},BSShapeMesh,getReference,newKey={1},size={2},lod={3}",
849 prim.LocalID, newMeshKey.ToString("X"), prim.Size, lod);
850
851 BSShapeConvexHull retConvexHull = null;
852 lock (ConvexHulls)
853 {
854 if (ConvexHulls.TryGetValue(newMeshKey, out retConvexHull))
855 {
856 // The mesh has already been created. Return a new reference to same.
857 retConvexHull.IncrementReference();
858 }
859 else
860 {
861 retConvexHull = new BSShapeConvexHull(new BulletShape());
862 BulletShape convexShape = null;
863
864 // Get a handle to a mesh to build the hull from
865 BSShape baseMesh = BSShapeMesh.GetReference(physicsScene, false /* forceRebuild */, prim);
866 if (baseMesh.physShapeInfo.isNativeShape)
867 {
868 // We get here if the mesh was not creatable. Could be waiting for an asset from the disk.
869 // In the short term, we return the native shape and a later ForceBodyShapeRebuild should
870 // get back to this code with a buildable mesh.
871 // TODO: not sure the temp native shape is freed when the mesh is rebuilt. When does this get freed?
872 convexShape = baseMesh.physShapeInfo;
873 }
874 else
875 {
876 convexShape = physicsScene.PE.BuildConvexHullShapeFromMesh(physicsScene.World, baseMesh.physShapeInfo);
877 convexShape.shapeKey = newMeshKey;
878 ConvexHulls.Add(convexShape.shapeKey, retConvexHull);
879 }
880
881 // Done with the base mesh
882 baseMesh.Dereference(physicsScene);
883
884 retConvexHull.physShapeInfo = convexShape;
885 }
886 }
887 return retConvexHull;
888 }
889 public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim)
890 {
891 // Calling this reference means we want another handle to an existing shape
892 // (usually linksets) so return this copy.
893 IncrementReference();
894 return this;
895 }
896 // Dereferencing a compound shape releases the hold on all the child shapes.
897 public override void Dereference(BSScene physicsScene)
898 {
899 lock (ConvexHulls)
900 {
901 this.DecrementReference();
902 physicsScene.DetailLog("{0},BSShapeConvexHull.Dereference,shape={1}", BSScene.DetailLogZero, this);
903 // TODO: schedule aging and destruction of unused meshes.
904 }
905 }
906}
907
908// ============================================================================================================
835public class BSShapeAvatar : BSShape 909public class BSShapeAvatar : BSShape
836{ 910{
837 private static string LogHeader = "[BULLETSIM SHAPE AVATAR]"; 911 private static string LogHeader = "[BULLETSIM SHAPE AVATAR]";