Skip to content

Commit 787c19e

Browse files
authored
Fix laser frustum culling (#6741)
* the naive method * bugfixing * respect radius
1 parent 4bc0a21 commit 787c19e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

code/object/objectsort.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "tracing/tracing.h"
3030
#include "weapon/weapon.h"
3131
#include "decals/decals.h"
32+
#include "freespace.h"
33+
#include "utils/modular_curves.h"
3234

3335
class sorted_obj
3436
{
@@ -142,8 +144,23 @@ int obj_in_view_cone( object * objp )
142144
// Center isn't in... are other points?
143145
ubyte and_codes = 0xff;
144146

147+
float obj_size;
148+
149+
if (objp->type == OBJ_WEAPON && Weapon_info[Weapons[objp->instance].weapon_info_index].render_type == WRT_LASER) {
150+
auto wp = &Weapons[objp->instance];
151+
auto wip = &Weapon_info[wp->weapon_info_index];
152+
float length_scalar = wip->weapon_curves.get_output(weapon_info::WeaponCurveOutputs::LASER_LENGTH_MULT, *wp, &wp->modular_curves_instance);
153+
if (wip->laser_length_by_frametime) {
154+
length_scalar *= flFrametime;
155+
}
156+
float radius_scalar = wip->weapon_curves.get_output(weapon_info::WeaponCurveOutputs::LASER_RADIUS_MULT, *wp, &wp->modular_curves_instance);
157+
obj_size = (wip->laser_length * length_scalar) + (wip->laser_head_radius * radius_scalar);
158+
} else {
159+
obj_size = objp->radius;
160+
}
161+
145162
for (i=0; i<8; i++ ) {
146-
vm_vec_scale_add( &pt, &objp->pos, &check_offsets[i], objp->radius );
163+
vm_vec_scale_add( &pt, &objp->pos, &check_offsets[i], obj_size );
147164
codes=g3_rotate_vector(&tmp,&pt);
148165
if ( !codes ) {
149166
//mprintf(( "A point is inside, so render it.\n" ));

0 commit comments

Comments
 (0)