draw debug lines on screen canvas

This commit is contained in:
jacob 2024-03-13 23:17:07 -05:00
parent e91a66f5b3
commit 808e106f78

View File

@ -348,39 +348,39 @@ INTERNAL struct v2 view_inverse_xform_basis_v2(struct view view, struct v2 p)
/* TODO: remove this (testing) */ /* TODO: remove this (testing) */
INTERNAL void debug_draw_xform(struct xform xf) INTERNAL void debug_draw_xform(struct xform xf)
{ {
f32 thickness = 2.f / PIXELS_PER_UNIT / L.world_view.zoom; f32 thickness = 2.f;
f32 arrowhead_len = 15.f / PIXELS_PER_UNIT / L.world_view.zoom; f32 arrowhead_len = 15.f;
u32 color = RGBA_F(0, 1, 1, 0.3); u32 color = RGBA_F(0, 1, 1, 0.3);
u32 color_x = RGBA_F(1, 0, 0, 0.3); u32 color_x = RGBA_F(1, 0, 0, 0.3);
u32 color_y = RGBA_F(0, 1, 0, 0.3); u32 color_y = RGBA_F(0, 1, 0, 0.3);
struct v2 pos = xf.og; struct v2 pos = view_xform_v2(L.world_view, xf.og);
struct v2 x_ray = xform_get_right(xf); struct v2 x_ray = view_xform_basis_v2(L.world_view, xform_get_right(xf));
struct v2 y_ray = xform_get_up(xf); struct v2 y_ray = view_xform_basis_v2(L.world_view, xform_get_up(xf));
struct quad quad = quad_from_rect(RECT(0, 0, 1, -1)); struct quad quad = quad_from_rect(RECT(0, 0, 1, -1));
quad = quad_mul_xform(quad_scale(quad, 0.075), xf); quad = quad_mul_xform(quad_scale(quad, 0.075), xf);
draw_solid_arrow_ray(L.world_canvas, pos, x_ray, thickness, arrowhead_len, color_x); draw_solid_arrow_ray(L.screen_canvas, pos, x_ray, thickness, arrowhead_len, color_x);
draw_solid_arrow_ray(L.world_canvas, pos, y_ray, thickness, arrowhead_len, color_y); draw_solid_arrow_ray(L.screen_canvas, pos, y_ray, thickness, arrowhead_len, color_y);
draw_solid_quad(L.world_canvas, quad, color); draw_solid_quad(L.screen_canvas, quad, color);
} }
/* TODO: remove this (testing) */ /* TODO: remove this (testing) */
INTERNAL void debug_draw_movement(struct entity *ent) INTERNAL void debug_draw_movement(struct entity *ent)
{ {
f32 thickness = 2.f / PIXELS_PER_UNIT / L.world_view.zoom; f32 thickness = 2.f;
f32 arrow_len = 15.f / PIXELS_PER_UNIT / L.world_view.zoom; f32 arrow_len = 15.f;
u32 color_vel = RGBA_F(1, 0.5, 0, 1); u32 color_vel = RGBA_F(1, 0.5, 0, 1);
u32 color_acc = RGBA_F(1, 1, 0.5, 1); u32 color_acc = RGBA_F(1, 1, 0.5, 1);
struct v2 pos = ent->world_xform.og; struct v2 pos = view_xform_v2(L.world_view, ent->world_xform.og);
struct v2 vel_ray = ent->velocity; struct v2 vel_ray = view_xform_basis_v2(L.world_view, ent->velocity);
struct v2 acc_ray = ent->acceleration; struct v2 acc_ray = view_xform_basis_v2(L.world_view, ent->acceleration);
draw_solid_arrow_ray(L.world_canvas, pos, vel_ray, thickness, arrow_len, color_vel); draw_solid_arrow_ray(L.screen_canvas, pos, vel_ray, thickness, arrow_len, color_vel);
draw_solid_arrow_ray(L.world_canvas, pos, acc_ray, thickness, arrow_len, color_acc); draw_solid_arrow_ray(L.screen_canvas, pos, acc_ray, thickness, arrow_len, color_acc);
} }
INTERNAL void user_update(void) INTERNAL void user_update(void)