| 968 | } |
| 969 | |
| 970 | void Node::render() { |
| 971 | if (_updateItem && _updateItem->renderFuncs) { |
| 972 | if (!_updateItem->renderFuncs->empty()) { |
| 973 | double deltaTime = _scheduler->getDeltaTime() * _scheduler->getTimeScale(); |
| 974 | auto funcs = std::move(*_updateItem->renderFuncs); |
| 975 | for (auto it = funcs.begin(); it != funcs.end();) { |
| 976 | if ((*it)(deltaTime)) { |
| 977 | it = funcs.erase(it); |
| 978 | } else { |
| 979 | it++; |
| 980 | } |
| 981 | } |
| 982 | for (auto& f : *_updateItem->renderFuncs) { |
| 983 | funcs.emplace_back(std::move(f)); |
| 984 | } |
| 985 | *_updateItem->renderFuncs = std::move(funcs); |
| 986 | } |
| 987 | } |
| 988 | if (isShowDebug()) { |
| 989 | Matrix transform; |
| 990 | Matrix::mulMtx(transform, SharedDirector.getViewProjection(), getWorld()); |
| 991 | float w = getWidth(); |
| 992 | float h = getHeight(); |
| 993 | const float anchorSize = 20.0f; |
| 994 | float anchorPointX = GetTAttr(anchorPointX); |
| 995 | float anchorPointY = GetTAttr(anchorPointY); |
| 996 | Vec4 positions[] = { |
| 997 | {0, h, 0, 1.0f}, |
| 998 | {w, h, 0, 1.0f}, |
| 999 | {w, 0, 0, 1.0f}, |
| 1000 | {0, 0, 0, 1.0f}, |
| 1001 | {anchorPointX - anchorSize, anchorPointY, 0, 1.0f}, |
| 1002 | {anchorPointX + anchorSize, anchorPointY, 0, 1.0f}, |
| 1003 | {anchorPointX, anchorPointY - anchorSize, 0, 1.0f}, |
| 1004 | {anchorPointX, anchorPointY + anchorSize, 0, 1.0f}}; |
| 1005 | auto color = getColor().toABGR(); |
| 1006 | auto themeColor = SharedApplication.getThemeColor(); |
| 1007 | themeColor.setOpacity(getRealOpacity()); |
| 1008 | auto anchorColor = themeColor.toABGR(); |
| 1009 | PosColorVertex verts[8] = { |
| 1010 | {0, 0, 0, 0, color}, |
| 1011 | {0, 0, 0, 0, color}, |
| 1012 | {0, 0, 0, 0, color}, |
| 1013 | {0, 0, 0, 0, color}, |
| 1014 | {0, 0, 0, 0, anchorColor}, |
| 1015 | {0, 0, 0, 0, anchorColor}, |
| 1016 | {0, 0, 0, 0, anchorColor}, |
| 1017 | {0, 0, 0, 0, anchorColor}}; |
| 1018 | for (size_t i = 0; i < 8; i++) { |
| 1019 | Matrix::mulVec4(&verts[i].x, transform, positions[i]); |
| 1020 | } |
| 1021 | SharedRendererManager.setCurrent(SharedLineRenderer.getTarget()); |
| 1022 | if (getSize() != Size::zero) { |
| 1023 | SharedLineRenderer.pushRect(verts); |
| 1024 | } |
| 1025 | SharedLineRenderer.pushSegment(verts + 4); |
| 1026 | SharedLineRenderer.pushSegment(verts + 6); |
| 1027 | } |
no test coverage detected