cd38101f99
Primera sub-fase del naming sweep. Punt era un struct sense
operacions, conservat per compatibilitat amb el Pascal original.
Substituit per Vec2, un aggregate amb operadors aritmetics, dot,
length, normalized i length_squared (camelBack: lengthSquared)
seguint les regles del .clang-tidy del projecte.
Canvis:
- core/types.hpp reescrit: nou struct Vec2 amb +=,-=,*=,/=,
unary -, ==, dot, length, lengthSquared, normalized
- Operadors fora de la classe: +, -, *, / (amb float per ambdues
bandes), - unari, ==
- Vec2 segueix sent aggregate (sense constructors definits):
els 'designated initializers' del codi existent funcionen igual:
Vec2{.x = ..., .y = ...}
- Sed global sobre 35 fitxers: tots els 'Punt' -> 'Vec2'
Net: 35 fitxers tocats, +180 / -114. Compila i enllaça.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// shape_renderer.hpp - Renderitzat de formes vectorials
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <memory>
|
|
|
|
#include "core/graphics/shape.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
namespace Rendering {
|
|
|
|
// Estructura per rotacions 3D (pitch, yaw, roll)
|
|
struct Rotation3D {
|
|
float pitch; // Rotació eix X (cabeceo arriba/baix)
|
|
float yaw; // Rotació eix Y (guiñada esquerra/dreta)
|
|
float roll; // Rotació eix Z (alabeo lateral)
|
|
|
|
Rotation3D()
|
|
: pitch(0.0F),
|
|
yaw(0.0F),
|
|
roll(0.0F) {}
|
|
Rotation3D(float p, float y, float r)
|
|
: pitch(p),
|
|
yaw(y),
|
|
roll(r) {}
|
|
|
|
[[nodiscard]] bool has_rotation() const {
|
|
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
|
|
}
|
|
};
|
|
|
|
// Renderitzar forma amb transformacions
|
|
// - renderer: SDL renderer
|
|
// - shape: forma vectorial a dibuixar
|
|
// - posicio: posició del centre en coordenades mundials
|
|
// - angle: rotació en radians (0 = amunt, sentit horari)
|
|
// - escala: factor d'escala (1.0 = mida original)
|
|
// - progress: progrés de l'animació (0.0-1.0, default 1.0 = tot visible)
|
|
// - brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor)
|
|
void render_shape(SDL_Renderer* renderer,
|
|
const std::shared_ptr<Graphics::Shape>& shape,
|
|
const Vec2& posicio,
|
|
float angle,
|
|
float escala = 1.0F,
|
|
float progress = 1.0F,
|
|
float brightness = 1.0F,
|
|
const Rotation3D* rotation_3d = nullptr);
|
|
|
|
} // namespace Rendering
|