View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003156 | FSSCP | beams | public | 2015-04-06 17:44 | 2015-04-17 13:00 |
Reporter | MatthTheGeek | Assigned To | m_m | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.7.2 RC4 | ||||
Target Version | 3.7.2 | ||||
Summary | 0003156: Fighter beam range depends on target radius | ||||
Description | When +Range is defined in the $BeamInfo parameters of a fighter beam, the actual effective range of the beam ingame seems to vary based on the radius of the target. In the test mod attached, a fighter beam with a +Range of 1000 is unable to hit an Orion 1.7km away, but can hit a Colossus 3.3km away. | ||||
Tags | No tags attached. | ||||
|
|
|
The current collision code doesn't check if a detected collision is actually in range of the beam as the collision code will return every collision it can find. I added a condition for beams where +Range is less than the far distance which checks the shield and hull collisions and invalidates them if the actual hit position is out of reach for the beam. |
|
beam.cpp.patch (1,535 bytes)
Index: code/weapon/beam.cpp =================================================================== --- code/weapon/beam.cpp (revision 11304) +++ code/weapon/beam.cpp (working copy) @@ -2338,6 +2338,30 @@ int hull_enter_collision = model_collide(&mc_hull_enter); int hull_exit_collision = (beam_will_tool_target(b, ship_objp)) ? model_collide(&mc_hull_exit) : 0; + // If we have a range less than the "far" range, check if the ray actually hit within the range + if (b->range < BEAM_FAR_LENGTH + && (shield_collision || hull_enter_collision || hull_exit_collision)) + { + // We can't use hit_dist as "1" is the distance between p0 and p1 + float rangeSq = b->range * b->range; + + // actually make sure that the collision points are within range of our beam + if (shield_collision && vm_vec_dist_squared(&b->last_start, &mc_shield.hit_point_world) > rangeSq) + { + shield_collision = 0; + } + + if (hull_enter_collision && vm_vec_dist_squared(&b->last_start, &mc_hull_enter.hit_point_world) > rangeSq) + { + hull_enter_collision = 0; + } + + if (hull_exit_collision && vm_vec_dist_squared(&mc_hull_exit.hit_point_world, &b->last_start) > rangeSq) + { + hull_exit_collision = 0; + } + } + // check shields for impact // (tooled ships are probably not going to be maintaining a shield over their exit hole, // therefore we need only check the entrance, just as with conventional weapons) |
|
Fix committed to trunk@11307. |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-04-06 17:44 | MatthTheGeek | New Issue | |
2015-04-06 17:44 | MatthTheGeek | File Added: fighterbeamtest.rar | |
2015-04-06 19:53 | m_m | Note Added: 0016600 | |
2015-04-06 19:53 | m_m | Assigned To | => m_m |
2015-04-06 19:53 | m_m | Status | new => code review |
2015-04-06 19:53 | m_m | File Added: beam.cpp.patch | |
2015-04-17 07:44 | m_m | File Deleted: beam.cpp.patch | |
2015-04-17 07:44 | m_m | File Added: beam.cpp.patch | |
2015-04-17 07:46 | m_m | Target Version | => 3.7.2 |
2015-04-17 13:00 | m_m | Changeset attached | => fs2open trunk r11307 |
2015-04-17 13:00 | m_m | Note Added: 0016644 | |
2015-04-17 13:00 | m_m | Status | code review => resolved |
2015-04-17 13:00 | m_m | Resolution | open => fixed |