refactor(core/rendering): netejar ctors de Sprite/MovingSprite (INC-06 + INC-07)
- MovingSprite: el ctor delegat Sprite(surface, pos) ja assigna pos_;
el Sprite::pos_ = pos; manual que seguia era redundant (INC-06).
- Sprite(surface) usava initializer posicional {0.0F, 0.0F, ...} mentre
la resta del projecte usa designated initializers ({.x = ..., .y = ...}).
Unificat (INC-07).
INC-05 (el static_cast<int> de pos_.x a MovingSprite::move i setters)
es marca WONTFIX al document: és snap intencional a píxel per al
pixel-art, divergent només al setter per SDL_FRect que es reserva per
a posicionament directe sense arrodoniment.
Build + smoke 5s xvfb OK (exit 124).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8b413affa8
commit
da66a7c03f
3 files changed
+10
-7
No files matched your search
@@ -86,9 +86,9 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
|||||||
| INC-02 | `screen.cpp:52,104,125` vs `gif.cpp:96` vs `sdl3gpu_shader.cpp:214` | `exit`/throw/`bool` mezclados | Importante | DEFERRED | decisión global |
|
| INC-02 | `screen.cpp:52,104,125` vs `gif.cpp:96` vs `sdl3gpu_shader.cpp:214` | `exit`/throw/`bool` mezclados | Importante | DEFERRED | decisión global |
|
||||||
| INC-03 | `screen.cpp`, `sdl3gpu_shader.cpp`, `surface.cpp`, `gif.cpp` | `fprintf`/`cerr`/`cout` mezclados | Menor | DEFERRED | logger inexistente |
|
| INC-03 | `screen.cpp`, `sdl3gpu_shader.cpp`, `surface.cpp`, `gif.cpp` | `fprintf`/`cerr`/`cout` mezclados | Menor | DEFERRED | logger inexistente |
|
||||||
| INC-04 | `text.hpp:48-57` | API discreta + `writeDX(flags)` coexisten | Importante | PENDING | elegir una |
|
| INC-04 | `text.hpp:48-57` | API discreta + `writeDX(flags)` coexisten | Importante | PENDING | elegir una |
|
||||||
| INC-05 | `moving_sprite.cpp:39-40,58-72` | `pos_.x = static_cast<int>(x_)` sobre `SDL_FRect` | Importante | PENDING | fijar semántica |
|
| INC-05 | `moving_sprite.cpp:39-40,58-72` | `pos_.x = static_cast<int>(x_)` sobre `SDL_FRect` | Importante | WONTFIX | És snap intencional a píxel per al pixel-art; setPos(SDL_FRect) es reserva per a posicionament directe sense arrodoniment. La divergència és una decisió, no un bug |
|
||||||
| INC-06 | `moving_sprite.cpp:12-21` | `Sprite::pos_ = pos;` redundante tras ctor delegado | Menor | PENDING | limpiar |
|
| INC-06 | `moving_sprite.cpp:12-21` | `Sprite::pos_ = pos;` redundante tras ctor delegado | Menor | DONE | línies eliminades |
|
||||||
| INC-07 | `sprite.cpp:19-22` | initializer posicional vs designated | Menor | PENDING | uniformar |
|
| INC-07 | `sprite.cpp:19-22` | initializer posicional vs designated | Menor | DONE | designated initializer uniforme |
|
||||||
|
|
||||||
## 6. Código muerto
|
## 6. Código muerto
|
||||||
|
|
||||||
@@ -132,4 +132,5 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
|||||||
- `ce3b6da` — DEAD-09: esborrats structs d'extensions GIF no usats
|
- `ce3b6da` — DEAD-09: esborrats structs d'extensions GIF no usats
|
||||||
- `bbb397a` — HC-06 + HC-07 + HC-09 + PATCH-08: constants nominals a `render_info` (segments, shadow offset, position count) i dedup init
|
- `bbb397a` — HC-06 + HC-07 + HC-09 + PATCH-08: constants nominals a `render_info` (segments, shadow offset, position count) i dedup init
|
||||||
- `be94a43` — DUP-01 + DUP-06 + HC-03 + HC-10 + PATCH-05: neteja parser GIF (extension single-skip, constants nominals LZW/GCT, signatura sense args morts, un sol parse per construcció de `Surface`)
|
- `be94a43` — DUP-01 + DUP-06 + HC-03 + HC-10 + PATCH-05: neteja parser GIF (extension single-skip, constants nominals LZW/GCT, signatura sense args morts, un sol parse per construcció de `Surface`)
|
||||||
- `<pendent>` — HC-02: `Rendering::OPAQUE_ALPHA` a `canvas.hpp` reemplaça `0xFF000000U` repetit
|
- `8b413af` — HC-02: `Rendering::OPAQUE_ALPHA` a `canvas.hpp` reemplaça `0xFF000000U` repetit
|
||||||
|
- `<pendent>` — INC-06 + INC-07: eliminats assignaments redundants `Sprite::pos_` a `MovingSprite`; designated initializer uniforme
|
||||||
@@ -9,16 +9,18 @@ MovingSprite::MovingSprite() { Sprite::clear(); }
|
|||||||
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface)
|
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface)
|
||||||
: Sprite(std::move(surface)) { Sprite::clear(); }
|
: Sprite(std::move(surface)) { Sprite::clear(); }
|
||||||
|
|
||||||
|
// pos_ ja queda inicialitzat pel ctor delegat Sprite(surface, pos); només
|
||||||
|
// cal sincronitzar la posició float x_/y_ (i el flip si ve).
|
||||||
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
||||||
: Sprite(std::move(surface), pos),
|
: Sprite(std::move(surface), pos),
|
||||||
x_(pos.x),
|
x_(pos.x),
|
||||||
y_(pos.y) { Sprite::pos_ = pos; }
|
y_(pos.y) {}
|
||||||
|
|
||||||
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip)
|
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip)
|
||||||
: Sprite(std::move(surface), pos),
|
: Sprite(std::move(surface), pos),
|
||||||
x_(pos.x),
|
x_(pos.x),
|
||||||
y_(pos.y),
|
y_(pos.y),
|
||||||
flip_(flip) { Sprite::pos_ = pos; }
|
flip_(flip) {}
|
||||||
|
|
||||||
void MovingSprite::clear() {
|
void MovingSprite::clear() {
|
||||||
x_ = 0.0F;
|
x_ = 0.0F;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Sprite::Sprite(std::shared_ptr<Surface> surface, SDL_FRect rect)
|
|||||||
|
|
||||||
Sprite::Sprite(std::shared_ptr<Surface> surface)
|
Sprite::Sprite(std::shared_ptr<Surface> surface)
|
||||||
: surface_(std::move(surface)),
|
: surface_(std::move(surface)),
|
||||||
pos_{0.0F, 0.0F, static_cast<float>(surface_->getWidth()), static_cast<float>(surface_->getHeight())},
|
pos_{.x = 0.0F, .y = 0.0F, .w = static_cast<float>(surface_->getWidth()), .h = static_cast<float>(surface_->getHeight())},
|
||||||
clip_(pos_) {}
|
clip_(pos_) {}
|
||||||
|
|
||||||
void Sprite::render() {
|
void Sprite::render() {
|
||||||
|
|||||||
Reference in new issue
Block a user