Skip to content

Commit

Permalink
Bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriiKoniushenko committed Oct 20, 2023
1 parent 512c3d4 commit c79c4f6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/core/camera/include/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Camera : public Utils::CopyableAndMoveable, public Updateable
private:
Utils::ISize2D size_;
glm::vec2 position_{};
float zoomFactor_ = 1.f;
float zoomFactor_ = 0.098f;
glm::vec2 origin_ = {};
float tick_{1.f};
};
9 changes: 7 additions & 2 deletions lib/core/core-wrappers/include/Updateable.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@

#pragma once

class Updateable
#include "NotCopyableButMovable.h"

class Updateable : public Utils::NotCopyableButMovable
{
public:
Updateable();
Updateable(bool isNeedUpdate = true);
virtual ~Updateable();
virtual void update() = 0;

private:
bool isNeedUpdate_ = false;
};
2 changes: 2 additions & 0 deletions lib/core/core-wrappers/source/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Image& Image::operator=(Image&& obj) noexcept
this->height_ = obj.height_;
this->channel_ = obj.channel_;
this->internalChannel_ = obj.internalChannel_;
this->name_ = obj.name_;

obj.init_();
return *this;
Expand All @@ -63,6 +64,7 @@ void Image::init_()
data_ = nullptr;
width_ = height_ = 0;
channel_ = Channel::None;
name_.clear();
}

int Image::getWidth() const
Expand Down
12 changes: 9 additions & 3 deletions lib/core/core-wrappers/source/Updateable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@

#include "UpdateableCollector.h"

Updateable::Updateable()
Updateable::Updateable(bool isNeedUpdate/* = true*/) : isNeedUpdate_(isNeedUpdate)
{
GetUpdateableCollector().add(this);
if (isNeedUpdate_)
{
GetUpdateableCollector().add(this);
}
}

Updateable::~Updateable()
{
GetUpdateableCollector().remove(this);
if (isNeedUpdate_)
{
GetUpdateableCollector().remove(this);
}
}
2 changes: 1 addition & 1 deletion lib/core/core-wrappers/source/UpdateableCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void UpdateableCollector::remove(Updateable* object)

void UpdateableCollector::updateAll()
{
for (auto* data : data_)
for (auto* data : data_) // TODO: it needs multithreading
{
data->update();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/shapes/include/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Widget : public DrawAble, public JsonPrintable, public Updateable, public
inline static constexpr float borderWidth = 0.05f;
inline static constexpr const char* componentName = "widget";

Widget();
Widget(bool isNeedUpdate = false);

Widget(Widget&& other) noexcept;

Expand Down
4 changes: 2 additions & 2 deletions lib/core/shapes/source/Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

Widget::Widget()
Widget::Widget(bool isNeedUpdate/* = true*/) : Updateable(isNeedUpdate)
{
getWidgetCollector().add(this);
}
Expand Down Expand Up @@ -123,7 +123,7 @@ void Widget::setTexture(Texture& texture)

Texture& Widget::getTexture()
{
if (texture_)
if (!texture_)
{
throw std::runtime_error("Impossible to get NULL texture");
}
Expand Down

0 comments on commit c79c4f6

Please sign in to comment.