Jump to content

  • Log In with Google      Sign In   
  • Create Account


jellyfishchris

Member Since 19 Apr 2012
Offline Last Active Nov 23 2013 12:46 AM
-----

Topics I've Started

Voxel engine load times

30 April 2013 - 06:14 AM

Hi,

Ive been making a voxel engine in my spare time. Currently I have it running at 60fps easy running the same amount of voxels you would see in a minecraft world. (125 chunks each chunk is 64 ^3 blocks.)

 

I am loading the voxels in as a flat array like so:

 

 

m_blocks.resize(CHUNK_SIZE);
for(int z = 0; z < CHUNK_SIZE; z++)
{
m_blocks[z].resize(CHUNK_SIZE);
for(int y = 0; y < CHUNK_SIZE; ++y)
{
m_blocks[z][y].resize(CHUNK_SIZE);
}
}
 

then using the terrain engine to create the desired layout of the blocks. Then putting this into an octree for optimizations and then clearing the original array. Also I am using a texture atlas.

 

My load time for all those blocks (32768000) is about 1minute in release mode. I was wondering if you guys have any ideas on how to boost up the load times. (I will eventually make the system multi-threaded when I get around to it)

 

Thanks

 

 


Voxel engine, storage of blocks

27 March 2013 - 09:56 PM

I have just started working on a voxel engine for the fun of it. Ive managed to create the voxels and apply those with a texture atlas into a VBO. I have performed a few optimizations such as dont draw blocks you cant see etc etc.

 

I'm storing the blocks such as

 

Block m_blocks[16][128][16]; 
 

 

for each chunk.

 

However the problem arises when I want to have an infinite terrain. I found a few resources online saying I need to use hashmap and or loading/saving to external file for this. I would just like to clarify is this the correct approach additionally any advice/tips on how to go about it would be very appreciated.

 

Thanks


Late night coding

26 February 2013 - 11:14 PM

While finishing off a uni assignment with 4 other programmers at around 3am in the night, you start to write some sloppy code. We didn't notice until we decided to review the code after submitting... For the record we already check if the program worked, which it did.

 

Here is an example of what we found a few days later (snippet taken from a FishController class)....

 

        if (dt == 0.0f)
        {
            dt = 0.0f;
        }
        else
        {
            dt = diff.total_milliseconds();
            dt /= 100.0f;
        }
 

 

 


Delagates c++

14 February 2013 - 06:12 PM

This question is just in references to what one of the posts that have been made. There was some code posted I just have a quick question, as I will be writing my own component + event management system. With delagates what is the fastest / best way to write them in c++. Please state why x is fastest etc.

 

Orignal quote...

 

 

ComposerCookie, on 14 Feb 2013 - 23:16, said:snapback.png


 


can you please explain a bit more detail?

So, you have an "event", which is just an id to distinguish between events. It can be an enum, #DEFINE'd ints, hashed strings, whatever.

You also have a "delegate", which is the code that should be executed when the event happens. Delegates in C++ (which is what I assume you're using) are a pretty big topic, so I'll link you to the stackoverflow question What is a C++ delegate?

Lets say you have a class that keeps track of the player's score, and whenever an enemy is killed, the score should increase by the enemy's point value.

Pseudocode would look like this:

class ScoreTracker

{

    class EnemyKilledDelegate : Delegate

    {

       int totalPoints;



       virtual void operator()(void* data)

       {

           totalPoints = (int*)data;

       }

    }



    ScoreTracker()

    {

        //...

        EventManager* mgr;

        EnemyKilledDelegate* del;

        mgr.RegisterListener("EnemyKilled", del);

        //...

    }

}

The event manager would then keep some sort of dictionary to call the delegates when the event occurs:

class EventManager

{

    map<string, vector<Delegate*>*> eventMap;  // map strings to (pointers to (vector of pointers to delegates))

    RegisterListener(string event, Delegate* delegate)

    {

        // get the vector of delegates for the event (or create a new one)

        vector<Delegate>* eventListeners = eventMap.getOrCreate(event);

        eventListeners.add(delegate);    // add the delegate

    }



    ProcessEvent(string event, void* data)

    {

        // get the vector of delegates for the event (or create a new one)

        vector<Delegate>* eventListeners = eventMap.getOrCreate(event);



        foreach(Delegate* del in eventListeners)   // loop through and call each delegate

        {

            (*del)(data);

        }

    }

}

And finally, to fire an event:

class Enemy

{

    int pointValue;



    Die()

    {

        //...

        EventManager* mgr;

        mgr.ProcessEvent("EnemyKilled", &pointValue);

        //...

    }

}


 

 


Scene Graphs

19 April 2012 - 10:46 AM

I am having a small problem, well theorotical problem. I have a scenegraph that represents the whole world. However at the moment if there is multiple copies of the same scenegraph(aka the same model) it will just create a new scenegraph linking. I mean this works all well and good however the loading time is insane. Which is to be expected. I have tried to load the models scene graphs and simply just have the world link to these however... When i need to travel up the scenegraph the model doesnt know anything about the worlds unless you count the last one that was using it. Making it impossible to render the models in the right place as everytime you travel up the scenegraph you get into the problem of not knowing where to go from the models node to get to the world node.

I was hoping for maybe some design advice with what to do! Thanks

PARTNERS