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

Method draw

core/3d/MeshRenderer.cpp:859–900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

857}
858
859void MeshRenderer::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
860{
861#if AX_USE_CULLING
862 // TODO new-renderer: interface isVisibleInFrustum removal
863 // camera clipping
864// if(_children.empty() && Camera::getVisitingCamera() &&
865// !Camera::getVisitingCamera()->isVisibleInFrustum(&getAABB()))
866// return;
867#endif
868
869 if (_skeleton)
870 _skeleton->updateBoneMatrix();
871
872 Color4F color(getDisplayedColor());
873 color.a = getDisplayedOpacity() / 255.0f;
874
875 // check light and determine the shader used
876 const auto& scene = Director::getInstance()->getRunningScene();
877
878 // Don't override GLProgramState if using manually set Material
879 if (_usingAutogeneratedGLProgram && scene)
880 {
881 const auto lights = scene->getLights();
882 bool usingLight = false;
883 for (const auto light : lights)
884 {
885 usingLight = light->isEnabled() && ((static_cast<unsigned int>(light->getLightFlag()) & _lightMask) > 0);
886 if (usingLight)
887 break;
888 }
889 if (usingLight != _shaderUsingLight)
890 {
891 genMaterial(usingLight);
892 }
893 }
894
895 for (auto&& mesh : _meshes)
896 {
897 mesh->draw(renderer, _globalZOrder, transform, flags, _lightMask, Vec4(color.r, color.g, color.b, color.a),
898 _forceDepthWrite, _wireframe);
899 }
900}
901
902bool MeshRenderer::setProgramState(backend::ProgramState* programState, bool ownPS /* = false*/)
903{

Callers 1

visitMethod · 0.95

Calls 4

getInstanceFunction · 0.85
updateBoneMatrixMethod · 0.80
Vec4Function · 0.50
isEnabledMethod · 0.45

Tested by

no test coverage detected