载入中...
搜索中...
未找到
AgentInstanceRenderer.cpp
浏览该文件的文档.
2
3#include <glm/gtc/matrix_transform.hpp>
4
5namespace eve::gpuagents {
6
7int AgentInstanceRenderer::sync(const std::vector<AgentState>& states) {
8 matrices_.clear();
9 customAttrs_.clear();
10 ages_.clear();
11 matrices_.reserve(states.size());
12 customAttrs_.reserve(states.size());
13 ages_.reserve(states.size());
14
15 for (const auto& s : states) {
16 if (s.alive == 0) continue;
17 const glm::mat4 rot = glm::mat4_cast(s.rotation);
18 const glm::mat4 tr = glm::translate(glm::mat4(1.f), s.position);
19 matrices_.push_back(tr * rot);
20 customAttrs_.emplace_back(s.customData[0], s.customData[1], s.customData[2], s.customData[3]);
21 ages_.push_back(s.age);
22 }
23 instanceCount_ = static_cast<int>(matrices_.size());
24 return instanceCount_;
25}
26
27} // namespace eve::gpuagents
const std::string & s
float tr
int sync(const std::vector< AgentState > &states)
Rebuild instance buffers from simulation states.