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

Method visit

core/2d/NodeGrid.cpp:97–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void NodeGrid::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags)
98{
99 // quick return if not visible. children won't be drawn.
100 if (!_visible)
101 {
102 return;
103 }
104
105 bool dirty = (parentFlags & FLAGS_TRANSFORM_DIRTY) || _transformUpdated;
106 if (dirty)
107 _modelViewTransform = this->transform(parentTransform);
108 _transformUpdated = false;
109
110 // IMPORTANT:
111 // To ease the migration to v3.0, we still support the Mat4 stack,
112 // but it is deprecated and your code should not rely on it
113 _director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
114 _director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
115
116 Director::Projection beforeProjectionType = Director::Projection::DEFAULT;
117 if (_nodeGrid && _nodeGrid->isActive())
118 {
119 beforeProjectionType = _director->getProjection();
120 _nodeGrid->set2DProjection();
121 }
122
123 onGridBeginDraw();
124
125 if (_gridTarget)
126 {
127 _gridTarget->visit(renderer, _modelViewTransform, dirty);
128 }
129
130 int i = 0;
131 bool visibleByCamera = isVisitableByVisitingCamera();
132
133 if (!_children.empty())
134 {
135 sortAllChildren();
136 // draw children zOrder < 0
137 for (auto size = _children.size(); i < size; ++i)
138 {
139 auto node = _children.at(i);
140
141 if (node && node->getLocalZOrder() < 0)
142 node->visit(renderer, _modelViewTransform, dirty);
143 else
144 break;
145 }
146 // self draw,currently we have nothing to draw on NodeGrid, so there is no need to add render command
147 if (visibleByCamera)
148 this->draw(renderer, _modelViewTransform, dirty);
149
150 for (auto it = _children.cbegin() + i, itCend = _children.cend(); it != itCend; ++it)
151 {
152 (*it)->visit(renderer, _modelViewTransform, dirty);
153 }
154 }

Callers

nothing calls this directly

Calls 13

pushMatrixMethod · 0.80
loadMatrixMethod · 0.80
set2DProjectionMethod · 0.80
setProjectionMethod · 0.80
popMatrixMethod · 0.80
transformMethod · 0.45
isActiveMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
drawMethod · 0.45
cbeginMethod · 0.45

Tested by

no test coverage detected