Esempio n. 1
0
        // We need separation create/destroy functions from the constructor/destructor because
        // the destructor cannot access the allocator or broad-phase (no destructor arguments allowed by C++).
        public void Create(BroadPhase broadPhase, Body body, Transform xf, FixtureDef def)
        {
            UserData = def.UserData;
            Friction = def.Friction;
            Restitution = def.Restitution;

            Body = body;
            _next = null;

            Filter = def.Filter;

            IsSensor = def.IsSensor;

            Shape = def.Shape.Clone();

            Shape.ComputeMass(out _massData, def.Density);

            // Create proxy in the broad-phase.
            Shape.ComputeAABB(out Aabb, ref xf);

            ProxyId = broadPhase.CreateProxy(Aabb, this);
        }
Esempio n. 2
0
        public void SetFilterData(Filter filter)
        {
            Filter = filter;

            if (Body == null)
            {
                return;
            }

            // Flag associated contacts for filtering.
            ContactEdge edge = Body.GetContactList();
            while (edge != null)
            {
                Contact contact = edge.Contact;
                Fixture fixtureA = contact.GetFixtureA();
                Fixture fixtureB = contact.GetFixtureB();
                if (fixtureA == this || fixtureB == this)
                {
                    contact.FlagForFiltering();
                }
            }
        }