22 # define M_PI 3.1415926535897932384626433832795
25 #define INTERNAL_RND_SORT_SEED 39871946
28 # define MIKK_INLINE static __forceinline
30 # define MIKK_INLINE static inline __attribute__((always_inline)) __attribute__((unused))
40 return (
v1.x ==
v2.x) && (
v1.y ==
v2.y) && (
v1.z ==
v2.z);
78 return v.x *
v.x +
v.y *
v.y +
v.z *
v.z;
112 return fabsf(fX) > FLT_MIN;
129 const unsigned int mask = CHAR_BIT *
sizeof(value) - 1;
147 #define MARK_DEGENERATE 1
148 #define QUAD_ONE_DEGEN_TRI 2
149 #define GROUP_WITH_ANY 4
150 #define ORIENT_PRESERVING 8
153 int FaceNeighbors[3];
163 unsigned char vert_num[4];
178 const int iNrTrianglesIn);
181 const int iNrTrianglesIn);
183 const int piTriListIn[],
185 const int iNrTrianglesIn);
188 int piGroupTrianglesBuffer[],
189 const int piTriListIn[],
190 const int iNrTrianglesIn);
194 const int iNrActiveGroups,
195 const int piTriListIn[],
196 const float fThresCos,
201 assert(iVert >= 0 && iVert < 4 && iFace >= 0);
202 return (iFace << 2) | (iVert & 0x3);
207 piVert[0] = iIndexIn & 0x3;
208 piFace[0] = iIndexIn >> 2;
244 const int iNrTrianglesIn,
250 const int iNrTrianglesIn,
261 int *piTriListIn =
NULL, *piGroupTrianglesBuffer =
NULL;
265 int iNrTrianglesIn = 0, f = 0,
t = 0, i = 0;
266 int iNrTSPaces = 0, iTotTris = 0, iDegenTriangles = 0, iNrMaxGroups = 0;
267 int iNrActiveGroups = 0, index = 0;
270 const float fThresCos =
cosf((fAngularThreshold * (
float)
M_PI) / 180.0f);
280 for (f = 0; f < iNrFaces; f++) {
287 if (iNrTrianglesIn <= 0)
291 piTriListIn = (
int *)malloc(
sizeof(
int[3]) * iNrTrianglesIn);
293 if (piTriListIn ==
NULL || pTriInfos ==
NULL) {
294 if (piTriListIn !=
NULL)
296 if (pTriInfos !=
NULL)
310 iTotTris = iNrTrianglesIn;
312 for (
t = 0;
t < iTotTris;
t++) {
313 const int i0 = piTriListIn[
t * 3 + 0];
314 const int i1 = piTriListIn[
t * 3 + 1];
315 const int i2 = piTriListIn[
t * 3 + 2];
319 if (
veq(p0, p1) ||
veq(p0, p2) ||
veq(p1, p2))
325 iNrTrianglesIn = iTotTris - iDegenTriangles;
332 DegenPrologue(pTriInfos, piTriListIn, iNrTrianglesIn, iTotTris);
336 InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn);
340 iNrMaxGroups = iNrTrianglesIn * 3;
341 pGroups = (
SGroup *)malloc(
sizeof(
SGroup) * iNrMaxGroups);
342 piGroupTrianglesBuffer = (
int *)malloc(
sizeof(
int[3]) * iNrTrianglesIn);
343 if (pGroups ==
NULL || piGroupTrianglesBuffer ==
NULL) {
346 if (piGroupTrianglesBuffer !=
NULL)
347 free(piGroupTrianglesBuffer);
354 pTriInfos, pGroups, piGroupTrianglesBuffer, piTriListIn, iNrTrianglesIn);
360 if (psTspace ==
NULL) {
364 free(piGroupTrianglesBuffer);
367 memset(psTspace, 0,
sizeof(
STSpace) * iNrTSPaces);
368 for (
t = 0;
t < iNrTSPaces;
t++) {
369 psTspace[
t].
vOs.
x = 1.0f;
370 psTspace[
t].
vOs.
y = 0.0f;
371 psTspace[
t].
vOs.
z = 0.0f;
373 psTspace[
t].
vOt.
x = 0.0f;
374 psTspace[
t].
vOt.
y = 1.0f;
375 psTspace[
t].
vOt.
z = 0.0f;
384 psTspace, pTriInfos, pGroups, iNrActiveGroups, piTriListIn, fThresCos, pContext);
389 free(piGroupTrianglesBuffer);
404 DegenEpilogue(psTspace, pTriInfos, piTriListIn, pContext, iNrTrianglesIn, iTotTris);
410 for (f = 0; f < iNrFaces; f++) {
423 bool bOrient = psTspace[index].
bOrient;
424 if (psTspace[index].iCounter == 0)
427 bool bNotFound =
true;
429 while (i<
verts && bNotFound)
431 if (psTspace[index+i].iCounter > 0) bNotFound=
false;
434 if (!bNotFound) bOrient = psTspace[index+i].
bOrient;
439 for (i = 0; i <
verts; i++) {
440 const STSpace *pTSpace = &psTspace[index];
441 float tang[] = {pTSpace->
vOs.
x, pTSpace->
vOs.
y, pTSpace->
vOs.
z};
442 float bitang[] = {pTSpace->
vOt.
x, pTSpace->
vOt.
y, pTSpace->
vOt.
z};
448 pContext, tang, pTSpace->
bOrient ==
TTRUE ? 1.0f : (-1.0f), f, i);
463 const int iNrTrianglesIn);
469 return *((
uint *)(&
v));
472 #define HASH(x, y, z) (((x)*73856093) ^ ((y)*19349663) ^ ((z)*83492791))
473 #define HASH_F(x, y, z) HASH(float_as_uint(x), float_as_uint(y), float_as_uint(z))
480 for (
int pass = 0; pass < 4; pass++, shift += 8) {
483 for (
int i = 0; i < n; i++) {
484 bins[((comp[i] >> shift) & 0xff) + 1]++;
487 for (
int i = 2; i < 256; i++) {
488 bins[i] += bins[i - 1];
491 for (
int i = 0; i < n; i++) {
492 int pos = bins[(comp[i] >> shift) & 0xff]++;
493 comp2[
pos] = comp[i];
501 uint *tmpcomp = comp;
515 const int iNrTrianglesIn)
522 int *temp_indices = (
int *)malloc(
sizeof(
int) *
numVertices);
535 const int index = piTriList_in_and_out[i];
546 hashes[i] =
HASH(hashP, hashN, hashT);
562 int blockend = blockstart + 1;
564 if (hashes[blockend] !=
hash)
569 if (blockend > blockstart + 1) {
570 for (
int i = blockstart; i < blockend; i++) {
571 int index1 = piTriList_in_and_out[
indices[i]];
575 for (
int i2 = i + 1; i2 < blockend; i2++) {
576 int index2 = piTriList_in_and_out[
indices[i2]];
577 if (index1 == index2)
582 piTriList_in_and_out[
indices[i2]] = index1;
593 blockstart = blockend;
602 const int iNrTrianglesIn)
604 int iNumUniqueVerts = 0,
t = 0, i = 0;
605 for (
t = 0;
t < iNrTrianglesIn;
t++) {
606 for (i = 0; i < 3; i++) {
607 const int offs =
t * 3 + i;
608 const int index = piTriList_in_and_out[offs];
615 int t2 = 0, index2rec = -1;
616 while (!bFound && t2 <=
t) {
618 while (!bFound && j < 3) {
619 const int index2 = piTriList_in_and_out[t2 * 3 + j];
624 if (
veq(vP, vP2) &&
veq(vN, vN2) &&
veq(vT, vT2))
635 if (index2rec == index) {
639 piTriList_in_and_out[offs] = index2rec;
647 const int iNrTrianglesIn)
649 int iTSpacesOffs = 0, f = 0,
t = 0;
650 int iDstTriIndex = 0;
652 for (f = 0; f < iNrFaces; f++) {
661 unsigned char *pVerts = pTriInfos[iDstTriIndex].
vert_num;
665 piTriList_out[iDstTriIndex * 3 + 0] =
MakeIndex(f, 0);
666 piTriList_out[iDstTriIndex * 3 + 1] =
MakeIndex(f, 1);
667 piTriList_out[iDstTriIndex * 3 + 2] =
MakeIndex(f, 2);
673 pTriInfos[iDstTriIndex + 1].
iTSpacesOffs = iTSpacesOffs;
690 tbool bQuadDiagIs_02;
691 if (distSQ_02 < distSQ_13)
692 bQuadDiagIs_02 =
TTRUE;
693 else if (distSQ_13 < distSQ_02)
703 bQuadDiagIs_02 = distSQ_13 < distSQ_02 ?
TFALSE :
TTRUE;
706 if (bQuadDiagIs_02) {
708 unsigned char *pVerts_A = pTriInfos[iDstTriIndex].
vert_num;
713 piTriList_out[iDstTriIndex * 3 + 0] = i0;
714 piTriList_out[iDstTriIndex * 3 + 1] =
i1;
715 piTriList_out[iDstTriIndex * 3 + 2] = i2;
718 unsigned char *pVerts_B = pTriInfos[iDstTriIndex].
vert_num;
723 piTriList_out[iDstTriIndex * 3 + 0] = i0;
724 piTriList_out[iDstTriIndex * 3 + 1] = i2;
725 piTriList_out[iDstTriIndex * 3 + 2] = i3;
730 unsigned char *pVerts_A = pTriInfos[iDstTriIndex].
vert_num;
735 piTriList_out[iDstTriIndex * 3 + 0] = i0;
736 piTriList_out[iDstTriIndex * 3 + 1] =
i1;
737 piTriList_out[iDstTriIndex * 3 + 2] = i3;
740 unsigned char *pVerts_B = pTriInfos[iDstTriIndex].
vert_num;
745 piTriList_out[iDstTriIndex * 3 + 0] =
i1;
746 piTriList_out[iDstTriIndex * 3 + 1] = i2;
747 piTriList_out[iDstTriIndex * 3 + 2] = i3;
753 iTSpacesOffs +=
verts;
754 assert(iDstTriIndex <= iNrTrianglesIn);
757 for (
t = 0;
t < iNrTrianglesIn;
t++)
758 pTriInfos[
t].iFlag = 0;
815 const int piTriListIn[],
816 const int iNrTrianglesIn);
818 const int piTriListIn[],
819 const int iNrTrianglesIn);
828 const float t21x = t2.
x - t1.
x;
829 const float t21y = t2.
y - t1.
y;
830 const float t31x = t3.
x - t1.
x;
831 const float t31y = t3.
y - t1.
y;
833 const float fSignedAreaSTx2 = t21x * t31y - t21y * t31x;
835 return fSignedAreaSTx2 < 0 ? (-fSignedAreaSTx2) : fSignedAreaSTx2;
839 const int piTriListIn[],
841 const int iNrTrianglesIn)
843 int f = 0, i = 0,
t = 0;
848 for (f = 0; f < iNrTrianglesIn; f++)
849 for (i = 0; i < 3; i++) {
853 pTriInfos[f].
vOs.
x = 0.0f;
854 pTriInfos[f].
vOs.
y = 0.0f;
855 pTriInfos[f].
vOs.
z = 0.0f;
856 pTriInfos[f].
vOt.
x = 0.0f;
857 pTriInfos[f].
vOt.
y = 0.0f;
858 pTriInfos[f].
vOt.
z = 0.0f;
859 pTriInfos[f].
fMagS = 0;
860 pTriInfos[f].
fMagT = 0;
867 for (f = 0; f < iNrTrianglesIn; f++) {
876 const float t21x = t2.
x - t1.
x;
877 const float t21y = t2.
y - t1.
y;
878 const float t31x = t3.
x - t1.
x;
879 const float t31y = t3.
y - t1.
y;
883 const float fSignedAreaSTx2 = t21x * t31y - t21y * t31x;
890 if (
NotZero(fSignedAreaSTx2)) {
891 const float fAbsArea =
fabsf(fSignedAreaSTx2);
892 const float fLenOs =
Length(vOs);
893 const float fLenOt =
Length(vOt);
896 pTriInfos[f].vOs =
vscale(fS / fLenOs, vOs);
898 pTriInfos[f].vOt =
vscale(fS / fLenOt, vOt);
901 pTriInfos[f].
fMagS = fLenOs / fAbsArea;
902 pTriInfos[f].
fMagT = fLenOt / fAbsArea;
911 while (
t < (iNrTrianglesIn - 1)) {
921 if ((bIsDeg_a || bIsDeg_b) ==
TFALSE) {
925 if (bOrientA != bOrientB) {
929 bChooseOrientFirstTri =
TTRUE;
930 else if (
CalcTexArea(pContext, &piTriListIn[
t * 3 + 0]) >=
932 bChooseOrientFirstTri =
TTRUE;
936 const int t0 = bChooseOrientFirstTri ?
t : (
t + 1);
937 const int t1 = bChooseOrientFirstTri ? (
t + 1) :
t;
967 const int iMyTriIndex,
973 int piGroupTrianglesBuffer[],
974 const int piTriListIn[],
975 const int iNrTrianglesIn)
977 const int iNrMaxGroups = iNrTrianglesIn * 3;
978 int iNrActiveGroups = 0;
979 int iOffset = 0, f = 0, i = 0;
981 for (f = 0; f < iNrTrianglesIn; f++) {
982 for (i = 0; i < 3; i++) {
986 int neigh_indexL, neigh_indexR;
987 const int vert_index = piTriListIn[f * 3 + i];
988 assert(iNrActiveGroups < iNrMaxGroups);
1000 neigh_indexR = pTriInfos[f].
FaceNeighbors[i > 0 ? (i - 1) : 2];
1001 if (neigh_indexL >= 0)
1004 piTriListIn, pTriInfos, neigh_indexL, pTriInfos[f].AssignedGroup[i]);
1009 assert(bAnswer || bDiff);
1010 (
void)bAnswer, (
void)bDiff;
1012 if (neigh_indexR >= 0)
1015 piTriListIn, pTriInfos, neigh_indexR, pTriInfos[f].AssignedGroup[i]);
1020 assert(bAnswer || bDiff);
1021 (
void)bAnswer, (
void)bDiff;
1029 assert(iOffset <= iNrMaxGroups);
1034 return iNrActiveGroups;
1045 const int iMyTriIndex,
1048 STriInfo *pMyTriInfo = &psTriInfos[iMyTriIndex];
1052 const int *pVerts = &piTriListIn[3 * iMyTriIndex + 0];
1054 if (pVerts[0] == iVertRep)
1056 else if (pVerts[1] == iVertRep)
1058 else if (pVerts[2] == iVertRep)
1060 assert(i >= 0 && i < 3);
1088 const int neigh_indexR = pMyTriInfo->
FaceNeighbors[i > 0 ? (i - 1) : 2];
1089 if (neigh_indexL >= 0)
1090 AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup);
1091 if (neigh_indexR >= 0)
1092 AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup);
1102 static void QuickSort(
int *pSortBuffer,
int iLeft,
int iRight,
unsigned int uSeed);
1105 const int piTriListIn[],
1108 const int iVertexRepresentitive);
1113 const int iNrActiveGroups,
1114 const int piTriListIn[],
1115 const float fThresCos,
1120 int *pTmpMembers =
NULL;
1121 int iMaxNrFaces = 0,
g = 0, i = 0;
1122 for (
g = 0;
g < iNrActiveGroups;
g++)
1123 if (iMaxNrFaces < pGroups[
g].iNrFaces)
1126 if (iMaxNrFaces == 0)
1130 pSubGroupTspace = (
STSpace *)malloc(
sizeof(
STSpace) * iMaxNrFaces);
1132 pTmpMembers = (
int *)malloc(
sizeof(
int) * iMaxNrFaces);
1133 if (pSubGroupTspace ==
NULL || pUniSubGroups ==
NULL || pTmpMembers ==
NULL) {
1134 if (pSubGroupTspace !=
NULL)
1135 free(pSubGroupTspace);
1136 if (pUniSubGroups !=
NULL)
1137 free(pUniSubGroups);
1138 if (pTmpMembers !=
NULL)
1143 for (
g = 0;
g < iNrActiveGroups;
g++) {
1144 const SGroup *pGroup = &pGroups[
g];
1145 int iUniqueSubGroups = 0, s = 0;
1147 for (i = 0; i < pGroup->
iNrFaces; i++)
1150 int index = -1, iVertIndex = -1, iOF_1 = -1, iMembers = 0, j = 0,
l = 0;
1154 if (pTriInfos[f].AssignedGroup[0] == pGroup)
1156 else if (pTriInfos[f].AssignedGroup[1] == pGroup)
1158 else if (pTriInfos[f].AssignedGroup[2] == pGroup)
1160 assert(index >= 0 && index < 3);
1162 iVertIndex = piTriListIn[f * 3 + index];
1176 for (j = 0; j < pGroup->
iNrFaces; j++) {
1191 const float fCosS =
vdot(vOs, vOs2);
1192 const float fCosT =
vdot(vOt, vOt2);
1194 assert(f !=
t || bSameOrgFace);
1195 if (bAny || bSameOrgFace || (fCosS > fThresCos && fCosT > fThresCos))
1196 pTmpMembers[iMembers++] =
t;
1205 QuickSort(pTmpMembers, 0, iMembers - 1, uSeed);
1211 while (
l < iUniqueSubGroups && !bFound) {
1217 assert(bFound ||
l == iUniqueSubGroups);
1222 int *pIndices = (
int *)malloc(
sizeof(
int) * iMembers);
1223 if (pIndices ==
NULL) {
1226 for (s = 0; s < iUniqueSubGroups; s++)
1227 free(pUniSubGroups[s].pTriMembers);
1228 free(pUniSubGroups);
1230 free(pSubGroupTspace);
1233 pUniSubGroups[iUniqueSubGroups].
iNrFaces = iMembers;
1234 pUniSubGroups[iUniqueSubGroups].
pTriMembers = pIndices;
1235 memcpy(pIndices, tmp_group.
pTriMembers,
sizeof(
int) * iMembers);
1248 const int iVert = pTriInfos[f].
vert_num[index];
1249 STSpace *pTS_out = &psTspace[iOffs + iVert];
1253 *pTS_out =
AvgTSpace(pTS_out, &pSubGroupTspace[
l]);
1259 *pTS_out = pSubGroupTspace[
l];
1267 for (s = 0; s < iUniqueSubGroups; s++)
1268 free(pUniSubGroups[s].pTriMembers);
1272 free(pUniSubGroups);
1274 free(pSubGroupTspace);
1281 const int piTriListIn[],
1284 const int iVertexRepresentitive)
1287 float fAngleSum = 0;
1298 for (face = 0; face < iFaces; face++) {
1299 const int f = face_indices[face];
1304 float fCos,
fAngle, fMagS, fMagT;
1305 int i = -1, index = -1, i0 = -1,
i1 = -1, i2 = -1;
1306 if (piTriListIn[3 * f + 0] == iVertexRepresentitive)
1308 else if (piTriListIn[3 * f + 1] == iVertexRepresentitive)
1310 else if (piTriListIn[3 * f + 2] == iVertexRepresentitive)
1312 assert(i >= 0 && i < 3);
1315 index = piTriListIn[3 * f + i];
1320 i2 = piTriListIn[3 * f + (i < 2 ? (i + 1) : 0)];
1321 i1 = piTriListIn[3 * f + i];
1322 i0 = piTriListIn[3 * f + (i > 0 ? (i - 1) : 2)];
1337 fCos = fCos > 1 ? 1 : (fCos < (-1) ? (-1) : fCos);
1339 fMagS = pTriInfos[f].
fMagS;
1340 fMagT = pTriInfos[f].
fMagT;
1353 if (fAngleSum > 0) {
1354 res.
fMagS /= fAngleSum;
1355 res.
fMagT /= fAngleSum;
1367 while (i < pg1->iNrFaces && bStillSame) {
1375 static void QuickSort(
int *pSortBuffer,
int iLeft,
int iRight,
unsigned int uSeed)
1377 int iL, iR, n, index, iMid, iTmp;
1380 unsigned int t = uSeed & 31;
1382 uSeed = uSeed +
t + 3;
1389 index = (int)(uSeed % (
unsigned int)n);
1391 iMid = pSortBuffer[index + iL];
1394 while (pSortBuffer[iL] < iMid)
1396 while (pSortBuffer[iR] > iMid)
1400 iTmp = pSortBuffer[iL];
1401 pSortBuffer[iL] = pSortBuffer[iR];
1402 pSortBuffer[iR] = iTmp;
1409 QuickSort(pSortBuffer, iLeft, iR, uSeed);
1411 QuickSort(pSortBuffer, iL, iRight, uSeed);
1418 SEdge *pSortBuffer,
int iLeft,
int iRight,
const int channel,
unsigned int uSeed);
1419 static void GetEdge(
int *i0_out,
1428 const int piTriListIn[],
1429 const int iNrTrianglesIn)
1433 int iEntries = 0, iCurStartIndex = -1, f = 0, i = 0;
1434 for (f = 0; f < iNrTrianglesIn; f++)
1435 for (i = 0; i < 3; i++) {
1436 const int i0 = piTriListIn[f * 3 + i];
1437 const int i1 = piTriListIn[f * 3 + (i < 2 ? (i + 1) : 0)];
1438 pEdges[f * 3 + i].
i0 = i0 <
i1 ? i0 :
i1;
1439 pEdges[f * 3 + i].
i1 = !(i0 <
i1) ? i0 :
i1;
1440 pEdges[f * 3 + i].
f = f;
1449 iEntries = iNrTrianglesIn * 3;
1451 for (i = 1; i < iEntries; i++) {
1452 if (pEdges[iCurStartIndex].i0 != pEdges[i].i0) {
1453 const int iL = iCurStartIndex;
1454 const int iR = i - 1;
1465 for (i = 1; i < iEntries; i++) {
1466 if (pEdges[iCurStartIndex].i0 != pEdges[i].i0 || pEdges[iCurStartIndex].
i1 != pEdges[i].
i1) {
1467 const int iL = iCurStartIndex;
1468 const int iR = i - 1;
1476 for (i = 0; i < iEntries; i++) {
1477 const int i0 = pEdges[i].
i0;
1478 const int i1 = pEdges[i].
i1;
1479 const int f = pEdges[i].
f;
1480 tbool bUnassigned_A;
1483 int edgenum_A, edgenum_B = 0;
1487 &piTriListIn[f * 3],
1492 if (bUnassigned_A) {
1496 while (j < iEntries && i0 == pEdges[j].i0 &&
i1 == pEdges[j].
i1 && bNotFound) {
1497 tbool bUnassigned_B;
1504 &piTriListIn[
t * 3],
1509 if (i0_A == i0_B && i1_A == i1_B && bUnassigned_B)
1516 int t = pEdges[j].
f;
1526 const int piTriListIn[],
1527 const int iNrTrianglesIn)
1530 for (f = 0; f < iNrTrianglesIn; f++) {
1531 for (i = 0; i < 3; i++) {
1533 if (pTriInfos[f].FaceNeighbors[i] == -1) {
1534 const int i0_A = piTriListIn[f * 3 + i];
1535 const int i1_A = piTriListIn[f * 3 + (i < 2 ? (i + 1) : 0)];
1540 while (!bFound &&
t < iNrTrianglesIn) {
1543 while (!bFound && j < 3) {
1545 const int i1_B = piTriListIn[
t * 3 + j];
1546 const int i0_B = piTriListIn[
t * 3 + (j < 2 ? (j + 1) : 0)];
1548 if (i0_A == i0_B && i1_A == i1_B)
1571 SEdge *pSortBuffer,
int iLeft,
int iRight,
const int channel,
unsigned int uSeed)
1574 int iL, iR, n, index, iMid;
1578 const int iElems = iRight - iLeft + 1;
1581 else if (iElems == 2) {
1582 if (pSortBuffer[iLeft].
array[channel] > pSortBuffer[iRight].
array[channel]) {
1583 sTmp = pSortBuffer[iLeft];
1584 pSortBuffer[iLeft] = pSortBuffer[iRight];
1585 pSortBuffer[iRight] = sTmp;
1589 else if (iElems < 16) {
1591 for (i = 0; i < iElems - 1; i++) {
1592 for (j = 0; j < iElems - i - 1; j++) {
1593 int index = iLeft + j;
1594 if (pSortBuffer[index].
array[channel] > pSortBuffer[index + 1].
array[channel]) {
1595 sTmp = pSortBuffer[index];
1596 pSortBuffer[index] = pSortBuffer[index + 1];
1597 pSortBuffer[index + 1] = sTmp;
1607 uSeed = uSeed +
t + 3;
1614 index = (int)(uSeed % (
unsigned int)n);
1616 iMid = pSortBuffer[index + iL].
array[channel];
1619 while (pSortBuffer[iL].
array[channel] < iMid)
1621 while (pSortBuffer[iR].
array[channel] > iMid)
1625 sTmp = pSortBuffer[iL];
1626 pSortBuffer[iL] = pSortBuffer[iR];
1627 pSortBuffer[iR] = sTmp;
1675 int piTriList_out[],
1676 const int iNrTrianglesIn,
1679 int iNextGoodTriangleSearchIndex = -1;
1680 tbool bStillFindingGoodOnes;
1684 while (
t < (iTotTris - 1)) {
1691 if ((bIsDeg_a ^ bIsDeg_b) != 0) {
1703 iNextGoodTriangleSearchIndex = 1;
1705 bStillFindingGoodOnes =
TTRUE;
1706 while (
t < iNrTrianglesIn && bStillFindingGoodOnes) {
1709 if (iNextGoodTriangleSearchIndex < (
t + 2))
1710 iNextGoodTriangleSearchIndex =
t + 2;
1716 while (bJustADegenerate && iNextGoodTriangleSearchIndex < iTotTris) {
1722 bJustADegenerate =
TFALSE;
1724 ++iNextGoodTriangleSearchIndex;
1728 t1 = iNextGoodTriangleSearchIndex;
1729 ++iNextGoodTriangleSearchIndex;
1730 assert(iNextGoodTriangleSearchIndex > (
t + 1));
1733 if (!bJustADegenerate) {
1735 for (i = 0; i < 3; i++) {
1736 const int index = piTriList_out[t0 * 3 + i];
1737 piTriList_out[t0 * 3 + i] = piTriList_out[t1 * 3 + i];
1738 piTriList_out[t1 * 3 + i] = index;
1741 const STriInfo tri_info = pTriInfos[t0];
1742 pTriInfos[t0] = pTriInfos[t1];
1743 pTriInfos[t1] = tri_info;
1747 bStillFindingGoodOnes =
TFALSE;
1750 if (bStillFindingGoodOnes)
1754 assert(bStillFindingGoodOnes);
1755 assert(iNrTrianglesIn ==
t);
1765 const int iNrTrianglesIn,
1771 for (
t = 0;
t < 3 * iNrTrianglesIn;
t++) {
1772 int iVertIndex = piTriListIn[
t];
1791 for (
t = 0;
t < 3 * iNrTrianglesIn;
t++) {
1792 int iVertIndex = piTriListIn[
t];
1793 if (pLookupCtx->
pLookup[iVertIndex] != -1) {
1796 pLookupCtx->
pLookup[iVertIndex] =
t;
1802 const int iNrTrianglesIn,
1803 const int iVertexIndex)
1818 return pLookupCtx->
pLookup[iVertexIndex];
1835 const int iNrTrianglesIn,
1842 for (
t = iNrTrianglesIn;
t < iTotTris;
t++) {
1850 for (i = 0; i < 3; i++) {
1851 const int index1 = piTriListIn[
t * 3 + i];
1858 const int iTri = j / 3;
1859 const int iVert = j % 3;
1860 const int iSrcVert = pTriInfos[iTri].
vert_num[iVert];
1862 const int iDstVert = pTriInfos[
t].
vert_num[i];
1865 psTspace[iDstOffs + iDstVert] = psTspace[iSrcOffs + iSrcVert];
1871 for (
t = 0;
t < iNrTrianglesIn;
t++) {
1876 int iOrgF = -1, i = 0;
1878 unsigned char *pV = pTriInfos[
t].
vert_num;
1879 int iFlag = (1 << pV[0]) | (1 << pV[1]) | (1 << pV[2]);
1880 int iMissingIndex = 0;
1881 if ((iFlag & 2) == 0)
1883 else if ((iFlag & 4) == 0)
1885 else if ((iFlag & 8) == 0)
1892 while (bNotFound && i < 3) {
1893 const int iVert = pV[i];
1897 psTspace[iOffs + iMissingIndex] = psTspace[iOffs + iVert];
typedef float(TangentPoint)[2]
void BLI_kdtree_nd_() free(KDTree *tree)
BLI_INLINE void Normalize(float no[3])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
SyclQueue void void size_t num_bytes void
static const float data2[18 *GP_PRIM_DATABUF_SIZE]
ccl_gpu_kernel_postfix int ccl_global int * indices
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup *pGroup)
static void radixsort_pair(uint *comp, int *data, uint *comp2, int *data2, int n)
struct VertReverseLookupContext VertReverseLookupContext
static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn)
MIKK_INLINE tbool veq(const SVec3 v1, const SVec3 v2)
MIKK_INLINE tbool NotZero(const float fX)
MIKK_INLINE float LengthSquared(const SVec3 v)
static void GenerateSharedVerticesIndexListSlow(int piTriList_in_and_out[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
static void GetEdge(int *i0_out, int *i1_out, int *edgenum_out, const int indices[], const int i0_in, const int i1_in)
MIKK_INLINE float Length(const SVec3 v)
static void QuickSort(int *pSortBuffer, int iLeft, int iRight, unsigned int uSeed)
#define ORIENT_PRESERVING
MIKK_INLINE SVec3 GetTexCoord(const SMikkTSpaceContext *pContext, const int index)
#define QUAD_ONE_DEGEN_TRI
MIKK_INLINE SVec3 vsub(const SVec3 v1, const SVec3 v2)
MIKK_INLINE unsigned int rotl(unsigned int value, unsigned int count)
tbool genTangSpace(const SMikkTSpaceContext *pContext, const float fAngularThreshold)
static int LookupVertexIndexFromGoodTriangle(VertReverseLookupContext *pLookupCtx, int piTriListIn[], const int iNrTrianglesIn, const int iVertexIndex)
MIKK_INLINE SVec3 GetPosition(const SMikkTSpaceContext *pContext, const int index)
MIKK_INLINE SVec3 GetNormal(const SMikkTSpaceContext *pContext, const int index)
static uint float_as_uint(const float v)
MIKK_INLINE SVec3 vadd(const SVec3 v1, const SVec3 v2)
static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris)
tbool genTangSpaceDefault(const SMikkTSpaceContext *pContext)
static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
#define INTERNAL_RND_SORT_SEED
static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
static void GenerateReverseLookup(const int piTriListIn[], const int iNrTrianglesIn, VertReverseLookupContext *pLookupCtx)
MIKK_INLINE SVec3 NormalizeSafe(const SVec3 v)
static float CalcTexArea(const SMikkTSpaceContext *pContext, const int indices[])
MIKK_INLINE SVec3 vscale(const float fS, const SVec3 v)
MIKK_INLINE int MakeIndex(const int iFace, const int iVert)
static void FreeReverseLookup(VertReverseLookupContext *pLookupCtx)
static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn, const int iTotTris)
static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
MIKK_INLINE float vdot(const SVec3 v1, const SVec3 v2)
static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, const SMikkTSpaceContext *pContext)
static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge *pEdges, const int piTriListIn[], const int iNrTrianglesIn)
static tbool CompareSubGroups(const SSubGroup *pg1, const SSubGroup *pg2)
static void QuickSortEdges(SEdge *pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed)
static STSpace EvalTspace(const int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[], const SMikkTSpaceContext *pContext, const int iVertexRepresentitive)
static STSpace AvgTSpace(const STSpace *pTS0, const STSpace *pTS1)
MIKK_INLINE void IndexToData(int *piFace, int *piVert, const int iIndexIn)
static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn)
MIKK_INLINE void AddTriToGroup(SGroup *pGroup, const int iTriIndex)
INLINE Rall1d< T, V, S > acos(const Rall1d< T, V, S > &x)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
tbool bOrientPreservering
int iVertexRepresentitive
SMikkTSpaceInterface * m_pInterface
void(* m_getNormal)(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert)
void(* m_getPosition)(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert)
void(* m_getTexCoord)(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert)
void(* m_setTSpace)(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT, const tbool bIsOrientationPreserving, const int iFace, const int iVert)
void(* m_setTSpaceBasic)(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert)
int(* m_getNumFaces)(const SMikkTSpaceContext *pContext)
int(* m_getNumVerticesOfFace)(const SMikkTSpaceContext *pContext, const int iFace)
SGroup * AssignedGroup[3]
unsigned char vert_num[4]