I then started working on meshing chunks for the engine. Though I've done this already on my Java version of the game, I needed to change some things in order to *mesh* well with my engine (pardon the pun). With that in mind, I rewrote my greedy mesher to be not only modular, but more efficient and data-driven. It seamlessly molded into the voxel corner of the engine, and I now can mesh chunks efficiently, with AO, as can be seen here:
Not only that, but I began creating methods that create circles, spheres, boxes, and other simple shapes in order to make modeling easier. Yay!
Next I wanted to tackle what puts me off these types of projects all the time: world management. For some reason, I can logically break apart that topic into a large group of manageable tasks, but I've never managed to do more than meshing management. Now that I have an engine structure I'm happy with and I've got a momentum carrying me along, I hope I can accomplish just that!
I haven't done much yet, so there's nothing to show, but the general layout of a world's "tick" looks a little like this:
[code=:0]//...In VoxelWorld.cppvoid tick(float dt) { // Update Chunk Management Logic // --> Chunks can move between different states: // a. Loading (Fire event with chunk pointer, // wait until loaded ) // b. Setup (generate, decorate, mesh, etc) // c. Physics/Water/Player/LOD/etc updates // d. Unloading (Fire event with chunk pointer, // wait until unloaded ) _chunkStateManager.updateChunkStates(dt, this); // Update visibility // --> Read front to back for solid rendering, // read back to front for transparent rendering :) // _chunkSorter is a modified std::priority_queue // (underlying vector for iterating ease). _chunkSorter.update(_camera.getPosition()); // Update player inputs and movement. _player.update(dt);}//...Whoo!! The nice thing about this is all cross-thread communication is done through the EventManager, and each event is fired asynchronously, making everything easy on the developer. Having [font='courier new']_chunkStateManager[/font] be an object has allowed me to try different options for state management, like dumb systems that are step-based (run 'x' amount of chunk updates per frame), as well as smart systems that are AI based (extend chunk updates in a smart fashion that allows for more realistic results that should take into account how it's taxing the computer). All of this together creates a flexible system that I can use with ease.