18 mGeometryOutdated(false),
21 mCurrentColour(0xFFFFFFFF),
35 mGeometryOutdated =
true;
44 mGeometryOutdated =
true;
61 mGeometryOutdated =
true;
70 mCurrentColour = (mCurrentColour & 0x00FFFFFF) | (alpha & 0xFF000000);
78 mGeometryOutdated =
true;
87 bool need_update =
true;
141 mGeometryOutdated =
true;
143 if (
nullptr != mNode)
149 MYGUI_ASSERT(!mRenderItem,
"mRenderItem must be nullptr");
153 mRenderItem->
addDrawItem(
this, (GEOMETRY_VERTICIES_TOTAL_COUNT - 2) * 3);
158 MYGUI_ASSERT(mRenderItem,
"mRenderItem must be not nullptr");
162 mRenderItem =
nullptr;
174 if (mGeometryOutdated)
177 mGeometryOutdated =
false;
180 for (
int i = 1; i < GEOMETRY_VERTICIES_TOTAL_COUNT - 1; ++i)
182 verticies[3 * i - 3].
set(mResultVerticiesPos[0].left, mResultVerticiesPos[0].top, vertex_z, mResultVerticiesUV[0].left, mResultVerticiesUV[0].top, mCurrentColour);
183 verticies[3 * i - 2].
set(mResultVerticiesPos[i].left, mResultVerticiesPos[i].top, vertex_z, mResultVerticiesUV[i].left, mResultVerticiesUV[i].top, mCurrentColour);
184 verticies[3 * i - 1].
set(mResultVerticiesPos[i + 1].left, mResultVerticiesPos[i + 1].top, vertex_z, mResultVerticiesUV[i + 1].left, mResultVerticiesUV[i + 1].top, mCurrentColour);
194 mCurrentColour = (colour & 0x00FFFFFF) | (mCurrentColour & 0xFF000000);
196 if (
nullptr != mNode)
212 mCurrentTexture = _rect;
214 mGeometryOutdated =
true;
216 if (
nullptr != mNode)
220 inline float len(
float x,
float y)
222 return sqrt(x * x + y * y);
232 const float M_PI = 3.141593f;
235 float width_base = (float)mCurrentCoord.
width;
236 float height_base = (
float)mCurrentCoord.
height;
239 float baseAngles[RECT_VERTICIES_COUNT];
240 baseAngles[0] = atan2((
float)mCenterPos.
left, (
float)mCenterPos.
top) + M_PI / 2;
241 baseAngles[1] = atan2(- width_base + (
float)mCenterPos.
left, (
float)mCenterPos.
top) + M_PI / 2;
242 baseAngles[2] = atan2(- width_base + (
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top) + M_PI / 2;
243 baseAngles[3] = atan2((
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top) + M_PI / 2;
246 float baseDistances[RECT_VERTICIES_COUNT];
247 baseDistances[0] =
len((
float)mCenterPos.
left, (
float)mCenterPos.
top);
248 baseDistances[1] =
len(- width_base + (
float)mCenterPos.
left, (
float)mCenterPos.
top);
249 baseDistances[2] =
len(- width_base + (
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top);
250 baseDistances[3] =
len((
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top);
254 FloatPoint baseVerticiesPos[RECT_VERTICIES_COUNT];
256 int offsetX = mCenterPos.
left;
257 int offsetY = mCenterPos.
top;
259 for (
int i = 0; i < RECT_VERTICIES_COUNT; ++i)
261 baseVerticiesPos[i].
left = offsetX + cos(-mAngle + baseAngles[i]) * baseDistances[i];
262 baseVerticiesPos[i].
top = offsetY - sin(-mAngle + baseAngles[i]) * baseDistances[i];
266 FloatPoint baseVerticiesUV[RECT_VERTICIES_COUNT] =
281 size_t size = RECT_VERTICIES_COUNT;
284 for (
int i = 0; i < RECT_VERTICIES_COUNT; ++i)
286 mResultVerticiesPos[i] = baseVerticiesPos[i];
287 mResultVerticiesUV[i] = baseVerticiesUV[i];
296 RECT_VERTICIES_COUNT,
303 for (
size_t i = 0; i < resultVerticiesPos.size(); ++i)
305 mResultVerticiesPos[i] = resultVerticiesPos[i];
308 size = resultVerticiesPos.size();
311 FloatPoint v0 = baseVerticiesUV[3] - baseVerticiesUV[0];
312 FloatPoint v1 = baseVerticiesUV[1] - baseVerticiesUV[0];
313 for (
size_t i = 0; i < GEOMETRY_VERTICIES_TOTAL_COUNT; ++i)
323 mResultVerticiesUV[i] = mResultVerticiesUV[size - 1];
334 for (
size_t i = 0; i < GEOMETRY_VERTICIES_TOTAL_COUNT; ++i)
338 mResultVerticiesPos[i].
left = vertex_left_base + mResultVerticiesPos[i].
left * info.
pixScaleX * 2;
339 mResultVerticiesPos[i].
top = vertex_top_base + mResultVerticiesPos[i].
top * info.
pixScaleY * -2;
344 mResultVerticiesPos[i] = mResultVerticiesPos[size - 1];