Changeset View
Changeset View
Standalone View
Standalone View
intern/mikktspace/mikktspace.c
| Context not available. | |||||
| #include <string.h> | #include <string.h> | ||||
| #include <float.h> | #include <float.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <limits.h> // for CHAR_BIT | |||||
| #include "mikktspace.h" | #include "mikktspace.h" | ||||
| Context not available. | |||||
| } | } | ||||
| #endif | #endif | ||||
| /* | |||||
| * Shift operations in C are only defined for shift values which are | |||||
| * not negative and smaller than sizeof(value) * CHAR_BIT. | |||||
| * The mask, used with bitwise-and (&), prevents undefined behaviour | |||||
| * when the shift count is 0 or >= the width of unsigned int. | |||||
| */ | |||||
| static unsigned int rotl(unsigned int value, unsigned int count) { | |||||
| const unsigned int mask = CHAR_BIT * sizeof(value) - 1; | |||||
| count &= mask; | |||||
| return (value << count) | (value >> (-count & mask)); | |||||
| } | |||||
| typedef struct { | typedef struct { | ||||
| int iNrFaces; | int iNrFaces; | ||||
| int *pTriMembers; | int *pTriMembers; | ||||
| Context not available. | |||||
| // Random | // Random | ||||
| t = uSeed & 31; | t = uSeed & 31; | ||||
| t = (uSeed << t) | (uSeed >> (32 - t)); | t = rotl(uSeed, t); | ||||
| uSeed = uSeed + t + 3; | uSeed = uSeed + t + 3; | ||||
| // Random end | // Random end | ||||
| Context not available. | |||||