diff options
author | Aki <please@ignore.pl> | 2022-05-03 16:12:52 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-05-03 16:12:52 +0200 |
commit | c610c4b94eda867a3f0b083038502dccb8116170 (patch) | |
tree | dda7499b3ac3c9f29bf70ecf927c1031758f53c1 /main.cpp | |
parent | 8e85b084e6ec73cd99899ad276891eb40944b909 (diff) | |
download | derelict-c610c4b94eda867a3f0b083038502dccb8116170.zip derelict-c610c4b94eda867a3f0b083038502dccb8116170.tar.gz derelict-c610c4b94eda867a3f0b083038502dccb8116170.tar.bz2 |
Added source and related stubs
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; }); |