29 using System.Collections.Generic;
33 using NUnit.Framework;
36 using OpenSim.Framework;
37 using OpenSim.Region.PhysicsModule.BulletS;
38 using OpenSim.Region.PhysicsModules.SharedBase;
39 using OpenSim.Tests.Common;
43 namespace OpenSim.
Region.PhysicsModule.BulletS.Tests
52 Vector3 ObjectInitPosition;
66 PhysicsScene.Dispose();
71 [TestCase(7, 2, 5f, 5f, 32, 0f)]
73 int maxDepthSplitForSimpleShapes,
74 float concavityThresholdPercent,
75 float volumeConservationThresholdPercent,
80 Dictionary<string, string> engineParams =
new Dictionary<string, string>();
81 engineParams.Add(
"MeshSculptedPrim",
"true");
82 engineParams.Add(
"ForceSimplePrimMeshing",
"false");
83 engineParams.Add(
"UseHullsForPhysicalObjects",
"true");
84 engineParams.Add(
"ShouldRemoveZeroWidthTriangles",
"true");
85 engineParams.Add(
"ShouldUseBulletHACD",
"false");
86 engineParams.Add(
"ShouldUseSingleConvexHullForPrims",
"true");
87 engineParams.Add(
"ShouldUseGImpactShapeForPrims",
"false");
88 engineParams.Add(
"ShouldUseAssetHulls",
"true");
90 engineParams.Add(
"CSHullMaxDepthSplit", maxDepthSplit.ToString());
91 engineParams.Add(
"CSHullMaxDepthSplitForSimpleShapes", maxDepthSplitForSimpleShapes.ToString());
92 engineParams.Add(
"CSHullConcavityThresholdPercent", concavityThresholdPercent.ToString());
93 engineParams.Add(
"CSHullVolumeConservationThresholdPercent", volumeConservationThresholdPercent.ToString());
94 engineParams.Add(
"CSHullMaxVertices", maxVertices.ToString());
95 engineParams.Add(
"CSHullMaxSkinWidth", maxSkinWidth.ToString());
97 PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
106 pbs = PrimitiveBaseShape.CreateCylinder();
107 pos =
new Vector3(100.0f, 100.0f, 0f);
108 pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
109 ObjectInitPosition = pos;
110 size =
new Vector3(2f, 2f, 2f);
112 rot = Quaternion.Identity;
114 uint cylinderLocalID = 123;
115 PhysicsScene.AddPrimShape(
"testCylinder", pbs, pos, size, rot, isPhys, cylinderLocalID);
120 pbs.ProfileHollow = (ushort)(0.70f * 50000);
121 pos =
new Vector3(110.0f, 110.0f, 0f);
122 pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
123 ObjectInitPosition = pos;
124 size =
new Vector3(2f, 2f, 2f);
126 rot = Quaternion.Identity;
128 uint hollowCylinderLocalID = 124;
129 PhysicsScene.AddPrimShape(
"testHollowCylinder", pbs, pos, size, rot, isPhys, hollowCylinderLocalID);
137 pbs.PathScaleX = 100;
138 pbs.PathScaleY = (int)(.25f / 0.01f) + 200;
139 pos =
new Vector3(120.0f, 120.0f, 0f);
140 pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
141 ObjectInitPosition = pos;
142 size =
new Vector3(2f, 4f, 4f);
144 rot = Quaternion.Identity;
146 uint torusLocalID = 125;
147 PhysicsScene.AddPrimShape(
"testTorus", pbs, pos, size, rot, isPhys, torusLocalID);
154 ReportShapeGeom(primTypeCylinder);
155 ReportShapeGeom(primTypeHollowCylinder);
156 ReportShapeGeom(primTypeTorus);
167 private void ReportShapeGeom(
BSPrim prim)
173 BSShape physShape = prim.PhysShape;
174 string shapeType = physShape.GetType().ToString();
177 case "OpenSim.Region.Physics.BulletSPlugin.BSShapeNative":
179 prim.PhysScene.DetailLog(
"{0}, type={1}", prim.Name, shapeType);
181 case "OpenSim.Region.Physics.BulletSPlugin.BSShapeMesh":
183 prim.PhysScene.DetailLog(
"{0}, mesh, shapeInfo={1}", prim.Name, mShape.shapeInfo);
185 case "OpenSim.Region.Physics.BulletSPlugin.BSShapeHull":
189 case "OpenSim.Region.Physics.BulletSPlugin.BSShapeConvexHull":
191 prim.PhysScene.DetailLog(
"{0}, convexHull, shapeInfo={1}", prim.Name, chShape.shapeInfo);
193 case "OpenSim.Region.Physics.BulletSPlugin.BSShapeCompound":
195 prim.PhysScene.DetailLog(
"{0}, type={1}", prim.Name, shapeType);
198 prim.PhysScene.DetailLog(
"{0}, type={1}", prim.Name, shapeType);
void GeomHullConvexDecomp(int maxDepthSplit, int maxDepthSplitForSimpleShapes, float concavityThresholdPercent, float volumeConservationThresholdPercent, int maxVertices, float maxSkinWidth)
void GeomHullBulletHACD()
virtual bool HasPhysicalShape
static PrimitiveBaseShape CreateCylinder()
static PrimitiveBaseShape CreateSphere()