Conversation
| { | ||
| if (!IS_VEC_NULL(&wp.homing_pos)) { | ||
| target_pos = wp.homing_pos; | ||
| } |
There was a problem hiding this comment.
Not sure how this could happen, but if homing_object is valid but IS_VEC_NULL(&wp.homing_pos) is true, the inner if body is skipped, target_pos is never assigned, and the function eventually hits vm_vec_sub with bad data. Could fix this by adding an else return 0.f, IE
} else {
return 0.f;
}
| return 0.f; | ||
| } | ||
| vec3d dir; | ||
| vm_vec_sub(&dir, &wep_objp->pos, &target_pos); |
There was a problem hiding this comment.
Should dir be normalized? I think vm_vec_dot on an unnormalized `dir gives a distance-scaled projection, which seems like that isn't the intent? Normalizing before the dot would fix this I reckon...IE
vm_vec_normalize(&dir);
return vm_vec_dot(&dir, &wep_objp->orient.vec.fvec);
``
| return 0.f; | ||
| } | ||
| vec3d dir; | ||
| vm_vec_sub(&dir, &wep_objp->pos, &target_pos); |
There was a problem hiding this comment.
PR description says dot product between the vector that points toward the current target and the weapon's forward vector. Just want to check, are these in the right order? I think dir = weapon - target points away from the target not towards it (so switching to target_pos - wep_objp->pos` would face torwards) but perhaps someone with better dot math can chime in. @Baezon perhaps :D
Adds a weapon lifetime input that consists of the dot product between the vector that points toward the current target and the weapon's forward vector.