载入中...
搜索中...
未找到
ObstacleField.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include <glm/glm.hpp>
5
6#include <vector>
7
8namespace eve::gpuagents {
9
12 float distance = 1e6f;
13 glm::vec3 gradient{0.f, 1.f, 0.f};
14};
15
18 glm::vec3 center{0.f};
19 float radius = 1.f;
20};
21
29public:
30 glm::vec3 origin{0.f};
31 float cellSize = 1.f;
32 glm::ivec3 dims{0};
33 std::vector<float> distances;
34 std::vector<DynamicObstacleSource> dynamicSources;
35
37 bool hasStaticGrid() const { return dims.x > 0 && dims.y > 0 && dims.z > 0; }
38
40 void clear();
41
49 void bakeEmpty(const glm::vec3& originMin, const glm::ivec3& dims, float cellSize, float fillDistance = 10.f);
50
56 void carveSphere(const glm::vec3& center, float radius);
57
63 void carveBox(const glm::vec3& minCorner, const glm::vec3& maxCorner);
64
66 void setDynamicSources(std::vector<DynamicObstacleSource> sources);
67
69 ObstacleSample sample(const glm::vec3& p) const;
70
78 void resolve(glm::vec3& position, glm::vec3& velocity, float agentRadius, float predictTime) const;
79
80private:
81 float sampleStatic(const glm::vec3& p) const;
82 glm::vec3 gradientStatic(const glm::vec3& p) const;
83 ObstacleSample sampleDynamic(const glm::vec3& p) const;
84};
85
86} // namespace eve::gpuagents
glm::vec4 p[6]
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::array< float, 3 > position
float radius
V3 origin
Definition RoadBake.cpp:138
Unified static + dynamic obstacle distance field.
bool hasStaticGrid() const
True when a static grid is allocated.
std::vector< float > distances
std::vector< DynamicObstacleSource > dynamicSources
Dynamic spherical obstacle source (e.g. moving prop / wake body).
One SDF sample with outward gradient.