refactor(渲染): 移除未使用的锚点变量并格式化代码
移除Sprite::onDraw中未使用的anchor变量,因为锚点处理已由RenderBackend负责 同时调整代码格式以提高可读性
This commit is contained in:
parent
d4055333a9
commit
f8c7298974
|
|
@ -148,8 +148,6 @@ void Sprite::onDraw(RenderBackend &renderer) {
|
||||||
float worldScaleY =
|
float worldScaleY =
|
||||||
glm::length(glm::vec2(worldTransform[1][0], worldTransform[1][1]));
|
glm::length(glm::vec2(worldTransform[1][0], worldTransform[1][1]));
|
||||||
|
|
||||||
auto anchor = getAnchor();
|
|
||||||
|
|
||||||
// 锚点由 RenderBackend 在绘制时处理,这里只传递位置和尺寸
|
// 锚点由 RenderBackend 在绘制时处理,这里只传递位置和尺寸
|
||||||
Rect destRect(worldX, worldY, width * worldScaleX, height * worldScaleY);
|
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]);
|
float worldRotation = std::atan2(worldTransform[0][1], worldTransform[0][0]);
|
||||||
|
|
||||||
renderer.drawSprite(texture_->getRHITexture(), destRect, srcRect, color_, worldRotation,
|
renderer.drawSprite(texture_->getRHITexture(), destRect, srcRect, color_,
|
||||||
flipX_, flipY_);
|
worldRotation, flipX_, flipY_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -224,8 +222,14 @@ void Sprite::generateRenderCommand(std::vector<RenderCommand> &commands,
|
||||||
RenderCommand cmd;
|
RenderCommand cmd;
|
||||||
cmd.type = RenderCommandType::Sprite;
|
cmd.type = RenderCommandType::Sprite;
|
||||||
cmd.layer = zOrder;
|
cmd.layer = zOrder;
|
||||||
cmd.data = SpriteRenderData{texture_->getRHITexture(), destRect, srcRect, color_,
|
cmd.data = SpriteRenderData{texture_->getRHITexture(),
|
||||||
worldRotation, anchor, rhi::BlendState::alphaBlend(), 0};
|
destRect,
|
||||||
|
srcRect,
|
||||||
|
color_,
|
||||||
|
worldRotation,
|
||||||
|
anchor,
|
||||||
|
rhi::BlendState::alphaBlend(),
|
||||||
|
0};
|
||||||
|
|
||||||
commands.push_back(std::move(cmd));
|
commands.push_back(std::move(cmd));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue