fix: PVS-Studio V550

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov 2024-08-03 22:27:11 +03:00 committed by Pugemon
parent 3621e7ce1b
commit ab28b4df70
No known key found for this signature in database
GPG Key ID: 472FA343B3CC3287
4 changed files with 19 additions and 14 deletions

View File

@ -261,7 +261,7 @@ void ALSpeaker::setPitch(float pitch) {
}
bool ALSpeaker::isLoop() const {
return AL::getSourcei(source, AL_LOOPING) == AL_TRUE;
return AL::getSourcei(source, AL_LOOPING) == AL_TRUE; //-V550
}
void ALSpeaker::setLoop(bool loop) {
@ -343,7 +343,7 @@ void ALSpeaker::setRelative(bool relative) {
}
bool ALSpeaker::isRelative() const {
return AL::getSourcei(source, AL_SOURCE_RELATIVE) == AL_TRUE;
return AL::getSourcei(source, AL_SOURCE_RELATIVE) == AL_TRUE; //-V550
}
int ALSpeaker::getPriority() const {

View File

@ -6,6 +6,8 @@
#include <GL/glew.h>
#include <cmath>
inline constexpr uint B2D_VERTEX_SIZE = 8;
Batch2D::Batch2D(size_t capacity) : capacity(capacity), color(1.0f){
@ -163,9 +165,10 @@ void Batch2D::rect(
float x1,y1,x2,y2,x3,y3,x4,y4;
if (angle != 0) {
float s = sin(angle);
float c = cos(angle);
constexpr float epsilon = 1e-6f; // 0.000001
if (std::fabs(angle) > epsilon) {
float s = std::sin(angle);
float c = std::cos(angle);
x1 = c * _x1 - s * _y1;
y1 = s * _x1 + c * _y1;

View File

@ -432,10 +432,10 @@ voxel* Chunks::rayCast(
int stepz = (dz > 0.0f) ? 1 : -1;
constexpr float infinity = std::numeric_limits<float>::infinity();
float txDelta = (dx == 0.0f) ? infinity : abs(1.0f / dx);
float tyDelta = (dy == 0.0f) ? infinity : abs(1.0f / dy);
float tzDelta = (dz == 0.0f) ? infinity : abs(1.0f / dz);
constexpr float epsilon = 1e-6f; // 0.000001
float txDelta = (fabs(dx) < epsilon) ? infinity : abs(1.0f / dx);
float tyDelta = (fabs(dy) < epsilon) ? infinity : abs(1.0f / dy);
float tzDelta = (fabs(dz) < epsilon) ? infinity : abs(1.0f / dz);
float xdist = (stepx > 0) ? (ix + 1 - px) : (px - ix);
float ydist = (stepy > 0) ? (iy + 1 - py) : (py - iy);
@ -563,10 +563,10 @@ glm::vec3 Chunks::rayCastToObstacle(
int stepz = (dz > 0.0f) ? 1 : -1;
constexpr float infinity = std::numeric_limits<float>::infinity();
float txDelta = (dx == 0.0f) ? infinity : abs(1.0f / dx);
float tyDelta = (dy == 0.0f) ? infinity : abs(1.0f / dy);
float tzDelta = (dz == 0.0f) ? infinity : abs(1.0f / dz);
constexpr float epsilon = 1e-6f; // 0.000001
float txDelta = (fabs(dx) < epsilon) ? infinity : abs(1.0f / dx);
float tyDelta = (fabs(dy) < epsilon) ? infinity : abs(1.0f / dy);
float tzDelta = (fabs(dz) < epsilon) ? infinity : abs(1.0f / dz);
float xdist = (stepx > 0) ? (ix + 1 - px) : (px - ix);
float ydist = (stepy > 0) ? (iy + 1 - py) : (py - iy);

View File

@ -1,5 +1,6 @@
#include "Camera.hpp"
#include <cmath>
#include <glm/ext.hpp>
#include "Window.hpp"
@ -29,8 +30,9 @@ void Camera::rotate(float x, float y, float z) {
}
glm::mat4 Camera::getProjection() {
constexpr float epsilon = 1e-6f; // 0.000001
float aspect = this->aspect;
if (aspect == 0.0f) {
if (std::fabs(aspect) < epsilon) {
aspect = (float)Window::width / (float)Window::height;
}
if (perspective)