17 float _calc_fov(
int viewport_width,
int angle_degree) {
18 return viewport_width * 0.5 / tan(angle_degree / 2 * 0.01745329) + 0.5;
51 for (
uint i = 0; i < 16384; ++i) {
56 for (
uint i = 0; i < 256; ++i)
list_E0380[i].mm7__vector_000004_size = 0;
70 unsigned int uNumVertices,
73 for (
uint i = 0; i < uNumVertices; ++i) {
119 if (!do_clip_test)
return false;
133 Vec3_short_ *a2) ->
void {
141 Vec3_short__to_RenderVertexSoft(&
v,
165 return (
float)0x2000;
173 int *transformed_y,
int *transformed_z,
175 this->
ViewTransform(x,
y,
z, transformed_x, transformed_y, transformed_z);
185 int *transformed_y,
int *transformed_z) {
187 v.vWorldPosition.x =
x;
188 v.vWorldPosition.y =
y;
189 v.vWorldPosition.z =
z;
193 *transformed_x = floorf(
v.vWorldViewPosition.x + 0.5f);
197 *transformed_y = floorf(
v.vWorldViewPosition.y + 0.5f);
201 *transformed_z = floorf(
v.vWorldViewPosition.z + 0.5f);
207 for (
uint i = 0; i < uNumVertices; ++i) {
265 if (fabs(a2->
z) < 0.70811361) {
294 if (pFace->
Portal())
return false;
312 signed int sStartDiffuse,
314 signed int sEndDiffuse,
315 unsigned int uOutNumVertices,
324 if ((
char)uOutNumVertices) {
333 v24[0].
pos.
z = 0.001 - z_stuff;
334 v24[0].
diffuse = sStartDiffuse;
342 v24[1].
pos.
z = 0.001 - z_stuff;
348 render->DrawLines(v24, 2);
351 for (
uint i = 0; i < 20; i++) a1[i].flt_2C = 0.0;
362 (
signed int)uOutNumVertices >= 2) {
368 v24[0].
pos.
z = 0.001 - z_stuff;
369 v24[0].
diffuse = sStartDiffuse;
377 v24[1].
pos.
z = 0.001 - z_stuff;
383 render->DrawLines(v24, 2);
391 unsigned int uNumLines,
int uDiffuse,
393 for (
int i = 0; i < uNumLines - 1; ++i)
394 render->do_draw_debug_line_d3d(&pLineVertices[i], uDiffuse,
395 &pLineVertices[i + 1], uDiffuse,
397 render->do_draw_debug_line_d3d(&pLineVertices[uNumLines - 1], uDiffuse,
398 pLineVertices, uDiffuse, z_stuff);
403 unsigned int uNumVertices,
404 unsigned int uDiffuse,
float a5) {
405 if (!uNumVertices)
return;
406 if ((
signed int)(uNumVertices - 1) > 0) {
407 for (
uint i = 0; i < uNumVertices - 1; i++)
432 v[i].diffuse = 0x80F020F0;
446 unsigned int uDiffuse) {
448 static bool __init_flag1 =
false;
452 for (
uint i = 0; i < 64; ++i)
453 static_sub_437906_array_50CDD0[i].flt_2C = 0.0
f;
463 static_sub_437906_array_50CDD0[i].
u = (
double)pFace->
pVertexUIDs[i];
464 static_sub_437906_array_50CDD0[i].
v = (double)pFace->
pVertexVIDs[i];
467 if (
engine->config->debug_portal_outlines)
479 for (
uint col = 0; col < 3; col++) {
483 m_out->
v[
row][col] = sum;
534 for (
uint i = 0; i < 3; ++i) {
576 v4 = v8.
x * a2->
x + v8.
y * a2->
y + v8.
z * a2->
z;
577 a2->
dot = v4 + 0.000099999997;
630 unsigned int *pOutNumVertices) {
641 memcpy(&v18, a2,
sizeof(v18));
643 memcpy(&a2[*pOutNumVertices], a2,
sizeof(a2[*pOutNumVertices]));
644 memcpy(&a2[*pOutNumVertices + 1], &a2[1],
sizeof(a2[*pOutNumVertices + 1]));
646 if ((
signed int)*pOutNumVertices <= 3 ||
656 (
signed int)*pOutNumVertices <= 0))
659 for (
int i = 1; i - 1 < (
signed int)*pOutNumVertices; i++) {
664 if (previous >= (
signed int)*pOutNumVertices)
665 previous -= *pOutNumVertices;
667 if (current >= (
signed int)*pOutNumVertices)
668 current -= *pOutNumVertices;
670 if (next >= (
signed int)*pOutNumVertices) next -= *pOutNumVertices;
672 if (-0.009999999776482582 <
673 ((a2[current].vWorldViewProjX - a2[previous].vWorldViewProjX) *
674 (a2[next].vWorldViewProjY - a2[previous].vWorldViewProjY) -
675 (a2[current].vWorldViewProjY - a2[previous].vWorldViewProjY) *
676 (a2[next].vWorldViewProjX - a2[previous].vWorldViewProjX)) *
679 if (next >= (
signed int)*pOutNumVertices)
680 v13 = next - *pOutNumVertices;
682 if (v13 < (
signed int)*pOutNumVertices) {
683 for (v14 = v13; v14 < (
signed int)*pOutNumVertices; ++v14)
684 memcpy(&a2[v14], &a2[v14 + 1],
sizeof(a2[v14]));
698 unsigned int *pOutNumVertices,
701 signed int NumFrustumPlanes,
char DebugLines,
718 int VertsAdjusted = 0;
728 int MinVertsAllowed = 2 * (DebugLines == 0) + 1;
731 if (NumFrustumPlanes <= 0)
return false;
737 for (
uint i = 0; i < NumFrustumPlanes; ++i) {
740 v15 = sr_vertices_50D9D8;
743 v14 = sr_vertices_50D9D8;
745 if (i == NumFrustumPlanes - 1) v14 =
pVertices;
746 FrustumPlaneVec.
x = CameraFrustrum[i].
x;
747 FrustumPlaneVec.
y = CameraFrustrum[i].
y;
748 FrustumPlaneVec.
z = CameraFrustrum[i].
z;
750 engine->pStru9Instance->AdjustVerticesToFrustumPlane(
751 v15, *pOutNumVertices, v14, pOutNumVertices, &FrustumPlaneVec, CameraFrustrum[i].dot,
752 (
char *)&VertsAdjusted, _unused);
755 if (*pOutNumVertices < MinVertsAllowed) {
756 *pOutNumVertices = 0;
764 return VertsAdjusted;
769 unsigned int *pOutNumVertices,
int _unused) {
780 unsigned int pVerticesa;
781 unsigned int pOutNumVerticesa;
786 static bool __init_flag1 =
false;
790 for (
uint i = 0; i < 64; ++i)
791 static_4371C3_array_50E5E0[i].flt_2C = 0.0
f;
796 v7 = pOutNumVertices;
797 if ((
int)*pOutNumVertices > 0) {
799 (
char *)static_4371C3_array_50E5E0 - (
char *)
pVertices;
800 pVerticesa = (
char *)&static_4371C3_array_50E5E0[0].vWorldViewProjY -
802 v8 = (
char *)&static_4371C3_array_50E5E0[0].vWorldPosition.y;
806 *((
int *)v8 - 1) = *(
int *)(v9 - 8);
807 *(
int *)v8 = *(
int *)(v9 - 4);
809 *(
float *)(pOutNumVerticesa + v9) = *(
float *)v9;
810 *(
float *)(pVerticesa + v9) = *(
float *)(v9 + 28);
811 *(
float *)((
char *)&static_4371C3_array_50E5E0[0].
_rhw -
812 (
char *)v6 + v9) = *(
float *)(v9 + 32);
814 }
while (v12 < (
signed int)*v7);
826 signed int *pOutNumVertices) {
831 for (; i < uNumInVertices; ++i) {
832 pInVertices[i].
_rhw =
834 memcpy(&pOutVertices[i], &pInVertices[i],
sizeof(pOutVertices[i]));
843 *pOutNumVertices = i;
851 unsigned int *pOutNumVertices) {
852 bool current_vertices_flag;
853 bool next_vertices_flag;
855 signed int depth_num_vertices;
857 memcpy(&pInVertices[uNumInVertices], &pInVertices[0],
858 sizeof(pInVertices[uNumInVertices]));
859 depth_num_vertices = 0;
860 current_vertices_flag =
false;
862 current_vertices_flag =
864 if ((
signed int)uNumInVertices <= 0)
return;
876 for (
uint i = 0; i < uNumInVertices; ++i) {
879 if (current_vertices_flag ^
880 next_vertices_flag) {
881 if (next_vertices_flag) {
888 (pInVertices[i].vWorldViewPosition.x -
904 pOutVertices[depth_num_vertices].
u =
906 (pInVertices[i].
u - pInVertices[i + 1].
u) *
t;
907 pOutVertices[depth_num_vertices].
v =
909 (pInVertices[i].
v - pInVertices[i + 1].
v) *
t;
910 pOutVertices[depth_num_vertices].
_rhw =
917 (pInVertices[i + 1].vWorldViewPosition.x -
933 pOutVertices[depth_num_vertices].
u =
935 (pInVertices[i + 1].
u - pInVertices[i].
u) *
t;
936 pOutVertices[depth_num_vertices].
v =
938 (pInVertices[i + 1].
v - pInVertices[i].
v) *
t;
939 pOutVertices[depth_num_vertices].
_rhw =
942 ++depth_num_vertices;
944 if (!next_vertices_flag) {
945 memcpy(&pOutVertices[depth_num_vertices], &pInVertices[i + 1],
946 sizeof(pOutVertices[depth_num_vertices]));
947 depth_num_vertices++;
949 current_vertices_flag = next_vertices_flag;
951 if (depth_num_vertices >= 3)
952 *pOutNumVertices = depth_num_vertices;
954 *pOutNumVertices = 0;
961 unsigned int *pOutNumVertices) {
965 bool current_vertices_flag;
966 bool next_vertices_flag;
979 int out_num_vertices = 0;
981 if (uNumInVertices) {
982 memcpy(&pInVertices[uNumInVertices], &pInVertices[0],
983 sizeof(pInVertices[0]));
984 next_vertices_flag =
false;
985 current_vertices_flag =
false;
986 if (pInVertices[0].vWorldViewPosition.x <= nearclip)
987 current_vertices_flag =
true;
988 for (
uint i = 0; i < uNumInVertices; ++i) {
991 if (current_vertices_flag ^ next_vertices_flag) {
992 if (next_vertices_flag) {
996 (pInVertices[i + 1].vWorldViewPosition.x -
1009 pOutVertices[out_num_vertices].
u =
1011 (pInVertices[i + 1].
u - pInVertices[i].
u) *
t;
1012 pOutVertices[out_num_vertices].
v =
1014 (pInVertices[i + 1].
v - pInVertices[i].
v) *
t;
1015 pOutVertices[out_num_vertices].
_rhw = 1.0 / 8.0;
1019 (pInVertices[i].vWorldViewPosition.x -
1032 pOutVertices[out_num_vertices].
u =
1034 (pInVertices[i].
u - pInVertices[i + 1].
u) *
t;
1035 pOutVertices[out_num_vertices].
v =
1037 (pInVertices[i].
v - pInVertices[i + 1].
v) *
t;
1038 pOutVertices[out_num_vertices].
_rhw = 1.0 / nearclip;
1042 if (!next_vertices_flag) {
1043 memcpy(&pOutVertices[out_num_vertices], &pInVertices[i + 1],
1044 sizeof(pInVertices[i + 1]));
1049 current_vertices_flag = next_vertices_flag;
1051 if (out_num_vertices >= 3)
1052 *pOutNumVertices = out_num_vertices;
1054 *pOutNumVertices = 0;
1060 unsigned int uNumVertices,
1061 bool fit_into_viewport) {
1072 for (
uint i = 0; i < uNumVertices; ++i) {
1089 v1 = 1.0 / (
v->vWorldViewPosition.x + 0.0000001);
1100 v2 *
v->vWorldViewPosition.y;
1102 v2 *
v->vWorldViewPosition.z;
1105 if (fit_into_viewport) {
1121 if (v11 >=
pVertices[i].vWorldViewProjY)
1127 if (v11 >=
pVertices[i].vWorldViewProjY)
1138 int *screenspace_y) {
1140 v.vWorldViewPosition.x =
x;
1141 v.vWorldViewPosition.y =
y;
1142 v.vWorldViewPosition.z =
z;
1146 if (screenspace_x) {
1147 *screenspace_x = floorf(
v.vWorldViewProjX + 0.5f);
1150 if (screenspace_y) {
1151 *screenspace_y = floorf(
v.vWorldViewProjY + 0.5f);
1157 unsigned int uStripType) {
1159 for (
uint i = 0; i < uStripType; i++) {
1169 unsigned int uStripType) {
1173 for (
uint i = 0; i < uStripType; i++) {
1174 if (pVertex[i].vWorldPosition.z >
result)