Fix render for Draw3DCircle and Draw3DFilledCircle (lw)

Пользователь
Статус
Оффлайн
Регистрация
12 Июн 2020
Сообщения
465
Реакции[?]
102
Поинты[?]
3K
Draw3DCircle fix:

Код:
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;
        }
    }
}
Draw3DFilledCircle fix:

Код:
void render::Draw3DFilledCircle(const Vector& origin, float radius, Color color)
{
    auto prevScreenPos = ZERO;
    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)
    {
        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;
        }
    }
}
ОПЯТЬ Я :roflanEbalo:
 
?
Пользователь
Статус
Оффлайн
Регистрация
9 Дек 2020
Сообщения
141
Реакции[?]
36
Поинты[?]
0
Draw3DCircle fix:

Код:
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;
        }
    }
}
Draw3DFilledCircle fix:

Код:
void render::Draw3DFilledCircle(const Vector& origin, float radius, Color color)
{
    auto prevScreenPos = ZERO;
    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)
    {
        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;
        }
    }
}
ОПЯТЬ Я :roflanEbalo:
а тоесть посто заменить в рендере кругов static auto на auto для слабаков...
 
Сверху Снизу