83 bool force_single_slot =
false;
88 collision_owner = actor;
93 force_single_slot =
true;
99 uint32_t remaining = (uint32_t)slot_count;
110 if (!force_single_slot && other_actor)
112 if (other_is_projectile && reference)
119 retained_target_definition =
131 int32_t
x = test_pos->
x;
132 int32_t target_delta_x;
133 int32_t target_delta_y;
134 int32_t target_delta_z;
136 if (position_source_actor)
138 target_delta_x =
x - position_source_actor->
position.
x;
139 target_delta_y = test_pos->
y - position_source_actor->
position.
y;
140 target_delta_z = test_pos->
z - position_source_actor->
position.
z;
154 uint64_t distance_squared = (uint64_t)((int64_t)target_delta_x * target_delta_x) +
155 (uint64_t)((int64_t)target_delta_y * target_delta_y) +
156 (uint64_t)((int64_t)target_delta_z * target_delta_z);
157 int32_t target_distance_squared = (uint32_t)(distance_squared >>
MATH_Q12_SHIFT);
158 uint64_t range_squared = (uint64_t)((int64_t)range * range);
160 if ((uint32_t)target_distance_squared < (uint32_t)(range_squared >>
MATH_Q12_SHIFT))
164 int32_t horizontal_cone_width;
165 int32_t vertical_cone_width;
167 if (!homing_turn_step_angle12)
170 int32_t turn_magnitude = turn_step;
172 vertical_cone_width = turn_magnitude;
174 if ((int16_t)turn_magnitude < 0)
176 turn_magnitude = -(turn_magnitude);
177 vertical_cone_width = turn_magnitude;
181 horizontal_cone_width = homing_turn_step_angle12;
199 if (attachment_joint_index)
207 uint16_t joint_horizontal_width = attachment_joint->
angle_param[0];
209 horizontal_cone_width = joint_horizontal_width ? horizontal_cone_width + joint_horizontal_width :
MATH_ANGLE_FULL_TURN;
211 uint16_t joint_vertical_width = attachment_joint->
angle_param[1];
213 vertical_cone_width = joint_vertical_width ? vertical_cone_width + joint_vertical_width :
MATH_ANGLE_FULL_TURN;
215 uint16_t joint_yaw = attachment_joint->
angle_param[2];
216 uint16_t joint_pitch = attachment_joint->
angle_param[3];
218 yaw_angle += joint_yaw;
219 pitch_angle += joint_pitch;
227 int64_t local_x_product = (int64_t)out_matrix.
m00 * target_delta_x +
228 (int64_t)out_matrix.
m10 * target_delta_y + (int64_t)out_matrix.
m20 * target_delta_z;
229 int32_t local_delta_x = (int32_t)(local_x_product >>
MATH_Q12_SHIFT);
230 int64_t local_y_product = (int64_t)out_matrix.
m01 * target_delta_x +
231 (int64_t)out_matrix.
m11 * target_delta_y + (int64_t)out_matrix.
m21 * target_delta_z;
232 int32_t local_delta_y = (int32_t)(local_y_product >>
MATH_Q12_SHIFT);
233 int64_t local_z_product = (int64_t)out_matrix.
m02 * target_delta_x +
234 (int64_t)out_matrix.
m12 * target_delta_y + (int64_t)out_matrix.
m22 * target_delta_z;
235 int32_t local_delta_z = (int32_t)(local_z_product >>
MATH_Q12_SHIFT);
236 int32_t target_half_radius_q12;
239 target_half_radius_q12 = 0;
241 target_half_radius_q12 = (int32_t)other_actor->
cull_radius << 6 >> 1;
243 int32_t horizontal_half_angle = (uint16_t)horizontal_cone_width >> 1;
247 int64_t narrow_yaw_center_x_product = (int64_t)(
Math_SinQ14(yaw_angle) >> 2) * local_delta_x;
249 int32_t horizontal_radius_lower_bound = -(target_half_radius_q12);
251 if (!(((int32_t)(narrow_yaw_center_z_product >>
MATH_Q12_SHIFT)) + ((int32_t)(narrow_yaw_center_x_product >>
MATH_Q12_SHIFT)) >= horizontal_radius_lower_bound))
257 if (!(((int32_t)(narrow_yaw_upper_z_product >>
MATH_Q12_SHIFT)) + ((int32_t)(narrow_yaw_upper_x_product >>
MATH_Q12_SHIFT)) >= horizontal_radius_lower_bound))
261 int64_t narrow_yaw_lower_z_product = (int64_t)(
Math_SinQ14(horizontal_half_angle - yaw_angle) >> 2) * local_delta_z;
263 if (!(((int32_t)(narrow_yaw_lower_z_product >>
MATH_Q12_SHIFT)) + ((int32_t)(narrow_yaw_lower_x_product >>
MATH_Q12_SHIFT)) >= horizontal_radius_lower_bound))
268 int64_t wide_yaw_center_x_product = (int64_t)(
Math_SinQ14(yaw_angle) >> 2) * local_delta_x;
271 if (!(((int32_t)(wide_yaw_center_z_product >>
MATH_Q12_SHIFT)) + ((int32_t)(wide_yaw_center_x_product >>
MATH_Q12_SHIFT)) >= -(target_half_radius_q12)))
273 int32_t horizontal_upper_boundary_angle = yaw_angle + horizontal_half_angle;
275 int64_t wide_yaw_upper_z_product = (int64_t)(
Math_SinQ14(-((int32_t)horizontal_upper_boundary_angle)) >> 2) * local_delta_z;
277 if (!(((int32_t)(wide_yaw_upper_z_product >>
MATH_Q12_SHIFT)) + ((int32_t)(wide_yaw_upper_x_product >>
MATH_Q12_SHIFT)) <= target_half_radius_q12))
282 if (!(((int32_t)(wide_yaw_lower_z_product >>
MATH_Q12_SHIFT)) + ((int32_t)(wide_yaw_lower_x_product >>
MATH_Q12_SHIFT)) <= target_half_radius_q12))
288 int32_t target_distance =
Math_SqrtFP12(target_distance_squared);
290 int32_t pitch_projected_distance = (int32_t)(pitch_distance_projection_product >>
MATH_Q12_SHIFT);
291 int32_t vertical_half_angle = (uint16_t)vertical_cone_width >> 1;
295 int64_t narrow_pitch_center_y_product = (int64_t)(
Math_SinQ14(pitch_angle) >> 2) * local_delta_y;
297 int32_t vertical_radius_lower_bound = -(target_half_radius_q12);
299 if (!(((int32_t)(narrow_pitch_center_distance_product >>
MATH_Q12_SHIFT)) + ((int32_t)(narrow_pitch_center_y_product >>
MATH_Q12_SHIFT)) >= vertical_radius_lower_bound))
303 int64_t narrow_pitch_upper_distance_product = (int64_t)(
Math_SinQ14(
MATH_ANGLE_HALF_TURN - vertical_half_angle - pitch_angle) >> 2) * pitch_projected_distance;
305 if (!(((int32_t)(narrow_pitch_upper_distance_product >>
MATH_Q12_SHIFT)) + ((int32_t)(narrow_pitch_upper_y_product >>
MATH_Q12_SHIFT)) >= vertical_radius_lower_bound))
309 int64_t narrow_pitch_lower_distance_product = (int64_t)(
Math_SinQ14(vertical_half_angle - pitch_angle) >> 2) * pitch_projected_distance;
311 if (!(((int32_t)(narrow_pitch_lower_distance_product >>
MATH_Q12_SHIFT)) + ((int32_t)(narrow_pitch_lower_y_product >>
MATH_Q12_SHIFT)) >= vertical_radius_lower_bound))
316 int64_t wide_pitch_center_y_product = (int64_t)(
Math_SinQ14(pitch_angle) >> 2) * local_delta_y;
319 if (!(((int32_t)(wide_pitch_center_distance_product >>
MATH_Q12_SHIFT)) + ((int32_t)(wide_pitch_center_y_product >>
MATH_Q12_SHIFT)) >= -(target_half_radius_q12)))
321 int32_t vertical_upper_boundary_angle = vertical_half_angle + pitch_angle;
323 int64_t wide_pitch_upper_distance_product = (int64_t)(
Math_SinQ14(-(vertical_upper_boundary_angle)) >> 2) * pitch_projected_distance;
325 if (!(((int32_t)(wide_pitch_upper_distance_product >>
MATH_Q12_SHIFT)) + ((int32_t)(wide_pitch_upper_y_product >>
MATH_Q12_SHIFT)) <= target_half_radius_q12))
328 int64_t wide_pitch_lower_distance_product = (int64_t)(
Math_SinQ14(vertical_half_angle - pitch_angle +
MATH_ANGLE_HALF_TURN) >> 2) * pitch_projected_distance;
330 if (!(((int32_t)(wide_pitch_lower_distance_product >>
MATH_Q12_SHIFT)) + ((int32_t)(wide_pitch_lower_y_product >>
MATH_Q12_SHIFT)) <= target_half_radius_q12))
347 }
while (--remaining);