help me with raycast, my player collision box is 0.5f, 1.8f, 1.0f (length, height, width), here how i init it in render:glm::vec3 dimensions(1.0f, 1.8f, 0.5f); // length (front-to-back), height, width
float vertices[] = {
    // Front face (facing positive X)
     dimensions.x / 2, 0.0f,           -dimensions.z / 2,  // bottom-right
     dimensions.x / 2, 0.0f,            dimensions.z / 2,  // bottom-left
     dimensions.x / 2, dimensions.y,    dimensions.z / 2,  // top-left
     dimensions.x / 2, dimensions.y,   -dimensions.z / 2,  // top-right
     // Back face (facing negative X)
     -dimensions.x / 2, 0.0f,           -dimensions.z / 2,  // bottom-left
     -dimensions.x / 2, 0.0f,            dimensions.z / 2,  // bottom-right
     -dimensions.x / 2, dimensions.y,    dimensions.z / 2,  // top-right
     -dimensions.x / 2, dimensions.y,   -dimensions.z / 2,  // top-left
};
unsigned int indices[] = {
    // Front face
    0, 1, 2,
    2, 3, 0,
    // Right face (facing positive Z)
    1, 5, 6,
    6, 2, 1,
    // Back face
    5, 4, 7,
    7, 6, 5,
    // Left face (facing negative Z)
    4, 0, 3,
    3, 7, 4,
    // Top face
    3, 2, 6,
    6, 7, 3,
    // Bottom face
    4, 5, 1,
    1, 0, 4
};
glGenVertexArrays(1, &m_VAO);
glGenBuffers(1, &m_VBO);
glGenBuffers(1, &m_EBO);,  sometimes raycast is incorrect, how can i fix this? 
RaycastResult World::PlayerBoxRaycast(const glm::vec3& start, const glm::vec3& direction, float maxDistance, const glm::vec3& playerDimensions, const glm::quat& playerRotation)
{
    glm::vec3 end = start + direction * maxDistance;
    RaycastResult result;
    result.hit = false;
    result.distance = maxDistance;
    result.triangleIndex = -1;
    float src[3] = { start.x, start.y, start.z };
    float dst[3] = { end.x, end.y, end.z };
    float btmin, btmax;
    if (!isectSegAABB(src, dst, m_StaticWorldMeshBMin, m_StaticWorldMeshBMax, btmin, btmax)) {
        std::cout << "Ray does not intersect world AABB" << std::endl;
        return result;
    }
    float p[2], q[2];
    p[0] = src[0] + (dst[0] - src[0]) * btmin;
    p[1] = src[2] + (dst[2] - src[2]) * btmin;
    q[0] = src[0] + (dst[0] - src[0]) * btmax;
    q[1] = src[2] + (dst[2] - src[2]) * btmax;
    int cid[512];
    const int ncid = rcChunkyTriMesh::rcGetChunksOverlappingSegment(m_StaticWorldChunkyMesh, p, q, cid, 512);
    if (!ncid) {
        std::cout << "No chunks overlapping segment" << std::endl;
        return result;
    }
    float tmin = 1.0f;
    const float* verts = m_StaticWorldMesh.getVerts();
    for (int i = 0; i < ncid; ++i)
    {
        const rcChunkyTriMeshNode& node = m_StaticWorldChunkyMesh->nodes[cid[i]];
        const int* tris = &m_StaticWorldChunkyMesh->tris[node.i * 3];
        const int ntris = node.n;
        for (int j = 0; j < ntris * 3; j += 3)
        {
            float t = 1;
            if (intersectSegmentTriangle(src, dst,
                &verts[tris[j] * 3],
                &verts[tris[j + 1] * 3],
                &verts[tris[j + 2] * 3], t))
            {
                if (t < tmin)
                {
                    tmin = t;
                    result.hit = true;
                    result.distance = tmin * maxDistance;
                    result.triangleIndex = node.i + j / 3;
                }
            }
        }
    }
    if (result.hit)
    {
        result.hitPoint = start + tmin * (end - start);
        //std::cout << "Hit at distance: " << result.distance << ", Triangle index: " << result.triangleIndex << std::endl;
    }
    else
    {
        //std::cout << "No hit detected" << std::endl;
    }
    return result;
}
static bool isectSegAABB(const float* sp, const float* sq,
    const float* amin, const float* amax,
    float& tmin, float& tmax)
{
    static const float EPS = 1e-6f;
    float d[3];
    d[0] = sq[0] - sp[0];
    d[1] = sq[1] - sp[1];
    d[2] = sq[2] - sp[2];
    tmin = 0.0;
    tmax = 1.0f;
    for (int i = 0; i < 3; i++)
    {
        if (fabsf(d[i]) < EPS)
        {
            if (sp[i] < amin[i] || sp[i] > amax[i])
                return false;
        }
        else
        {
            const float ood = 1.0f / d[i];
            float t1 = (amin[i] - sp[i]) * ood;
            float t2 = (amax[i] - sp[i]) * ood;
            if (t1 > t2) { float tmp = t1; t1 = t2; t2 = tmp; }
            if (t1 > tmin) tmin = t1;
            if (t2 < tmax) tmax = t2;
            if (tmin > tmax) return false;
        }
    }
    return true;
}

static bool intersectSegmentTriangle(const float* sp, const float* sq,
    const float* a, const float* b, const float* c,
    float& t)
{
    float v, w;
    float ab[3], ac[3], qp[3], ap[3], norm[3], e[3];
    rcVsub(ab, b, a);
    rcVsub(ac, c, a);
    rcVsub(qp, sp, sq);
    // Compute triangle normal. Can be precalculated or cached if
    // intersecting multiple segments against the same triangle
    rcVcross(norm, ab, ac);
    // Compute denominator d. If d <= 0, segment is parallel to or points
    // away from triangle, so exit early
    float d = rcVdot(qp, norm);
    if (d <= 0.0f) return false;
    // Compute intersection t value of pq with plane of triangle. A ray
    // intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay
    // dividing by d until intersection has been found to pierce triangle
    rcVsub(ap, sp, a);
    t = rcVdot(ap, norm);
    if (t < 0.0f) return false;
    if (t > d) return false; // For segment; exclude this code line for a ray test
    // Compute barycentric coordinate components and test if within bounds
    rcVcross(e, qp, ap);
    v = rcVdot(ac, e);
    if (v < 0.0f || v > d) return false;
    w = -rcVdot(ab, e);
    if (w < 0.0f || v + w > d) return false;
    // Segment/ray intersects triangle. Perform delayed division
    t /= d;
    return true;
}