Подведи собственные итоги года совместно с YOUGAME и забери ценные призы! Перейти

Вопрос Проблема с кругами в LW

Код:
Expand Collapse Copy
void render::circle_filled(int x, int y, int points, int radius, Color color)
{
    if (!m_surface())
        return;

    color.SetAlpha(static_cast<int>(color.a() * alpha_factor));

    static bool once = true;

    static std::vector<float> temppointsx;
    static std::vector<float> temppointsy;

    if (once)
    {
        float step = (float)DirectX::XM_PI * 2.0f / points;
        for (float a = 0; a < (DirectX::XM_PI * 2.0f); a += step) //-V1034
        {
            temppointsx.push_back(cosf(a));
            temppointsy.push_back(sinf(a));
        }
        once = false;
    }

    std::vector<int> pointsx;
    std::vector<int> pointsy;
    std::vector<Vertex_t> vertices;

    for (int i = 0; i < temppointsx.size(); i++)
    {
        float eeks = radius * temppointsx[i] + x;
        float why = radius * temppointsy[i] + y;
        pointsx.push_back(eeks);
        pointsy.push_back(why);

        vertices.emplace_back(Vertex_t(Vector2D(eeks, why)));
    }

    m_surface()->DrawSetColor(color);
    m_surface()->DrawTexturedPolygon(points, vertices.data());
}
 
Код:
Expand Collapse Copy
void render::circle_filled(int x, int y, int points, int radius, Color color)
{
    if (!m_surface())
        return;

    color.SetAlpha(static_cast<int>(color.a() * alpha_factor));

    static bool once = true;

    static std::vector<float> temppointsx;
    static std::vector<float> temppointsy;

    if (once)
    {
        float step = (float)DirectX::XM_PI * 2.0f / points;
        for (float a = 0; a < (DirectX::XM_PI * 2.0f); a += step) //-V1034
        {
            temppointsx.push_back(cosf(a));
            temppointsy.push_back(sinf(a));
        }
        once = false;
    }

    std::vector<int> pointsx;
    std::vector<int> pointsy;
    std::vector<Vertex_t> vertices;

    for (int i = 0; i < temppointsx.size(); i++)
    {
        float eeks = radius * temppointsx[i] + x;
        float why = radius * temppointsy[i] + y;
        pointsx.push_back(eeks);
        pointsy.push_back(why);

        vertices.emplace_back(Vertex_t(Vector2D(eeks, why)));
    }

    m_surface()->DrawSetColor(color);
    m_surface()->DrawTexturedPolygon(points, vertices.data());
}
Во-первых, ты скинул код не 3д кругов, во-вторых, замени переменную auto на static в коде 3д кругов.
 
Код:
Expand Collapse Copy
void render::Draw3DCircle(const Vector& origin, float radius, Color color)
{
    static auto prevScreenPos = ZERO; //-V656
    static auto step = M_PI * 2.0f / 72.0f;

    auto screenPos = ZERO;

    for (auto rotation = 0.0f; rotation <= M_PI * 2.0f; rotation += step) //-V1034
    {
        Vector pos(radius * cos(rotation) + origin.x, radius * sin(rotation) + origin.y, origin.z);

        Ray_t ray;
        trace_t trace;
        CTraceFilterWorldOnly filter;

        ray.Init(origin, pos);
        m_trace()->TraceRay(ray, MASK_SHOT_BRUSHONLY, &filter, &trace);

        if (math::world_to_screen(trace.endpos, screenPos))
        {
            if (!prevScreenPos.IsZero())
                line(prevScreenPos.x, prevScreenPos.y, screenPos.x, screenPos.y, color);

            prevScreenPos = screenPos;
        }
    }
}
Код:
Expand Collapse Copy
void render::Draw3DFilledCircle(const Vector& origin, float radius, Color color)
{
    static auto prevScreenPos = ZERO; //-V656
    static auto step = M_PI * 2.0f / 72.0f;

    auto screenPos = ZERO;
    auto screen = ZERO;

    if (!math::world_to_screen(origin, screen))
        return;

    for (auto rotation = 0.0f; rotation <= M_PI * 2.0f; rotation += step) //-V1034
    {
        Vector pos(radius * cos(rotation) + origin.x, radius * sin(rotation) + origin.y, origin.z);

        if (math::world_to_screen(pos, screenPos))
        {
            if (!prevScreenPos.IsZero() && prevScreenPos.IsValid() && screenPos.IsValid() && prevScreenPos != screenPos)
            {
                line(prevScreenPos.x, prevScreenPos.y, screenPos.x, screenPos.y, color);
                triangle(Vector2D(screen.x, screen.y), Vector2D(screenPos.x, screenPos.y), Vector2D(prevScreenPos.x, prevScreenPos.y), Color(color.r(), color.g(), color.b(), color.a() / 2));
            }

            prevScreenPos = screenPos;
        }
    }
}
 
