本文整理汇总了C#中BulletSharp.DiscreteDynamicsWorld.SetInternalTickCallback方法的典型用法代码示例。如果您正苦于以下问题:C# DiscreteDynamicsWorld.SetInternalTickCallback方法的具体用法?C# DiscreteDynamicsWorld.SetInternalTickCallback怎么用?C# DiscreteDynamicsWorld.SetInternalTickCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletSharp.DiscreteDynamicsWorld
的用法示例。
在下文中一共展示了DiscreteDynamicsWorld.SetInternalTickCallback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInitializePhysics
protected override void OnInitializePhysics()
{
// collision configuration contains default setup for memory, collision setup
CollisionConf = new DefaultCollisionConfiguration();
Dispatcher = new CollisionDispatcher(CollisionConf);
Vector3 worldAabbMin = new Vector3(-10000, -10000, -10000);
Vector3 worldAabbMax = new Vector3(10000, 10000, 10000);
Broadphase = new AxisSweep3(worldAabbMin, worldAabbMax);
Solver = new SequentialImpulseConstraintSolver();
World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
World.Gravity = new Vector3(0, -10, 0);
World.SetInternalTickCallback(MotorPreTickCallback, this, true);
// create the ground
CollisionShape groundShape = new BoxShape(200, 10, 200);
CollisionShapes.Add(groundShape);
CollisionObject ground = LocalCreateRigidBody(0, Matrix.Translation(0, -10, 0), groundShape);
ground.UserObject = "Ground";
fCyclePeriod = 2000.0f;
fMuscleStrength = 0.5f;
m_Time = 0;
SpawnTestRig(new Vector3(1, 0.5f, 0), false);
SpawnTestRig(new Vector3(-2, 0.5f, 0), true);
}
示例2: TestGCCollection
public static void TestGCCollection()
{
var conf = new DefaultCollisionConfiguration();
var dispatcher = new CollisionDispatcher(conf);
var broadphase = new DbvtBroadphase();
var world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf);
world.Gravity = new Vector3(0, -10, 0);
var conf_wr = new WeakReference(conf);
var dispatcher_wr = new WeakReference(dispatcher);
var broadphase_wr = new WeakReference(broadphase);
var world_wr = new WeakReference(broadphase);
//conf.Dispose();
conf = null;
dispatcher.OnDisposing += onDisposing;
dispatcher.OnDisposed += onDisposed;
//dispatcher.Dispose();
dispatcher = null;
broadphase.OnDisposing += onDisposing;
broadphase.OnDisposed += onDisposed;
//broadphase.Dispose();
broadphase = null;
world.OnDisposing += onDisposing;
world.OnDisposed += onDisposed;
world.SetInternalTickCallback(WorldPreTickCallback);
world.StepSimulation(1.0f/60.0f);
//world.SetInternalTickCallback(null);
//world.Dispose();
world = null;
GC.Collect();
GC.WaitForPendingFinalizers();
TestWeakRef("CollisionConfiguration", conf_wr);
TestWeakRef("CollisionDispatcher", dispatcher_wr);
TestWeakRef("DbvtBroadphase", broadphase_wr);
TestWeakRef("DiscreteDynamicsWorld", world_wr);
}
示例3: TestGCCollection
static void TestGCCollection()
{
var conf = new DefaultCollisionConfiguration();
var dispatcher = new CollisionDispatcher(conf);
var broadphase = new DbvtBroadphase();
//var broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf);
world.Gravity = new Vector3(0, -10, 0);
dispatcher.NearCallback = DispatcherNearCallback;
CreateBody(0.0f, new BoxShape(50, 1, 50), Vector3.Zero);
var dynamicObject = CreateBody(10.0f, new SphereShape(1.0f), new Vector3(2, 2, 0));
var dynamicObject2 = CreateBody(1.0f, new SphereShape(1.0f), new Vector3(0, 2, 0));
var ghostPairCallback = new GhostPairCallback();
broadphase.OverlappingPairCache.SetInternalGhostPairCallback(ghostPairCallback);
AddToDisposeQueue(ghostPairCallback);
ghostPairCallback = null;
var ghostObject = new PairCachingGhostObject();
ghostObject.CollisionShape = new BoxShape(2);
ghostObject.WorldTransform = Matrix.Translation(2,2,0);
world.AddCollisionObject(ghostObject);
var trimesh = new TriangleMesh();
Vector3 v0 = new Vector3(0, 0, 0);
Vector3 v1 = new Vector3(1, 0, 0);
Vector3 v2 = new Vector3(0, 1, 0);
Vector3 v3 = new Vector3(1, 1, 0);
trimesh.AddTriangle(v0, v1, v2);
trimesh.AddTriangle(v1, v3, v2);
var triangleMeshShape = new BvhTriangleMeshShape(trimesh, false);
var triMeshObject = CreateBody(0, triangleMeshShape, new Vector3(20,0,20));
AddToDisposeQueue(triangleMeshShape);
AddToDisposeQueue(trimesh);
AddToDisposeQueue(triMeshObject);
triangleMeshShape = null;
trimesh = null;
AddToDisposeQueue(conf);
AddToDisposeQueue(dispatcher);
AddToDisposeQueue(broadphase);
AddToDisposeQueue(world);
//conf.Dispose();
conf = null;
//dispatcher.Dispose();
dispatcher = null;
//broadphase.Dispose();
broadphase = null;
world.DebugDrawer = new DebugDrawTest();
AddToDisposeQueue(world.DebugDrawer);
world.SetInternalTickCallback(WorldPreTickCallback);
for (int i = 0; i < 600; i++)
{
world.StepSimulation(1.0f / 60.0f);
}
world.DispatchInfo.DebugDraw = new DebugDrawTest2();
AddToDisposeQueue(world.DispatchInfo.DebugDraw);
world.DispatchInfo.DebugDraw = world.DispatchInfo.DebugDraw;
AddToDisposeQueue(world.DispatchInfo.DebugDraw);
world.DispatchInfo.DebugDraw = null;
world.DebugDrawer = null;
world.DebugDrawer = new DebugDrawTest2();
world.StepSimulation(1.0f / 60.0f);
world.DebugDrawWorld();
AddToDisposeQueue(world.DispatchInfo.DebugDraw);
world.DebugDrawer = new DebugDrawTest();
world.DebugDrawWorld();
AddToDisposeQueue(world.DebugDrawer);
world.DebugDrawer = null;
TestContactTest(dynamicObject, dynamicObject2);
TestGhostObjectPairs(ghostObject);
TestRayCast(dynamicObject);
TestTriangleMeshRayCast(triMeshObject);
dynamicObject = null;
dynamicObject2 = null;
triMeshObject = null;
//world.SetInternalTickCallback(null);
world.Dispose();
world = null;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();
TestWeakRefs();
disposeQueue.Clear();
}
示例4: InitBullet
public static void InitBullet()
{
// collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration.
BtEngineCollisionConfiguration = new DefaultCollisionConfiguration();
// use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
BtEngineDispatcher = new CollisionDispatcher(BtEngineCollisionConfiguration);
BtEngineDispatcher.NearCallback = RoomNearCallback;
// btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep.
BtEngineOverlappingPairCache = new DbvtBroadphase();
BtEngineGhostPairCallback = new GhostPairCallback();
BtEngineOverlappingPairCache.OverlappingPairCache.SetInternalGhostPairCallback(BtEngineGhostPairCallback);
// the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
BtEngineSolver = new SequentialImpulseConstraintSolver();
BtEngineDynamicsWorld = new DiscreteDynamicsWorld(BtEngineDispatcher,
BtEngineOverlappingPairCache, BtEngineSolver, BtEngineCollisionConfiguration);
BtEngineDynamicsWorld.SetInternalTickCallback(InternalTickCallback);
BtEngineDynamicsWorld.Gravity = new BulletSharp.Math.Vector3(0, 0, -4500.0f);
DebugDrawer = new RenderDebugDrawer();
DebugDrawer.DebugMode = DebugDrawModes.DrawWireframe | DebugDrawModes.DrawConstraints;
BtEngineDynamicsWorld.DebugDrawer = DebugDrawer;
//Global.BtEngineDynamicsWorld.PairCache.SetInternalGhostPairCallback(Global.BtEngineFilterCallback);
}