From e67713c113c6044c9a395a1872769e556b902a97 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 19 May 2004 19:30:43 +0000 Subject: [PATCH] Removed a bzero from octree-filling, replaced with exact code what needs cleared. Timings go down nice: octree new 2.33a 128 0:04.2 0:07.5 256 0:06.5 0:20.0 512 0:18.0 2.06.9 Time is including initialize renderfaces etc. 100k quads. --- source/blender/render/intern/source/ray.c | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c index 694f27faeb8..0e5351d775e 100644 --- a/source/blender/render/intern/source/ray.c +++ b/source/blender/render/intern/source/ray.c @@ -500,8 +500,11 @@ void makeoctree() if(g_oc.min[0] > g_oc.max[0]) return; /* empty octree */ g_oc.adrbranch[0]=(Branch *)MEM_callocN(4096*sizeof(Branch), "makeoctree"); - ocvlak= MEM_callocN( 3*ocres2 + 8, "ocvlak"); + /* the lookup table, per face, for which nodes to fill in */ + ocvlak= MEM_callocN( 3*ocres2 + 8, "ocvlak"); + memset(ocvlak, 0, 3*ocres2); + for(c=0;c<3;c++) { /* octree enlarge, still needed? */ g_oc.min[c]-= 0.01; g_oc.max[c]+= 0.01; @@ -542,7 +545,7 @@ void makeoctree() } } - memset(ocvlak, 0, 3*ocres2); + for(c=0;c<3;c++) { oc1= rts[0][c]; @@ -591,14 +594,31 @@ void makeoctree() for(x=ocmin[0];x<=ocmax[0];x++) { a= g_oc.ocres*x; for(y=ocmin[1];y<=ocmax[1];y++) { - b= g_oc.ocres*y; if(ocvlak[a+y+ocres2]) { + b= g_oc.ocres*y+2*ocres2; for(z=ocmin[2];z<=ocmax[2];z++) { - if(ocvlak[b+z+2*ocres2] && ocvlak[a+z]) ocwrite(vlr, x,y,z, rtf); + if(ocvlak[b+z] && ocvlak[a+z]) ocwrite(vlr, x,y,z, rtf); } } } } + + /* same loops to clear octree, doubt it can be done smarter */ + for(x=ocmin[0];x<=ocmax[0];x++) { + a= g_oc.ocres*x; + for(y=ocmin[1];y<=ocmax[1];y++) { + /* x-y */ + ocvlak[a+y+ocres2]= 0; + + b= g_oc.ocres*y + 2*ocres2; + for(z=ocmin[2];z<=ocmax[2];z++) { + /* y-z */ + ocvlak[b+z]= 0; + /* x-z */ + ocvlak[a+z]= 0; + } + } + } } }