From f8c7298974e1138b7f1cb6166619c5d20151574e Mon Sep 17 00:00:00 2001 From: ChestnutYueyue <952134128@qq.com> Date: Thu, 19 Feb 2026 23:18:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B8=B2=E6=9F=93):=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E9=94=9A=E7=82=B9?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=B9=B6=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除Sprite::onDraw中未使用的anchor变量,因为锚点处理已由RenderBackend负责 同时调整代码格式以提高可读性 --- Extra2D/src/scene/sprite.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Extra2D/src/scene/sprite.cpp b/Extra2D/src/scene/sprite.cpp index fc640c3..1190acd 100644 --- a/Extra2D/src/scene/sprite.cpp +++ b/Extra2D/src/scene/sprite.cpp @@ -148,8 +148,6 @@ void Sprite::onDraw(RenderBackend &renderer) { float worldScaleY = glm::length(glm::vec2(worldTransform[1][0], worldTransform[1][1])); - auto anchor = getAnchor(); - // 锚点由 RenderBackend 在绘制时处理,这里只传递位置和尺寸 Rect destRect(worldX, worldY, width * worldScaleX, height * worldScaleY); @@ -167,8 +165,8 @@ void Sprite::onDraw(RenderBackend &renderer) { // 从世界变换矩阵中提取旋转角度 float worldRotation = std::atan2(worldTransform[0][1], worldTransform[0][0]); - renderer.drawSprite(texture_->getRHITexture(), destRect, srcRect, color_, worldRotation, - flipX_, flipY_); + renderer.drawSprite(texture_->getRHITexture(), destRect, srcRect, color_, + worldRotation, flipX_, flipY_); } /** @@ -224,8 +222,14 @@ void Sprite::generateRenderCommand(std::vector &commands, RenderCommand cmd; cmd.type = RenderCommandType::Sprite; cmd.layer = zOrder; - cmd.data = SpriteRenderData{texture_->getRHITexture(), destRect, srcRect, color_, - worldRotation, anchor, rhi::BlendState::alphaBlend(), 0}; + cmd.data = SpriteRenderData{texture_->getRHITexture(), + destRect, + srcRect, + color_, + worldRotation, + anchor, + rhi::BlendState::alphaBlend(), + 0}; commands.push_back(std::move(cmd)); }