Skip to content

Commit 6b19fe5

Browse files
committed
Revert to flooring coordinates instead of rounding; Newline formatting
1 parent 1155c97 commit 6b19fe5

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/draw/engine_display_draw.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void engine_draw_blit(texture_resource_class_obj_t *texture, uint32_t offset, fl
108108
// ENGINE_PERFORMANCE_CYCLES_START();
109109
float inverse_x_scale = 1.0f / x_scale;
110110
float inverse_y_scale = 1.0f / y_scale;
111-
111+
112112
// https://codereview.stackexchange.com/a/86546
113113
float sin_angle = sinf(rotation_radians);
114114
float cos_angle = cosf(rotation_radians);
@@ -131,8 +131,8 @@ void engine_draw_blit(texture_resource_class_obj_t *texture, uint32_t offset, fl
131131
float dim_half = (dim / 2.0f);
132132

133133
// The top-left of the bitmap destination
134-
int32_t top_left_x = (int32_t)roundf(center_x - dim_half);
135-
int32_t top_left_y = (int32_t)roundf(center_y - dim_half);
134+
int32_t top_left_x = (int32_t)floorf(center_x - dim_half);
135+
int32_t top_left_y = (int32_t)floorf(center_y - dim_half);
136136

137137
// If the top-left is above the viewport but
138138
// the bitmap may eventually showup, clip the
@@ -157,7 +157,7 @@ void engine_draw_blit(texture_resource_class_obj_t *texture, uint32_t offset, fl
157157
uint32_t dest_offset = center_pixel_offset;
158158

159159
// The stride to the next row usually consists of just the
160-
// screen width, however, subtract the dimensions of the
160+
// screen width, however, subtract the dimensions of the
161161
// destination rect so that we end up at the next row
162162
// in the rect. Also proceed forward on the next row
163163
// by the amount we are left clipping the dest rect
@@ -257,7 +257,7 @@ void engine_draw_blit_depth(texture_resource_class_obj_t *texture, uint32_t offs
257257
// ENGINE_PERFORMANCE_CYCLES_START();
258258
float inverse_x_scale = 1.0f / x_scale;
259259
float inverse_y_scale = 1.0f / y_scale;
260-
260+
261261
// https://codereview.stackexchange.com/a/86546
262262
float sin_angle = sinf(rotation_radians);
263263
float cos_angle = cosf(rotation_radians);
@@ -306,7 +306,7 @@ void engine_draw_blit_depth(texture_resource_class_obj_t *texture, uint32_t offs
306306
uint32_t dest_offset = center_pixel_offset;
307307

308308
// The stride to the next row usually consists of just the
309-
// screen width, however, subtract the dimensions of the
309+
// screen width, however, subtract the dimensions of the
310310
// destination rect so that we end up at the next row
311311
// in the rect. Also proceed forward on the next row
312312
// by the amount we are left clipping the dest rect
@@ -407,7 +407,7 @@ void engine_draw_rect(uint16_t color, float center_x, float center_y, int32_t wi
407407
// ENGINE_PERFORMANCE_CYCLES_START();
408408
float inverse_x_scale = 1.0f / x_scale;
409409
float inverse_y_scale = 1.0f / y_scale;
410-
410+
411411
// https://codereview.stackexchange.com/a/86546
412412
float sin_angle = sinf(rotation_radians);
413413
float cos_angle = cosf(rotation_radians);
@@ -456,7 +456,7 @@ void engine_draw_rect(uint16_t color, float center_x, float center_y, int32_t wi
456456
uint32_t dest_offset = center_pixel_offset;
457457

458458
// The stride to the next row usually consists of just the
459-
// screen width, however, subtract the dimensions of the
459+
// screen width, however, subtract the dimensions of the
460460
// destination rect so that we end up at the next row
461461
// in the rect. Also proceed forward on the next row
462462
// by the amount we are left clipping the dest rect
@@ -532,7 +532,7 @@ void engine_draw_outline_circle(uint16_t color, float center_x, float center_y,
532532
for(float angle = 0; angle <= 90; angle += angle_increment){
533533
float cx = distance * cosf(angle);
534534
float cy = distance * sinf(angle);
535-
535+
536536
// Bottom right quadrant of the circle
537537
int brx = (int)(center_x+cx);
538538
int bry = (int)(center_y+cy);
@@ -575,7 +575,7 @@ void engine_draw_filled_circle(uint16_t color, float center_x, float center_y, f
575575
}
576576

577577

578-
void engine_draw_text(font_resource_class_obj_t *font, mp_obj_t text, float center_x, float center_y, float text_box_width, float text_box_height, float letter_spacing, float line_spacing, float x_scale, float y_scale, float rotation_radians, float alpha, engine_shader_t *shader){
578+
void engine_draw_text(font_resource_class_obj_t *font, mp_obj_t text, float center_x, float center_y, float text_box_width, float text_box_height, float letter_spacing, float line_spacing, float x_scale, float y_scale, float rotation_radians, float alpha, engine_shader_t *shader){
579579
float sin_angle = sinf(rotation_radians);
580580
float cos_angle = cosf(rotation_radians);
581581

@@ -791,7 +791,7 @@ void engine_draw_filled_triangle_depth(texture_resource_class_obj_t *texture, ui
791791
// https://fgiesen.wordpress.com/2013/02/10/optimizing-the-basic-rasterizer/#:~:text=In%20our%20basic%20triangle%20rasterization%20loop
792792
float dy_bc = (float)(by - cy) / ABC;
793793
float dx_bc = (float)(cx - bx) / ABC;
794-
794+
795795
float dy_ca = (float)(cy - ay) / ABC;
796796
float dx_ca = (float)(ax - cx) / ABC;
797797

src/physics/engine_physics_collision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void engine_physics_rect_circle_get_contact(physics_contact_t *contact, float ci
322322
float a_edge_v1_y = 0.0f;
323323

324324
engine_physics_rect_rect_get_contacting(abs_rect->abs_x, abs_rect->abs_y, -contact->collision_normal_x, -contact->collision_normal_y, &a_max_proj_vertex_x, &a_max_proj_vertex_y, &a_edge_v0_x, &a_edge_v0_y, &a_edge_v1_x, &a_edge_v1_y, abs_rect->vertices_x, abs_rect->vertices_y);
325-
325+
326326
float circle_radius = mp_obj_get_float(physics_circle->radius);
327327

328328
float circle_pos_proj = engine_math_dot_product(abs_circle->abs_x, abs_circle->abs_y, contact->collision_normal_y, -contact->collision_normal_x);
@@ -415,7 +415,7 @@ bool engine_physics_check_rect_circle_collision(physics_abs_rectangle_t *abs_rec
415415
for(uint8_t ivx=0; ivx<4; ivx++){
416416
float vert_x = abs_rect->abs_x + abs_rect->vertices_x[ivx];
417417
float vert_y = abs_rect->abs_y + abs_rect->vertices_y[ivx];
418-
418+
419419
// Get the position difference between rect vertex and circle
420420
// (rect vertices are rotated when the rect's rotation changes)
421421
float delta_x = vert_x - abs_rect->abs_x;

0 commit comments

Comments
 (0)