| 2907 | } |
| 2908 | |
| 2909 | void ReIndexShapef(BC6H_Encode_local* BC6H_data, CGU_INT shape_indices[MAX_SUBSETS][MAX_SUBSET_SIZE]) |
| 2910 | { |
| 2911 | CGU_FLOAT error = 0; |
| 2912 | CGU_FLOAT bestError; |
| 2913 | CGU_INT bestIndex = 0; |
| 2914 | CGU_INT sub0index = 0; |
| 2915 | CGU_INT sub1index = 0; |
| 2916 | CGU_INT MaxPallet = 0; |
| 2917 | CGU_INT region = (BC6H_data->region - 1); |
| 2918 | |
| 2919 | if (region == 0) |
| 2920 | MaxPallet = 16; |
| 2921 | else |
| 2922 | MaxPallet = 8; |
| 2923 | |
| 2924 | CGU_UINT8 isSet = 0; |
| 2925 | for (CGU_INT i = 0; i < MAX_SUBSET_SIZE; i++) |
| 2926 | { |
| 2927 | // subset 0 or subset 1 |
| 2928 | if (region) |
| 2929 | isSet = BC6_PARTITIONS[BC6H_data->d_shape_index][i]; |
| 2930 | |
| 2931 | if (isSet) |
| 2932 | { |
| 2933 | bestError = CMP_HALF_MAX; |
| 2934 | bestIndex = 0; |
| 2935 | |
| 2936 | // For two shape regions max Pallet is 8 |
| 2937 | for (CGU_INT j = 0; j < MaxPallet; j++) |
| 2938 | { |
| 2939 | // Calculate error from original |
| 2940 | error = abs(BC6H_data->din[i][0] - BC6H_data->Paletef[1][j].x) + abs(BC6H_data->din[i][1] - BC6H_data->Paletef[1][j].y) + |
| 2941 | abs(BC6H_data->din[i][2] - BC6H_data->Paletef[1][j].z); |
| 2942 | if (error < bestError) |
| 2943 | { |
| 2944 | bestError = error; |
| 2945 | bestIndex = j; |
| 2946 | } |
| 2947 | } |
| 2948 | |
| 2949 | shape_indices[1][sub1index] = bestIndex; |
| 2950 | sub1index++; |
| 2951 | } |
| 2952 | else |
| 2953 | { |
| 2954 | // This is shared for one or two shape regions max Pallet either 16 or 8 |
| 2955 | bestError = CMP_FLOAT_MAX; |
| 2956 | bestIndex = 0; |
| 2957 | |
| 2958 | for (CGU_INT j = 0; j < MaxPallet; j++) |
| 2959 | { |
| 2960 | // Calculate error from original |
| 2961 | error = abs(BC6H_data->din[i][0] - BC6H_data->Paletef[0][j].x) + abs(BC6H_data->din[i][1] - BC6H_data->Paletef[0][j].y) + |
| 2962 | abs(BC6H_data->din[i][2] - BC6H_data->Paletef[0][j].z); |
| 2963 | if (error < bestError) |
| 2964 | { |
| 2965 | bestError = error; |
| 2966 | bestIndex = j; |