mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 08:06:27 +08:00
more source indentation fix
This commit is contained in:
@@ -25,13 +25,9 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using NUnit.Framework;
|
||||
using log4net;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.PhysicsModule.BulletS;
|
||||
@@ -42,115 +38,115 @@ using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.PhysicsModule.BulletS.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class BasicVehicles : OpenSimTestCase
|
||||
{
|
||||
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||
|
||||
BSScene PhysicsScene { get; set; }
|
||||
BSPrim TestVehicle { get; set; }
|
||||
Vector3 TestVehicleInitPosition { get; set; }
|
||||
float simulationTimeStep = 0.089f;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
[TestFixture]
|
||||
public class BasicVehicles : OpenSimTestCase
|
||||
{
|
||||
Dictionary<string, string> engineParams = new Dictionary<string, string>();
|
||||
engineParams.Add("VehicleEnableAngularVerticalAttraction", "true");
|
||||
engineParams.Add("VehicleAngularVerticalAttractionAlgorithm", "1");
|
||||
PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
|
||||
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||
|
||||
PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere();
|
||||
Vector3 pos = new Vector3(100.0f, 100.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2f;
|
||||
TestVehicleInitPosition = pos;
|
||||
Vector3 size = new Vector3(1f, 1f, 1f);
|
||||
pbs.Scale = size;
|
||||
Quaternion rot = Quaternion.Identity;
|
||||
bool isPhys = false;
|
||||
uint localID = 123;
|
||||
BSScene PhysicsScene { get; set; }
|
||||
BSPrim TestVehicle { get; set; }
|
||||
Vector3 TestVehicleInitPosition { get; set; }
|
||||
float simulationTimeStep = 0.089f;
|
||||
|
||||
PhysicsScene.AddPrimShape("testPrim", pbs, pos, size, rot, isPhys, localID);
|
||||
TestVehicle = (BSPrim)PhysicsScene.PhysObjects[localID];
|
||||
// The actual prim shape creation happens at taint time
|
||||
PhysicsScene.ProcessTaints();
|
||||
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (PhysicsScene != null)
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
// The Dispose() will also free any physical objects in the scene
|
||||
PhysicsScene.Dispose();
|
||||
PhysicsScene = null;
|
||||
}
|
||||
}
|
||||
Dictionary<string, string> engineParams = new Dictionary<string, string>();
|
||||
engineParams.Add("VehicleEnableAngularVerticalAttraction", "true");
|
||||
engineParams.Add("VehicleAngularVerticalAttractionAlgorithm", "1");
|
||||
PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
|
||||
|
||||
[TestCase(2f, 0.2f, 0.25f, 0.25f, 0.25f)]
|
||||
[TestCase(2f, 0.2f, -0.25f, 0.25f, 0.25f)]
|
||||
[TestCase(2f, 0.2f, 0.25f, -0.25f, 0.25f)]
|
||||
[TestCase(2f, 0.2f, -0.25f, -0.25f, 0.25f)]
|
||||
// [TestCase(2f, 0.2f, 0.785f, 0.0f, 0.25f) /*, "Leaning 45 degrees to the side" */]
|
||||
// [TestCase(2f, 0.2f, 1.650f, 0.0f, 0.25f) /*, "Leaning more than 90 degrees to the side" */]
|
||||
// [TestCase(2f, 0.2f, 2.750f, 0.0f, 0.25f) /*, "Almost upside down, tipped right" */]
|
||||
// [TestCase(2f, 0.2f,-2.750f, 0.0f, 0.25f) /*, "Almost upside down, tipped left" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f, 0.785f, 0.25f) /*, "Tipped back 45 degrees" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f, 1.650f, 0.25f) /*, "Tipped back more than 90 degrees" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f, 2.750f, 0.25f) /*, "Almost upside down, tipped back" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f,-2.750f, 0.25f) /*, "Almost upside down, tipped forward" */]
|
||||
public void AngularVerticalAttraction(float timeScale, float efficiency, float initRoll, float initPitch, float initYaw)
|
||||
{
|
||||
// Enough simulation steps to cover the timescale the operation should take
|
||||
int simSteps = (int)(timeScale / simulationTimeStep) + 1;
|
||||
PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere();
|
||||
Vector3 pos = new Vector3(100.0f, 100.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2f;
|
||||
TestVehicleInitPosition = pos;
|
||||
Vector3 size = new Vector3(1f, 1f, 1f);
|
||||
pbs.Scale = size;
|
||||
Quaternion rot = Quaternion.Identity;
|
||||
bool isPhys = false;
|
||||
uint localID = 123;
|
||||
|
||||
// Tip the vehicle
|
||||
Quaternion initOrientation = Quaternion.CreateFromEulers(initRoll, initPitch, initYaw);
|
||||
TestVehicle.Orientation = initOrientation;
|
||||
|
||||
TestVehicle.Position = TestVehicleInitPosition;
|
||||
|
||||
// The vehicle controller is not enabled directly (by setting a vehicle type).
|
||||
// Instead the appropriate values are set and calls are made just the parts of the
|
||||
// controller we want to exercise. Stepping the physics engine then applies
|
||||
// the actions of that one feature.
|
||||
BSDynamics vehicleActor = TestVehicle.GetVehicleActor(true /* createIfNone */);
|
||||
if (vehicleActor != null)
|
||||
{
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
|
||||
// vehicleActor.enableAngularVerticalAttraction = true;
|
||||
|
||||
TestVehicle.IsPhysical = true;
|
||||
PhysicsScene.AddPrimShape("testPrim", pbs, pos, size, rot, isPhys, localID);
|
||||
TestVehicle = (BSPrim)PhysicsScene.PhysObjects[localID];
|
||||
// The actual prim shape creation happens at taint time
|
||||
PhysicsScene.ProcessTaints();
|
||||
|
||||
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
|
||||
for (int ii = 0; ii < simSteps; ii++)
|
||||
{
|
||||
vehicleActor.ForgetKnownVehicleProperties();
|
||||
vehicleActor.ComputeAngularVerticalAttraction();
|
||||
vehicleActor.PushKnownChanged();
|
||||
}
|
||||
|
||||
PhysicsScene.Simulate(simulationTimeStep);
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (PhysicsScene != null)
|
||||
{
|
||||
// The Dispose() will also free any physical objects in the scene
|
||||
PhysicsScene.Dispose();
|
||||
PhysicsScene = null;
|
||||
}
|
||||
}
|
||||
|
||||
TestVehicle.IsPhysical = false;
|
||||
PhysicsScene.ProcessTaints();
|
||||
[TestCase(2f, 0.2f, 0.25f, 0.25f, 0.25f)]
|
||||
[TestCase(2f, 0.2f, -0.25f, 0.25f, 0.25f)]
|
||||
[TestCase(2f, 0.2f, 0.25f, -0.25f, 0.25f)]
|
||||
[TestCase(2f, 0.2f, -0.25f, -0.25f, 0.25f)]
|
||||
// [TestCase(2f, 0.2f, 0.785f, 0.0f, 0.25f) /*, "Leaning 45 degrees to the side" */]
|
||||
// [TestCase(2f, 0.2f, 1.650f, 0.0f, 0.25f) /*, "Leaning more than 90 degrees to the side" */]
|
||||
// [TestCase(2f, 0.2f, 2.750f, 0.0f, 0.25f) /*, "Almost upside down, tipped right" */]
|
||||
// [TestCase(2f, 0.2f,-2.750f, 0.0f, 0.25f) /*, "Almost upside down, tipped left" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f, 0.785f, 0.25f) /*, "Tipped back 45 degrees" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f, 1.650f, 0.25f) /*, "Tipped back more than 90 degrees" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f, 2.750f, 0.25f) /*, "Almost upside down, tipped back" */]
|
||||
// [TestCase(2f, 0.2f, 0.0f,-2.750f, 0.25f) /*, "Almost upside down, tipped forward" */]
|
||||
public void AngularVerticalAttraction(float timeScale, float efficiency, float initRoll, float initPitch, float initYaw)
|
||||
{
|
||||
// Enough simulation steps to cover the timescale the operation should take
|
||||
int simSteps = (int)(timeScale / simulationTimeStep) + 1;
|
||||
|
||||
// After these steps, the vehicle should be upright
|
||||
/*
|
||||
float finalRoll, finalPitch, finalYaw;
|
||||
TestVehicle.Orientation.GetEulerAngles(out finalRoll, out finalPitch, out finalYaw);
|
||||
Assert.That(finalRoll, Is.InRange(-0.01f, 0.01f));
|
||||
Assert.That(finalPitch, Is.InRange(-0.01f, 0.01f));
|
||||
Assert.That(finalYaw, Is.InRange(initYaw - 0.1f, initYaw + 0.1f));
|
||||
*/
|
||||
// Tip the vehicle
|
||||
Quaternion initOrientation = Quaternion.CreateFromEulers(initRoll, initPitch, initYaw);
|
||||
TestVehicle.Orientation = initOrientation;
|
||||
|
||||
Vector3 upPointer = Vector3.UnitZ * TestVehicle.Orientation;
|
||||
Assert.That(upPointer.Z, Is.GreaterThan(0.99f));
|
||||
TestVehicle.Position = TestVehicleInitPosition;
|
||||
|
||||
// The vehicle controller is not enabled directly (by setting a vehicle type).
|
||||
// Instead the appropriate values are set and calls are made just the parts of the
|
||||
// controller we want to exercise. Stepping the physics engine then applies
|
||||
// the actions of that one feature.
|
||||
BSDynamics vehicleActor = TestVehicle.GetVehicleActor(true /* createIfNone */);
|
||||
if (vehicleActor != null)
|
||||
{
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
|
||||
// vehicleActor.enableAngularVerticalAttraction = true;
|
||||
|
||||
TestVehicle.IsPhysical = true;
|
||||
PhysicsScene.ProcessTaints();
|
||||
|
||||
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
|
||||
for (int ii = 0; ii < simSteps; ii++)
|
||||
{
|
||||
vehicleActor.ForgetKnownVehicleProperties();
|
||||
vehicleActor.ComputeAngularVerticalAttraction();
|
||||
vehicleActor.PushKnownChanged();
|
||||
|
||||
PhysicsScene.Simulate(simulationTimeStep);
|
||||
}
|
||||
}
|
||||
|
||||
TestVehicle.IsPhysical = false;
|
||||
PhysicsScene.ProcessTaints();
|
||||
|
||||
// After these steps, the vehicle should be upright
|
||||
/*
|
||||
float finalRoll, finalPitch, finalYaw;
|
||||
TestVehicle.Orientation.GetEulerAngles(out finalRoll, out finalPitch, out finalYaw);
|
||||
Assert.That(finalRoll, Is.InRange(-0.01f, 0.01f));
|
||||
Assert.That(finalPitch, Is.InRange(-0.01f, 0.01f));
|
||||
Assert.That(finalYaw, Is.InRange(initYaw - 0.1f, initYaw + 0.1f));
|
||||
*/
|
||||
|
||||
Vector3 upPointer = Vector3.UnitZ * TestVehicle.Orientation;
|
||||
Assert.That(upPointer.Z, Is.GreaterThan(0.99f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -25,32 +25,26 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using NUnit.Framework;
|
||||
using log4net;
|
||||
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Region.PhysicsModule.BulletS.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class BulletSimTests : OpenSimTestCase
|
||||
{
|
||||
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
[TestFixture]
|
||||
public class BulletSimTests : OpenSimTestCase
|
||||
{
|
||||
}
|
||||
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,69 +41,69 @@ using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.PhysicsModule.BulletS.Tests
|
||||
{
|
||||
// Utility functions for building up and tearing down the sample physics environments
|
||||
public static class BulletSimTestsUtil
|
||||
{
|
||||
// 'engineName' is the Bullet engine to use. Either null (for unmanaged), "BulletUnmanaged" or "BulletXNA"
|
||||
// 'params' is a set of keyValue pairs to set in the engine's configuration file (override defaults)
|
||||
// May be 'null' if there are no overrides.
|
||||
public static BSScene CreateBasicPhysicsEngine(Dictionary<string,string> paramOverrides)
|
||||
// Utility functions for building up and tearing down the sample physics environments
|
||||
public static class BulletSimTestsUtil
|
||||
{
|
||||
IConfigSource openSimINI = new IniConfigSource();
|
||||
IConfig startupConfig = openSimINI.AddConfig("Startup");
|
||||
startupConfig.Set("physics", "BulletSim");
|
||||
startupConfig.Set("meshing", "Meshmerizer");
|
||||
startupConfig.Set("cacheSculptMaps", "false"); // meshmerizer shouldn't save maps
|
||||
|
||||
IConfig bulletSimConfig = openSimINI.AddConfig("BulletSim");
|
||||
// If the caller cares, specify the bullet engine otherwise it will default to "BulletUnmanaged".
|
||||
// bulletSimConfig.Set("BulletEngine", "BulletUnmanaged");
|
||||
// bulletSimConfig.Set("BulletEngine", "BulletXNA");
|
||||
bulletSimConfig.Set("MeshSculptedPrim", "false");
|
||||
bulletSimConfig.Set("ForceSimplePrimMeshing", "true");
|
||||
if (paramOverrides != null)
|
||||
// 'engineName' is the Bullet engine to use. Either null (for unmanaged), "BulletUnmanaged" or "BulletXNA"
|
||||
// 'params' is a set of keyValue pairs to set in the engine's configuration file (override defaults)
|
||||
// May be 'null' if there are no overrides.
|
||||
public static BSScene CreateBasicPhysicsEngine(Dictionary<string, string> paramOverrides)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in paramOverrides)
|
||||
IConfigSource openSimINI = new IniConfigSource();
|
||||
IConfig startupConfig = openSimINI.AddConfig("Startup");
|
||||
startupConfig.Set("physics", "BulletSim");
|
||||
startupConfig.Set("meshing", "Meshmerizer");
|
||||
startupConfig.Set("cacheSculptMaps", "false"); // meshmerizer shouldn't save maps
|
||||
|
||||
IConfig bulletSimConfig = openSimINI.AddConfig("BulletSim");
|
||||
// If the caller cares, specify the bullet engine otherwise it will default to "BulletUnmanaged".
|
||||
// bulletSimConfig.Set("BulletEngine", "BulletUnmanaged");
|
||||
// bulletSimConfig.Set("BulletEngine", "BulletXNA");
|
||||
bulletSimConfig.Set("MeshSculptedPrim", "false");
|
||||
bulletSimConfig.Set("ForceSimplePrimMeshing", "true");
|
||||
if (paramOverrides != null)
|
||||
{
|
||||
bulletSimConfig.Set(kvp.Key, kvp.Value);
|
||||
foreach (KeyValuePair<string, string> kvp in paramOverrides)
|
||||
{
|
||||
bulletSimConfig.Set(kvp.Key, kvp.Value);
|
||||
}
|
||||
}
|
||||
|
||||
// If a special directory exists, put detailed logging therein.
|
||||
// This allows local testing/debugging without having to worry that the build engine will output logs.
|
||||
if (Directory.Exists("physlogs"))
|
||||
{
|
||||
bulletSimConfig.Set("PhysicsLoggingDir", "./physlogs");
|
||||
bulletSimConfig.Set("PhysicsLoggingEnabled", "True");
|
||||
bulletSimConfig.Set("PhysicsLoggingDoFlush", "True");
|
||||
bulletSimConfig.Set("VehicleLoggingEnabled", "True");
|
||||
}
|
||||
|
||||
Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
|
||||
|
||||
RegionInfo info = new RegionInfo();
|
||||
info.RegionName = "BSTestRegion";
|
||||
info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
|
||||
OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
|
||||
|
||||
IMesher mesher = new OpenSim.Region.PhysicsModule.Meshing.Meshmerizer();
|
||||
INonSharedRegionModule mod = mesher as INonSharedRegionModule;
|
||||
mod.Initialise(openSimINI);
|
||||
mod.AddRegion(scene);
|
||||
mod.RegionLoaded(scene);
|
||||
|
||||
BSScene pScene = new BSScene();
|
||||
mod = (pScene as INonSharedRegionModule);
|
||||
mod.Initialise(openSimINI);
|
||||
mod.AddRegion(scene);
|
||||
mod.RegionLoaded(scene);
|
||||
|
||||
// Since the asset requestor is not initialized, any mesh or sculptie will be a cube.
|
||||
// In the future, add a fake asset fetcher to get meshes and sculpts.
|
||||
// bsScene.RequestAssetMethod = ???;
|
||||
|
||||
return pScene;
|
||||
}
|
||||
|
||||
// If a special directory exists, put detailed logging therein.
|
||||
// This allows local testing/debugging without having to worry that the build engine will output logs.
|
||||
if (Directory.Exists("physlogs"))
|
||||
{
|
||||
bulletSimConfig.Set("PhysicsLoggingDir","./physlogs");
|
||||
bulletSimConfig.Set("PhysicsLoggingEnabled","True");
|
||||
bulletSimConfig.Set("PhysicsLoggingDoFlush","True");
|
||||
bulletSimConfig.Set("VehicleLoggingEnabled","True");
|
||||
}
|
||||
|
||||
Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
|
||||
|
||||
RegionInfo info = new RegionInfo();
|
||||
info.RegionName = "BSTestRegion";
|
||||
info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
|
||||
OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
|
||||
|
||||
IMesher mesher = new OpenSim.Region.PhysicsModule.Meshing.Meshmerizer();
|
||||
INonSharedRegionModule mod = mesher as INonSharedRegionModule;
|
||||
mod.Initialise(openSimINI);
|
||||
mod.AddRegion(scene);
|
||||
mod.RegionLoaded(scene);
|
||||
|
||||
BSScene pScene = new BSScene();
|
||||
mod = (pScene as INonSharedRegionModule);
|
||||
mod.Initialise(openSimINI);
|
||||
mod.AddRegion(scene);
|
||||
mod.RegionLoaded(scene);
|
||||
|
||||
// Since the asset requestor is not initialized, any mesh or sculptie will be a cube.
|
||||
// In the future, add a fake asset fetcher to get meshes and sculpts.
|
||||
// bsScene.RequestAssetMethod = ???;
|
||||
|
||||
return pScene;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,164 +42,164 @@ using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.PhysicsModule.BulletS.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class HullCreation : OpenSimTestCase
|
||||
{
|
||||
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||
|
||||
BSScene PhysicsScene { get; set; }
|
||||
Vector3 ObjectInitPosition;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
[TestFixture]
|
||||
public class HullCreation : OpenSimTestCase
|
||||
{
|
||||
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||
|
||||
}
|
||||
BSScene PhysicsScene { get; set; }
|
||||
Vector3 ObjectInitPosition;
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (PhysicsScene != null)
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
// The Dispose() will also free any physical objects in the scene
|
||||
PhysicsScene.Dispose();
|
||||
PhysicsScene = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(7, 2, 5f, 5f, 32, 0f)] /* default hull parameters */
|
||||
public void GeomHullConvexDecomp( int maxDepthSplit,
|
||||
int maxDepthSplitForSimpleShapes,
|
||||
float concavityThresholdPercent,
|
||||
float volumeConservationThresholdPercent,
|
||||
int maxVertices,
|
||||
float maxSkinWidth)
|
||||
{
|
||||
// Setup the physics engine to use the C# version of convex decomp
|
||||
Dictionary<string, string> engineParams = new Dictionary<string, string>();
|
||||
engineParams.Add("MeshSculptedPrim", "true"); // ShouldMeshSculptedPrim
|
||||
engineParams.Add("ForceSimplePrimMeshing", "false"); // ShouldForceSimplePrimMeshing
|
||||
engineParams.Add("UseHullsForPhysicalObjects", "true"); // ShouldUseHullsForPhysicalObjects
|
||||
engineParams.Add("ShouldRemoveZeroWidthTriangles", "true");
|
||||
engineParams.Add("ShouldUseBulletHACD", "false");
|
||||
engineParams.Add("ShouldUseSingleConvexHullForPrims", "true");
|
||||
engineParams.Add("ShouldUseGImpactShapeForPrims", "false");
|
||||
engineParams.Add("ShouldUseAssetHulls", "true");
|
||||
|
||||
engineParams.Add("CSHullMaxDepthSplit", maxDepthSplit.ToString());
|
||||
engineParams.Add("CSHullMaxDepthSplitForSimpleShapes", maxDepthSplitForSimpleShapes.ToString());
|
||||
engineParams.Add("CSHullConcavityThresholdPercent", concavityThresholdPercent.ToString());
|
||||
engineParams.Add("CSHullVolumeConservationThresholdPercent", volumeConservationThresholdPercent.ToString());
|
||||
engineParams.Add("CSHullMaxVertices", maxVertices.ToString());
|
||||
engineParams.Add("CSHullMaxSkinWidth", maxSkinWidth.ToString());
|
||||
|
||||
PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
|
||||
|
||||
PrimitiveBaseShape pbs;
|
||||
Vector3 pos;
|
||||
Vector3 size;
|
||||
Quaternion rot;
|
||||
bool isPhys;
|
||||
|
||||
// Cylinder
|
||||
pbs = PrimitiveBaseShape.CreateCylinder();
|
||||
pos = new Vector3(100.0f, 100.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
|
||||
ObjectInitPosition = pos;
|
||||
size = new Vector3(2f, 2f, 2f);
|
||||
pbs.Scale = size;
|
||||
rot = Quaternion.Identity;
|
||||
isPhys = true;
|
||||
uint cylinderLocalID = 123;
|
||||
PhysicsScene.AddPrimShape("testCylinder", pbs, pos, size, rot, isPhys, cylinderLocalID);
|
||||
BSPrim primTypeCylinder = (BSPrim)PhysicsScene.PhysObjects[cylinderLocalID];
|
||||
|
||||
// Hollow Cylinder
|
||||
pbs = PrimitiveBaseShape.CreateCylinder();
|
||||
pbs.ProfileHollow = (ushort)(0.70f * 50000);
|
||||
pos = new Vector3(110.0f, 110.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
|
||||
ObjectInitPosition = pos;
|
||||
size = new Vector3(2f, 2f, 2f);
|
||||
pbs.Scale = size;
|
||||
rot = Quaternion.Identity;
|
||||
isPhys = true;
|
||||
uint hollowCylinderLocalID = 124;
|
||||
PhysicsScene.AddPrimShape("testHollowCylinder", pbs, pos, size, rot, isPhys, hollowCylinderLocalID);
|
||||
BSPrim primTypeHollowCylinder = (BSPrim)PhysicsScene.PhysObjects[hollowCylinderLocalID];
|
||||
|
||||
// Torus
|
||||
// ProfileCurve = Circle, PathCurve = Curve1
|
||||
pbs = PrimitiveBaseShape.CreateSphere();
|
||||
pbs.ProfileShape = (byte)ProfileShape.Circle;
|
||||
pbs.PathCurve = (byte)Extrusion.Curve1;
|
||||
pbs.PathScaleX = 100; // default hollow info as set in the viewer
|
||||
pbs.PathScaleY = (int)(.25f / 0.01f) + 200;
|
||||
pos = new Vector3(120.0f, 120.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
|
||||
ObjectInitPosition = pos;
|
||||
size = new Vector3(2f, 4f, 4f);
|
||||
pbs.Scale = size;
|
||||
rot = Quaternion.Identity;
|
||||
isPhys = true;
|
||||
uint torusLocalID = 125;
|
||||
PhysicsScene.AddPrimShape("testTorus", pbs, pos, size, rot, isPhys, torusLocalID);
|
||||
BSPrim primTypeTorus = (BSPrim)PhysicsScene.PhysObjects[torusLocalID];
|
||||
|
||||
// The actual prim shape creation happens at taint time
|
||||
PhysicsScene.ProcessTaints();
|
||||
|
||||
// Check out the created hull shapes and report their characteristics
|
||||
ReportShapeGeom(primTypeCylinder);
|
||||
ReportShapeGeom(primTypeHollowCylinder);
|
||||
ReportShapeGeom(primTypeTorus);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void GeomHullBulletHACD()
|
||||
{
|
||||
// Cylinder
|
||||
// Hollow Cylinder
|
||||
// Torus
|
||||
}
|
||||
|
||||
private void ReportShapeGeom(BSPrim prim)
|
||||
{
|
||||
if (prim != null)
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (prim.PhysShape.HasPhysicalShape)
|
||||
if (PhysicsScene != null)
|
||||
{
|
||||
BSShape physShape = prim.PhysShape;
|
||||
string shapeType = physShape.GetType().ToString();
|
||||
switch (shapeType)
|
||||
// The Dispose() will also free any physical objects in the scene
|
||||
PhysicsScene.Dispose();
|
||||
PhysicsScene = null;
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(7, 2, 5f, 5f, 32, 0f)] /* default hull parameters */
|
||||
public void GeomHullConvexDecomp(int maxDepthSplit,
|
||||
int maxDepthSplitForSimpleShapes,
|
||||
float concavityThresholdPercent,
|
||||
float volumeConservationThresholdPercent,
|
||||
int maxVertices,
|
||||
float maxSkinWidth)
|
||||
{
|
||||
// Setup the physics engine to use the C# version of convex decomp
|
||||
Dictionary<string, string> engineParams = new Dictionary<string, string>();
|
||||
engineParams.Add("MeshSculptedPrim", "true"); // ShouldMeshSculptedPrim
|
||||
engineParams.Add("ForceSimplePrimMeshing", "false"); // ShouldForceSimplePrimMeshing
|
||||
engineParams.Add("UseHullsForPhysicalObjects", "true"); // ShouldUseHullsForPhysicalObjects
|
||||
engineParams.Add("ShouldRemoveZeroWidthTriangles", "true");
|
||||
engineParams.Add("ShouldUseBulletHACD", "false");
|
||||
engineParams.Add("ShouldUseSingleConvexHullForPrims", "true");
|
||||
engineParams.Add("ShouldUseGImpactShapeForPrims", "false");
|
||||
engineParams.Add("ShouldUseAssetHulls", "true");
|
||||
|
||||
engineParams.Add("CSHullMaxDepthSplit", maxDepthSplit.ToString());
|
||||
engineParams.Add("CSHullMaxDepthSplitForSimpleShapes", maxDepthSplitForSimpleShapes.ToString());
|
||||
engineParams.Add("CSHullConcavityThresholdPercent", concavityThresholdPercent.ToString());
|
||||
engineParams.Add("CSHullVolumeConservationThresholdPercent", volumeConservationThresholdPercent.ToString());
|
||||
engineParams.Add("CSHullMaxVertices", maxVertices.ToString());
|
||||
engineParams.Add("CSHullMaxSkinWidth", maxSkinWidth.ToString());
|
||||
|
||||
PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
|
||||
|
||||
PrimitiveBaseShape pbs;
|
||||
Vector3 pos;
|
||||
Vector3 size;
|
||||
Quaternion rot;
|
||||
bool isPhys;
|
||||
|
||||
// Cylinder
|
||||
pbs = PrimitiveBaseShape.CreateCylinder();
|
||||
pos = new Vector3(100.0f, 100.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
|
||||
ObjectInitPosition = pos;
|
||||
size = new Vector3(2f, 2f, 2f);
|
||||
pbs.Scale = size;
|
||||
rot = Quaternion.Identity;
|
||||
isPhys = true;
|
||||
uint cylinderLocalID = 123;
|
||||
PhysicsScene.AddPrimShape("testCylinder", pbs, pos, size, rot, isPhys, cylinderLocalID);
|
||||
BSPrim primTypeCylinder = (BSPrim)PhysicsScene.PhysObjects[cylinderLocalID];
|
||||
|
||||
// Hollow Cylinder
|
||||
pbs = PrimitiveBaseShape.CreateCylinder();
|
||||
pbs.ProfileHollow = (ushort)(0.70f * 50000);
|
||||
pos = new Vector3(110.0f, 110.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
|
||||
ObjectInitPosition = pos;
|
||||
size = new Vector3(2f, 2f, 2f);
|
||||
pbs.Scale = size;
|
||||
rot = Quaternion.Identity;
|
||||
isPhys = true;
|
||||
uint hollowCylinderLocalID = 124;
|
||||
PhysicsScene.AddPrimShape("testHollowCylinder", pbs, pos, size, rot, isPhys, hollowCylinderLocalID);
|
||||
BSPrim primTypeHollowCylinder = (BSPrim)PhysicsScene.PhysObjects[hollowCylinderLocalID];
|
||||
|
||||
// Torus
|
||||
// ProfileCurve = Circle, PathCurve = Curve1
|
||||
pbs = PrimitiveBaseShape.CreateSphere();
|
||||
pbs.ProfileShape = (byte)ProfileShape.Circle;
|
||||
pbs.PathCurve = (byte)Extrusion.Curve1;
|
||||
pbs.PathScaleX = 100; // default hollow info as set in the viewer
|
||||
pbs.PathScaleY = (int)(.25f / 0.01f) + 200;
|
||||
pos = new Vector3(120.0f, 120.0f, 0f);
|
||||
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 10f;
|
||||
ObjectInitPosition = pos;
|
||||
size = new Vector3(2f, 4f, 4f);
|
||||
pbs.Scale = size;
|
||||
rot = Quaternion.Identity;
|
||||
isPhys = true;
|
||||
uint torusLocalID = 125;
|
||||
PhysicsScene.AddPrimShape("testTorus", pbs, pos, size, rot, isPhys, torusLocalID);
|
||||
BSPrim primTypeTorus = (BSPrim)PhysicsScene.PhysObjects[torusLocalID];
|
||||
|
||||
// The actual prim shape creation happens at taint time
|
||||
PhysicsScene.ProcessTaints();
|
||||
|
||||
// Check out the created hull shapes and report their characteristics
|
||||
ReportShapeGeom(primTypeCylinder);
|
||||
ReportShapeGeom(primTypeHollowCylinder);
|
||||
ReportShapeGeom(primTypeTorus);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void GeomHullBulletHACD()
|
||||
{
|
||||
// Cylinder
|
||||
// Hollow Cylinder
|
||||
// Torus
|
||||
}
|
||||
|
||||
private void ReportShapeGeom(BSPrim prim)
|
||||
{
|
||||
if (prim != null)
|
||||
{
|
||||
if (prim.PhysShape.HasPhysicalShape)
|
||||
{
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeNative":
|
||||
BSShapeNative nShape = physShape as BSShapeNative;
|
||||
prim.PhysScene.DetailLog("{0}, type={1}", prim.Name, shapeType);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeMesh":
|
||||
BSShapeMesh mShape = physShape as BSShapeMesh;
|
||||
prim.PhysScene.DetailLog("{0}, mesh, shapeInfo={1}", prim.Name, mShape.shapeInfo);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeHull":
|
||||
// BSShapeHull hShape = physShape as BSShapeHull;
|
||||
// prim.PhysScene.DetailLog("{0}, hull, shapeInfo={1}", prim.Name, hShape.shapeInfo);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeConvexHull":
|
||||
BSShapeConvexHull chShape = physShape as BSShapeConvexHull;
|
||||
prim.PhysScene.DetailLog("{0}, convexHull, shapeInfo={1}", prim.Name, chShape.shapeInfo);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeCompound":
|
||||
BSShapeCompound cShape = physShape as BSShapeCompound;
|
||||
prim.PhysScene.DetailLog("{0}, type={1}", prim.Name, shapeType);
|
||||
break;
|
||||
default:
|
||||
prim.PhysScene.DetailLog("{0}, type={1}", prim.Name, shapeType);
|
||||
break;
|
||||
BSShape physShape = prim.PhysShape;
|
||||
string shapeType = physShape.GetType().ToString();
|
||||
switch (shapeType)
|
||||
{
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeNative":
|
||||
BSShapeNative nShape = physShape as BSShapeNative;
|
||||
prim.PhysScene.DetailLog("{0}, type={1}", prim.Name, shapeType);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeMesh":
|
||||
BSShapeMesh mShape = physShape as BSShapeMesh;
|
||||
prim.PhysScene.DetailLog("{0}, mesh, shapeInfo={1}", prim.Name, mShape.shapeInfo);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeHull":
|
||||
// BSShapeHull hShape = physShape as BSShapeHull;
|
||||
// prim.PhysScene.DetailLog("{0}, hull, shapeInfo={1}", prim.Name, hShape.shapeInfo);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeConvexHull":
|
||||
BSShapeConvexHull chShape = physShape as BSShapeConvexHull;
|
||||
prim.PhysScene.DetailLog("{0}, convexHull, shapeInfo={1}", prim.Name, chShape.shapeInfo);
|
||||
break;
|
||||
case "OpenSim.Region.Physics.BulletSPlugin.BSShapeCompound":
|
||||
BSShapeCompound cShape = physShape as BSShapeCompound;
|
||||
prim.PhysScene.DetailLog("{0}, type={1}", prim.Name, shapeType);
|
||||
break;
|
||||
default:
|
||||
prim.PhysScene.DetailLog("{0}, type={1}", prim.Name, shapeType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS.Tests
|
||||
BSScene _physicsScene { get; set; }
|
||||
BSPrim _targetSphere { get; set; }
|
||||
Vector3 _targetSpherePosition { get; set; }
|
||||
// float _simulationTimeStep = 0.089f;
|
||||
// float _simulationTimeStep = 0.089f;
|
||||
|
||||
uint _targetLocalID = 123;
|
||||
|
||||
@@ -97,7 +97,8 @@ namespace OpenSim.Region.PhysicsModule.BulletS.Tests
|
||||
[TestCase(100f, 100f, 100f, 100f, 100f, 20f, true, "Pass through sphere from above")]
|
||||
[TestCase(20f, 20f, 50f, 80f, 80f, 50f, false, "Not reach sphere")]
|
||||
[TestCase(50f, 50f, 65f, 150f, 150f, 65f, false, "Passed over sphere")]
|
||||
public void RaycastAroundObject(float fromX, float fromY, float fromZ, float toX, float toY, float toZ, bool expected, string msg) {
|
||||
public void RaycastAroundObject(float fromX, float fromY, float fromZ, float toX, float toY, float toZ, bool expected, string msg)
|
||||
{
|
||||
Vector3 fromPos = new Vector3(fromX, fromY, fromZ);
|
||||
Vector3 toPos = new Vector3(toX, toY, toZ);
|
||||
Vector3 direction = toPos - fromPos;
|
||||
@@ -105,7 +106,8 @@ namespace OpenSim.Region.PhysicsModule.BulletS.Tests
|
||||
|
||||
List<ContactResult> results = _physicsScene.RaycastWorld(fromPos, direction, len, 1);
|
||||
|
||||
if (expected) {
|
||||
if (expected)
|
||||
{
|
||||
// The test coordinates should generate a hit
|
||||
Assert.True(results.Count != 0, msg + ": Did not return a hit but expected to.");
|
||||
Assert.True(results.Count == 1, msg + ": Raycast returned not just one hit result.");
|
||||
|
||||
Reference in New Issue
Block a user