Revert "fix: optimization: Various PVS-Studio warnings"
This commit is contained in:
@@ -50,10 +50,9 @@ std::unique_ptr<ImageData> BlocksPreview::draw(
|
||||
}
|
||||
offset = glm::vec3(1, 1, 0.0f);
|
||||
shader->uniformMatrix("u_apply", glm::translate(glm::mat4(1.0f), offset));
|
||||
glm::vec3 scaledSize = glm::vec3(size * 0.63f);
|
||||
batch->cube(
|
||||
-hitbox * scaledSize * 0.5f * glm::vec3(1,1,-1),
|
||||
hitbox * scaledSize,
|
||||
-hitbox * glm::vec3(size * 0.63f)*0.5f * glm::vec3(1,1,-1),
|
||||
hitbox * glm::vec3(size * 0.63f),
|
||||
texfaces, glm::vec4(1.0f),
|
||||
!def->rt.emissive
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ struct DecomposedMat4 {
|
||||
glm::vec4 perspective;
|
||||
};
|
||||
|
||||
static glm::mat4 extract_rotation(const glm::mat4& matrix) {
|
||||
static glm::mat4 extract_rotation(glm::mat4 matrix) {
|
||||
DecomposedMat4 decomposed = {};
|
||||
glm::quat rotation;
|
||||
glm::decompose(
|
||||
@@ -64,12 +64,11 @@ ModelBatch::ModelBatch(size_t capacity, Assets* assets, Chunks* chunks)
|
||||
blank = Texture::from(&image);
|
||||
}
|
||||
|
||||
ModelBatch::~ModelBatch() = default;
|
||||
ModelBatch::~ModelBatch() {
|
||||
}
|
||||
|
||||
void ModelBatch::draw(const model::Mesh& mesh,
|
||||
const glm::mat4& matrix,
|
||||
const glm::mat3& rotation,
|
||||
const glm::vec3& tint,
|
||||
void ModelBatch::draw(const model::Mesh& mesh, const glm::mat4& matrix,
|
||||
const glm::mat3& rotation, glm::vec3 tint,
|
||||
const texture_names_map* varTextures) {
|
||||
glm::vec3 gpos = matrix * glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
light_t light = chunks->getLight(floor(gpos.x), floor(gpos.y), floor(gpos.z));
|
||||
@@ -96,9 +95,8 @@ void ModelBatch::draw(const model::Mesh& mesh,
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBatch::draw(
|
||||
const glm::mat4& matrix,
|
||||
const glm::vec3& tint,
|
||||
void ModelBatch::draw(glm::mat4 matrix,
|
||||
glm::vec3 tint,
|
||||
const model::Model* model,
|
||||
const texture_names_map* varTextures) {
|
||||
for (const auto& mesh : model->meshes) {
|
||||
|
||||
@@ -37,10 +37,7 @@ class ModelBatch {
|
||||
static inline glm::vec3 SUN_VECTOR {0.411934f, 0.863868f, -0.279161f};
|
||||
|
||||
inline void vertex(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec2& uv,
|
||||
const glm::vec4& light,
|
||||
const glm::vec3& tint
|
||||
glm::vec3 pos, glm::vec2 uv, glm::vec4 light, glm::vec3 tint
|
||||
) {
|
||||
float* buffer = this->buffer.get();
|
||||
buffer[index++] = pos.x;
|
||||
@@ -67,8 +64,8 @@ class ModelBatch {
|
||||
|
||||
void draw(const model::Mesh& mesh,
|
||||
const glm::mat4& matrix,
|
||||
const glm::mat3& rotation,
|
||||
const glm::vec3& tint,
|
||||
const glm::mat3& rotation,
|
||||
glm::vec3 tint,
|
||||
const texture_names_map* varTextures);
|
||||
void setTexture(const std::string& name,
|
||||
const texture_names_map* varTextures);
|
||||
@@ -87,9 +84,8 @@ public:
|
||||
ModelBatch(size_t capacity, Assets* assets, Chunks* chunks);
|
||||
~ModelBatch();
|
||||
|
||||
void draw(
|
||||
const glm::mat4& matrix,
|
||||
const glm::vec3& tint,
|
||||
void draw(glm::mat4 matrix,
|
||||
glm::vec3 tint,
|
||||
const model::Model* model,
|
||||
const texture_names_map* varTextures);
|
||||
void render();
|
||||
|
||||
@@ -55,7 +55,8 @@ Skybox::Skybox(uint size, Shader* shader)
|
||||
});
|
||||
}
|
||||
|
||||
Skybox::~Skybox() = default;
|
||||
Skybox::~Skybox() {
|
||||
}
|
||||
|
||||
void Skybox::drawBackground(Camera* camera, Assets* assets, int width, int height) {
|
||||
auto backShader = assets->get<Shader>("background");
|
||||
|
||||
@@ -75,7 +75,8 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
|
||||
);
|
||||
}
|
||||
|
||||
WorldRenderer::~WorldRenderer() = default;
|
||||
WorldRenderer::~WorldRenderer() {
|
||||
}
|
||||
|
||||
bool WorldRenderer::drawChunk(
|
||||
size_t index,
|
||||
@@ -230,29 +231,26 @@ void WorldRenderer::renderBlockSelection() {
|
||||
: block->hitboxes;
|
||||
|
||||
lineBatch->lineWidth(2.0f);
|
||||
constexpr auto boxOffset = glm::vec3(0.02);
|
||||
constexpr auto boxColor = glm::vec4(0.f, 0.f, 0.f, 0.5f);
|
||||
for (auto& hitbox: hitboxes) {
|
||||
const glm::vec3 center = glm::vec3(pos) + hitbox.center();
|
||||
const glm::vec3 size = hitbox.size();
|
||||
lineBatch->box(center, size + boxOffset, boxColor);
|
||||
lineBatch->box(center, size + glm::vec3(0.02), glm::vec4(0.f, 0.f, 0.f, 0.5f));
|
||||
if (player->debug) {
|
||||
lineBatch->line(point, point+norm*0.5f, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
lineBatch->flush();
|
||||
}
|
||||
|
||||
void WorldRenderer::renderLines(
|
||||
Camera* camera, Shader* linesShader, const DrawContext& pctx
|
||||
) {
|
||||
auto ctx = pctx.sub(lineBatch.get());
|
||||
linesShader->use();
|
||||
linesShader->uniformMatrix("u_projview", camera->getProjView());
|
||||
if (player->selection.vox.id != BLOCK_VOID) {
|
||||
renderBlockSelection();
|
||||
}
|
||||
if (player->debug && showEntitiesDebug) {
|
||||
auto ctx = pctx.sub(lineBatch.get());
|
||||
level->entities->renderDebug(*lineBatch, *frustumCulling, ctx);
|
||||
}
|
||||
}
|
||||
@@ -343,12 +341,12 @@ void WorldRenderer::draw(
|
||||
ctx.setDepthTest(true);
|
||||
ctx.setCullFace(true);
|
||||
renderLevel(ctx, camera, settings, delta, pause);
|
||||
|
||||
// Debug lines
|
||||
if (hudVisible){
|
||||
renderLines(camera, linesShader, ctx);
|
||||
}
|
||||
}
|
||||
// Debug lines
|
||||
|
||||
if (hudVisible && player->debug) {
|
||||
renderDebugLines(wctx, camera, linesShader);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user