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

Method draw

core/3d/Mesh.cpp:429–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429void Mesh::draw(Renderer* renderer,
430 float globalZOrder,
431 const Mat4& transform,
432 uint32_t flags,
433 unsigned int lightMask,
434 const Vec4& color,
435 bool forceDepthWrite,
436 bool wireframe)
437{
438 if (!isVisible())
439 return;
440
441 bool isTransparent = (_material->isTransparent() || color.w < 1.f);
442 float globalZ = isTransparent ? 0 : globalZOrder;
443 if (isTransparent)
444 flags |= Node::FLAGS_RENDER_AS_3D;
445
446 if (_instancing && _instanceCount > 0)
447 {
448 if (!_instanceTransformBuffer || _instanceTransformBufferDirty)
449 {
450 AX_SAFE_RELEASE(_instanceTransformBuffer);
451 AX_SAFE_DELETE_ARRAY(_instanceMatrixCache);
452
453 _instanceTransformBuffer = backend::DriverBase::getInstance()->newBuffer(
454 _instanceCount * 64, backend::BufferType::VERTEX, backend::BufferUsage::DYNAMIC);
455
456 _instanceMatrixCache = new float[_instanceCount * 16];
457 for (int i = 0; i < _instanceCount; i++)
458 {
459 _instanceMatrixCache[i * 16 + 0] = 1.0f;
460 _instanceMatrixCache[i * 16 + 1] = 0.0f;
461 _instanceMatrixCache[i * 16 + 2] = 0.0f;
462 _instanceMatrixCache[i * 16 + 3] = 0.0f;
463 _instanceMatrixCache[i * 16 + 4] = 0.0f;
464 _instanceMatrixCache[i * 16 + 5] = 1.0f;
465 _instanceMatrixCache[i * 16 + 6] = 0.0f;
466 _instanceMatrixCache[i * 16 + 7] = 0.0f;
467 _instanceMatrixCache[i * 16 + 8] = 0.0f;
468 _instanceMatrixCache[i * 16 + 9] = 0.0f;
469 _instanceMatrixCache[i * 16 + 10] = 1.0f;
470 _instanceMatrixCache[i * 16 + 11] = 0.0f;
471 _instanceMatrixCache[i * 16 + 12] = 0.0f;
472 _instanceMatrixCache[i * 16 + 13] = 0.0f;
473 _instanceMatrixCache[i * 16 + 14] = 0.0f;
474 _instanceMatrixCache[i * 16 + 15] = 1.0f;
475 }
476
477 // Fill the buffer with identity matrix.
478 _instanceTransformBuffer->updateData(_instanceMatrixCache, _instanceCount * 64);
479
480 _instanceTransformBufferDirty = false;
481 }
482
483 if (_instanceTransformDirty || _dynamicInstancing)
484 {
485 _instanceTransformDirty = false;
486

Callers

nothing calls this directly

Calls 15

getInstanceFunction · 0.85
getIndexFormatFunction · 0.85
newBufferMethod · 0.80
setUniformColorMethod · 0.80
getMatrixPaletteMethod · 0.80
setTransparentMethod · 0.80
setInstanceBufferMethod · 0.80
getVertexBufferFunction · 0.70
getIndexBufferFunction · 0.70

Tested by

no test coverage detected