MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / zVolume_OccludePrecalc

Function zVolume_OccludePrecalc

src/SB/Game/zVolume.cpp:70–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68void zVolume_OccludePrecalc(xVec3* camPos)
69{
70 S32 i;
71 S32 j;
72 xVec3 corner[5];
73 zVolume* vol;
74 xVolumeAsset* a;
75 F32 c;
76 F32 s;
77 PreCalcOcclude* calc;
78 xVec3 d1;
79 xVec3 d2;
80 xVec4 locFrustVec[4];
81 F32 depthdot;
82 F32 camdot;
83 F32 testdot1;
84 F32 testdot2;
85
86 gOccludeCalcCount = 0;
87
88 for (i = 0; i < gOccludeCount; i++)
89 {
90 vol = gOccludeList[i];
91 a = vol->asset;
92
93 c = icos(a->rot);
94 s = isin(a->rot);
95
96 calc = &gOccludeCalc[gOccludeCalcCount];
97
98 corner[0].x = c * (a->bound.box.box.lower.x - a->xpivot) + a->xpivot;
99 corner[0].y = a->bound.box.box.lower.y;
100 corner[0].z = s * (a->bound.box.box.lower.x - a->xpivot) + a->bound.box.box.lower.z;
101
102 corner[1].y = a->bound.box.box.lower.y;
103 corner[1].x = c * (a->bound.box.box.upper.x - a->xpivot) + a->xpivot;
104 corner[1].z = s * (a->bound.box.box.upper.x - a->xpivot) + a->bound.box.box.lower.z;
105
106 corner[2].x = c * (a->bound.box.box.upper.x - a->xpivot) + a->xpivot;
107 corner[2].y = a->bound.box.box.upper.y;
108 corner[2].z = s * (a->bound.box.box.upper.x - a->xpivot) + a->bound.box.box.lower.z;
109
110 corner[3].x = c * (a->bound.box.box.lower.x - a->xpivot) + a->xpivot;
111 corner[3].y = a->bound.box.box.upper.y;
112 corner[3].z = s * (a->bound.box.box.lower.x - a->xpivot) + a->bound.box.box.lower.z;
113
114 corner[4] = corner[0];
115
116 xVec3Sub(&d1, &corner[1], &corner[0]);
117 xVec3Sub(&d2, &corner[2], &corner[0]);
118
119 xVec3Cross((xVec3*)calc, &d1, &d2);
120 xVec3Normalize((xVec3*)calc, (xVec3*)calc);
121
122 depthdot = xVec3Dot((xVec3*)calc, &corner[0]);
123 camdot = xVec3Dot((xVec3*)calc, camPos);
124
125 if (camdot > depthdot)
126 {
127 xVec3Inv((xVec3*)calc, (xVec3*)calc);

Callers

nothing calls this directly

Calls 6

icosFunction · 0.85
isinFunction · 0.85
xVec3SubFunction · 0.85
xVec3CrossFunction · 0.85
xVec3InvFunction · 0.85
xVec3NormalizeFunction · 0.50

Tested by

no test coverage detected