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

Method render

Source/Node/Grid.cpp:207–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207void Grid::render() {
208 if (!_texture || !_effect || _vertices.empty()) {
209 Node::render();
210 return;
211 }
212
213 if (SharedDirector.isFrustumCulling()) {
214 auto [minX, maxX] = std::minmax_element(_points.begin(), _points.end(), [](const auto& a, const auto& b) {
215 return a.position.x < b.position.x;
216 });
217 auto [minY, maxY] = std::minmax_element(_points.begin(), _points.end(), [](const auto& a, const auto& b) {
218 return a.position.y < b.position.y;
219 });
220 AABB aabb;
221 Matrix::mulAABB(aabb, getWorld(), {
222 {minX->position.x, minY->position.y, 0},
223 {maxX->position.x, maxY->position.y, 0},
224 });
225 if (!SharedDirector.isInFrustum(aabb)) {
226 return;
227 }
228 }
229
230 if (_flags.isOn(Grid::VertexColorDirty)) {
231 _flags.setOff(Grid::VertexColorDirty);
232 for (size_t i = 0; i < _points.size(); i++) {
233 auto rc = _realColor.toVec4();
234 const auto& c = _points[i].color;
235 _vertices[i].abgr = Color(Vec4{
236 c.x * rc.x,
237 c.y * rc.y,
238 c.z * rc.z,
239 c.w * rc.w})
240 .toABGR();
241 }
242 }
243
244 if (_flags.isOn(Grid::VertexPosDirty)) {
245 _flags.setOff(Grid::VertexPosDirty);
246 Matrix transform;
247 Matrix::mulMtx(transform, SharedDirector.getViewProjection(), getWorld());
248 for (size_t i = 0; i < _points.size(); i++) {
249 Matrix::mulVec4(&_vertices[i].x, transform, _points[i].position);
250 }
251 }
252
253 uint64_t renderState = (BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_MSAA | _blendFunc.toValue());
254 if (isDepthWrite()) {
255 renderState |= (BGFX_STATE_WRITE_Z | BGFX_STATE_DEPTH_TEST_LESS);
256 }
257
258 SharedRendererManager.setCurrent(SharedSpriteRenderer.getTarget());
259 SharedSpriteRenderer.push(
260 _vertices.data(), _vertices.size(),
261 _indices.data(), _indices.size(),
262 _effect, _texture, renderState);
263
264 Node::render();

Callers

nothing calls this directly

Calls 15

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
ColorClass · 0.50
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected