MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / render

Method render

Source/Node/DrawNode.cpp:75–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void DrawNode::render() {
76 if (_vertices.empty()) {
77 Node::render();
78 return;
79 }
80
81 if (SharedDirector.isFrustumCulling()) {
82 auto [minX, maxX] = std::minmax_element(_posColors.begin(), _posColors.end(), [](const auto& a, const auto& b) {
83 return a.pos.x < b.pos.x;
84 });
85 auto [minY, maxY] = std::minmax_element(_posColors.begin(), _posColors.end(), [](const auto& a, const auto& b) {
86 return a.pos.y < b.pos.y;
87 });
88 AABB aabb;
89 Matrix::mulAABB(aabb, getWorld(), {
90 {minX->pos.x, minY->pos.y, 0},
91 {maxX->pos.x, maxY->pos.y, 0},
92 });
93 if (!SharedDirector.isInFrustum(aabb)) {
94 return;
95 }
96 }
97
98 if (_flags.isOn(DrawNode::VertexColorDirty)) {
99 _flags.setOff(DrawNode::VertexColorDirty);
100 Vec4 ucolor = _realColor.toVec4();
101 for (size_t i = 0; i < _posColors.size(); i++) {
102 const Vec4& acolor = _posColors[i].color;
103 Vec4 color{
104 acolor.x * ucolor.x,
105 acolor.y * ucolor.y,
106 acolor.z * ucolor.z,
107 acolor.w * ucolor.w};
108 _vertices[i].abgr = Color(color).toABGR();
109 }
110 }
111
112 if (_flags.isOn(DrawNode::VertexPosDirty)) {
113 _flags.setOff(DrawNode::VertexPosDirty);
114 Matrix transform;
115 Matrix::mulMtx(transform, SharedDirector.getViewProjection(), getWorld());
116 for (size_t i = 0; i < _vertices.size(); i++) {
117 Matrix::mulVec4(&_vertices[i].x, transform, _posColors[i].pos);
118 }
119 }
120
121 _renderState = BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | _blendFunc.toValue();
122 if (_flags.isOn(DrawNode::DepthWrite)) {
123 _renderState |= (BGFX_STATE_WRITE_Z | BGFX_STATE_DEPTH_TEST_LESS);
124 }
125
126 SharedRendererManager.setCurrent(SharedDrawRenderer.getTarget());
127 SharedDrawRenderer.push(this);
128
129 Node::render();
130}
131
132void DrawNode::pushVertex(const Vec2& pos, const Vec4& color, const Vec2& coord) {

Callers

nothing calls this directly

Calls 15

allocTransientBuffersFunction · 0.85
isFrustumCullingMethod · 0.80
isInFrustumMethod · 0.80
isOnMethod · 0.80
setOffMethod · 0.80
toVec4Method · 0.80
toABGRMethod · 0.80
setCurrentMethod · 0.80
getTargetMethod · 0.80
pushMethod · 0.65
getIdMethod · 0.65
applyMethod · 0.65

Tested by

no test coverage detected