def crash_bounds(position_i, size, peak, delta, bounds): is_hit = False crash_time = 0.0 hit_normal = [] dest_point = bounds["position"] dest_size = bounds["size"] for i in range(3): magnitude = delta[int(i)] if (magnitude == 0.0): continue sign = 0.0 if (magnitude > 0.0): sign = 1.0 b_peak = farthest_axis_sign(dest_point, bounds["max"], i, (1.0 - sign)) crash_time = ((b_peak - peak[int(i)]) / magnitude) if ((crash_time >= 0.0) and (crash_time < 1.0)): if (magnitude > 0.0): test = (b_peak + 0.5) else: test = (b_peak - 0.5) test_time = ((test - peak[int(i)]) / magnitude) test_position = sum_arrays(position_i, array_scaled(delta, test_time)) test_max = sum_arrays_3(test_position, size) if is_overlap_cuboids(test_position, size, test_max, dest_point, dest_size, bounds["max"]): crash_time = crash_time is_hit = True hit_normal = vector_axis_sign(i, sign) break return is_hit, crash_time, hit_normal
def touching_two(one_position, one_size, one_max, two): yes = False normals = [] two_bounds = two["world_bounds"] axis, sign = face_overlap(one_position, one_size, one_max, two_bounds["position"], two_bounds["size"], two_bounds["max"]) if (len(two["children"]) > 0.0): if (axis == None): if (is_overlap_cuboids(one_position, one_size, one_max, two_bounds["position"], two_bounds["size"], two_bounds["max"]) == False): return yes, normals for child in two["children"]: child_yes, child_normals = touching_two(one_position, one_size, one_max, child) if child_yes: yes = True normals.extend(child_normals) else: if (axis != None): yes = True normals.append(vector_axis_sign(axis, sign)) return yes, normals