private void createWorld(boolean visualized) { collisionConfiguration = new btDefaultCollisionConfiguration(); dispatcher = new btCollisionDispatcher(collisionConfiguration); broadPhase = new btDbvtBroadphase(); constraintSolver = new btSequentialImpulseConstraintSolver(); bulletWorld = new btDiscreteDynamicsWorld(dispatcher, broadPhase, constraintSolver, collisionConfiguration); if (visualized) { debugDrawer = new DebugDrawer(); bulletWorld.setDebugDrawer(debugDrawer); rayCallback = new ClosestRayResultCallback(new Vector3(), new Vector3()); } // btGImpactCollisionAlgorithm.registerAlgorithm(dispatcher); // TODO: Collision between GImpact not needed? bulletWorld.setGravity(new Vector3(0, 0f, 0)); }
public World(String name) { collisionConfiguration = new btDefaultCollisionConfiguration(); dispatcher = new btCollisionDispatcher(collisionConfiguration); broadPhase = new btDbvtBroadphase(); constraintSolver = new btSequentialImpulseConstraintSolver(); bulletWorld = new btDiscreteDynamicsWorld(dispatcher, broadPhase, constraintSolver, collisionConfiguration); debugDrawer = new DebugDrawer(); btGImpactCollisionAlgorithm.registerAlgorithm(dispatcher); bulletWorld.setDebugDrawer(debugDrawer); bulletWorld.setGravity(new Vector3(0, -10f, 0)); worldCounter = CounterUtil.getCounter("worldTick" + name); this.name = name; rayCallback = new ClosestRayResultCallback(new Vector3(), new Vector3()); logger.info("Iterations: {}", bulletWorld.getSolverInfo().getNumIterations()); logger.info("Erp: {}", bulletWorld.getSolverInfo().getErp()); // // bulletWorld.getSolverInfo().setNumIterations(20); // bulletWorld.getSolverInfo().setErp(0.01f); }
public ControllerPhysic(float gravity, PhysicsListener listener) { this.listener = listener; collisionConfig = new btDefaultCollisionConfiguration(); dispatcher = new btCollisionDispatcher(collisionConfig); broadphase = new btDbvtBroadphase(); constraintSolver = new btSequentialImpulseConstraintSolver(); dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, constraintSolver, collisionConfig); dynamicsWorld.setGravity(new Vector3(0, 0, gravity * 2.5f)); if (Config.DEBUG_RENDERER) { debugDrawer = new DebugDrawer(); debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE); dynamicsWorld.setDebugDrawer(debugDrawer); } tickCallback = new TickCallback(dynamicsWorld, listener); }
public GameEngine() { collisionConfig = new btDefaultCollisionConfiguration(); dispatcher = new btCollisionDispatcher(collisionConfig); broadphase = new btDbvtBroadphase(); constraintSolver = new btSequentialImpulseConstraintSolver(); dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, constraintSolver, collisionConfig); dynamicsWorld.setGravity(GameSettings.GRAVITY); debugDrawer = new DebugDrawer(); dynamicsWorld.setDebugDrawer(debugDrawer); debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_DrawWireframe); contactListener = new CollisionContactListener(); }
private void createWorld() { debugDrawer = new DebugDrawer(); collisionConfig = new btDefaultCollisionConfiguration(); dispatcher = new btCollisionDispatcher(collisionConfig); constraintSolver = new btSequentialImpulseConstraintSolver(); sweep = new btAxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000)); ghostCallback = new btGhostPairCallback(); sweep.getOverlappingPairCache().setInternalGhostPairCallback(ghostCallback); bulletWorld = new btDiscreteDynamicsWorld(dispatcher, sweep, constraintSolver, collisionConfig); bulletWorld.setGravity(new Vector3(0, -9f, 0)); debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE); }
public Physics() { Bullet.init(); shapes = new Array<>(); objects = new Array<>(); disposables = new Array<>(); if (Main.isClient()) { debugDrawer = new DebugDrawer(); debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE); } inst = this; collisionConfig = new btDefaultCollisionConfiguration(); dispatcher = new btCollisionDispatcher(collisionConfig); broadphaseInterface = new btDbvtBroadphase(); // TODO is it worth comparing performance with other broadphase types? //broadphaseInterface = new btSimpleBroadphase(); //broadphaseInterface = new btAxisSweep3(tmp.set(0f, -10, 0f), tmp2.set(GameWorld.WORLD_WIDTH, 200f, GameWorld.WORLD_DEPTH)); world = new btCollisionWorld(dispatcher, broadphaseInterface, collisionConfig); if (Main.isClient()) { world.setDebugDrawer(debugDrawer); } contactListener = new MyContactListener(); disposables.add(world); if (debugDrawer != null) { disposables.add(debugDrawer); } disposables.add(collisionConfig); disposables.add(dispatcher); disposables.add(broadphaseInterface); disposables.add(contactListener); }
public void setDebugDrawer(DebugDrawer debugDrawer) { dynamicsWorld.setDebugDrawer(debugDrawer); }
public DebugDrawer getDebugDrawer() { return debugDrawer; }
public DebugRenderer(btCollisionWorld world) { this.world = world; this.drawer = new DebugDrawer(); this.drawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_DrawNormals); this.world.setDebugDrawer(this.drawer); }
public void setDebugMode (final int mode) { if (mode == btIDebugDraw.DebugDrawModes.DBG_NoDebug && debugDrawer == null) return; if (debugDrawer == null) collisionWorld.setDebugDrawer(debugDrawer = new DebugDrawer()); debugDrawer.setDebugMode(mode); }