Incorporate clangd recommendations
Some checks failed
Build / Format (push) Successful in 20s
Build / Lint (push) Failing after 1m35s
Build / Build (push) Failing after 33s

This commit is contained in:
Michael Bradley 2025-02-28 20:46:42 -05:00
parent b564918e1c
commit 9a7969b63a
Signed by: MichaelBradley
SSH key fingerprint: SHA256:cj/YZ5VT+QOKncqSkx+ibKTIn0Obg7OIzwzl9BL8EO8
6 changed files with 41 additions and 31 deletions

View file

@ -26,16 +26,18 @@ class Camera {
aspect_ = static_cast<float>(width) / static_cast<float>(height);
}
const glm::vec3 &getPosition() const { return position_; }
[[nodiscard]] const glm::vec3 &getPosition() const { return position_; }
private:
glm::vec3 look_vector() const {
[[nodiscard]] glm::vec3 look_vector() const {
return rotateZ(rotateY(glm::vec3(1., 0., 0.), rotation_.y), rotation_.z);
}
glm::vec3 up_vector() const {
[[nodiscard]] glm::vec3 up_vector() const {
return rotateZ(rotateY(glm::vec3(0., 0., 1.), rotation_.y), rotation_.z);
}
glm::vec3 normal_vector() const { return cross(up_vector(), look_vector()); }
[[nodiscard]] glm::vec3 normal_vector() const {
return cross(up_vector(), look_vector());
}
glm::vec3 position_{kGeographyShort / 2,
kGeographyLong *kGeographyCountLong / 2,

View file

@ -10,8 +10,8 @@ class Geography final : public Renderable {
void Randomize(bool);
float min() const { return height_.min(); }
float max() const { return height_.max(); }
[[nodiscard]] float min() const { return height_.min(); }
[[nodiscard]] float max() const { return height_.max(); }
protected:
void SetData() override;

View file

@ -24,26 +24,30 @@ class Grid {
return (*data_)[index(x, y)];
}
Grid operator+(const Grid &) const;
[[nodiscard]] Grid operator+(const Grid &) const;
void operator+=(const Grid &) const;
Grid operator-() const;
Grid operator-(const Grid &) const;
[[nodiscard]] Grid operator-() const;
[[nodiscard]] Grid operator-(const Grid &) const;
void operator-=(const Grid &) const;
Grid operator*(float) const;
[[nodiscard]] Grid operator*(float) const;
void operator*=(float) const;
Grid operator/(float) const;
[[nodiscard]] Grid operator/(float) const;
void operator/=(float) const;
glm::vec3 normal_at(std::size_t, std::size_t, float = 1.) const;
[[nodiscard]] glm::vec3 normal_at(std::size_t, std::size_t, float = 1.) const;
static Grid *PerlinNoise(int, int, std::size_t);
[[nodiscard]] static Grid *PerlinNoise(int, int, std::size_t);
std::array<Vertex, kTotalVertices> *vertices() const;
static std::array<unsigned int, kTotalIndices> *indices();
[[nodiscard]] std::array<Vertex, kTotalVertices> *vertices() const;
[[nodiscard]] static std::array<unsigned int, kTotalIndices> *indices();
static void RandomizeBase() { base_random_ = device_() << 4; }
float min() const { return *std::min_element(data_->begin(), data_->end()); }
float max() const { return *std::max_element(data_->begin(), data_->end()); }
[[nodiscard]] float min() const {
return *std::min_element(data_->begin(), data_->end());
}
[[nodiscard]] float max() const {
return *std::max_element(data_->begin(), data_->end());
}
private:
std::unique_ptr<std::array<float, kGeographyShort * kGeographyLong>> data_{
@ -54,6 +58,6 @@ class Grid {
std::uniform_real_distribution<float> dist_{0, glm::two_pi<float>()};
static std::mt19937::result_type base_random_;
float RandomAngle() { return dist_(engine_); }
[[nodiscard]] float RandomAngle() { return dist_(engine_); }
void AngleSeed(const std::mt19937::result_type seed) { engine_.seed(seed); }
};

View file

@ -3,7 +3,7 @@
// Based on Ken Perlin's smoother step function:
// https://en.wikipedia.org/wiki/Smoothstep#Variations Returns value in range
// [0, 1]
constexpr float SmootherStep(const float x) {
[[nodiscard]] constexpr float SmootherStep(const float x) {
if (x < 0) {
return 0;
}
@ -17,7 +17,7 @@ constexpr float SmootherStep(const float x) {
// Interpolates between two doubles
// If x <= 0 returns bound_0, if x >= 1 returns bound_1,
// otherwise smoothly transitions between the two
constexpr float Interpolate(const float x, const float bound_0,
const float bound_1) {
[[nodiscard]] constexpr float Interpolate(const float x, const float bound_0,
const float bound_1) {
return bound_0 + SmootherStep(x) * (bound_1 - bound_0);
}

View file

@ -16,7 +16,7 @@ class PointLight final : public Renderable {
void LoadData(const Shader *) const;
void GenerateCubeMaps(const std::vector<Renderable *> &) const;
GLuint getDepthTexture() const { return depth_; }
[[nodiscard]] GLuint getDepthTexture() const { return depth_; }
void setPosition(const glm::vec3 &pos) {
pos_ = pos;
CleanUp();

View file

@ -15,22 +15,26 @@ class Shader {
Shader(const std::string &, const std::string &, const std::string & = "");
~Shader();
bool CopyDataToUniform(const glm::mat4 &, const std::string &) const;
bool CopyDataToUniform(int, const glm::mat4 *, const std::string &) const;
bool CopyDataToUniform(const glm::vec4 &, const std::string &) const;
bool CopyDataToUniform(const glm::vec3 &, const std::string &) const;
bool CopyDataToUniform(float, const std::string &) const;
bool CopyDataToUniform(int, const std::string &) const;
bool CopyDataToUniform(bool, const std::string &) const;
[[nodiscard]] bool CopyDataToUniform(const glm::mat4 &,
const std::string &) const;
[[nodiscard]] bool CopyDataToUniform(int, const glm::mat4 *,
const std::string &) const;
[[nodiscard]] bool CopyDataToUniform(const glm::vec4 &,
const std::string &) const;
[[nodiscard]] bool CopyDataToUniform(const glm::vec3 &,
const std::string &) const;
[[nodiscard]] bool CopyDataToUniform(float, const std::string &) const;
[[nodiscard]] bool CopyDataToUniform(int, const std::string &) const;
[[nodiscard]] bool CopyDataToUniform(bool, const std::string &) const;
void PrintStatus() const;
GLuint id() const { return id_; }
[[nodiscard]] GLuint id() const { return id_; }
private:
GLuint id_;
static GLuint CompileShader(const std::string &, GLenum);
[[nodiscard]] static GLuint CompileShader(const std::string &, GLenum);
static void CheckGLError(const std::string &);
static void CheckProgramivError(GLuint, GLenum, const std::string &);