18 mGeometryOutdated(false),
21 mCurrentColour(0xFFFFFFFF),
31 mGeometryOutdated =
true;
40 mGeometryOutdated =
true;
57 mGeometryOutdated =
true;
66 mCurrentColour = (mCurrentColour & 0x00FFFFFF) | (alpha & 0xFF000000);
74 mGeometryOutdated =
true;
125 mGeometryOutdated =
true;
127 if (
nullptr != mNode)
133 MYGUI_ASSERT(!mRenderItem,
"mRenderItem must be nullptr");
137 mRenderItem->
addDrawItem(
this, (GEOMETRY_VERTICIES_TOTAL_COUNT - 2) * 3);
142 MYGUI_ASSERT(mRenderItem,
"mRenderItem must be not nullptr");
146 mRenderItem =
nullptr;
158 if (mGeometryOutdated)
161 mGeometryOutdated =
false;
164 for (
int i = 1; i < GEOMETRY_VERTICIES_TOTAL_COUNT - 1; ++i)
166 verticies[3 * i - 3].
set(mResultVerticiesPos[0].left, mResultVerticiesPos[0].top, vertex_z, mResultVerticiesUV[0].left, mResultVerticiesUV[0].top, mCurrentColour);
167 verticies[3 * i - 2].
set(mResultVerticiesPos[i].left, mResultVerticiesPos[i].top, vertex_z, mResultVerticiesUV[i].left, mResultVerticiesUV[i].top, mCurrentColour);
168 verticies[3 * i - 1].
set(mResultVerticiesPos[i + 1].left, mResultVerticiesPos[i + 1].top, vertex_z, mResultVerticiesUV[i + 1].left, mResultVerticiesUV[i + 1].top, mCurrentColour);
178 mCurrentColour = (colour & 0x00FFFFFF) | (mCurrentColour & 0xFF000000);
180 if (
nullptr != mNode)
196 mCurrentTexture = _rect;
198 mGeometryOutdated =
true;
200 if (
nullptr != mNode)
204 inline float len(
float x,
float y)
206 return std::sqrt(x * x + y * y);
218 const float M_PI = 3.141593f;
220 float width_base = (float)mCurrentCoord.
width;
221 float height_base = (
float)mCurrentCoord.
height;
224 float baseAngles[RECT_VERTICIES_COUNT];
225 baseAngles[0] = std::atan2((
float)mCenterPos.
left, (
float)mCenterPos.
top) +
M_PI / 2;
226 baseAngles[1] = std::atan2(- width_base + (
float)mCenterPos.
left, (
float)mCenterPos.
top) +
M_PI / 2;
227 baseAngles[2] = std::atan2(- width_base + (
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top) +
M_PI / 2;
228 baseAngles[3] = std::atan2((
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top) +
M_PI / 2;
231 float baseDistances[RECT_VERTICIES_COUNT];
232 baseDistances[0] =
len((
float)mCenterPos.
left, (
float)mCenterPos.
top);
233 baseDistances[1] =
len(- width_base + (
float)mCenterPos.
left, (
float)mCenterPos.
top);
234 baseDistances[2] =
len(- width_base + (
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top);
235 baseDistances[3] =
len((
float)mCenterPos.
left, - height_base + (
float)mCenterPos.
top);
239 FloatPoint baseVerticiesPos[RECT_VERTICIES_COUNT];
241 int offsetX = mCenterPos.
left;
242 int offsetY = mCenterPos.
top;
244 for (
int i = 0; i < RECT_VERTICIES_COUNT; ++i)
246 baseVerticiesPos[i].
left = offsetX + std::cos(-mAngle + baseAngles[i]) * baseDistances[i];
247 baseVerticiesPos[i].
top = offsetY - std::sin(-mAngle + baseAngles[i]) * baseDistances[i];
251 FloatPoint baseVerticiesUV[RECT_VERTICIES_COUNT] =
266 size_t size = RECT_VERTICIES_COUNT;
269 for (
int i = 0; i < RECT_VERTICIES_COUNT; ++i)
271 mResultVerticiesPos[i] = baseVerticiesPos[i];
272 mResultVerticiesUV[i] = baseVerticiesUV[i];
281 RECT_VERTICIES_COUNT,
288 for (
size_t i = 0; i < resultVerticiesPos.size(); ++i)
290 mResultVerticiesPos[i] = resultVerticiesPos[i];
293 size = resultVerticiesPos.size();
296 FloatPoint v0 = baseVerticiesUV[3] - baseVerticiesUV[0];
297 FloatPoint v1 = baseVerticiesUV[1] - baseVerticiesUV[0];
298 for (
size_t i = 0; i < GEOMETRY_VERTICIES_TOTAL_COUNT; ++i)
308 mResultVerticiesUV[i] = mResultVerticiesUV[size == 0 ? 0 : (size - 1)];
319 for (
size_t i = 0; i < GEOMETRY_VERTICIES_TOTAL_COUNT; ++i)
323 mResultVerticiesPos[i].
left = vertex_left_base + mResultVerticiesPos[i].
left * info.
pixScaleX * 2;
324 mResultVerticiesPos[i].
top = vertex_top_base + mResultVerticiesPos[i].
top * info.
pixScaleY * -2;
329 mResultVerticiesPos[i] = mResultVerticiesPos[size == 0 ? 0 : (size - 1)];
#define MYGUI_ASSERT(exp, dest)
int getAbsoluteLeft() const
const IntPoint & getAbsolutePosition() const
ICroppedRectangle * mCroppedParent
int _getMarginLeft() const
int _getMarginTop() const
ICroppedRectangle * getCroppedParent()
int getAbsoluteTop() const
int _getViewWidth() const
int _getViewHeight() const
virtual float getNodeDepth() const =0
virtual void outOfDate(RenderItem *_item)=0
virtual RenderItem * addToRenderItem(ITexture *_texture, bool _firstQueue, bool _separate)=0
Type * castType(bool _throw=true)
virtual const RenderTargetInfo & getInfo() const =0
void addDrawItem(ISubWidget *_item, size_t _count)
IRenderTarget * getRenderTarget()
void removeDrawItem(ISubWidget *_item)
Vertex * getCurrentVertexBuffer() const
void setLastVertexCount(size_t _count)
virtual VertexColourType getVertexFormat() const =0
static RenderManager & getInstance()
void setAlpha(float _alpha) override
void setAngle(float _angle)
void _setColour(const Colour &_value) override
void _setUVSet(const FloatRect &_rect) override
IntPoint getCenter(bool _local=true) const
void setStateData(IStateInfo *_data) override
void _correctView() override
void destroyDrawItem() override
void setVisible(bool _visible) override
void _updateView() override
void createDrawItem(ITexture *_texture, ILayerNode *_node) override
void setCenter(const IntPoint &_center)
void _setAlign(const IntSize &_oldsize) override
const IntPoint & getCenter() const
const FloatRect & getRect() const
FloatPoint getUVFromPositionInsideRect(const FloatPoint &_point, const FloatPoint &_v0, const FloatPoint &_v1, const FloatPoint &_baseUV)
FloatPoint getPositionInsideRect(const FloatPoint &_point, const FloatPoint &_corner0, const FloatPoint &_corner1, const FloatPoint &_corner2)
VectorFloatPoint cropPolygon(FloatPoint *_baseVerticiesPos, size_t _size, const IntCoord &_cropRectangle)
void convertColour(uint32 &_colour, VertexColourType _format)
uint32 toColourARGB(const Colour &_colour)
std::vector< FloatPoint > VectorFloatPoint
types::TCoord< int > IntCoord
types::TPoint< float > FloatPoint
types::TPoint< int > IntPoint
float len(float x, float y)
void set(float _x, float _y, float _z, float _u, float _v, uint32 _colour)