MCPcopy Create free account
hub / github.com/MyGUI/mygui / _rebuildGeometry

Method _rebuildGeometry

MyGUIEngine/src/MyGUI_RotatingSkin.cpp:220–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218 }
219
220 void RotatingSkin::_rebuildGeometry()
221 {
222 /*
223 0 1
224 3 2
225 */
226#ifdef M_PI
227 #undef M_PI
228#endif
229 const float M_PI = 3.141593f;
230
231 float width_base = (float)mCurrentCoord.width;
232 float height_base = (float)mCurrentCoord.height;
233
234 // calculate original unrotated angles of uncropped rectangle verticies: between axis and line from center of rotation to vertex)
235 float baseAngles[RECT_VERTICIES_COUNT];
236 baseAngles[0] = std::atan2((float)mCenterPos.left, (float)mCenterPos.top) + M_PI / 2;
237 baseAngles[1] = std::atan2(-width_base + (float)mCenterPos.left, (float)mCenterPos.top) + M_PI / 2;
238 baseAngles[2] =
239 std::atan2(-width_base + (float)mCenterPos.left, -height_base + (float)mCenterPos.top) + M_PI / 2;
240 baseAngles[3] = std::atan2((float)mCenterPos.left, -height_base + (float)mCenterPos.top) + M_PI / 2;
241
242 // calculate original unrotated distances of uncropped rectangle verticies: between center of rotation and vertex)
243 float baseDistances[RECT_VERTICIES_COUNT];
244 baseDistances[0] = len((float)mCenterPos.left, (float)mCenterPos.top);
245 baseDistances[1] = len(-width_base + (float)mCenterPos.left, (float)mCenterPos.top);
246 baseDistances[2] = len(-width_base + (float)mCenterPos.left, -height_base + (float)mCenterPos.top);
247 baseDistances[3] = len((float)mCenterPos.left, -height_base + (float)mCenterPos.top);
248
249
250 // calculate rotated positions of uncropped rectangle verticies (relative to parent)
251 FloatPoint baseVerticiesPos[RECT_VERTICIES_COUNT];
252
253 int offsetX = /*mCurrentCoord.left +*/ mCenterPos.left;
254 int offsetY = /*mCurrentCoord.top +*/ mCenterPos.top;
255
256 for (int i = 0; i < RECT_VERTICIES_COUNT; ++i)
257 {
258 baseVerticiesPos[i].left = offsetX + std::cos(-mAngle + baseAngles[i]) * baseDistances[i];
259 baseVerticiesPos[i].top = offsetY - std::sin(-mAngle + baseAngles[i]) * baseDistances[i];
260 }
261
262 // base texture coordinates
263 FloatPoint baseVerticiesUV[RECT_VERTICIES_COUNT] = {
264 FloatPoint(mCurrentTexture.left, mCurrentTexture.top),
265 FloatPoint(mCurrentTexture.right, mCurrentTexture.top),
266 FloatPoint(mCurrentTexture.right, mCurrentTexture.bottom),
267 FloatPoint(mCurrentTexture.left, mCurrentTexture.bottom)};
268
269 // now we have rotated uncropped rectangle verticies coordinates
270
271 // --------- here the cropping starts ---------
272
273 // now we are going to calculate verticies of resulting figure
274
275 // no parent - no cropping
276 size_t size = RECT_VERTICIES_COUNT;
277 if (nullptr == mCroppedParent->getCroppedParent())

Callers

nothing calls this directly

Calls 11

cropPolygonFunction · 0.85
getPositionInsideRectFunction · 0.85
getLeftMethod · 0.80
getTopMethod · 0.80
getInfoMethod · 0.80
lenFunction · 0.70
FloatPointFunction · 0.50
IntCoordFunction · 0.50
sizeMethod · 0.45
getRenderTargetMethod · 0.45

Tested by

no test coverage detected