collision: draw collision polyline in 2d

This commit is contained in:
Zack Buhman 2025-04-19 23:14:19 -05:00
parent 5f2e7e440a
commit 54751fe2e4

View File

@ -822,23 +822,20 @@ void render_collision(ta_parameter_writer& writer, const mat4x4& model_trans, co
vec3 a = trans * model->position[line->a]; vec3 a = trans * model->position[line->a];
vec3 b = trans * model->position[line->b]; vec3 b = trans * model->position[line->b];
if (a.z < 0 || b.z < 0)
continue;
render_line(writer, render_line(writer,
screen_transform(a), screen_transform((vec3){a.x, a.z, 4.f}),
screen_transform(b), screen_transform((vec3){b.x, b.z, 4.f}),
collided[i] ? 0xffff0000 : base_color); collided[i] ? 0xffff0000 : base_color);
} }
vec3 a = {last_dx * -2, last_dy * 2, 1}; vec3 a = {last_dx * -4, last_dy * -4, 4};
vec3 b = {0, 0, 1}; vec3 b = {last_dx * 0.5f, last_dy * 0.5f, 4};
if (a.z > 0) { //if (a.z > 0) {
render_line(writer, render_line(writer,
screen_transform(a), screen_transform(a),
screen_transform(b), screen_transform(b),
0xff00ff00); 0xff00ff00);
} //}
} }
void transfer_scene(ta_parameter_writer& writer, const mat4x4& mansion_model_trans, const mat4x4& screen, const mat4x4& cone_model) void transfer_scene(ta_parameter_writer& writer, const mat4x4& mansion_model_trans, const mat4x4& screen, const mat4x4& cone_model)
@ -995,8 +992,9 @@ constexpr inline mat4x4 update_analog(const mat4x4& model_trans, const mat4x4& s
last_dx = x; last_dx = x;
last_dy = y; last_dy = y;
vec3 a = {last_dx * -2, 0.f, last_dy * 2}; vec3 a = {last_dx * -4, 0.f, last_dy * -4};
vec3 b = {0, 0.f, 1.f}; //vec3 b = {0, 0.f, 0.f};
vec3 b = {last_dx * 0.5f, 0.f, last_dy * 0.5f};
if (line_has_collision(a, b, model_trans, screen)) { if (line_has_collision(a, b, model_trans, screen)) {
x = 0; x = 0;