22 float near_clip_distance =
27 corner_a.
z = projection_depth_or_focal;
31 corner_b.
z = projection_depth_or_focal;
33 __builtin_memcpy(&
data_19a95ec, &near_clip_distance,
sizeof(
float));
37 float half_width = (float)((
long double)viewport_w * (
long double)0.5f);
40 __builtin_memset(&eye_origin, 0, 0xc);
45 projection_depth_or_focal = (float)((
long double)viewport_h * (
long double)0.5f);
47 long double negative_half_width = -((
long double)half_width);
49 corner_b.
x = (float)negative_half_width;
50 corner_a.
x = (float)negative_half_width;
51 corner_b.
y = projection_depth_or_focal;
54 long double negative_half_height = -((
long double)projection_depth_or_focal);
56 corner_a.
y = (float)negative_half_height;
62 float left_normal_y = out_normal.
y;
63 float left_normal_z = out_normal.
z;
69 corner_b.
x = half_width;
70 corner_b.
y = (float)negative_half_height;
75 float upper_normal_y = out_normal.
y;
76 float upper_normal_z = out_normal.
z;
82 corner_a.
x = half_width;
83 corner_a.
y = projection_depth_or_focal;
87 float right_normal_y = out_normal.
y;
91 float right_normal_z = out_normal.
z;
95 corner_b.
x = (float)negative_half_width;
96 corner_b.
y = projection_depth_or_focal;
100 float lower_normal_y = out_normal.
y;
101 float lower_normal_z = out_normal.
z;
161 frustum_dirs->
v[0].
dir.
x = 0;
162 frustum_dirs->
v[0].
dir.
y = 0;
165 int32_t focal_q6 = focal_distance >> 6;
166 int32_t half_height_q6 = ((int32_t)viewport_size[1] & ~1) * 32;
167 int32_t half_width_q6 = ((int32_t)viewport_size[0] & ~1) * 32;
168 int32_t left_delta_y = -2 * half_height_q6;
169 int32_t top_delta_x = 2 * half_width_q6;
170 int32_t right_delta_y = 2 * half_height_q6;
171 int32_t bottom_delta_x = -2 * half_width_q6;
173 {-(int32_t)(((int64_t)focal_q6 * left_delta_y) >>
MATH_Q12_SHIFT), 0,
174 (int32_t)(((int64_t)left_delta_y * -half_width_q6) >>
MATH_Q12_SHIFT)},
175 {0, (int32_t)(((int64_t)top_delta_x * focal_q6) >>
MATH_Q12_SHIFT),
176 -(int32_t)(((int64_t)-half_height_q6 * top_delta_x) >>
MATH_Q12_SHIFT)},
177 {-(int32_t)(((int64_t)focal_q6 * right_delta_y) >>
MATH_Q12_SHIFT), 0,
178 (int32_t)(((int64_t)right_delta_y * half_width_q6) >>
MATH_Q12_SHIFT)},
179 {0, (int32_t)(((int64_t)bottom_delta_x * focal_q6) >>
MATH_Q12_SHIFT),
180 -(int32_t)(((int64_t)half_height_q6 * bottom_delta_x) >>
MATH_Q12_SHIFT)}};
182 const int plane_indices[4] = {1, 4, 2, 3};
184 for (
int side = 0; side < 4; ++side)
186 int32_t
x = normals[side].
x;
187 int32_t
y = normals[side].
y;
188 int32_t
z = normals[side].
z;
189 uint64_t squared_length = (uint64_t)((int64_t)
x *
x) +
190 (uint64_t)((int64_t)
y *
y) + (uint64_t)((int64_t)
z *
z);
192 int16_t unit_x = 0, unit_y = 0, unit_z = 0;
196 int32_t inverse_length = INT64_C(0x100000000) / length;
198 unit_x = (int16_t)((int32_t)(((int64_t)inverse_length *
x) >>
MATH_Q12_SHIFT) >> 8);
199 unit_y = (int16_t)((int32_t)(((int64_t)inverse_length *
y) >>
MATH_Q12_SHIFT) >> 8);
200 unit_z = (int16_t)((int32_t)(((int64_t)inverse_length *
z) >>
MATH_Q12_SHIFT) >> 8);
203 frustum_dirs->
v[plane_indices[side]].
dir.
x = unit_x;
204 frustum_dirs->
v[plane_indices[side]].
dir.
y = unit_y;
205 frustum_dirs->
v[plane_indices[side]].
dir.
z = unit_z;