void VoxelTreeElement::splitChildren() { if (requiresSplit()) { const nodeColor& ourColor = getColor(); // for colored leaves, we must add *all* the children for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { addChildAtIndex(i)->setColor(ourColor); } nodeColor noColor = { 0, 0, 0, 0}; setColor(noColor); // set our own color to noColor so we are a pure non-leaf } }
void render(Scene& scene, Camera<FilmTy, width, height>& camera) { glUseProgram(0); glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glEnable(GL_DEPTH_TEST); mem::Pool<Microgrid, GIRDPOOL_SIZE>* grids = new mem::Pool<Microgrid, GIRDPOOL_SIZE>; //glEnable(GL_CULL_FACE); // do culling while (scene) { mem::blk shp_blk = scene.pop(); Shape* shape = static_cast<Shape*>(shp_blk.ptr); Microgrid& grid = *(grids->alloc()); shape->dice(grid); // DICE AABB2 bb = grid.aabb(); // BOUND if (!isInFrustum(bb)) // | try to cull goto memoryCleanup; // | vec2 rasSz = camera.film.estimate(bb.max - bb.min); // SPLIT - estimate grid's raster size if (requiresSplit(rasSz, RASTER_THRESHOLD)) // | { // | shape->split(scene); // | do split } // | else // | don't split, so continue to raster { shape->shade(grid); // SHADE camera.film.rasterize(grid); // SAMPLE } memoryCleanup: grids->free(grid); //scene.free(shp_blk); printf("\rSHAPES: %d ", scene.cnt); } delete grids; SwapBuffersBackend(); }