Skip to content
Snippets Groups Projects
Commit 9ae58fad authored by Jonathan Kunstwald's avatar Jonathan Kunstwald
Browse files

Replace stl execution policies with pstl equivalents in Swarm

parent ba74b0fa
No related branches found
No related tags found
No related merge requests found
#include "Swarm.hh"
#include <pstl/algorithm>
#include <pstl/execution>
#include "../util/Misc.hh"
glm::ivec3 flock::Swarm::getVoxelIndex(const glm::vec3& pos) const
......@@ -159,7 +162,7 @@ void flock::Swarm::tick(float dt)
mVoxelCache.clear();
auto view = mRegistry->view<TransformC, SwarmlingC>();
std::for_each(std::execution::seq, view.begin(), view.end(), [&](auto const ent) {
std::for_each(pstl::execution::seq, view.begin(), view.end(), [&](auto const ent) {
auto& swarmling = mRegistry->get<SwarmlingC>(ent);
mVoxelCache[getVoxelIndex(swarmling.position)].emplace_back(
VoxelCacheSwarmling{ent, swarmling.position, swarmling.velocity});
......@@ -172,7 +175,7 @@ void flock::Swarm::tick(float dt)
// NOTE: std::execution::parallel_unsequenced_policy
// Only call thread safe methods here
auto view = mRegistry->view<TransformC, SwarmlingC>();
std::for_each(std::execution::par_unseq, view.begin(), view.end(),
std::for_each(pstl::execution::par_unseq, view.begin(), view.end(),
[&](auto const ent) { updateSwarmling(ent, mRegistry->get<SwarmlingC>(ent)); });
}
......@@ -182,7 +185,7 @@ void flock::Swarm::tick(float dt)
// NOTE: std::execution::parallel_unsequenced_policy
// Only call thread safe methods here
auto view = mRegistry->view<TransformC, SwarmlingC>();
std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&](auto const ent) {
std::for_each(pstl::execution::par_unseq, view.begin(), view.end(), [&](auto const ent) {
auto& swarmling = mRegistry->get<SwarmlingC>(ent);
auto& transform = mRegistry->get<TransformC>(ent);
swarmling.velocity = clampVectorLength(swarmling.velocity + swarmling.acceleration * dt, mMaxVelocity);
......
#pragma once
#include <atomic>
#include <execution>
#include <iostream>
#include <random>
#include <unordered_map>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment