public EdgeShape () { super(new org.jbox2d.collision.shapes.EdgeShape()); shape = (org.jbox2d.collision.shapes.EdgeShape)super.shape; }
@Override public float computeDistanceToOut(Transform xf, Vec2 p, int childIndex, Vec2 normalOut) { final EdgeShape edge = pool0; getChildEdge(edge, childIndex); return edge.computeDistanceToOut(xf, p, 0, normalOut); }
@Override public boolean raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex) { assert (childIndex < m_count); final EdgeShape edgeShape = pool0; int i1 = childIndex; int i2 = childIndex + 1; if (i2 == m_count) { i2 = 0; } Vec2 v = m_vertices[i1]; edgeShape.m_vertex1.x = v.x; edgeShape.m_vertex1.y = v.y; Vec2 v1 = m_vertices[i2]; edgeShape.m_vertex2.x = v1.x; edgeShape.m_vertex2.y = v1.y; return edgeShape.raycast(output, input, xf, 0); }
EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-20, 32), new Vec2(-12, 32)); body.createFixture(shape, 0.1f); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-11, 32), new Vec2(20, 32)); body.createFixture(shape, 0.1f); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-12, 32), new Vec2(-12, 28)); body.createFixture(shape, 0.1f); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-11, 32), new Vec2(-11, 28)); body.createFixture(shape, 0.1f); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-16, 24), new Vec2(8, 20)); body.createFixture(shape, 0.1f); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(16, 16), new Vec2(-8, 12)); body.createFixture(shape, 0.1f); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-12, 8), new Vec2(-12, 0)); body.createFixture(shape, 0.1f); EdgeShape shape = new EdgeShape();
@Override public Shape clone() { EdgeShape edge = new EdgeShape(); edge.setRadius(this.getRadius()); edge.m_hasVertex0 = this.m_hasVertex0; edge.m_hasVertex3 = this.m_hasVertex3; edge.m_vertex0.set(this.m_vertex0); edge.m_vertex1.set(this.m_vertex1); edge.m_vertex2.set(this.m_vertex2); edge.m_vertex3.set(this.m_vertex3); return edge; }
@Override public float getRadius () { return shape.getRadius(); }
@Override public void setRadius (float radius) { shape.setRadius(radius); }
/** Set this as an isolated edge. */ public void set (float v1X, float v1Y, float v2X, float v2Y) { tmp.set(v1X, v1Y); tmp2.set(v2X, v2Y); shape.set(tmp, tmp2); }
@Override public void initTest(boolean argDeserialized) { { BodyDef bd = new BodyDef(); Body ground = getWorld().createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f)); ground.createFixture(shape, 0.0f); } BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.position.set(0.0f, 10.0f); m_body = getWorld().createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(4.0f, 4.0f, new Vec2(0.0f, 0.0f), 0.0f); m_fixture1 = m_body.createFixture(shape, 10.0f); m_fixture2 = null; }
m_vertices[1].set(edge.m_vertex2); m_count = 2; m_radius = edge.getRadius(); break; default:
public EdgeShape() { super(ShapeType.EDGE); setRadius(JBoxSettings.polygonRadius); }
@Override public void initTest(boolean deserialized) { if (deserialized) { return; } Body bodies[] = new Body[e_count]; { BodyDef bd = new BodyDef(); Body ground = getWorld().createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f)); ground.createFixture(shape, 0.0f); } { CircleShape shape = new CircleShape(); shape.m_radius = 1.0f; for (int i = 0; i < e_count; ++i) { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.position.set(0.0f, 4.0f + 3.0f * i); bodies[i] = getWorld().createBody(bd); bodies[i].createFixture(shape, 1.0f); // m_bodies[i].setLinearVelocity(new Vec2(0.0f, -100.0f)); } } }
@Override public Shape clone() { EdgeShape edge = new EdgeShape(); edge.m_radius = this.m_radius; edge.m_hasVertex0 = this.m_hasVertex0; edge.m_hasVertex3 = this.m_hasVertex3; edge.m_vertex0.set(this.m_vertex0); edge.m_vertex1.set(this.m_vertex1); edge.m_vertex2.set(this.m_vertex2); edge.m_vertex3.set(this.m_vertex3); return edge; } }
@Override public boolean raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex) { assert (childIndex < m_count); final EdgeShape edgeShape = pool0; int i1 = childIndex; int i2 = childIndex + 1; if (i2 == m_count) { i2 = 0; } Vec2 v = m_vertices[i1]; edgeShape.m_vertex1.x = v.x; edgeShape.m_vertex1.y = v.y; Vec2 v1 = m_vertices[i2]; edgeShape.m_vertex2.x = v1.x; edgeShape.m_vertex2.y = v1.y; return edgeShape.raycast(output, input, xf, 0); }
@Override public float computeDistanceToOut(Transform xf, Vec2 p, int childIndex, Vec2 normalOut) { final EdgeShape edge = pool0; getChildEdge(edge, childIndex); return edge.computeDistanceToOut(xf, p, 0, normalOut); }
float v = Vec2.dot(e, temp.set(Q).subLocal(A)); float radius = edgeA.getRadius() + circleB.getRadius();
assert (0 <= index && index < m_count - 1); edge.setRadius(getRadius());
Body ground = getWorld().createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-10.0f, 0.0f), new Vec2(10.0f, 0.0f)); ground.createFixture(shape, 0.0f); shape.set(new Vec2(-10.0f, 0.0f), new Vec2(-10.0f, 20.0f)); ground.createFixture(shape, 0.0f); shape.set(new Vec2(10.0f, 0.0f), new Vec2(10.0f, 20.0f)); ground.createFixture(shape, 0.0f); shape.set(new Vec2(-10.0f, 20.0f), new Vec2(10.0f, 20.0f)); ground.createFixture(shape, 0.0f);
@Override public Shape clone() { EdgeShape edge = new EdgeShape(); edge.m_radius = this.m_radius; edge.m_hasVertex0 = this.m_hasVertex0; edge.m_hasVertex3 = this.m_hasVertex3; edge.m_vertex0.set(this.m_vertex0); edge.m_vertex1.set(this.m_vertex1); edge.m_vertex2.set(this.m_vertex2); edge.m_vertex3.set(this.m_vertex3); return edge; } }
@Override public boolean raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex) { assert (childIndex < m_count); final EdgeShape edgeShape = pool0; int i1 = childIndex; int i2 = childIndex + 1; if (i2 == m_count) { i2 = 0; } Vec2 v = m_vertices[i1]; edgeShape.m_vertex1.x = v.x; edgeShape.m_vertex1.y = v.y; Vec2 v1 = m_vertices[i2]; edgeShape.m_vertex2.x = v1.x; edgeShape.m_vertex2.y = v1.y; return edgeShape.raycast(output, input, xf, 0); }