pre-calculate morton codes in threadpool

This commit is contained in:
2026-03-06 02:42:30 +01:00
parent c060cfd35d
commit 6ab935c9be
5 changed files with 33 additions and 15 deletions

View File

@ -91,4 +91,9 @@ constexpr Color BLOCK_COLOR = DARKBLUE;
constexpr Color TARGET_BLOCK_COLOR = RED;
constexpr Color WALL_COLOR = BLACK;
// Threadpool
static constexpr int SMALL_TASK_BLOCK_SIZE = 256; // Weirdly larger blocks decrease performance...
static constexpr int LARGE_TASK_BLOCK_SIZE = 256;
#endif

View File

@ -22,9 +22,6 @@ public:
};
public:
static constexpr int SMALL_TASK_BLOCK_SIZE = 256;
static constexpr int LARGE_TASK_BLOCK_SIZE = 256;
octree tree;
// This is the main ownership of all the states/masses/springs.

View File

@ -2,6 +2,7 @@
#define OCTREE_HPP_
#include "util.hpp"
#include "config.hpp"
#include <array>
#include <vector>
@ -98,7 +99,9 @@ public:
[[nodiscard]] auto root() const -> const node&;
// Morton/linear octree implementation
static auto build_octree_morton(octree& t, const std::vector<Vector3>& positions) -> void;
static auto build_octree_morton(octree& t,
const std::vector<Vector3>& positions,
const std::optional<BS::thread_pool<>*>& thread_pool) -> void;
[[nodiscard]] auto calculate_force_morton(int node_idx, const Vector3& pos, int self_id) const -> Vector3;
};