Skip to content

Commit b1b197c

Browse files
authored
Merge pull request #1440 from ln-zookeeper/asteroid_null_vec_fix
Fix for a null vector normalization
2 parents 637a962 + 941b729 commit b1b197c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

code/asteroid/asteroid.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,12 @@ void asteroid_maybe_break_up(object *pasteroid_obj)
15681568
vec3d tempv = dir_vec;
15691569
vm_vec_random_cone(&dir_vec, &tempv, (360.0f / total_roids / 2));
15701570

1571-
// Make the roid inherit half of the parent's velocity
1572-
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
1571+
// Make the roid inherit half of parent's directional movement
1572+
if (!IS_VEC_NULL(&pasteroid_obj->phys_info.vel)) {
1573+
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
1574+
} else {
1575+
vm_vec_rand_vec_quick(&parent_vel);
1576+
}
15731577
vm_vec_scale(&parent_vel, 0.5f);
15741578

15751579
// Make the hit position affect the direction, but only a little

0 commit comments

Comments
 (0)