MCPcopy Create free account
hub / github.com/axmolengine/axmol / draw

Method draw

core/navmesh/NavMeshDebugDraw.cpp:165–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void NavMeshDebugDraw::draw(Renderer* renderer)
166{
167 auto& transform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
168 auto beforeCommand = renderer->nextCallbackCommand();
169 auto afterCommand = renderer->nextCallbackCommand();
170
171 beforeCommand->init(0, Mat4::IDENTITY, Node::FLAGS_RENDER_AS_3D);
172 afterCommand->init(0, Mat4::IDENTITY, Node::FLAGS_RENDER_AS_3D);
173
174 beforeCommand->func = AX_CALLBACK_0(NavMeshDebugDraw::onBeforeVisitCmd, this);
175 afterCommand->func = AX_CALLBACK_0(NavMeshDebugDraw::onAfterVisitCmd, this);
176
177 beforeCommand->set3D(true);
178 beforeCommand->setTransparent(true);
179 afterCommand->set3D(true);
180 afterCommand->setTransparent(true);
181
182 _programState->setUniform(_locMVP, transform.m, sizeof(transform.m));
183
184 renderer->addCommand(beforeCommand);
185
186 if (!_vertexBuffer || _vertexBuffer->getSize() < _vertices.size() * sizeof(_vertices[0]))
187 {
188 _vertexBuffer = backend::DriverBase::getInstance()->newBuffer(
189 _vertices.size() * sizeof(_vertices[0]), backend::BufferType::VERTEX, backend::BufferUsage::STATIC);
190 _dirtyBuffer = true;
191 }
192
193 if (_dirtyBuffer)
194 {
195 _vertexBuffer->updateData(_vertices.data(), sizeof(_vertices[0]) * _vertices.size());
196 _dirtyBuffer = false;
197 }
198 int idx = 0;
199 if (_commands.size() < _primitiveList.size())
200 {
201 _commands.resize(_primitiveList.size());
202 }
203 for (auto&& iter : _primitiveList)
204 {
205 if (iter->type == backend::PrimitiveType::POINT)
206 continue;
207 if (iter->end - iter->start <= 0)
208 continue;
209
210 auto& command = _commands[idx];
211
212 initCustomCommand(command);
213 command.setBeforeCallback(AX_CALLBACK_0(NavMeshDebugDraw::onBeforeEachCommand, this, iter->depthMask));
214
215 command.setVertexBuffer(_vertexBuffer);
216 command.setPrimitiveType(iter->type);
217 command.setVertexDrawInfo(iter->start, iter->end - iter->start);
218
219 renderer->addCommand(&command);
220
221 AX_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, iter->end - iter->start);
222 idx++;

Callers 1

debugDrawMethod · 0.45

Calls 13

getInstanceFunction · 0.85
nextCallbackCommandMethod · 0.80
setTransparentMethod · 0.80
newBufferMethod · 0.80
initMethod · 0.45
setUniformMethod · 0.45
addCommandMethod · 0.45
getSizeMethod · 0.45
sizeMethod · 0.45
updateDataMethod · 0.45
dataMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected