RavEngine
Loading...
Searching...
No Matches
NavMeshComponent.hpp
1#pragma once
2#include "Queryable.hpp"
3#include "IDebugRenderable.hpp"
4#include "Vector.hpp"
5
6class dtNavMesh;
8
9namespace RavEngine{
10
11 class NavMeshComponent : public IDebugRenderable, public Queryable<NavMeshComponent,IDebugRenderable>{
12 private:
13 dtNavMesh* navMesh = nullptr;
14 dtNavMeshQuery* navMeshQuery = nullptr;
15 unsigned char* navData = nullptr;
16 Bounds bounds;
17 mutable SpinLock mtx;
18
19 public:
20 using Queryable<NavMeshComponent,IDebugRenderable>::GetQueryTypes;
21 struct Options{
22 float cellSize = 0.3f;
23 float cellHeight = 0.2f;
24 float maxEdgeLen = 12.f;
25 float maxSimplificationError = 1.3f;
26 float maxVertsPerPoly = 6.f;
27 float detailSampleDist = 6.f;
28 float detailSampleMaxError = 1.f;
29
30 struct Agent{
31 float height = 2.0f;
32 float radius = 0.6f;
33 float maxClimb = 0.9f;
34 float maxSlope = 45.f;
35 } agent;
36
37 float regionMinDimension = 8.f;
38 float regionMergeDimension = 20.f;
39
40 enum PartitionMethod{
41 Watershed, // best but slowest
42 Monotone, // worst but fastest
43 Layer // compromise, good for tiled w/ small-medium tiles
44 } partitionMethod = Watershed;
45
46 };
47
51 NavMeshComponent(Ref<MeshAsset> mesh, Options opt);
52
53 void UpdateNavMesh(Ref<MeshAsset> mesh, Options opt);
54
61 RavEngine::Vector<vector3> CalculatePath(const vector3& start, const vector3& end, uint16_t maxPoints = std::numeric_limits<uint16_t>::max());
62
63 void DebugDraw(class RavEngine::DebugDrawer& dbg, const struct RavEngine::Transform& tr) const override;
64
65 virtual ~NavMeshComponent();
66 };
67}
Definition DebugDrawer.hpp:11
Definition NavMeshComponent.hpp:11
RavEngine::Vector< vector3 > CalculatePath(const vector3 &start, const vector3 &end, uint16_t maxPoints=std::numeric_limits< uint16_t >::max())
Definition NavMeshComponent.cpp:260
Definition SpinLock.hpp:9
Definition DetourNavMeshQuery.h:166
Definition DetourNavMesh.h:339
Definition concurrentqueue.h:747
Definition Animation.hpp:6
Definition mathtypes.hpp:122
Definition IDebugRenderable.hpp:8
Definition NavMeshComponent.hpp:30
Definition NavMeshComponent.hpp:21
Definition Queryable.hpp:21
Definition Transform.hpp:20
Definition qualifier.hpp:35