fix: PVS-Studio V550
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
parent
3621e7ce1b
commit
ab28b4df70
@ -261,7 +261,7 @@ void ALSpeaker::setPitch(float pitch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ALSpeaker::isLoop() const {
|
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) {
|
void ALSpeaker::setLoop(bool loop) {
|
||||||
@ -343,7 +343,7 @@ void ALSpeaker::setRelative(bool relative) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ALSpeaker::isRelative() const {
|
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 {
|
int ALSpeaker::getPriority() const {
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
inline constexpr uint B2D_VERTEX_SIZE = 8;
|
inline constexpr uint B2D_VERTEX_SIZE = 8;
|
||||||
|
|
||||||
Batch2D::Batch2D(size_t capacity) : capacity(capacity), color(1.0f){
|
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;
|
float x1,y1,x2,y2,x3,y3,x4,y4;
|
||||||
|
|
||||||
if (angle != 0) {
|
constexpr float epsilon = 1e-6f; // 0.000001
|
||||||
float s = sin(angle);
|
if (std::fabs(angle) > epsilon) {
|
||||||
float c = cos(angle);
|
float s = std::sin(angle);
|
||||||
|
float c = std::cos(angle);
|
||||||
|
|
||||||
x1 = c * _x1 - s * _y1;
|
x1 = c * _x1 - s * _y1;
|
||||||
y1 = s * _x1 + c * _y1;
|
y1 = s * _x1 + c * _y1;
|
||||||
|
|||||||
@ -432,10 +432,10 @@ voxel* Chunks::rayCast(
|
|||||||
int stepz = (dz > 0.0f) ? 1 : -1;
|
int stepz = (dz > 0.0f) ? 1 : -1;
|
||||||
|
|
||||||
constexpr float infinity = std::numeric_limits<float>::infinity();
|
constexpr float infinity = std::numeric_limits<float>::infinity();
|
||||||
|
constexpr float epsilon = 1e-6f; // 0.000001
|
||||||
float txDelta = (dx == 0.0f) ? infinity : abs(1.0f / dx);
|
float txDelta = (fabs(dx) < epsilon) ? infinity : abs(1.0f / dx);
|
||||||
float tyDelta = (dy == 0.0f) ? infinity : abs(1.0f / dy);
|
float tyDelta = (fabs(dy) < epsilon) ? infinity : abs(1.0f / dy);
|
||||||
float tzDelta = (dz == 0.0f) ? infinity : abs(1.0f / dz);
|
float tzDelta = (fabs(dz) < epsilon) ? infinity : abs(1.0f / dz);
|
||||||
|
|
||||||
float xdist = (stepx > 0) ? (ix + 1 - px) : (px - ix);
|
float xdist = (stepx > 0) ? (ix + 1 - px) : (px - ix);
|
||||||
float ydist = (stepy > 0) ? (iy + 1 - py) : (py - iy);
|
float ydist = (stepy > 0) ? (iy + 1 - py) : (py - iy);
|
||||||
@ -563,10 +563,10 @@ glm::vec3 Chunks::rayCastToObstacle(
|
|||||||
int stepz = (dz > 0.0f) ? 1 : -1;
|
int stepz = (dz > 0.0f) ? 1 : -1;
|
||||||
|
|
||||||
constexpr float infinity = std::numeric_limits<float>::infinity();
|
constexpr float infinity = std::numeric_limits<float>::infinity();
|
||||||
|
constexpr float epsilon = 1e-6f; // 0.000001
|
||||||
float txDelta = (dx == 0.0f) ? infinity : abs(1.0f / dx);
|
float txDelta = (fabs(dx) < epsilon) ? infinity : abs(1.0f / dx);
|
||||||
float tyDelta = (dy == 0.0f) ? infinity : abs(1.0f / dy);
|
float tyDelta = (fabs(dy) < epsilon) ? infinity : abs(1.0f / dy);
|
||||||
float tzDelta = (dz == 0.0f) ? infinity : abs(1.0f / dz);
|
float tzDelta = (fabs(dz) < epsilon) ? infinity : abs(1.0f / dz);
|
||||||
|
|
||||||
float xdist = (stepx > 0) ? (ix + 1 - px) : (px - ix);
|
float xdist = (stepx > 0) ? (ix + 1 - px) : (px - ix);
|
||||||
float ydist = (stepy > 0) ? (iy + 1 - py) : (py - iy);
|
float ydist = (stepy > 0) ? (iy + 1 - py) : (py - iy);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <glm/ext.hpp>
|
#include <glm/ext.hpp>
|
||||||
|
|
||||||
#include "Window.hpp"
|
#include "Window.hpp"
|
||||||
@ -29,8 +30,9 @@ void Camera::rotate(float x, float y, float z) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Camera::getProjection() {
|
glm::mat4 Camera::getProjection() {
|
||||||
|
constexpr float epsilon = 1e-6f; // 0.000001
|
||||||
float aspect = this->aspect;
|
float aspect = this->aspect;
|
||||||
if (aspect == 0.0f) {
|
if (std::fabs(aspect) < epsilon) {
|
||||||
aspect = (float)Window::width / (float)Window::height;
|
aspect = (float)Window::width / (float)Window::height;
|
||||||
}
|
}
|
||||||
if (perspective)
|
if (perspective)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user