diff --git a/3rdparty/box2d/CMakeLists.txt b/3rdparty/box2d/CMakeLists.txt index 6755de797921..8e1e066b851a 100644 --- a/3rdparty/box2d/CMakeLists.txt +++ b/3rdparty/box2d/CMakeLists.txt @@ -4,7 +4,7 @@ set(target_name ${lib_name}) project(${lib_name}) -FILE(GLOB_RECURSE box2d_sources *.h;*.c) +file(GLOB_RECURSE box2d_sources *.h;*.c) add_library(${target_name} ${box2d_sources}) diff --git a/core/2d/AnchoredSprite.cpp b/core/2d/AnchoredSprite.cpp index d71941b43935..65737c481654 100644 --- a/core/2d/AnchoredSprite.cpp +++ b/core/2d/AnchoredSprite.cpp @@ -186,10 +186,10 @@ void AnchoredSprite::setVertexCoords(const Rect& rect, V3F_C4F_T2F_Quad* outQuad const float y2 = y1 + rect.size.height; // Don't update Z. - outQuad->bl.vertices.set(x1, y1, 0.0f); - outQuad->br.vertices.set(x2, y1, 0.0f); - outQuad->tl.vertices.set(x1, y2, 0.0f); - outQuad->tr.vertices.set(x2, y2, 0.0f); + outQuad->bl.position.set(x1, y1, 0.0f); + outQuad->br.position.set(x2, y1, 0.0f); + outQuad->tl.position.set(x1, y2, 0.0f); + outQuad->tr.position.set(x2, y2, 0.0f); } } diff --git a/core/2d/AutoPolygon.cpp b/core/2d/AutoPolygon.cpp index e2020308da06..bb52d01a23fd 100644 --- a/core/2d/AutoPolygon.cpp +++ b/core/2d/AutoPolygon.cpp @@ -63,7 +63,7 @@ PolygonInfo::PolygonInfo(const PolygonInfo& other) : triangles(), _isVertsOwner( _filename = other._filename; _isVertsOwner = true; _rect = other._rect; - triangles.verts = new V3F_C4F_T2F[other.triangles.vertCount]; + triangles.verts = new V3F_T2F_C4F[other.triangles.vertCount]; triangles.indices = new unsigned short[other.triangles.indexCount]; AXASSERT(triangles.verts && triangles.indices, "not enough memory"); triangles.vertCount = other.triangles.vertCount; @@ -80,7 +80,7 @@ PolygonInfo& PolygonInfo::operator=(const PolygonInfo& other) _filename = other._filename; _isVertsOwner = true; _rect = other._rect; - triangles.verts = new V3F_C4F_T2F[other.triangles.vertCount]; + triangles.verts = new V3F_T2F_C4F[other.triangles.vertCount]; triangles.indices = new unsigned short[other.triangles.indexCount]; AXASSERT(triangles.verts && triangles.indices, "not enough memory"); triangles.vertCount = other.triangles.vertCount; @@ -104,7 +104,7 @@ void PolygonInfo::setQuad(V3F_C4F_T2F_Quad* quad) triangles.indices = quadIndices9; triangles.vertCount = 4; triangles.indexCount = 6; - triangles.verts = (V3F_C4F_T2F*)quad; + triangles.verts = (V3F_T2F_C4F*)quad; } void PolygonInfo::setQuads(V3F_C4F_T2F_Quad* quad, int numberOfQuads) @@ -116,7 +116,7 @@ void PolygonInfo::setQuads(V3F_C4F_T2F_Quad* quad, int numberOfQuads) triangles.indices = quadIndices9; triangles.vertCount = 4 * numberOfQuads; triangles.indexCount = 6 * numberOfQuads; - triangles.verts = (V3F_C4F_T2F*)quad; + triangles.verts = (V3F_T2F_C4F*)quad; } void PolygonInfo::setTriangles(const TrianglesCommand::Triangles& other) @@ -159,13 +159,13 @@ unsigned int PolygonInfo::getTrianglesCount() const float PolygonInfo::getArea() const { float area = 0; - V3F_C4F_T2F* verts = triangles.verts; + V3F_T2F_C4F* verts = triangles.verts; unsigned short* indices = triangles.indices; for (unsigned int i = 0; i < triangles.indexCount; i += 3) { - auto A = verts[indices[i]].vertices; - auto B = verts[indices[i + 1]].vertices; - auto C = verts[indices[i + 2]].vertices; + auto A = verts[indices[i]].position; + auto B = verts[indices[i + 1]].position; + auto C = verts[indices[i + 2]].position; area += (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y)) / 2; } return area; @@ -610,7 +610,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& po std::vector tris = cdt.GetTriangles(); axstd::pod_vector indices(tris.size() * 3); - axstd::pod_vector verts; + axstd::pod_vector verts; verts.reserve(indices.size() / 2); // we won't know the size of verts until we process all of the triangles! unsigned short idx = 0; @@ -627,7 +627,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& po auto length = vdx; for (j = 0; j < length; j++) { - if (verts[j].vertices == v3) + if (verts[j].position == v3) { found = true; break; @@ -640,10 +640,8 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& po } else { - // vert does not exist yet, so we need to create a new one, - auto c = Color::WHITE; - auto t2f = Tex2F(0, 0); // don't worry about tex coords now, we calculate that later - verts.push_back(V3F_C4F_T2F{v3, c, t2f}); + // vert does not exist yet, so we need to create a new one + verts.emplace_back(v3, Vec2::ZERO, Color::WHITE); indices[idx++] = vdx++;; } } @@ -656,7 +654,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& po return triangles; } -void AutoPolygon::calculateUV(const Rect& rect, V3F_C4F_T2F* verts, ssize_t count) +void AutoPolygon::calculateUV(const Rect& rect, V3F_T2F_C4F* verts, ssize_t count) { /* whole texture UV coordination @@ -683,10 +681,10 @@ void AutoPolygon::calculateUV(const Rect& rect, V3F_C4F_T2F* verts, ssize_t coun for (auto i = verts; i != end; ++i) { // for every point, offset with the center point - float u = (i->vertices.x * _scaleFactor + rect.origin.x) / texWidth; - float v = (rect.origin.y + rect.size.height - i->vertices.y * _scaleFactor) / texHeight; - i->texCoords.u = u; - i->texCoords.v = v; + float u = (i->position.x * _scaleFactor + rect.origin.x) / texWidth; + float v = (rect.origin.y + rect.size.height - i->position.y * _scaleFactor) / texHeight; + i->texCoord.u = u; + i->texCoord.v = v; } } diff --git a/core/2d/AutoPolygon.h b/core/2d/AutoPolygon.h index 7f6470866153..dccf7ffdc95b 100644 --- a/core/2d/AutoPolygon.h +++ b/core/2d/AutoPolygon.h @@ -225,7 +225,7 @@ class AX_DLL AutoPolygon * ap.calculateUV(rect, myPolygons.verts, 20); * @endcode */ - void calculateUV(const Rect& rect, V3F_C4F_T2F* verts, ssize_t count); + void calculateUV(const Rect& rect, V3F_T2F_C4F* verts, ssize_t count); /** * a helper function, packing trace, reduce, expand, triangulate and calculate uv in one function diff --git a/core/2d/CameraBackgroundBrush.cpp b/core/2d/CameraBackgroundBrush.cpp index e37d359ef9fc..b253077e7948 100644 --- a/core/2d/CameraBackgroundBrush.cpp +++ b/core/2d/CameraBackgroundBrush.cpp @@ -133,17 +133,17 @@ bool CameraBackgroundDepthBrush::init() pipelineDescriptor.programState = _programState; _vertices.resize(4); - _vertices[0].vertices = Vec3(-1, -1, 0); - _vertices[1].vertices = Vec3(1, -1, 0); - _vertices[2].vertices = Vec3(1, 1, 0); - _vertices[3].vertices = Vec3(-1, 1, 0); + _vertices[0].position = Vec3(-1, -1, 0); + _vertices[1].position = Vec3(1, -1, 0); + _vertices[2].position = Vec3(1, 1, 0); + _vertices[3].position = Vec3(-1, 1, 0); - _vertices[0].colors = _vertices[1].colors = _vertices[2].colors = _vertices[3].colors = Color(0, 0, 0, 1); + _vertices[0].color = _vertices[1].color = _vertices[2].color = _vertices[3].color = Color(0, 0, 0, 1); - _vertices[0].texCoords = Tex2F(0, 0); - _vertices[1].texCoords = Tex2F(1, 0); - _vertices[2].texCoords = Tex2F(1, 1); - _vertices[3].texCoords = Tex2F(0, 1); + _vertices[0].texCoord = Tex2F(0, 0); + _vertices[1].texCoord = Tex2F(1, 0); + _vertices[2].texCoord = Tex2F(1, 1); + _vertices[3].texCoord = Tex2F(0, 1); _customCommand.setBeforeCallback(AX_CALLBACK_0(CameraBackgroundDepthBrush::onBeforeDraw, this)); _customCommand.setAfterCallback(AX_CALLBACK_0(CameraBackgroundDepthBrush::onAfterDraw, this)); @@ -235,7 +235,7 @@ void CameraBackgroundColorBrush::setColor(const Color& color) { for (auto&& vert : _vertices) { - vert.colors = color; + vert.color = color; } _customCommand.updateVertexBuffer(_vertices.data(), sizeof(_vertices[0]) * _vertices.size()); } diff --git a/core/2d/CameraBackgroundBrush.h b/core/2d/CameraBackgroundBrush.h index 35abe37c159e..a54e5c2328aa 100644 --- a/core/2d/CameraBackgroundBrush.h +++ b/core/2d/CameraBackgroundBrush.h @@ -179,7 +179,7 @@ class AX_DLL CameraBackgroundDepthBrush : public CameraBackgroundBrush CustomCommand _customCommand; bool _clearColor; - std::vector _vertices; + std::vector _vertices; struct { uint32_t stencilWriteMask = 0; diff --git a/core/2d/DrawNode.cpp b/core/2d/DrawNode.cpp index 65a3abe249bb..0a089dbed594 100644 --- a/core/2d/DrawNode.cpp +++ b/core/2d/DrawNode.cpp @@ -72,7 +72,7 @@ static bool isConvex(const Vec2* verts, int count) return true; // is convex } -static V2F_C4F_T2F* expandBufferAndGetPointer(axstd::pod_vector& buffer, size_t count) +static V2F_T2F_C4F* expandBufferAndGetPointer(axstd::pod_vector& buffer, size_t count) { size_t oldSize = buffer.size(); buffer.expand(count); @@ -235,7 +235,7 @@ void DrawNode::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) } } -static void udpateCommand(CustomCommand& cmd, const axstd::pod_vector& buffer) +static void udpateCommand(CustomCommand& cmd, const axstd::pod_vector& buffer) { if (buffer.empty()) { @@ -244,8 +244,8 @@ static void udpateCommand(CustomCommand& cmd, const axstd::pod_vectorGetPoint(2); V2F_C4F_T2F_Triangle triangle = { - {Vec2(vec1->x, vec1->y), fillColor, Vec2::ZERO}, - {Vec2(vec2->x, vec2->y), fillColor, Vec2::ZERO}, - {Vec2(vec3->x, vec3->y), fillColor, Vec2::ZERO}, + {Vec2(vec1->x, vec1->y), Vec2::ZERO, fillColor}, + {Vec2(vec2->x, vec2->y), Vec2::ZERO, fillColor}, + {Vec2(vec3->x, vec3->y), Vec2::ZERO, fillColor}, }; triangleList.emplace_back(triangle); // use it for drawing later } @@ -904,9 +904,9 @@ void DrawNode::_drawPolygon(const Vec2* verts, for (unsigned int i = 0; i < count - 2; i++) { triangles[ii++] = { - {_vertices[0], fillColor, Vec2::ZERO}, - {_vertices[i + 1], fillColor, Vec2::ZERO}, - {_vertices[i + 2], fillColor, Vec2::ZERO}, + {_vertices[0], Vec2::ZERO, fillColor}, + {_vertices[i + 1], Vec2::ZERO, fillColor}, + {_vertices[i + 2], Vec2::ZERO, fillColor}, }; } } @@ -935,38 +935,38 @@ void DrawNode::_drawPolygon(const Vec2* verts, { triangles[ii++] = { - {v0, borderColor, -(n + t)}, - {v1, borderColor, n - t}, - {v2, borderColor, -n}, + {v0, -(n + t), borderColor}, + {v1, n - t, borderColor}, + {v2, -n, borderColor}, }; triangles[ii++] = { - {v3, borderColor, n}, - {v1, borderColor, n - t}, - {v2, borderColor, -n}, + {v3, n, borderColor}, + {v1, n - t, borderColor}, + {v2, -n, borderColor}, }; } triangles[ii++] = { - {v3, borderColor, n}, - {v4, borderColor, -n}, - {v2, borderColor, -n}, + {v3, n, borderColor}, + {v4, -n, borderColor}, + {v2, -n, borderColor}, }; triangles[ii++] = { - {v3, borderColor, n}, - {v4, borderColor, -n}, - {v5, borderColor, n}, + {v3, n, borderColor}, + {v4, -n, borderColor}, + {v5, n, borderColor}, }; { triangles[ii++] = { - {v6, borderColor, t - n}, - {v4, borderColor, -n}, - {v5, borderColor, n}, + {v6, t - n, borderColor}, + {v4, -n, borderColor}, + {v5, n, borderColor}, }; triangles[ii++] = { - {v6, borderColor, t - n}, - {v7, borderColor, t + n}, - {v5, borderColor, n}, + {v6, t - n, borderColor}, + {v7, t + n, borderColor}, + {v5, n, borderColor}, }; } } @@ -1009,9 +1009,9 @@ void DrawNode::_drawPolygon(const Vec2* verts, Vec2 outer0 = v0 + offset0 * thickness; Vec2 outer1 = v1 + offset1 * thickness; - triangles[ii++] = {{inner0, borderColor, -n0}, {inner1, borderColor, -n0}, {outer1, borderColor, n0}}; + triangles[ii++] = {{inner0, -n0, borderColor}, {inner1, -n0, borderColor}, {outer1, n0, borderColor}}; - triangles[ii++] = {{inner0, borderColor, -n0}, {outer0, borderColor, n0}, {outer1, borderColor, n0}}; + triangles[ii++] = {{inner0, -n0, borderColor}, {outer0, n0, borderColor}, {outer1, n0, borderColor}}; } } } @@ -1036,12 +1036,12 @@ void DrawNode::_drawPoly(const Vec2* verts, int ii = 0; for (unsigned int i = 0; i < count - 1; i++) { - line[ii++] = {_vertices[i], color, Vec2::ZERO}; - line[ii++] = {_vertices[i + 1], color, Vec2::ZERO}; + line[ii++] = {_vertices[i], Vec2::ZERO, color}; + line[ii++] = {_vertices[i + 1], Vec2::ZERO, color}; } if (closedPolygon) { - line[ii++] = {_vertices[count - 1], color, Vec2::ZERO}; + line[ii++] = {_vertices[count - 1], Vec2::ZERO, color}; line[ii++] = line[0]; } } @@ -1066,8 +1066,8 @@ void DrawNode::_drawSegment(const Vec2& from, auto line = expandBufferAndGetPointer(_lines, 2); _linesDirty = true; - line[0] = {vertices[0], color, Vec2::ZERO}; - line[1] = {vertices[1], color, Vec2::ZERO}; + line[0] = {vertices[0], Vec2::ZERO, color}; + line[1] = {vertices[1], Vec2::ZERO, color}; } else { @@ -1099,29 +1099,29 @@ void DrawNode::_drawSegment(const Vec2& from, case DrawNode::EndType::Square: triangles[ii++] = { - {v0, color, Vec2::ZERO}, - {v1, color, -n}, - {v2, color, n}, + {v0, Vec2::ZERO, color}, + {v1, -n, color}, + {v2, n, color}, }; triangles[ii++] = { - {v3, color, n}, - {v1, color, Vec2::ZERO}, - {v2, color, -n}, + {v3, n, color}, + {v1, Vec2::ZERO, color}, + {v2, -n, color}, }; break; case DrawNode::EndType::Round: triangles[ii++] = { - {v0, color, -(n + t)}, - {v1, color, n - t}, - {v2, color, -n}, + {v0, -(n + t), color}, + {v1, n - t, color}, + {v2, -n, color}, }; triangles[ii++] = { - {v3, color, n}, - {v1, color, n - t}, - {v2, color, -n}, + {v3, n, color}, + {v1, n - t, color}, + {v2, -n, color}, }; break; @@ -1131,15 +1131,15 @@ void DrawNode::_drawSegment(const Vec2& from, // BODY triangles[ii++] = { - {v3, color, n}, - {v4, color, -n}, - {v2, color, -n}, + {v3, n, color}, + {v4, -n, color}, + {v2, -n, color}, }; triangles[ii++] = { - {v3, color, n}, - {v4, color, -n}, - {v5, color, n}, + {v3, n, color}, + {v4, -n, color}, + {v5, n, color}, }; switch (etStart) @@ -1149,29 +1149,29 @@ void DrawNode::_drawSegment(const Vec2& from, case DrawNode::EndType::Square: triangles[ii++] = { - {v6, color, Vec2::ZERO}, - {v4, color, -n}, - {v5, color, n}, + {v6, Vec2::ZERO, color}, + {v4, -n, color}, + {v5, n, color}, }; triangles[ii++] = { - {v6, color, -n}, - {v7, color, Vec2::ZERO}, - {v5, color, n}, + {v6, -n, color}, + {v7, Vec2::ZERO, color}, + {v5, n, color}, }; break; case DrawNode::EndType::Round: triangles[ii++] = { - {v6, color, t - n}, - {v4, color, -n}, - {v5, color, n}, + {v6, t - n, color}, + {v4, -n, color}, + {v5, n, color}, }; triangles[ii++] = { - {v6, color, t - n}, - {v7, color, t + n}, - {v5, color, n}, + {v6, t - n, color}, + {v7, t + n, color}, + {v5, n, color}, }; break; @@ -1187,10 +1187,10 @@ void DrawNode::_drawDot(const Vec2& pos, float radius, const Color& color) auto triangles = reinterpret_cast(expandBufferAndGetPointer(_triangles, vertex_count)); _trianglesDirty = true; - V2F_C4F_T2F a = {Vec2(pos.x - radius, pos.y - radius), color, Vec2(-1.0f, -1.0f)}; - V2F_C4F_T2F b = {Vec2(pos.x - radius, pos.y + radius), color, Vec2(-1.0f, 1.0f)}; - V2F_C4F_T2F c = {Vec2(pos.x + radius, pos.y + radius), color, Vec2(1.0f, 1.0f)}; - V2F_C4F_T2F d = {Vec2(pos.x + radius, pos.y - radius), color, Vec2(1.0f, -1.0f)}; + V2F_T2F_C4F a = {Vec2(pos.x - radius, pos.y - radius), Vec2(-1.0f, -1.0f), color}; + V2F_T2F_C4F b = {Vec2(pos.x - radius, pos.y + radius), Vec2(-1.0f, 1.0f), color}; + V2F_T2F_C4F c = {Vec2(pos.x + radius, pos.y + radius), Vec2(1.0f, 1.0f), color}; + V2F_T2F_C4F d = {Vec2(pos.x + radius, pos.y - radius), Vec2(1.0f, -1.0f), color}; triangles[0] = {a, b, c}; triangles[1] = {a, c, d}; @@ -1253,9 +1253,9 @@ void DrawNode::_drawTriangle(Vec2* vertices3, auto triangles = reinterpret_cast(expandBufferAndGetPointer(_triangles, vertex_count)); _trianglesDirty = true; - triangles[0] = {{vertices3[0], fillColor, Vec2::ZERO}, - {vertices3[1], fillColor, Vec2::ZERO}, - {vertices3[2], fillColor, Vec2::ZERO}}; + triangles[0] = {{vertices3[0], Vec2::ZERO, fillColor}, + {vertices3[1], Vec2::ZERO, fillColor}, + {vertices3[2], Vec2::ZERO, fillColor}}; } } @@ -1332,7 +1332,7 @@ void DrawNode::_drawPoints(const Vec2* position, for (unsigned int i = 0; i < numberOfPoints; i++) { - *(point + i) = {position[i], color, Vec2(pointSize, 0.0f)}; + *(point + i) = {position[i], Vec2(pointSize, 0.0f), color}; } } @@ -1382,7 +1382,7 @@ void DrawNode::_drawPoint(const Vec2& position, auto point = expandBufferAndGetPointer(_points, 1); _pointsDirty = true; - *point = {position, color, Vec2(pointSize, 0.0f)}; + *point = {position, Vec2(pointSize, 0.0f), color}; } } diff --git a/core/2d/DrawNode.h b/core/2d/DrawNode.h index 0cf8942ae2df..6d0ab2b02eb9 100644 --- a/core/2d/DrawNode.h +++ b/core/2d/DrawNode.h @@ -577,9 +577,9 @@ class AX_DLL DrawNode : public Node CustomCommand _customCommandPoint; CustomCommand _customCommandLine; - axstd::pod_vector _triangles; - axstd::pod_vector _points; - axstd::pod_vector _lines; + axstd::pod_vector _triangles; + axstd::pod_vector _points; + axstd::pod_vector _lines; private: diff --git a/core/2d/FastTMXLayer.cpp b/core/2d/FastTMXLayer.cpp index 66cb70936fba..4438c832f70b 100644 --- a/core/2d/FastTMXLayer.cpp +++ b/core/2d/FastTMXLayer.cpp @@ -275,7 +275,7 @@ void FastTMXLayer::updateTiles(const Rect& culledRect) void FastTMXLayer::updateVertexBuffer() { - unsigned int vertexBufferSize = (unsigned int)(sizeof(V3F_C4F_T2F) * _totalQuads.size() * 4); + unsigned int vertexBufferSize = (unsigned int)(sizeof(V3F_T2F_C4F) * _totalQuads.size() * 4); if (!_vertexBuffer) { _vertexBuffer = backend::DriverBase::getInstance()->newBuffer(vertexBufferSize, backend::BufferType::VERTEX, backend::BufferUsage::STATIC); @@ -569,33 +569,33 @@ void FastTMXLayer::updateTotalQuads() if (tileGID & kTMXTileDiagonalFlag) { // FIXME: not working correctly - quad.bl.vertices.x = left; - quad.bl.vertices.y = bottom; - quad.bl.vertices.z = z; - quad.br.vertices.x = left; - quad.br.vertices.y = top; - quad.br.vertices.z = z; - quad.tl.vertices.x = right; - quad.tl.vertices.y = bottom; - quad.tl.vertices.z = z; - quad.tr.vertices.x = right; - quad.tr.vertices.y = top; - quad.tr.vertices.z = z; + quad.bl.position.x = left; + quad.bl.position.y = bottom; + quad.bl.position.z = z; + quad.br.position.x = left; + quad.br.position.y = top; + quad.br.position.z = z; + quad.tl.position.x = right; + quad.tl.position.y = bottom; + quad.tl.position.z = z; + quad.tr.position.x = right; + quad.tr.position.y = top; + quad.tr.position.z = z; } else { - quad.bl.vertices.x = left; - quad.bl.vertices.y = bottom; - quad.bl.vertices.z = z; - quad.br.vertices.x = right; - quad.br.vertices.y = bottom; - quad.br.vertices.z = z; - quad.tl.vertices.x = left; - quad.tl.vertices.y = top; - quad.tl.vertices.z = z; - quad.tr.vertices.x = right; - quad.tr.vertices.y = top; - quad.tr.vertices.z = z; + quad.bl.position.x = left; + quad.bl.position.y = bottom; + quad.bl.position.z = z; + quad.br.position.x = right; + quad.br.position.y = bottom; + quad.br.position.z = z; + quad.tl.position.x = left; + quad.tl.position.y = top; + quad.tl.position.z = z; + quad.tr.position.x = right; + quad.tr.position.y = top; + quad.tr.position.z = z; } // texcoords @@ -609,19 +609,19 @@ void FastTMXLayer::updateTotalQuads() float ptx = 1.0 / (_tileSet->_imageSize.x * tileSize.x); float pty = 1.0 / (_tileSet->_imageSize.y * tileSize.y); - quad.bl.texCoords.u = left + ptx; - quad.bl.texCoords.v = bottom + pty; - quad.br.texCoords.u = right - ptx; - quad.br.texCoords.v = bottom + pty; - quad.tl.texCoords.u = left + ptx; - quad.tl.texCoords.v = top - pty; - quad.tr.texCoords.u = right - ptx; - quad.tr.texCoords.v = top - pty; - - quad.bl.colors = color; - quad.br.colors = color; - quad.tl.colors = color; - quad.tr.colors = color; + quad.bl.texCoord.u = left + ptx; + quad.bl.texCoord.v = bottom + pty; + quad.br.texCoord.u = right - ptx; + quad.br.texCoord.v = bottom + pty; + quad.tl.texCoord.u = left + ptx; + quad.tl.texCoord.v = top - pty; + quad.tr.texCoord.u = right - ptx; + quad.tr.texCoord.v = top - pty; + + quad.bl.color = color; + quad.br.color = color; + quad.tl.color = color; + quad.tr.color = color; ++quadIndex; } diff --git a/core/2d/Label.cpp b/core/2d/Label.cpp index 199d253af5cb..179bf4b8c3d8 100644 --- a/core/2d/Label.cpp +++ b/core/2d/Label.cpp @@ -136,10 +136,10 @@ class LabelLetter : public Sprite float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; - _quad.bl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ); - _quad.br.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ); - _quad.tl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ); - _quad.tr.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ); + _quad.bl.position.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ); + _quad.br.position.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ); + _quad.tl.position.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ); + _quad.tr.position.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ); if (_textureAtlas) { @@ -173,10 +173,10 @@ class LabelLetter : public Sprite color.g *= displayedOpacity / 255.0f; color.b *= displayedOpacity / 255.0f; } - _quad.bl.colors = color; - _quad.br.colors = color; - _quad.tl.colors = color; - _quad.tr.colors = color; + _quad.bl.color = color; + _quad.br.color = color; + _quad.tl.color = color; + _quad.tr.color = color; _textureAtlas->updateQuad(_quad, _atlasIndex); } @@ -619,7 +619,7 @@ void Label::reset() _hAlignment = TextHAlignment::LEFT; _vAlignment = TextVAlignment::TOP; - _effectColorF = Color::BLACK; + _effectColor = Color::BLACK; _textColor = Color4B::WHITE; _textColorF = Color::WHITE; setColor(Color3B::WHITE); @@ -1357,10 +1357,10 @@ void Label::enableGlow(const Color4B& glowColor) _contentDirty = true; } _currLabelEffect = LabelEffect::GLOW; - _effectColorF.r = glowColor.r / 255.0f; - _effectColorF.g = glowColor.g / 255.0f; - _effectColorF.b = glowColor.b / 255.0f; - _effectColorF.a = glowColor.a / 255.0f; + _effectColor.r = glowColor.r / 255.0f; + _effectColor.g = glowColor.g / 255.0f; + _effectColor.b = glowColor.b / 255.0f; + _effectColor.a = glowColor.a / 255.0f; updateShaderProgram(); } } @@ -1374,10 +1374,10 @@ void Label::enableOutline(const Color4B& outlineColor, int outlineSize /* = -1 * { if (_currentLabelType == LabelType::TTF) { - _effectColorF.r = outlineColor.r / 255.0f; - _effectColorF.g = outlineColor.g / 255.0f; - _effectColorF.b = outlineColor.b / 255.0f; - _effectColorF.a = outlineColor.a / 255.0f; + _effectColor.r = outlineColor.r / 255.0f; + _effectColor.g = outlineColor.g / 255.0f; + _effectColor.b = outlineColor.b / 255.0f; + _effectColor.a = outlineColor.a / 255.0f; if (!_useDistanceField) { // not SDF, request font atlas from feetype @@ -1394,12 +1394,12 @@ void Label::enableOutline(const Color4B& outlineColor, int outlineSize /* = -1 * updateShaderProgram(); } } - else if (_effectColorF != outlineColor || _outlineSize != outlineSize) + else if (_effectColor != outlineColor || _outlineSize != outlineSize) { - _effectColorF.r = outlineColor.r / 255.f; - _effectColorF.g = outlineColor.g / 255.f; - _effectColorF.b = outlineColor.b / 255.f; - _effectColorF.a = outlineColor.a / 255.f; + _effectColor.r = outlineColor.r / 255.f; + _effectColor.g = outlineColor.g / 255.f; + _effectColor.b = outlineColor.b / 255.f; + _effectColor.a = outlineColor.a / 255.f; _currLabelEffect = LabelEffect::OUTLINE; _contentDirty = true; } @@ -1428,7 +1428,7 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */, auto fontDef = _getFontDefinition(); if (_shadowNode) { - if (shadowColor != _shadowColor4F) + if (shadowColor != _shadowColor) { _shadowNode->release(); _shadowNode = nullptr; @@ -1445,10 +1445,10 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */, } } - _shadowColor4F.r = shadowColor.r / 255.0f; - _shadowColor4F.g = shadowColor.g / 255.0f; - _shadowColor4F.b = shadowColor.b / 255.0f; - _shadowColor4F.a = shadowColor.a / 255.0f; + _shadowColor.r = shadowColor.r / 255.0f; + _shadowColor.g = shadowColor.g / 255.0f; + _shadowColor.b = shadowColor.b / 255.0f; + _shadowColor.a = shadowColor.a / 255.0f; if (_currentLabelType == LabelType::BMFONT || _currentLabelType == LabelType::CHARMAP) { @@ -1813,14 +1813,13 @@ void Label::updateEffectUniforms(BatchCommand& batch, case LabelEffect::OUTLINE: { int effectType = 0; - Vec4 effectColor(_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a); + Vec4 effectColor(_effectColor.r, _effectColor.g, _effectColor.b, _effectColor.a); // draw shadow if (_shadowEnabled) { effectType = 2; - Vec4 shadowColor = Vec4(_shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); auto* programStateShadow = batch.shadowCommand.getPipelineDescriptor().programState; - programStateShadow->setUniform(_effectColorLocation, &shadowColor, sizeof(Vec4)); + programStateShadow->setUniform(_effectColorLocation, &_shadowColor, sizeof(ax::Color)); programStateShadow->setUniform(_effectTypeLocation, &effectType, sizeof(effectType)); batch.shadowCommand.init(_globalZOrder); renderer->addCommand(&batch.shadowCommand); @@ -1830,7 +1829,7 @@ void Label::updateEffectUniforms(BatchCommand& batch, { // distance outline effectColor.w = _outlineSize > 0 ? _outlineSize : _fontConfig.outlineSize; batch.textCommand.getPipelineDescriptor().programState->setUniform(_effectColorLocation, &effectColor, - sizeof(Vec4)); + sizeof(ax::Color)); } else { @@ -1860,9 +1859,8 @@ void Label::updateEffectUniforms(BatchCommand& batch, { if (_shadowEnabled) { - Vec4 shadowColor = Vec4(_shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); auto* programStateShadow = batch.shadowCommand.getPipelineDescriptor().programState; - programStateShadow->setUniform(_textColorLocation, &shadowColor, sizeof(Vec4)); + programStateShadow->setUniform(_textColorLocation, &_shadowColor, sizeof(Vec4)); batch.shadowCommand.init(_globalZOrder); renderer->addCommand(&batch.shadowCommand); } @@ -1873,16 +1871,14 @@ void Label::updateEffectUniforms(BatchCommand& batch, // draw shadow if (_shadowEnabled) { - Vec4 shadowColor = Vec4(_shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); auto* programStateShadow = batch.shadowCommand.getPipelineDescriptor().programState; - programStateShadow->setUniform(_textColorLocation, &shadowColor, sizeof(Vec4)); - programStateShadow->setUniform(_effectColorLocation, &shadowColor, sizeof(Vec4)); + programStateShadow->setUniform(_textColorLocation, &_shadowColor, sizeof(Vec4)); + programStateShadow->setUniform(_effectColorLocation, &_shadowColor, sizeof(Vec4)); batch.shadowCommand.init(_globalZOrder); renderer->addCommand(&batch.shadowCommand); } - Vec4 effectColor(_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a); - batch.textCommand.getPipelineDescriptor().programState->setUniform(_effectColorLocation, &effectColor, + batch.textCommand.getPipelineDescriptor().programState->setUniform(_effectColorLocation, &_effectColor, sizeof(Vec4)); } break; @@ -1896,8 +1892,8 @@ void Label::updateEffectUniforms(BatchCommand& batch, { Color3B oldColor = _realColor; uint8_t oldOPacity = _displayedOpacity; - _displayedOpacity = _shadowColor4F.a * (oldOPacity / 255.0f) * 255; - setColor(Color3B(_shadowColor4F)); + _displayedOpacity = _shadowColor.a * (oldOPacity / 255.0f) * 255; + setColor(Color3B(_shadowColor)); batch.shadowCommand.updateVertexBuffer( textureAtlas->getQuads(), (unsigned int)(textureAtlas->getTotalQuads() * sizeof(V3F_C4F_T2F_Quad))); batch.shadowCommand.init(_globalZOrder); @@ -2400,10 +2396,10 @@ void Label::updateColor() for (int index = 0; index < count; ++index) { - quads[index].bl.colors = color; - quads[index].br.colors = color; - quads[index].tl.colors = color; - quads[index].tr.colors = color; + quads[index].bl.color = color; + quads[index].br.color = color; + quads[index].tl.color = color; + quads[index].tr.color = color; textureAtlas->updateQuad(quads[index], index); } } @@ -2494,10 +2490,10 @@ FontDefinition Label::_getFontDefinition() const { systemFontDef._stroke._strokeEnabled = true; systemFontDef._stroke._strokeSize = _outlineSize; - systemFontDef._stroke._strokeColor.r = _effectColorF.r * 255; - systemFontDef._stroke._strokeColor.g = _effectColorF.g * 255; - systemFontDef._stroke._strokeColor.b = _effectColorF.b * 255; - systemFontDef._stroke._strokeAlpha = _effectColorF.a * 255; + systemFontDef._stroke._strokeColor.r = _effectColor.r * 255.f; + systemFontDef._stroke._strokeColor.g = _effectColor.g * 255.f; + systemFontDef._stroke._strokeColor.b = _effectColor.b * 255.f; + systemFontDef._stroke._strokeAlpha = _effectColor.a * 255.f; } else { diff --git a/core/2d/Label.h b/core/2d/Label.h index 212aa698091b..f85cd65126d3 100644 --- a/core/2d/Label.h +++ b/core/2d/Label.h @@ -474,7 +474,7 @@ class AX_DLL Label : public Node, public LabelProtocol, public BlendProtocol /** * Return the shadow effect color value. */ - Color getShadowColor() const { return _shadowColor4F; } + Color getShadowColor() const { return _shadowColor; } /** * Return the outline effect size value. @@ -489,7 +489,7 @@ class AX_DLL Label : public Node, public LabelProtocol, public BlendProtocol /** * Return current effect color value. */ - Color getEffectColor() const { return _effectColorF; } + Color getEffectColor() const { return _effectColor; } /** Sets the Label's text horizontal alignment.*/ void setAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment, _vAlignment); } @@ -874,9 +874,9 @@ class AX_DLL Label : public Node, public LabelProtocol, public BlendProtocol Rect _bmRect; Rect _reusedRect; - Color _effectColorF; + Color _effectColor; Color _textColorF; - Color _shadowColor4F; + Color _shadowColor; Mat4 _shadowTransform; std::u32string _utf32Text; diff --git a/core/2d/LabelAtlas.cpp b/core/2d/LabelAtlas.cpp index 045721a00d45..153199646625 100644 --- a/core/2d/LabelAtlas.cpp +++ b/core/2d/LabelAtlas.cpp @@ -182,32 +182,32 @@ void LabelAtlas::updateAtlasValues() float bottom = top + itemHeightInPixels / textureHigh; #endif // ! AX_FIX_ARTIFACTS_BY_STRECHING_TEXEL - quads[i].tl.texCoords.u = left; - quads[i].tl.texCoords.v = top; - quads[i].tr.texCoords.u = right; - quads[i].tr.texCoords.v = top; - quads[i].bl.texCoords.u = left; - quads[i].bl.texCoords.v = bottom; - quads[i].br.texCoords.u = right; - quads[i].br.texCoords.v = bottom; - - quads[i].bl.vertices.x = (float)(i * _itemWidth); - quads[i].bl.vertices.y = 0; - quads[i].bl.vertices.z = 0.0f; - quads[i].br.vertices.x = (float)(i * _itemWidth + _itemWidth); - quads[i].br.vertices.y = 0; - quads[i].br.vertices.z = 0.0f; - quads[i].tl.vertices.x = (float)(i * _itemWidth); - quads[i].tl.vertices.y = (float)(_itemHeight); - quads[i].tl.vertices.z = 0.0f; - quads[i].tr.vertices.x = (float)(i * _itemWidth + _itemWidth); - quads[i].tr.vertices.y = (float)(_itemHeight); - quads[i].tr.vertices.z = 0.0f; + quads[i].tl.texCoord.u = left; + quads[i].tl.texCoord.v = top; + quads[i].tr.texCoord.u = right; + quads[i].tr.texCoord.v = top; + quads[i].bl.texCoord.u = left; + quads[i].bl.texCoord.v = bottom; + quads[i].br.texCoord.u = right; + quads[i].br.texCoord.v = bottom; + + quads[i].bl.position.x = (float)(i * _itemWidth); + quads[i].bl.position.y = 0; + quads[i].bl.position.z = 0.0f; + quads[i].br.position.x = (float)(i * _itemWidth + _itemWidth); + quads[i].br.position.y = 0; + quads[i].br.position.z = 0.0f; + quads[i].tl.position.x = (float)(i * _itemWidth); + quads[i].tl.position.y = (float)(_itemHeight); + quads[i].tl.position.z = 0.0f; + quads[i].tr.position.x = (float)(i * _itemWidth + _itemWidth); + quads[i].tr.position.y = (float)(_itemHeight); + quads[i].tr.position.z = 0.0f; Color c(_displayedColor, _displayedOpacity / 255.0f); - quads[i].tl.colors = c; - quads[i].tr.colors = c; - quads[i].bl.colors = c; - quads[i].br.colors = c; + quads[i].tl.color = c; + quads[i].tr.color = c; + quads[i].bl.color = c; + quads[i].br.color = c; } if (n > 0) { @@ -259,10 +259,10 @@ void LabelAtlas::updateColor() ssize_t length = _string.length(); for (int index = 0; index < length; index++) { - quads[index].bl.colors = color; - quads[index].br.colors = color; - quads[index].tl.colors = color; - quads[index].tr.colors = color; + quads[index].bl.color = color; + quads[index].br.color = color; + quads[index].tl.color = color; + quads[index].tr.color = color; _textureAtlas->updateQuad(quads[index], index); } } diff --git a/core/2d/Layer.cpp b/core/2d/Layer.cpp index a7ba06e80bc5..50cea166aa74 100644 --- a/core/2d/Layer.cpp +++ b/core/2d/Layer.cpp @@ -238,25 +238,25 @@ void LayerGradient::updateColor() Color E(_endColor, _endOpacity * opacityf / 255.0f); // (-1, -1) - _quad.bl.colors.r = (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c))) * 255; - _quad.bl.colors.g = (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c))) * 255; - _quad.bl.colors.b = (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c))) * 255; - _quad.bl.colors.a = (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c))) * 255; + _quad.bl.color.r = (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c))) * 255; + _quad.bl.color.g = (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c))) * 255; + _quad.bl.color.b = (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c))) * 255; + _quad.bl.color.a = (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c))) * 255; // (1, -1) - _quad.br.colors.r = (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c))) * 255; - _quad.br.colors.g = (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c))) * 255; - _quad.br.colors.b = (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c))) * 255; - _quad.br.colors.a = (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c))) * 255; + _quad.br.color.r = (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c))) * 255; + _quad.br.color.g = (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c))) * 255; + _quad.br.color.b = (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c))) * 255; + _quad.br.color.a = (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c))) * 255; // (-1, 1) - _quad.tl.colors.r = (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c))) * 255; - _quad.tl.colors.g = (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c))) * 255; - _quad.tl.colors.b = (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c))) * 255; - _quad.tl.colors.a = (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c))) * 255; + _quad.tl.color.r = (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c))) * 255; + _quad.tl.color.g = (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c))) * 255; + _quad.tl.color.b = (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c))) * 255; + _quad.tl.color.a = (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c))) * 255; // (1, 1) - _quad.tr.colors.r = (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c))) * 255; - _quad.tr.colors.g = (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c))) * 255; - _quad.tr.colors.b = (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c))) * 255; - _quad.tr.colors.a = (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c))) * 255; + _quad.tr.color.r = (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c))) * 255; + _quad.tr.color.g = (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c))) * 255; + _quad.tr.color.b = (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c))) * 255; + _quad.tr.color.a = (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c))) * 255; // renders using batch node if (_renderMode == RenderMode::QUAD_BATCHNODE) diff --git a/core/2d/ParticleBatchNode.cpp b/core/2d/ParticleBatchNode.cpp index 010b38d48f96..43b8351d2e32 100644 --- a/core/2d/ParticleBatchNode.cpp +++ b/core/2d/ParticleBatchNode.cpp @@ -475,8 +475,8 @@ void ParticleBatchNode::increaseAtlasCapacityTo(ssize_t quantity) void ParticleBatchNode::disableParticle(int particleIndex) { V3F_C4F_T2F_Quad* quad = &((_textureAtlas->getQuads())[particleIndex]); - quad->br.vertices.x = quad->br.vertices.y = quad->tr.vertices.x = quad->tr.vertices.y = quad->tl.vertices.x = - quad->tl.vertices.y = quad->bl.vertices.x = quad->bl.vertices.y = 0.0f; + quad->br.position.x = quad->br.position.y = quad->tr.position.x = quad->tr.position.y = quad->tl.position.x = + quad->tl.position.y = quad->bl.position.x = quad->bl.position.y = 0.0f; } // ParticleBatchNode - add / remove / reorder helper methods diff --git a/core/2d/ParticleSystemQuad.cpp b/core/2d/ParticleSystemQuad.cpp index e235e5866204..b0bf3acc8f86 100644 --- a/core/2d/ParticleSystemQuad.cpp +++ b/core/2d/ParticleSystemQuad.cpp @@ -194,17 +194,17 @@ void ParticleSystemQuad::initTexCoordsWithRect(const Rect& pointRect) for (unsigned int i = start; i < end; i++) { // bottom-left vertex: - quads[i].bl.texCoords.u = left; - quads[i].bl.texCoords.v = bottom; + quads[i].bl.texCoord.u = left; + quads[i].bl.texCoord.v = bottom; // bottom-right vertex: - quads[i].br.texCoords.u = right; - quads[i].br.texCoords.v = bottom; + quads[i].br.texCoord.u = right; + quads[i].br.texCoord.v = bottom; // top-left vertex: - quads[i].tl.texCoords.u = left; - quads[i].tl.texCoords.v = top; + quads[i].tl.texCoord.u = left; + quads[i].tl.texCoord.v = top; // top-right vertex: - quads[i].tr.texCoords.u = right; - quads[i].tr.texCoords.v = top; + quads[i].tr.texCoord.u = right; + quads[i].tr.texCoord.v = top; } } @@ -290,20 +290,20 @@ inline void updatePosWithParticle(V3F_C4F_T2F_Quad* quad, float dy = x1 * sr + y2 * cr + y; // bottom-left - quad->bl.vertices.x = ax; - quad->bl.vertices.y = ay; + quad->bl.position.x = ax; + quad->bl.position.y = ay; // bottom-right vertex: - quad->br.vertices.x = bx; - quad->br.vertices.y = by; + quad->br.position.x = bx; + quad->br.position.y = by; // top-left vertex: - quad->tl.vertices.x = dx; - quad->tl.vertices.y = dy; + quad->tl.position.x = dx; + quad->tl.position.y = dy; // top-right vertex: - quad->tr.vertices.x = cx; - quad->tr.vertices.y = cy; + quad->tr.position.x = cx; + quad->tr.position.y = cy; } void ParticleSystemQuad::updateParticleQuads() @@ -479,13 +479,13 @@ void ParticleSystemQuad::updateParticleQuads() hsv.s = abs(*sat); hsv.v = abs(*val); auto colF = hsv.toRgba(); - quad->bl.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->bl.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); - quad->br.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->br.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); - quad->tl.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->tl.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); - quad->tr.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->tr.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); } } @@ -500,10 +500,10 @@ void ParticleSystemQuad::updateParticleQuads() hsv.s = abs(*sat); hsv.v = abs(*val); auto col = hsv.toColor4B(); - quad->bl.colors.set(col.r, col.g, col.b, col.a); - quad->br.colors.set(col.r, col.g, col.b, col.a); - quad->tl.colors.set(col.r, col.g, col.b, col.a); - quad->tr.colors.set(col.r, col.g, col.b, col.a); + quad->bl.color.set(col.r, col.g, col.b, col.a); + quad->br.color.set(col.r, col.g, col.b, col.a); + quad->tl.color.set(col.r, col.g, col.b, col.a); + quad->tr.color.set(col.r, col.g, col.b, col.a); } } } @@ -518,10 +518,10 @@ void ParticleSystemQuad::updateParticleQuads() auto colorG = *g * *a; auto colorB = *b * *a; auto colorA = *a * (*fadeDt / *fadeLn); - quad->bl.colors.set(colorR, colorG, colorB, colorA); - quad->br.colors.set(colorR, colorG, colorB, colorA); - quad->tl.colors.set(colorR, colorG, colorB, colorA); - quad->tr.colors.set(colorR, colorG, colorB, colorA); + quad->bl.color.set(colorR, colorG, colorB, colorA); + quad->br.color.set(colorR, colorG, colorB, colorA); + quad->tl.color.set(colorR, colorG, colorB, colorA); + quad->tr.color.set(colorR, colorG, colorB, colorA); } } else @@ -532,10 +532,10 @@ void ParticleSystemQuad::updateParticleQuads() auto colorG = *g; auto colorB = *b; auto colorA = *a * (*fadeDt / *fadeLn); - quad->bl.colors.set(colorR, colorG, colorB, colorA); - quad->br.colors.set(colorR, colorG, colorB, colorA); - quad->tl.colors.set(colorR, colorG, colorB, colorA); - quad->tr.colors.set(colorR, colorG, colorB, colorA); + quad->bl.color.set(colorR, colorG, colorB, colorA); + quad->br.color.set(colorR, colorG, colorB, colorA); + quad->tl.color.set(colorR, colorG, colorB, colorA); + quad->tr.color.set(colorR, colorG, colorB, colorA); } } } @@ -559,13 +559,13 @@ void ParticleSystemQuad::updateParticleQuads() hsv.s = abs(*sat); hsv.v = abs(*val); auto colF = hsv.toRgba(); - quad->bl.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->bl.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); - quad->br.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->br.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); - quad->tl.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->tl.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); - quad->tr.colors.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, + quad->tr.color.set(colF.r * colF.a, colF.g * colF.a, colF.b * colF.a, colF.a); } } @@ -579,10 +579,10 @@ void ParticleSystemQuad::updateParticleQuads() hsv.s = abs(*sat); hsv.v = abs(*val); auto col = hsv.toColor4B(); - quad->bl.colors.set(col.r, col.g, col.b, col.a); - quad->br.colors.set(col.r, col.g, col.b, col.a); - quad->tl.colors.set(col.r, col.g, col.b, col.a); - quad->tr.colors.set(col.r, col.g, col.b, col.a); + quad->bl.color.set(col.r, col.g, col.b, col.a); + quad->br.color.set(col.r, col.g, col.b, col.a); + quad->tl.color.set(col.r, col.g, col.b, col.a); + quad->tr.color.set(col.r, col.g, col.b, col.a); } } } @@ -597,10 +597,10 @@ void ParticleSystemQuad::updateParticleQuads() auto colorG = *g * *a; auto colorB = *b * *a; auto colorA = *a; - quad->bl.colors.set(colorR, colorG, colorB, colorA); - quad->br.colors.set(colorR, colorG, colorB, colorA); - quad->tl.colors.set(colorR, colorG, colorB, colorA); - quad->tr.colors.set(colorR, colorG, colorB, colorA); + quad->bl.color.set(colorR, colorG, colorB, colorA); + quad->br.color.set(colorR, colorG, colorB, colorA); + quad->tl.color.set(colorR, colorG, colorB, colorA); + quad->tr.color.set(colorR, colorG, colorB, colorA); } } else @@ -611,10 +611,10 @@ void ParticleSystemQuad::updateParticleQuads() auto colorG = *g; auto colorB = *b; auto colorA = *a; - quad->bl.colors.set(colorR, colorG, colorB, colorA); - quad->br.colors.set(colorR, colorG, colorB, colorA); - quad->tl.colors.set(colorR, colorG, colorB, colorA); - quad->tr.colors.set(colorR, colorG, colorB, colorA); + quad->bl.color.set(colorR, colorG, colorB, colorA); + quad->br.color.set(colorR, colorG, colorB, colorA); + quad->tl.color.set(colorR, colorG, colorB, colorA); + quad->tr.color.set(colorR, colorG, colorB, colorA); } } } @@ -653,17 +653,17 @@ void ParticleSystemQuad::updateParticleQuads() top = index.rect.origin.y / texHeight; bottom = (index.rect.origin.y + index.rect.size.y) / texHeight; - quad->bl.texCoords.u = left; - quad->bl.texCoords.v = bottom; + quad->bl.texCoord.u = left; + quad->bl.texCoord.v = bottom; - quad->br.texCoords.u = right; - quad->br.texCoords.v = bottom; + quad->br.texCoord.u = right; + quad->br.texCoord.v = bottom; - quad->tl.texCoords.u = left; - quad->tl.texCoords.v = top; + quad->tl.texCoord.u = left; + quad->tl.texCoord.v = top; - quad->tr.texCoords.u = right; - quad->tr.texCoords.v = top; + quad->tr.texCoord.u = right; + quad->tr.texCoord.v = top; } } } diff --git a/core/2d/ProgressTimer.cpp b/core/2d/ProgressTimer.cpp index cc4fa33a9a58..45932aa5ba88 100644 --- a/core/2d/ProgressTimer.cpp +++ b/core/2d/ProgressTimer.cpp @@ -57,17 +57,17 @@ backend::ProgramState* initPipelineDescriptor(ax::CustomCommand& command, AX_SAFE_RELEASE(pipelieDescriptor.programState); pipelieDescriptor.programState = programState; - // set custom vertexLayout according to V2F_C4F_T2F structure + // set custom vertexLayout according to V2F_T2F_C4F structure auto vertexLayout = programState->getMutableVertexLayout(); vertexLayout->setAttrib("a_position", program->getAttributeLocation(backend::Attribute::POSITION), backend::VertexFormat::FLOAT2, 0, false); vertexLayout->setAttrib("a_texCoord", program->getAttributeLocation(backend::Attribute::TEXCOORD), backend::VertexFormat::FLOAT2, - offsetof(V2F_C4F_T2F, texCoords), false); + offsetof(V2F_T2F_C4F, texCoord), false); vertexLayout->setAttrib("a_color", program->getAttributeLocation(backend::Attribute::COLOR), backend::VertexFormat::FLOAT4, - offsetof(V2F_C4F_T2F, colors), false); - vertexLayout->setStride(sizeof(V2F_C4F_T2F)); + offsetof(V2F_T2F_C4F, color), false); + vertexLayout->setStride(sizeof(V2F_T2F_C4F)); if (ridal) { @@ -203,8 +203,8 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vec2 alpha) return ret; } V3F_C4F_T2F_Quad quad = _sprite->getQuad(); - Vec2 min(quad.bl.texCoords.u, quad.bl.texCoords.v); - Vec2 max(quad.tr.texCoords.u, quad.tr.texCoords.v); + Vec2 min(quad.bl.texCoord.u, quad.bl.texCoord.v); + Vec2 max(quad.tr.texCoord.u, quad.tr.texCoord.v); // Fix bug #1303 so that progress timer handles sprite frame texture rotation if (_sprite->isTextureRectRotated()) { @@ -221,8 +221,8 @@ Vec2 ProgressTimer::vertexFromAlphaPoint(Vec2 alpha) return ret; } V3F_C4F_T2F_Quad quad = _sprite->getQuad(); - Vec2 min(quad.bl.vertices.x, quad.bl.vertices.y); - Vec2 max(quad.tr.vertices.x, quad.tr.vertices.y); + Vec2 min(quad.bl.position.x, quad.bl.position.y); + Vec2 max(quad.tr.position.x, quad.tr.position.y); ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x; ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y; return ret; @@ -256,14 +256,14 @@ void ProgressTimer::updateColor() if (!_vertexData.empty()) { - auto sc = _sprite->getQuad().tl.colors; + auto sc = _sprite->getQuad().tl.color; sc.r = sc.r * _sprite->getOpacity() / 255.0f; sc.g = sc.g * _sprite->getOpacity() / 255.0f; sc.b = sc.b * _sprite->getOpacity() / 255.0f; sc.a = sc.a * _sprite->getOpacity() / 255.0f; for (auto& d : _vertexData) { - d.colors = ax::Color{sc}; + d.color = ax::Color{sc}; } } } @@ -454,17 +454,17 @@ void ProgressTimer::updateRadial() { // First we populate the array with the _midpoint, then all // vertices/texcoords/colors of the 12 'o clock start and edges and the hitpoint - _vertexData[0].texCoords = textureCoordFromAlphaPoint(_midpoint); - _vertexData[0].vertices = vertexFromAlphaPoint(_midpoint); + _vertexData[0].texCoord = textureCoordFromAlphaPoint(_midpoint); + _vertexData[0].position = vertexFromAlphaPoint(_midpoint); - _vertexData[1].texCoords = textureCoordFromAlphaPoint(topMid); - _vertexData[1].vertices = vertexFromAlphaPoint(topMid); + _vertexData[1].texCoord = textureCoordFromAlphaPoint(topMid); + _vertexData[1].position = vertexFromAlphaPoint(topMid); for (int i = 0; i < index; ++i) { Vec2 alphaPoint = boundaryTexCoord(i); - _vertexData[i + 2].texCoords = textureCoordFromAlphaPoint(alphaPoint); - _vertexData[i + 2].vertices = vertexFromAlphaPoint(alphaPoint); + _vertexData[i + 2].texCoord = textureCoordFromAlphaPoint(alphaPoint); + _vertexData[i + 2].position = vertexFromAlphaPoint(alphaPoint); } for (int i = 0; i < index + 1; i++) @@ -478,8 +478,8 @@ void ProgressTimer::updateRadial() } // hitpoint will go last - _vertexData[_vertexData.size() - 1].texCoords = textureCoordFromAlphaPoint(hit); - _vertexData[_vertexData.size() - 1].vertices = vertexFromAlphaPoint(hit); + _vertexData[_vertexData.size() - 1].texCoord = textureCoordFromAlphaPoint(hit); + _vertexData[_vertexData.size() - 1].position = vertexFromAlphaPoint(hit); updateColor(); _customCommand.updateVertexBuffer(_vertexData.data(), (unsigned int)(sizeof(_vertexData[0]) * _vertexData.size())); @@ -541,20 +541,20 @@ void ProgressTimer::updateBar() } // TOPLEFT - _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(min.x, max.y)); - _vertexData[0].vertices = vertexFromAlphaPoint(Vec2(min.x, max.y)); + _vertexData[0].texCoord = textureCoordFromAlphaPoint(Vec2(min.x, max.y)); + _vertexData[0].position = vertexFromAlphaPoint(Vec2(min.x, max.y)); // BOTLEFT - _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(min.x, min.y)); - _vertexData[1].vertices = vertexFromAlphaPoint(Vec2(min.x, min.y)); + _vertexData[1].texCoord = textureCoordFromAlphaPoint(Vec2(min.x, min.y)); + _vertexData[1].position = vertexFromAlphaPoint(Vec2(min.x, min.y)); // TOPRIGHT - _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(max.x, max.y)); - _vertexData[2].vertices = vertexFromAlphaPoint(Vec2(max.x, max.y)); + _vertexData[2].texCoord = textureCoordFromAlphaPoint(Vec2(max.x, max.y)); + _vertexData[2].position = vertexFromAlphaPoint(Vec2(max.x, max.y)); // BOTRIGHT - _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(max.x, min.y)); - _vertexData[3].vertices = vertexFromAlphaPoint(Vec2(max.x, min.y)); + _vertexData[3].texCoord = textureCoordFromAlphaPoint(Vec2(max.x, min.y)); + _vertexData[3].position = vertexFromAlphaPoint(Vec2(max.x, min.y)); updateColor(); @@ -571,37 +571,37 @@ void ProgressTimer::updateBar() _customCommand2.createVertexBuffer(sizeof(_vertexData[0]), (unsigned int)(_vertexData.size() / 2), CustomCommand::BufferUsage::DYNAMIC); // TOPLEFT 1 - _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(0, 1)); - _vertexData[0].vertices = vertexFromAlphaPoint(Vec2(0, 1)); + _vertexData[0].texCoord = textureCoordFromAlphaPoint(Vec2(0, 1)); + _vertexData[0].position = vertexFromAlphaPoint(Vec2(0, 1)); // BOTLEFT 1 - _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(0, 0)); - _vertexData[1].vertices = vertexFromAlphaPoint(Vec2(0, 0)); + _vertexData[1].texCoord = textureCoordFromAlphaPoint(Vec2(0, 0)); + _vertexData[1].position = vertexFromAlphaPoint(Vec2(0, 0)); // TOPRIGHT 2 - _vertexData[6].texCoords = textureCoordFromAlphaPoint(Vec2(1, 1)); - _vertexData[6].vertices = vertexFromAlphaPoint(Vec2(1, 1)); + _vertexData[6].texCoord = textureCoordFromAlphaPoint(Vec2(1, 1)); + _vertexData[6].position = vertexFromAlphaPoint(Vec2(1, 1)); // BOTRIGHT 2 - _vertexData[7].texCoords = textureCoordFromAlphaPoint(Vec2(1, 0)); - _vertexData[7].vertices = vertexFromAlphaPoint(Vec2(1, 0)); + _vertexData[7].texCoord = textureCoordFromAlphaPoint(Vec2(1, 0)); + _vertexData[7].position = vertexFromAlphaPoint(Vec2(1, 0)); } // TOPRIGHT 1 - _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(min.x, max.y)); - _vertexData[2].vertices = vertexFromAlphaPoint(Vec2(min.x, max.y)); + _vertexData[2].texCoord = textureCoordFromAlphaPoint(Vec2(min.x, max.y)); + _vertexData[2].position = vertexFromAlphaPoint(Vec2(min.x, max.y)); // BOTRIGHT 1 - _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(min.x, min.y)); - _vertexData[3].vertices = vertexFromAlphaPoint(Vec2(min.x, min.y)); + _vertexData[3].texCoord = textureCoordFromAlphaPoint(Vec2(min.x, min.y)); + _vertexData[3].position = vertexFromAlphaPoint(Vec2(min.x, min.y)); // TOPLEFT 2 - _vertexData[4].texCoords = textureCoordFromAlphaPoint(Vec2(max.x, max.y)); - _vertexData[4].vertices = vertexFromAlphaPoint(Vec2(max.x, max.y)); + _vertexData[4].texCoord = textureCoordFromAlphaPoint(Vec2(max.x, max.y)); + _vertexData[4].position = vertexFromAlphaPoint(Vec2(max.x, max.y)); // BOTLEFT 2 - _vertexData[5].texCoords = textureCoordFromAlphaPoint(Vec2(max.x, min.y)); - _vertexData[5].vertices = vertexFromAlphaPoint(Vec2(max.x, min.y)); + _vertexData[5].texCoord = textureCoordFromAlphaPoint(Vec2(max.x, min.y)); + _vertexData[5].position = vertexFromAlphaPoint(Vec2(max.x, min.y)); updateColor(); diff --git a/core/2d/ProgressTimer.h b/core/2d/ProgressTimer.h index 4fdebfaa69b9..c6b0706085a6 100644 --- a/core/2d/ProgressTimer.h +++ b/core/2d/ProgressTimer.h @@ -187,7 +187,7 @@ class AX_DLL ProgressTimer : public Node Vec2 _barChangeRate; float _percentage = 0.0f; Sprite* _sprite = nullptr; - axstd::pod_vector _vertexData; + axstd::pod_vector _vertexData; axstd::pod_vector _indexData; bool _reverseDirection = false; diff --git a/core/2d/Sprite.cpp b/core/2d/Sprite.cpp index 7f98952a2300..57c219b5a28a 100644 --- a/core/2d/Sprite.cpp +++ b/core/2d/Sprite.cpp @@ -296,10 +296,10 @@ bool Sprite::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated) memset(&_quad, 0, sizeof(_quad)); // Atlas: Color - _quad.bl.colors = Color::WHITE; - _quad.br.colors = Color::WHITE; - _quad.tl.colors = Color::WHITE; - _quad.tr.colors = Color::WHITE; + _quad.bl.color = Color::WHITE; + _quad.br.color = Color::WHITE; + _quad.tl.color = Color::WHITE; + _quad.tr.color = Color::WHITE; // update texture (calls updateBlendFunc) setTexture(texture); @@ -736,7 +736,7 @@ void Sprite::setCenterRectNormalized(const ax::Rect& rectTopLeft) { _renderMode = RenderMode::SLICE9; // 9 quads + 7 exterior points = 16 - _trianglesVertex = (V3F_C4F_T2F*)malloc(sizeof(*_trianglesVertex) * (9 + 3 + 4)); + _trianglesVertex = (V3F_T2F_C4F*)malloc(sizeof(*_trianglesVertex) * (9 + 3 + 4)); // 9 quads, each needs 6 vertices = 54 _trianglesIndex = (unsigned short*)malloc(sizeof(*_trianglesIndex) * 6 * 9); @@ -856,25 +856,25 @@ void Sprite::setTextureCoords(const Rect& rectInPoints, V3F_C4F_T2F_Quad* outQua if (_rectRotated) { - outQuad->bl.texCoords.u = left; - outQuad->bl.texCoords.v = top; - outQuad->br.texCoords.u = left; - outQuad->br.texCoords.v = bottom; - outQuad->tl.texCoords.u = right; - outQuad->tl.texCoords.v = top; - outQuad->tr.texCoords.u = right; - outQuad->tr.texCoords.v = bottom; + outQuad->bl.texCoord.u = left; + outQuad->bl.texCoord.v = top; + outQuad->br.texCoord.u = left; + outQuad->br.texCoord.v = bottom; + outQuad->tl.texCoord.u = right; + outQuad->tl.texCoord.v = top; + outQuad->tr.texCoord.u = right; + outQuad->tr.texCoord.v = bottom; } else { - outQuad->bl.texCoords.u = left; - outQuad->bl.texCoords.v = bottom; - outQuad->br.texCoords.u = right; - outQuad->br.texCoords.v = bottom; - outQuad->tl.texCoords.u = left; - outQuad->tl.texCoords.v = top; - outQuad->tr.texCoords.u = right; - outQuad->tr.texCoords.v = top; + outQuad->bl.texCoord.u = left; + outQuad->bl.texCoord.v = bottom; + outQuad->br.texCoord.u = right; + outQuad->br.texCoord.v = bottom; + outQuad->tl.texCoord.u = left; + outQuad->tl.texCoord.v = top; + outQuad->tr.texCoord.u = right; + outQuad->tr.texCoord.v = top; } } @@ -917,10 +917,10 @@ void Sprite::setVertexCoords(const Rect& rect, V3F_C4F_T2F_Quad* outQuad) const float y2 = y1 + rect.size.height; // Don't update Z. - outQuad->bl.vertices.set(x1, y1, 0.0f); - outQuad->br.vertices.set(x2, y1, 0.0f); - outQuad->tl.vertices.set(x1, y2, 0.0f); - outQuad->tr.vertices.set(x2, y2, 0.0f); + outQuad->bl.position.set(x1, y1, 0.0f); + outQuad->br.position.set(x2, y1, 0.0f); + outQuad->tl.position.set(x1, y2, 0.0f); + outQuad->tr.position.set(x2, y2, 0.0f); } } @@ -993,10 +993,10 @@ void Sprite::updateTransform() // If it is not visible, or one of its ancestors is not visible, then do nothing: if (!_visible || (_parent && _parent != _batchNode && static_cast(_parent)->_shouldBeHidden)) { - _quad.br.vertices.setZero(); - _quad.tl.vertices.setZero(); - _quad.tr.vertices.setZero(); - _quad.bl.vertices.setZero(); + _quad.br.position.setZero(); + _quad.tl.position.setZero(); + _quad.tr.position.setZero(); + _quad.bl.position.setZero(); _shouldBeHidden = true; } else @@ -1044,10 +1044,10 @@ void Sprite::updateTransform() float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; - _quad.bl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ); - _quad.br.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ); - _quad.tl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ); - _quad.tr.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ); + _quad.bl.position.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ); + _quad.br.position.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ); + _quad.tl.position.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ); + _quad.tr.position.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ); setTextureCoords(_rect); } @@ -1099,16 +1099,16 @@ void Sprite::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) for (unsigned int i = 0; i < count; i++) { // draw 3 lines - Vec3 from = verts[indices[i * 3]].vertices; - Vec3 to = verts[indices[i * 3 + 1]].vertices; + Vec3 from = verts[indices[i * 3]].position; + Vec3 to = verts[indices[i * 3 + 1]].position; _debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4B::WHITE); - from = verts[indices[i * 3 + 1]].vertices; - to = verts[indices[i * 3 + 2]].vertices; + from = verts[indices[i * 3 + 1]].position; + to = verts[indices[i * 3 + 2]].position; _debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4B::WHITE); - from = verts[indices[i * 3 + 2]].vertices; - to = verts[indices[i * 3]].vertices; + from = verts[indices[i * 3 + 2]].position; + to = verts[indices[i * 3]].position; _debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4B::WHITE); } #endif // AX_SPRITE_DEBUG_DRAW @@ -1467,7 +1467,7 @@ void Sprite::flipX() { for (unsigned int i = 0; i < _polyInfo.triangles.vertCount; i++) { - auto& v = _polyInfo.triangles.verts[i].vertices; + auto& v = _polyInfo.triangles.verts[i].position; v.x = _contentSize.width - v.x; } } @@ -1484,7 +1484,7 @@ void Sprite::flipY() { for (unsigned int i = 0; i < _polyInfo.triangles.vertCount; i++) { - auto& v = _polyInfo.triangles.verts[i].vertices; + auto& v = _polyInfo.triangles.verts[i].position; v.y = _contentSize.height - v.y; } } @@ -1510,12 +1510,12 @@ void Sprite::updateColor() } for (unsigned int i = 0; i < _polyInfo.triangles.vertCount; i++) - _polyInfo.triangles.verts[i].colors = color; + _polyInfo.triangles.verts[i].color = color; // related to issue #17116 // when switching from Quad to Slice9, the color will be obtained from _quad // so it is important to update _quad colors as well. - _quad.bl.colors = _quad.tl.colors = _quad.br.colors = _quad.tr.colors = color; + _quad.bl.color = _quad.tl.color = _quad.br.color = _quad.tr.color = color; // renders using batch node if (_renderMode == RenderMode::QUAD_BATCHNODE) @@ -1658,10 +1658,10 @@ void Sprite::setBatchNode(SpriteBatchNode* spriteBatchNode) float y1 = _offsetPosition.y; float x2 = x1 + _rect.size.width; float y2 = y1 + _rect.size.height; - _quad.bl.vertices.set(x1, y1, 0); - _quad.br.vertices.set(x2, y1, 0); - _quad.tl.vertices.set(x1, y2, 0); - _quad.tr.vertices.set(x2, y2, 0); + _quad.bl.position.set(x1, y1, 0); + _quad.br.position.set(x2, y1, 0); + _quad.tl.position.set(x1, y2, 0); + _quad.tr.position.set(x2, y2, 0); } else { diff --git a/core/2d/Sprite.h b/core/2d/Sprite.h index bee0bf2a9d84..a76254d98dcf 100644 --- a/core/2d/Sprite.h +++ b/core/2d/Sprite.h @@ -716,7 +716,7 @@ class AX_DLL Sprite : public Node, public TextureProtocol // vertex coords, texture coords and color info V3F_C4F_T2F_Quad _quad; - V3F_C4F_T2F* _trianglesVertex = nullptr; + V3F_T2F_C4F* _trianglesVertex = nullptr; unsigned short* _trianglesIndex = nullptr; PolygonInfo _polyInfo; diff --git a/core/2d/SpriteSheetLoader.cpp b/core/2d/SpriteSheetLoader.cpp index 72fa3392e321..68bfbb50cb4e 100644 --- a/core/2d/SpriteSheetLoader.cpp +++ b/core/2d/SpriteSheetLoader.cpp @@ -19,13 +19,13 @@ void SpriteSheetLoader::initializePolygonInfo(const Vec2& textureSize, const auto scaleFactor = AX_CONTENT_SCALE_FACTOR(); - auto* vertexData = new V3F_C4F_T2F[vertexCount]; + auto* vertexData = new V3F_T2F_C4F[vertexCount]; for (size_t i = 0; i < vertexCount / 2; i++) { - vertexData[i].colors = Color::WHITE; - vertexData[i].vertices = + vertexData[i].color = Color::WHITE; + vertexData[i].position = Vec3(vertices[i * 2] / scaleFactor, (spriteSize.height - vertices[i * 2 + 1]) / scaleFactor, 0); - vertexData[i].texCoords = + vertexData[i].texCoord = Tex2F(verticesUV[i * 2] / textureSize.width, verticesUV[i * 2 + 1] / textureSize.height); } diff --git a/core/2d/TileMapAtlas.cpp b/core/2d/TileMapAtlas.cpp index 976612e6e144..fccb74df6cbb 100644 --- a/core/2d/TileMapAtlas.cpp +++ b/core/2d/TileMapAtlas.cpp @@ -188,33 +188,33 @@ void TileMapAtlas::updateAtlasValueAt(const Vec2& pos, const Color3B& value, int float bottom = top + itemHeightInPixels / textureHigh; #endif - quad->tl.texCoords.u = left; - quad->tl.texCoords.v = top; - quad->tr.texCoords.u = right; - quad->tr.texCoords.v = top; - quad->bl.texCoords.u = left; - quad->bl.texCoords.v = bottom; - quad->br.texCoords.u = right; - quad->br.texCoords.v = bottom; - - quad->bl.vertices.x = (float)(x * _itemWidth); - quad->bl.vertices.y = (float)(y * _itemHeight); - quad->bl.vertices.z = 0.0f; - quad->br.vertices.x = (float)(x * _itemWidth + _itemWidth); - quad->br.vertices.y = (float)(y * _itemHeight); - quad->br.vertices.z = 0.0f; - quad->tl.vertices.x = (float)(x * _itemWidth); - quad->tl.vertices.y = (float)(y * _itemHeight + _itemHeight); - quad->tl.vertices.z = 0.0f; - quad->tr.vertices.x = (float)(x * _itemWidth + _itemWidth); - quad->tr.vertices.y = (float)(y * _itemHeight + _itemHeight); - quad->tr.vertices.z = 0.0f; + quad->tl.texCoord.u = left; + quad->tl.texCoord.v = top; + quad->tr.texCoord.u = right; + quad->tr.texCoord.v = top; + quad->bl.texCoord.u = left; + quad->bl.texCoord.v = bottom; + quad->br.texCoord.u = right; + quad->br.texCoord.v = bottom; + + quad->bl.position.x = (float)(x * _itemWidth); + quad->bl.position.y = (float)(y * _itemHeight); + quad->bl.position.z = 0.0f; + quad->br.position.x = (float)(x * _itemWidth + _itemWidth); + quad->br.position.y = (float)(y * _itemHeight); + quad->br.position.z = 0.0f; + quad->tl.position.x = (float)(x * _itemWidth); + quad->tl.position.y = (float)(y * _itemHeight + _itemHeight); + quad->tl.position.z = 0.0f; + quad->tr.position.x = (float)(x * _itemWidth + _itemWidth); + quad->tr.position.y = (float)(y * _itemHeight + _itemHeight); + quad->tr.position.z = 0.0f; Color color(_displayedColor, _displayedOpacity / 255.0f); - quad->tr.colors = color; - quad->tl.colors = color; - quad->br.colors = color; - quad->bl.colors = color; + quad->tr.color = color; + quad->tl.color = color; + quad->br.color = color; + quad->bl.color = color; _textureAtlas->setDirty(true); ssize_t totalQuads = _textureAtlas->getTotalQuads(); diff --git a/core/base/Properties.cpp b/core/base/Properties.cpp index d10081b1e064..ab7037833a66 100644 --- a/core/base/Properties.cpp +++ b/core/base/Properties.cpp @@ -955,12 +955,7 @@ bool Properties::getQuaternionFromAxisAngle(const char* name, Quaternion* out) c return parseAxisAngle(getString(name), out); } -bool Properties::getColor(const char* name, Vec3* out) const -{ - return parseColor(getString(name), out); -} - -bool Properties::getColor(const char* name, Vec4* out) const +bool Properties::getColor(const char* name, Color* out) const { return parseColor(getString(name), out); } @@ -1261,39 +1256,7 @@ bool Properties::parseAxisAngle(const char* str, Quaternion* out) return false; } -bool Properties::parseColor(const char* str, Vec3* out) -{ - if (str) - { - if (strlen(str) == 7 && str[0] == '#') - { - // Read the string into an int as hex. - unsigned int color; - if (sscanf(str + 1, "%x", &color) == 1) - { - if (out) - out->set(Vec3::fromColor(color)); - return true; - } - else - { - // Invalid format - AXLOGW("Error attempting to parse property as an RGB color: {}", str); - } - } - else - { - // Not a color string. - AXLOGW("Error attempting to parse property as an RGB color (not specified as a color string): {}", str); - } - } - - if (out) - out->set(0.0f, 0.0f, 0.0f); - return false; -} - -bool Properties::parseColor(const char* str, Vec4* out) +bool Properties::parseColor(const char* str, Color* out) { if (str) { @@ -1304,7 +1267,7 @@ bool Properties::parseColor(const char* str, Vec4* out) if (sscanf(str + 1, "%x", &color) == 1) { if (out) - out->set(Vec4::fromColor(color)); + out->set(Color::fromHex(color)); return true; } else diff --git a/core/base/Properties.h b/core/base/Properties.h index 9f521b2e4aba..01c9e480bcf3 100644 --- a/core/base/Properties.h +++ b/core/base/Properties.h @@ -392,20 +392,6 @@ class AX_DLL Properties */ bool getQuaternionFromAxisAngle(const char* name, Quaternion* out) const; - /** - * Interpret the value of the given property as an RGB color in hex and write this color to a Vector3. - * E.g. 0xff0000 represents red and sets the vector to (1, 0, 0). - * If the property does not exist, out will be set to Vector3(0.0f, 0.0f, 0.0f). - * If the property exists but could not be scanned, an error will be logged and out will be set - * to Vector3(0.0f, 0.0f, 0.0f). - * - * @param name The name of the property to interpret, or NULL to return the current property's value. - * @param out The vector to set to this property's interpreted value. - * - * @return True on success, false if the property does not exist or could not be scanned. - */ - bool getColor(const char* name, Vec3* out) const; - /** * Interpret the value of the given property as an RGBA color in hex and write this color to a Vector4. * E.g. 0xff0000ff represents opaque red and sets the vector to (1, 0, 0, 1). @@ -418,7 +404,7 @@ class AX_DLL Properties * * @return True on success, false if the property does not exist or could not be scanned. */ - bool getColor(const char* name, Vec4* out) const; + bool getColor(const char* name, Color* out) const; /** * Gets the file path for the given property if the file exists. @@ -507,16 +493,6 @@ class AX_DLL Properties */ static bool parseAxisAngle(const char* str, Quaternion* out); - /** - * Attempts to parse the specified string as an RGB color value. - * - * @param str The string to parse. - * @param out The value to populate if successful. - * - * @return True if a valid RGB color was parsed, false otherwise. - */ - static bool parseColor(const char* str, Vec3* out); - /** * Attempts to parse the specified string as an RGBA color value. * @@ -525,7 +501,7 @@ class AX_DLL Properties * * @return True if a valid RGBA color was parsed, false otherwise. */ - static bool parseColor(const char* str, Vec4* out); + static bool parseColor(const char* str, Color* out); private: /** diff --git a/core/base/Types.h b/core/base/Types.h index a9ad6e060261..fffbdc306081 100644 --- a/core/base/Types.h +++ b/core/base/Types.h @@ -72,32 +72,32 @@ struct Quad3 Vec3 tr; }; -/** @struct V2F_C4F_T2F +/** @struct V2F_T2F_C4F * A Vec2 with a vertex point, a tex coord point and a color 4F. */ -struct V2F_C4F_T2F +struct V2F_T2F_C4F { - /// vertices (2F) - Vec2 vertices; - /// colors (4F) - Color colors; + /// position (2F) + Vec2 position; /// tex coords (2F) - Tex2F texCoords; + Tex2F texCoord; + /// color (4F) + Color color; }; -/** @struct V3F_C4F_T2F aka PosColorTex +/** @struct V3F_T2F_C4F aka PosColorTex * A Vec2 with a vertex point, a tex coord point and a color 4B. */ -struct V3F_C4F_T2F +struct V3F_T2F_C4F { - /// vertices (3F) - Vec3 vertices; // 12 bytes - - /// colors (4B) - Color colors; // 4 bytes + /// position (3F) + Vec3 position; // 12 bytes // tex coords (2F) - Tex2F texCoords; // 8 bytes + Tex2F texCoord; // 8 bytes + + /// color (4F) + Color color; // 16 bytes }; /** @struct V3F_T2F @@ -105,10 +105,10 @@ struct V3F_C4F_T2F */ struct V3F_T2F { - /// vertices (2F) - Vec3 vertices; + /// position (2F) + Vec3 position; /// tex coords (2F) - Tex2F texCoords; + Tex2F texCoord; }; /** @struct V3F_C4F @@ -116,17 +116,10 @@ struct V3F_T2F */ struct V3F_C4F { - /// vertices (3F) - Vec3 vertices; - /// vertices (4F) - Color colors; -}; - -struct V3F_T2F_C4F -{ + /// position (3F) Vec3 position; - Vec2 uv; - Vec4 color; + /// color (4F) + Color color; }; struct V3F_T2F_N3F @@ -138,9 +131,9 @@ struct V3F_T2F_N3F struct V2F_C4F_T2F_Triangle { - V2F_C4F_T2F a; - V2F_C4F_T2F b; - V2F_C4F_T2F c; + V2F_T2F_C4F a; + V2F_T2F_C4F b; + V2F_T2F_C4F c; }; /** @struct V3F_C4F_T2F_Quad @@ -149,13 +142,13 @@ struct V2F_C4F_T2F_Triangle struct V3F_C4F_T2F_Quad { /// top left - V3F_C4F_T2F tl; + V3F_T2F_C4F tl; /// bottom left - V3F_C4F_T2F bl; + V3F_T2F_C4F bl; /// top right - V3F_C4F_T2F tr; + V3F_T2F_C4F tr; /// bottom right - V3F_C4F_T2F br; + V3F_T2F_C4F br; }; /** @struct V2F_C4F_T2F_Quad @@ -164,13 +157,13 @@ struct V3F_C4F_T2F_Quad struct V2F_C4F_T2F_Quad { /// bottom left - V2F_C4F_T2F bl; + V2F_T2F_C4F bl; /// bottom right - V2F_C4F_T2F br; + V2F_T2F_C4F br; /// top left - V2F_C4F_T2F tl; + V2F_T2F_C4F tl; /// top right - V2F_C4F_T2F tr; + V2F_T2F_C4F tr; }; /** @struct V3F_T2F_Quad diff --git a/core/math/Color.cpp b/core/math/Color.cpp index 6a7d41cf606c..e86920e4e334 100644 --- a/core/math/Color.cpp +++ b/core/math/Color.cpp @@ -162,7 +162,7 @@ const Color Color::TRANSPARENT(0, 0, 0, 0); HSV::HSV() {} -HSV::HSV(float _h, float _s, float _v, float _a) : Vec4Base(_h, _s, _v, _a) {} +HSV::HSV(float _h, float _s, float _v, float _a) : Vec4Adapter(_h, _s, _v, _a) {} HSV::HSV(const Color3B& c) { @@ -299,7 +299,7 @@ Color4B HSV::toColor4B() const } HSL::HSL() {} -HSL::HSL(float _h, float _s, float _l, float _a) : Vec4Base(_h, _s, _l, _a) {} +HSL::HSL(float _h, float _s, float _l, float _a) : Vec4Adapter(_h, _s, _l, _a) {} HSL::HSL(const Color3B& c) { diff --git a/core/math/Color.h b/core/math/Color.h index e3fa0005fef3..b45575f874dd 100644 --- a/core/math/Color.h +++ b/core/math/Color.h @@ -120,28 +120,27 @@ struct AX_DLL Color4B * RGBA color composed of 4 floats. * @since v3.0 */ -struct AX_DLL Color : public Vec4Base +struct AX_DLL Color : public Vec4Adapter { - using Vec4Base = Vec4Base; - Color() {} - Color(float _r, float _g, float _b, float _a) : Vec4Base(_r, _g, _b, _a) {} + Color(float _r, float _g, float _b, float _a) : Vec4Adapter(_r, _g, _b, _a) {} explicit Color(const Color3B& color, float _a = 1.0f) - : Vec4Base(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, _a) + : Vec4Adapter(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, _a) {} explicit Color(const Color4B& color) - : Vec4Base(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f) + : Vec4Adapter(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f) {} template - explicit Color(const _Other& color) : Vec4Base(color.r, color.g, color.b, color.a) + explicit Color(const _Other& color) : Vec4Adapter(color.r, color.g, color.b, color.a) {} - static Color fromHex(unsigned int hexVal, bool useAlpha = false) + static Color fromHex(unsigned int v) { - unsigned int r = (hexVal >> 16) & 0xff; - unsigned int g = (hexVal >> 8) & 0xff; - unsigned int b = (hexVal) & 0xff; - return Color{r / 255.f, g / 255.f, b / 255.f, !useAlpha ? 1.0f : ((hexVal >> 24) & 0xff) / 255.f}; + auto r = (v >> 24) & 0xff; + auto g = (v >> 16) & 0xff; + auto b = (v >> 8) & 0xff; + auto a = v & 0xff; + return Color{r / 255.f, g / 255.f, b / 255.f, a / 255.f }; } bool operator==(const Color3B& rhs) const; @@ -170,7 +169,7 @@ using Color4F = Color; // DEPRECATED * * Implementation source: https://gist.github.com/fairlight1337/4935ae72bcbcc1ba5c72 */ -struct AX_DLL HSV : public Vec4Base +struct AX_DLL HSV : public Vec4Adapter { HSV(); HSV(float _h, float _s, float _v, float _a = 1.0F); @@ -194,7 +193,7 @@ struct AX_DLL HSV : public Vec4Base * * Implementation source: https://gist.github.com/ciembor/1494530 */ -struct AX_DLL HSL : public Vec4Base +struct AX_DLL HSL : public Vec4Adapter { HSL(); HSL(float _h, float _s, float _l, float _a = 1.0F); diff --git a/core/math/MathUtil.cpp b/core/math/MathUtil.cpp index e7346dbabf76..63ff6a7c01e6 100644 --- a/core/math/MathUtil.cpp +++ b/core/math/MathUtil.cpp @@ -283,13 +283,13 @@ void MathUtil::crossVec3(const float* v1, const float* v2, float* dst) #endif } -void MathUtil::transformVertices(V3F_C4F_T2F* dst, const V3F_C4F_T2F* src, size_t count, const Mat4& transform) +void MathUtil::transformVertices(V3F_T2F_C4F* dst, const V3F_T2F_C4F* src, size_t count, const Mat4& transform) { // Check some assumptions made by optimizations - static_assert(sizeof(V3F_C4F_T2F) == 36); - static_assert(offsetof(V3F_C4F_T2F, vertices) == 0); - static_assert(offsetof(V3F_C4F_T2F, colors) == 12); - static_assert(offsetof(V3F_C4F_T2F, texCoords) == 28); + static_assert(sizeof(V3F_T2F_C4F) == 36); + static_assert(offsetof(V3F_T2F_C4F, position) == 0); + static_assert(offsetof(V3F_T2F_C4F, texCoord) == 12); + static_assert(offsetof(V3F_T2F_C4F, color) == 20); #if defined(AX_SSE_INTRINSICS) MathUtilSSE::transformVertices(dst, src, count, transform); #elif defined(AX_NEON_INTRINSICS) diff --git a/core/math/MathUtil.h b/core/math/MathUtil.h index b2d4b1dc9743..53c65a768011 100644 --- a/core/math/MathUtil.h +++ b/core/math/MathUtil.h @@ -29,7 +29,7 @@ namespace ax { - struct V3F_C4F_T2F; + struct V3F_T2F_C4F; } /** @@ -119,7 +119,7 @@ class AX_DLL MathUtil static void crossVec3(const float* v1, const float* v2, float* dst); - static void transformVertices(V3F_C4F_T2F* dst, const V3F_C4F_T2F* src, size_t count, const Mat4& transform); + static void transformVertices(V3F_T2F_C4F* dst, const V3F_T2F_C4F* src, size_t count, const Mat4& transform); static void transformIndices(uint16_t* dst, const uint16_t* src, size_t count, uint16_t offset); }; diff --git a/core/math/MathUtil.inl b/core/math/MathUtil.inl index 19ee3d678915..f4b23204b70a 100644 --- a/core/math/MathUtil.inl +++ b/core/math/MathUtil.inl @@ -191,7 +191,7 @@ public: dst[2] = z; } - inline static void transformVertices(V3F_C4F_T2F* dst, const V3F_C4F_T2F* src, size_t count, const Mat4& transform) + inline static void transformVertices(V3F_T2F_C4F* dst, const V3F_T2F_C4F* src, size_t count, const Mat4& transform) { auto end = dst + count; auto& t = transform; // Make copy for better aliasing inference @@ -199,11 +199,11 @@ public: while (dst < end) { - auto pos = src->vertices; - dst->vertices.x = pos.x * m[0] + pos.y * m[4] + pos.z * m[8] + m[12]; - dst->vertices.y = pos.x * m[1] + pos.y * m[5] + pos.z * m[9] + m[13]; - dst->vertices.z = pos.x * m[2] + pos.y * m[6] + pos.z * m[10] + m[14]; - memcpy(&dst->colors, &src->colors, sizeof(V3F_C4F_T2F::colors) + sizeof(V3F_C4F_T2F::texCoords)); + auto pos = src->position; + dst->position.x = pos.x * m[0] + pos.y * m[4] + pos.z * m[8] + m[12]; + dst->position.y = pos.x * m[1] + pos.y * m[5] + pos.z * m[9] + m[13]; + dst->position.z = pos.x * m[2] + pos.y * m[6] + pos.z * m[10] + m[14]; + memcpy(&dst->texCoord, &src->texCoord, sizeof(V3F_T2F_C4F::texCoord) + sizeof(V3F_T2F_C4F::color)); ++dst; ++src; } diff --git a/core/math/MathUtilNeon.inl b/core/math/MathUtilNeon.inl index f238e2487ecd..bbb9acb27757 100644 --- a/core/math/MathUtilNeon.inl +++ b/core/math/MathUtilNeon.inl @@ -147,7 +147,7 @@ struct MathUtilNeon } #if AX_64BITS - inline static void transformVertices(V3F_C4F_T2F* dst, const V3F_C4F_T2F* src, size_t count, const Mat4& transform) + inline static void transformVertices(V3F_T2F_C4F* dst, const V3F_T2F_C4F* src, size_t count, const Mat4& transform) { auto end = dst + count; @@ -159,26 +159,26 @@ struct MathUtilNeon while (dst < end4) { // Do this for each vertex - // dst->vertices.x = pos.x * m[0] + pos.y * m[4] + pos.z * m[8] + m[12]; - // dst->vertices.y = pos.x * m[1] + pos.y * m[5] + pos.z * m[9] + m[13]; - // dst->vertices.z = pos.x * m[2] + pos.y * m[6] + pos.z * m[10] + m[14]; + // dst->position.x = pos.x * m[0] + pos.y * m[4] + pos.z * m[8] + m[12]; + // dst->position.y = pos.x * m[1] + pos.y * m[5] + pos.z * m[9] + m[13]; + // dst->position.z = pos.x * m[2] + pos.y * m[6] + pos.z * m[10] + m[14]; // First, load each vertex, multiply x by column 0 and add to column 3 - // Note: since we're reading 4 floats it will load color bytes into v.w - float32x4_t v0 = vld1q_f32(&src[0].vertices.x); + // Note: since we're reading 4 floats it will load color.u into v.w + float32x4_t v0 = vld1q_f32(&src[0].position.x); float32x4_t r0 = vmlaq_laneq_f32(m.val[3], m.val[0], v0, 0); - float32x4_t v1 = vld1q_f32(&src[1].vertices.x); + float32x4_t v1 = vld1q_f32(&src[1].position.x); float32x4_t r1 = vmlaq_laneq_f32(m.val[3], m.val[0], v1, 0); - float32x4_t v2 = vld1q_f32(&src[2].vertices.x); + float32x4_t v2 = vld1q_f32(&src[2].position.x); float32x4_t r2 = vmlaq_laneq_f32(m.val[3], m.val[0], v2, 0); - float32x4_t v3 = vld1q_f32(&src[3].vertices.x); + float32x4_t v3 = vld1q_f32(&src[3].position.x); float32x4_t r3 = vmlaq_laneq_f32(m.val[3], m.val[0], v3, 0); - // Load texCoords - float32x2_t uv0 = vld1_f32(&src[0].texCoords.u); - float32x2_t uv1 = vld1_f32(&src[1].texCoords.u); - float32x2_t uv2 = vld1_f32(&src[2].texCoords.u); - float32x2_t uv3 = vld1_f32(&src[3].texCoords.u); + // Load texCoord.v and color.rgb + float32x4_t vrgb0 = vld1q_f32(&src[0].texCoord.v); + float32x4_t vrgb1 = vld1q_f32(&src[1].texCoord.v); + float32x4_t vrgb2 = vld1q_f32(&src[2].texCoord.v); + float32x4_t vrgb3 = vld1q_f32(&src[3].texCoord.v); // Multiply y by column 1 and add to result r0 = vmlaq_laneq_f32(r0, m.val[1], v0, 1); @@ -192,21 +192,27 @@ struct MathUtilNeon r2 = vmlaq_laneq_f32(r2, m.val[2], v2, 2); r3 = vmlaq_laneq_f32(r3, m.val[2], v3, 2); - // Set w to loaded color + // Set w to loaded color.r r0 = vsetq_lane_f32(vgetq_lane_f32(v0, 3), r0, 3); r1 = vsetq_lane_f32(vgetq_lane_f32(v1, 3), r1, 3); r2 = vsetq_lane_f32(vgetq_lane_f32(v2, 3), r2, 3); r3 = vsetq_lane_f32(vgetq_lane_f32(v3, 3), r3, 3); // Store result - vst1q_f32(&dst[0].vertices.x, r0); - vst1_f32(&dst[0].texCoords.u, uv0); - vst1q_f32(&dst[1].vertices.x, r1); - vst1_f32(&dst[1].texCoords.u, uv1); - vst1q_f32(&dst[2].vertices.x, r2); - vst1_f32(&dst[2].texCoords.u, uv2); - vst1q_f32(&dst[3].vertices.x, r3); - vst1_f32(&dst[3].texCoords.u, uv3); + vst1q_f32(&dst[0].position.x, r0); + vst1q_f32(&dst[0].texCoord.v, vrgb0); + vst1q_f32(&dst[1].position.x, r1); + vst1q_f32(&dst[1].texCoord.v, vrgb1); + vst1q_f32(&dst[2].position.x, r2); + vst1q_f32(&dst[2].texCoord.v, vrgb2); + vst1q_f32(&dst[3].position.x, r3); + vst1q_f32(&dst[3].texCoord.v, vrgb3); + + // Store color.a + dst[0].color.a = src[0].color.a; + dst[1].color.a = src[1].color.a; + dst[2].color.a = src[2].color.a; + dst[3].color.a = src[3].color.a; dst += 4; src += 4; @@ -215,14 +221,15 @@ struct MathUtilNeon // Process remaining vertices one by one while (dst < end) { - float32x4_t v = vld1q_f32(&src->vertices.x); + float32x4_t v = vld1q_f32(&src->position.x); float32x4_t r = vmlaq_laneq_f32(m.val[3], m.val[0], v, 0); r = vmlaq_laneq_f32(r, m.val[1], v, 1); r = vmlaq_laneq_f32(r, m.val[2], v, 2); r = vsetq_lane_f32(vgetq_lane_f32(v, 3), r, 3); - float32x2_t uv = vld1_f32(&src->texCoords.u); - vst1q_f32(&dst->vertices.x, r); - vst1_f32(&dst->texCoords.u, uv); + float32x4_t vrgb = vld1q_f32(&src->texCoord.v); + vst1q_f32(&dst->position.x, r); + vst1q_f32(&dst->texCoord.v, vrgb); + dst->color.a = src->color.a; ++dst; ++src; @@ -280,8 +287,8 @@ struct MathUtilNeon } } #else - inline static void transformVertices(ax::V3F_C4F_T2F* dst, - const ax::V3F_C4F_T2F* src, + inline static void transformVertices(ax::V3F_T2F_C4F* dst, + const ax::V3F_T2F_C4F* src, size_t count, const ax::Mat4& transform) { @@ -297,19 +304,19 @@ struct MathUtilNeon auto end4 = dst + count / 4 * 4; while (dst < end4) { - // Load 4 vertices. Note that color will also get loaded into w - float32x2_t xy0 = vld1_f32(&src[0].vertices.x); - float32x2_t zw0 = vld1_f32(&src[0].vertices.z); - float32x2_t uv0 = vld1_f32(&src[0].texCoords.u); - float32x2_t xy1 = vld1_f32(&src[1].vertices.x); - float32x2_t zw1 = vld1_f32(&src[1].vertices.z); - float32x2_t uv1 = vld1_f32(&src[1].texCoords.u); - float32x2_t xy2 = vld1_f32(&src[2].vertices.x); - float32x2_t zw2 = vld1_f32(&src[2].vertices.z); - float32x2_t uv2 = vld1_f32(&src[2].texCoords.u); - float32x2_t xy3 = vld1_f32(&src[3].vertices.x); - float32x2_t zw3 = vld1_f32(&src[3].vertices.z); - float32x2_t uv3 = vld1_f32(&src[3].texCoords.u); + // Load 4 vertices. Note that texCoord.u will also get loaded into w + float32x2_t xy0 = vld1_f32(&src[0].position.x); + float32x2_t zw0 = vld1_f32(&src[0].position.z); + //float32x2_t uv0 = vld1_f32(&src[0].texCoord.u); + float32x2_t xy1 = vld1_f32(&src[1].position.x); + float32x2_t zw1 = vld1_f32(&src[1].position.z); + //float32x2_t uv1 = vld1_f32(&src[1].texCoord.u); + float32x2_t xy2 = vld1_f32(&src[2].position.x); + float32x2_t zw2 = vld1_f32(&src[2].position.z); + //float32x2_t uv2 = vld1_f32(&src[2].texCoord.u); + float32x2_t xy3 = vld1_f32(&src[3].position.x); + float32x2_t zw3 = vld1_f32(&src[3].position.z); + //float32x2_t uv3 = vld1_f32(&src[3].texCoord.u); // Multiply x by column 0 float32x4_t r0 = vmulq_lane_f32(mc0, xy0, 0); @@ -341,15 +348,27 @@ struct MathUtilNeon r2 = vsetq_lane_f32(vget_lane_f32(zw2, 1), r2, 3); r3 = vsetq_lane_f32(vget_lane_f32(zw3, 1), r3, 3); + // Load texCoords.v color.rgb + float32x4_t vrgb0 = vld1q_f32(&src[0].texCoord.v); + float32x4_t vrgb1 = vld1q_f32(&src[1].texCoord.v); + float32x4_t vrgb2 = vld1q_f32(&src[2].texCoord.v); + float32x4_t vrgb3 = vld1q_f32(&src[3].texCoord.v); + // Store result - vst1q_f32(&dst[0].vertices.x, r0); - vst1_f32(&dst[0].texCoords.u, uv0); - vst1q_f32(&dst[1].vertices.x, r1); - vst1_f32(&dst[1].texCoords.u, uv1); - vst1q_f32(&dst[2].vertices.x, r2); - vst1_f32(&dst[2].texCoords.u, uv2); - vst1q_f32(&dst[3].vertices.x, r3); - vst1_f32(&dst[3].texCoords.u, uv3); + vst1q_f32(&dst[0].position.x, r0); + vst1q_f32(&dst[0].texCoord.v, vrgb0); + vst1q_f32(&dst[1].position.x, r1); + vst1q_f32(&dst[1].texCoord.v, vrgb1); + vst1q_f32(&dst[2].position.x, r2); + vst1q_f32(&dst[2].texCoord.v, vrgb2); + vst1q_f32(&dst[3].position.x, r3); + vst1q_f32(&dst[3].texCoord.v, vrgb3); + + // Store texture color.a + dst[0].color.a = src[0].color.a; + dst[1].color.a = src[1].color.a; + dst[2].color.a = src[2].color.a; + dst[3].color.a = src[3].color.a; dst += 4; src += 4; @@ -359,9 +378,9 @@ struct MathUtilNeon while (dst < end) { // Load vertex - float32x2_t xy = vld1_f32(&src->vertices.x); - float32x2_t zw = vld1_f32(&src->vertices.z); - float32x2_t uv = vld1_f32(&src->texCoords.u); + float32x2_t xy = vld1_f32(&src->position.x); + float32x2_t zw = vld1_f32(&src->position.z); + float32x4_t vrgb = vld1q_f32(&src->color.v); // Multiply x by column 0 float32x4_t r = vmulq_lane_f32(mc0, xy, 0); @@ -376,8 +395,10 @@ struct MathUtilNeon r = vsetq_lane_f32(vget_lane_f32(zw, 1), r, 3); // Store result - vst1q_f32(&dst->vertices.x, r); - vst1_f32(&dst->texCoords.u, uv); + vst1q_f32(&dst->position.x, r); + vst1q_f32(&dst->texCoord.v, vrgb); + + dst->color.a = src->color.a; ++dst; ++src; diff --git a/core/math/MathUtilSSE.inl b/core/math/MathUtilSSE.inl index 120e3cc0172a..0ff57d1eff3c 100644 --- a/core/math/MathUtilSSE.inl +++ b/core/math/MathUtilSSE.inl @@ -230,27 +230,22 @@ struct MathUtilSSE # endif } - static void transformVertices(V3F_C4F_T2F* dst, const V3F_C4F_T2F* src, size_t count, const Mat4& transform) + static void transformVertices(V3F_T2F_C4F* dst, const V3F_T2F_C4F* src, size_t count, const Mat4& transform) { auto& m = transform.col; for (size_t i = 0; i < count; ++i) { - auto& vert = src[i].vertices; + auto& vert = src[i].position; __m128 v = _mm_set_ps(1.0f, vert.z, vert.y, vert.x); v = _mm_add_ps( _mm_add_ps(_mm_mul_ps(m[0], _mm_shuffle_ps(v, v, 0)), _mm_mul_ps(m[1], _mm_shuffle_ps(v, v, 0x55))), _mm_add_ps(_mm_mul_ps(m[2], _mm_shuffle_ps(v, v, 0xaa)), _mm_mul_ps(m[3], _mm_shuffle_ps(v, v, 0xff)))); - _mm_storeu_ps((float*)&dst[i].vertices, v); + _mm_storeu_ps((float*)&dst[i].position, v); - v = _mm_set_ps(src[i].colors.w, src[i].colors.z, src[i].colors.y, src[i].colors.x); - _mm_storeu_ps((float*)&dst[i].colors, v); - memcpy(&dst[i].texCoords, &src[i].texCoords, sizeof(V3F_C4F_T2F::texCoords)); - - // Copy tex coords and colors - // dst[i].texCoords = src[i].texCoords; - // dst[i].colors = src[i].colors; - // memcpy(&dst[i].colors, &src[i].colors, sizeof(V3F_C4F_T2F::colors) + sizeof(V3F_C4F_T2F::texCoords)); + v = _mm_set_ps(src[i].color.w, src[i].color.z, src[i].color.y, src[i].color.x); + _mm_storeu_ps((float*)&dst[i].color, v); + memcpy(&dst[i].texCoord, &src[i].texCoord, sizeof(V3F_T2F_C4F::texCoord)); } } diff --git a/core/math/Vec3.cpp b/core/math/Vec3.cpp index 60c9235eda99..47293d01ba04 100644 --- a/core/math/Vec3.cpp +++ b/core/math/Vec3.cpp @@ -33,22 +33,6 @@ NS_AX_MATH_BEGIN const Vec3 Vec3::UNIT_Z(0.0f, 0.0f, 1.0f); #endif - -Vec3 Vec3::fromColor(unsigned int color) -{ - float components[3]; - int componentIndex = 0; - for (int i = 2; i >= 0; --i) - { - int component = (color >> i * 8) & 0x0000ff; - - components[componentIndex++] = static_cast(component) / 255.0f; - } - - Vec3 value(components); - return value; -} - float Vec3::angle(const Vec3& v1, const Vec3& v2) { float dx = v1.y * v2.z - v1.z * v2.y; diff --git a/core/math/Vec3.h b/core/math/Vec3.h index 014c96f05c06..6e89db67da63 100644 --- a/core/math/Vec3.h +++ b/core/math/Vec3.h @@ -93,16 +93,6 @@ class AX_DLL Vec3 */ constexpr Vec3(const Vec3& p1, const Vec3& p2) { set(p1, p2); } - /** - * Creates a new vector from an integer interpreted as an RGB value. - * E.g. 0xff0000 represents red or the vector (1, 0, 0). - * - * @param color The integer to interpret as an RGB value. - * - * @return A vector corresponding to the interpreted RGB color. - */ - static Vec3 fromColor(unsigned int color); - /** * Indicates whether this vector contains all zeros. * diff --git a/core/math/Vec4.cpp b/core/math/Vec4.cpp index 3d26db646e3c..464c3805312d 100644 --- a/core/math/Vec4.cpp +++ b/core/math/Vec4.cpp @@ -37,52 +37,8 @@ NS_AX_MATH_BEGIN const Vec4 Vec4::UNIT_W = Vec4(0.0f, 0.0f, 0.0f, 1.0f); #endif - -Vec4 Vec4::fromColor(unsigned int color) -{ - float components[4]; - int componentIndex = 0; - for (int i = 3; i >= 0; --i) - { - int component = (color >> i * 8) & 0x000000ff; - - components[componentIndex++] = static_cast(component) / 255.0f; - } - - Vec4 value(components); - return value; -} - -bool Vec4::isZero() const -{ - return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f; -} - -bool Vec4::isOne() const -{ - return x == 1.0f && y == 1.0f && z == 1.0f && w == 1.0f; -} - -float Vec4::angle(const Vec4& v1, const Vec4& v2) -{ - float dx = v1.w * v2.x - v1.x * v2.w - v1.y * v2.z + v1.z * v2.y; - float dy = v1.w * v2.y - v1.y * v2.w - v1.z * v2.x + v1.x * v2.z; - float dz = v1.w * v2.z - v1.z * v2.w - v1.x * v2.y + v1.y * v2.x; - - return std::atan2(std::sqrt(dx * dx + dy * dy + dz * dz) + MATH_FLOAT_SMALL, dot(v1, v2)); -} - -void Vec4::add(const Vec4& v1, const Vec4& v2, Vec4* dst) -{ - AX_ASSERT(dst); - - dst->x = v1.x + v2.x; - dst->y = v1.y + v2.y; - dst->z = v1.z + v2.z; - dst->w = v1.w + v2.w; -} - -void Vec4::clamp(const Vec4& min, const Vec4& max) + +void Vec4Base::clamp(const Vec4Base& min, const Vec4Base& max) { AX_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); @@ -111,7 +67,7 @@ void Vec4::clamp(const Vec4& min, const Vec4& max) w = max.w; } -void Vec4::clamp(const Vec4& v, const Vec4& min, const Vec4& max, Vec4* dst) +void Vec4Base::clamp(const Vec4Base& v, const Vec4Base& min, const Vec4Base& max, Vec4Base* dst) { AX_ASSERT(dst); AX_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); @@ -145,6 +101,35 @@ void Vec4::clamp(const Vec4& v, const Vec4& min, const Vec4& max, Vec4* dst) dst->w = max.w; } +bool Vec4::isZero() const +{ + return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f; +} + +bool Vec4::isOne() const +{ + return x == 1.0f && y == 1.0f && z == 1.0f && w == 1.0f; +} + +float Vec4::angle(const Vec4& v1, const Vec4& v2) +{ + float dx = v1.w * v2.x - v1.x * v2.w - v1.y * v2.z + v1.z * v2.y; + float dy = v1.w * v2.y - v1.y * v2.w - v1.z * v2.x + v1.x * v2.z; + float dz = v1.w * v2.z - v1.z * v2.w - v1.x * v2.y + v1.y * v2.x; + + return std::atan2(std::sqrt(dx * dx + dy * dy + dz * dz) + MATH_FLOAT_SMALL, dot(v1, v2)); +} + +void Vec4::add(const Vec4& v1, const Vec4& v2, Vec4* dst) +{ + AX_ASSERT(dst); + + dst->x = v1.x + v2.x; + dst->y = v1.y + v2.y; + dst->z = v1.z + v2.z; + dst->w = v1.w + v2.w; +} + float Vec4::distance(const Vec4& v) const { float dx = v.x - x; diff --git a/core/math/Vec4.h b/core/math/Vec4.h index 7541fb59eeb1..5069e3e5966d 100644 --- a/core/math/Vec4.h +++ b/core/math/Vec4.h @@ -36,18 +36,73 @@ NS_AX_MATH_BEGIN class Mat4; -/* - * @brief A 4-floats class template with base math operators - */ -template -class Vec4Base +struct AX_DLL Vec4Base { -public: - using impl_type = _ImplType; - constexpr Vec4Base() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {} constexpr Vec4Base(float xx, float yy, float zz, float ww) : x(xx), y(yy), z(zz), w(ww) {} - constexpr explicit Vec4Base(const float* src) { this->set(src); } + explicit Vec4Base(const float* src) { this->set(src); } + + /** + * Sets the elements of this vector to those in the specified vector. + * + * @param v The vector to copy. + */ + void set(const Vec4Base& v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + this->w = v.w; + } + + /** + * Sets the elements of this vector to the specified values. + * + * @param xx The new x coordinate. + * @param yy The new y coordinate. + * @param zz The new z coordinate. + * @param ww The new w coordinate. + */ + constexpr void set(float xx, float yy, float zz, float ww) + { + this->x = xx; + this->y = yy; + this->z = zz; + this->w = ww; + } + + /** + * Sets the elements of this vector from the values in the specified array. + * + * @param array An array containing the elements of the vector in the order x, y, z, w. + */ + void set(const float* array) + { + AX_ASSERT(array); + + this->x = array[0]; + this->y = array[1]; + this->z = array[2]; + this->w = array[3]; + } + + /** + * Clamps this vector within the specified range. + * + * @param min The minimum value. + * @param max The maximum value. + */ + void clamp(const Vec4Base& min, const Vec4Base& max); + + /** + * Clamps the specified vector within the specified range and returns it in dst. + * + * @param v The vector to clamp. + * @param min The minimum value. + * @param max The maximum value. + * @param dst A vector to store the result in. + */ + static void clamp(const Vec4Base& v, const Vec4Base& min, const Vec4Base& max, Vec4Base* dst); union { @@ -69,6 +124,20 @@ class Vec4Base }; float comps[4]; }; +}; + +/* + * @brief A 4-floats class template with base math operators + */ +template +struct Vec4Adapter : public Vec4Base +{ +public: + using impl_type = _ImplType; + + constexpr Vec4Adapter() = default; + constexpr Vec4Adapter(float xx, float yy, float zz, float ww) : Vec4Base(xx, yy, zz, ww) {} + constexpr explicit Vec4Adapter(const float* src) : Vec4Base(src) {} impl_type& negate() { @@ -112,50 +181,6 @@ class Vec4Base return *static_cast(this); } - /** - * Sets the elements of this vector to the specified values. - * - * @param xx The new x coordinate. - * @param yy The new y coordinate. - * @param zz The new z coordinate. - * @param ww The new w coordinate. - */ - constexpr void set(float xx, float yy, float zz, float ww) - { - this->x = xx; - this->y = yy; - this->z = zz; - this->w = ww; - } - - /** - * Sets the elements of this vector from the values in the specified array. - * - * @param array An array containing the elements of the vector in the order x, y, z, w. - */ - void set(const float* array) - { - AX_ASSERT(array); - - this->x = array[0]; - this->y = array[1]; - this->z = array[2]; - this->w = array[3]; - } - - /** - * Sets the elements of this vector to those in the specified vector. - * - * @param v The vector to copy. - */ - void set(const impl_type& v) - { - this->x = v.x; - this->y = v.y; - this->z = v.z; - this->w = v.w; - } - inline impl_type& operator-() { return impl_type{*static_cast(this)}.negate(); } /** @@ -269,9 +294,9 @@ class Vec4Base /** * Defines 4-element floating point vector. */ -class AX_DLL Vec4 : public Vec4Base +class AX_DLL Vec4 : public Vec4Adapter { - using Vec4Base = Vec4Base; + using MyBase = Vec4Adapter; public: /** @@ -287,14 +312,14 @@ class AX_DLL Vec4 : public Vec4Base * @param zz The z coordinate. * @param ww The w coordinate. */ - constexpr Vec4(float xx, float yy, float zz, float ww) : Vec4Base(xx, yy, zz, ww) {} + constexpr Vec4(float xx, float yy, float zz, float ww) : MyBase(xx, yy, zz, ww) {} /** * Constructs a new vector from the values in the specified array. * * @param array An array containing the elements of the vector in the order x, y, z, w. */ - constexpr explicit Vec4(const float* array) : Vec4Base(array) {} + constexpr explicit Vec4(const float* array) : MyBase(array) {} /** * Constructs a vector that describes the direction between the specified points. @@ -304,16 +329,6 @@ class AX_DLL Vec4 : public Vec4Base */ constexpr Vec4(const Vec4& p1, const Vec4& p2) { setDirection(p1, p2); } - /** - * Creates a new vector from an integer interpreted as an RGBA value. - * E.g. 0xff0000ff represents opaque red or the vector (1, 0, 0, 1). - * - * @param color The integer to interpret as an RGBA value. - * - * @return A vector corresponding to the interpreted RGBA color. - */ - static Vec4 fromColor(unsigned int color); - /** * Indicates whether this vector contains all zeros. * @@ -347,24 +362,6 @@ class AX_DLL Vec4 : public Vec4Base */ static void add(const Vec4& v1, const Vec4& v2, Vec4* dst); - /** - * Clamps this vector within the specified range. - * - * @param min The minimum value. - * @param max The maximum value. - */ - void clamp(const Vec4& min, const Vec4& max); - - /** - * Clamps the specified vector within the specified range and returns it in dst. - * - * @param v The vector to clamp. - * @param min The minimum value. - * @param max The maximum value. - * @param dst A vector to store the result in. - */ - static void clamp(const Vec4& v, const Vec4& min, const Vec4& max, Vec4* dst); - /** * Returns the distance between this vector and v. * @@ -491,12 +488,12 @@ class AX_DLL Vec4 : public Vec4Base }; #if !(defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT)) - inline constexpr Vec4 Vec4::ZERO = Vec4(0.0f, 0.0f, 0.0f, 0.0f); - inline constexpr Vec4 Vec4::ONE = Vec4(1.0f, 1.0f, 1.0f, 1.0f); - inline constexpr Vec4 Vec4::UNIT_X = Vec4(1.0f, 0.0f, 0.0f, 0.0f); - inline constexpr Vec4 Vec4::UNIT_Y = Vec4(0.0f, 1.0f, 0.0f, 0.0f); - inline constexpr Vec4 Vec4::UNIT_Z = Vec4(0.0f, 0.0f, 1.0f, 0.0f); - inline constexpr Vec4 Vec4::UNIT_W = Vec4(0.0f, 0.0f, 0.0f, 1.0f); +inline constexpr Vec4 Vec4::ZERO = Vec4(0.0f, 0.0f, 0.0f, 0.0f); +inline constexpr Vec4 Vec4::ONE = Vec4(1.0f, 1.0f, 1.0f, 1.0f); +inline constexpr Vec4 Vec4::UNIT_X = Vec4(1.0f, 0.0f, 0.0f, 0.0f); +inline constexpr Vec4 Vec4::UNIT_Y = Vec4(0.0f, 1.0f, 0.0f, 0.0f); +inline constexpr Vec4 Vec4::UNIT_Z = Vec4(0.0f, 0.0f, 1.0f, 0.0f); +inline constexpr Vec4 Vec4::UNIT_W = Vec4(0.0f, 0.0f, 0.0f, 1.0f); #endif NS_AX_MATH_END diff --git a/core/physics/PhysicsHelper.h b/core/physics/PhysicsHelper.h new file mode 100644 index 000000000000..3cc10e83f07d --- /dev/null +++ b/core/physics/PhysicsHelper.h @@ -0,0 +1,30 @@ +#pragma once + +#include "math/Math.h" +#include "box2d/box2d.h" + +namespace ax +{ +struct PhysicsHelper +{ + static Vec2 toVec2(const b2Vec2& v) { return Vec2{v.x, v.y}; } + + static b2Vec2 tob2Vec2(const Vec2& v) { return b2Vec2{v.x, v.y}; } + + static Color toColor(b2HexColor color) + { + unsigned int r = ((unsigned int)color >> 16) & 0xff; + unsigned int g = ((unsigned int)color >> 8) & 0xff; + unsigned int b = ((unsigned int)color) & 0xff; + return ax::Color{r / 255.f, g / 255.f, b / 255.f, 1.0f}; + } + + static b2HexColor tob2HexColor(Color color) + { + Color3B ret(color); + return (b2HexColor)(static_cast(ret.r) << 16 | static_cast(ret.g) << 8 | + static_cast(ret.b)); + } +}; + +} // namespace ax diff --git a/core/physics3d/Physics3DDebugDrawer.cpp b/core/physics3d/Physics3DDebugDrawer.cpp index d478f981353c..1d165dc265a6 100644 --- a/core/physics3d/Physics3DDebugDrawer.cpp +++ b/core/physics3d/Physics3DDebugDrawer.cpp @@ -45,10 +45,10 @@ void Physics3DDebugDrawer::drawLine(const btVector3& from, const btVector3& to, Vec3 col = convertbtVector3ToVec3(color); V3F_C4F a, b; - a.vertices = convertbtVector3ToVec3(from); - a.colors = Color(col.x, col.y, col.z, 1.0f); - b.vertices = convertbtVector3ToVec3(to); - b.colors = Color(col.x, col.y, col.z, 1.0f); + a.position = convertbtVector3ToVec3(from); + a.color = Color(col.x, col.y, col.z, 1.0f); + b.position = convertbtVector3ToVec3(to); + b.color = Color(col.x, col.y, col.z, 1.0f); _buffer.emplace_back(a); _buffer.emplace_back(b); diff --git a/core/renderer/Renderer.h b/core/renderer/Renderer.h index 3a9ea0d8ec85..92313c6f00bb 100644 --- a/core/renderer/Renderer.h +++ b/core/renderer/Renderer.h @@ -509,7 +509,7 @@ class AX_DLL Renderer std::vector _groupCommandPool; // for TrianglesCommand - V3F_C4F_T2F _verts[VBO_SIZE]; + V3F_T2F_C4F _verts[VBO_SIZE]; unsigned short _indices[INDEX_VBO_SIZE]; backend::Buffer* _vertexBuffer = nullptr; backend::Buffer* _indexBuffer = nullptr; diff --git a/core/renderer/TrianglesCommand.h b/core/renderer/TrianglesCommand.h index fc546a87c8bc..f8c6680600a2 100644 --- a/core/renderer/TrianglesCommand.h +++ b/core/renderer/TrianglesCommand.h @@ -54,14 +54,14 @@ class AX_DLL TrianglesCommand : public RenderCommand /**The structure of Triangles. */ struct Triangles { - Triangles(V3F_C4F_T2F* _verts, unsigned short* _indices, unsigned int _vertCount, unsigned int _indexCount) + Triangles(V3F_T2F_C4F* _verts, unsigned short* _indices, unsigned int _vertCount, unsigned int _indexCount) : verts(_verts), indices(_indices), vertCount(_vertCount), indexCount(_indexCount) {} Triangles() {} /**Vertex data pointer.*/ - V3F_C4F_T2F* verts = nullptr; + V3F_T2F_C4F* verts = nullptr; /**Index data pointer.*/ unsigned short* indices = nullptr; /**The number of vertices.*/ @@ -98,7 +98,7 @@ class AX_DLL TrianglesCommand : public RenderCommand /**Get the index count of the triangles.*/ size_t getIndexCount() const { return _triangles.indexCount; } /**Get the vertex data pointer.*/ - const V3F_C4F_T2F* getVertices() const { return _triangles.verts; } + const V3F_T2F_C4F* getVertices() const { return _triangles.verts; } /**Get the index data pointer.*/ const unsigned short* getIndices() const { return _triangles.indices; } /**Get the model view matrix.*/ diff --git a/core/renderer/backend/Program.cpp b/core/renderer/backend/Program.cpp index 3282501a5c82..2782f5a856b0 100644 --- a/core/renderer/backend/Program.cpp +++ b/core/renderer/backend/Program.cpp @@ -62,12 +62,12 @@ struct VertexLayoutHelper /// a_texCoord vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_TEXCOORD, program->getAttributeLocation(backend::Attribute::TEXCOORD), - backend::VertexFormat::FLOAT2, offsetof(V3F_C4F_T2F, texCoords), false); + backend::VertexFormat::FLOAT2, offsetof(V3F_T2F_C4F, texCoord), false); /// a_color vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_COLOR, program->getAttributeLocation(backend::Attribute::COLOR), - backend::VertexFormat::FLOAT4, offsetof(V3F_C4F_T2F, colors), false); - vertexLayout->setStride(sizeof(V3F_C4F_T2F)); + backend::VertexFormat::FLOAT4, offsetof(V3F_T2F_C4F, color), false); + vertexLayout->setStride(sizeof(V3F_T2F_C4F)); } static void setupDrawNode(Program* program) @@ -80,12 +80,12 @@ struct VertexLayoutHelper vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_TEXCOORD, program->getAttributeLocation(backend::Attribute::TEXCOORD), - backend::VertexFormat::FLOAT2, offsetof(V2F_C4F_T2F, texCoords), false); + backend::VertexFormat::FLOAT2, offsetof(V2F_T2F_C4F, texCoord), false); vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_COLOR, program->getAttributeLocation(backend::Attribute::COLOR), - backend::VertexFormat::FLOAT4, offsetof(V2F_C4F_T2F, colors), true); + backend::VertexFormat::FLOAT4, offsetof(V2F_T2F_C4F, color), true); - vertexLayout->setStride(sizeof(V2F_C4F_T2F)); + vertexLayout->setStride(sizeof(V2F_T2F_C4F)); } static void setupDrawNode3D(Program* program) @@ -97,7 +97,7 @@ struct VertexLayoutHelper backend::VertexFormat::FLOAT3, 0, false); vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_COLOR, program->getAttributeLocation(backend::Attribute::COLOR), - backend::VertexFormat::FLOAT4, offsetof(V3F_C4F, colors), true); + backend::VertexFormat::FLOAT4, offsetof(V3F_C4F, color), true); vertexLayout->setStride(sizeof(V3F_C4F)); } @@ -111,24 +111,6 @@ struct VertexLayoutHelper vertexLayout->setStride(sizeof(Vec3)); } - static void setupPU3D(Program* program) - { - auto vertexLayout = program->getVertexLayout(); - - vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_POSITION, - program->getAttributeLocation(backend::Attribute::POSITION), - backend::VertexFormat::FLOAT3, offsetof(V3F_T2F_C4F, position), false); - - vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_TEXCOORD, - program->getAttributeLocation(backend::Attribute::TEXCOORD), - backend::VertexFormat::FLOAT2, offsetof(V3F_T2F_C4F, uv), false); - - vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_COLOR, program->getAttributeLocation(backend::Attribute::COLOR), - backend::VertexFormat::FLOAT4, offsetof(V3F_T2F_C4F, color), false); - - vertexLayout->setStride(sizeof(V3F_T2F_C4F)); - } - static void setupPos(Program* program) { auto vertexLayout = program->getVertexLayout(); @@ -145,7 +127,7 @@ struct VertexLayoutHelper program->getAttributeLocation(backend::Attribute::POSITION), backend::VertexFormat::FLOAT3, 0, false); vertexLayout->setAttrib(backend::ATTRIBUTE_NAME_COLOR, program->getAttributeLocation(backend::Attribute::COLOR), - backend::VertexFormat::FLOAT4, offsetof(V3F_C4F, colors), false); + backend::VertexFormat::FLOAT4, offsetof(V3F_C4F, color), false); vertexLayout->setStride(sizeof(V3F_C4F)); } @@ -176,7 +158,7 @@ struct VertexLayoutHelper std::function Program::s_vertexLayoutSetupList[static_cast(VertexLayoutType::Count)] = { VertexLayoutHelper::setupDummy, VertexLayoutHelper::setupPos, VertexLayoutHelper::setupTexture, VertexLayoutHelper::setupSprite, VertexLayoutHelper::setupDrawNode, VertexLayoutHelper::setupDrawNode3D, - VertexLayoutHelper::setupSkyBox, VertexLayoutHelper::setupPU3D, VertexLayoutHelper::setupPosColor, + VertexLayoutHelper::setupSkyBox, VertexLayoutHelper::setupPosColor, VertexLayoutHelper::setupTerrain3D, VertexLayoutHelper::setupInstanced}; Program::Program(std::string_view vs, std::string_view fs) : _vertexShader(vs), _fragmentShader(fs) diff --git a/core/renderer/backend/Program.h b/core/renderer/backend/Program.h index 6d88f4db8069..78870166f829 100644 --- a/core/renderer/backend/Program.h +++ b/core/renderer/backend/Program.h @@ -51,11 +51,10 @@ enum class VertexLayoutType Unspec, // needs binding after program load Pos, // V2F Texture, // T2F - Sprite, // V3F_C4F_T2F posTexColor - DrawNode, // V2F_C4F_T2F + Sprite, // V3F_T2F_C4F posTexColor + DrawNode, // V2F_T2F_C4F DrawNode3D, // V3F_C4F SkyBox, // V3F - PU3D, // V3F_C4F_T2F // same with sprite, TODO: reuse sprite posColor, // V3F_C4F Terrain3D, // V3F_T2F_V3F Instanced, // builtin instanced vertex format for 3D transform diff --git a/core/renderer/backend/ProgramManager.cpp b/core/renderer/backend/ProgramManager.cpp index 60c74f02baf7..13fe28be4e74 100644 --- a/core/renderer/backend/ProgramManager.cpp +++ b/core/renderer/backend/ProgramManager.cpp @@ -140,8 +140,8 @@ bool ProgramManager::init() registerProgram(ProgramType::SKINPOSITION_BUMPEDNORMAL_TEXTURE_3D, skinPositionNormalTexture_vert_1, colorNormalTexture_frag_1, VertexLayoutType::Unspec); registerProgram(ProgramType::TERRAIN_3D, terrain_vert, terrain_frag, VertexLayoutType::Terrain3D); - registerProgram(ProgramType::PARTICLE_TEXTURE_3D, particle_vert, particleTexture_frag, VertexLayoutType::PU3D); - registerProgram(ProgramType::PARTICLE_COLOR_3D, particle_vert, particleColor_frag, VertexLayoutType::PU3D); + registerProgram(ProgramType::PARTICLE_TEXTURE_3D, particle_vert, particleTexture_frag, VertexLayoutType::Sprite); + registerProgram(ProgramType::PARTICLE_COLOR_3D, particle_vert, particleColor_frag, VertexLayoutType::Sprite); registerProgram(ProgramType::QUAD_COLOR_2D, quadColor_vert, quadColor_frag, VertexLayoutType::Unspec); registerProgram(ProgramType::QUAD_TEXTURE_2D, quadTexture_vert, quadTexture_frag, VertexLayoutType::Unspec); registerProgram(ProgramType::HSV, positionTextureColor_vert, hsv_frag, VertexLayoutType::Sprite); diff --git a/extensions/DragonBones/src/DragonBones/CCArmatureDisplay.cpp b/extensions/DragonBones/src/DragonBones/CCArmatureDisplay.cpp index 72c2e5b5f831..37b2e0749e65 100644 --- a/extensions/DragonBones/src/DragonBones/CCArmatureDisplay.cpp +++ b/extensions/DragonBones/src/DragonBones/CCArmatureDisplay.cpp @@ -208,16 +208,16 @@ void DBCCSprite::draw(ax::Renderer* renderer, const ax::Mat4& transform, uint32_ for (ssize_t i = 0; i < count; i++) { // draw 3 lines - auto from = verts[indices[i * 3]].vertices; - auto to = verts[indices[i * 3 + 1]].vertices; + auto from = verts[indices[i * 3]].position; + auto to = verts[indices[i * 3 + 1]].position; _debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4B::WHITE); - from = verts[indices[i * 3 + 1]].vertices; - to = verts[indices[i * 3 + 2]].vertices; + from = verts[indices[i * 3 + 1]].position; + to = verts[indices[i * 3 + 2]].position; _debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4B::WHITE); - from = verts[indices[i * 3 + 2]].vertices; - to = verts[indices[i * 3]].vertices; + from = verts[indices[i * 3 + 2]].position; + to = verts[indices[i * 3]].position; _debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4B::WHITE); } #endif // AX_SPRITE_DEBUG_DRAW diff --git a/extensions/DragonBones/src/DragonBones/CCSlot.cpp b/extensions/DragonBones/src/DragonBones/CCSlot.cpp index 21652aa13227..f0fb73837f0e 100644 --- a/extensions/DragonBones/src/DragonBones/CCSlot.cpp +++ b/extensions/DragonBones/src/DragonBones/CCSlot.cpp @@ -92,7 +92,7 @@ void CCSlot::_updateFrame() const auto& region = currentTextureData->region; const auto& textureAtlasSize = currentTextureData->spriteFrame->getTexture()->getContentSizeInPixels(); - auto vertices = new ax::V3F_C4F_T2F[vertexCount]; // does cocos2dx release it? + auto vertices = new ax::V3F_T2F_C4F[vertexCount]; // does cocos2dx release it? auto vertexIndices = new unsigned short[triangleCount * 3]; // does cocos2dx release it? ax::Rect boundsRect(999999.0f, 999999.0f, -999999.0f, -999999.0f); @@ -103,21 +103,21 @@ void CCSlot::_updateFrame() const auto y = floatArray[vertexOffset + i + 1]; auto u = floatArray[uvOffset + i]; auto v = floatArray[uvOffset + i + 1]; - ax::V3F_C4F_T2F vertexData; - vertexData.vertices.set(x, -y, 0.0f); + ax::V3F_T2F_C4F vertexData; + vertexData.position.set(x, -y, 0.0f); if (currentTextureData->rotated) { - vertexData.texCoords.u = (region.x + (1.0f - v) * region.width) / textureAtlasSize.width; - vertexData.texCoords.v = (region.y + u * region.height) / textureAtlasSize.height; + vertexData.texCoord.u = (region.x + (1.0f - v) * region.width) / textureAtlasSize.width; + vertexData.texCoord.v = (region.y + u * region.height) / textureAtlasSize.height; } else { - vertexData.texCoords.u = (region.x + u * region.width) / textureAtlasSize.width; - vertexData.texCoords.v = (region.y + v * region.height) / textureAtlasSize.height; + vertexData.texCoord.u = (region.x + u * region.width) / textureAtlasSize.width; + vertexData.texCoord.v = (region.y + v * region.height) / textureAtlasSize.height; } - vertexData.colors = ax::Color::WHITE; + vertexData.color = ax::Color::WHITE; vertices[iH] = vertexData; if (boundsRect.origin.x > x) @@ -262,7 +262,7 @@ void CCSlot::_updateMesh() } auto& vertex = vertices[i]; - auto& vertexPosition = vertex.vertices; + auto& vertexPosition = vertex.position; vertexPosition.set(xG, -yG, 0.0f); @@ -307,7 +307,7 @@ void CCSlot::_updateMesh() const auto yG = floatArray[vertexOffset + i + 1] * scale + deformVertices[i + 1]; auto& vertex = vertices[iH]; - auto& vertexPosition = vertex.vertices; + auto& vertexPosition = vertex.position; vertexPosition.set(xG, -yG, 0.0f); diff --git a/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelGenerator.cpp b/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelGenerator.cpp index c566c117fffb..8619b0189fcc 100644 --- a/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelGenerator.cpp +++ b/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelGenerator.cpp @@ -885,7 +885,7 @@ ModelRef ProceduralModelGenerator::Generate(const ProceduralModelParameter& para generator.Rotator = primitiveGenerator; generator.Noise = noiseFunc; generator.CrossSectionType = parameter.Ribbon.CrossSection; - generator.Vertices = parameter.Ribbon.Vertices; + generator.position = parameter.Ribbon.position; generator.Rotate = parameter.Ribbon.Rotate; generator.Count = parameter.Ribbon.Count; generator.RibbonSizes = parameter.Ribbon.RibbonSizes; diff --git a/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelParameter.h b/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelParameter.h index 4829044f58a3..1f26f402b349 100644 --- a/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelParameter.h +++ b/extensions/Effekseer/Effekseer/Effekseer/Model/ProceduralModelParameter.h @@ -189,8 +189,8 @@ struct ProceduralModelParameter if (Ribbon.Rotate != rhs.Ribbon.Rotate) return Ribbon.Rotate < rhs.Ribbon.Rotate; - if (Ribbon.Vertices != rhs.Ribbon.Vertices) - return Ribbon.Vertices < rhs.Ribbon.Vertices; + if (Ribbon.position != rhs.Ribbon.position) + return Ribbon.position < rhs.Ribbon.position; if (Ribbon.RibbonSizes != rhs.Ribbon.RibbonSizes) return Ribbon.RibbonSizes < rhs.Ribbon.RibbonSizes; @@ -366,7 +366,7 @@ struct ProceduralModelParameter { reader.Read(Ribbon.CrossSection); reader.Read(Ribbon.Rotate); - reader.Read(Ribbon.Vertices); + reader.Read(Ribbon.position); reader.Read(Ribbon.RibbonSizes); reader.Read(Ribbon.RibbonAngles); reader.Read(Ribbon.RibbonNoises); diff --git a/extensions/Live2D/Framework/src/Rendering/axmol/CubismCommandBuffer_Cocos2dx.cpp b/extensions/Live2D/Framework/src/Rendering/axmol/CubismCommandBuffer_Cocos2dx.cpp index ac7b03acd22a..45bb5fd0da7d 100644 --- a/extensions/Live2D/Framework/src/Rendering/axmol/CubismCommandBuffer_Cocos2dx.cpp +++ b/extensions/Live2D/Framework/src/Rendering/axmol/CubismCommandBuffer_Cocos2dx.cpp @@ -210,7 +210,7 @@ void CubismCommandBuffer_Cocos2dx::SetWindingMode(WindingType windingType) void CubismCommandBuffer_Cocos2dx::Clear(csmFloat32 r, csmFloat32 g, csmFloat32 b, csmFloat32 a) { // Add the callback command internally. - GetCocos2dRenderer()->clear(ax::ClearFlag::COLOR, ax::Color4F(r, g, b, a), 0.0f, 0, 0.0f); + GetCocos2dRenderer()->clear(ax::ClearFlag::COLOR, ax::Color(r, g, b, a), 0.0f, 0, 0.0f); } void CubismCommandBuffer_Cocos2dx::Viewport(csmFloat32 x, csmFloat32 y, csmFloat32 w, csmFloat32 h) diff --git a/extensions/Particle3D/src/Particle3D/PU/PUBeamRender.cpp b/extensions/Particle3D/src/Particle3D/PU/PUBeamRender.cpp index e6b7018d6eec..17500220c219 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUBeamRender.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUBeamRender.cpp @@ -269,7 +269,7 @@ void PUBeamRender::prepare() PUBillboardChain::Element element; element = PUBillboardChain::Element( Vec3::ZERO, _rendererScale.x * static_cast(_particleSystem)->getDefaultWidth(), - 0.0f, Vec4::ONE, Quaternion::identity()); // V1.51 + 0.0f, Color::WHITE, Quaternion::identity()); // V1.51 _billboardChain->addChainElement(i, element); } diff --git a/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.cpp b/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.cpp index 2769431f15be..963d8241fee7 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.cpp @@ -45,7 +45,7 @@ const size_t PUBillboardChain::SEGMENT_EMPTY = std::numeric_limits::max( //----------------------------------------------------------------------- PUBillboardChain::Element::Element() {} //----------------------------------------------------------------------- -PUBillboardChain::Element::Element(const Vec3& pos, float w, float tex, const Vec4& col, const Quaternion& ori) +PUBillboardChain::Element::Element(const Vec3& pos, float w, float tex, const Color& col, const Quaternion& ori) : position(pos), width(w), texCoord(tex), color(col), orientation(ori) {} //----------------------------------------------------------------------- @@ -157,10 +157,10 @@ void PUBillboardChain::setupBuffers() AX_SAFE_RELEASE_NULL(_vertexBuffer); AX_SAFE_RELEASE_NULL(_indexBuffer); - size_t stride = sizeof(VertexInfo); + size_t stride = sizeof(V3F_T2F_C4F); _vertexBuffer = backend::DriverBase::getInstance()->newBuffer( stride * _chainElementList.size() * 2, backend::BufferType::VERTEX, backend::BufferUsage::DYNAMIC); - VertexInfo vi = {Vec3(0.0f, 0.0f, 0.0f), Vec2(0.0f, 0.0f), Vec4::ONE}; + V3F_T2F_C4F vi = {Vec3(0.0f, 0.0f, 0.0f), Vec2(0.0f, 0.0f), Color::WHITE}; _vertices.resize(_chainElementList.size() * 2, vi); _indexBuffer = @@ -404,7 +404,7 @@ void PUBillboardChain::updateVertexBuffer(const Mat4& camMat) if (!_vertexContentDirty) return; - VertexInfo vi = {Vec3(0.0f, 0.0f, 0.0f), Vec2(0.0f, 0.0f), Vec4::ONE}; + V3F_T2F_C4F vi = {Vec3(0.0f, 0.0f, 0.0f), Vec2(0.0f, 0.0f), Color::WHITE}; _vertices.assign(_vertices.size(), vi); // HardwareVertexBufferSharedPtr pBuffer = // _vertexData->vertexBufferBinding->getBuffer(0); @@ -501,15 +501,15 @@ void PUBillboardChain::updateVertexBuffer(const Mat4& camMat) { //*pFloat++ = elem.texCoord; //*pFloat++ = _otherTexCoordRange[0]; - _vertices[vertexIndex + 0].uv.x = elem.texCoord; - _vertices[vertexIndex + 0].uv.y = _otherTexCoordRange[0]; + _vertices[vertexIndex + 0].texCoord.x = elem.texCoord; + _vertices[vertexIndex + 0].texCoord.y = _otherTexCoordRange[0]; } else { //*pFloat++ = _otherTexCoordRange[0]; //*pFloat++ = elem.texCoord; - _vertices[vertexIndex + 0].uv.x = _otherTexCoordRange[0]; - _vertices[vertexIndex + 0].uv.y = elem.texCoord; + _vertices[vertexIndex + 0].texCoord.x = _otherTexCoordRange[0]; + _vertices[vertexIndex + 0].texCoord.y = elem.texCoord; } // pBase = static_cast(pFloat); } @@ -538,15 +538,15 @@ void PUBillboardChain::updateVertexBuffer(const Mat4& camMat) { //*pFloat++ = elem.texCoord; //*pFloat++ = _otherTexCoordRange[1]; - _vertices[vertexIndex + 1].uv.x = elem.texCoord; - _vertices[vertexIndex + 1].uv.y = _otherTexCoordRange[1]; + _vertices[vertexIndex + 1].texCoord.x = elem.texCoord; + _vertices[vertexIndex + 1].texCoord.y = _otherTexCoordRange[1]; } else { //*pFloat++ = _otherTexCoordRange[1]; //*pFloat++ = elem.texCoord; - _vertices[vertexIndex + 1].uv.x = _otherTexCoordRange[1]; - _vertices[vertexIndex + 1].uv.y = elem.texCoord; + _vertices[vertexIndex + 1].texCoord.x = _otherTexCoordRange[1]; + _vertices[vertexIndex + 1].texCoord.y = elem.texCoord; } } diff --git a/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.h b/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.h index c9179aca02e3..67b0a5629034 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.h +++ b/extensions/Particle3D/src/Particle3D/PU/PUBillboardChain.h @@ -57,13 +57,13 @@ class PUBillboardChain public: Element(); - Element(const Vec3& position, float width, float texCoord, const Vec4& colour, const Quaternion& orientation); + Element(const Vec3& position, float width, float texCoord, const Color& colour, const Quaternion& orientation); Vec3 position; float width; /// U or V texture coord depending on options float texCoord; - Vec4 color; + Color color; // Only used when mFaceCamera == false Quaternion orientation; @@ -310,12 +310,6 @@ class PUBillboardChain /// Chain segment has no elements static const size_t SEGMENT_EMPTY; - struct VertexInfo - { - Vec3 position; - Vec2 uv; - Vec4 color; - }; MeshCommand _meshCommand; RenderState::StateBlock _stateBlock; Texture2D* _texture = nullptr; @@ -323,7 +317,7 @@ class PUBillboardChain backend::Buffer* _indexBuffer = nullptr; // index buffer backend::Buffer* _vertexBuffer = nullptr; // vertex buffer - std::vector _vertices; + std::vector _vertices; std::vector _indices; std::string _texFile; diff --git a/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.cpp b/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.cpp index 5e04e3eb097d..a84d679b475a 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.cpp @@ -48,7 +48,7 @@ void PUColorAffector::setColorOperation(const PUColorAffector::ColorOperation& c _colorOperation = colorOperation; } //----------------------------------------------------------------------- -void PUColorAffector::addColor(float timeFraction, const Vec4& color) +void PUColorAffector::addColor(float timeFraction, const Color& color) { _colorMap[timeFraction] = color; } @@ -91,7 +91,7 @@ void PUColorAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime { // PUParticle3D *particle = iter; // Linear interpolation of the colour - Vec4 color = Vec4::ONE; + Color color = Color::WHITE; float timeFraction = (particle->totalTimeToLive - particle->timeToLive) / particle->totalTimeToLive; ColorMapIterator it1 = findNearestColorMapIterator(timeFraction); ColorMapIterator it2 = it1; @@ -117,7 +117,7 @@ void PUColorAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime else { // Multiply - particle->color = Vec4(color.x * particle->originalColor.x, color.y * particle->originalColor.y, + particle->color = Color(color.x * particle->originalColor.x, color.y * particle->originalColor.y, color.z * particle->originalColor.z, color.w * particle->originalColor.w); } } diff --git a/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.h b/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.h index 0e87f1283801..adc7121020c1 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.h +++ b/extensions/Particle3D/src/Particle3D/PU/PUColorAffector.h @@ -37,8 +37,8 @@ namespace ax class AX_EX_DLL PUColorAffector : public PUAffector { public: - typedef std::map ColorMap; - typedef std::map::iterator ColorMapIterator; + typedef std::map ColorMap; + typedef std::map::iterator ColorMapIterator; enum ColorOperation { CAO_MULTIPLY, @@ -54,7 +54,7 @@ class AX_EX_DLL PUColorAffector : public PUAffector /** */ - void addColor(float timeFraction, const Vec4& color); + void addColor(float timeFraction, const Color& color); /** */ @@ -88,4 +88,4 @@ class AX_EX_DLL PUColorAffector : public PUAffector }; } -#endif \ No newline at end of file +#endif diff --git a/extensions/Particle3D/src/Particle3D/PU/PUColorAffectorTranslator.cpp b/extensions/Particle3D/src/Particle3D/PU/PUColorAffectorTranslator.cpp index 6c7ee4fc4c83..d841da253b3d 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUColorAffectorTranslator.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUColorAffectorTranslator.cpp @@ -46,7 +46,7 @@ bool PUColorAffectorTranslator::translateChildProperty(PUScriptCompiler* compile { int n = 0; float time; - Vec4 colour; + Color color; PUAbstractNodeList::const_iterator i = prop->values.begin(); PUAbstractNodeList::const_iterator end = prop->values.end(); while (i != end) @@ -60,23 +60,23 @@ bool PUColorAffectorTranslator::translateChildProperty(PUScriptCompiler* compile time = v; break; case 1: - colour.x = v; + color.x = v; break; case 2: - colour.y = v; + color.y = v; break; case 3: - colour.z = v; + color.z = v; break; case 4: - colour.w = v; + color.w = v; break; } } ++n; ++i; } - affector->addColor(time, colour); + affector->addColor(time, color); return true; } } diff --git a/extensions/Particle3D/src/Particle3D/PU/PUEmitter.cpp b/extensions/Particle3D/src/Particle3D/PU/PUEmitter.cpp index c7e19bee9ca2..1f6351514e78 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUEmitter.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUEmitter.cpp @@ -433,33 +433,33 @@ bool PUEmitter::makeParticleLocal(PUParticle3D* particle) } //----------------------------------------------------------------------- -const Vec4& PUEmitter::getParticleColor() const +const Color& PUEmitter::getParticleColor() const { return _particleColor; } //----------------------------------------------------------------------- -void PUEmitter::setParticleColor(const Vec4& particleColor) +void PUEmitter::setParticleColor(const Color& particleColor) { _particleColor = particleColor; } //----------------------------------------------------------------------- -const Vec4& PUEmitter::getParticleColorRangeStart() const +const Color& PUEmitter::getParticleColorRangeStart() const { return _particleColorRangeStart; } //----------------------------------------------------------------------- -void PUEmitter::setParticleColorRangeStart(const Vec4& particleColorRangeStart) +void PUEmitter::setParticleColorRangeStart(const Color& particleColorRangeStart) { _particleColorRangeStart = particleColorRangeStart; _particleColorRangeSet = true; } //----------------------------------------------------------------------- -const Vec4& PUEmitter::getParticleColorRangeEnd() const +const Color& PUEmitter::getParticleColorRangeEnd() const { return _particleColorRangeEnd; } //----------------------------------------------------------------------- -void PUEmitter::setParticleColorRangeEnd(const Vec4& particleColorRangeEnd) +void PUEmitter::setParticleColorRangeEnd(const Color& particleColorRangeEnd) { _particleColorRangeEnd = particleColorRangeEnd; _particleColorRangeSet = true; diff --git a/extensions/Particle3D/src/Particle3D/PU/PUEmitter.h b/extensions/Particle3D/src/Particle3D/PU/PUEmitter.h index f3b149a50ed6..9034805c73f3 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUEmitter.h +++ b/extensions/Particle3D/src/Particle3D/PU/PUEmitter.h @@ -262,27 +262,27 @@ class AX_EX_DLL PUEmitter : public Particle3DEmitter /** Get the colour of a particle that will be emitted. */ - const Vec4& getParticleColor() const; + const Color& getParticleColor() const; /** Set the colour of an emitted particle. */ - void setParticleColor(const Vec4& particleColour); + void setParticleColor(const Color& particleColour); /** Get the colour range start of an emitted particle. */ - const Vec4& getParticleColorRangeStart() const; + const Color& getParticleColorRangeStart() const; /** Set the colour range start of an emitted particle. This is the lower value used to generate a random colour. */ - void setParticleColorRangeStart(const Vec4& particleColourRangeStart); + void setParticleColorRangeStart(const Color& particleColourRangeStart); /** Get the colour range end of an emitted particle. */ - const Vec4& getParticleColorRangeEnd() const; + const Color& getParticleColorRangeEnd() const; /** Set the colour range end of an emitted particle. This is the upper value used to generate a random colour. */ - void setParticleColorRangeEnd(const Vec4& particleColourRangeEnd); + void setParticleColorRangeEnd(const Color& particleColourRangeEnd); /** Get the texture coords of an emitted particle. */ @@ -534,15 +534,15 @@ class AX_EX_DLL PUEmitter : public Particle3DEmitter /** Colour that is assigned to an emitted particle. */ - Vec4 _particleColor; + Color _particleColor; /** Used to randomize the colour of an emitted particle. */ - Vec4 _particleColorRangeStart; + Color _particleColorRangeStart; /** Used to randomize the colour of an emitted particle. */ - Vec4 _particleColorRangeEnd; + Color _particleColorRangeEnd; /** Used to determine whether the colour range has been set. */ diff --git a/extensions/Particle3D/src/Particle3D/PU/PUEmitterTranslator.cpp b/extensions/Particle3D/src/Particle3D/PU/PUEmitterTranslator.cpp index 307da57cad8a..a175d2e97ca9 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUEmitterTranslator.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUEmitterTranslator.cpp @@ -303,7 +303,7 @@ void PUEmitterTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode* // Property: start_colour_range if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_START_COLOUR_RANGE], VAL_COLOURVALUE)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { _emitter->setParticleColorRangeStart(val); @@ -315,7 +315,7 @@ void PUEmitterTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode* // Property: end_colour_range if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_END_COLOUR_RANGE], VAL_COLOURVALUE)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { _emitter->setParticleColorRangeEnd(val); @@ -327,7 +327,7 @@ void PUEmitterTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode* // Property: colour if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_COLOUR], VAL_COLOURVALUE)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { _emitter->setParticleColor(val); diff --git a/extensions/Particle3D/src/Particle3D/PU/PUMaterialManager.h b/extensions/Particle3D/src/Particle3D/PU/PUMaterialManager.h index 299fa240462d..9f52cc9e315f 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUMaterialManager.h +++ b/extensions/Particle3D/src/Particle3D/PU/PUMaterialManager.h @@ -42,10 +42,10 @@ class AX_EX_DLL PUMaterial : public Object std::string fileName; std::string name; bool isEnabledLight; - Vec4 ambientColor; - Vec4 diffuseColor; - Vec4 specularColor; - Vec4 emissiveColor; + Color ambientColor; + Color diffuseColor; + Color specularColor; + Color emissiveColor; float shininess; BlendFunc blendFunc; diff --git a/extensions/Particle3D/src/Particle3D/PU/PUMaterialTranslator.cpp b/extensions/Particle3D/src/Particle3D/PU/PUMaterialTranslator.cpp index 703af72f3e3f..76fe5482c2ad 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUMaterialTranslator.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUMaterialTranslator.cpp @@ -198,7 +198,7 @@ void PUMaterialPassTranslator::translate(PUScriptCompiler* compiler, PUAbstractN { if (passValidateProperty(compiler, prop, matToken[TOKEN_MAT_AMIBIENT], VAL_VECTOR4)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { material->ambientColor = val; @@ -209,7 +209,7 @@ void PUMaterialPassTranslator::translate(PUScriptCompiler* compiler, PUAbstractN { if (passValidateProperty(compiler, prop, matToken[TOKEN_MAT_AMIBIENT], VAL_VECTOR4)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { material->diffuseColor = val; @@ -221,7 +221,7 @@ void PUMaterialPassTranslator::translate(PUScriptCompiler* compiler, PUAbstractN PUAbstractNodeList::const_iterator it = prop->values.begin(); PUAbstractNodeList::const_iterator end = prop->values.end(); unsigned int n = 0; - Vec4 color; + Color color; float shininess = 0.0f; while (it != end) { @@ -258,7 +258,7 @@ void PUMaterialPassTranslator::translate(PUScriptCompiler* compiler, PUAbstractN { if (passValidateProperty(compiler, prop, matToken[TOKEN_MAT_AMIBIENT], VAL_VECTOR4)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { material->emissiveColor = val; diff --git a/extensions/Particle3D/src/Particle3D/PU/PUParticleSystem3D.h b/extensions/Particle3D/src/Particle3D/PU/PUParticleSystem3D.h index 68c2842b54e6..8fb7c4baa357 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUParticleSystem3D.h +++ b/extensions/Particle3D/src/Particle3D/PU/PUParticleSystem3D.h @@ -108,7 +108,7 @@ struct AX_EX_DLL PUParticle3D : public Particle3D Vec3 rotationAxis; /** Current and original colour */ - Vec4 originalColor; + Color originalColor; /** The zRotationSpeed is used in combination with zRotation and defines tha actual rotationspeed in 2D. */ diff --git a/extensions/Particle3D/src/Particle3D/PU/PURender.cpp b/extensions/Particle3D/src/Particle3D/PU/PURender.cpp index 4a4ceecf1e07..9b9a52c421c0 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PURender.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PURender.cpp @@ -81,7 +81,7 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4& transform, P if (_vertexBuffer == nullptr) { - size_t stride = sizeof(VertexInfo); + size_t stride = sizeof(V3F_T2F_C4F); _vertexBuffer = backend::DriverBase::getInstance()->newBuffer(stride * 4 * particleSystem->getParticleQuota(), backend::BufferType::VERTEX, backend::BufferUsage::DYNAMIC); @@ -441,11 +441,11 @@ void PUParticle3DQuadRender::determineUVCoords(PUParticle3D* particle) particle->rt_uv = particle->lb_uv + Vec2(_textureCoordsColStep, _textureCoordsRowStep); } -void PUParticle3DQuadRender::fillVertex(unsigned short index, const Vec3& pos, const Vec4& color, const Vec2& uv) +void PUParticle3DQuadRender::fillVertex(unsigned short index, const Vec3& pos, const Color& color, const Vec2& uv) { _vertices[index].position = pos; _vertices[index].color = color; - _vertices[index].uv = uv; + _vertices[index].texCoord = uv; } void PUParticle3DQuadRender::fillTriangle(unsigned short index, unsigned short v0, unsigned short v1, unsigned short v2) @@ -699,7 +699,7 @@ void PUParticle3DBoxRender::render(Renderer* renderer, const Mat4& transform, Pa if (_vertexBuffer == nullptr && _indexBuffer == nullptr) { - size_t stride = sizeof(VertexInfo); + size_t stride = sizeof(V3F_T2F_C4F); _vertexBuffer = backend::DriverBase::getInstance()->newBuffer(stride * 8 * particleSystem->getParticleQuota(), backend::BufferType::VERTEX, backend::BufferUsage::DYNAMIC); @@ -736,44 +736,44 @@ void PUParticle3DBoxRender::render(Renderer* renderer, const Mat4& transform, Pa val = texRot * Vec3(0.0f, 0.75f, 0.0); _vertices[vertexindex + 0].position = particle->position + Vec3(-halfWidth, -halfHeight, halfDepth); _vertices[vertexindex + 0].color = particle->color; - _vertices[vertexindex + 0].uv.x = val.x; - _vertices[vertexindex + 0].uv.y = val.y; + _vertices[vertexindex + 0].texCoord.x = val.x; + _vertices[vertexindex + 0].texCoord.y = val.y; val = texRot * Vec3(0.0f, 0.25f, 0.0); _vertices[vertexindex + 1].position = particle->position + Vec3(halfWidth, -halfHeight, halfDepth); _vertices[vertexindex + 1].color = particle->color; - _vertices[vertexindex + 1].uv.x = val.x; - _vertices[vertexindex + 1].uv.y = val.y; + _vertices[vertexindex + 1].texCoord.x = val.x; + _vertices[vertexindex + 1].texCoord.y = val.y; val = texRot * Vec3(0.5f, 0.25f, 0.0); _vertices[vertexindex + 2].position = particle->position + Vec3(halfWidth, halfHeight, halfDepth); _vertices[vertexindex + 2].color = particle->color; - _vertices[vertexindex + 2].uv.x = val.x; - _vertices[vertexindex + 2].uv.y = val.y; + _vertices[vertexindex + 2].texCoord.x = val.x; + _vertices[vertexindex + 2].texCoord.y = val.y; val = texRot * Vec3(0.5f, 0.75f, 0.0); _vertices[vertexindex + 3].position = particle->position + Vec3(-halfWidth, halfHeight, halfDepth); _vertices[vertexindex + 3].color = particle->color; - _vertices[vertexindex + 3].uv.x = val.x; - _vertices[vertexindex + 3].uv.y = val.y; + _vertices[vertexindex + 3].texCoord.x = val.x; + _vertices[vertexindex + 3].texCoord.y = val.y; val = texRot * Vec3(0.0f, 0.0f, 0.0); _vertices[vertexindex + 4].position = particle->position + Vec3(halfWidth, -halfHeight, -halfDepth); _vertices[vertexindex + 4].color = particle->color; - _vertices[vertexindex + 4].uv.x = val.x; - _vertices[vertexindex + 4].uv.y = val.y; + _vertices[vertexindex + 4].texCoord.x = val.x; + _vertices[vertexindex + 4].texCoord.y = val.y; val = texRot * Vec3(0.0f, 1.0f, 0.0); _vertices[vertexindex + 5].position = particle->position + Vec3(-halfWidth, -halfHeight, -halfDepth); _vertices[vertexindex + 5].color = particle->color; - _vertices[vertexindex + 5].uv.x = val.x; - _vertices[vertexindex + 5].uv.y = val.y; + _vertices[vertexindex + 5].texCoord.x = val.x; + _vertices[vertexindex + 5].texCoord.y = val.y; val = texRot * Vec3(0.5f, 1.0f, 0.0); _vertices[vertexindex + 6].position = particle->position + Vec3(-halfWidth, halfHeight, -halfDepth); _vertices[vertexindex + 6].color = particle->color; - _vertices[vertexindex + 6].uv.x = val.x; - _vertices[vertexindex + 6].uv.y = val.y; + _vertices[vertexindex + 6].texCoord.x = val.x; + _vertices[vertexindex + 6].texCoord.y = val.y; val = texRot * Vec3(0.5f, 0.0f, 0.0); _vertices[vertexindex + 7].position = particle->position + Vec3(halfWidth, halfHeight, -halfDepth); _vertices[vertexindex + 7].color = particle->color; - _vertices[vertexindex + 7].uv.x = val.x; - _vertices[vertexindex + 7].uv.y = val.y; + _vertices[vertexindex + 7].texCoord.x = val.x; + _vertices[vertexindex + 7].texCoord.y = val.y; vertexindex += 8; index += 36; @@ -891,7 +891,7 @@ void PUSphereRender::render(Renderer* renderer, const Mat4& transform, ParticleS unsigned int indexCount = 6 * _numberOfRings * (_numberOfSegments + 1); if (_vertexBuffer == nullptr && _indexBuffer == nullptr) { - size_t stride = sizeof(VertexInfo); + size_t stride = sizeof(V3F_T2F_C4F); _vertexBuffer = backend::DriverBase::getInstance()->newBuffer(stride * vertexCount * particleSystem->getParticleQuota(), backend::BufferType::VERTEX, backend::BufferUsage::DYNAMIC); @@ -937,11 +937,11 @@ void PUSphereRender::render(Renderer* renderer, const Mat4& transform, ParticleS for (unsigned int i = 0; i < vertexCount; ++i) { - val = texRot * Vec3(_vertexTemplate[vertexindex + i].uv.x, _vertexTemplate[vertexindex + i].uv.y, 0.0f); + val = texRot * Vec3(_vertexTemplate[vertexindex + i].texCoord.x, _vertexTemplate[vertexindex + i].texCoord.y, 0.0f); mat.transformPoint(_vertexTemplate[vertexindex + i].position, &_vertices[vertexindex + i].position); _vertices[vertexindex + i].color = particle->color; - _vertices[vertexindex + i].uv.x = val.x; - _vertices[vertexindex + i].uv.y = val.y; + _vertices[vertexindex + i].texCoord.x = val.x; + _vertices[vertexindex + i].texCoord.y = val.y; } vertexindex += vertexCount; index += indexCount; @@ -990,7 +990,7 @@ void PUSphereRender::buildBuffers(unsigned short count) for (unsigned int segment = 0; segment <= _numberOfSegments; segment++) { - VertexInfo vi; + V3F_T2F_C4F vi; float x0 = r0 * sinf(segment * stepSegmentAngle); float z0 = r0 * cosf(segment * stepSegmentAngle); @@ -998,11 +998,11 @@ void PUSphereRender::buildBuffers(unsigned short count) vi.position.set(x0, y0, z0); // Colour - vi.color = Vec4::ONE; + vi.color = Color::WHITE; // Texture Coordinates - vi.uv.x = (float)segment / (float)_numberOfSegments; - vi.uv.y = 1.0f - (float)ring / (float)_numberOfRings; + vi.texCoord.x = (float)segment / (float)_numberOfSegments; + vi.texCoord.y = 1.0f - (float)ring / (float)_numberOfRings; if (ring != _numberOfRings) { diff --git a/extensions/Particle3D/src/Particle3D/PU/PURender.h b/extensions/Particle3D/src/Particle3D/PU/PURender.h index c906d3230851..cb6639042bb3 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PURender.h +++ b/extensions/Particle3D/src/Particle3D/PU/PURender.h @@ -78,13 +78,6 @@ class AX_EX_DLL PUParticle3DEntityRender : public PURender void onAfterDraw(); protected: - struct VertexInfo - { - Vec3 position; - Vec2 uv; - Vec4 color; - }; - MeshCommand _meshCommand; RenderState::StateBlock _stateBlock; @@ -93,7 +86,7 @@ class AX_EX_DLL PUParticle3DEntityRender : public PURender backend::Buffer* _indexBuffer = nullptr; // index buffer backend::Buffer* _vertexBuffer = nullptr; // vertex buffer - std::vector _vertices; + std::vector _vertices; std::vector _indices; std::string _texFile; @@ -172,7 +165,7 @@ class AX_EX_DLL PUParticle3DQuadRender : public PUParticle3DEntityRender protected: void getOriginOffset(int& offsetX, int& offsetY); void determineUVCoords(PUParticle3D* particle); - void fillVertex(unsigned short index, const Vec3& pos, const Vec4& color, const Vec2& uv); + void fillVertex(unsigned short index, const Vec3& pos, const Color& color, const Vec2& uv); void fillTriangle(unsigned short index, unsigned short v0, unsigned short v1, unsigned short v2); protected: @@ -245,7 +238,7 @@ class AX_EX_DLL PUSphereRender : public PUParticle3DEntityRender protected: unsigned short _numberOfRings; unsigned short _numberOfSegments; - std::vector _vertexTemplate; + std::vector _vertexTemplate; }; } diff --git a/extensions/Particle3D/src/Particle3D/PU/PURendererTranslator.cpp b/extensions/Particle3D/src/Particle3D/PU/PURendererTranslator.cpp index 013782ce7a50..7e2f30539b3b 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PURendererTranslator.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PURendererTranslator.cpp @@ -580,7 +580,7 @@ void PURendererTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode* // Property: initial_colour if (passValidateProperty(compiler, prop, token[TOKEN_INITIAL_COLOUR], VAL_COLOURVALUE)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { static_cast(_renderer)->setInitialColor(val); @@ -593,7 +593,7 @@ void PURendererTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode* if (passValidateProperty(compiler, prop, token[TOKEN_RIBBONTRAIL_INITIAL_COLOUR], VAL_COLOURVALUE)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { static_cast(_renderer)->setInitialColor(val); @@ -605,7 +605,7 @@ void PURendererTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode* // Property: colour_change if (passValidateProperty(compiler, prop, token[TOKEN_COLOUR_CHANGE], VAL_COLOURVALUE)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { static_cast(_renderer)->setColorChange(val); @@ -618,7 +618,7 @@ void PURendererTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode* if (passValidateProperty(compiler, prop, token[TOKEN_RIBBONTRAIL_COLOUR_CHANGE], VAL_COLOURVALUE)) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { static_cast(_renderer)->setColorChange(val); diff --git a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.cpp b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.cpp index 98ddfa5b593e..b569e5bf9103 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.cpp @@ -34,6 +34,11 @@ #include "2d/Camera.h" #include "3d/MeshRenderer.h" +#if defined(_WIN32) +# pragma push_macro("TRANSPARENT") +# undef TRANSPARENT +#endif + namespace ax { @@ -137,8 +142,8 @@ void PURibbonTrail::setNumberOfChains(size_t numChains) PUBillboardChain::setNumberOfChains(numChains); - _initialColor.resize(numChains, Vec4::ONE); - _deltaColor.resize(numChains, Vec4::ZERO); + _initialColor.resize(numChains, Color::WHITE); + _deltaColor.resize(numChains, Color::TRANSPARENT); _initialWidth.resize(numChains, 10); _deltaWidth.resize(numChains, 0); @@ -175,7 +180,7 @@ void PURibbonTrail::clearChain(size_t chainIndex) } } //----------------------------------------------------------------------- -void PURibbonTrail::setInitialColour(size_t chainIndex, const Vec4& col) +void PURibbonTrail::setInitialColour(size_t chainIndex, const Color& col) { setInitialColour(chainIndex, col.x, col.y, col.z, col.w); } @@ -189,7 +194,7 @@ void PURibbonTrail::setInitialColour(size_t chainIndex, float r, float g, float _initialColor[chainIndex].w = a; } //----------------------------------------------------------------------- -const Vec4& PURibbonTrail::getInitialColour(size_t chainIndex) const +const Color& PURibbonTrail::getInitialColour(size_t chainIndex) const { AXASSERT(chainIndex < _chainCount, "chainIndex out of bounds"); return _initialColor[chainIndex]; @@ -207,7 +212,7 @@ float PURibbonTrail::getInitialWidth(size_t chainIndex) const return _initialWidth[chainIndex]; } //----------------------------------------------------------------------- -void PURibbonTrail::setColourChange(size_t chainIndex, const Vec4& valuePerSecond) +void PURibbonTrail::setColourChange(size_t chainIndex, const Color& valuePerSecond) { setColourChange(chainIndex, valuePerSecond.x, valuePerSecond.y, valuePerSecond.z, valuePerSecond.w); } @@ -223,7 +228,7 @@ void PURibbonTrail::setColourChange(size_t chainIndex, float r, float g, float b manageController(); } //----------------------------------------------------------------------- -const Vec4& PURibbonTrail::getColourChange(size_t chainIndex) const +const Color& PURibbonTrail::getColourChange(size_t chainIndex) const { AXASSERT(chainIndex < _chainCount, "chainIndex out of bounds"); return _deltaColor[chainIndex]; @@ -247,7 +252,7 @@ void PURibbonTrail::manageController() _needTimeUpdate = false; for (size_t i = 0; i < _chainCount; ++i) { - if (_deltaWidth[i] != 0 || _deltaColor[i] != Vec4::ZERO) + if (_deltaWidth[i] != 0 || !_deltaColor[i].equals(Color::TRANSPARENT)) { _needTimeUpdate = true; break; @@ -421,3 +426,7 @@ void PURibbonTrail::update(float deltaTime) } } + +#if defined(_WIN32) +# pragma pop_macro("TRANSPARENT") +#endif diff --git a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.h b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.h index 88d2d917ee7d..3799eacb360e 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.h +++ b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrail.h @@ -94,7 +94,7 @@ class PURibbonTrail : public PUBillboardChain @note Only used if this instance is using vertex colours. */ - virtual void setInitialColour(size_t chainIndex, const Vec4& col); + virtual void setInitialColour(size_t chainIndex, const Color& col); /** Set the starting ribbon colour. @param chainIndex The index of the chain @param r,b,g,a The initial colour @@ -103,13 +103,13 @@ class PURibbonTrail : public PUBillboardChain */ virtual void setInitialColour(size_t chainIndex, float r, float g, float b, float a = 1.0); /** Get the starting ribbon colour. */ - virtual const Vec4& getInitialColour(size_t chainIndex) const; + virtual const Color& getInitialColour(size_t chainIndex) const; /** Enables / disables fading the trail using colour. @param chainIndex The index of the chain @param valuePerSecond The amount to subtract from colour each second */ - virtual void setColourChange(size_t chainIndex, const Vec4& valuePerSecond); + virtual void setColourChange(size_t chainIndex, const Color& valuePerSecond); /** Set the starting ribbon width in world units. @param chainIndex The index of the chain @@ -134,7 +134,7 @@ class PURibbonTrail : public PUBillboardChain virtual void setColourChange(size_t chainIndex, float r, float g, float b, float a); /** Get the per-second fading amount */ - virtual const Vec4& getColourChange(size_t chainIndex) const; + virtual const Color& getColourChange(size_t chainIndex) const; void update(float deltaTime); @@ -177,7 +177,7 @@ class PURibbonTrail : public PUBillboardChain float _elemLength; /// Squared length of each element float _squaredElemLength; - typedef std::vector ColorValueList; + typedef std::vector ColorValueList; typedef std::vector RealList; /// Initial colour of the ribbon ColorValueList _initialColor; diff --git a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.cpp b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.cpp index b5af038f3587..d23edd03926b 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.cpp @@ -192,22 +192,22 @@ void PURibbonTrailRender::setRandomInitialColor(bool randomInitialColour) _randomInitialColor = randomInitialColour; } //----------------------------------------------------------------------- -const Vec4& PURibbonTrailRender::getInitialColor() const +const Color& PURibbonTrailRender::getInitialColor() const { return _initialColor; } //----------------------------------------------------------------------- -void PURibbonTrailRender::setInitialColor(const Vec4& initialColour) +void PURibbonTrailRender::setInitialColor(const Color& initialColour) { _initialColor = initialColour; } //----------------------------------------------------------------------- -const Vec4& PURibbonTrailRender::getColorChange() const +const Color& PURibbonTrailRender::getColorChange() const { return _colorChange; } //----------------------------------------------------------------------- -void PURibbonTrailRender::setColorChange(const Vec4& colourChange) +void PURibbonTrailRender::setColorChange(const Color& colourChange) { _colorChange = colourChange; } diff --git a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.h b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.h index 7ac35b86599f..be7f47d23e7a 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.h +++ b/extensions/Particle3D/src/Particle3D/PU/PURibbonTrailRender.h @@ -112,11 +112,11 @@ class AX_EX_DLL PURibbonTrailRender : public PURender, public PUListener bool isRandomInitialColor() const; void setRandomInitialColor(bool randomInitialColour); - const Vec4& getInitialColor() const; - void setInitialColor(const Vec4& initialColour); + const Color& getInitialColor() const; + void setInitialColor(const Color& initialColour); - const Vec4& getColorChange() const; - void setColorChange(const Vec4& colourChange); + const Color& getColorChange() const; + void setColorChange(const Color& colourChange); /** Deletes all ChildSceneNodes en Entities. */ @@ -143,8 +143,8 @@ class AX_EX_DLL PURibbonTrailRender : public PURender, public PUListener bool _randomInitialColor; bool _setLength; bool _setWidth; - Vec4 _initialColor; - Vec4 _colorChange; + Color _initialColor; + Color _colorChange; Node* _childNode; std::string _texFile; }; diff --git a/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.cpp b/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.cpp index e73431be83ad..f3e979b8f279 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.cpp +++ b/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.cpp @@ -444,7 +444,7 @@ bool PUScriptTranslator::getVector3(PUAbstractNodeList::const_iterator i, //------------------------------------------------------------------------- bool PUScriptTranslator::getVector4(PUAbstractNodeList::const_iterator i, PUAbstractNodeList::const_iterator end, - Vec4* result, + Color* result, int maxEntries) { int n = 0; @@ -715,7 +715,7 @@ bool PUScriptTranslator::passValidatePropertyValidVector3(PUScriptCompiler* /*co //------------------------------------------------------------------------- bool PUScriptTranslator::passValidatePropertyValidVector4(PUScriptCompiler* /*compiler*/, PUPropertyAbstractNode* prop) { - Vec4 val; + Color val; if (getVector4(prop->values.begin(), prop->values.end(), &val)) { return true; diff --git a/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.h b/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.h index 9287f3ac31ef..74bfe567c50e 100644 --- a/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.h +++ b/extensions/Particle3D/src/Particle3D/PU/PUScriptTranslator.h @@ -666,7 +666,7 @@ class PUScriptTranslator */ bool getVector4(PUAbstractNodeList::const_iterator i, PUAbstractNodeList::const_iterator end, - Vec4* result, + Color* result, int maxEntries = 4); /** Parse Quaternion diff --git a/extensions/Particle3D/src/Particle3D/Particle3DRender.cpp b/extensions/Particle3D/src/Particle3D/Particle3DRender.cpp index d30404b021d8..8453e935589b 100644 --- a/extensions/Particle3D/src/Particle3D/Particle3DRender.cpp +++ b/extensions/Particle3D/src/Particle3D/Particle3DRender.cpp @@ -77,7 +77,7 @@ void Particle3DQuadRender::render(Renderer* renderer, const Mat4& transform, Par if (_vertexBuffer == nullptr) { - size_t stride = sizeof(Particle3DQuadRender::posuvcolor); + size_t stride = sizeof(V3F_T2F_C4F); _vertexBuffer = backend::DriverBase::getInstance()->newBuffer(stride * 4 * particleSystem->getParticleQuota(), backend::BufferType::VERTEX, backend::BufferUsage::DYNAMIC); @@ -127,19 +127,19 @@ void Particle3DQuadRender::render(Renderer* renderer, const Mat4& transform, Par position = particle->position; _posuvcolors[vertexindex].position = (position + (-halfwidth - halfheight)); _posuvcolors[vertexindex].color = particle->color; - _posuvcolors[vertexindex].uv.set(particle->lb_uv); + _posuvcolors[vertexindex].texCoord.set(particle->lb_uv); _posuvcolors[vertexindex + 1].position = (position + (halfwidth - halfheight)); _posuvcolors[vertexindex + 1].color = particle->color; - _posuvcolors[vertexindex + 1].uv.set(particle->rt_uv.x, particle->lb_uv.y); + _posuvcolors[vertexindex + 1].texCoord.set(particle->rt_uv.x, particle->lb_uv.y); _posuvcolors[vertexindex + 2].position = (position + (-halfwidth + halfheight)); _posuvcolors[vertexindex + 2].color = particle->color; - _posuvcolors[vertexindex + 2].uv.set(particle->lb_uv.x, particle->rt_uv.y); + _posuvcolors[vertexindex + 2].texCoord.set(particle->lb_uv.x, particle->rt_uv.y); _posuvcolors[vertexindex + 3].position = (position + (halfwidth + halfheight)); _posuvcolors[vertexindex + 3].color = particle->color; - _posuvcolors[vertexindex + 3].uv.set(particle->rt_uv); + _posuvcolors[vertexindex + 3].texCoord.set(particle->rt_uv); _indexData[index] = vertexindex; _indexData[index + 1] = vertexindex + 1; diff --git a/extensions/Particle3D/src/Particle3D/Particle3DRender.h b/extensions/Particle3D/src/Particle3D/Particle3DRender.h index b52b87cc5741..7e4e00e3cf6d 100644 --- a/extensions/Particle3D/src/Particle3D/Particle3DRender.h +++ b/extensions/Particle3D/src/Particle3D/Particle3DRender.h @@ -119,14 +119,7 @@ class AX_EX_DLL Particle3DQuadRender : public Particle3DRender backend::Buffer* _indexBuffer = nullptr; // index buffer backend::Buffer* _vertexBuffer = nullptr; // vertex buffer - struct posuvcolor - { - Vec3 position; - Vec2 uv; - Vec4 color; - }; - - std::vector _posuvcolors; // vertex data + std::vector _posuvcolors; // vertex data std::vector _indexData; // index data std::string _texFile; diff --git a/extensions/Particle3D/src/Particle3D/ParticleSystem3D.h b/extensions/Particle3D/src/Particle3D/ParticleSystem3D.h index 9896fb518876..6ca41d37ddb3 100644 --- a/extensions/Particle3D/src/Particle3D/ParticleSystem3D.h +++ b/extensions/Particle3D/src/Particle3D/ParticleSystem3D.h @@ -50,7 +50,7 @@ struct AX_EX_DLL Particle3D // property of particles Vec3 position; // position Quaternion orientation; // Orientation of the particle. - Vec4 color; // particle color + Color color; // particle color Vec2 lb_uv; // left bottom uv Vec2 rt_uv; // right top uv float width; // Own width diff --git a/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.cpp b/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.cpp index 65160e2aca20..37ca81de8fc9 100644 --- a/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.cpp +++ b/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.cpp @@ -334,7 +334,7 @@ void BoneNode::setDebugDrawEnabled(bool isDebugDraw) _isRackShow = isDebugDraw; } -void BoneNode::setDebugDrawColor(const ax::Color4F& color) +void BoneNode::setDebugDrawColor(const ax::Color& color) { _rackColor = color; updateColor(); diff --git a/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.h b/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.h index 10aa80f30421..71bad0a1351e 100644 --- a/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.h +++ b/extensions/cocostudio/src/cocostudio/ActionTimeline/BoneNode.h @@ -128,8 +128,8 @@ class CCS_DLL BoneNode : public ax::Node, public ax::BlendProtocol virtual float getDebugDrawWidth() const { return _rackWidth; } // bone's debug draw's width - virtual void setDebugDrawColor(const ax::Color4F& color); - virtual ax::Color4F getDebugDrawColor() const { return _rackColor; } + virtual void setDebugDrawColor(const ax::Color& color); + virtual ax::Color getDebugDrawColor() const { return _rackColor; } // get bone's bounding box, depends on getVisibleSkinsRect, apply on node to parent's transform ax::Rect getBoundingBox() const override; @@ -218,7 +218,7 @@ class CCS_DLL BoneNode : public ax::Node, public ax::BlendProtocol ax::BlendFunc _blendFunc = ax::BlendFunc::ALPHA_NON_PREMULTIPLIED; bool _isRackShow = false; - ax::Color4F _rackColor = ax::Color4F::WHITE; + ax::Color _rackColor = ax::Color::WHITE; float _rackLength = 50.0f; float _rackWidth = 20.0f; @@ -229,7 +229,7 @@ class CCS_DLL BoneNode : public ax::Node, public ax::BlendProtocol private: struct VertexData { - ax::Color4F squareColor; + ax::Color squareColor; ax::Vec3 noMVPVertices; }; diff --git a/extensions/cocostudio/src/cocostudio/ActionTimeline/SkeletonNode.h b/extensions/cocostudio/src/cocostudio/ActionTimeline/SkeletonNode.h index eb93aac5eed2..b2f2ad150c97 100644 --- a/extensions/cocostudio/src/cocostudio/ActionTimeline/SkeletonNode.h +++ b/extensions/cocostudio/src/cocostudio/ActionTimeline/SkeletonNode.h @@ -92,7 +92,7 @@ class CCS_DLL SkeletonNode : public BoneNode struct VertexData { ax::Vec3 vertex; - ax::Color4F color; + ax::Color color; }; ax::Vec2 _squareVertices[8]; diff --git a/extensions/cocostudio/src/cocostudio/Skin.cpp b/extensions/cocostudio/src/cocostudio/Skin.cpp index 25e481f67628..cabc892fdc02 100644 --- a/extensions/cocostudio/src/cocostudio/Skin.cpp +++ b/extensions/cocostudio/src/cocostudio/Skin.cpp @@ -145,10 +145,10 @@ void Skin::updateTransform() // If it is not visible, or one of its ancestors is not visible, then do nothing: if (!_visible) { - _quad.br.vertices.setZero(); - _quad.tl.vertices.setZero(); - _quad.tr.vertices.setZero(); - _quad.bl.vertices.setZero(); + _quad.br.position.setZero(); + _quad.tl.position.setZero(); + _quad.tr.position.setZero(); + _quad.bl.position.setZero(); } else { @@ -193,10 +193,10 @@ void Skin::updateTransform() float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; - _quad.bl.vertices.set(RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ); - _quad.br.vertices.set(RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ); - _quad.tl.vertices.set(RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ); - _quad.tr.vertices.set(RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ); + _quad.bl.position.set(RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ); + _quad.br.position.set(RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ); + _quad.tl.position.set(RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ); + _quad.tr.position.set(RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS diff --git a/extensions/fairygui/src/fairygui/GRoot.cpp b/extensions/fairygui/src/fairygui/GRoot.cpp index 71232cd2e906..c50033366617 100644 --- a/extensions/fairygui/src/fairygui/GRoot.cpp +++ b/extensions/fairygui/src/fairygui/GRoot.cpp @@ -167,7 +167,7 @@ void GRoot::createModalLayer() { _modalLayer = GGraph::create(); _modalLayer->retain(); - _modalLayer->drawRect(getWidth(), getHeight(), 0, Color4F::WHITE, UIConfig::modalLayerColor); + _modalLayer->drawRect(getWidth(), getHeight(), 0, ax::Color::WHITE, UIConfig::modalLayerColor); _modalLayer->addRelation(this, RelationType::Size); } diff --git a/extensions/fairygui/src/fairygui/UIConfig.cpp b/extensions/fairygui/src/fairygui/UIConfig.cpp index 99a9559835b8..fd27f0882f4d 100644 --- a/extensions/fairygui/src/fairygui/UIConfig.cpp +++ b/extensions/fairygui/src/fairygui/UIConfig.cpp @@ -19,7 +19,7 @@ int UIConfig::touchScrollSensitivity = 20; int UIConfig::defaultComboBoxVisibleItemCount = 10; std::string UIConfig::globalModalWaiting = ""; std::string UIConfig::tooltipsWin = ""; -Color4F UIConfig::modalLayerColor = Color4F(0, 0, 0, 0.4f); +ax::Color UIConfig::modalLayerColor = ax::Color(0, 0, 0, 0.4f); bool UIConfig::bringWindowToFrontOnClick = true; std::string UIConfig::windowModalWaiting = ""; std::string UIConfig::popupMenu = ""; diff --git a/extensions/fairygui/src/fairygui/UIConfig.h b/extensions/fairygui/src/fairygui/UIConfig.h index c9b0956d68ba..beaf72310d5c 100644 --- a/extensions/fairygui/src/fairygui/UIConfig.h +++ b/extensions/fairygui/src/fairygui/UIConfig.h @@ -24,7 +24,7 @@ class UIConfig static int touchScrollSensitivity; static int defaultComboBoxVisibleItemCount; static std::string globalModalWaiting; - static ax::Color4F modalLayerColor; + static ax::Color modalLayerColor; static std::string tooltipsWin; static bool bringWindowToFrontOnClick; static std::string windowModalWaiting; diff --git a/extensions/fairygui/src/fairygui/Window.cpp b/extensions/fairygui/src/fairygui/Window.cpp index 0bfa3d08030a..9d5df7faac57 100644 --- a/extensions/fairygui/src/fairygui/Window.cpp +++ b/extensions/fairygui/src/fairygui/Window.cpp @@ -102,7 +102,7 @@ void Window::setDragArea(GObject * value) { _dragArea->retain(); if (dynamic_cast(_dragArea) && ((GGraph*)_dragArea)->isEmpty()) - ((GGraph*)_dragArea)->drawRect(_dragArea->getWidth(), _dragArea->getHeight(), 0, Color4F(0, 0, 0, 0), Color4F(0, 0, 0, 0)); + ((GGraph*)_dragArea)->drawRect(_dragArea->getWidth(), _dragArea->getHeight(), 0, ax::Color(0, 0, 0, 0), ax::Color(0, 0, 0, 0)); _dragArea->setDraggable(true); _dragArea->addEventListener(UIEventType::DragStart, AX_CALLBACK_1(Window::onDragStart, this), EventTag(this)); } diff --git a/extensions/fairygui/src/fairygui/display/FUISprite.cpp b/extensions/fairygui/src/fairygui/display/FUISprite.cpp index 76cf3f16165c..1750f104a6a2 100644 --- a/extensions/fairygui/src/fairygui/display/FUISprite.cpp +++ b/extensions/fairygui/src/fairygui/display/FUISprite.cpp @@ -194,8 +194,8 @@ Tex2F FUISprite::textureCoordFromAlphaPoint(Vec2 alpha) Tex2F ret(0.0f, 0.0f); V3F_C4F_T2F_Quad quad = getQuad(); - Vec2 min(quad.bl.texCoords.u, quad.bl.texCoords.v); - Vec2 max(quad.tr.texCoords.u, quad.tr.texCoords.v); + Vec2 min(quad.bl.texCoord.u, quad.bl.texCoord.v); + Vec2 max(quad.tr.texCoord.u, quad.tr.texCoord.v); // Fix bug #1303 so that progress timer handles sprite frame texture rotation if (isTextureRectRotated()) { @@ -209,8 +209,8 @@ Vec3 FUISprite::vertexFromAlphaPoint(Vec2 alpha) Vec3 ret(0.0f, 0.0f, 0.0f); V3F_C4F_T2F_Quad quad = getQuad(); - Vec2 min(quad.bl.vertices.x, quad.bl.vertices.y); - Vec2 max(quad.tr.vertices.x, quad.tr.vertices.y); + Vec2 min(quad.bl.position.x, quad.bl.position.y); + Vec2 max(quad.tr.position.x, quad.tr.position.y); ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x; ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y; return ret; @@ -222,10 +222,10 @@ void FUISprite::updateColor(void) if (_vertexData) { - Color sc = getQuad().tl.colors; + Color sc = getQuad().tl.color; for (int i = 0; i < _vertexDataCount; ++i) { - _vertexData[i].colors = sc; + _vertexData[i].color = sc; } } } @@ -344,7 +344,7 @@ void FUISprite::updateRadial(void) { _vertexDataCount = index + 3; triangleCount = _vertexDataCount - 2; - _vertexData = (V3F_C4F_T2F*)malloc(_vertexDataCount * sizeof(*_vertexData)); + _vertexData = (V3F_T2F_C4F*)malloc(_vertexDataCount * sizeof(*_vertexData)); _vertexIndex = (unsigned short *)malloc(triangleCount * 3 * sizeof(*_vertexIndex)); AXASSERT(_vertexData, "FUISprite. Not enough memory"); } @@ -360,23 +360,23 @@ void FUISprite::updateRadial(void) // First we populate the array with the _midpoint, then all // vertices/texcoords/colors of the 12 'o clock start and edges and the hitpoint - _vertexData[0].texCoords = textureCoordFromAlphaPoint(midpoint); - _vertexData[0].vertices = vertexFromAlphaPoint(midpoint); + _vertexData[0].texCoord = textureCoordFromAlphaPoint(midpoint); + _vertexData[0].position = vertexFromAlphaPoint(midpoint); - _vertexData[1].texCoords = textureCoordFromAlphaPoint(topMid); - _vertexData[1].vertices = vertexFromAlphaPoint(topMid); + _vertexData[1].texCoord = textureCoordFromAlphaPoint(topMid); + _vertexData[1].position = vertexFromAlphaPoint(topMid); for (int i = 0; i < index; ++i) { Vec2 alphaPoint = boundaryTexCoord(i); - _vertexData[i + 2].texCoords = textureCoordFromAlphaPoint(alphaPoint); - _vertexData[i + 2].vertices = vertexFromAlphaPoint(alphaPoint); + _vertexData[i + 2].texCoord = textureCoordFromAlphaPoint(alphaPoint); + _vertexData[i + 2].position = vertexFromAlphaPoint(alphaPoint); } } // hitpoint will go last - _vertexData[_vertexDataCount - 1].texCoords = textureCoordFromAlphaPoint(hit); - _vertexData[_vertexDataCount - 1].vertices = vertexFromAlphaPoint(hit); + _vertexData[_vertexDataCount - 1].texCoord = textureCoordFromAlphaPoint(hit); + _vertexData[_vertexDataCount - 1].position = vertexFromAlphaPoint(hit); for (int i = 0; i < triangleCount; i++) { _vertexIndex[i * 3] = 0; @@ -433,25 +433,25 @@ void FUISprite::updateBar(void) if (!_vertexData) { _vertexDataCount = 4; - _vertexData = (V3F_C4F_T2F*)malloc(_vertexDataCount * sizeof(*_vertexData)); + _vertexData = (V3F_T2F_C4F*)malloc(_vertexDataCount * sizeof(*_vertexData)); _vertexIndex = (unsigned short*)malloc(6 * sizeof(*_vertexIndex)); AXASSERT(_vertexData, "FUISprite. Not enough memory"); } // TOPLEFT - _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(min.x, max.y)); - _vertexData[0].vertices = vertexFromAlphaPoint(Vec2(min.x, max.y)); + _vertexData[0].texCoord = textureCoordFromAlphaPoint(Vec2(min.x, max.y)); + _vertexData[0].position = vertexFromAlphaPoint(Vec2(min.x, max.y)); // BOTLEFT - _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(min.x, min.y)); - _vertexData[1].vertices = vertexFromAlphaPoint(Vec2(min.x, min.y)); + _vertexData[1].texCoord = textureCoordFromAlphaPoint(Vec2(min.x, min.y)); + _vertexData[1].position = vertexFromAlphaPoint(Vec2(min.x, min.y)); // TOPRIGHT - _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(max.x, max.y)); - _vertexData[2].vertices = vertexFromAlphaPoint(Vec2(max.x, max.y)); + _vertexData[2].texCoord = textureCoordFromAlphaPoint(Vec2(max.x, max.y)); + _vertexData[2].position = vertexFromAlphaPoint(Vec2(max.x, max.y)); // BOTRIGHT - _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(max.x, min.y)); - _vertexData[3].vertices = vertexFromAlphaPoint(Vec2(max.x, min.y)); + _vertexData[3].texCoord = textureCoordFromAlphaPoint(Vec2(max.x, min.y)); + _vertexData[3].position = vertexFromAlphaPoint(Vec2(max.x, min.y)); _vertexIndex[0] = 0; _vertexIndex[1] = 1; diff --git a/extensions/fairygui/src/fairygui/display/FUISprite.h b/extensions/fairygui/src/fairygui/display/FUISprite.h index e1a540f541d3..31377c7c792b 100644 --- a/extensions/fairygui/src/fairygui/display/FUISprite.h +++ b/extensions/fairygui/src/fairygui/display/FUISprite.h @@ -55,7 +55,7 @@ class FUISprite : public ax::Sprite bool _scaleByTile; int _vertexDataCount; ax::TrianglesCommand::Triangles _fillTriangles; - ax::V3F_C4F_T2F *_vertexData; + ax::V3F_T2F_C4F *_vertexData; unsigned short *_vertexIndex; static ax::Texture2D* _empty; diff --git a/extensions/physics-nodes/src/physics-nodes/PhysicsDebugNode.cpp b/extensions/physics-nodes/src/physics-nodes/PhysicsDebugNode.cpp index fb8e4433d2e3..cd0a922bcc11 100644 --- a/extensions/physics-nodes/src/physics-nodes/PhysicsDebugNode.cpp +++ b/extensions/physics-nodes/src/physics-nodes/PhysicsDebugNode.cpp @@ -17,6 +17,7 @@ */ #include "PhysicsDebugNode.h" +#include "physics/PhysicsHelper.h" #if defined(_WIN32) # pragma push_macro("TRANSPARENT") @@ -25,26 +26,6 @@ NS_AX_EXT_BEGIN -static Color4F toColor4F(b2HexColor color) -{ - unsigned int r = ((unsigned int)color >> 16) & 0xff; - unsigned int g = ((unsigned int)color >> 8) & 0xff; - unsigned int b = ((unsigned int)color) & 0xff; - return Color4F{r / 255.f, g / 255.f, b / 255.f, 1.0f}; -} - -static Vec2 toVec2(const b2Vec2& v) -{ - return Vec2{v.x, v.y}; -} - -static b2HexColor tob2HexColor(Color4F color) -{ - Color3B ret(color); - return (b2HexColor)(static_cast(ret.r) << 16 | static_cast(ret.g) << 8 | - static_cast(ret.b)); -} - /// Draw a closed polygon provided in CCW order. // void (*DrawPolygon)(const b2Vec2* vertices, int vertexCount, b2HexColor color, void* context); static void b2DrawPolygon(const b2Vec2* verts, int vertexCount, b2HexColor color, PhysicsDebugNode* dn) @@ -54,7 +35,7 @@ static void b2DrawPolygon(const b2Vec2* verts, int vertexCount, b2HexColor color { vec[i] = Vec2(verts[i].x * dn->getPTMRatio(), verts[i].y * dn->getPTMRatio()) + dn->getWorldOffset(); } - dn->drawPolygon(vec, vertexCount, Color4F::BLACK, 0.4f, toColor4F(color)); + dn->drawPolygon(vec, vertexCount, ax::Color::BLACK, 0.4f, PhysicsHelper::toColor(color)); } /// Draw a solid closed polygon provided in CCW order. @@ -77,8 +58,8 @@ static void b2DrawSolidPolygon(b2Transform t, auto pt = b2TransformPoint(t, verts[i]); vec[i] = Vec2(pt.x * dn->getPTMRatio(), pt.y * dn->getPTMRatio()) + dn->getWorldOffset(); } - auto color4f = toColor4F(color); - dn->drawPolygon(vec.data(), vertexCount, Color4F(color4f.r / 2, color4f.g / 2, color4f.b / 2, color4f.a), 0.5f, + auto color4f = PhysicsHelper::toColor(color); + dn->drawPolygon(vec.data(), vertexCount, ax::Color(color4f.r / 2, color4f.g / 2, color4f.b / 2, color4f.a), 0.5f, color4f); } @@ -87,7 +68,8 @@ static void b2DrawSolidPolygon(b2Transform t, static void b2DrawCircle(b2Vec2 center, float radius, b2HexColor color, PhysicsDebugNode* dn) { dn->drawCircle(Vec2(center.x * dn->getPTMRatio(), center.y * dn->getPTMRatio()) + dn->getWorldOffset(), - radius * dn->getPTMRatio(), AX_DEGREES_TO_RADIANS(0), 30, true, 1.0f, 1.0f, toColor4F(color)); + radius * dn->getPTMRatio(), AX_DEGREES_TO_RADIANS(0), 30, true, 1.0f, 1.0f, + PhysicsHelper::toColor(color)); } /// Draw a solid circle. @@ -96,10 +78,10 @@ static void b2DrawSolidCircle(b2Transform t, float radius, b2HexColor color, Phy { auto center = b2TransformPoint(t, b2Vec2_zero); Vec2 c = {Vec2(center.x * dn->getPTMRatio(), center.y * dn->getPTMRatio()) + dn->getWorldOffset()}; - auto color4f = toColor4F(color); + auto color4f = PhysicsHelper::toColor(color); dn->drawSolidCircle(c, radius * dn->getPTMRatio(), AX_DEGREES_TO_RADIANS(0), 20, 1.0f, 1.0f, - Color4F(color4f.r / 2, color4f.g / 2, color4f.b / 2, color4f.a), 0.4f, color4f); + ax::Color(color4f.r / 2, color4f.g / 2, color4f.b / 2, color4f.a), 0.4f, color4f); // Draw a line fixed in the circle to animate rotation. b2Vec2 pp = {(center + radius * b2Rot_GetXAxis(t.q))}; Vec2 cp = {Vec2(pp.x * dn->getPTMRatio(), pp.y * dn->getPTMRatio()) + dn->getWorldOffset()}; @@ -114,7 +96,8 @@ static void b2DrawSolidCircle(b2Transform t, float radius, b2HexColor color, Phy static void b2DrawSegment(b2Vec2 p1, b2Vec2 p2, b2HexColor color, PhysicsDebugNode* dn) { dn->drawLine(Vec2(p1.x * dn->getPTMRatio(), p1.y * dn->getPTMRatio()) + dn->getWorldOffset(), - Vec2(p2.x * dn->getPTMRatio(), p2.y * dn->getPTMRatio()) + dn->getWorldOffset(), toColor4F(color)); + Vec2(p2.x * dn->getPTMRatio(), p2.y * dn->getPTMRatio()) + dn->getWorldOffset(), + PhysicsHelper::toColor(color)); } /// Draw a transform. Choose your own length scale. @@ -136,7 +119,7 @@ static void b2DrawTransform(b2Transform t, PhysicsDebugNode* dn) static void b2DrawPoint(b2Vec2 p, float size, b2HexColor color, PhysicsDebugNode* dn) { dn->drawPoint(Vec2(p.x * dn->getPTMRatio(), p.y * dn->getPTMRatio()) + dn->getWorldOffset(), size, - toColor4F(color)); + PhysicsHelper::toColor(color)); } bool PhysicsDebugNode::initWithWorld(b2WorldId worldId) diff --git a/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp b/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp index 5ede068fb0ca..af52964f2435 100644 --- a/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp +++ b/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp @@ -16596,9 +16596,9 @@ int lua_ax_base_Director_setClearColor(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Director:setClearColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Director:setClearColor"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_Director_setClearColor'", nullptr); @@ -30464,24 +30464,8 @@ int lua_ax_base_Properties_getColor(lua_State* tolua_S) std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "ax.Properties:getColor"); arg0 = arg0_tmp.c_str(); if (!ok) { break; } - ax::Vec4* arg1; - ok &= luaval_to_object(tolua_S, 3, "ax.Vec4",&arg1, "ax.Properties:getColor"); - - if (!ok) { break; } - bool ret = cobj->getColor(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 2) { - const char* arg0; - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "ax.Properties:getColor"); arg0 = arg0_tmp.c_str(); - - if (!ok) { break; } - ax::Vec3* arg1; - ok &= luaval_to_object(tolua_S, 3, "ax.Vec3",&arg1, "ax.Properties:getColor"); + ax::Color* arg1; + ok &= luaval_to_object(tolua_S, 3, "ax.Color", &arg1, "ax.Properties:getColor"); if (!ok) { break; } bool ret = cobj->getColor(arg0, arg1); @@ -30847,24 +30831,8 @@ int lua_ax_base_Properties_parseColor(lua_State* tolua_S) const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "ax.Properties:parseColor"); arg0 = arg0_tmp.c_str(); if (!ok) { break; } - ax::Vec4* arg1; - ok &= luaval_to_object(tolua_S, 3, "ax.Vec4",&arg1, "ax.Properties:parseColor"); - if (!ok) { break; } - bool ret = ax::Properties::parseColor(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 2) - { - const char* arg0; - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "ax.Properties:parseColor"); arg0 = arg0_tmp.c_str(); - if (!ok) { break; } - ax::Vec3* arg1; - ok &= luaval_to_object(tolua_S, 3, "ax.Vec3",&arg1, "ax.Properties:parseColor"); + ax::Color* arg1; + ok &= luaval_to_object(tolua_S, 3, "ax.Vec4", &arg1, "ax.Properties:parseColor"); if (!ok) { break; } bool ret = ax::Properties::parseColor(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); @@ -51502,7 +51470,7 @@ int lua_ax_base_DrawNode_drawPoint(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawPoint"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawPoint"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawPoint"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawPoint'", nullptr); @@ -51523,7 +51491,7 @@ int lua_ax_base_DrawNode_drawPoint(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawPoint"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawPoint"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawPoint"); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "ax.DrawNode:drawPoint"); if(!ok) @@ -51581,7 +51549,7 @@ int lua_ax_base_DrawNode_drawLine(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawLine"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawLine'", nullptr); @@ -51602,7 +51570,7 @@ int lua_ax_base_DrawNode_drawLine(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawLine"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawLine"); if(!ok) @@ -51626,7 +51594,7 @@ int lua_ax_base_DrawNode_drawLine(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawLine"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawLine"); @@ -51653,7 +51621,7 @@ int lua_ax_base_DrawNode_drawLine(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawLine"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawLine"); @@ -51719,7 +51687,7 @@ int lua_ax_base_DrawNode_drawRect(lua_State* tolua_S) if (!ok) { break; } ax::Color arg4; - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawRect"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawRect"); if (!ok) { break; } cobj->drawRect(arg0, arg1, arg2, arg3, arg4); @@ -51747,7 +51715,7 @@ int lua_ax_base_DrawNode_drawRect(lua_State* tolua_S) if (!ok) { break; } ax::Color arg4; - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawRect"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawRect"); if (!ok) { break; } double arg5; @@ -51771,7 +51739,7 @@ int lua_ax_base_DrawNode_drawRect(lua_State* tolua_S) if (!ok) { break; } ax::Color arg2; - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawRect"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawRect"); if (!ok) { break; } cobj->drawRect(arg0, arg1, arg2); @@ -51791,7 +51759,7 @@ int lua_ax_base_DrawNode_drawRect(lua_State* tolua_S) if (!ok) { break; } ax::Color arg2; - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawRect"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawRect"); if (!ok) { break; } double arg3; @@ -51858,7 +51826,7 @@ int lua_ax_base_DrawNode_drawCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg5; - ok &=luaval_to_color4f(tolua_S, 7, &arg5, "ax.DrawNode:drawCircle"); + ok &=luaval_to_color(tolua_S, 7, &arg5, "ax.DrawNode:drawCircle"); if (!ok) { break; } cobj->drawCircle(arg0, arg1, arg2, arg3, arg4, arg5); @@ -51890,7 +51858,7 @@ int lua_ax_base_DrawNode_drawCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg5; - ok &=luaval_to_color4f(tolua_S, 7, &arg5, "ax.DrawNode:drawCircle"); + ok &=luaval_to_color(tolua_S, 7, &arg5, "ax.DrawNode:drawCircle"); if (!ok) { break; } double arg6; @@ -51934,7 +51902,7 @@ int lua_ax_base_DrawNode_drawCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg7; - ok &=luaval_to_color4f(tolua_S, 9, &arg7, "ax.DrawNode:drawCircle"); + ok &=luaval_to_color(tolua_S, 9, &arg7, "ax.DrawNode:drawCircle"); if (!ok) { break; } cobj->drawCircle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); @@ -51974,7 +51942,7 @@ int lua_ax_base_DrawNode_drawCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg7; - ok &=luaval_to_color4f(tolua_S, 9, &arg7, "ax.DrawNode:drawCircle"); + ok &=luaval_to_color(tolua_S, 9, &arg7, "ax.DrawNode:drawCircle"); if (!ok) { break; } double arg8; @@ -52039,7 +52007,7 @@ int lua_ax_base_DrawNode_drawStar(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawStar"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawStar"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawStar"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawStar'", nullptr); @@ -52066,7 +52034,7 @@ int lua_ax_base_DrawNode_drawStar(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawStar"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawStar"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawStar"); ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawStar"); if(!ok) @@ -52131,9 +52099,9 @@ int lua_ax_base_DrawNode_drawSolidStar(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidStar"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidStar"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidStar"); - ok &=luaval_to_color4f(tolua_S, 7, &arg5, "ax.DrawNode:drawSolidStar"); + ok &=luaval_to_color(tolua_S, 7, &arg5, "ax.DrawNode:drawSolidStar"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSolidStar'", nullptr); @@ -52161,9 +52129,9 @@ int lua_ax_base_DrawNode_drawSolidStar(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidStar"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidStar"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidStar"); - ok &=luaval_to_color4f(tolua_S, 7, &arg5, "ax.DrawNode:drawSolidStar"); + ok &=luaval_to_color(tolua_S, 7, &arg5, "ax.DrawNode:drawSolidStar"); ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawSolidStar"); if(!ok) @@ -52227,7 +52195,7 @@ int lua_ax_base_DrawNode_drawQuadBezier(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawQuadBezier"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawQuadBezier"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawQuadBezier"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawQuadBezier'", nullptr); @@ -52254,7 +52222,7 @@ int lua_ax_base_DrawNode_drawQuadBezier(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawQuadBezier"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawQuadBezier"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawQuadBezier"); ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawQuadBezier"); if(!ok) @@ -52321,7 +52289,7 @@ int lua_ax_base_DrawNode_drawCubicBezier(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 6,&arg4, "ax.DrawNode:drawCubicBezier"); - ok &=luaval_to_color4f(tolua_S, 7, &arg5, "ax.DrawNode:drawCubicBezier"); + ok &=luaval_to_color(tolua_S, 7, &arg5, "ax.DrawNode:drawCubicBezier"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawCubicBezier'", nullptr); @@ -52351,7 +52319,7 @@ int lua_ax_base_DrawNode_drawCubicBezier(lua_State* tolua_S) ok &= luaval_to_uint32(tolua_S, 6,&arg4, "ax.DrawNode:drawCubicBezier"); - ok &=luaval_to_color4f(tolua_S, 7, &arg5, "ax.DrawNode:drawCubicBezier"); + ok &=luaval_to_color(tolua_S, 7, &arg5, "ax.DrawNode:drawCubicBezier"); ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawCubicBezier"); if(!ok) @@ -52409,7 +52377,7 @@ int lua_ax_base_DrawNode_drawDot(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawDot"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawDot"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawDot"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawDot'", nullptr); @@ -52465,7 +52433,7 @@ int lua_ax_base_DrawNode_drawSolidRect(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidRect"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSolidRect'", nullptr); @@ -52486,7 +52454,7 @@ int lua_ax_base_DrawNode_drawSolidRect(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidRect"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidRect"); if(!ok) @@ -52510,11 +52478,11 @@ int lua_ax_base_DrawNode_drawSolidRect(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidRect"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidRect"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidRect"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidRect"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSolidRect'", nullptr); @@ -52582,7 +52550,7 @@ int lua_ax_base_DrawNode_drawSolidCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg6; - ok &=luaval_to_color4f(tolua_S, 8, &arg6, "ax.DrawNode:drawSolidCircle"); + ok &=luaval_to_color(tolua_S, 8, &arg6, "ax.DrawNode:drawSolidCircle"); if (!ok) { break; } cobj->drawSolidCircle(arg0, arg1, arg2, arg3, arg4, arg5, arg6); @@ -52618,7 +52586,7 @@ int lua_ax_base_DrawNode_drawSolidCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg6; - ok &=luaval_to_color4f(tolua_S, 8, &arg6, "ax.DrawNode:drawSolidCircle"); + ok &=luaval_to_color(tolua_S, 8, &arg6, "ax.DrawNode:drawSolidCircle"); if (!ok) { break; } double arg7; @@ -52626,7 +52594,7 @@ int lua_ax_base_DrawNode_drawSolidCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg8; - ok &=luaval_to_color4f(tolua_S, 10, &arg8, "ax.DrawNode:drawSolidCircle"); + ok &=luaval_to_color(tolua_S, 10, &arg8, "ax.DrawNode:drawSolidCircle"); if (!ok) { break; } cobj->drawSolidCircle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); @@ -52662,7 +52630,7 @@ int lua_ax_base_DrawNode_drawSolidCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg6; - ok &=luaval_to_color4f(tolua_S, 8, &arg6, "ax.DrawNode:drawSolidCircle"); + ok &=luaval_to_color(tolua_S, 8, &arg6, "ax.DrawNode:drawSolidCircle"); if (!ok) { break; } double arg7; @@ -52670,7 +52638,7 @@ int lua_ax_base_DrawNode_drawSolidCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg8; - ok &=luaval_to_color4f(tolua_S, 10, &arg8, "ax.DrawNode:drawSolidCircle"); + ok &=luaval_to_color(tolua_S, 10, &arg8, "ax.DrawNode:drawSolidCircle"); if (!ok) { break; } bool arg9; @@ -52702,7 +52670,7 @@ int lua_ax_base_DrawNode_drawSolidCircle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg4; - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidCircle"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidCircle"); if (!ok) { break; } cobj->drawSolidCircle(arg0, arg1, arg2, arg3, arg4); @@ -52772,8 +52740,8 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg7; - ok &=luaval_to_color4f(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + ax::Color arg7; + ok &=luaval_to_color(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); if (!ok) { break; } cobj->drawPie(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); @@ -52812,8 +52780,8 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg7; - ok &=luaval_to_color4f(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + ax::Color arg7; + ok &=luaval_to_color(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); if (!ok) { break; } ax::DrawNode::DrawMode arg8; @@ -52856,12 +52824,12 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg7; - ok &=luaval_to_color4f(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + ax::Color arg7; + ok &=luaval_to_color(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg8; - ok &=luaval_to_color4f(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); + ax::Color arg8; + ok &=luaval_to_color(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); if (!ok) { break; } cobj->drawPie(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); @@ -52900,12 +52868,12 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg7; - ok &=luaval_to_color4f(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + ax::Color arg7; + ok &=luaval_to_color(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg8; - ok &=luaval_to_color4f(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); + ax::Color arg8; + ok &=luaval_to_color(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); if (!ok) { break; } ax::DrawNode::DrawMode arg9; @@ -52948,12 +52916,12 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg7; - ok &=luaval_to_color4f(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + ax::Color arg7; + ok &=luaval_to_color(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); if (!ok) { break; } - ax::Color4F arg8; - ok &=luaval_to_color4f(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); + ax::Color arg8; + ok &=luaval_to_color(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); if (!ok) { break; } ax::DrawNode::DrawMode arg9; @@ -53061,7 +53029,7 @@ int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) ax::Vec2 arg0; ax::Vec2 arg1; double arg2; - ax::Color4F arg3; + ax::Color arg3; ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSegment"); @@ -53069,7 +53037,7 @@ int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSegment"); - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); + ok &=luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSegment'", nullptr); @@ -53084,7 +53052,7 @@ int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) ax::Vec2 arg0; ax::Vec2 arg1; double arg2; - ax::Color4F arg3; + ax::Color arg3; ax::DrawNode::EndType arg4; ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSegment"); @@ -53093,7 +53061,7 @@ int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSegment"); - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); + ok &=luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawSegment"); if(!ok) @@ -53110,7 +53078,7 @@ int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) ax::Vec2 arg0; ax::Vec2 arg1; double arg2; - ax::Color4F arg3; + ax::Color arg3; ax::DrawNode::EndType arg4; ax::DrawNode::EndType arg5; @@ -53120,7 +53088,7 @@ int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSegment"); - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); + ok &=luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawSegment"); @@ -53179,8 +53147,8 @@ int lua_ax_base_DrawNode_drawTriangle(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawTriangle"); if (!ok) { break; } - ax::Color4F arg3; - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawTriangle"); + ax::Color arg3; + ok &=luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawTriangle"); if (!ok) { break; } cobj->drawTriangle(arg0, arg1, arg2, arg3); @@ -53195,8 +53163,8 @@ int lua_ax_base_DrawNode_drawTriangle(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "ax.Vec2",&arg0, "ax.DrawNode:drawTriangle"); if (!ok) { break; } - ax::Color4F arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.DrawNode:drawTriangle"); + ax::Color arg1; + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.DrawNode:drawTriangle"); if (!ok) { break; } cobj->drawTriangle(arg0, arg1); @@ -53250,12 +53218,12 @@ int lua_ax_base_DrawNode_drawSolidTriangle(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } - ax::Color4F arg3; - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawSolidTriangle"); + ax::Color arg3; + ok &=luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } - ax::Color4F arg4; - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidTriangle"); + ax::Color arg4; + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } cobj->drawSolidTriangle(arg0, arg1, arg2, arg3, arg4); @@ -53278,12 +53246,12 @@ int lua_ax_base_DrawNode_drawSolidTriangle(lua_State* tolua_S) ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } - ax::Color4F arg3; - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawSolidTriangle"); + ax::Color arg3; + ok &=luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } - ax::Color4F arg4; - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidTriangle"); + ax::Color arg4; + ok &=luaval_to_color(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } double arg5; @@ -53302,12 +53270,12 @@ int lua_ax_base_DrawNode_drawSolidTriangle(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "ax.Vec2",&arg0, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } - ax::Color4F arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); + ax::Color arg1; + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } - ax::Color4F arg2; - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); + ax::Color arg2; + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } cobj->drawSolidTriangle(arg0, arg1, arg2); @@ -53323,11 +53291,11 @@ int lua_ax_base_DrawNode_drawSolidTriangle(lua_State* tolua_S) if (!ok) { break; } ax::Color arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } ax::Color arg2; - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); if (!ok) { break; } double arg3; @@ -54540,7 +54508,7 @@ int lua_ax_base_Label_setTextColor(lua_State* tolua_S) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Label:setTextColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Label:setTextColor"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_Label_setTextColor'", nullptr); @@ -54648,7 +54616,7 @@ int lua_ax_base_Label_enableShadow(lua_State* tolua_S) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Label:enableShadow"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Label:enableShadow"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_Label_enableShadow'", nullptr); @@ -54663,7 +54631,7 @@ int lua_ax_base_Label_enableShadow(lua_State* tolua_S) ax::Color arg0; ax::Vec2 arg1; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Label:enableShadow"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Label:enableShadow"); ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.Label:enableShadow"); if(!ok) @@ -54681,7 +54649,7 @@ int lua_ax_base_Label_enableShadow(lua_State* tolua_S) ax::Vec2 arg1; int arg2; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Label:enableShadow"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Label:enableShadow"); ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.Label:enableShadow"); @@ -54735,7 +54703,7 @@ int lua_ax_base_Label_enableOutline(lua_State* tolua_S) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Label:enableOutline"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Label:enableOutline"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_Label_enableOutline'", nullptr); @@ -54750,7 +54718,7 @@ int lua_ax_base_Label_enableOutline(lua_State* tolua_S) ax::Color arg0; int arg1; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Label:enableOutline"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Label:enableOutline"); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ax.Label:enableOutline"); if(!ok) @@ -54802,7 +54770,7 @@ int lua_ax_base_Label_enableGlow(lua_State* tolua_S) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.Label:enableGlow"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.Label:enableGlow"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_Label_enableGlow'", nullptr); @@ -55236,7 +55204,7 @@ int lua_ax_base_Label_getShadowColor(lua_State* tolua_S) return 0; } auto&& ret = cobj->getShadowColor(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Label:getShadowColor",argc, 0); @@ -55377,7 +55345,7 @@ int lua_ax_base_Label_getEffectColor(lua_State* tolua_S) return 0; } auto&& ret = cobj->getEffectColor(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Label:getEffectColor",argc, 0); @@ -60882,7 +60850,7 @@ int lua_ax_base_LayerColor_initWithColor(lua_State* tolua_S) do{ if (argc == 1) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerColor:initWithColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerColor:initWithColor"); if (!ok) { break; } bool ret = cobj->initWithColor(arg0); @@ -60894,7 +60862,7 @@ int lua_ax_base_LayerColor_initWithColor(lua_State* tolua_S) do{ if (argc == 3) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerColor:initWithColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerColor:initWithColor"); if (!ok) { break; } double arg1; @@ -60940,7 +60908,7 @@ int lua_ax_base_LayerColor_create(lua_State* tolua_S) if (argc == 3) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerColor:create"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerColor:create"); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.LayerColor:create"); @@ -60969,7 +60937,7 @@ int lua_ax_base_LayerColor_create(lua_State* tolua_S) if (argc == 1) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerColor:create"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerColor:create"); if (!ok) { break; } ax::LayerColor* ret = ax::LayerColor::create(arg0); object_to_luaval(tolua_S, "ax.LayerColor",(ax::LayerColor*)ret); @@ -61653,11 +61621,11 @@ int lua_ax_base_LayerGradient_initWithColor(lua_State* tolua_S) do{ if (argc == 3) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerGradient:initWithColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerGradient:initWithColor"); if (!ok) { break; } ax::Color arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.LayerGradient:initWithColor"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.LayerGradient:initWithColor"); if (!ok) { break; } ax::Vec2 arg2; @@ -61673,11 +61641,11 @@ int lua_ax_base_LayerGradient_initWithColor(lua_State* tolua_S) do{ if (argc == 2) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerGradient:initWithColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerGradient:initWithColor"); if (!ok) { break; } ax::Color arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.LayerGradient:initWithColor"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.LayerGradient:initWithColor"); if (!ok) { break; } bool ret = cobj->initWithColor(arg0, arg1); @@ -61715,10 +61683,10 @@ int lua_ax_base_LayerGradient_create(lua_State* tolua_S) if (argc == 2) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerGradient:create"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerGradient:create"); if (!ok) { break; } ax::Color arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.LayerGradient:create"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.LayerGradient:create"); if (!ok) { break; } ax::LayerGradient* ret = ax::LayerGradient::create(arg0, arg1); object_to_luaval(tolua_S, "ax.LayerGradient",(ax::LayerGradient*)ret); @@ -61741,10 +61709,10 @@ int lua_ax_base_LayerGradient_create(lua_State* tolua_S) if (argc == 3) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerGradient:create"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerGradient:create"); if (!ok) { break; } ax::Color arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.LayerGradient:create"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.LayerGradient:create"); if (!ok) { break; } ax::Vec2 arg2; ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.LayerGradient:create"); @@ -62343,7 +62311,7 @@ int lua_ax_base_LayerRadialGradient_setStartColor(lua_State* tolua_S) do{ if (argc == 1) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerRadialGradient:setStartColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerRadialGradient:setStartColor"); if (!ok) { break; } cobj->setStartColor(arg0); @@ -62492,7 +62460,7 @@ int lua_ax_base_LayerRadialGradient_setEndColor(lua_State* tolua_S) do{ if (argc == 1) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerRadialGradient:setEndColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerRadialGradient:setEndColor"); if (!ok) { break; } cobj->setEndColor(arg0); @@ -62748,9 +62716,9 @@ int lua_ax_base_LayerRadialGradient_initWithColor(lua_State* tolua_S) ax::Vec2 arg3; double arg4; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerRadialGradient:initWithColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerRadialGradient:initWithColor"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.LayerRadialGradient:initWithColor"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.LayerRadialGradient:initWithColor"); ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.LayerRadialGradient:initWithColor"); @@ -62805,10 +62773,10 @@ int lua_ax_base_LayerRadialGradient_create(lua_State* tolua_S) if (argc == 5) { ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.LayerRadialGradient:create"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.LayerRadialGradient:create"); if (!ok) { break; } ax::Color arg1; - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.LayerRadialGradient:create"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.LayerRadialGradient:create"); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.LayerRadialGradient:create"); @@ -73396,7 +73364,7 @@ int lua_ax_base_ParticleSystem_getStartColor(lua_State* tolua_S) return 0; } auto&& ret = cobj->getStartColor(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.ParticleSystem:getStartColor",argc, 0); @@ -73437,9 +73405,9 @@ int lua_ax_base_ParticleSystem_setStartColor(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.ParticleSystem:setStartColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.ParticleSystem:setStartColor"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_ParticleSystem_setStartColor'", nullptr); @@ -73493,7 +73461,7 @@ int lua_ax_base_ParticleSystem_getStartColorVar(lua_State* tolua_S) return 0; } auto&& ret = cobj->getStartColorVar(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.ParticleSystem:getStartColorVar",argc, 0); @@ -73534,9 +73502,9 @@ int lua_ax_base_ParticleSystem_setStartColorVar(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.ParticleSystem:setStartColorVar"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.ParticleSystem:setStartColorVar"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_ParticleSystem_setStartColorVar'", nullptr); @@ -73590,7 +73558,7 @@ int lua_ax_base_ParticleSystem_getEndColor(lua_State* tolua_S) return 0; } auto&& ret = cobj->getEndColor(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.ParticleSystem:getEndColor",argc, 0); @@ -73631,9 +73599,9 @@ int lua_ax_base_ParticleSystem_setEndColor(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.ParticleSystem:setEndColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.ParticleSystem:setEndColor"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_ParticleSystem_setEndColor'", nullptr); @@ -73687,7 +73655,7 @@ int lua_ax_base_ParticleSystem_getEndColorVar(lua_State* tolua_S) return 0; } auto&& ret = cobj->getEndColorVar(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.ParticleSystem:getEndColorVar",argc, 0); @@ -73728,9 +73696,9 @@ int lua_ax_base_ParticleSystem_setEndColorVar(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.ParticleSystem:setEndColorVar"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.ParticleSystem:setEndColorVar"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_ParticleSystem_setEndColorVar'", nullptr); @@ -83692,7 +83660,7 @@ int lua_ax_base_RenderTexture_getClearColor(lua_State* tolua_S) return 0; } auto&& ret = cobj->getClearColor(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.RenderTexture:getClearColor",argc, 0); @@ -83733,9 +83701,9 @@ int lua_ax_base_RenderTexture_setClearColor(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.RenderTexture:setClearColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.RenderTexture:setClearColor"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_RenderTexture_setClearColor'", nullptr); @@ -91666,9 +91634,9 @@ int lua_ax_base_CameraBackgroundBrush_createColorBrush(lua_State* tolua_S) if (argc == 2) { - ax::Color4F arg0; + ax::Color arg0; double arg1; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.CameraBackgroundBrush:createColorBrush"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.CameraBackgroundBrush:createColorBrush"); ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.CameraBackgroundBrush:createColorBrush"); if(!ok) { @@ -91971,9 +91939,9 @@ int lua_ax_base_CameraBackgroundColorBrush_setColor(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.CameraBackgroundColorBrush:setColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.CameraBackgroundColorBrush:setColor"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_CameraBackgroundColorBrush_setColor'", nullptr); @@ -92010,9 +91978,9 @@ int lua_ax_base_CameraBackgroundColorBrush_create(lua_State* tolua_S) if (argc == 2) { - ax::Color4F arg0; + ax::Color arg0; double arg1; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ax.CameraBackgroundColorBrush:create"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ax.CameraBackgroundColorBrush:create"); ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.CameraBackgroundColorBrush:create"); if(!ok) { @@ -99435,14 +99403,14 @@ int lua_ax_base_Renderer_clear(lua_State* tolua_S) if (argc == 5) { ax::backend::TargetBufferFlags arg0; - ax::Color4F arg1; + ax::Color arg1; double arg2; unsigned int arg3; double arg4; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ax.Renderer:clear"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "ax.Renderer:clear"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "ax.Renderer:clear"); ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.Renderer:clear"); @@ -99502,7 +99470,7 @@ int lua_ax_base_Renderer_getClearColor(lua_State* tolua_S) return 0; } auto&& ret = cobj->getClearColor(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Renderer:getClearColor",argc, 0); diff --git a/extensions/scripting/lua-bindings/auto/axlua_fairygui_auto.cpp b/extensions/scripting/lua-bindings/auto/axlua_fairygui_auto.cpp index a90f25984b2f..914fdc8cb90d 100644 --- a/extensions/scripting/lua-bindings/auto/axlua_fairygui_auto.cpp +++ b/extensions/scripting/lua-bindings/auto/axlua_fairygui_auto.cpp @@ -10677,9 +10677,9 @@ int lua_ax_fairygui_GGraph_drawRect(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "fgui.GGraph:drawRect"); - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "fgui.GGraph:drawRect"); + ok &=luaval_to_color(tolua_S, 5, &arg3, "fgui.GGraph:drawRect"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "fgui.GGraph:drawRect"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "fgui.GGraph:drawRect"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_fairygui_GGraph_drawRect'", nullptr); @@ -10739,9 +10739,9 @@ int lua_ax_fairygui_GGraph_drawEllipse(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "fgui.GGraph:drawEllipse"); - ok &=luaval_to_color4f(tolua_S, 5, &arg3, "fgui.GGraph:drawEllipse"); + ok &=luaval_to_color(tolua_S, 5, &arg3, "fgui.GGraph:drawEllipse"); - ok &=luaval_to_color4f(tolua_S, 6, &arg4, "fgui.GGraph:drawEllipse"); + ok &=luaval_to_color(tolua_S, 6, &arg4, "fgui.GGraph:drawEllipse"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_fairygui_GGraph_drawEllipse'", nullptr); @@ -10797,9 +10797,9 @@ int lua_ax_fairygui_GGraph_drawPolygon(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "fgui.GGraph:drawPolygon"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "fgui.GGraph:drawPolygon"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "fgui.GGraph:drawPolygon"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "fgui.GGraph:drawPolygon"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "fgui.GGraph:drawPolygon"); ok &= luaval_to_object(tolua_S, 5, "ax.Vec2",&arg3, "fgui.GGraph:drawPolygon"); @@ -10858,9 +10858,9 @@ int lua_ax_fairygui_GGraph_drawRegularPolygon(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "fgui.GGraph:drawRegularPolygon"); if(!ok) @@ -10882,9 +10882,9 @@ int lua_ax_fairygui_GGraph_drawRegularPolygon(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "fgui.GGraph:drawRegularPolygon"); @@ -10909,9 +10909,9 @@ int lua_ax_fairygui_GGraph_drawRegularPolygon(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "fgui.GGraph:drawRegularPolygon"); @@ -10940,9 +10940,9 @@ int lua_ax_fairygui_GGraph_drawRegularPolygon(lua_State* tolua_S) ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "fgui.GGraph:drawRegularPolygon"); - ok &=luaval_to_color4f(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); + ok &=luaval_to_color(tolua_S, 4, &arg2, "fgui.GGraph:drawRegularPolygon"); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "fgui.GGraph:drawRegularPolygon"); @@ -32483,8 +32483,8 @@ int lua_ax_fairygui_GTween_toColor4B(lua_State* tolua_S) ax::Color arg0; ax::Color arg1; double arg2; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "fgui.GTween:toColor4B"); - ok &=luaval_to_color4f(tolua_S, 3, &arg1, "fgui.GTween:toColor4B"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "fgui.GTween:toColor4B"); + ok &=luaval_to_color(tolua_S, 3, &arg1, "fgui.GTween:toColor4B"); ok &= luaval_to_number(tolua_S, 4,&arg2, "fgui.GTween:toColor4B"); if(!ok) { diff --git a/extensions/scripting/lua-bindings/auto/axlua_studio_auto.cpp b/extensions/scripting/lua-bindings/auto/axlua_studio_auto.cpp index a4b031d2a8bf..113a80a05418 100644 --- a/extensions/scripting/lua-bindings/auto/axlua_studio_auto.cpp +++ b/extensions/scripting/lua-bindings/auto/axlua_studio_auto.cpp @@ -24342,9 +24342,9 @@ int lua_ax_studio_BoneNode_setDebugDrawColor(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ax::Color4F arg0; + ax::Color arg0; - ok &=luaval_to_color4f(tolua_S, 2, &arg0, "ccs.BoneNode:setDebugDrawColor"); + ok &=luaval_to_color(tolua_S, 2, &arg0, "ccs.BoneNode:setDebugDrawColor"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_ax_studio_BoneNode_setDebugDrawColor'", nullptr); @@ -24398,7 +24398,7 @@ int lua_ax_studio_BoneNode_getDebugDrawColor(lua_State* tolua_S) return 0; } auto&& ret = cobj->getDebugDrawColor(); - color4f_to_luaval(tolua_S, ret); + color_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccs.BoneNode:getDebugDrawColor",argc, 0); diff --git a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp index a890931ecfba..7910059791b7 100644 --- a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -708,7 +708,7 @@ bool luaval_to_color4b(lua_State* L, int lo, Color4B* outValue, const char* func return ok; } -bool luaval_to_color4f(lua_State* L, int lo, Color4F* outValue, const char* funcName) +bool luaval_to_color(lua_State* L, int lo, ax::Color* outValue, const char* funcName) { if (NULL == L || NULL == outValue) return false; @@ -1885,7 +1885,7 @@ bool luaval_to_tex2f(lua_State* L, int lo, ax::Tex2F* outValue, const char* func return ok; } -bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_C4F_T2F* outValue, const char* funcName) +bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_T2F_C4F* outValue, const char* funcName) { if (nullptr == L || nullptr == outValue) return false; @@ -1903,7 +1903,7 @@ bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_C4F_T2F* outValue, cons if (ok) { - lua_pushstring(L, "vertices"); + lua_pushstring(L, "position"); lua_gettable(L, lo); if (!tolua_istable(L, lua_gettop(L), 0, &tolua_err)) { @@ -1911,7 +1911,7 @@ bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_C4F_T2F* outValue, cons return false; } - ok &= luaval_to_vec3(L, lua_gettop(L), &outValue->vertices); + ok &= luaval_to_vec3(L, lua_gettop(L), &outValue->position); if (!ok) { lua_pop(L, 1); @@ -1919,14 +1919,14 @@ bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_C4F_T2F* outValue, cons } lua_pop(L, 1); - lua_pushstring(L, "colors"); + lua_pushstring(L, "color"); lua_gettable(L, lo); if (!tolua_istable(L, lua_gettop(L), 0, &tolua_err)) { lua_pop(L, 1); return false; } - ok &= luaval_to_color4f(L, lua_gettop(L), &outValue->colors); + ok &= luaval_to_color(L, lua_gettop(L), &outValue->color); if (!ok) { lua_pop(L, 1); @@ -1934,14 +1934,14 @@ bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_C4F_T2F* outValue, cons } lua_pop(L, 1); - lua_pushstring(L, "texCoords"); + lua_pushstring(L, "texCoord"); lua_gettable(L, lo); if (!tolua_istable(L, lua_gettop(L), 0, &tolua_err)) { lua_pop(L, 1); return false; } - ok &= luaval_to_tex2f(L, lua_gettop(L), &outValue->texCoords); + ok &= luaval_to_tex2f(L, lua_gettop(L), &outValue->texCoord); if (!ok) { lua_pop(L, 1); @@ -2040,7 +2040,7 @@ bool luaval_to_std_vector_vec3(lua_State* L, int lo, std::vector* ret, bool luaval_to_std_vector_v3f_c4b_t2f(lua_State* L, int lo, - std::vector* ret, + std::vector* ret, const char* funcName) { if (nullptr == L || nullptr == ret || lua_gettop(L) < lo) @@ -2060,7 +2060,7 @@ bool luaval_to_std_vector_v3f_c4b_t2f(lua_State* L, if (ok) { size_t len = lua_objlen(L, lo); - ax::V3F_C4F_T2F value; + ax::V3F_T2F_C4F value; for (size_t i = 0; i < len; i++) { lua_pushnumber(L, i + 1); @@ -2075,7 +2075,7 @@ bool luaval_to_std_vector_v3f_c4b_t2f(lua_State* L, } else { - AXASSERT(false, "V3F_C4F_T2F type is needed"); + AXASSERT(false, "V3F_T2F_C4F type is needed"); } lua_pop(L, 1); } @@ -2386,7 +2386,7 @@ void color4b_to_luaval(lua_State* L, const Color4B& color) lua_rawset(L, -3); /* table[key] = value, L: table */ } -void color4f_to_luaval(lua_State* L, const Color4F& color) +void color_to_luaval(lua_State* L, const ax::Color& color) { if (NULL == L) return; diff --git a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h index 9ad3bbdb6253..e82af4ccaf37 100644 --- a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -298,18 +298,18 @@ extern AX_LUA_DLL bool luaval_to_color3b(lua_State* L, int lo, Color3B* outValue extern bool luaval_to_color4b(lua_State* L, int lo, Color4B* outValue, const char* funcName = ""); /** - * Get a Color4F object value from the given acceptable index of stack. + * Get a ax::Color object value from the given acceptable index of stack. * If the value at the given acceptable index of stack is a table it returns true, otherwise returns false. * If the table has the `r`,`g`, `b` and 'a' keys and the corresponding values are not nil, this function would assign * the values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0. * * @param L the current lua_State. * @param lo the given acceptable index of stack. - * @param outValue the pointer to a Color4F object which stores the values from the Lua table. + * @param outValue the pointer to a ax::Color object which stores the values from the Lua table. * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given acceptable index of stack is a table, otherwise return false. */ -extern bool luaval_to_color4f(lua_State* L, int lo, Color4F* outValue, const char* funcName = ""); +extern bool luaval_to_color(lua_State* L, int lo, ax::Color* outValue, const char* funcName = ""); #if defined(AX_ENABLE_PHYSICS) && 0 /** @@ -799,17 +799,17 @@ extern bool luaval_to_quaternion(lua_State* L, int lo, ax::Quaternion* outValue, extern bool luaval_to_texparams(lua_State* L, int lo, ax::Texture2D::TexParams* outValue, const char* funcName = ""); /** - * Get a ax::V3F_C4F_T2F object value from the given acceptable index of stack. + * Get a ax::V3F_T2F_C4F object value from the given acceptable index of stack. * If the value at the given acceptable index of stack is a table it returns true, otherwise returns false. * If the table has the `vertices`, `colors`, and `texCoords` keys and the corresponding values are not nil, this * function would assign the values to the corresponding members of outValue. * @param L the current lua_State. * @param lo the given acceptable index of stack. - * @param outValue the pointer to a ax::V3F_C4F_T2F object which stores the values from the Lua table. + * @param outValue the pointer to a ax::V3F_T2F_C4F object which stores the values from the Lua table. * @param funcName the name of calling function, it is used for error output in the debug model. * @return true if the value at the given acceptable index of stack is a table, otherwise return false. */ -extern bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_C4F_T2F* outValue, const char* funcName = ""); +extern bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_T2F_C4F* outValue, const char* funcName = ""); /** * Get a ax::Tex2F object value from the given acceptable index of stack. @@ -825,17 +825,17 @@ extern bool luaval_to_v3f_c4f_t2f(lua_State* L, int lo, ax::V3F_C4F_T2F* outValu extern bool luaval_to_tex2f(lua_State* L, int lo, ax::Tex2F* outValue, const char* funcName = ""); /** - * Get a pointer points to a std::vector from a Lua array table in the stack. + * Get a pointer points to a std::vector from a Lua array table in the stack. * * @param L the current lua_State. * @param lo the given acceptable index of stack. - * @param ret a pointer points to a std::vector. + * @param ret a pointer points to a std::vector. * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given acceptable index of stack is a table, otherwise return false. */ extern bool luaval_to_std_vector_v3f_c4b_t2f(lua_State* L, int lo, - std::vector* ret, + std::vector* ret, const char* funcName = ""); /** @@ -952,13 +952,13 @@ extern AX_LUA_DLL void color3b_to_luaval(lua_State* L, const Color3B& cc); extern void color4b_to_luaval(lua_State* L, const Color4B& cc); /** - * Push a table converted from a ax::Color4F object into the Lua stack. + * Push a table converted from a ax::Color object into the Lua stack. * The format of table as follows: {r=numberValue1, g=numberValue2, b=numberValue3, a=numberValue4} * * @param L the current lua_State. - * @param cc a ax::Color4F object. + * @param cc a ax::Color object. */ -extern void color4f_to_luaval(lua_State* L, const Color4F& cc); +extern void color_to_luaval(lua_State* L, const Color& cc); void std_thread_id_to_luaval(lua_State* L, const std::thread::id& value); diff --git a/extensions/scripting/lua-bindings/manual/base/axlua_base_manual.cpp b/extensions/scripting/lua-bindings/manual/base/axlua_base_manual.cpp index bd66aae311f8..75face6e60a2 100644 --- a/extensions/scripting/lua-bindings/manual/base/axlua_base_manual.cpp +++ b/extensions/scripting/lua-bindings/manual/base/axlua_base_manual.cpp @@ -3041,8 +3041,8 @@ static int toaxlua_DrawNode_drawPolygon(lua_State* tolua_S) lua_pop(tolua_S, 1); } - Color4F fillColor; - if (!luaval_to_color4f(tolua_S, 4, &fillColor, "ax.DrawNode:drawPolygon")) + ax::Color fillColor; + if (!luaval_to_color(tolua_S, 4, &fillColor, "ax.DrawNode:drawPolygon")) { AX_SAFE_DELETE_ARRAY(points); return 0; @@ -3050,8 +3050,8 @@ static int toaxlua_DrawNode_drawPolygon(lua_State* tolua_S) float borderWidth = (float)tolua_tonumber(tolua_S, 5, 0); - Color4F borderColor; - if (!luaval_to_color4f(tolua_S, 6, &borderColor, "ax.DrawNode:drawPolygon")) + ax::Color borderColor; + if (!luaval_to_color(tolua_S, 6, &borderColor, "ax.DrawNode:drawPolygon")) { AX_SAFE_DELETE_ARRAY(points); return 0; @@ -3125,9 +3125,9 @@ int toaxlua_DrawNode_drawSolidPoly(lua_State* tolua_S) lua_pop(tolua_S, 1); } - ax::Color4F arg2; + ax::Color arg2; - ok &= luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidPoly"); + ok &= luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidPoly"); if (!ok) return 0; self->drawSolidPoly(points, size, arg2); @@ -3204,11 +3204,11 @@ int toaxlua_DrawNode_drawPoly(lua_State* tolua_S) } bool arg2; - ax::Color4F arg3; + ax::Color arg3; ok &= luaval_to_boolean(tolua_S, 4, &arg2, "ax.DrawNode:drawPoly"); - ok &= luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawPoly"); + ok &= luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawPoly"); if (!ok) return 0; @@ -3273,13 +3273,13 @@ int toaxlua_DrawNode_drawCardinalSpline(lua_State* tolua_S) double arg1; unsigned int arg2; - ax::Color4F arg3; + ax::Color arg3; ok &= luaval_to_number(tolua_S, 3, &arg1, "ax.DrawNode:drawCardinalSpline"); ok &= luaval_to_uint32(tolua_S, 4, &arg2, "ax.DrawNode:drawCardinalSpline"); - ok &= luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawCardinalSpline"); + ok &= luaval_to_color(tolua_S, 5, &arg3, "ax.DrawNode:drawCardinalSpline"); if (!ok) return 0; self->drawCardinalSpline(config, (float)arg1, arg2, arg3); @@ -3340,11 +3340,11 @@ int toaxlua_DrawNode_drawCatmullRom(lua_State* tolua_S) AX_SAFE_DELETE_ARRAY(arr); unsigned int arg1; - ax::Color4F arg2; + ax::Color arg2; ok &= luaval_to_uint32(tolua_S, 3, &arg1, "ax.DrawNode:drawCatmullRom"); - ok &= luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawCatmullRom"); + ok &= luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawCatmullRom"); if (!ok) return 0; self->drawCatmullRom(config, arg1, arg2); @@ -3415,9 +3415,9 @@ int toaxlua_DrawNode_drawPoints(lua_State* tolua_S) lua_pop(tolua_S, 1); } - ax::Color4F arg2; + ax::Color arg2; - ok &= luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawPoints"); + ok &= luaval_to_color(tolua_S, 4, &arg2, "ax.DrawNode:drawPoints"); if (!ok) return 0; self->drawPoints(points, size, arg2); @@ -3453,8 +3453,8 @@ int toaxlua_DrawNode_drawPoints(lua_State* tolua_S) } float pointSize = (float)tolua_tonumber(tolua_S, 4, 0); - ax::Color4F color; - ok &= luaval_to_color4f(tolua_S, 5, &color, "ax.DrawNode:drawPoints"); + ax::Color color; + ok &= luaval_to_color(tolua_S, 5, &color, "ax.DrawNode:drawPoints"); if (!ok) return 0; self->drawPoints(points, size, pointSize, color); diff --git a/extensions/scripting/lua-bindings/script/core/Axmol.lua b/extensions/scripting/lua-bindings/script/core/Axmol.lua index 1e1fe29b084c..11d89bc134e0 100644 --- a/extensions/scripting/lua-bindings/script/core/Axmol.lua +++ b/extensions/scripting/lua-bindings/script/core/Axmol.lua @@ -295,7 +295,7 @@ function cc.c4b( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end ---Color4F +--ax::Color function cc.c4f( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end @@ -379,13 +379,13 @@ function cc.Quad3(_tl, _tr, _bl, _br) return { tl = _tl, tr = _tr, bl = _bl, br = _br } end ---V2F_C4F_T2F -function cc.V2F_C4F_T2F(_vertices, _colors, _texCoords) +--V2F_T2F_C4F +function cc.V2F_T2F_C4F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end ---V3F_C4F_T2F -function cc.V3F_C4F_T2F(_vertices, _colors, _texCoords) +--V3F_T2F_C4F +function cc.V3F_T2F_C4F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end diff --git a/extensions/spine/src/spine/SkeletonBatch.cpp b/extensions/spine/src/spine/SkeletonBatch.cpp index d2b9db95b375..ad88ad828586 100644 --- a/extensions/spine/src/spine/SkeletonBatch.cpp +++ b/extensions/spine/src/spine/SkeletonBatch.cpp @@ -107,11 +107,11 @@ namespace spine { reset(); } - axmol::V3F_C4F_T2F *SkeletonBatch::allocateVertices(uint32_t numVertices) { + axmol::V3F_T2F_C4F *SkeletonBatch::allocateVertices(uint32_t numVertices) { if (_vertices.size() - _numVertices < numVertices) { - axmol::V3F_C4F_T2F *oldData = _vertices.data(); + axmol::V3F_T2F_C4F *oldData = _vertices.data(); _vertices.resize((_vertices.size() + numVertices) * 2 + 1); - axmol::V3F_C4F_T2F *newData = _vertices.data(); + axmol::V3F_T2F_C4F *newData = _vertices.data(); for (uint32_t i = 0; i < this->_nextFreeCommand; i++) { SkeletonCommand *command = _commandsPool[i]; SkeletonCommand::Triangles &triangles = (SkeletonCommand::Triangles &) command->getTriangles(); @@ -119,7 +119,7 @@ namespace spine { } } - axmol::V3F_C4F_T2F *vertices = _vertices.data() + _numVertices; + axmol::V3F_T2F_C4F *vertices = _vertices.data() + _numVertices; _numVertices += numVertices; return vertices; } diff --git a/extensions/spine/src/spine/SkeletonBatch.h b/extensions/spine/src/spine/SkeletonBatch.h index c94d2d4779ab..e82af14f0948 100644 --- a/extensions/spine/src/spine/SkeletonBatch.h +++ b/extensions/spine/src/spine/SkeletonBatch.h @@ -49,7 +49,7 @@ namespace spine { void update(float delta); - axmol::V3F_C4F_T2F *allocateVertices(uint32_t numVertices); + axmol::V3F_T2F_C4F *allocateVertices(uint32_t numVertices); void deallocateVertices(uint32_t numVertices); unsigned short *allocateIndices(uint32_t numIndices); void deallocateIndices(uint32_t numVertices); @@ -74,7 +74,7 @@ namespace spine { uint32_t _nextFreeCommand; // pool of vertices - std::vector _vertices; + std::vector _vertices; uint32_t _numVertices; // pool of indices diff --git a/extensions/spine/src/spine/SkeletonRenderer.cpp b/extensions/spine/src/spine/SkeletonRenderer.cpp index c74d627914e3..0131f94e0472 100644 --- a/extensions/spine/src/spine/SkeletonRenderer.cpp +++ b/extensions/spine/src/spine/SkeletonRenderer.cpp @@ -286,11 +286,11 @@ namespace spine { triangles.vertCount = 4; assert(triangles.vertCount == 4); for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) { - auto &texCoords = triangles.verts[v].texCoords; + auto &texCoords = triangles.verts[v].texCoord; texCoords.u = attachment->getUVs()[i]; texCoords.v = attachment->getUVs()[i + 1]; } - dstStride = sizeof(V3F_C4F_T2F) / sizeof(float); + dstStride = sizeof(V3F_T2F_C4F) / sizeof(float); dstTriangleVertices = reinterpret_cast(triangles.verts); } else { trianglesTwoColor.indices = quadIndices; @@ -299,7 +299,7 @@ namespace spine { trianglesTwoColor.vertCount = 4; assert(trianglesTwoColor.vertCount == 4); for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) { - auto &texCoords = trianglesTwoColor.verts[v].texCoords; + auto &texCoords = trianglesTwoColor.verts[v].texCoord; texCoords.u = attachment->getUVs()[i]; texCoords.v = attachment->getUVs()[i + 1]; } @@ -324,12 +324,12 @@ namespace spine { triangles.verts = batch->allocateVertices((int)attachment->getWorldVerticesLength() / 2); triangles.vertCount = (int)attachment->getWorldVerticesLength() / 2; for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) { - auto &texCoords = triangles.verts[v].texCoords; + auto &texCoords = triangles.verts[v].texCoord; texCoords.u = attachment->getUVs()[i]; texCoords.v = attachment->getUVs()[i + 1]; } dstTriangleVertices = (float *) triangles.verts; - dstStride = sizeof(V3F_C4F_T2F) / sizeof(float); + dstStride = sizeof(V3F_T2F_C4F) / sizeof(float); dstVertexCount = triangles.vertCount; } else { trianglesTwoColor.indices = attachment->getTriangles().buffer(); @@ -337,7 +337,7 @@ namespace spine { trianglesTwoColor.verts = twoColorBatch->allocateVertices((int)attachment->getWorldVerticesLength() / 2); trianglesTwoColor.vertCount = (int)attachment->getWorldVerticesLength() / 2; for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) { - auto &texCoords = trianglesTwoColor.verts[v].texCoords; + auto &texCoords = trianglesTwoColor.verts[v].texCoord; texCoords.u = attachment->getUVs()[i]; texCoords.v = attachment->getUVs()[i + 1]; } @@ -391,7 +391,7 @@ namespace spine { if (hasSingleTint) { if (_clipper->isClipping()) { - _clipper->clipTriangles((float *) &triangles.verts[0].vertices, triangles.indices, triangles.indexCount, (float *) &triangles.verts[0].texCoords, sizeof(axmol::V3F_C4F_T2F) / 4); + _clipper->clipTriangles((float *) &triangles.verts[0].position, triangles.indices, triangles.indexCount, (float *) &triangles.verts[0].texCoord, sizeof(axmol::V3F_T2F_C4F) / 4); batch->deallocateVertices(triangles.vertCount); if (_clipper->getClippedTriangles().size() == 0) { @@ -407,24 +407,24 @@ namespace spine { const float* verts = _clipper->getClippedVertices().buffer(); const float* uvs = _clipper->getClippedUVs().buffer(); - V3F_C4F_T2F* vertex = triangles.verts; + V3F_T2F_C4F* vertex = triangles.verts; for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) { - vertex->vertices.x = verts[vv]; - vertex->vertices.y = verts[vv + 1]; - vertex->texCoords.u = uvs[vv]; - vertex->texCoords.v = uvs[vv + 1]; - vertex->colors = color_r; + vertex->position.x = verts[vv]; + vertex->position.y = verts[vv + 1]; + vertex->texCoord.u = uvs[vv]; + vertex->texCoord.v = uvs[vv + 1]; + vertex->color = color_r; } batch->addCommand(renderer, _globalZOrder, texture, _programState, blendFunc, triangles, transform, transformFlags); } else { // Not clipping. - V3F_C4F_T2F* vertex = triangles.verts; + V3F_T2F_C4F* vertex = triangles.verts; for (int v = 0, vn = triangles.vertCount; v < vn; ++v, ++vertex) { - vertex->colors = color_r; + vertex->color = color_r; } batch->addCommand(renderer, _globalZOrder, texture, _programState, blendFunc, triangles, transform, transformFlags); } @@ -432,7 +432,7 @@ namespace spine { // Two color tinting. if (_clipper->isClipping()) { - _clipper->clipTriangles((float *) &trianglesTwoColor.verts[0].position, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float *) &trianglesTwoColor.verts[0].texCoords, sizeof(V3F_C4B_C4B_T2F) / 4); + _clipper->clipTriangles((float *) &trianglesTwoColor.verts[0].position, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float *) &trianglesTwoColor.verts[0].texCoord, sizeof(V3F_C4B_C4B_T2F) / 4); twoColorBatch->deallocateVertices(trianglesTwoColor.vertCount); if (_clipper->getClippedTriangles().size() == 0) { @@ -455,8 +455,8 @@ namespace spine { { vertex->position.x = verts[vv]; vertex->position.y = verts[vv + 1]; - vertex->texCoords.u = uvs[vv]; - vertex->texCoords.v = uvs[vv + 1]; + vertex->texCoord.u = uvs[vv]; + vertex->texCoord.v = uvs[vv + 1]; vertex->color = color_r; vertex->color2 = darkColor_r; } diff --git a/extensions/spine/src/spine/SkeletonTwoColorBatch.cpp b/extensions/spine/src/spine/SkeletonTwoColorBatch.cpp index 71cc7e359a72..0a91fcf92e17 100644 --- a/extensions/spine/src/spine/SkeletonTwoColorBatch.cpp +++ b/extensions/spine/src/spine/SkeletonTwoColorBatch.cpp @@ -69,7 +69,7 @@ namespace { vertexLayout->setAttrib("a_color2", locColor2, backend::VertexFormat::UBYTE4, offsetof(spine::V3F_C4B_C4B_T2F, color2), true); vertexLayout->setAttrib("a_texCoord", locTexcoord, backend::VertexFormat::FLOAT2, - offsetof(spine::V3F_C4B_C4B_T2F, texCoords), false); + offsetof(spine::V3F_C4B_C4B_T2F, texCoord), false); vertexLayout->setStride(sizeof(spine::V3F_C4B_C4B_T2F)); } diff --git a/extensions/spine/src/spine/SkeletonTwoColorBatch.h b/extensions/spine/src/spine/SkeletonTwoColorBatch.h index b928c60bb481..263748ce2ebb 100644 --- a/extensions/spine/src/spine/SkeletonTwoColorBatch.h +++ b/extensions/spine/src/spine/SkeletonTwoColorBatch.h @@ -40,7 +40,7 @@ namespace spine { axmol::Vec3 position; axmol::Color4B color; axmol::Color4B color2; - axmol::Tex2F texCoords; + axmol::Tex2F texCoord; }; struct TwoColorTriangles { diff --git a/templates/cpp/Source/MainScene.cpp b/templates/cpp/Source/MainScene.cpp index 956eaac6b4a2..8e318e182431 100644 --- a/templates/cpp/Source/MainScene.cpp +++ b/templates/cpp/Source/MainScene.cpp @@ -147,7 +147,7 @@ void MainScene::onTouchesBegan(const std::vector& touches, ax::Event { for (auto&& t : touches) { - AXLOG("onTouchesBegan detected, X:%f Y:%f", t->getLocation().x, t->getLocation().y); + AXLOGD("onTouchesBegan detected, X:{} Y:{}", t->getLocation().x, t->getLocation().y); } } @@ -155,7 +155,7 @@ void MainScene::onTouchesMoved(const std::vector& touches, ax::Event { for (auto&& t : touches) { - AXLOG("onTouchesMoved detected, X:%f Y:%f", t->getLocation().x, t->getLocation().y); + AXLOGD("onTouchesMoved detected, X:{} Y:{}", t->getLocation().x, t->getLocation().y); } } @@ -163,42 +163,42 @@ void MainScene::onTouchesEnded(const std::vector& touches, ax::Event { for (auto&& t : touches) { - AXLOG("onTouchesEnded detected, X:%f Y:%f", t->getLocation().x, t->getLocation().y); + AXLOGD("onTouchesEnded detected, X:{} Y:{}", t->getLocation().x, t->getLocation().y); } } void MainScene::onMouseDown(Event* event) { EventMouse* e = static_cast(event); - AXLOG("onMouseDown detected, Key: %d", static_cast(e->getMouseButton())); + AXLOGD("onMouseDown detected, Key: {}", static_cast(e->getMouseButton())); } void MainScene::onMouseUp(Event* event) { EventMouse* e = static_cast(event); - AXLOG("onMouseUp detected, Key: %d", static_cast(e->getMouseButton())); + AXLOGD("onMouseUp detected, Key: {}", static_cast(e->getMouseButton())); } void MainScene::onMouseMove(Event* event) { EventMouse* e = static_cast(event); - AXLOG("onMouseMove detected, X:%f Y:%f", e->getCursorX(), e->getCursorY()); + AXLOGD("onMouseMove detected, X:{} Y:{}", e->getCursorX(), e->getCursorY()); } void MainScene::onMouseScroll(Event* event) { EventMouse* e = static_cast(event); - AXLOG("onMouseScroll detected, X:%f Y:%f", e->getScrollX(), e->getScrollY()); + AXLOGD("onMouseScroll detected, X:{} Y:{}", e->getScrollX(), e->getScrollY()); } void MainScene::onKeyPressed(EventKeyboard::KeyCode code, Event* event) { - AXLOG("onKeyPressed, keycode: %d", static_cast(code)); + AXLOGD("onKeyPressed, keycode: {}", static_cast(code)); } void MainScene::onKeyReleased(EventKeyboard::KeyCode code, Event* event) { - AXLOG("onKeyReleased, keycode: %d", static_cast(code)); + AXLOGD("onKeyReleased, keycode: {}", static_cast(code)); } void MainScene::update(float delta) diff --git a/tests/cpp-tests/Source/Box2DTestBed/Box2DTestDebugDrawNode.cpp b/tests/cpp-tests/Source/Box2DTestBed/Box2DTestDebugDrawNode.cpp index 4beaa32e3fbc..41e648bc5418 100644 --- a/tests/cpp-tests/Source/Box2DTestBed/Box2DTestDebugDrawNode.cpp +++ b/tests/cpp-tests/Source/Box2DTestBed/Box2DTestDebugDrawNode.cpp @@ -1,5 +1,6 @@ #include "Box2DTestDebugDrawNode.h" #include "VisibleRect.h" +#include "physics/PhysicsHelper.h" using namespace ax; @@ -7,16 +8,6 @@ Box2DTestDebugDrawNode* g_pDebugDrawNode; GLFWwindow* g_mainWindow; b2SampleCamera g_camera; -static Vec2 toVec2(const b2Vec2& v) -{ - return Vec2{v.x, v.y}; -} - -static b2Vec2 tob2Vec2(const Vec2& v) -{ - return b2Vec2{v.x, v.y}; -} - b2AABB b2SampleCamera::GetViewBounds() { b2AABB bounds; @@ -47,7 +38,7 @@ static void b2DrawCircle(b2Vec2 center, float radius, b2HexColor color, Box2DTes auto ratio = context->getPTMRatio(); auto offset = context->getWorldOffset(); context->AddCircle(CircleData{b2Vec2{center.x * ratio + offset.x, center.y * ratio + offset.y}, radius * ratio, - Color::fromHex(color)}); + PhysicsHelper::toColor(color)}); } static void b2DrawSolidCircle(b2Transform t, float radius, b2HexColor color, Box2DTestDebugDrawNode* context) @@ -56,8 +47,9 @@ static void b2DrawSolidCircle(b2Transform t, float radius, b2HexColor color, Box // m_circles.push_back({{transform.p.x, transform.p.y, transform.q.c, transform.q.s}, radius, rgba}); auto ratio = context->getPTMRatio(); auto offset = context->getWorldOffset(); - context->AddCircle( - {{t.p.x * ratio + offset.x, t.p.y * ratio + offset.y, t.q.c, t.q.s}, radius * ratio, Color::fromHex(color)}); + context->AddCircle({{t.p.x * ratio + offset.x, t.p.y * ratio + offset.y, t.q.c, t.q.s}, + radius * ratio, + PhysicsHelper::toColor(color)}); } static void b2DrawSolidCapsule(b2Vec2 pt1, b2Vec2 pt2, float radius, b2HexColor c, Box2DTestDebugDrawNode* context) @@ -76,11 +68,11 @@ static void b2DrawSolidCapsule(b2Vec2 pt1, b2Vec2 pt2, float radius, b2HexColor b2Vec2 axis = {d.x / length, d.y / length}; b2Transform transform; - transform.p = tob2Vec2(0.5f * (p1 + p2)); + transform.p = PhysicsHelper::tob2Vec2(0.5f * (p1 + p2)); transform.q.c = axis.x; transform.q.s = axis.y; - ax::Color4F rgba = Color::fromHex(c); + auto rgba = PhysicsHelper::toColor(c); context->AddCapsule({{transform.p.x + offset.x, transform.p.y + offset.y, transform.q.c, transform.q.s}, radius * ratio, @@ -415,5 +407,5 @@ void Box2DTestDebugDrawNode::clear() void Box2DTestDebugDrawNode::DrawAABB(b2AABB aabb, b2HexColor color) { this->drawRect(Vec2{aabb.lowerBound.x, aabb.lowerBound.y}, Vec2{aabb.upperBound.x, aabb.upperBound.y}, - Color::fromHex(color)); + PhysicsHelper::toColor(color)); } diff --git a/tests/cpp-tests/Source/NodeTest/NodeTest.cpp b/tests/cpp-tests/Source/NodeTest/NodeTest.cpp index c794036bcbde..e2b48d486e7e 100644 --- a/tests/cpp-tests/Source/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Source/NodeTest/NodeTest.cpp @@ -963,8 +963,8 @@ bool MySprite::setProgramState(backend::ProgramState* programState, bool ownPS/* _customCommand.setDrawType(CustomCommand::DrawType::ARRAY); _customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE_STRIP); - _customCommand.createVertexBuffer(sizeof(V3F_C4F_T2F), 4, CustomCommand::BufferUsage::STATIC); - _customCommand.updateVertexBuffer(&_quad, 4 * sizeof(V3F_C4F_T2F)); + _customCommand.createVertexBuffer(sizeof(V3F_T2F_C4F), 4, CustomCommand::BufferUsage::STATIC); + _customCommand.updateVertexBuffer(&_quad, 4 * sizeof(V3F_T2F_C4F)); return true; } return false; diff --git a/tests/cpp-tests/Source/SpritePolygonTest/SpritePolygonTest.cpp b/tests/cpp-tests/Source/SpritePolygonTest/SpritePolygonTest.cpp index 4b993a760f4c..33f9800f9f32 100644 --- a/tests/cpp-tests/Source/SpritePolygonTest/SpritePolygonTest.cpp +++ b/tests/cpp-tests/Source/SpritePolygonTest/SpritePolygonTest.cpp @@ -44,7 +44,7 @@ SpritePolygonTest::SpritePolygonTest() ADD_TEST_CASE(SpritePolygonTestAutoPolyIsland); ADD_TEST_CASE(SpritePolygonTestFrameAnim); ADD_TEST_CASE(Issue14017Test); - ADD_TEST_CASE(SpritePolygonTestPerformance); + ADD_TEST_CASE(SpritePolygonTestPerformance); } SpritePolygonTestCase::SpritePolygonTestCase() @@ -129,16 +129,16 @@ void SpritePolygonTestCase::updateDrawNode() for (ssize_t i = 0; i < count; i++) { // draw 3 lines - Vec3 from = verts[indices[i * 3]].vertices; - Vec3 to = verts[indices[i * 3 + 1]].vertices; + Vec3 from = verts[indices[i * 3]].position; + Vec3 to = verts[indices[i * 3 + 1]].position; drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4F::BLUE); - from = verts[indices[i * 3 + 1]].vertices; - to = verts[indices[i * 3 + 2]].vertices; + from = verts[indices[i * 3 + 1]].position; + to = verts[indices[i * 3 + 2]].position; drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4F::GREEN); - from = verts[indices[i * 3 + 2]].vertices; - to = verts[indices[i * 3]].vertices; + from = verts[indices[i * 3 + 2]].position; + to = verts[indices[i * 3]].position; drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4F::RED); } } @@ -241,10 +241,10 @@ void SpritePolygonTest2::initSprites() auto offset = Vec2(0.15 * s.width, 0); auto filename = s_pathGrossini; - // Fix for issue #231 Rect have to be adapt to the 2.0/"ContentScaleFactor()" + // Fix for issue #231 Rect have to be adapt to the 2.0/"ContentScaleFactor()" auto a = 2.0 / Director::getInstance()->getContentScaleFactor(); Rect head = Rect(30 * a, 25 * a, 25 * a, 25 * a); - + // Sprite auto pinfo = AutoPolygon::generatePolygon(filename, head); _polygonSprite = Sprite::create(pinfo); diff --git a/tests/lua-tests/Source/lua_test_bindings.cpp b/tests/lua-tests/Source/lua_test_bindings.cpp index 6f3d1c022ee5..4290fa830526 100644 --- a/tests/lua-tests/Source/lua_test_bindings.cpp +++ b/tests/lua-tests/Source/lua_test_bindings.cpp @@ -465,7 +465,7 @@ int lua_cocos2dx_DrawNode3D_drawLine(lua_State* L) ok &= luaval_to_vec3(L, 3, &arg1, "ax.DrawNode3D:drawLine"); - ok &= luaval_to_color4f(L, 4, &arg2, "ax.DrawNode3D:drawLine"); + ok &= luaval_to_color(L, 4, &arg2, "ax.DrawNode3D:drawLine"); if (!ok) return 0; cobj->drawLine(arg0, arg1, arg2); @@ -587,7 +587,7 @@ int lua_cocos2dx_DrawNode3D_drawCube(lua_State* L) lua_pop(L, 1); } - ok &= luaval_to_color4f(L, 3, &arg1, "ax.DrawNode3D:drawCube"); + ok &= luaval_to_color(L, 3, &arg1, "ax.DrawNode3D:drawCube"); if (!ok) return 0; cobj->drawCube(&arg0[0], arg1); diff --git a/tests/unit-tests/Source/core/math/MathUtilTests.cpp b/tests/unit-tests/Source/core/math/MathUtilTests.cpp index 0edbc5084c89..faef547eb313 100644 --- a/tests/unit-tests/Source/core/math/MathUtilTests.cpp +++ b/tests/unit-tests/Source/core/math/MathUtilTests.cpp @@ -67,33 +67,33 @@ TEST_SUITE("math/MathUtil") { using namespace UnitTest::ax; - static void checkVerticesAreEqual(const V3F_C4F_T2F* v1, const V3F_C4F_T2F* v2, size_t count) + static void checkVerticesAreEqual(const V3F_T2F_C4F* v1, const V3F_T2F_C4F* v2, size_t count) { for (size_t i = 0; i < count; ++i) { - CHECK_EQ(v1[i].vertices, v2[i].vertices); - CHECK_EQ(v1[i].colors, v2[i].colors); - CHECK_EQ(v1[i].texCoords, v2[i].texCoords); + CHECK_EQ(v1[i].position, v2[i].position); + CHECK_EQ(v1[i].color, v2[i].color); + CHECK_EQ(v1[i].texCoord, v2[i].texCoord); } } TEST_CASE("transformVertices") { auto count = 5; - std::vector src(count); - std::vector expected(count); - std::vector dst(count); + std::vector src(count); + std::vector expected(count); + std::vector dst(count); for (int i = 0; i < count; ++i) { - src[i].vertices.set(float(i), float(i + 1), float(i + 2)); - src[i].colors.set(uint8_t(i + 3), uint8_t(i + 4), uint8_t(i + 5), uint8_t(i + 6)); - src[i].texCoords.set(float(i + 7), float(i + 8)); + src[i].position.set(float(i), float(i + 1), float(i + 2)); + src[i].color.set(uint8_t(i + 3), uint8_t(i + 4), uint8_t(i + 5), uint8_t(i + 6)); + src[i].texCoord.set(float(i + 7), float(i + 8)); expected[i] = src[i]; - expected[i].vertices.x = src[i].vertices.y * 4; - expected[i].vertices.y = src[i].vertices.x * -5; - expected[i].vertices.z = src[i].vertices.z * 6; + expected[i].position.x = src[i].position.y * 4; + expected[i].position.y = src[i].position.x * -5; + expected[i].position.z = src[i].position.z * 6; } Mat4 transform(0, 4, 0, 0, -5, 0, 0, 0, 0, 0, 6, 0, 1, 2, 3, 1); diff --git a/tools/bindings-generator/generator.py b/tools/bindings-generator/generator.py index 55fed5f9cd30..1c956a851ba3 100644 --- a/tools/bindings-generator/generator.py +++ b/tools/bindings-generator/generator.py @@ -1741,8 +1741,8 @@ def js_typename_from_natve(self, namespace_class_name): return "color3b_object" if namespace_class_name.find("ax::Color4B") == 0: return "color4b_object" - if namespace_class_name.find("ax::Color4F") == 0: - return "color4f_object" + if namespace_class_name.find("ax::Color") == 0: + return "color_object" else: return namespace_class_name.replace("*","").replace("const ", "").replace(k,v) return namespace_class_name.replace("*","").replace("const ", "") diff --git a/tools/bindings-generator/targets/lua/conversions.yaml b/tools/bindings-generator/targets/lua/conversions.yaml index b040e1a0c9d2..307d0bcbfb7c 100644 --- a/tools/bindings-generator/targets/lua/conversions.yaml +++ b/tools/bindings-generator/targets/lua/conversions.yaml @@ -52,7 +52,7 @@ conversions: "Rect": "ok &= luaval_to_rect(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")" "Size": "ok &= luaval_to_size(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")" "Color4B": "ok &=luaval_to_color4b(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")" - "Color4F": "ok &=luaval_to_color4f(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")" + "Color": "ok &=luaval_to_color(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")" "Color3B": "ok &= luaval_to_color3b(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")" "PhysicsMaterial": "ok &= luaval_to_physics_material(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")" "Array*": "ok &= luaval_to_array(tolua_S, ${arg_idx}, &${out_value}, \"${lua_namespaced_class_name}:${func_name}\")"