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

Function xClumpColl_ForAllLineLeafNodeIntersections

src/SB/Core/x/xClumpColl.cpp:124–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124xClumpCollBSPTree*
125xClumpColl_ForAllLineLeafNodeIntersections(xClumpCollBSPTree* tree, RwLine* line,
126 xClumpCollV3dGradient* grad,
127 xClumpCollIntersectionCallback callBack, void* data)
128{
129 S32 nStack;
130 nodeInfo nodeStack[33];
131 nodeInfo node;
132 RwLine lineStack[33];
133 RwLine currLine;
134
135 node.type = tree->branchNodes ? 2 : 1;
136 node.index = 0;
137 currLine = *line;
138 nStack = 0;
139
140 while (nStack >= 0)
141 {
142 if (node.type == 1)
143 {
144 xClumpCollBSPTriangle* tris = tree->triangles + node.index;
145 if (!callBack(tris, data))
146 return NULL;
147
148 node = nodeStack[nStack];
149 currLine = lineStack[nStack];
150 nStack--;
151 }
152 else
153 {
154 RwSplitBits lStart, lEnd, rStart, rEnd;
155 xClumpCollBSPBranchNode* branch = tree->branchNodes + node.index;
156
157 lStart.nReal =
158 *(RwReal*)((U8*)&currLine.start + (branch->leftInfo & 0xC)) - branch->leftValue;
159 lEnd.nReal =
160 *(RwReal*)((U8*)&currLine.end + (branch->leftInfo & 0xC)) - branch->leftValue;
161 rStart.nReal =
162 *(RwReal*)((U8*)&currLine.start + (branch->leftInfo & 0xC)) - branch->rightValue;
163 rEnd.nReal =
164 *(RwReal*)((U8*)&currLine.end + (branch->leftInfo & 0xC)) - branch->rightValue;
165
166 if (rStart.nInt < 0 && rEnd.nInt < 0)
167 {
168 node.type = branch->leftInfo & 0x3;
169 node.index = branch->leftInfo >> 12;
170 }
171 else if (lStart.nInt >= 0 && lEnd.nInt >= 0)
172 {
173 node.type = branch->rightInfo & 0x3;
174 node.index = branch->rightInfo >> 12;
175 }
176 else if (!((lStart.nInt ^ lEnd.nInt) & 0x80000000) &&
177 !((rStart.nInt ^ rEnd.nInt) & 0x80000000))
178 {
179 if (rStart.nInt < rEnd.nInt)
180 {
181 nStack++;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected