lundi 8 juillet 2019

drawing quarter circle ends up being smaller

i have a function that is ment to be able to draw full, half, quarter circles.

everything works fine to draw full circles and half circles.

But as soon as i try to draw a quarter circle it gets messed up and is even smaller then a quarter.

void Renderer::draw_filled_circle(const RenderListPtr& render_list, const Vec2& position, float radius, CircleType type, Color color, float rotate){
    float pi;
    if (type == FULL) pi = D3DX_PI;         // Full circle
    if (type == HALF) pi = D3DX_PI / 2;     // 1/2 circle
    if (type == QUARTER) pi = D3DX_PI / 4;  // 1/4 circle

    const int segments = 24;
    float angle = rotate * D3DX_PI / 180;
    Vertex v[segments + 1];

    for (int i = 0; i < segments +1; i++){
        float theta = 2.f * pi * static_cast<float>(i) / static_cast<float>(segments);
        v[i] = Vertex{
            position.x + radius * std::cos(theta),
            position.y + radius * std::sin(theta),
            color
        };
    }

    add_vertices(render_list, v, D3DPT_TRIANGLEFAN);
}

Aucun commentaire:

Enregistrer un commentaire