|
|
@@ -33,191 +33,189 @@ namespace Urho3D
|
|
|
{
|
|
|
|
|
|
#ifdef USE_OPENGL
|
|
|
-static const Vector2 posAdjust(Vector2::ZERO);
|
|
|
+static const float posAdjust = 0.0f;
|
|
|
#else
|
|
|
-static const Vector2 posAdjust(0.5f, 0.5f);
|
|
|
+static const float posAdjust = 0.5f;
|
|
|
#endif
|
|
|
|
|
|
-UIQuad::UIQuad() :
|
|
|
- defined_(false)
|
|
|
+UIBatch::UIBatch() :
|
|
|
+ element_(0),
|
|
|
+ blendMode_(BLEND_REPLACE),
|
|
|
+ texture_(0),
|
|
|
+ vertexData_(0),
|
|
|
+ vertexStart_(0),
|
|
|
+ vertexEnd_(0)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+UIBatch::UIBatch(UIElement* element, BlendMode blendMode, const IntRect& scissor, Texture* texture, PODVector<float>* vertexData) :
|
|
|
+ element_(element),
|
|
|
+ blendMode_(blendMode),
|
|
|
+ scissor_(scissor),
|
|
|
+ texture_(texture),
|
|
|
+ vertexData_(vertexData),
|
|
|
+ vertexStart_(vertexData->Size()),
|
|
|
+ vertexEnd_(vertexData->Size())
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-UIQuad::UIQuad(const UIElement& element, int x, int y, int width, int height, int texOffsetX, int texOffsetY,
|
|
|
- int texWidth, int texHeight, Color* color) :
|
|
|
- defined_(false)
|
|
|
+
|
|
|
+void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight,
|
|
|
+ Color* color)
|
|
|
{
|
|
|
- if (color || !element.HasColorGradient())
|
|
|
+ unsigned topLeftColor, topRightColor, bottomLeftColor, bottomRightColor;
|
|
|
+
|
|
|
+ if (color || !element_->HasColorGradient())
|
|
|
{
|
|
|
- unsigned uintColor = (color ? *color : element.GetDerivedColor()).ToUInt();
|
|
|
+ unsigned uintColor = (color ? *color : element_->GetDerivedColor()).ToUInt();
|
|
|
|
|
|
// If alpha is 0, nothing will be rendered, so do not add the quad
|
|
|
if (!(uintColor & 0xff000000))
|
|
|
return;
|
|
|
|
|
|
- topLeftColor_ = uintColor;
|
|
|
- topRightColor_ = uintColor;
|
|
|
- bottomLeftColor_ = uintColor;
|
|
|
- bottomRightColor_ = uintColor;
|
|
|
+ topLeftColor = uintColor;
|
|
|
+ topRightColor = uintColor;
|
|
|
+ bottomLeftColor = uintColor;
|
|
|
+ bottomRightColor = uintColor;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- topLeftColor_ = GetInterpolatedColor(element, x, y);
|
|
|
- topRightColor_ = GetInterpolatedColor(element, x + width, y);
|
|
|
- bottomLeftColor_ = GetInterpolatedColor(element, x, y + height);
|
|
|
- bottomRightColor_ = GetInterpolatedColor(element, x + width, y + height);
|
|
|
+ topLeftColor = GetInterpolatedColor(x, y);
|
|
|
+ topRightColor = GetInterpolatedColor(x + width, y);
|
|
|
+ bottomLeftColor = GetInterpolatedColor(x, y + height);
|
|
|
+ bottomRightColor = GetInterpolatedColor(x + width, y + height);
|
|
|
}
|
|
|
|
|
|
- const IntVector2& screenPos = element.GetScreenPosition();
|
|
|
+ const IntVector2& screenPos = element_->GetScreenPosition();
|
|
|
+
|
|
|
+ Vector2 invTextureSize;
|
|
|
+ if (texture_)
|
|
|
+ invTextureSize = Vector2(1.0f / (float)texture_->GetWidth(), 1.0f / (float)texture_->GetHeight());
|
|
|
+ else
|
|
|
+ invTextureSize = Vector2::ONE;
|
|
|
|
|
|
- float left = (float)(x + screenPos.x_);
|
|
|
+ float left = (float)(x + screenPos.x_) - posAdjust;
|
|
|
float right = left + (float)width;
|
|
|
- float top = (float)(y + screenPos.y_);
|
|
|
+ float top = (float)(y + screenPos.y_) - posAdjust;
|
|
|
float bottom = top + (float)height;
|
|
|
- topLeft_ = Vector2(left, top) - posAdjust;
|
|
|
- topRight_ = Vector2(right, top) - posAdjust;
|
|
|
- bottomLeft_ = Vector2(left, bottom) - posAdjust;
|
|
|
- bottomRight_ = Vector2(right, bottom) - posAdjust;
|
|
|
|
|
|
- leftUV_ = texOffsetX;
|
|
|
- topUV_ = texOffsetY;
|
|
|
- rightUV_ = texOffsetX + (texWidth ? texWidth : width);
|
|
|
- bottomUV_ = texOffsetY + (texHeight ? texHeight : height);
|
|
|
+ float leftUV = texOffsetX * invTextureSize.x_;
|
|
|
+ float topUV = texOffsetY * invTextureSize.y_;
|
|
|
+ float rightUV = (texOffsetX + (texWidth ? texWidth : width)) * invTextureSize.x_;
|
|
|
+ float bottomUV = (texOffsetY + (texHeight ? texHeight : height)) * invTextureSize.y_;
|
|
|
+
|
|
|
+ unsigned begin = vertexData_->Size();
|
|
|
+ vertexData_->Resize(begin + 6 * 6);
|
|
|
+ float* dest = &(vertexData_->At(begin));
|
|
|
+ vertexEnd_ = vertexData_->Size();
|
|
|
+
|
|
|
+ *dest++ = left; *dest++ = top; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = topLeftColor; dest++;
|
|
|
+ *dest++ = leftUV; *dest++ = topUV;
|
|
|
+
|
|
|
+ *dest++ = right; *dest++ = top; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = topRightColor; dest++;
|
|
|
+ *dest++ = rightUV; *dest++ = topUV;
|
|
|
+
|
|
|
+ *dest++ = left; *dest++ = bottom; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = bottomLeftColor; dest++;
|
|
|
+ *dest++ = leftUV; *dest++ = bottomUV;
|
|
|
|
|
|
- defined_ = true;
|
|
|
+ *dest++ = right; *dest++ = top; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = topRightColor; dest++;
|
|
|
+ *dest++ = rightUV; *dest++ = topUV;
|
|
|
+
|
|
|
+ *dest++ = right; *dest++ = bottom; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = bottomRightColor; dest++;
|
|
|
+ *dest++ = rightUV; *dest++ = bottomUV;
|
|
|
+
|
|
|
+ *dest++ = left; *dest++ = bottom; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = bottomLeftColor; dest++;
|
|
|
+ *dest++ = leftUV; *dest++ = bottomUV;
|
|
|
}
|
|
|
|
|
|
-UIQuad::UIQuad(const UIElement& element, const Matrix3x4& transform, int x, int y, int width, int height, int texOffsetX, int texOffsetY,
|
|
|
- int texWidth, int texHeight, Color* color) :
|
|
|
- defined_(false)
|
|
|
+void UIBatch::AddQuad(const Matrix3x4& transform, int x, int y, int width, int height, int texOffsetX, int texOffsetY,
|
|
|
+ int texWidth, int texHeight, Color* color)
|
|
|
{
|
|
|
- if (color || !element.HasColorGradient())
|
|
|
+ unsigned topLeftColor, topRightColor, bottomLeftColor, bottomRightColor;
|
|
|
+
|
|
|
+ if (color || !element_->HasColorGradient())
|
|
|
{
|
|
|
- unsigned uintColor = (color ? *color : element.GetDerivedColor()).ToUInt();
|
|
|
+ unsigned uintColor = (color ? *color : element_->GetDerivedColor()).ToUInt();
|
|
|
|
|
|
// If alpha is 0, nothing will be rendered, so do not add the quad
|
|
|
if (!(uintColor & 0xff000000))
|
|
|
return;
|
|
|
|
|
|
- topLeftColor_ = uintColor;
|
|
|
- topRightColor_ = uintColor;
|
|
|
- bottomLeftColor_ = uintColor;
|
|
|
- bottomRightColor_ = uintColor;
|
|
|
+ topLeftColor = uintColor;
|
|
|
+ topRightColor = uintColor;
|
|
|
+ bottomLeftColor = uintColor;
|
|
|
+ bottomRightColor = uintColor;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- topLeftColor_ = GetInterpolatedColor(element, x, y);
|
|
|
- topRightColor_ = GetInterpolatedColor(element, x + width, y);
|
|
|
- bottomLeftColor_ = GetInterpolatedColor(element, x, y + height);
|
|
|
- bottomRightColor_ = GetInterpolatedColor(element, x + width, y + height);
|
|
|
+ topLeftColor = GetInterpolatedColor(x, y);
|
|
|
+ topRightColor = GetInterpolatedColor(x + width, y);
|
|
|
+ bottomLeftColor = GetInterpolatedColor(x, y + height);
|
|
|
+ bottomRightColor = GetInterpolatedColor(x + width, y + height);
|
|
|
}
|
|
|
|
|
|
- Vector3 v1 = transform * Vector3((float)x, (float)y, 0.0f);
|
|
|
- Vector3 v2 = transform * Vector3((float)x + (float)width, (float)y, 0.0f);
|
|
|
- Vector3 v3 = transform * Vector3((float)x, (float)y + (float)height, 0.0f);
|
|
|
- Vector3 v4 = transform * Vector3((float)x + (float)width, (float)y + (float)height, 0.0f);
|
|
|
+ Vector2 invTextureSize;
|
|
|
+ if (texture_)
|
|
|
+ invTextureSize = Vector2(1.0f / (float)texture_->GetWidth(), 1.0f / (float)texture_->GetHeight());
|
|
|
+ else
|
|
|
+ invTextureSize = Vector2::ONE;
|
|
|
|
|
|
- topLeft_.x_ = v1.x_; topLeft_.y_ = v1.y_;
|
|
|
- topRight_.x_ = v2.x_; topRight_.y_ = v2.y_;
|
|
|
- bottomLeft_.x_ = v3.x_; bottomLeft_.y_ = v3.y_;
|
|
|
- bottomRight_.x_ = v4.x_; bottomRight_.y_ = v4.y_;
|
|
|
+ Vector3 posAdjustVec(posAdjust, posAdjust, 0.0f);
|
|
|
|
|
|
- leftUV_ = texOffsetX;
|
|
|
- topUV_ = texOffsetY;
|
|
|
- rightUV_ = texOffsetX + (texWidth ? texWidth : (int)width);
|
|
|
- bottomUV_ = texOffsetY + (texHeight ? texHeight : (int)height);
|
|
|
+ Vector3 v1 = (transform * Vector3((float)x, (float)y, 0.0f)) - posAdjustVec;
|
|
|
+ Vector3 v2 = (transform * Vector3((float)x + (float)width, (float)y, 0.0f)) - posAdjustVec;
|
|
|
+ Vector3 v3 = (transform * Vector3((float)x, (float)y + (float)height, 0.0f)) - posAdjustVec;
|
|
|
+ Vector3 v4 = (transform * Vector3((float)x + (float)width, (float)y + (float)height, 0.0f)) - posAdjustVec;
|
|
|
|
|
|
- defined_ = true;
|
|
|
-}
|
|
|
-
|
|
|
-unsigned UIQuad::GetInterpolatedColor(const UIElement& element, int x, int y)
|
|
|
-{
|
|
|
- const IntVector2& size = element.GetSize();
|
|
|
+ float leftUV = ((float)texOffsetX) * invTextureSize.x_;
|
|
|
+ float topUV = ((float)texOffsetY) * invTextureSize.y_;
|
|
|
+ float rightUV = ((float)(texOffsetX + (texWidth ? texWidth : width))) * invTextureSize.x_;
|
|
|
+ float bottomUV = ((float)(texOffsetY + (texHeight ? texHeight : height))) * invTextureSize.y_;
|
|
|
|
|
|
- if (size.x_ && size.y_)
|
|
|
- {
|
|
|
- float cLerpX = Clamp((float)x / (float)size.x_, 0.0f, 1.0f);
|
|
|
- float cLerpY = Clamp((float)y / (float)size.y_, 0.0f, 1.0f);
|
|
|
-
|
|
|
- Color topColor = element.GetColor(C_TOPLEFT).Lerp(element.GetColor(C_TOPRIGHT), cLerpX);
|
|
|
- Color bottomColor = element.GetColor(C_BOTTOMLEFT).Lerp(element.GetColor(C_BOTTOMRIGHT), cLerpX);
|
|
|
- Color color = topColor.Lerp(bottomColor, cLerpY);
|
|
|
- color.a_ *= element.GetDerivedOpacity();
|
|
|
- return color.ToUInt();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Color color = element.GetColor(C_TOPLEFT);
|
|
|
- color.a_ *= element.GetDerivedOpacity();
|
|
|
- return color.ToUInt();
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-UIBatch::UIBatch() :
|
|
|
- blendMode_(BLEND_REPLACE),
|
|
|
- texture_(0),
|
|
|
- quads_(0),
|
|
|
- quadStart_(0),
|
|
|
- quadCount_(0)
|
|
|
-{
|
|
|
-}
|
|
|
+ unsigned begin = vertexData_->Size();
|
|
|
+ vertexData_->Resize(begin + 6 * 6);
|
|
|
+ float* dest = &(vertexData_->At(begin));
|
|
|
+ vertexEnd_ = vertexData_->Size();
|
|
|
|
|
|
-UIBatch::UIBatch(BlendMode blendMode, const IntRect& scissor, Texture* texture, PODVector<UIQuad>* quads) :
|
|
|
- blendMode_(blendMode),
|
|
|
- scissor_(scissor),
|
|
|
- texture_(texture),
|
|
|
- quads_(0),
|
|
|
- quadStart_(0),
|
|
|
- quadCount_(0)
|
|
|
-{
|
|
|
- Begin(quads);
|
|
|
-}
|
|
|
-
|
|
|
-void UIBatch::Begin(PODVector<UIQuad>* quads)
|
|
|
-{
|
|
|
- quads_ = quads;
|
|
|
- quadStart_ = quads_->Size();
|
|
|
- quadCount_ = 0;
|
|
|
-}
|
|
|
-
|
|
|
-void UIBatch::AddQuad(const PODVector<UIQuad>& quads)
|
|
|
-{
|
|
|
- if (quads.Empty())
|
|
|
- return;
|
|
|
+ *dest++ = v1.x_; *dest++ = v1.y_; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = topLeftColor; dest++;
|
|
|
+ *dest++ = leftUV; *dest++ = topUV;
|
|
|
|
|
|
- *quads_ += quads;
|
|
|
- quadCount_ += quads.Size();
|
|
|
-}
|
|
|
-
|
|
|
-void UIBatch::AddQuad(UIQuad quad)
|
|
|
-{
|
|
|
- if (quad.defined_)
|
|
|
- {
|
|
|
- quads_->Push(quad);
|
|
|
- ++quadCount_;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void UIBatch::AddQuad(const UIElement& element, int x, int y, int width, int height, int texOffsetX, int texOffsetY)
|
|
|
-{
|
|
|
- AddQuad(UIQuad(element, x, y, width, height, texOffsetX, texOffsetY));
|
|
|
-}
|
|
|
+ *dest++ = v2.x_; *dest++ = v2.y_; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = topRightColor; dest++;
|
|
|
+ *dest++ = rightUV; *dest++ = topUV;
|
|
|
+
|
|
|
+ *dest++ = v3.x_; *dest++ = v3.y_; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = bottomLeftColor; dest++;
|
|
|
+ *dest++ = leftUV; *dest++ = bottomUV;
|
|
|
+
|
|
|
+ *dest++ = v2.x_; *dest++ = v2.y_; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = topRightColor; dest++;
|
|
|
+ *dest++ = rightUV; *dest++ = topUV;
|
|
|
+
|
|
|
+ *dest++ = v4.x_; *dest++ = v4.y_; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = bottomRightColor; dest++;
|
|
|
+ *dest++ = rightUV; *dest++ = bottomUV;
|
|
|
|
|
|
-void UIBatch::AddQuad(const UIElement& element, int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth,
|
|
|
- int texHeight)
|
|
|
-{
|
|
|
- AddQuad(UIQuad(element, x, y, width, height, texOffsetX, texOffsetY, texWidth, texHeight));
|
|
|
+ *dest++ = v3.x_; *dest++ = v3.y_; *dest++ = 0.0f;
|
|
|
+ *((unsigned*)dest) = bottomLeftColor; dest++;
|
|
|
+ *dest++ = leftUV; *dest++ = bottomUV;
|
|
|
}
|
|
|
|
|
|
-void UIBatch::AddQuad(const UIElement& element, int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth,
|
|
|
- int texHeight, bool tiled)
|
|
|
+void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight, bool tiled)
|
|
|
{
|
|
|
- if (!(element.HasColorGradient() || element.GetDerivedColor().ToUInt() & 0xff000000))
|
|
|
- return; // No gradient and alpha is 0, so do not add the quads
|
|
|
+ if (!(element_->HasColorGradient() || element_->GetDerivedColor().ToUInt() & 0xff000000))
|
|
|
+ return; // No gradient and alpha is 0, so do not add the quad
|
|
|
|
|
|
if (!tiled)
|
|
|
{
|
|
|
- AddQuad(element, x, y, width, height, texOffsetX, texOffsetY, texWidth, texHeight);
|
|
|
+ AddQuad(x, y, width, height, texOffsetX, texOffsetY, texWidth, texHeight);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -235,7 +233,7 @@ void UIBatch::AddQuad(const UIElement& element, int x, int y, int width, int hei
|
|
|
{
|
|
|
tileW = Min(width - tileX, texWidth);
|
|
|
|
|
|
- AddQuad(element, x + tileX, y + tileY, tileW, tileH, texOffsetX, texOffsetY, tileW, tileH);
|
|
|
+ AddQuad(x + tileX, y + tileY, tileW, tileH, texOffsetX, texOffsetY, tileW, tileH);
|
|
|
|
|
|
tileX += tileW;
|
|
|
}
|
|
|
@@ -244,11 +242,11 @@ void UIBatch::AddQuad(const UIElement& element, int x, int y, int width, int hei
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void UIBatch::AddQuad(const UIElement& element, int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth,
|
|
|
- int texHeight, const Color& color)
|
|
|
+void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight,
|
|
|
+ const Color& color)
|
|
|
{
|
|
|
- Color derivedColor(color.r_, color.g_, color.b_, color.a_ * element.GetDerivedOpacity());
|
|
|
- AddQuad(UIQuad(element, x, y, width, height, texOffsetX, texOffsetY, texWidth, texHeight, &derivedColor));
|
|
|
+ Color derivedColor(color.r_, color.g_, color.b_, color.a_ * element_->GetDerivedOpacity());
|
|
|
+ AddQuad(x, y, width, height, texOffsetX, texOffsetY, texWidth, texHeight, &derivedColor);
|
|
|
}
|
|
|
|
|
|
bool UIBatch::Merge(const UIBatch& batch)
|
|
|
@@ -256,93 +254,40 @@ bool UIBatch::Merge(const UIBatch& batch)
|
|
|
if (batch.blendMode_ != blendMode_ ||
|
|
|
batch.scissor_ != scissor_ ||
|
|
|
batch.texture_ != texture_ ||
|
|
|
- batch.quads_ != quads_ ||
|
|
|
- batch.quadStart_ != quadStart_ + quadCount_)
|
|
|
+ batch.vertexData_ != vertexData_ ||
|
|
|
+ batch.vertexStart_ != vertexEnd_)
|
|
|
return false;
|
|
|
|
|
|
- quadCount_ += batch.quadCount_;
|
|
|
+ vertexEnd_ = batch.vertexEnd_;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void UIBatch::UpdateGeometry(Graphics* graphics, void* lockedData)
|
|
|
+unsigned UIBatch::GetInterpolatedColor(int x, int y)
|
|
|
{
|
|
|
- if (!quadCount_)
|
|
|
- return;
|
|
|
-
|
|
|
- float* dest = (float*)lockedData;
|
|
|
+ const IntVector2& size = element_->GetSize();
|
|
|
|
|
|
- if (texture_)
|
|
|
+ if (size.x_ && size.y_)
|
|
|
{
|
|
|
- Vector2 invTextureSize(1.0f / (float)texture_->GetWidth(), 1.0f / (float)texture_->GetHeight());
|
|
|
+ float cLerpX = Clamp((float)x / (float)size.x_, 0.0f, 1.0f);
|
|
|
+ float cLerpY = Clamp((float)y / (float)size.y_, 0.0f, 1.0f);
|
|
|
|
|
|
- for (unsigned i = 0; i < quadCount_; ++i)
|
|
|
- {
|
|
|
- const UIQuad& quad = quads_->At(quadStart_ + i);
|
|
|
-
|
|
|
- Vector2 topLeftUV = Vector2((float)quad.leftUV_, (float)quad.topUV_) * invTextureSize;
|
|
|
- Vector2 bottomRightUV = Vector2((float)quad.rightUV_, (float)quad.bottomUV_) * invTextureSize;
|
|
|
-
|
|
|
- *dest++ = quad.topLeft_.x_; *dest++ = quad.topLeft_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.topLeftColor_; dest++;
|
|
|
- *dest++ = topLeftUV.x_; *dest++ = topLeftUV.y_;
|
|
|
-
|
|
|
- *dest++ = quad.topRight_.x_; *dest++ = quad.topRight_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.topRightColor_; dest++;
|
|
|
- *dest++ = bottomRightUV.x_; *dest++ = topLeftUV.y_;
|
|
|
-
|
|
|
- *dest++ = quad.bottomLeft_.x_; *dest++ = quad.bottomLeft_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.bottomLeftColor_; dest++;
|
|
|
- *dest++ = topLeftUV.x_; *dest++ = bottomRightUV.y_;
|
|
|
-
|
|
|
- *dest++ = quad.topRight_.x_; *dest++ = quad.topRight_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.topRightColor_; dest++;
|
|
|
- *dest++ = bottomRightUV.x_; *dest++ = topLeftUV.y_;
|
|
|
-
|
|
|
- *dest++ = quad.bottomRight_.x_; *dest++ = quad.bottomRight_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.bottomRightColor_; dest++;
|
|
|
- *dest++ = bottomRightUV.x_; *dest++ = bottomRightUV.y_;
|
|
|
-
|
|
|
- *dest++ = quad.bottomLeft_.x_; *dest++ = quad.bottomLeft_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.bottomLeftColor_; dest++;
|
|
|
- *dest++ = topLeftUV.x_; *dest++ = bottomRightUV.y_;
|
|
|
- }
|
|
|
+ Color topColor = element_->GetColor(C_TOPLEFT).Lerp(element_->GetColor(C_TOPRIGHT), cLerpX);
|
|
|
+ Color bottomColor = element_->GetColor(C_BOTTOMLEFT).Lerp(element_->GetColor(C_BOTTOMRIGHT), cLerpX);
|
|
|
+ Color color = topColor.Lerp(bottomColor, cLerpY);
|
|
|
+ color.a_ *= element_->GetDerivedOpacity();
|
|
|
+ return color.ToUInt();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- for (unsigned i = 0; i < quadCount_; ++i)
|
|
|
- {
|
|
|
- const UIQuad& quad = quads_->At(quadStart_ + i);
|
|
|
-
|
|
|
- *dest++ = quad.topLeft_.x_; *dest++ = quad.topLeft_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.topLeftColor_; dest++;
|
|
|
- dest += 2; // Jump over unused UV coordinates
|
|
|
-
|
|
|
- *dest++ = quad.topRight_.x_; *dest++ = quad.topRight_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.topRightColor_; dest++;
|
|
|
- dest += 2;
|
|
|
-
|
|
|
- *dest++ = quad.bottomLeft_.x_; *dest++ = quad.bottomLeft_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.bottomLeftColor_; dest++;
|
|
|
- dest += 2;
|
|
|
-
|
|
|
- *dest++ = quad.topRight_.x_; *dest++ = quad.topRight_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.topRightColor_; dest++;
|
|
|
- dest += 2;
|
|
|
-
|
|
|
- *dest++ = quad.bottomRight_.x_; *dest++ = quad.bottomRight_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.bottomRightColor_; dest++;
|
|
|
- dest += 2;
|
|
|
-
|
|
|
- *dest++ = quad.bottomLeft_.x_; *dest++ = quad.bottomLeft_.y_; *dest++ = 0.0f;
|
|
|
- *((unsigned*)dest) = quad.bottomLeftColor_; dest++;
|
|
|
- dest += 2;
|
|
|
- }
|
|
|
+ Color color = element_->GetColor(C_TOPLEFT);
|
|
|
+ color.a_ *= element_->GetDerivedOpacity();
|
|
|
+ return color.ToUInt();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void UIBatch::AddOrMerge(const UIBatch& batch, PODVector<UIBatch>& batches)
|
|
|
{
|
|
|
- if (!batch.quadCount_)
|
|
|
+ if (batch.vertexEnd_ == batch.vertexStart_)
|
|
|
return;
|
|
|
|
|
|
if (!batches.Empty() && batches.Back().Merge(batch))
|