Set() public method

public Set ( Filter argOther ) : void
argOther Filter
return void
Exemplo n.º 1
0
        // We need separation create/destroy functions from the constructor/destructor because
        // the destructor cannot access the allocator (no destructor arguments allowed by C++).

        public void Create(Body body, FixtureDef def)
        {
            UserData    = def.UserData;
            Friction    = def.Friction;
            Restitution = def.Restitution;

            Body = body;
            Next = null;


            Filter.Set(def.Filter);

            IsSensor = def.IsSensor;

            Shape = def.Shape.Clone();

            // Reserve proxy space
            int childCount = Shape.ChildCount;

            if (Proxies == null)
            {
                Proxies = new FixtureProxy[childCount];
                for (int i = 0; i < childCount; i++)
                {
                    Proxies[i] = new FixtureProxy {
                        Fixture = null, ProxyId = BroadPhase.NULL_PROXY
                    };
                }
            }

            if (Proxies.Length < childCount)
            {
                FixtureProxy[] old    = Proxies;
                int            newLen = MathUtils.Max(old.Length * 2, childCount);
                Proxies = new FixtureProxy[newLen];
                Array.Copy(old, 0, Proxies, 0, old.Length);
                for (int i = 0; i < newLen; i++)
                {
                    if (i >= old.Length)
                    {
                        Proxies[i] = new FixtureProxy();
                    }
                    Proxies[i].Fixture = null;
                    Proxies[i].ProxyId = BroadPhase.NULL_PROXY;
                }
            }
            ProxyCount = 0;

            m_density = def.Density;
        }