From 87507db94b383ac7809277c035097e3ee61bb910 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 7 Jun 2008 19:12:27 +0000 Subject: [PATCH] More work on bitwise optimisations... --- source/SurfaceExtractors.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/SurfaceExtractors.cpp b/source/SurfaceExtractors.cpp index 2cab9946..32c20d6d 100644 --- a/source/SurfaceExtractors.cpp +++ b/source/SurfaceExtractors.cpp @@ -248,8 +248,15 @@ namespace PolyVox uint8_t iPreviousCubeIndex = previousBitmask[getIndex(x,y)]; iCubeIndex = iPreviousCubeIndex >> 4; - if (v001 == 0) iCubeIndex |= 16; - if (v101 == 0) iCubeIndex |= 32; + uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; + uint8_t bit7 = iPreviousCubeIndexY & 128; + uint8_t bit4 = bit7 >> 3; + + uint8_t bit6 = iPreviousCubeIndexY & 64; + uint8_t bit5 = bit6 >> 1; + + iCubeIndex |= bit4; + iCubeIndex |= bit5; if (v111 == 0) iCubeIndex |= 64; if (v011 == 0) iCubeIndex |= 128; }