Ejemplo n.º 1
0
        public override void step(TestbedSettings settings)
        {
            m_rayActor = null;
            for (int i = 0; i < _e_actorCount; ++i)
            {
                m_actors[i].fraction = 1.0f;
                m_actors[i].overlap = false;
            }

            if (m_automated == true)
            {
                int actionCount = MathUtils.max(1, _e_actorCount >> 2);

                for (int i = 0; i < actionCount; ++i)
                {
                    Action();
                }
            }

            Query();
            RayCast();
            Vec2[] vecs = vecPool.get(4);

            for (int i = 0; i < _e_actorCount; ++i)
            {
                Actor actor = m_actors[i];
                if (actor.proxyId == -1)
                    continue;

                Color4f c = new Color4f(0.9f, 0.9f, 0.9f);
                if (actor == m_rayActor && actor.overlap)
                {
                    c.set(0.9f, 0.6f, 0.6f);
                }
                else if (actor == m_rayActor)
                {
                    c.set(0.6f, 0.9f, 0.6f);
                }
                else if (actor.overlap)
                {
                    c.set(0.6f, 0.6f, 0.9f);
                }
                actor.aabb.getVertices(vecs);
                getDebugDraw().drawPolygon(vecs, 4, c);
            }

            Color4f c2 = new Color4f(0.7f, 0.7f, 0.7f);
            m_queryAABB.getVertices(vecs);
            getDebugDraw().drawPolygon(vecs, 4, c2);

            getDebugDraw().drawSegment(m_rayCastInput.p1, m_rayCastInput.p2, c2);

            Color4f c1 = new Color4f(0.2f, 0.9f, 0.2f);
            Color4f c3 = new Color4f(0.9f, 0.2f, 0.2f);
            getDebugDraw().drawPoint(m_rayCastInput.p1, 6.0f, c1);
            getDebugDraw().drawPoint(m_rayCastInput.p2, 6.0f, c3);

            if (m_rayActor != null)
            {
                Color4f cr = new Color4f(0.2f, 0.2f, 0.9f);
                m_rayCastInput.p2.sub(m_rayCastInput.p1);
                m_rayCastInput.p2.mulLocal(m_rayActor.fraction);
                m_rayCastInput.p2.addLocal(m_rayCastInput.p1);
                Vec2 p = m_rayCastInput.p2;
                getDebugDraw().drawPoint(p, 6.0f, cr);
            }

            ++m_stepCount;

            if (settings.getSetting(TestbedSettings.DrawTree).enabled)
            {
                m_tree.drawTree(getDebugDraw());
            }

            getDebugDraw().drawString(5, 30,
                "(c)reate proxy, (d)estroy proxy, (a)utomate", Color4f.WHITE);
        }