Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
NavMeshDebugDraw.cpp
Go to the documentation of this file.
1// With huge thanks to:
2// Mikko Mononen http://groups.google.com/group/recastnavigation
3// And thanks to Daniel Buckmaster, 2011 for his
4// T3D 1.1 implementation of Recast's DebugUtils.
5
6
7
9
14
15namespace Divide::AI::Navigation {
16
18 : _context(context)
19{
20}
21
23{
25 {
26 DebugBreak();
27 }
28}
29
30void NavMeshDebugDraw::paused(const bool state) noexcept {
31 _paused = state;
32}
33
34void NavMeshDebugDraw::depthMask(const bool state) noexcept {
35 _depthMask = state;
36}
37
39 if (!_primitive) {
40 _dirty = true;
41 _primitive = _context.newIMP("NavMesh Debug Draw");
42
43 PipelineDescriptor pipeDesc{};
45 pipeDesc._stateBlock._depthTestEnabled = _depthMask;
46 pipeDesc._stateBlock._depthWriteEnabled = false;
47 pipeDesc._shaderProgramHandle = _context.imShaders()->imShaderNoTexture();
49 }
50
51 assert(_primitive != nullptr);
52
53 if (_dirty) {
54 _primitive->beginBatch(true, 1024, 1);
55 }
56}
57
59 if (!_dirty) {
60 return;
61 }
62
63 if (_primitive) {
65 }
66
67 _dirty = false;
68}
69
70void NavMeshDebugDraw::begin(const duDebugDrawPrimitives prim, F32 size) {
71 DIVIDE_UNUSED( size );
72
73 if (!_dirty || !_primitive) {
74 return;
75 }
76
77 switch (prim) {
78 case DU_DRAW_QUADS:
80 break;
81 case DU_DRAW_TRIS:
83 break;
84 case DU_DRAW_POINTS:
86 break;
87 case DU_DRAW_LINES:
89 break;
90 }
91
94}
95
96void NavMeshDebugDraw::vertex(const F32 x, const F32 y, const F32 z,
97 U32 colour) {
98 if (!_dirty || !_primitive) {
99 return;
100 }
101 if (_overrideColour) {
102 colour = _colour;
103 }
104
105 UColour4 colourVec;
106 rcCol(colour, colourVec.r, colourVec.g, colourVec.b, colourVec.a);
107 colourVec.a = 64;
108
110 _primitive->vertex(x, y, z);
111}
112
114 if (_dirty && _primitive) {
115 _primitive->end();
116 }
117}
118
120{
121 _primitive->getCommandBuffer(bufferInOut, memCmdInOut);
122}
123
124void NavMeshDebugDraw::overrideColour(const U32 col) noexcept {
125 _overrideColour = true;
126 _colour = col;
127}
128
129} // namespace Divide::AI::Navigation
#define DIVIDE_UNUSED(X)
#define DIVIDE_UNEXPECTED_CALL()
void depthMask(bool state) noexcept override
NavMeshDebugDraw(GFXDevice &context) noexcept
void toCommandBuffer(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) const
void begin(duDebugDrawPrimitives prim, F32 size=1.0f) override
void vertex(F32 x, F32 y, F32 z, U32 colour) override
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
IMPrimitive * newIMP(std::string_view name)
Create and return a new immediate mode emulation primitive.
Definition: GFXDevice.cpp:3055
bool destroyIMP(IMPrimitive *&primitive)
Definition: GFXDevice.cpp:3061
void getCommandBuffer(GFX::CommandBuffer &commandBufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void beginBatch(bool reserveBuffers, U32 vertexCount, U32 attributeCount)
Definition: IMPrimitive.cpp:96
void vertex(F32 x, F32 y, F32 z)
void setPipelineDescriptor(const PipelineDescriptor &descriptor)
void attribute4f(U32 attribLocation, F32 x, F32 y, F32 z, F32 w)
void begin(PrimitiveTopology type)
void endBatch() noexcept
void rcCol(U32 col, U8 &r, U8 &g, U8 &b, U8 &a) noexcept
Convert a Recast colour integer to RGBA components.
FColour4 ToFloatColour(const UColour4 &byteColour) noexcept
Definition: MathHelper.cpp:268
vec4< F32 > FColour4
Definition: MathHelper.h:73
bool DebugBreak(const bool condition) noexcept
uint32_t U32
constexpr auto to_base(const Type value) -> Type
RenderStateBlock _stateBlock
Definition: Pipeline.h:46