Showing the changes to interface/src/VoxelSystem.cpp (1 of 4 files). Show all
Unified · Split
| @@ -133,12 +133,35 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, float nodePosition[3]) { · 132 unmodified lines | |||
| 133 | 133 | ||
| 134 | float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE); | 134 | float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE); |
| 135 | glm::vec3 viewerPosition = viewerHead->getPos(); | 135 | glm::vec3 viewerPosition = viewerHead->getPos(); |
| 136 | |||
| 137 | // XXXBHG - Note: It appears as if the X and Z coordinates of Head or Agent are flip-flopped relative to the | ||
| 138 | // coords of the voxel space. This flip flop causes LOD behavior to be extremely odd. This is my temporary hack | ||
| 139 | // to fix this behavior. To disable this swap, set swapXandZ to false. | ||
| 140 | bool swapXandZ=true; | ||
| 141 | float viewerX = swapXandZ ? viewerPosition[2] : viewerPosition[0]; | ||
| 142 | float viewerZ = swapXandZ ? viewerPosition[0] : viewerPosition[2]; | ||
| 143 | |||
| 144 | // debugging code. | ||
| 145 | //printf("treeToArrays() halfUnitForVoxel=%f\n",halfUnitForVoxel); | ||
| 146 | //printf("treeToArrays() viewerPosition {x,y,z or [0],[1],[2]} ={%f,%f,%f}\n", | ||
| 147 | // viewerPosition[0],viewerPosition[1],viewerPosition[2]); | ||
| 148 | //printf("treeToArrays() nodePosition {x,y,z or [0],[1],[2]} = {%f,%f,%f}\n", | ||
| 149 | // nodePosition[0],nodePosition[1],nodePosition[2]); | ||
| 150 | //float* vertices = firstVertexForCode(currentNode->octalCode); | ||
| 151 | //printf("treeToArrays() firstVerticesForCode(currentNode->octalCode)={x,y,z or [0],[1],[2]} = {%f,%f,%f}\n", | ||
| 152 | // vertices[0],vertices[1],vertices[2]); | ||
| 153 | //delete []vertices; | ||
| 136 | 154 | ||
| 137 | float distanceToVoxelCenter = sqrtf(powf(viewerPosition[0] - nodePosition[0] - halfUnitForVoxel, 2) + | 155 | float distanceToVoxelCenter = sqrtf(powf(viewerX - nodePosition[0] - halfUnitForVoxel, 2) + |
| 138 | powf(viewerPosition[1] - nodePosition[1] - halfUnitForVoxel, 2) + | 156 | powf(viewerPosition[1] - nodePosition[1] - halfUnitForVoxel, 2) + |
| 139 | powf(viewerPosition[2] - nodePosition[2] - halfUnitForVoxel, 2)); | 157 | powf(viewerZ - nodePosition[2] - halfUnitForVoxel, 2)); |
| 140 | 158 | ||
| 141 | if (distanceToVoxelCenter < boundaryDistanceForRenderLevel(*currentNode->octalCode + 1)) { | 159 | int boundaryPosition = boundaryDistanceForRenderLevel(*currentNode->octalCode + 1); |
| 160 | //printf("treeToArrays() distanceToVoxelCenter=%f boundaryPosition=%d\n",distanceToVoxelCenter,boundaryPosition); | ||
| 161 | |||
| 162 | bool alwaysDraw = false; // XXXBHG - temporary debug code. Flip this to true to disable LOD blurring | ||
| 163 | |||
| 164 | if (alwaysDraw || distanceToVoxelCenter < boundaryPosition) { | ||
| 142 | for (int i = 0; i < 8; i++) { | 165 | for (int i = 0; i < 8; i++) { |
| 143 | // check if there is a child here | 166 | // check if there is a child here |
| 144 | if (currentNode->children[i] != NULL) { | 167 | if (currentNode->children[i] != NULL) { |
| @@ -155,8 +178,6 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, float nodePosition[3]) { · 10 unmodified lines | |||
| 155 | childNodePosition[j] -= (powf(0.5, *currentNode->children[i]->octalCode) * TREE_SCALE); | 178 | childNodePosition[j] -= (powf(0.5, *currentNode->children[i]->octalCode) * TREE_SCALE); |
| 156 | } | 179 | } |
| 157 | } | 180 | } |
| 158 | |||
| 159 | |||
| 160 | voxelsAdded += treeToArrays(currentNode->children[i], childNodePosition); | 181 | voxelsAdded += treeToArrays(currentNode->children[i], childNodePosition); |
| 161 | } | 182 | } |
| 162 | } | 183 | } |