Skip to content

Commit

Permalink
Fix code formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciech-graj committed Aug 15, 2022
1 parent b0efaa5 commit 19dfab3
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 1,033 deletions.
2 changes: 0 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
- Replace hashmap.c with glib HashTable
- Improve atmosphere shader
- Clean up multithreading sync functions
- Ensure all GObjects are correctly ref'd and unref'd
- Re-implement timeline (maybe)
- Improve settings menu
- Web build? (broadway)
1,005 changes: 0 additions & 1,005 deletions res/ui/ui.glade~

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/error.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __ERROR_H__
#define __ERROR_H__

#include "type.h"
#include "system.h"
#include "type.h"

#define error(...) \
do { \
Expand Down
2 changes: 0 additions & 2 deletions src/core/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@

#define sgn(x) (signbit(x) ? -1 : 1)

#define PI 3.1415927f

#endif /* __TYPE_H__ */
2 changes: 1 addition & 1 deletion src/gfx/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include "camera.h"
#include "error.h"
#include "info.h"
#include "render.h"
#include "thread.h"
#include "timemgr.h"
#include "info.h"

struct GLCtx e_gl_ctx;
static GtkGLArea *glarea;
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void render_init(void)
glm_vec3_copy((vec3){ 0, 0, 1 }, e_camera.up);

e_camera.rad = 5.f;
e_camera.fov = PI / 2.f;
e_camera.fov = (float)G_PI / 2.f;
e_camera.near = 0.05f;
e_camera.far = 100.f;

Expand Down
8 changes: 4 additions & 4 deletions src/phys/phys.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ void phys_phys(void)
double n = fmod(jd_epoch, 365.25); /* Days elapsed since Jan 1 Midnight */
glm_vec2_copy((vec2){
1.0 - modf(jd_epoch, &temp), /* Omitted Equation of Time */
((float)asin(0.39779 * cos(0.017203 * (n + 10) + 0.0334 * sin(0.017203 * (n - 2)))) + PI) / (2.f * PI),
((float)asin(0.39779 * cos(0.017203 * (n + 10) + 0.0334 * sin(0.017203 * (n - 2)))) + (float)G_PI) / (2.f * (float)G_PI),
},
phys_ctx_sync.sun_uv);
glm_vec3_copy((vec3){
-cosf(phys_ctx_sync.sun_uv[0] * 2.f * PI) * sinf(phys_ctx_sync.sun_uv[1] * PI),
-sinf(phys_ctx_sync.sun_uv[0] * 2.f * PI) * sinf(phys_ctx_sync.sun_uv[1] * PI),
cosf(phys_ctx_sync.sun_uv[1] * PI),
-cosf(phys_ctx_sync.sun_uv[0] * 2.f * (float)G_PI) * sinf(phys_ctx_sync.sun_uv[1] * (float)G_PI),
-sinf(phys_ctx_sync.sun_uv[0] * 2.f * (float)G_PI) * sinf(phys_ctx_sync.sun_uv[1] * (float)G_PI),
cosf(phys_ctx_sync.sun_uv[1] * (float)G_PI),
},
phys_ctx_sync.sun_dir);
}
Expand Down
7 changes: 3 additions & 4 deletions src/ui/catalog.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "catalog.h"

#include "satcat_code.h"
#include "info.h"
#include "satcat_code.h"

enum Column {
COL_SELECT = 0u,
Expand Down Expand Up @@ -150,8 +150,7 @@ void on_catalog_notebook_switch_page(GtkNotebook *notebook, GtkWidget *page, gui
-1);
info_show(satellite);
}
}
break;
} break;
}
}

Expand Down Expand Up @@ -340,7 +339,7 @@ void catalog_init(GtkBuilder *builder)
"on_window_catalog_delete_event", G_CALLBACK(on_window_catalog_delete_event),
"on_catalog_search_search_changed", G_CALLBACK(on_catalog_search_search_changed),
"on_col_clicked", G_CALLBACK(on_col_clicked),
"on_catalog_notebook_switch_page", G_CALLBACK(on_catalog_notebook_switch_page),
"on_catalog_notebook_switch_page", G_CALLBACK(on_catalog_notebook_switch_page),
NULL);

window_catalog = GTK_WINDOW(gtk_builder_get_object(builder, "window_catalog"));
Expand Down
12 changes: 6 additions & 6 deletions src/ui/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include "TLE.h"
#include "satcat_code.h"
#include <cglm/vec2.h>
#include <cglm/vec3.h>
#include <cglm/mat3.h>
#include <cglm/mat4.h>
#include <cglm/vec2.h>
#include <cglm/vec3.h>

