Showing the changes to interface/src/VoxelSystem.cpp (1 of 3 files). Show all
Unified · Split
| @@ -292,6 +292,7 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 291 unmodified lines | |||
| 292 | assert(_viewFrustum); // you must set up _viewFrustum before calling this | 292 | assert(_viewFrustum); // you must set up _viewFrustum before calling this |
| 293 | int voxelsUpdated = 0; | 293 | int voxelsUpdated = 0; |
| 294 | bool shouldRender = false; // assume we don't need to render it | 294 | bool shouldRender = false; // assume we don't need to render it |
| 295 | bool isLeaf = node->isLeaf(); | ||
| 295 | // if it's colored, we might need to render it! | 296 | // if it's colored, we might need to render it! |
| 296 | if (node->isColored()) { | 297 | if (node->isColored()) { |
| 297 | float distanceToNode = node->distanceToCamera(*_viewFrustum); | 298 | float distanceToNode = node->distanceToCamera(*_viewFrustum); |
| @@ -299,13 +300,15 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 1 unmodified line | |||
| 299 | float childBoundary = boundaryDistanceForRenderLevel(node->getLevel() + 1); | 300 | float childBoundary = boundaryDistanceForRenderLevel(node->getLevel() + 1); |
| 300 | bool inBoundary = (distanceToNode <= boundary); | 301 | bool inBoundary = (distanceToNode <= boundary); |
| 301 | bool inChildBoundary = (distanceToNode <= childBoundary); | 302 | bool inChildBoundary = (distanceToNode <= childBoundary); |
| 302 | shouldRender = (node->isLeaf() && inChildBoundary) || (inBoundary && !inChildBoundary); | 303 | shouldRender = (isLeaf && inChildBoundary) || (inBoundary && !inChildBoundary); |
| 303 | } | 304 | } |
| 304 | node->setShouldRender(shouldRender && !node->isStagedForDeletion()); | 305 | node->setShouldRender(shouldRender && !node->isStagedForDeletion()); |
| 305 | // let children figure out their renderness | 306 | // let children figure out their renderness |
| 306 | for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { | 307 | if (!isLeaf) { |
| 307 | if (node->getChildAtIndex(i)) { | 308 | for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { |
| 308 | voxelsUpdated += newTreeToArrays(node->getChildAtIndex(i)); | 309 | if (node->getChildAtIndex(i)) { |
| 310 | voxelsUpdated += newTreeToArrays(node->getChildAtIndex(i)); | ||
| 311 | } | ||
| 309 | } | 312 | } |
| 310 | } | 313 | } |
| 311 | if (_renderFullVBO) { | 314 | if (_renderFullVBO) { |
| @@ -886,7 +889,8 @@ public: · 574 unmodified lines | |||
| 886 | coloredNodes(0), | 889 | coloredNodes(0), |
| 887 | nodesInVBO(0), | 890 | nodesInVBO(0), |
| 888 | nodesInVBOOverExpectedMax(0), | 891 | nodesInVBOOverExpectedMax(0), |
| 889 | duplicateVBOIndex(0) | 892 | duplicateVBOIndex(0), |
| 893 | leafNodes(0) | ||
| 890 | { | 894 | { |
| 891 | memset(hasIndexFound, false, MAX_VOXELS_PER_SYSTEM * sizeof(bool)); | 895 | memset(hasIndexFound, false, MAX_VOXELS_PER_SYSTEM * sizeof(bool)); |
| 892 | }; | 896 | }; |
| @@ -898,9 +902,10 @@ public: · 5 unmodified lines | |||
| 898 | unsigned long nodesInVBO; | 902 | unsigned long nodesInVBO; |
| 899 | unsigned long nodesInVBOOverExpectedMax; | 903 | unsigned long nodesInVBOOverExpectedMax; |
| 900 | unsigned long duplicateVBOIndex; | 904 | unsigned long duplicateVBOIndex; |
| 905 | unsigned long leafNodes; | ||
| 906 | |||
| 901 | unsigned long expectedMax; | 907 | unsigned long expectedMax; |
| 902 | 908 | ||
| 903 | bool colorThis; | ||
| 904 | bool hasIndexFound[MAX_VOXELS_PER_SYSTEM]; | 909 | bool hasIndexFound[MAX_VOXELS_PER_SYSTEM]; |
| 905 | }; | 910 | }; |
| 906 | 911 | ||
| @@ -908,6 +913,10 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex · 1 unmodified line | |||
| 908 | collectStatsForTreesAndVBOsArgs* args = (collectStatsForTreesAndVBOsArgs*)extraData; | 913 | collectStatsForTreesAndVBOsArgs* args = (collectStatsForTreesAndVBOsArgs*)extraData; |
| 909 | args->totalNodes++; | 914 | args->totalNodes++; |
| 910 | 915 | ||
| 916 | if (node->isLeaf()) { | ||
| 917 | args->leafNodes++; | ||
| 918 | } | ||
| 919 | |||
| 911 | if (node->isColored()) { | 920 | if (node->isColored()) { |
| 912 | args->coloredNodes++; | 921 | args->coloredNodes++; |
| 913 | } | 922 | } |
| @@ -939,6 +948,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex · 25 unmodified lines | |||
| 939 | } | 948 | } |
| 940 | 949 | ||
| 941 | void VoxelSystem::collectStatsForTreesAndVBOs() { | 950 | void VoxelSystem::collectStatsForTreesAndVBOs() { |
| 951 | PerformanceWarning warn(true, "collectStatsForTreesAndVBOs()", true); | ||
| 942 | 952 | ||
| 943 | glBufferIndex minDirty = GLBUFFER_INDEX_UNKNOWN; | 953 | glBufferIndex minDirty = GLBUFFER_INDEX_UNKNOWN; |
| 944 | glBufferIndex maxDirty = 0; | 954 | glBufferIndex maxDirty = 0; |
| @@ -957,8 +967,10 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { · 12 unmodified lines | |||
| 957 | printLog("_voxelsDirty=%s _voxelsInWriteArrays=%ld minDirty=%ld maxDirty=%ld \n", (_voxelsDirty ? "yes" : "no"), | 967 | printLog("_voxelsDirty=%s _voxelsInWriteArrays=%ld minDirty=%ld maxDirty=%ld \n", (_voxelsDirty ? "yes" : "no"), |
| 958 | _voxelsInWriteArrays, minDirty, maxDirty); | 968 | _voxelsInWriteArrays, minDirty, maxDirty); |
| 959 | 969 | ||
| 960 | printLog("stats: total %ld, dirty %ld, colored %ld, shouldRender %ld, inVBO %ld, nodesInVBOOverExpectedMax %ld, duplicateVBOIndex %ld\n", | 970 | printLog("stats: total %ld, leaves %ld, dirty %ld, colored %ld, shouldRender %ld, inVBO %ld\n", |
| 961 | args.totalNodes, args.dirtyNodes, args.coloredNodes, args.shouldRenderNodes, | 971 | args.totalNodes, args.leafNodes, args.dirtyNodes, args.coloredNodes, args.shouldRenderNodes); |
| 972 | |||
| 973 | printLog("inVBO %ld, nodesInVBOOverExpectedMax %ld, duplicateVBOIndex %ld\n", | ||
| 962 | args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex); | 974 | args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex); |
| 963 | 975 | ||
| 964 | glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN; | 976 | glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN; |