From 498a30d1beeed7c9858f513ee2c82b612a1746d4 Mon Sep 17 00:00:00 2001 From: BMagnu <6238428+BMagnu@users.noreply.github.com> Date: Tue, 16 Sep 2025 10:09:00 +0900 Subject: [PATCH 1/3] Pass out normals for edge hits --- code/model/modelcollide.cpp | 1 + code/weapon/beam.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/code/model/modelcollide.cpp b/code/model/modelcollide.cpp index ad7dfed84f3..c6fe18afa20 100644 --- a/code/model/modelcollide.cpp +++ b/code/model/modelcollide.cpp @@ -323,6 +323,7 @@ static void mc_check_sphereline_face( int nv, vec3d ** verts, vec3d * plane_pnt, // This is closer than best so far Mc->hit_dist = sphere_time; Mc->hit_point = hit_point; + Mc->hit_normal = *plane_norm; Mc->hit_submodel = Mc_submodel; Mc->edge_hit = true; diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index f2e05b477cf..e2c5a83f67e 100644 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -3964,7 +3964,7 @@ void beam_handle_collisions(beam *b) particleSource->setHost(beam_hit_make_effect_host(b, &Objects[target], b->f_collisions[idx].cinfo.hit_submodel, &b->f_collisions[idx].cinfo.hit_point_world, &b->f_collisions[idx].cinfo.hit_point)); // TODO: Commenting out until the collision code can be enhanced to return a valid normal when a beam collides with an edge. // (This can happen when a slash beam moves off the edge of a model; edge_hit will be true and hit_normal will be 0,0,0.) -// particleSource->setNormal(worldNormal); + particleSource->setNormal(worldNormal); particleSource->setTriggerRadius(width); particleSource->finishCreation(); } @@ -3973,7 +3973,7 @@ void beam_handle_collisions(beam *b) auto particleSource = particle::ParticleManager::get()->createSource(wi->impact_weapon_expl_effect); particleSource->setHost(beam_hit_make_effect_host(b, &Objects[target], b->f_collisions[idx].cinfo.hit_submodel, &b->f_collisions[idx].cinfo.hit_point_world, &b->f_collisions[idx].cinfo.hit_point)); // TODO: see comment above -// particleSource->setNormal(worldNormal); + particleSource->setNormal(worldNormal); particleSource->setTriggerRadius(width); particleSource->finishCreation(); } From 9ce0458430d85532cd6eafa91e071309d401efd1 Mon Sep 17 00:00:00 2001 From: BMagnu <6238428+BMagnu@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:58:28 +0900 Subject: [PATCH 2/3] Remove now-obsolete comments --- code/weapon/beam.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index e2c5a83f67e..4b488ff7132 100644 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -3962,8 +3962,6 @@ void beam_handle_collisions(beam *b) if (wi->flash_impact_weapon_expl_effect.isValid()) { auto particleSource = particle::ParticleManager::get()->createSource(wi->flash_impact_weapon_expl_effect); particleSource->setHost(beam_hit_make_effect_host(b, &Objects[target], b->f_collisions[idx].cinfo.hit_submodel, &b->f_collisions[idx].cinfo.hit_point_world, &b->f_collisions[idx].cinfo.hit_point)); -// TODO: Commenting out until the collision code can be enhanced to return a valid normal when a beam collides with an edge. -// (This can happen when a slash beam moves off the edge of a model; edge_hit will be true and hit_normal will be 0,0,0.) particleSource->setNormal(worldNormal); particleSource->setTriggerRadius(width); particleSource->finishCreation(); @@ -3972,7 +3970,6 @@ void beam_handle_collisions(beam *b) if(do_expl){ auto particleSource = particle::ParticleManager::get()->createSource(wi->impact_weapon_expl_effect); particleSource->setHost(beam_hit_make_effect_host(b, &Objects[target], b->f_collisions[idx].cinfo.hit_submodel, &b->f_collisions[idx].cinfo.hit_point_world, &b->f_collisions[idx].cinfo.hit_point)); -// TODO: see comment above particleSource->setNormal(worldNormal); particleSource->setTriggerRadius(width); particleSource->finishCreation(); From 7a00485c5273c97fc5f35493e5c8161a0b0f1c79 Mon Sep 17 00:00:00 2001 From: BMagnu <6238428+BMagnu@users.noreply.github.com> Date: Tue, 16 Sep 2025 13:07:09 +0900 Subject: [PATCH 3/3] Also add third instance of disabled particle normal --- code/weapon/beam.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index 4b488ff7132..4a0a25e13f6 100644 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -4026,8 +4026,7 @@ void beam_handle_collisions(beam *b) auto particleSource = particle::ParticleManager::get()->createSource(wi->piercing_impact_effect); particleSource->setHost(beam_hit_make_effect_host(b, &Objects[target], b->f_collisions[idx].cinfo.hit_submodel, &b->f_collisions[idx].cinfo.hit_point_world, &b->f_collisions[idx].cinfo.hit_point)); -// TODO: see comment above -// particleSource->setNormal(worldNormal); + particleSource->setNormal(worldNormal); particleSource->setTriggerRadius(width); particleSource->finishCreation(); }