diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -1,9 +1,13 @@ #include <algorithm> #include <cmath> +#include <memory> #include <vector> #include <raylib.h> +#include "ExampleSource.h" +#include "Source.h" + constexpr int AMOUNT {2000}; @@ -29,32 +33,27 @@ main(int argc, char* argv[]) camera.fovy = 45; camera.projection = CAMERA_PERSPECTIVE; SetCameraMode(camera, CAMERA_ORBITAL); - std::vector<Vector3> points; - points.reserve(AMOUNT); - for (int i = 0; i < AMOUNT; ++i) - points.push_back({ - GetRandomValue(-100, 100) * 0.05f, - GetRandomValue(-100, 100) * 0.05f, - GetRandomValue(-100, 100) * 0.05f}); + std::unique_ptr<Source> source = std::make_unique<ExampleSource>(); + auto killmails = source->all(); std::vector<Entry> projected; while (!WindowShouldClose()) { UpdateCamera(&camera); projected.clear(); - projected.reserve(points.size()); + projected.reserve(killmails.size()); const int height = GetScreenHeight(); const int width = GetScreenWidth(); - for (const auto& point : points) { - const auto vec2 = GetWorldToScreen(point, camera); + for (const auto& km : killmails) { + const auto vec2 = GetWorldToScreen(km.position, camera); const float d = std::sqrt( - std::pow(camera.position.x - point.x, 2) + - std::pow(camera.position.y - point.y, 2) + - std::pow(camera.position.z - point.z, 2)); + std::pow(camera.position.x - km.position.x, 2) + + std::pow(camera.position.y - km.position.y, 2) + + std::pow(camera.position.z - km.position.z, 2)); if (0 > vec2.x || width < vec2.x || 0 > vec2.y || height < vec2.y) continue; projected.push_back(Entry{ - vec2, GetWorldToScreen({point.x, 0, point.z}, camera), d + vec2, GetWorldToScreen({km.position.x, 0, km.position.z}, camera), d }); } std::sort(projected.begin(), projected.end(), [](Entry& a, Entry& b){ return a.depth > b.depth; }); |