コード例 #1
0
    protected static void AddType(b2ContactCreateFcn createFcn, b2ContactDestroyFcn destoryFcn, b2Shape.Type type1, b2Shape.Type type2)
    {
        Debug.Assert(0 <= ((int)type1) && type1 < b2Shape.Type.e_typeCount);
        Debug.Assert(0 <= ((int)type2) && type2 < b2Shape.Type.e_typeCount);

        s_registers[(int)type1, (int)type2]            = new b2ContactRegister();
        s_registers[(int)type1, (int)type2].createFcn  = createFcn;
        s_registers[(int)type1, (int)type2].destroyFcn = destoryFcn;
        s_registers[(int)type1, (int)type2].primary    = true;

        if (type1 != type2)
        {
            s_registers[(int)type2, (int)type1]            = new b2ContactRegister();
            s_registers[(int)type2, (int)type1].createFcn  = createFcn;
            s_registers[(int)type2, (int)type1].destroyFcn = destoryFcn;
            s_registers[(int)type2, (int)type1].primary    = false;
        }
    }
コード例 #2
0
    internal static void Destroy(ref b2Contact contact)
    {
        Debug.Assert(s_initialized == true);

        b2Fixture fixtureA = contact.m_fixtureA;
        b2Fixture fixtureB = contact.m_fixtureB;

        if (contact.m_manifold.pointCount > 0 && fixtureA.IsSensor() == false && fixtureB.IsSensor() == false)
        {
            fixtureA.GetBody().SetAwake(true);
            fixtureB.GetBody().SetAwake(true);
        }

        b2Shape.Type typeA = fixtureA.GetType();
        b2Shape.Type typeB = fixtureB.GetType();

        Debug.Assert(0 <= ((int)typeA) && typeB < b2Shape.Type.e_typeCount);
        Debug.Assert(0 <= ((int)typeA) && typeB < b2Shape.Type.e_typeCount);

        b2ContactDestroyFcn destroyFcn = s_registers[(int)typeA, (int)typeB].destroyFcn;

        destroyFcn(ref contact);
    }