я
Код:
Expand Collapse Copy
void render::Draw3DCircle(const Vector& origin, float radius, Color color)
{
    static auto prevScreenPos = ZERO; //-V656
    static auto step = M_PI * 2.0f / 72.0f;

    auto screenPos = ZERO;

    for (auto rotation = 0.0f; rotation <= M_PI * 2.0f; rotation += step) //-V1034
    {
        Vector pos(radius * cos(rotation) + origin.x, radius * sin(rotation) + origin.y, origin.z);

        Ray_t ray;
        trace_t trace;
        CTraceFilterWorldOnly filter;

        ray.Init(origin, pos);
        m_trace()->TraceRay(ray, MASK_SHOT_BRUSHONLY, &filter, &trace);

        if (math::world_to_screen(trace.endpos, screenPos))
        {
            if (!prevScreenPos.IsZero())
                line(prevScreenPos.x, prevScreenPos.y, screenPos.x, screenPos.y, color);

            prevScreenPos = screenPos;
        }
    }
}
Код:
Expand Collapse Copy
void render::Draw3DFilledCircle(const Vector& origin, float radius, Color color)
{
    static auto prevScreenPos = ZERO; //-V656
    static auto step = M_PI * 2.0f / 72.0f;

    auto screenPos = ZERO;
    auto screen = ZERO;

    if (!math::world_to_screen(origin, screen))
        return;

    for (auto rotation = 0.0f; rotation <= M_PI * 2.0f; rotation += step) //-V1034
    {
        Vector pos(radius * cos(rotation) + origin.x, radius * sin(rotation) + origin.y, origin.z);

        if (math::world_to_screen(pos, screenPos))
        {
            if (!prevScreenPos.IsZero() && prevScreenPos.IsValid() && screenPos.IsValid() && prevScreenPos != screenPos)
            {
                line(prevScreenPos.x, prevScreenPos.y, screenPos.x, screenPos.y, color);
                triangle(Vector2D(screen.x, screen.y), Vector2D(screenPos.x, screenPos.y), Vector2D(prevScreenPos.x, prevScreenPos.y), Color(color.r(), color.g(), color.b(), color.a() / 2));
            }

            prevScreenPos = screenPos;
        }
    }
}
я уже ответил, как решить проблему.
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
В лв проблема с отрисовкой кругов (появляются треугольники) Как это пофиксить? @t4pp3r я знаю, что ты это сделал.
Открой отрисовку 3д кругов и у первых 2 строк убери static
C++:
Expand Collapse Copy
void render::Draw3DCircle(const Vector& origin, float radius, Color color)
{
    auto prevScreenPos = ZERO;
    auto step = M_PI * 2.0f / 72.0f;

    auto screenPos = ZERO;

    for (auto rotation = 0.0f; rotation <= M_PI * 2.0f; rotation += step)
    {
        Vector pos(radius * cos(rotation) + origin.x, radius * sin(rotation) + origin.y, origin.z);

        Ray_t ray;
        trace_t trace;
        CTraceFilterWorldOnly filter;

        ray.Init(origin, pos);
        m_trace()->TraceRay(ray, MASK_SHOT_BRUSHONLY, &filter, &trace);

        if (math::world_to_screen(trace.endpos, screenPos))
        {
            if (!prevScreenPos.IsZero())
                line(prevScreenPos.x, prevScreenPos.y, screenPos.x, screenPos.y, color);

            prevScreenPos = screenPos;
        }
    }
}
 
Открой отрисовку 3д кругов и у первых 2 строк убери static
C++:
Expand Collapse Copy
void render::Draw3DCircle(const Vector& origin, float radius, Color color)
{
    auto prevScreenPos = ZERO;
    auto step = M_PI * 2.0f / 72.0f;

    auto screenPos = ZERO;

    for (auto rotation = 0.0f; rotation <= M_PI * 2.0f; rotation += step)
    {
        Vector pos(radius * cos(rotation) + origin.x, radius * sin(rotation) + origin.y, origin.z);

        Ray_t ray;
        trace_t trace;
        CTraceFilterWorldOnly filter;

        ray.Init(origin, pos);
        m_trace()->TraceRay(ray, MASK_SHOT_BRUSHONLY, &filter, &trace);

        if (math::world_to_screen(trace.endpos, screenPos))
        {
            if (!prevScreenPos.IsZero())
                line(prevScreenPos.x, prevScreenPos.y, screenPos.x, screenPos.y, color);

            prevScreenPos = screenPos;
        }
    }
}
а чё, у тебя степ как-то изменяется??
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
В лв проблема с отрисовкой кругов (появляются треугольники) Как это пофиксить? @t4pp3r я знаю, что ты это сделал.
1609064136097.png
 
Назад
Сверху Снизу