@Override public boolean solvePositionConstraints(SolverData step) { return constrainEdges(step.positions); }
public static void destroy(Joint joint) { joint.destructor(); }
/** * This is used to prevent connected bodies from colliding. * It may lie, depending on the collideConnected flag. * * @param other other body * @return if they should collide */ public boolean shouldCollide(Body other) { // At least one body should be dynamic. if (type != BodyType.DYNAMIC && other.type != BodyType.DYNAMIC) { return false; } // Does a joint prevent collision? for (JointEdge jn = m_jointList; jn != null; jn = jn.next) { if (jn.other == other) { if (!jn.joint.getCollideConnected()) { return false; } } } return true; }
public static Joint create(World world, JointDef def) { switch (def.type) { case MOUSE: return new MouseJoint(world.getPool(), (MouseJointDef) def); case DISTANCE: return new DistanceJoint(world.getPool(), (DistanceJointDef) def); case PRISMATIC: return new PrismaticJoint(world.getPool(), (PrismaticJointDef) def); case REVOLUTE: return new RevoluteJoint(world.getPool(), (RevoluteJointDef) def); case WELD: return new WeldJoint(world.getPool(), (WeldJointDef) def); case FRICTION: return new FrictionJoint(world.getPool(), (FrictionJointDef) def); case WHEEL: return new WheelJoint(world.getPool(), (WheelJointDef) def); case GEAR: return new GearJoint(world.getPool(), (GearJointDef) def); case PULLEY: return new PulleyJoint(world.getPool(), (PulleyJointDef) def); case CONSTANT_VOLUME: return new ConstantVolumeJoint(world, (ConstantVolumeJointDef) def); case ROPE: return new RopeJoint(world.getPool(), (RopeJointDef) def); case MOTOR: return new MotorJoint(world.getPool(), (MotorJointDef) def); case UNKNOWN: default:
assertNotLocked(); boolean collideConnected = j.getCollideConnected(); Body bodyA = j.getBodyA(); Body bodyB = j.getBodyB(); j.m_edgeB.next = null; Joint.destroy(j);
targetLengths[i] = dist; targetVolume = getBodyArea(); final DistanceJointDef djd = new DistanceJointDef(); distanceJoints = new DistanceJoint[bodies.length]; for (int i = 0; i < targetLengths.length; ++i) { djd.initialize(bodies[i], bodies[next], bodies[i].getWorldCenter(), bodies[next].getWorldCenter()); distanceJoints[i] = (DistanceJoint) world.createJoint(djd);
assertNotLocked(); Joint j = Joint.create(this, def); j.m_edgeA.other = j.getBodyB(); j.m_edgeA.prev = null; j.m_edgeA.next = j.getBodyA().m_jointList; if (j.getBodyA().m_jointList != null) { j.getBodyA().m_jointList.prev = j.m_edgeA; j.getBodyA().m_jointList = j.m_edgeA; j.m_edgeB.other = j.getBodyA(); j.m_edgeB.prev = null; j.m_edgeB.next = j.getBodyB().m_jointList; if (j.getBodyB().m_jointList != null) { j.getBodyB().m_jointList.prev = j.m_edgeB; j.getBodyB().m_jointList = j.m_edgeB;
/** * Adds a body and the pre-made distance joint. Should only be used for deserialization. */ public void addBodyAndJoint(Body argBody, DistanceJoint argJoint) { addBody(argBody); if (joints == null) { joints = new ArrayList<DistanceJoint>(); } joints.add(argJoint); } }
protected Joint(IWorldPool worldPool, JointDef def) { assert (def.bodyA != def.bodyB); pool = worldPool; m_type = def.type; m_prev = null; m_next = null; m_bodyA = def.bodyA; m_bodyB = def.bodyB; m_collideConnected = def.collideConnected; m_islandFlag = false; m_userData = def.userData; m_edgeA = new JointEdge(); m_edgeA.joint = null; m_edgeA.other = null; m_edgeA.prev = null; m_edgeA.next = null; m_edgeB = new JointEdge(); m_edgeB.joint = null; m_edgeB.other = null; m_edgeB.prev = null; m_edgeB.next = null; // m_localCenterA = new Vec2(); // m_localCenterB = new Vec2(); }
float deltaArea = targetVolume - getSolverArea(positions); float toExtrude = 0.5f * deltaArea / perimeter; // *relaxationFactor
public static Joint create(World world, JointDef def) { switch (def.type) { case MOUSE: return new MouseJoint(world.getPool(), (MouseJointDef) def); case DISTANCE: return new DistanceJoint(world.getPool(), (DistanceJointDef) def); case PRISMATIC: return new PrismaticJoint(world.getPool(), (PrismaticJointDef) def); case REVOLUTE: return new RevoluteJoint(world.getPool(), (RevoluteJointDef) def); case WELD: return new WeldJoint(world.getPool(), (WeldJointDef) def); case FRICTION: return new FrictionJoint(world.getPool(), (FrictionJointDef) def); case WHEEL: return new WheelJoint(world.getPool(), (WheelJointDef) def); case GEAR: return new GearJoint(world.getPool(), (GearJointDef) def); case PULLEY: return new PulleyJoint(world.getPool(), (PulleyJointDef) def); case CONSTANT_VOLUME: return new ConstantVolumeJoint(world, (ConstantVolumeJointDef) def); case ROPE: return new RopeJoint(world.getPool(), (RopeJointDef) def); case MOTOR: return new MotorJoint(world.getPool(), (MotorJointDef) def); case UNKNOWN: default:
assertNotLocked(); boolean collideConnected = j.getCollideConnected(); Body bodyA = j.getBodyA(); Body bodyB = j.getBodyB(); j.m_edgeB.next = null; Joint.destroy(j);
targetLengths[i] = dist; targetVolume = getBodyArea(); final DistanceJointDef djd = new DistanceJointDef(); distanceJoints = new DistanceJoint[bodies.length]; for (int i = 0; i < targetLengths.length; ++i) { djd.initialize(bodies[i], bodies[next], bodies[i].getWorldCenter(), bodies[next].getWorldCenter()); distanceJoints[i] = (DistanceJoint) world.createJoint(djd);
assertNotLocked(); Joint j = Joint.create(this, def); j.m_edgeA.other = j.getBodyB(); j.m_edgeA.prev = null; j.m_edgeA.next = j.getBodyA().m_jointList; if (j.getBodyA().m_jointList != null) { j.getBodyA().m_jointList.prev = j.m_edgeA; j.getBodyA().m_jointList = j.m_edgeA; j.m_edgeB.other = j.getBodyA(); j.m_edgeB.prev = null; j.m_edgeB.next = j.getBodyB().m_jointList; if (j.getBodyB().m_jointList != null) { j.getBodyB().m_jointList.prev = j.m_edgeB; j.getBodyB().m_jointList = j.m_edgeB;
@Override public boolean solvePositionConstraints(SolverData step) { return constrainEdges(step.positions); }
public static void destroy(Joint joint) { joint.destructor(); }
/** * Adds a body and the pre-made distance joint. Should only be used for deserialization. */ public void addBodyAndJoint(Body argBody, DistanceJoint argJoint) { addBody(argBody); if (joints == null) { joints = new ArrayList<DistanceJoint>(); } joints.add(argJoint); } }
/** * This is used to prevent connected bodies from colliding. * It may lie, depending on the collideConnected flag. * * @param other other body * @return if they should collide */ public boolean shouldCollide(Body other) { // At least one body should be dynamic. if (type != BodyType.DYNAMIC && other.type != BodyType.DYNAMIC) { return false; } // Does a joint prevent collision? for (JointEdge jn = m_jointList; jn != null; jn = jn.next) { if (jn.other == other) { if (!jn.joint.getCollideConnected()) { return false; } } } return true; }
protected Joint(IWorldPool worldPool, JointDef def) { assert (def.bodyA != def.bodyB); pool = worldPool; m_type = def.type; m_prev = null; m_next = null; m_bodyA = def.bodyA; m_bodyB = def.bodyB; m_collideConnected = def.collideConnected; m_islandFlag = false; m_userData = def.userData; m_edgeA = new JointEdge(); m_edgeA.joint = null; m_edgeA.other = null; m_edgeA.prev = null; m_edgeA.next = null; m_edgeB = new JointEdge(); m_edgeB.joint = null; m_edgeB.other = null; m_edgeB.prev = null; m_edgeB.next = null; // m_localCenterA = new Vec2(); // m_localCenterB = new Vec2(); }
float deltaArea = targetVolume - getSolverArea(positions); float toExtrude = 0.5f * deltaArea / perimeter; // *relaxationFactor