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