Skip to content

Commit

Permalink
Chore: Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
brenocq committed Dec 30, 2023
1 parent 888f461 commit e98ed22
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 39 deletions.
8 changes: 4 additions & 4 deletions src/atta/graphics/apis/openGL/framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ void Framebuffer::bindAttachments() {

for (unsigned i = 0; i < _images.size(); i++) {
std::shared_ptr<Image> image = std::dynamic_pointer_cast<Image>(_images[i]);
bool isColor = (i != _depthAttachmentIndex) && (i != _stencilAttachmentIndex);
if (i == _depthAttachmentIndex) {
bool isColor = ((int)i != _depthAttachmentIndex) && ((int)i != _stencilAttachmentIndex);
if ((int)i == _depthAttachmentIndex) {
if (!image->isCubemap())
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, image->getHandle(), 0);
else
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, image->getHandle(), 0);
}
if (i == _stencilAttachmentIndex) {
if ((int)i == _stencilAttachmentIndex) {
if (!image->isCubemap())
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, image->getHandle(), 0);
else
Expand Down Expand Up @@ -94,7 +94,7 @@ void Framebuffer::bind(bool clear) {
GLint clearColor[4];
for (size_t i = 0; i < 4; i++)
clearColor[i] = (GLint)std::round(_clearColor[i]);
glClearBufferiv(GL_COLOR, GL_COLOR_ATTACHMENT0, clearColor);
glClearBufferiv(GL_COLOR, 0, clearColor);
}

if (_depthAttachmentIndex != -1 && _stencilAttachmentIndex != -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/atta/graphics/bufferLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace atta::graphics {
std::vector<std::string> toStr = {"?", "bool", "int", "uint", "float", "vec2", "vec3", "vec4",
"ivec2", "ivec3", "ivec4", "mat3", "mat4", "sampler2D", "samplerCube"};
BufferLayout::Element::Type BufferLayout::Element::typeFromString(std::string type) {
for (int i = 0; i < toStr.size(); i++)
for (size_t i = 0; i < toStr.size(); i++)
if (toStr[i] == type)
return (Type)i;
return Type::NONE;
Expand Down
2 changes: 0 additions & 2 deletions src/atta/io/bluetooth/linuxBluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,13 +789,11 @@ bool LinuxBluetooth::notifyCharStart(const Char& ch, NotifyFunction func) {
bool LinuxBluetooth::notifyCharStop(const Char& ch) {
Char* cch = nullptr;
LinuxChar* lch = nullptr;
LinuxDevice* lDev = nullptr;
for (auto& llDev : _linuxDevices)
for (auto& lServ : llDev.services)
for (auto& llch : lServ.chars)
if (llch.uuid == ch.uuid) {
lch = &llch;
lDev = &llDev;
}
for (auto& llDev : _devices)
for (auto& lServ : llDev.services)
Expand Down
2 changes: 1 addition & 1 deletion src/atta/io/http/jsonParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void Json::parseAux(const std::string& str, unsigned& pos, bool& res) {
// INT or FLOAT
unsigned curr = pos;
// Find first char that is not a digit or '-'
while (curr + 1 < str.size() && (str[curr] >= '0' && str[curr] <= '9' || str[curr] == '-'))
while (curr + 1 < str.size() && ((str[curr] >= '0' && str[curr] <= '9') || str[curr] == '-'))
curr++;

// Check if it is .
Expand Down
3 changes: 0 additions & 3 deletions src/atta/physics/engines/box2DEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ void Box2DEngine::createRigidBody(component::EntityId entity) {
component::Transform worldT = t->getWorldTransform(entity);
vec3 position = worldT.position;
quat orientation = worldT.orientation;
vec3 scale = worldT.scale;

// Create box2d body definition
b2BodyDef bodyDef;
Expand Down Expand Up @@ -283,8 +282,6 @@ void Box2DEngine::createColliders(component::EntityId entity) {

// Get world transform
component::Transform worldT = t->getWorldTransform(entity);
vec3 position = worldT.position;
quat orientation = worldT.orientation;
vec3 scale = worldT.scale;
b2FixtureDef fixtureDef;

Expand Down
5 changes: 2 additions & 3 deletions src/atta/physics/engines/bulletEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ void BulletEngine::step(float dt) {
auto t = component::getComponent<component::Transform>(eid);
component::Transform worldT = t->getWorldTransform(eid);
vec3 position = worldT.position;
vec3 scale = worldT.scale;
quat orientation = worldT.orientation;

// Get bullet transform
Expand Down Expand Up @@ -142,7 +141,7 @@ void BulletEngine::step(float dt) {
// TODO Should go through collisionObjects from the root down the relationship hierarchy,
// strange simulations may happen otherwise because of wrong parent transform
btCollisionObject* obj = _world->getCollisionObjectArray()[j];
btRigidBody* body = btRigidBody::upcast(obj);
// btRigidBody* body = btRigidBody::upcast(obj);
btTransform trans;
trans = obj->getWorldTransform();

Expand Down Expand Up @@ -213,7 +212,7 @@ void BulletEngine::stop() {
}

// Delete collision shapes
for (size_t i = 0; i < _collisionShapes.size(); i++) {
for (int i = 0; i < _collisionShapes.size(); i++) {
delete _collisionShapes[i];
_collisionShapes[i] = nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions src/atta/resource/resources/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Image::Image(const fs::path& filename, CreateInfo info) : Resource(filename) {
}

_data = new uint8_t[_width * _height * _channels * getBytesPerChannel(_format)];
for (int i = 0; i < _width * _height * _channels * getBytesPerChannel(_format); i++)
for (size_t i = 0; i < _width * _height * _channels * getBytesPerChannel(_format); i++)
_data[i] = 0;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ void Image::load() {
// Copy temp data to _data
uint32_t size = _width * _height * _channels * getBytesPerChannel(_format);
_data = new uint8_t[size];
for (int i = 0; i < size; i++)
for (size_t i = 0; i < size; i++)
_data[i] = data[i];
stbi_image_free(data);
// LOG_INFO("resource::Image", "[w]$3[] -> w:$0, h:$1, c:$2", _width, _height, _channels, absolutePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace atta::ui {

void FlameGraph::compute() {
for (auto& [threadId, records] : Profiler::calcRecordsByThreadId(_lastRecordsSize)) {
for (int i = 0; i < records.size(); i++) {

for (size_t i = 0; i < records.size(); i++) {
}
}
_lastRecordsSize = Profiler::getRecords().size();
Expand Down Expand Up @@ -51,8 +50,7 @@ void FlameGraph::render() {
ImVec2 rmin = ImPlot::PlotToPixels(ImPlotPoint(0.25f, 0.75f));
ImVec2 rmax = ImPlot::PlotToPixels(ImPlotPoint(0.75f, 0.25f));
ImPlot::PushPlotClipRect();
if(_flameBar.name != StringId())
{
if (_flameBar.name != StringId()) {
ImPlot::GetPlotDrawList()->AddCircleFilled(cntr, 20, IM_COL32(255, 255, 0, 255), 20);
ImPlot::GetPlotDrawList()->AddRect(rmin, rmax, IM_COL32(128, 0, 255, 255));
}
Expand Down
13 changes: 6 additions & 7 deletions src/atta/ui/editor/tools/timeProfiler/components/tearDown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ void TearDown::compute() {
for (auto& [threadId, records] : Profiler::calcRecordsByThreadId(_lastRecordsSize)) {
std::vector<TimeInterval>& nestedTime = _nestedTime[threadId];
// For each record in this thread
for (int i = 0; i < records.size(); i++) {
for (size_t i = 0; i < records.size(); i++) {
Profiler::Record r = records[i];

// Total time
Profiler::Time time = r.end - r.begin;

// Remove time of nested functions
for (int j = nestedTime.size() - 1; j >= 0; j--) {
for (int j = (int)nestedTime.size() - 1; j >= 0; j--) {
if (nestedTime[j].end < r.begin)
break;
else {
Expand Down Expand Up @@ -140,8 +140,8 @@ void TearDown::render() {

// Name
ImGui::TableNextColumn();
std::string name = _funcTime[row].name.getString();
if(cropName)
std::string name = _funcTime[row].name.getString();
if (cropName)
name = Profiler::cropFuncName(name);
ImGui::Text(name.c_str());

Expand Down Expand Up @@ -170,9 +170,8 @@ void TearDown::render() {
float barPerc = _funcTime[row].time / float(_maxTime);
pMax.x = pMin.x + (pMax.x - pMin.x) * barPerc;

if (pMax.x > pMin.x)
{
uint8_t r,g,b;
if (pMax.x > pMin.x) {
uint8_t r, g, b;
Profiler::getFuncColor(_funcTime[row].name, r, g, b);
drawList->AddRectFilled(pMin, pMax, IM_COL32(r, g, b, 255));
}
Expand Down
16 changes: 6 additions & 10 deletions src/atta/ui/editor/tools/timeProfiler/components/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ namespace atta::ui {
void Timeline::compute() {
for (auto& [threadId, records] : Profiler::calcRecordsByThreadId(_lastRecordsSize)) {
std::vector<Profiler::Record>& sortedRecords = _sortedRecords[threadId];
for (int i = 0; i < records.size(); i++) {
for (size_t i = 0; i < records.size(); i++) {
// Add to back
sortedRecords.push_back(records[i]);

// Move back until correct position
for (int j = sortedRecords.size() - 2; j >= 0; j--) {
for (int j = (int)sortedRecords.size() - 2; j >= 0; j--) {
if (sortedRecords[j].begin > sortedRecords[j + 1].begin)
std::swap(sortedRecords[j], sortedRecords[j + 1]);
else
Expand Down Expand Up @@ -92,7 +92,6 @@ void Timeline::render() {
float pixelTime = size.x / sizePixels.x; // Time interval of each pixel

ImPlot::PushPlotClipRect();
float nextDrawTime = 0;
maxStackSize = 0;
for (const Profiler::Record& record : records) {
// Free stack
Expand Down Expand Up @@ -125,24 +124,21 @@ void Timeline::render() {
min.x = std::max(beginTime, float(limits.X.Min));
max.x = std::min(endTime, float(limits.X.Max));
// Calculate text size
ImPlotPoint textOrigin = ImPlot::PixelsToPlot(ImVec2(0,0));
ImPlotPoint textOrigin = ImPlot::PixelsToPlot(ImVec2(0, 0));
ImPlotPoint textSize = ImPlot::PixelsToPlot(ImGui::CalcTextSize(name.c_str()));
textSize.x = textSize.x - textOrigin.x;
// If text too big, try funcName...
if (textSize.x >= max.x - min.x) {
// If can't render full name, try partial name
std::string fullName = name;
for(int s = 5; s <= fullName.size()-3; s++)
{
for (size_t s = 5; s <= fullName.size() - 3; s++) {
std::string subStr = fullName.substr(0, s) + "...";
ImPlotPoint subTextSize = ImPlot::PixelsToPlot(ImGui::CalcTextSize(subStr.c_str()));
subTextSize.x = subTextSize.x - textOrigin.x;
if (subTextSize.x < max.x - min.x)
{
if (subTextSize.x < max.x - min.x) {
name = subStr;
textSize = subTextSize;
}
else
} else
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/atta/ui/editor/windows/viewportWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ void ViewportWindows::render() {
static clock_t vpLastTime = std::clock();
const clock_t vpCurrTime = std::clock();
const float vpTimeDiff = float(vpCurrTime - vpLastTime) / CLOCKS_PER_SEC;
bool shouldRenderViewports = false;
if (graphics::getViewportRendering() && (graphics::getViewportFPS() > 0 && (vpTimeDiff > 1 / graphics::getViewportFPS()))) {
vpLastTime = vpCurrTime;
shouldRenderViewports = true;
}

int i = -1;
Expand Down

0 comments on commit e98ed22

Please sign in to comment.