| 857 | } |
| 858 | |
| 859 | void 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 | |
| 902 | bool MeshRenderer::setProgramState(backend::ProgramState* programState, bool ownPS /* = false*/) |
| 903 | { |
no test coverage detected