public void Defaults() { shape = null; userData = null; friction = 0.2f; restitution = 0.0f; density = 0.0f; isSensor = false; }
public void Set(b2Shape shape, int index) { switch (shape.ShapeType) { case b2ShapeType.e_circle: { b2CircleShape circle = (b2CircleShape)shape; m_buffer[0] = circle.Position; m_vertices = m_buffer; m_count = 1; m_radius = circle.Radius; } break; case b2ShapeType.e_polygon: { b2PolygonShape polygon = (b2PolygonShape)shape; m_vertices = polygon.Vertices; m_count = polygon.VertexCount; m_radius = polygon.Radius; } break; case b2ShapeType.e_chain: { b2ChainShape chain = (b2ChainShape)shape; Debug.Assert(0 <= index && index < chain.Count); m_buffer[0] = chain.Vertices[index]; if (index + 1 < chain.Count) { m_buffer[1] = chain.Vertices[index + 1]; } else { m_buffer[1] = chain.Vertices[0]; } m_vertices = m_buffer; m_count = 2; m_radius = chain.Radius; } break; case b2ShapeType.e_edge: { b2EdgeShape edge = (b2EdgeShape)shape; m_buffer[0] = edge.Vertex1; m_buffer[1] = edge.Vertex2; m_vertices = m_buffer; m_count = 2; m_radius = edge.Radius; } break; default: Debug.Assert(false); break; } }
public static b2DistanceProxy Create(b2Shape shape, int index) { b2DistanceProxy bp = Create(); bp.Set(shape, index); return (bp); }
public b2Shape(b2Shape copy) { m_type = copy.m_type; m_radius = copy.m_radius; }
/// Determine if two generic shapes overlap. public static bool b2TestOverlap(b2Shape shapeA, int indexA, b2Shape shapeB, int indexB, ref b2Transform xfA, ref b2Transform xfB) { b2DistanceInput input = b2DistanceInput.Create(); input.proxyA = b2DistanceProxy.Create(shapeA, indexA); input.proxyB = b2DistanceProxy.Create(shapeB, indexB); input.transformA = xfA; input.transformB = xfB; input.useRadii = true; b2SimplexCache cache = b2SimplexCache.Create(); b2DistanceOutput output = new b2DistanceOutput(); b2Simplex.b2Distance(ref output, ref cache, ref input); // Console.WriteLine("{2} vs {3}: distance={0} after {1} iters", output.distance, output.iterations, shapeA.ShapeType, shapeB.ShapeType); return output.distance < 10.0f * b2Settings.b2_epsilon; }
public virtual void Destroy() { m_proxies = null; m_shape = null; }
public void Create(b2Body body, b2FixtureDef def) { m_userData = def.userData; m_friction = def.friction; m_restitution = def.restitution; m_body = body; Next = null; m_filter = def.filter; m_isSensor = def.isSensor; m_shape = def.shape.Clone(); // Reserve proxy space int childCount = m_shape.GetChildCount(); for (int i = 0; i < childCount; ++i) { b2FixtureProxy proxy = new b2FixtureProxy(); proxy.fixture = null; proxy.proxyId = b2BroadPhase.e_nullProxy; m_proxies.Add(proxy); } m_proxyCount = 0; m_density = def.density; }
public virtual b2Fixture CreateFixture(b2Shape shape, float density) { b2FixtureDef def = b2FixtureDef.Default; def.shape = shape; def.density = density; return CreateFixture(def); }
public b2Shape(b2Shape copy) { ShapeType = copy.ShapeType; Radius = copy.Radius; }
public virtual void Destroy() { b2ArrayPool<b2FixtureProxy>.Free(m_proxies); m_proxies = null; Shape = null; }
public void Create(b2Body body, b2FixtureDef def) { UserData = def.userData; Friction = def.friction; Restitution = def.restitution; Body = body; Next = null; m_filter = def.filter; m_isSensor = def.isSensor; Shape = def.shape.Clone(); // Reserve proxy space int childCount = Shape.GetChildCount(); m_proxies = b2ArrayPool<b2FixtureProxy>.Create(childCount, true); for (int i = 0; i < childCount; ++i) { m_proxies[i].fixture = null; m_proxies[i].proxyId = b2BroadPhase.e_nullProxy; } m_proxyCount = 0; Density = def.density; }
/// Determine if two generic shapes overlap. public static bool b2TestOverlap(b2Shape shapeA, int indexA, b2Shape shapeB, int indexB, b2Transform xfA, b2Transform xfB) { }