public Fixture(Body body, Shape shape, object userData) { if (Settings.UseFPECollisionCategories) _collisionCategories = Category.All; else _collisionCategories = Category.Cat1; _collidesWith = Category.All; _collisionGroup = 0; //Fixture defaults Friction = 0.2f; Restitution = 0; IsSensor = false; Body = body; UserData = userData; if (Settings.ConserveMemory) Shape = shape; else Shape = shape.Clone(); RegisterFixture(); }
internal Fixture(Body body, Shape shape, object userData = null) { #if DEBUG if (shape.ShapeType == ShapeType.Polygon) ((PolygonShape)shape).Vertices.AttachedToBody = true; #endif _collisionCategories = Settings.DefaultFixtureCollisionCategories; _collidesWith = Settings.DefaultFixtureCollidesWith; _collisionGroup = 0; IgnoreCCDWith = Settings.DefaultFixtureIgnoreCCDWith; //Fixture defaults Friction = 0.2f; Restitution = 0; Body = body; IsSensor = false; UserData = userData; Shape = Settings.ConserveMemory ? shape : shape.Clone(); RegisterFixture(); }
public FSFixture(FSBody body, Shape shape, object userData) { _collisionCategories = FSSettings.DefaultFixtureCollisionCategories; _collidesWith = FSSettings.DefaultFixtureCollidesWith; _collisionGroup = 0; #if USE_IGNORE_CCD_CATEGORIES IgnoreCCDWith = FSSettings.DefaultFixtureIgnoreCCDWith; #endif //Fixture defaults Friction = 0.2f; Restitution = 0; Body = body; IsSensor = false; UserData = userData; if (FSSettings.ConserveMemory) Shape = shape; else if (shape != null) Shape = shape.Clone(); RegisterFixture(); }
internal Fixture(Body body, Shape shape, float density) { //Fixture defaults Friction = 0.2f; _collisionCategories = CollisionCategory.All; _collidesWith = CollisionCategory.All; IsSensor = false; Body = body; #if ConserveMemory Shape = shape; #else Shape = shape.Clone(); #endif // Reserve proxy space int childCount = Shape.ChildCount; Proxies = new FixtureProxy[childCount]; for (int i = 0; i < childCount; ++i) { Proxies[i] = new FixtureProxy(); Proxies[i].Fixture = null; Proxies[i].ProxyId = BroadPhase.NullProxy; } ProxyCount = 0; Density = density; FixtureId = _fixtureIdCounter++; }
public Fixture(Body body, Shape shape, Object userData) { CollisionFilter = new CollisionFilter(this); //Fixture defaults Friction = 0.2f; Restitution = 0; IsSensor = false; Body = body; UserData = userData; if (Settings.ConserveMemory) Shape = shape; else Shape = shape.Clone(); // Reserve proxy space int childCount = Shape.ChildCount; Proxies = new FixtureProxy[childCount]; for (int i = 0; i < childCount; ++i) { Proxies[i] = new FixtureProxy(); Proxies[i].Fixture = null; Proxies[i].ProxyId = BroadPhase.NullProxy; } ProxyCount = 0; FixtureId = _fixtureIdCounter++; if ((Body.Flags & BodyFlags.Enabled) == BodyFlags.Enabled) { BroadPhase broadPhase = Body.World.ContactManager.BroadPhase; CreateProxies(broadPhase, ref Body.Xf); } Body.FixtureList.Add(this); // Adjust mass properties if needed. if (Shape._density > 0.0f) { Body.ResetMassData(); } // Let the world know we have a new fixture. This will cause new contacts // to be created at the beginning of the next time step. Body.World.Flags |= WorldFlags.NewFixture; if (Body.World.FixtureAdded != null) { Body.World.FixtureAdded(this); } }
private static Fixture GlomFixture(World world, Body oldBody, List<Body> thisSideBodies, Shape shape, DebugMaterial mat, List<Joint> joints) { foreach (Body lb in thisSideBodies) { foreach (Fixture lf in lb.FixtureList) { Manifold m = new Manifold(); PolygonShape newShape = shape.Clone() as PolygonShape; PolygonShape existingShape = lf.Shape as PolygonShape; if (newShape != null && existingShape != null) { Collision.Collision.CollidePolygons(ref m, newShape, ref oldBody.Xf, existingShape, ref oldBody.Xf); if (m.PointCount > 0) { Fixture glommed = lb.CreateFixture(newShape, mat); transferJoints(oldBody, joints, lb, glommed); return glommed; } } } } Body lb2 = new Body(world); if (!thisSideBodies.Any()) { transferJoints(oldBody, joints, lb2, null); } lb2.Position = oldBody.Position; lb2.Rotation = oldBody.Rotation; thisSideBodies.Add(lb2); Fixture separate = lb2.CreateFixture(shape.Clone(), mat); transferJoints(oldBody, joints, lb2, separate); return separate; }