From ae082abaa2f4a691951bc86a174ac0021f437566 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 16 Sep 2026 23:28:03 +0300 Subject: [PATCH 1/6] feat: allow passing rgba color to entity skeletons and block wraps --- res/shaders/entity.glslv | 6 ++-- src/animation/rigging.hpp | 2 +- src/graphics/render/BlockWrapsRenderer.cpp | 2 +- src/graphics/render/BlockWrapsRenderer.hpp | 4 +-- src/graphics/render/MainBatch.cpp | 2 +- src/graphics/render/MainBatch.hpp | 10 +++--- src/graphics/render/ModelBatch.cpp | 16 ++++++---- src/graphics/render/ModelBatch.hpp | 32 +++++++++++-------- src/graphics/render/ParticlesRenderer.cpp | 2 +- src/graphics/render/PrecipitationRenderer.cpp | 2 +- .../scripting/lua/libs/lib__skeleton.cpp | 4 ++- .../scripting/lua/libs/libblockwraps.cpp | 13 ++++++-- 12 files changed, 55 insertions(+), 40 deletions(-) diff --git a/res/shaders/entity.glslv b/res/shaders/entity.glslv index 8f534a6dc..579a15879 100644 --- a/res/shaders/entity.glslv +++ b/res/shaders/entity.glslv @@ -2,7 +2,7 @@ layout (location = 0) in vec3 v_position; layout (location = 1) in vec2 v_texCoord; -layout (location = 2) in vec3 v_color; +layout (location = 2) in vec4 v_color; layout (location = 3) in vec4 v_light; layout (location = 4) in vec4 v_normal; @@ -29,8 +29,8 @@ void main() { a_dir = a_modelpos.xyz - u_cameraPos; vec3 skyLightColor = pick_sky_color(u_skybox, u_dayTime, u_minSkyLight); - a_color.rgb = max(a_color.rgb, skyLightColor.rgb * v_light.a) * v_color; - a_color.a = u_opacity; + a_color.rgb = max(a_color.rgb, skyLightColor.rgb * v_light.a) * v_color.rgb; + a_color.a = u_opacity * v_color.a; mat4 viewmodel = u_view * u_model; a_distance = length(viewmodel * vec4(pos3d, 0.0)); diff --git a/src/animation/rigging.hpp b/src/animation/rigging.hpp index 82066e132..a2bd11375 100644 --- a/src/animation/rigging.hpp +++ b/src/animation/rigging.hpp @@ -85,7 +85,7 @@ namespace rigging { std::unordered_map textures; std::vector modelOverrides; bool visible; - glm::vec3 tint {1.0f, 1.0f, 1.0f}; + glm::vec4 tint {1.0f, 1.0f, 1.0f, 1.0f}; util::VecInterpolation<3, float> interpolation {false}; diff --git a/src/graphics/render/BlockWrapsRenderer.cpp b/src/graphics/render/BlockWrapsRenderer.cpp index 168ad14a2..7548afa34 100644 --- a/src/graphics/render/BlockWrapsRenderer.cpp +++ b/src/graphics/render/BlockWrapsRenderer.cpp @@ -161,7 +161,7 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx) { u64id_t BlockWrapsRenderer::add( const glm::ivec3& position, const std::string& texture, - const glm::vec3& tint, + const glm::vec4& tint, float emission ) { u64id_t id = nextWrapper++; diff --git a/src/graphics/render/BlockWrapsRenderer.hpp b/src/graphics/render/BlockWrapsRenderer.hpp index 0f2ed8f7e..fb4893877 100644 --- a/src/graphics/render/BlockWrapsRenderer.hpp +++ b/src/graphics/render/BlockWrapsRenderer.hpp @@ -20,7 +20,7 @@ class DrawContext; struct BlockWrapper { glm::ivec3 position; std::array textureFaces {}; - std::array tints {}; + std::array tints {}; float emission = 0.0f; // --- render cache --- @@ -56,7 +56,7 @@ public: u64id_t add( const glm::ivec3& position, const std::string& texture, - const glm::vec3& tint, + const glm::vec4& tint, float emission ); diff --git a/src/graphics/render/MainBatch.cpp b/src/graphics/render/MainBatch.cpp index 91364e510..0bb6900dd 100644 --- a/src/graphics/render/MainBatch.cpp +++ b/src/graphics/render/MainBatch.cpp @@ -87,7 +87,7 @@ void MainBatch::cube( const glm::vec3& size, const UVRegion(&texfaces)[6], const glm::vec4& lights, - const glm::vec3 tints[], + const glm::vec4 tints[], float emission, uint8_t cullingBits ) { diff --git a/src/graphics/render/MainBatch.hpp b/src/graphics/render/MainBatch.hpp index 8ad119199..86397f36f 100644 --- a/src/graphics/render/MainBatch.hpp +++ b/src/graphics/render/MainBatch.hpp @@ -17,14 +17,14 @@ class Chunks; struct MainBatchVertex { glm::vec3 position; glm::vec2 uv; - glm::vec3 tint; + glm::vec4 tint; std::array color; std::array normal; static constexpr VertexAttribute ATTRIBUTES[] = { {VertexAttribute::Type::FLOAT, false, 3}, {VertexAttribute::Type::FLOAT, false, 2}, - {VertexAttribute::Type::FLOAT, false, 3}, + {VertexAttribute::Type::FLOAT, false, 4}, {VertexAttribute::Type::UNSIGNED_BYTE, true, 4}, {VertexAttribute::Type::UNSIGNED_BYTE, true, 4}, {{}, 0}}; @@ -63,7 +63,7 @@ public: const glm::vec3& pos, const glm::vec2& uv, const glm::vec4& light, - const glm::vec3& tint, + const glm::vec4& tint, const glm::vec3& normal, float emission ) { @@ -91,7 +91,7 @@ public: const glm::vec3& normal, const glm::vec2& size, const glm::vec4& light, - const glm::vec3& tint, + const glm::vec4& tint, const UVRegion& subregion, float emission = 0.0f ) { @@ -152,7 +152,7 @@ public: const glm::vec3& size, const UVRegion(&texfaces)[6], const glm::vec4& lights, - const glm::vec3 tints[], + const glm::vec4 tints[], float emission, uint8_t cullingBits = 0xFF ); diff --git a/src/graphics/render/ModelBatch.cpp b/src/graphics/render/ModelBatch.cpp index 35e891aff..949edfee0 100644 --- a/src/graphics/render/ModelBatch.cpp +++ b/src/graphics/render/ModelBatch.cpp @@ -61,8 +61,8 @@ void ModelBatch::draw( const model::Mesh& mesh, const glm::mat4& matrix, const glm::mat3& rotation, - glm::vec3 tint, - const texture_names_map* varTextures, + const glm::vec4& tint, + const TextureNamesMap* varTextures, bool backlight ) { setTexture(mesh.texture, varTextures); @@ -97,10 +97,12 @@ void ModelBatch::draw( } } -void ModelBatch::draw(glm::mat4 matrix, - glm::vec3 tint, - const model::Model* model, - const texture_names_map* varTextures) { +void ModelBatch::draw( + const glm::mat4& matrix, + const glm::vec4& tint, + const model::Model* model, + const TextureNamesMap* varTextures +) { for (const auto& mesh : model->meshes) { entries.push_back({ matrix, extract_rotation(matrix), tint, &mesh, varTextures @@ -134,7 +136,7 @@ void ModelBatch::setLightsOffset(const glm::vec3& offset) { } void ModelBatch::setTexture(const std::string& name, - const texture_names_map* varTextures) { + const TextureNamesMap* varTextures) { if (varTextures && !name.empty() && name.at(0) == '$') { const auto& found = varTextures->find(name); if (found == varTextures->end()) { diff --git a/src/graphics/render/ModelBatch.hpp b/src/graphics/render/ModelBatch.hpp index e93237865..460b8e13b 100644 --- a/src/graphics/render/ModelBatch.hpp +++ b/src/graphics/render/ModelBatch.hpp @@ -18,7 +18,7 @@ namespace model { struct Model; } -using texture_names_map = std::unordered_map; +using TextureNamesMap = std::unordered_map; class ModelBatch { const Assets& assets; @@ -31,22 +31,24 @@ class ModelBatch { std::unique_ptr batch; - void draw(const model::Mesh& mesh, - const glm::mat4& matrix, - const glm::mat3& rotation, - glm::vec3 tint, - const texture_names_map* varTextures, - bool backlight); + void draw( + const model::Mesh& mesh, + const glm::mat4& matrix, + const glm::mat3& rotation, + const glm::vec4& tint, + const TextureNamesMap* varTextures, + bool backlight + ); void setTexture(const std::string& name, - const texture_names_map* varTextures); + const TextureNamesMap* varTextures); struct DrawEntry { glm::mat4 matrix; glm::mat3 rotation; - glm::vec3 tint; + glm::vec4 tint; const model::Mesh* mesh; - const texture_names_map* varTextures; + const TextureNamesMap* varTextures; }; std::vector entries; public: @@ -58,10 +60,12 @@ public: ); ~ModelBatch(); - void draw(glm::mat4 matrix, - glm::vec3 tint, - const model::Model* model, - const texture_names_map* varTextures); + void draw( + const glm::mat4& matrix, + const glm::vec4& tint, + const model::Model* model, + const TextureNamesMap* varTextures + ); void render(); void setLightsOffset(const glm::vec3& offset); diff --git a/src/graphics/render/ParticlesRenderer.cpp b/src/graphics/render/ParticlesRenderer.cpp index d588cd63a..ea449479c 100644 --- a/src/graphics/render/ParticlesRenderer.cpp +++ b/src/graphics/render/ParticlesRenderer.cpp @@ -160,7 +160,7 @@ void ParticlesRenderer::renderParticle( -camera.front, preset.size * scale, light, - glm::vec3(1.0f), + glm::vec4(1.0f), particle.region, preset.lighting ? 0.0f : 1.0f ); diff --git a/src/graphics/render/PrecipitationRenderer.cpp b/src/graphics/render/PrecipitationRenderer.cpp index c566a06d2..6b2735d54 100644 --- a/src/graphics/render/PrecipitationRenderer.cpp +++ b/src/graphics/render/PrecipitationRenderer.cpp @@ -151,7 +151,7 @@ void PrecipitationRenderer::render( glm::cross(glm::vec3(0, 1, 0), face.right), FACE_SIZE, light_at(chunks, pos.x, y, pos.z), - glm::vec3(1.0f), + glm::vec4(1.0f), calc_uv(pos, face.right, timer, weather) ); } diff --git a/src/logic/scripting/lua/libs/lib__skeleton.cpp b/src/logic/scripting/lua/libs/lib__skeleton.cpp index a310abe87..fc673db77 100644 --- a/src/logic/scripting/lua/libs/lib__skeleton.cpp +++ b/src/logic/scripting/lua/libs/lib__skeleton.cpp @@ -156,7 +156,9 @@ static int l_get_color(lua::State* L) { static int l_set_color(lua::State* L) { if (auto skeleton = get_skeleton(L)) { - skeleton->tint = lua::tovec3(L, 2); + skeleton->tint = lua::objlen(L, 2) > 3 + ? lua::tovec4(L, 2) + : glm::vec4(lua::tovec3(L, 2), 1.0f); } return 0; } diff --git a/src/logic/scripting/lua/libs/libblockwraps.cpp b/src/logic/scripting/lua/libs/libblockwraps.cpp index 084dd6b8b..a6eba3e8f 100644 --- a/src/logic/scripting/lua/libs/libblockwraps.cpp +++ b/src/logic/scripting/lua/libs/libblockwraps.cpp @@ -10,7 +10,11 @@ static int l_wrap(lua::State* L) { auto position = lua::tovec3(L, 1); std::string texture = lua::require_string(L, 2); float emission = lua::isnumber(L, 3) ? lua::tonumber(L, 3) : 1.0f; - glm::vec3 tint = lua::istable(L, 4) ? lua::tovec3(L, 4) : glm::vec3(1.0f); + glm::vec4 tint = + lua::istable(L, 4) + ? (lua::objlen(L, 4) > 3 ? lua::tovec4(L, 4) + : glm::vec4(lua::tovec3(L, 4), 1.0f)) + : glm::vec4(1.0f); return lua::pushinteger( L, @@ -72,9 +76,12 @@ static int l_set_tints(lua::State* L) { if (auto wrapper = renderer->blockWraps->get(lua::tointeger(L, 1))) { for (int i = 0; i < wrapper->textureFaces.size(); i++) { if (lua::isnil(L, 2 + i)) { - wrapper->tints[i] = glm::vec3(1.0f); + wrapper->tints[i] = glm::vec4(1.0f); } else { - wrapper->tints[i] = lua::tovec3(L, 2 + i); + wrapper->tints[i] = + lua::objlen(L, 2 + i) > 3 + ? lua::tovec4(L, 2 + i) + : glm::vec4(lua::tovec3(L, 2 + i), 1.0f); } } } From dbeeef90a82a25b4bc261932ae283e1dd085fd03 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 16 Sep 2026 23:31:37 +0300 Subject: [PATCH 2/6] cleanup a bit --- src/graphics/render/MainBatch.cpp | 63 +++++++++++++++++++++++++ src/graphics/render/MainBatch.hpp | 76 +++++------------------------- src/graphics/render/ModelBatch.hpp | 37 ++++++++------- 3 files changed, 95 insertions(+), 81 deletions(-) diff --git a/src/graphics/render/MainBatch.cpp b/src/graphics/render/MainBatch.cpp index 0bb6900dd..70d4af6f7 100644 --- a/src/graphics/render/MainBatch.cpp +++ b/src/graphics/render/MainBatch.cpp @@ -82,6 +82,69 @@ inline glm::vec4 do_tint(float value) { return {value, value, value, 1.0f}; } +void MainBatch::quad( + const glm::vec3& pos, + const glm::vec3& right, + const glm::vec3& up, + const glm::vec3& normal, + const glm::vec2& size, + const glm::vec4& light, + const glm::vec4& tint, + const UVRegion& subregion, + float emission +) { + prepare(6); + vertex( + pos - right * size.x * 0.5f - up * size.y * 0.5f, + {subregion.u1, subregion.v1}, + light, + tint, + normal, + emission + ); + vertex( + pos + right * size.x * 0.5f - up * size.y * 0.5f, + {subregion.u2, subregion.v1}, + light, + tint, + normal, + emission + ); + vertex( + pos + right * size.x * 0.5f + up * size.y * 0.5f, + {subregion.u2, subregion.v2}, + light, + tint, + normal, + emission + ); + + vertex( + pos - right * size.x * 0.5f - up * size.y * 0.5f, + {subregion.u1, subregion.v1}, + light, + tint, + normal, + emission + ); + vertex( + pos + right * size.x * 0.5f + up * size.y * 0.5f, + {subregion.u2, subregion.v2}, + light, + tint, + normal, + emission + ); + vertex( + pos - right * size.x * 0.5f + up * size.y * 0.5f, + {subregion.u1, subregion.v2}, + light, + tint, + normal, + emission + ); +} + void MainBatch::cube( const glm::vec3& coord, const glm::vec3& size, diff --git a/src/graphics/render/MainBatch.hpp b/src/graphics/render/MainBatch.hpp index 86397f36f..d51b2d05b 100644 --- a/src/graphics/render/MainBatch.hpp +++ b/src/graphics/render/MainBatch.hpp @@ -31,16 +31,6 @@ struct MainBatchVertex { }; class MainBatch { - std::unique_ptr const buffer; - size_t const capacity; - size_t index; - - UVRegion region {0.0f, 0.0f, 1.0f, 1.0f}; - - std::unique_ptr> mesh; - std::unique_ptr blank; - - const Texture* texture = nullptr; public: /// xyz, uv, color, compressed lights @@ -84,7 +74,7 @@ public: index++; } - inline void quad( + void quad( const glm::vec3& pos, const glm::vec3& right, const glm::vec3& up, @@ -94,58 +84,7 @@ public: const glm::vec4& tint, const UVRegion& subregion, float emission = 0.0f - ) { - prepare(6); - vertex( - pos - right * size.x * 0.5f - up * size.y * 0.5f, - {subregion.u1, subregion.v1}, - light, - tint, - normal, - emission - ); - vertex( - pos + right * size.x * 0.5f - up * size.y * 0.5f, - {subregion.u2, subregion.v1}, - light, - tint, - normal, - emission - ); - vertex( - pos + right * size.x * 0.5f + up * size.y * 0.5f, - {subregion.u2, subregion.v2}, - light, - tint, - normal, - emission - ); - - vertex( - pos - right * size.x * 0.5f - up * size.y * 0.5f, - {subregion.u1, subregion.v1}, - light, - tint, - normal, - emission - ); - vertex( - pos + right * size.x * 0.5f + up * size.y * 0.5f, - {subregion.u2, subregion.v2}, - light, - tint, - normal, - emission - ); - vertex( - pos - right * size.x * 0.5f + up * size.y * 0.5f, - {subregion.u1, subregion.v2}, - light, - tint, - normal, - emission - ); - } + ); void cube( const glm::vec3& coord, @@ -156,4 +95,15 @@ public: float emission, uint8_t cullingBits = 0xFF ); +private: + std::unique_ptr const buffer; + size_t const capacity; + size_t index; + + UVRegion region {0.0f, 0.0f, 1.0f, 1.0f}; + + std::unique_ptr> mesh; + std::unique_ptr blank; + + const Texture* texture = nullptr; }; diff --git a/src/graphics/render/ModelBatch.hpp b/src/graphics/render/ModelBatch.hpp index 460b8e13b..84b182c83 100644 --- a/src/graphics/render/ModelBatch.hpp +++ b/src/graphics/render/ModelBatch.hpp @@ -21,6 +21,25 @@ namespace model { using TextureNamesMap = std::unordered_map; class ModelBatch { +public: + ModelBatch( + size_t capacity, + const Assets& assets, + const Chunks& chunks, + const EngineSettings& settings + ); + ~ModelBatch(); + + void draw( + const glm::mat4& matrix, + const glm::vec4& tint, + const model::Model* model, + const TextureNamesMap* varTextures + ); + void render(); + + void setLightsOffset(const glm::vec3& offset); +private: const Assets& assets; const Chunks& chunks; @@ -51,22 +70,4 @@ class ModelBatch { const TextureNamesMap* varTextures; }; std::vector entries; -public: - ModelBatch( - size_t capacity, - const Assets& assets, - const Chunks& chunks, - const EngineSettings& settings - ); - ~ModelBatch(); - - void draw( - const glm::mat4& matrix, - const glm::vec4& tint, - const model::Model* model, - const TextureNamesMap* varTextures - ); - void render(); - - void setLightsOffset(const glm::vec3& offset); }; From f5f17b7746e724f46cd4844b46ed7ef8f2610aa9 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 16 Sep 2026 23:37:44 +0300 Subject: [PATCH 3/6] feat: individual bone tints --- src/animation/rigging.cpp | 6 ++++-- src/animation/rigging.hpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/animation/rigging.cpp b/src/animation/rigging.cpp index d5e36a82c..c1d7a9e27 100644 --- a/src/animation/rigging.cpp +++ b/src/animation/rigging.cpp @@ -46,7 +46,8 @@ Skeleton::Skeleton(std::shared_ptr config) flags(config ? config->getBones().size() : 0), textures(), modelOverrides(config ? config->getBones().size() : 0), - visible(true) { + visible(true), + boneTints(config ? config->getBones().size() : 0, glm::vec4(1.0f)) { if (config == nullptr) { return; } @@ -99,6 +100,7 @@ void Skeleton::setConfig(std::shared_ptr rigConfig) { modelOverrides.resize(bonesCount); flags.resize(bonesCount); + boneTints.resize(bonesCount, glm::vec4(1.0f)); for (size_t i = 0; i < bonesCount; i++) { flags[i].visible = true; @@ -204,7 +206,7 @@ void SkeletonConfig::render( if (model) { batch.draw( skeleton.calculated.matrices[i], - skeleton.tint, + skeleton.tint * skeleton.boneTints[i], model, &skeleton.textures ); diff --git a/src/animation/rigging.hpp b/src/animation/rigging.hpp index a2bd11375..55d7fd8a7 100644 --- a/src/animation/rigging.hpp +++ b/src/animation/rigging.hpp @@ -86,6 +86,7 @@ namespace rigging { std::vector modelOverrides; bool visible; glm::vec4 tint {1.0f, 1.0f, 1.0f, 1.0f}; + std::vector boneTints; util::VecInterpolation<3, float> interpolation {false}; From ad22763a1ffef533a964de384723c5fc75ec0a0b Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 16 Sep 2026 23:40:41 +0300 Subject: [PATCH 4/6] add new skeleton:get_color, skeleton:set_color overloads --- res/modules/internal/stdcomp.lua | 4 ++-- .../scripting/lua/libs/lib__skeleton.cpp | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/res/modules/internal/stdcomp.lua b/res/modules/internal/stdcomp.lua index 4a0ace852..dfea2e7c9 100644 --- a/res/modules/internal/stdcomp.lua +++ b/res/modules/internal/stdcomp.lua @@ -58,8 +58,8 @@ local Skeleton = {__index={ index=function(self, s) return __skeleton.index(self.eid, s) end, is_visible=function(self, i) return __skeleton.is_visible(self.eid, i) end, set_visible=function(self, i, b) return __skeleton.set_visible(self.eid, i, b) end, - get_color=function(self) return __skeleton.get_color(self.eid) end, - set_color=function(self, color) return __skeleton.set_color(self.eid, color) end, + get_color=function(self, ...) return __skeleton.get_color(self.eid, ...) end, + set_color=function(self, color, ...) return __skeleton.set_color(self.eid, color, ...) end, set_interpolated=function(self, b) return __skeleton.set_interpolated(self.eid, b) end, }} diff --git a/src/logic/scripting/lua/libs/lib__skeleton.cpp b/src/logic/scripting/lua/libs/lib__skeleton.cpp index fc673db77..136f4ce62 100644 --- a/src/logic/scripting/lua/libs/lib__skeleton.cpp +++ b/src/logic/scripting/lua/libs/lib__skeleton.cpp @@ -147,8 +147,19 @@ static int l_set_visible(lua::State* L) { return 0; } +static glm::vec4 to_color(lua::State* L, int idx) { + if (lua::objlen(L, idx) > 3) { + return lua::tovec4(L, idx); + } + return glm::vec4(lua::tovec3(L, idx), 1.0f); +} + static int l_get_color(lua::State* L) { if (auto skeleton = get_skeleton(L)) { + if (lua::isnumber(L, 2)) { + auto index = index_range_check(*skeleton, lua::tointeger(L, 2)); + return lua::pushvec(L, skeleton->boneTints[index]); + } return lua::pushvec(L, skeleton->tint); } return 0; @@ -156,9 +167,12 @@ static int l_get_color(lua::State* L) { static int l_set_color(lua::State* L) { if (auto skeleton = get_skeleton(L)) { - skeleton->tint = lua::objlen(L, 2) > 3 - ? lua::tovec4(L, 2) - : glm::vec4(lua::tovec3(L, 2), 1.0f); + if (lua::isnumber(L, 2)) { + auto index = index_range_check(*skeleton, lua::tointeger(L, 2)); + skeleton->boneTints[index] = to_color(L, 3); + } else { + skeleton->tint = to_color(L, 2); + } } return 0; } From f130be4c42a97397390a5d4ca3f0ad01c22cfd77 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 16 Sep 2026 23:43:24 +0300 Subject: [PATCH 5/6] update doc/*/scripting/ecs.md --- doc/en/scripting/ecs.md | 8 ++++++-- doc/ru/scripting/ecs.md | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/en/scripting/ecs.md b/doc/en/scripting/ecs.md index d9194ea93..ddc361998 100644 --- a/doc/en/scripting/ecs.md +++ b/doc/en/scripting/ecs.md @@ -190,10 +190,14 @@ rig:is_visible([optional] index: int) -> bool rig:set_visible([optional] index: int, status: bool) -- Returns the color of the entity -rig:get_color() -> vec3 +rig:get_color() -> vec4 +-- Return the color of the bone by index +rig:get_color(index: int) -> vec4 -- Sets the color of the entity -rig:set_color(color: vec3) +rig:set_color(color: vec3 | vec4) +-- Sets the color of the bone by index +rig:set_color(index: int, color: vec3 | vec4) ``` > [!WARNING] diff --git a/doc/ru/scripting/ecs.md b/doc/ru/scripting/ecs.md index fa6186d41..3c50ef26b 100644 --- a/doc/ru/scripting/ecs.md +++ b/doc/ru/scripting/ecs.md @@ -179,10 +179,14 @@ rig:is_visible([optional] index: int) -> bool rig:set_visible([optional] index: int, status: bool) -- Возвращает цвет сущности -rig:get_color() -> vec3 +rig:get_color() -> vec4 +-- Возвращает цвет кости по индексу +rig:get_color(index: int) -> vec4 -- Устанавливает цвет сущности -rig:set_color(color: vec3) +rig:set_color(color: vec3 | vec4) +-- Устанавливает цвет кости по индексу +rig:set_color(index: int, color: vec3 | vec4) ``` ## Пользовательские компоненты From 3e2f311e672be9d592cc94ed0f2c63ffa3d547da Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 16 Sep 2026 23:47:25 +0300 Subject: [PATCH 6/6] update methods schemes --- doc/en/scripting/ecs.md | 2 +- doc/ru/scripting/ecs.md | 2 +- src/logic/scripting/lua/libs/lib__skeleton.cpp | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/en/scripting/ecs.md b/doc/en/scripting/ecs.md index ddc361998..0473fc852 100644 --- a/doc/en/scripting/ecs.md +++ b/doc/en/scripting/ecs.md @@ -197,7 +197,7 @@ rig:get_color(index: int) -> vec4 -- Sets the color of the entity rig:set_color(color: vec3 | vec4) -- Sets the color of the bone by index -rig:set_color(index: int, color: vec3 | vec4) +rig:set_color(color: vec3 | vec4, index: int) ``` > [!WARNING] diff --git a/doc/ru/scripting/ecs.md b/doc/ru/scripting/ecs.md index 3c50ef26b..d6a823cf0 100644 --- a/doc/ru/scripting/ecs.md +++ b/doc/ru/scripting/ecs.md @@ -186,7 +186,7 @@ rig:get_color(index: int) -> vec4 -- Устанавливает цвет сущности rig:set_color(color: vec3 | vec4) -- Устанавливает цвет кости по индексу -rig:set_color(index: int, color: vec3 | vec4) +rig:set_color(color: vec3 | vec4, index: int) ``` ## Пользовательские компоненты diff --git a/src/logic/scripting/lua/libs/lib__skeleton.cpp b/src/logic/scripting/lua/libs/lib__skeleton.cpp index 136f4ce62..c1004434f 100644 --- a/src/logic/scripting/lua/libs/lib__skeleton.cpp +++ b/src/logic/scripting/lua/libs/lib__skeleton.cpp @@ -167,11 +167,12 @@ static int l_get_color(lua::State* L) { static int l_set_color(lua::State* L) { if (auto skeleton = get_skeleton(L)) { - if (lua::isnumber(L, 2)) { - auto index = index_range_check(*skeleton, lua::tointeger(L, 2)); - skeleton->boneTints[index] = to_color(L, 3); + auto color = to_color(L, 2); + if (lua::isnumber(L, 3)) { + auto index = index_range_check(*skeleton, lua::tointeger(L, 3)); + skeleton->boneTints[index] = color; } else { - skeleton->tint = to_color(L, 2); + skeleton->tint = color; } } return 0;