draw bullet circle in tracer
This commit is contained in:
parent
e961b6dceb
commit
33ad436040
@ -108,7 +108,6 @@ struct entity {
|
||||
struct collider_shape local_collider;
|
||||
|
||||
#if COLLIDER_DEBUG
|
||||
i32 colliding;
|
||||
struct phys_collision_debug collision_debug_data;
|
||||
#endif
|
||||
|
||||
|
||||
22
src/game.c
22
src/game.c
@ -345,8 +345,15 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, array)
|
||||
if (entity_is_valid_and_active(e0) && entity_is_valid_and_active(e1)) {
|
||||
/* Bullet hit entity */
|
||||
if (entity_has_prop(e0, ENTITY_PROP_BULLET) || entity_has_prop(e1, ENTITY_PROP_BULLET)) {
|
||||
struct entity *bullet = entity_has_prop(e0, ENTITY_PROP_BULLET) ? e0 : e1;
|
||||
struct entity *target = e0 == bullet ? e1 : e0;
|
||||
struct v2 normal = data->normal;
|
||||
struct entity *target = e0;
|
||||
struct entity *bullet = e1;
|
||||
if (entity_has_prop(e0, ENTITY_PROP_BULLET)) {
|
||||
target = e1;
|
||||
bullet = e0;
|
||||
normal = v2_neg(normal);
|
||||
}
|
||||
|
||||
struct entity *src = entity_from_handle(store, bullet->bullet_src);
|
||||
(UNUSED)bullet;
|
||||
(UNUSED)target;
|
||||
@ -359,7 +366,6 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, array)
|
||||
constraint->skip_solve = true;
|
||||
} else {
|
||||
struct v2 point = data->point;
|
||||
struct v2 normal = data->normal;
|
||||
|
||||
/* Update bullet */
|
||||
bullet->bullet_has_hit = true;
|
||||
@ -814,11 +820,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
|
||||
bullet->bullet_src = ent->handle;
|
||||
bullet->bullet_src_pos = rel_pos;
|
||||
bullet->bullet_src_dir = rel_dir;
|
||||
//bullet->bullet_impulse = 0.1f;
|
||||
//bullet->bullet_impulse = 0.25f;
|
||||
bullet->bullet_impulse = 0.5f;
|
||||
//bullet->bullet_impulse = 1.0f;
|
||||
//bullet->bullet_impulse = 5.f;
|
||||
bullet->bullet_impulse = 0.75f;
|
||||
bullet->mass_unscaled = 0.04f;
|
||||
bullet->inertia_unscaled = 0.00001f;
|
||||
|
||||
@ -833,9 +835,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
|
||||
/* Spawn tracer */
|
||||
{
|
||||
struct entity *tracer = entity_alloc(root);
|
||||
//tracer->tracer_fade_duration = 0.075f;
|
||||
//tracer->tracer_fade_duration = 0.025f;
|
||||
tracer->tracer_fade_duration = 0.01f;
|
||||
tracer->tracer_fade_duration = 0.025f;
|
||||
entity_enable_prop(tracer, ENTITY_PROP_TRACER);
|
||||
|
||||
bullet->bullet_tracer = tracer->handle;
|
||||
|
||||
@ -400,13 +400,6 @@ void phys_prepare_contacts(struct phys_ctx *ctx)
|
||||
struct entity_lookup_key key = entity_lookup_key_from_two_handles(dbg->e0, dbg->e1);
|
||||
struct entity_lookup_entry *entry = entity_lookup_get(debug_lookup, key);
|
||||
|
||||
if (e0->valid) {
|
||||
--e0->colliding;
|
||||
}
|
||||
if (e1->valid) {
|
||||
--e1->colliding;
|
||||
}
|
||||
|
||||
if (entry) {
|
||||
entity_lookup_remove(debug_lookup, entry);
|
||||
} else {
|
||||
|
||||
@ -13,9 +13,9 @@ struct phys_collision_data {
|
||||
struct entity_handle e0;
|
||||
struct entity_handle e1;
|
||||
struct v2 point;
|
||||
struct v2 normal;
|
||||
struct v2 vrel; /* Relative velocity */
|
||||
f32 dt; /* How much time elapsed in the step when this event occurred (this will equal the physics timestep unless an early time of impact collision occurred) */
|
||||
struct v2 normal; /* Normal of the collision from e0 to e1 */
|
||||
struct v2 vrel; /* Relative velocity at point of collision */
|
||||
f32 dt; /* How much time elapsed in the step when this event occurred (this will equal the physics timestep unless an early time of impact occurred) */
|
||||
};
|
||||
|
||||
struct phys_collision_data_array {
|
||||
|
||||
19
src/user.c
19
src/user.c
@ -934,11 +934,15 @@ INTERNAL void user_update(void)
|
||||
|
||||
f32 opacity_b = clamp_f32(1.f - (v2_dot(vdc, vdb) / v2_len_sq(vdc)), 0, 1);
|
||||
|
||||
//f32 thickness = 0.0025;
|
||||
f32 thickness = 0.005;
|
||||
u32 color_start = RGBA_32_F(1, 1, 1, opacity_a);
|
||||
u32 color_end = RGBA_32_F(1, 1, 1, opacity_b);
|
||||
f32 thickness = 0.01;
|
||||
u32 color_start = RGBA_32_F(1, 0.5, 0, opacity_a);
|
||||
u32 color_end = RGBA_32_F(1, 0.8, 0.4, opacity_b);
|
||||
|
||||
if (opacity_b > 0.99f) {
|
||||
draw_solid_circle(G.world_canvas, b, thickness / 2, color_end, 20);
|
||||
}
|
||||
draw_gradient_line(G.world_canvas, a, b, thickness, color_start, color_end);
|
||||
|
||||
}
|
||||
|
||||
/* Draw sprite */
|
||||
@ -1070,12 +1074,7 @@ INTERNAL void user_update(void)
|
||||
/* Draw collider */
|
||||
if (entity_has_prop(ent, ENTITY_PROP_PHYSICAL_DYNAMIC)) {
|
||||
struct collider_shape collider = ent->local_collider;
|
||||
u32 color = RGBA_32_F(1, 1, 0, 0.25);
|
||||
#if COLLIDER_DEBUG
|
||||
if (ent->colliding > 0) {
|
||||
color = RGBA_32_F(1, 1, 1, 0.5);
|
||||
}
|
||||
#endif
|
||||
u32 color = RGBA_32_F(1, 0, 1, 0.25);
|
||||
f32 thickness = 2;
|
||||
{
|
||||
/* Draw collider using support points */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user