载入中...
搜索中...
未找到
GpuAgentSimulation.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include "common/Result.h"
9
10#include <cstdint>
11#include <functional>
12#include <memory>
13#include <vector>
14
15namespace eve::gpuagents {
16
24public:
26 GpuAgentSimulation() = default;
27
33 [[nodiscard("check simulation configure")]] Result<void> configure(const EffectProfile& profile);
34
39 [[nodiscard("check solver bind")]] Result<void> setSolver(std::unique_ptr<IAgentSolver> solver);
40
46 [[nodiscard("check initialize")]] Result<void> initialize(int count,
47 const std::function<AgentState(int)>& spawnFn);
48
50 void reset();
51
58 [[nodiscard("check simulation step")]] Result<void> step(float dt, const EnvironmentSnapshot& env);
59
61 int capacity() const { return capacity_; }
63 int aliveCount() const;
65 const std::vector<AgentState>& states() const { return buffers_[front_]; }
67 std::vector<AgentState>& states() { return buffers_[front_]; }
69 const EffectProfile& profile() const { return profile_; }
71 bool isConfigured() const { return configured_; }
73 float simTime() const { return simTime_; }
75 std::uint64_t stepCount() const { return stepCount_; }
76
77private:
78 EffectProfile profile_{};
79 std::unique_ptr<IAgentSolver> solver_;
80 std::vector<AgentState> buffers_[2]{};
81 int front_ = 0;
82 int capacity_ = 0;
83 float accumulator_ = 0.f;
84 float simTime_ = 0.f;
85 std::uint64_t stepCount_ = 0;
86 bool configured_ = false;
87
88 [[nodiscard]] Result<void> makeDefaultSolver();
89};
90
91} // namespace eve::gpuagents
#define EVENGINE_API_DOMAINS
Definition Export.h:110
Move-only, checked operation results for the common layer.
std::uint32_t count
float step
Definition TreeMesh.cpp:314
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Fixed-step, double-buffered agent simulation owner.
const EffectProfile & profile() const
Bound profile.
GpuAgentSimulation()=default
Gpu agent simulation.
float simTime() const
Accumulated simulation time in seconds.
int capacity() const
Active agent capacity.
bool isConfigured() const
True after successful configure.
const std::vector< AgentState > & states() const
Current front-buffer states (read-only).
std::vector< AgentState > & states()
Mutable front buffer (editor preview / tests).
std::uint64_t stepCount() const
Completed fixed substeps.
Standardized per-agent simulation output shared by all effect kinds.
Definition AgentState.h:12
Type-erased profile bundle owned by an EffectBackend.
Read-only environment semantics prepared by GpuAgentWorld each tick.