#include <math.h>

Expand Down Expand Up @@ -140,7 +140,7 @@ void info_tic(void)
glm_vec3_norm(t[1]);

vec3 rf, recef;
glm_vec3_copy((vec3){r[0], r[1], r[2]}, rf);
glm_vec3_copy((vec3){ r[0], r[1], r[2] }, rf);
glm_mat3_mulv(t, rf, recef);
fmt_coords(buf, 48, recef[0], recef[1], recef[2]);
gtk_label_set_text(info_items[INFO_POSITION_ECEF], buf);
Expand All @@ -151,9 +151,9 @@ void info_tic(void)
float alat = fabsf(lat);
float tmp;
g_snprintf(buf, 48, "%02u\u00B0%02u'%c\n%03u\u00B0%02u'%c\n%011.3f",
(unsigned)alat, (unsigned)(modff(alat, &tmp) * 60.f), ((signbit(lat)) ? 'S' : 'N'),
(unsigned)algt, (unsigned)(modff(algt, &tmp) * 60.f), ((signbit(lgt)) ? 'W' : 'E'),
(double)glm_vec3_norm(recef));
(unsigned)alat, (unsigned)(modff(alat, &tmp) * 60.f), ((signbit(lat)) ? 'S' : 'N'),
(unsigned)algt, (unsigned)(modff(algt, &tmp) * 60.f), ((signbit(lgt)) ? 'W' : 'E'),
(double)glm_vec3_norm(recef));
gtk_label_set_text(info_items[INFO_POSITION_LLH], buf);
}
}
2 changes: 1 addition & 1 deletion src/ui/info.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __INFO_H__
#define __INFO_H__

#include "ui.h"
#include "satellite.h"
#include "ui.h"

void info_init(GtkBuilder *builder);

Expand Down
6 changes: 3 additions & 3 deletions src/ui/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ gboolean on_glarea_motion_notify_event(GtkWidget *widget, GdkEvent *event, gpoin
(void)user_data;
GdkEventMotion *motion = &event->motion;
if (cursor_pressed) {
float d_ang_x = (2.f * PI / e_gl_ctx.res_x);
float d_ang_y = (PI / e_gl_ctx.res_y);
float d_ang_x = (2.f * (float)G_PI / e_gl_ctx.res_x);
float d_ang_y = ((float)G_PI / e_gl_ctx.res_y);
float ang_x = (float)(cursor_xpos - motion->x) * d_ang_x;
float ang_y = (float)(cursor_ypos - motion->y) * d_ang_y;

vec3 view_dir;
glm_vec3_sub(e_camera.target, e_camera.pos, view_dir);
glm_vec3_normalize(view_dir);
float cam_ang = acosf(glm_vec3_dot(view_dir, e_camera.up));
ang_y = glm_clamp(1e-2f, cam_ang + ang_y, PI - 1e-2f) - cam_ang;
ang_y = glm_clamp(1e-2f, cam_ang + ang_y, (float)G_PI - 1e-2f) - cam_ang;

vec3 right;
glm_vec3_cross(e_camera.up, view_dir, right);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "entity.h"
#include "error.h"
#include "gfx.h"
#include "info.h"
#include "input.h"
#include "render.h"
#include "setting.h"
#include "status.h"
#include "system.h"
#include "thread.h"
#include "timemgr.h"
#include "info.h"

const gchar *FILENAME_GUI = "res/ui/ui.glade";

Expand Down
4 changes: 2 additions & 2 deletions src/util/icosphere.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ void icosphere_generate(const unsigned n_sub, vec3 **verts, guint32 **faces, vec
/* Generate UVs */
for (i = 0; i < *n_verts; i++) {
glm_vec2_copy((vec2){
(atan2f((*verts)[i][1], (*verts)[i][0]) + PI) * (1.f / (2.f * PI)),
acosf(-((*verts)[i][2])) * (1.f / PI) },
(atan2f((*verts)[i][1], (*verts)[i][0]) + (float)G_PI) * (1.f / (2.f * (float)G_PI)),
acosf(-((*verts)[i][2])) * (1.f / (float)G_PI) },
(*uv)[i]);
}

Expand Down

0 comments on commit 19dfab3

Please sign in to comment.