Exemplo n.º 1
0
        public static float sol_test_side(float dt,
                                          float[] T,
                                          s_ball up,
                                          s_file fp,
                                          s_lump lp,
                                          s_side sp,
                                          float[] o,
                                          float[] w)
        {
            float t = v_side(T, o, w, sp.m_n, sp.m_d, up.m_p, up.m_v, up.m_r);
            int   i;

            if (t < dt)
            {
                for (i = 0; i < lp.m_sc; i++)
                {
                    s_side sq = fp.m_sv[fp.m_iv[lp.m_s0 + i]];

                    if (sp != sq &&
                        Vec3.v_dot(T, sq.m_n) -
                        Vec3.v_dot(o, sq.m_n) -
                        Vec3.v_dot(w, sq.m_n) * t > sq.m_d)
                    {
                        return((float)LARGE);
                    }
                }
            }
            return(t);
        }
Exemplo n.º 2
0
        public static int sol_test_back(float dt,
                                        s_ball up,
                                        s_side sp,
                                        float[] o,
                                        float[] w)
        {
            float[] q = new float[3];

            /* If the ball is not in front of the plane, the test passes. */

            Vec3.v_sub(q, up.m_p, o);

            if (Vec3.v_dot(q, sp.m_n) - sp.m_d - up.m_r <= 0)
            {
                return(1);
            }

            /* If it's not in front of the plane after DT seconds, the test passes. */

            Vec3.v_mad(q, q, up.m_v, dt);

            if (Vec3.v_dot(q, sp.m_n) - sp.m_d - up.m_r <= 0)
            {
                return(1);
            }

            /* Else, test fails. */

            return(0);
        }
Exemplo n.º 3
0
        public static float sol_test_lump(float dt,
                                          float[] T,
                                          s_ball up,
                                          s_file fp,
                                          s_lump lp,
                                          float[] o,
                                          float[] w)
        {
            float[] U = new float[3] {
                0.0f, 0.0f, 0.0f
            };

            float u, t = dt;
            int   i;

            /* Short circuit a non-solid lump. */

            if ((lp.m_fl & Solid.L_DETAIL) != 0)
            {
                return(t);
            }

            /* Test all verts */

            if (up.m_r > 0.0f)
            {
                for (i = 0; i < lp.m_vc; i++)
                {
                    s_vert vp = fp.m_vv[fp.m_iv[lp.m_v0 + i]];

                    if ((u = sol_test_vert(t, U, up, vp, o, w)) < t)
                    {
                        Vec3.v_cpy(T, U);
                        t = u;
                    }
                }
            }

            /* Test all edges */

            if (up.m_r > 0.0f)
            {
                for (i = 0; i < lp.m_ec; i++)
                {
                    s_edge ep = fp.m_ev[fp.m_iv[lp.m_e0 + i]];

                    if ((u = sol_test_edge(t, U, up, fp, ep, o, w)) < t)
                    {
                        Vec3.v_cpy(T, U);
                        t = u;
                    }
                }
            }

            /* Test all sides */

            for (i = 0; i < lp.m_sc; i++)
            {
                s_side sp = fp.m_sv[fp.m_iv[lp.m_s0 + i]];

                if ((u = sol_test_side(t, U, up, fp, lp, sp, o, w)) < t)
                {
                    Vec3.v_cpy(T, U);
                    t = u;
                }
            }
            return(t);
        }
Exemplo n.º 4
0
 public static void sol_load_side(IntPtr fin, s_side sp)
 {
     Binary.get_array(fin, sp.m_n, 3);
     Binary.get_float(fin, ref sp.m_d);
 }