Results 1 to 10 of 34

Thread: Thyandyr's voxel engine

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I'm not sure exactly how TDictionary works but in general when you are removing items from Lists it is always better to go from last item to first instead of always removing first item in a loop. Why?
    Because when you remove first item from the list all other items needs to be shifted in order to fill the hole that you caused by removing that one item. This results in lots of unneeded data moving in the list internal array.

  2. #2
    Quote Originally Posted by SilverWarior View Post
    I'm not sure exactly how TDictionary works but in general when you are removing items from Lists it is always better to go from last item to first instead of always removing first item in a loop. Why?
    Because when you remove first item from the list all other items needs to be shifted in order to fill the hole that you caused by removing that one item. This results in lots of unneeded data moving in the list internal array.
    I agree and would have done it 'from count-1 downto 0' but that is not possible with TDictionary. Anyway freeing the Chunks is only for the program shutdown so performance is not that important anyway.

    Also I think if I do

    for Chunk in TDict.Values do Chunk.Free

    it still leaves the keys in, so the size of TDict size is not updated. Might be the size is not updated even if I removed the key as well, since there is some method to it called TrimExcess

    Didn't work much today.

    Fixed one bug, but made no progress on the case of too large VBO size causing full chunks disappear.

    Line of 11x11 size chunks along X axis. If I decrease the count by few they all fill a nice solid line as supposed to. Too many like here, and something gets corrupted. Note the closest artifact, the whole chunk is not missing, only half of it (It is hollow since none of the cubes that should not be visible are not drawn)

    Image2.jpg
    Last edited by Thyandyr; 03-11-2017 at 12:05 PM.

  3. #3
    Why keeping all this in single vbo?
    btw occlusion culling will be possible with this approach?

  4. #4
    Quote Originally Posted by laggyluk View Post
    Why keeping all this in single vbo?
    btw occlusion culling will be possible with this approach?
    I'm learning by doing and just wanted to see what happens and how much can push to one VBO. I will only remember things that I learn if I have first hand experience of the 'why' of things. Seeing something work or fail is essential to me.

    Sure occlusion calculations will be possible, currently I only draw voxel surfaces that have solid-gas interface (assuming atmosphere... should be called transparent-opaque interface I guess. Actually you draw glass and water too, so should be called change-of-light-refraction interface heh heh), plus chunk edges. Occlusion on larger scale will be necessary once I manage to draw more stuff on screen. I have camera and chunk locations (and voxels' too). I don't know how it's normally done but I thought do to the large scale occlusion per-chunk and not per voxel.
    Last edited by Thyandyr; 03-11-2017 at 12:21 PM.

  5. #5
    Image3.jpg

    Oh yeah! Long and sturdy like my d***

    Problem was I had indices data type as UInt16

    I can now get back to chunk manager. And after that multiple VBOs. And then compacting the data; I don't need full single for texture type or texture coordinates and so forth. Then culling.... and...
    Last edited by Thyandyr; 04-11-2017 at 11:43 AM.

  6. #6
    I have elementary chunk management. It is slow but it works. It is fun to fly (backwards) and to see chunks get deleted in the distance from where you came and new ones to appear under you.
    Last edited by Thyandyr; 04-11-2017 at 11:09 PM.

  7. #7
    I think next I will work on moving the code that generates the vertex and indices arrays, from TChunk to TChunkManager. The latter has easy access to surrounding chunks so I can easier do some culling when drawing at the edge of the chunk. I thought at the same time I would also optimize the attribute data. https://www.khronos.org/opengl/wiki/...ttribute_sizes Not sure how to 'cheat' and insert four bytes instead of single, and how get 'use' them as bytes instead os a single in the shaders.




    Also, is there a better way to get undefined entry from TDictionary? Feels kind-a odd, that part getting a key/id from ListLoad
    Code:
    procedure TChunkManager.ListLoadChunksProcess(const Steps: Cardinal);
    var
      I: Integer;
      aID: String;
      C: TChunk;
    begin
      for I := 1 to Steps do
        begin
          aID := '';
    
    
          if ListLoad.Count > 0 then        // If we have entries in the ListLoad
            for aID in ListLoad.Keys do     // Get one of them
              break;
    
    
          if aID <> '' then                 // If we do have Chunk to load
            begin
              ListLoad.Remove(aID);         // Remove the Chunk ID from ListLoad
              C := ChunkLoadCreate(aID);    // Load Chunk from disk or create it
              ListLoaded.Add(C.ID, C);      // Add to list of loaded chunks
            end
          else                              // Break out, nothing to process
            break;
        end;
    end;
    Last edited by Thyandyr; 05-11-2017 at 07:03 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •