Revert "fix: optimization: Various PVS-Studio warnings"
This commit is contained in:
@@ -19,7 +19,8 @@ Atlas::Atlas(
|
||||
}
|
||||
}
|
||||
|
||||
Atlas::~Atlas() = default;
|
||||
Atlas::~Atlas() {
|
||||
}
|
||||
|
||||
void Atlas::prepare() {
|
||||
texture = Texture::from(image.get());
|
||||
|
||||
@@ -47,7 +47,7 @@ class AtlasBuilder {
|
||||
std::vector<atlasentry> entries;
|
||||
std::set<std::string> names;
|
||||
public:
|
||||
AtlasBuilder() = default;
|
||||
AtlasBuilder() {}
|
||||
void add(const std::string& name, std::unique_ptr<ImageData> image);
|
||||
bool has(const std::string& name) const;
|
||||
const std::set<std::string>& getNames() { return names; };
|
||||
|
||||
@@ -59,8 +59,8 @@ void Batch2D::vertex(
|
||||
buffer[index++] = a;
|
||||
}
|
||||
void Batch2D::vertex(
|
||||
const glm::vec2& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec2 point,
|
||||
glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
) {
|
||||
buffer[index++] = point.x;
|
||||
@@ -138,7 +138,7 @@ void Batch2D::rect(
|
||||
UVRegion region,
|
||||
bool flippedX,
|
||||
bool flippedY,
|
||||
const glm::vec4& tint
|
||||
glm::vec4 tint
|
||||
) {
|
||||
if (index + 6*B2D_VERTEX_SIZE >= capacity) {
|
||||
flush();
|
||||
@@ -322,13 +322,11 @@ void Batch2D::rect(
|
||||
vertex(v1, glm::vec2(0, 0), r2,g2,b2,1.0f);
|
||||
}
|
||||
|
||||
void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region,
|
||||
const glm::vec4& tint){
|
||||
void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint){
|
||||
rect(x, y, w, h, region.u1, region.v1, region.u2-region.u1, region.v2-region.v1, tint.r, tint.g, tint.b, tint.a);
|
||||
}
|
||||
|
||||
void Batch2D::sprite(float x, float y, float w, float h, int atlasRes, int index,
|
||||
const glm::vec4& tint){
|
||||
void Batch2D::sprite(float x, float y, float w, float h, int atlasRes, int index, glm::vec4 tint){
|
||||
float scale = 1.0f / (float)atlasRes;
|
||||
float u = (index % atlasRes) * scale;
|
||||
float v = 1.0f - ((index / atlasRes) * scale) - scale;
|
||||
|
||||
@@ -31,8 +31,8 @@ class Batch2D : public Flushable {
|
||||
);
|
||||
|
||||
void vertex(
|
||||
const glm::vec2& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec2 point,
|
||||
glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
|
||||
@@ -44,13 +44,11 @@ public:
|
||||
void texture(Texture* texture);
|
||||
void untexture();
|
||||
void setRegion(UVRegion region);
|
||||
void sprite(float x, float y, float w, float h, const UVRegion& region,
|
||||
const glm::vec4& tint);
|
||||
void sprite(float x, float y, float w, float h, int atlasRes, int index,
|
||||
const glm::vec4& tint);
|
||||
void sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint);
|
||||
void sprite(float x, float y, float w, float h, int atlasRes, int index, glm::vec4 tint);
|
||||
void point(float x, float y, float r, float g, float b, float a);
|
||||
|
||||
inline void setColor(const glm::vec4& color) {
|
||||
inline void setColor(glm::vec4 color) {
|
||||
this->color = color;
|
||||
}
|
||||
inline glm::vec4 getColor() const {
|
||||
@@ -71,7 +69,7 @@ public:
|
||||
float ox, float oy,
|
||||
float angle, UVRegion region,
|
||||
bool flippedX, bool flippedY,
|
||||
const glm::vec4& tint
|
||||
glm::vec4 tint
|
||||
);
|
||||
|
||||
void rect(float x, float y, float w, float h);
|
||||
|
||||
@@ -51,7 +51,7 @@ void Batch3D::vertex(
|
||||
buffer[index++] = a;
|
||||
}
|
||||
void Batch3D::vertex(
|
||||
const glm::vec3& coord, float u, float v,
|
||||
glm::vec3 coord, float u, float v,
|
||||
float r, float g, float b, float a
|
||||
) {
|
||||
buffer[index++] = coord.x;
|
||||
@@ -65,8 +65,8 @@ void Batch3D::vertex(
|
||||
buffer[index++] = a;
|
||||
}
|
||||
void Batch3D::vertex(
|
||||
const glm::vec3& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec3 point,
|
||||
glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
) {
|
||||
buffer[index++] = point.x;
|
||||
@@ -118,12 +118,12 @@ void Batch3D::texture(Texture* new_texture){
|
||||
}
|
||||
|
||||
void Batch3D::sprite(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec3& up,
|
||||
const glm::vec3& right,
|
||||
glm::vec3 pos,
|
||||
glm::vec3 up,
|
||||
glm::vec3 right,
|
||||
float w, float h,
|
||||
const UVRegion& uv,
|
||||
const glm::vec4& color
|
||||
const UVRegion& uv,
|
||||
glm::vec4 color
|
||||
){
|
||||
const float r = color.r;
|
||||
const float g = color.g;
|
||||
@@ -245,11 +245,11 @@ void Batch3D::blockCube(
|
||||
cube((1.0f - size) * -0.5f, size, texfaces, tint, shading);
|
||||
}
|
||||
|
||||
void Batch3D::point(const glm::vec3& coord, const glm::vec2& uv, const glm::vec4& tint) {
|
||||
void Batch3D::point(glm::vec3 coord, glm::vec2 uv, glm::vec4 tint) {
|
||||
vertex(coord, uv, tint.r, tint.g, tint.b, tint.a);
|
||||
}
|
||||
|
||||
void Batch3D::point(const glm::vec3& coord, const glm::vec4& tint) {
|
||||
void Batch3D::point(glm::vec3 coord, glm::vec4 tint) {
|
||||
point(coord, glm::vec2(), tint);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,12 @@ class Batch3D : public Flushable {
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
void vertex(
|
||||
const glm::vec3& coord,
|
||||
glm::vec3 coord,
|
||||
float u, float v,
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
void vertex(
|
||||
const glm::vec3& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec3 point, glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
void face(
|
||||
@@ -50,18 +49,12 @@ public:
|
||||
|
||||
void begin();
|
||||
void texture(Texture* texture);
|
||||
void sprite(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec3& up,
|
||||
const glm::vec3& right, float w, float h, const UVRegion& uv,
|
||||
const glm::vec4& color
|
||||
);
|
||||
void sprite(glm::vec3 pos, glm::vec3 up, glm::vec3 right, float w, float h, const UVRegion& uv, glm::vec4 tint);
|
||||
void xSprite(float w, float h, const UVRegion& uv, const glm::vec4 tint, bool shading=true);
|
||||
void cube(const glm::vec3 coords, const glm::vec3 size, const UVRegion(&texfaces)[6], const glm::vec4 tint, bool shading=true);
|
||||
void blockCube(const glm::vec3 size, const UVRegion(&texfaces)[6], const glm::vec4 tint, bool shading=true);
|
||||
void point(
|
||||
const glm::vec3& coord, const glm::vec2& uv, const glm::vec4& tint);
|
||||
void point(const glm::vec3& coord, const glm::vec4& tint);
|
||||
void point(glm::vec3 pos, glm::vec2 uv, glm::vec4 tint);
|
||||
void point(glm::vec3 pos, glm::vec4 tint);
|
||||
void flush() override;
|
||||
void flushPoints();
|
||||
};
|
||||
|
||||
@@ -148,7 +148,7 @@ void DrawContext::setBlendMode(BlendMode mode) {
|
||||
set_blend_mode(mode);
|
||||
}
|
||||
|
||||
void DrawContext::setScissors(const glm::vec4& area) {
|
||||
void DrawContext::setScissors(glm::vec4 area) {
|
||||
Window::pushScissor(area);
|
||||
scissorsCount++;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
void setDepthTest(bool flag);
|
||||
void setCullFace(bool flag);
|
||||
void setBlendMode(BlendMode mode);
|
||||
void setScissors(const glm::vec4& area);
|
||||
void setScissors(glm::vec4 area);
|
||||
void setLineWidth(float width);
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ Font::Font(std::vector<std::unique_ptr<Texture>> pages, int lineHeight, int yoff
|
||||
: lineHeight(lineHeight), yoffset(yoffset), pages(std::move(pages)) {
|
||||
}
|
||||
|
||||
Font::~Font() = default;
|
||||
Font::~Font(){
|
||||
}
|
||||
|
||||
int Font::getYOffset() const {
|
||||
return yoffset;
|
||||
|
||||
@@ -41,7 +41,8 @@ ImageData::ImageData(ImageFormat format, uint width, uint height, const ubyte* d
|
||||
std::memcpy(this->data.get(), data, width * height * pixsize);
|
||||
}
|
||||
|
||||
ImageData::~ImageData() = default;
|
||||
ImageData::~ImageData() {
|
||||
}
|
||||
|
||||
void ImageData::flipX() {
|
||||
switch (format) {
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
LineBatch(size_t capacity=4096);
|
||||
~LineBatch();
|
||||
|
||||
inline void line(const glm::vec3 &a, const glm::vec3 &b, const glm::vec4 &color) {
|
||||
inline void line(const glm::vec3 a, const glm::vec3 b, const glm::vec4 color) {
|
||||
line(a.x, a.y, a.z, b.x, b.y, b.z, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
void line(float x1, float y1, float z1, float x2, float y2, float z2,
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
void box(float x, float y, float z, float w, float h, float d,
|
||||
float r, float g, float b, float a);
|
||||
|
||||
inline void box(const glm::vec3 &xyz, const glm::vec3 &whd, const glm::vec4 &rgba) {
|
||||
inline void box(glm::vec3 xyz, glm::vec3 whd, glm::vec4 rgba) {
|
||||
box(xyz.x, xyz.y, xyz.z, whd.x, whd.y, whd.z,
|
||||
rgba.r, rgba.g, rgba.b, rgba.a);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,7 @@ inline constexpr glm::vec3 X(1, 0, 0);
|
||||
inline constexpr glm::vec3 Y(0, 1, 0);
|
||||
inline constexpr glm::vec3 Z(0, 0, 1);
|
||||
|
||||
void Mesh::addPlane(
|
||||
const glm::vec3 &pos,
|
||||
const glm::vec3 &right,
|
||||
const glm::vec3 &up,
|
||||
const glm::vec3 &norm) {
|
||||
void Mesh::addPlane(glm::vec3 pos, glm::vec3 right, glm::vec3 up, glm::vec3 norm) {
|
||||
vertices.push_back({pos-right-up, {0,0}, norm});
|
||||
vertices.push_back({pos+right-up, {1,0}, norm});
|
||||
vertices.push_back({pos+right+up, {1,1}, norm});
|
||||
@@ -22,7 +18,7 @@ void Mesh::addPlane(
|
||||
vertices.push_back({pos-right+up, {0,1}, norm});
|
||||
}
|
||||
|
||||
void Mesh::addBox(const glm::vec3 &pos, const glm::vec3 &size) {
|
||||
void Mesh::addBox(glm::vec3 pos, glm::vec3 size) {
|
||||
addPlane(pos+Z*size, X*size, Y*size, Z);
|
||||
addPlane(pos-Z*size, -X*size, Y*size, -Z);
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@ namespace model {
|
||||
std::string texture;
|
||||
std::vector<Vertex> vertices;
|
||||
|
||||
void addPlane(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec3& right,
|
||||
const glm::vec3& up,
|
||||
const glm::vec3& norm);
|
||||
void addBox(const glm::vec3& pos, const glm::vec3& size);
|
||||
void addPlane(glm::vec3 pos, glm::vec3 right, glm::vec3 up, glm::vec3 norm);
|
||||
void addBox(glm::vec3 pos, glm::vec3 size);
|
||||
};
|
||||
|
||||
struct Model {
|
||||
|
||||
@@ -18,7 +18,8 @@ PostProcessing::PostProcessing() {
|
||||
quadMesh = std::make_unique<Mesh>(vertices, 6, attrs);
|
||||
}
|
||||
|
||||
PostProcessing::~PostProcessing() = default;
|
||||
PostProcessing::~PostProcessing() {
|
||||
}
|
||||
|
||||
void PostProcessing::use(DrawContext& context) {
|
||||
const auto& vp = context.getViewport();
|
||||
|
||||
@@ -32,7 +32,7 @@ uint Shader::getUniformLocation(const std::string& name) {
|
||||
auto found = uniformLocations.find(name);
|
||||
if (found == uniformLocations.end()) {
|
||||
uint location = glGetUniformLocation(id, name.c_str());
|
||||
uniformLocations.try_emplace(name, location);
|
||||
uniformLocations.emplace(name, location);
|
||||
return location;
|
||||
}
|
||||
return found->second;
|
||||
@@ -54,11 +54,11 @@ void Shader::uniform2f(const std::string& name, float x, float y){
|
||||
glUniform2f(getUniformLocation(name), x, y);
|
||||
}
|
||||
|
||||
void Shader::uniform2f(const std::string& name, const glm::vec2& xy){
|
||||
void Shader::uniform2f(const std::string& name, glm::vec2 xy){
|
||||
glUniform2f(getUniformLocation(name), xy.x, xy.y);
|
||||
}
|
||||
|
||||
void Shader::uniform2i(const std::string& name, const glm::ivec2& xy){
|
||||
void Shader::uniform2i(const std::string& name, glm::ivec2 xy){
|
||||
glUniform2i(getUniformLocation(name), xy.x, xy.y);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ void Shader::uniform3f(const std::string& name, float x, float y, float z){
|
||||
glUniform3f(getUniformLocation(name), x,y,z);
|
||||
}
|
||||
|
||||
void Shader::uniform3f(const std::string& name, const glm::vec3& xyz){
|
||||
void Shader::uniform3f(const std::string& name, glm::vec3 xyz){
|
||||
glUniform3f(getUniformLocation(name), xyz.x, xyz.y, xyz.z);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ public:
|
||||
void uniform1i(const std::string& name, int x);
|
||||
void uniform1f(const std::string& name, float x);
|
||||
void uniform2f(const std::string& name, float x, float y);
|
||||
void uniform2f(const std::string& name, const glm::vec2& xy);
|
||||
void uniform2i(const std::string& name, const glm::ivec2& xy);
|
||||
void uniform2f(const std::string& name, glm::vec2 xy);
|
||||
void uniform2i(const std::string& name, glm::ivec2 xy);
|
||||
void uniform3f(const std::string& name, float x, float y, float z);
|
||||
void uniform3f(const std::string& name, const glm::vec3& xyz);
|
||||
void uniform3f(const std::string& name, glm::vec3 xyz);
|
||||
|
||||
/// @brief Create shader program using vertex and fragment shaders source.
|
||||
/// @param vertexFile vertex shader file name
|
||||
|
||||
@@ -22,7 +22,7 @@ struct Frame {
|
||||
class TextureAnimation {
|
||||
public:
|
||||
TextureAnimation(Texture* srcTex, Texture* dstTex) : srcTexture(srcTex), dstTexture(dstTex) {};
|
||||
~TextureAnimation() = default;
|
||||
~TextureAnimation() {};
|
||||
|
||||
void addFrame(const Frame& frame) { frames.emplace_back(frame); };
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ GUI::GUI() {
|
||||
container->add(tooltip);
|
||||
}
|
||||
|
||||
GUI::~GUI() = default;
|
||||
GUI::~GUI() {
|
||||
}
|
||||
|
||||
std::shared_ptr<Menu> GUI::getMenu() {
|
||||
return menu;
|
||||
|
||||
@@ -52,7 +52,7 @@ InventoryBuilder::InventoryBuilder() {
|
||||
|
||||
void InventoryBuilder::addGrid(
|
||||
int cols, int count,
|
||||
const glm::vec2 &pos,
|
||||
glm::vec2 pos,
|
||||
int padding,
|
||||
bool addpanel,
|
||||
const SlotLayout& slotLayout
|
||||
@@ -126,7 +126,7 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
|
||||
langs::get(util::str2wstr_utf8(def->caption))
|
||||
);
|
||||
} else {
|
||||
tooltip.clear();
|
||||
tooltip = L"";
|
||||
}
|
||||
}
|
||||
prevItem = itemid;
|
||||
@@ -381,7 +381,7 @@ void InventoryView::setPos(glm::vec2 pos) {
|
||||
Container::setPos(pos - origin);
|
||||
}
|
||||
|
||||
void InventoryView::setOrigin(const glm::vec2 &origin) {
|
||||
void InventoryView::setOrigin(glm::vec2 origin) {
|
||||
this->origin = origin;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace gui {
|
||||
|
||||
virtual void setPos(glm::vec2 pos) override;
|
||||
|
||||
void setOrigin(const glm::vec2 &origin);
|
||||
void setOrigin(glm::vec2 origin);
|
||||
glm::vec2 getOrigin() const;
|
||||
|
||||
void setSelected(int index);
|
||||
@@ -130,7 +130,7 @@ namespace gui {
|
||||
/// @param slotLayout slot settings (index and position are ignored)
|
||||
void addGrid(
|
||||
int cols, int count,
|
||||
const glm::vec2 &pos,
|
||||
glm::vec2 pos,
|
||||
int padding,
|
||||
bool addpanel,
|
||||
const SlotLayout& slotLayout
|
||||
|
||||
@@ -145,7 +145,7 @@ uint Label::getLineByYOffset(int offset) const {
|
||||
|
||||
uint Label::getLineByTextIndex(size_t index) const {
|
||||
for (size_t i = 0; i < cache.lines.size(); i++) {
|
||||
if (cache.lines[i].offset > index) {
|
||||
if (cache.lines.at(i).offset > index) {
|
||||
return i-1;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void Label::draw(const DrawContext* pctx, Assets* assets) {
|
||||
|
||||
if (multiline) {
|
||||
for (size_t i = 0; i < cache.lines.size(); i++) {
|
||||
auto& line = cache.lines[i];
|
||||
auto& line = cache.lines.at(i);
|
||||
size_t offset = line.offset;
|
||||
std::wstring_view view(text.c_str()+offset, text.length()-offset);
|
||||
if (i < cache.lines.size()-1) {
|
||||
|
||||
@@ -203,7 +203,7 @@ static void _readPanel(UiXmlReader& reader, const xml::xmlelement& element, Pane
|
||||
panel.setMaxLength(element->attr("max-length").asInt());
|
||||
}
|
||||
if (element->has("orientation")) {
|
||||
const auto &oname = element->attr("orientation").getText();
|
||||
auto oname = element->attr("orientation").getText();
|
||||
if (oname == "horizontal") {
|
||||
panel.setOrientation(Orientation::horizontal);
|
||||
}
|
||||
@@ -286,7 +286,7 @@ static std::shared_ptr<UINode> readButton(UiXmlReader& reader, const xml::xmlele
|
||||
|
||||
std::shared_ptr<Button> button;
|
||||
auto& elements = element->getElements();
|
||||
if (!elements.empty() && elements[0]->getTag() != "#") {
|
||||
if (!elements.empty() && elements.at(0)->getTag() != "#") {
|
||||
auto inner = reader.readUINode(element->getElements().at(0));
|
||||
if (inner != nullptr) {
|
||||
button = std::make_shared<Button>(inner, padding);
|
||||
|
||||
Reference in New Issue
Block a user