-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Просто замените свой код на этот.
и фикс Filled
credits: Vortyk
C++:
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;
}
}
}
C++:
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;
}
}
}
Последнее редактирование: