Начинающий
- Статус
- Оффлайн
- Регистрация
- 2 Мар 2024
- Сообщения
- 260
- Реакции
- 4
внимание очень плохой ии код, был спашен из centrum
cursor ai solution:
void render_offscreen_arrow_enhanced(const Vector3& player_pos, const Vector3& local_pos, ImColor color, const std::string& player_name = "") {
if (!globals::visuals::oofarrows || !globals::instances::draw) return;
auto dimensions = globals::instances::visualengine.get_dimensions();
if (dimensions.x == 0 || dimensions.y == 0) return;
ImVec2 screen_center(dimensions.x / 2.f, dimensions.y / 2.f);
auto camerarotation = globals::instances::camera.getRot();
Vector3 camera_forward = camerarotation.getColumn(2);
camera_forward = camera_forward * -1.0f;
Vector3 dir_to_player = player_pos - local_pos;
float distance = vector_length(dir_to_player);
if (distance < 1.0f) return;
dir_to_player.x /= distance;
dir_to_player.y /= distance;
dir_to_player.z /= distance;
Vector3 camera_right = camerarotation.getColumn(0);
Vector3 camera_up = camerarotation.getColumn(1);
float forward_dot = dir_to_player.dot(camera_forward);
if (forward_dot > 0.5f) return;
float right_dot = dir_to_player.dot(camera_right);
float up_dot = dir_to_player.dot(camera_up);
ImVec2 screen_dir(right_dot, -up_dot);
float screen_dir_len = sqrtf(screen_dir.x * screen_dir.x + screen_dir.y * screen_dir.y);
if (screen_dir_len < 0.001f) return;
screen_dir.x /= screen_dir_len;
screen_dir.y /= screen_dir_len;
float radius = globals::visuals::oof_distance;
ImVec2 pos(
screen_center.x + screen_dir.x * radius,
screen_center.y + screen_dir.y * radius
);
float margin = 20.0f;
if (pos.x < margin) pos.x = margin;
if (pos.x > dimensions.x - margin) pos.x = dimensions.x - margin;
if (pos.y < margin) pos.y = margin;
if (pos.y > dimensions.y - margin) pos.y = dimensions.y - margin;
float angle = atan2f(screen_dir.y, screen_dir.x);
const float arrow_size = 10.0f;
const float arrow_angle = 0.6f;
ImVec2 point1(
pos.x - arrow_size * cosf(angle - arrow_angle),
pos.y - arrow_size * sinf(angle - arrow_angle)
);
ImVec2 point2(
pos.x - arrow_size * cosf(angle + arrow_angle),
pos.y - arrow_size * sinf(angle + arrow_angle)
);
ImColor arrow_color = ImColor(
(int)(globals::visuals::oofcolor[0] * 255),
(int)(globals::visuals::oofcolor[1] * 255),
(int)(globals::visuals::oofcolor[2] * 255),
(int)(globals::visuals::oofcolor[3] * 255)
);
if ((*globals::visuals::oof_overlay_flags)[1]) {
for (int i = -3; i <= 3; i++) {
for (int j = -3; j <= 3; j++) {
if (i == 0 && j == 0) continue;
ImColor glow_color = arrow_color;
glow_color.Value.w *= 0.3f;
ImVec2 glow_pos(pos.x + i, pos.y + j);
ImVec2 glow_point1(point1.x + i, point1.y + j);
ImVec2 glow_point2(point2.x + i, point2.y + j);
globals::instances::draw->AddTriangleFilled(glow_pos, glow_point1, glow_point2, glow_color);
}
}
}
globals::instances::draw->AddTriangleFilled(pos, point1, point2, arrow_color);
globals::instances::draw->AddTriangle(pos, point1, point2, ImColor(0, 0, 0, 255), 0.5f);
if (globals::visuals::ooftype == 0 && !player_name.empty()) {
char distance_text[32];
sprintf_s(distance_text, "%.0fm", distance);
ImVec2 text_pos(pos.x - 15, pos.y + 15);
draw_text_with_shadow_enhanced(10.0f, text_pos, arrow_color, distance_text);
}
}
Vector2 screen_check = roblox::worldtoscreen(player.position);
bool is_onscreen = screen_check.x > 0 && screen_check.x < screen_dimensions.x &&
screen_check.y > 0 && screen_check.y < screen_dimensions.y;
if (globals::visuals::oofarrows && !is_onscreen) {
Vector3 local_pos = globals::instances::camera.getPos();
ImColor arrow_color = ImColor(
(int)(globals::visuals::oofcolor[0] * 255),
(int)(globals::visuals::oofcolor[1] * 255),
(int)(globals::visuals::oofcolor[2] * 255),
(int)(globals::visuals::oofcolor[3] * 255)
);
render_offscreen_arrow_enhanced(player.position, local_pos, arrow_color, player.name);
}