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

Method updateTransform

core/2d/Label.cpp:106–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104 CREATE_FUNC(LabelLetter);
105
106 virtual void updateTransform() override
107 {
108 if (isDirty())
109 {
110 _transformToBatch = getNodeToParentTransform();
111 Vec2& size = _rect.size;
112
113 float x1 = _offsetPosition.x;
114 float y1 = _offsetPosition.y;
115 float x2 = x1 + size.width;
116 float y2 = y1 + size.height;
117
118 // issue #17022: don't flip, again, the letter since they are flipped in sprite's code
119 // if (_flippedX) std::swap(x1, x2);
120 // if (_flippedY) std::swap(y1, y2);
121
122 float x = _transformToBatch.m[12];
123 float y = _transformToBatch.m[13];
124
125 float cr = _transformToBatch.m[0];
126 float sr = _transformToBatch.m[1];
127 float cr2 = _transformToBatch.m[5];
128 float sr2 = -_transformToBatch.m[4];
129 float ax = x1 * cr - y1 * sr2 + x;
130 float ay = x1 * sr + y1 * cr2 + y;
131
132 float bx = x2 * cr - y1 * sr2 + x;
133 float by = x2 * sr + y1 * cr2 + y;
134 float cx = x2 * cr - y2 * sr2 + x;
135 float cy = x2 * sr + y2 * cr2 + y;
136 float dx = x1 * cr - y2 * sr2 + x;
137 float dy = x1 * sr + y2 * cr2 + y;
138
139 _quad.bl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ);
140 _quad.br.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ);
141 _quad.tl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ);
142 _quad.tr.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ);
143
144 if (_textureAtlas)
145 {
146 _textureAtlas->updateQuad(_quad, _atlasIndex);
147 }
148
149 _recursiveDirty = false;
150 setDirty(false);
151 }
152
153 Node::updateTransform();
154 }
155
156 virtual void updateColor() override
157 {

Callers 1

drawMethod · 0.45

Calls 4

updateQuadMethod · 0.80
isDirtyFunction · 0.70
setDirtyFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected