Anasky Show full post »
I just noticed your other code m_ClipmapView->xpos = m_ClipmapView->xoffs + Main->m_Player->GetPosition( ).x;

Did you ever get that to working?  Perhaps you need to translate your GetPosition.x into an appropriate scale for VF?  For UE it was just a 0.1 scale factor
OriginX + UEPlayerPos.x * 0.1

Also I discovered when I was having gaps issues, I tried turning down my max LoD (so I could see less of the world) and I also ramped up the cells baked and other adjustable levels, and noticed all of my gap and other issues completely disappear.

edit: I realized I misinterpreted some of your comments.
I think you had the right code in clsVoxelFarm::Update and in the appropriate location. 

You had previously commented out to fix another issue,  have you tried un-commenting that out now that the other issue is resolved?
0 0

Thanks for the quickly reply namrog 😉

Unfortunately however, that method results in nothing appearing on-screen.. I switched the pos from {200 000.0, 50200.0, 200 000.0} to {0, 0, 0} at the init, while keeping the offset on that position. Then modified the m_ClipmapView->pos to playerLocation. This resulted in the clipmapview thinking I wasn't even close to the offset.

This makes sense though given that the code you supplied above does the same thing as I was already doing.
In that code the clipmapView->pos is set to focusVec.X*UE_TO_VOX + ORIGINX, whereas I was doing m_ClipmapView.xoffs + Main->m_Player->GetPosition( ).x, which should result in the correct thing.

I couldn't find the SetClipmapviewFocus function though, and assumed that was part of the Unreal plugin, so I went for the code you supplied extracted from that function.

0 0
When you switched the pos from the {200k, 50k, 200k}  to 0,  did you also remember to set the offset to those values instead?  In your earlier code, your offset was based upon your initial pos.

void AVoxelFarmWorldActor::SetClipmapviewFocus(const FVector& uepoint)
is part of VoxelFarmWorldActor.cpp which is from the Unreal engine plugin.  

Can be found without UE though at "...\Voxel Farm\SDK\Demo.Unreal\Plugins\VoxelFarmPlugin\Source\VoxelFarmPlugin\Private"

However, while you aren't using UE, its still c++ and can contain various nuggets of usefulness. 
0 0

Yeah, I did do that ^^ From as far as I can tell, the offset doesn't really do anything, but I could be wrong.

It's a bit of a shame that it's so black-box that if you end up having a bug, it's reallyy hard to find it...

0 0
So to start fresh and re-examine the problem pragmatically.

1. All the crashes mentioned from earlier in this thread are resolved from DestroyData stuff, right?

2. Meshes are randomly disappearing in certain areas, you believe it to be related to the clipmapview and players position.

3. When investigating #1 and trying different things, did you maybe change something from an earlier version that you might have inadvertently broke something else?  If you haven't already, make at least a local git repo to track changes and versions/commits, even if you bounce back and forth a lot, just for historical value of accidental edit or forgot (i'd recommend sourcetree, or just commandline git)

4. Let's isolate the disappearing,  does when you load in, if you do NOT move the player,  are there gaps?  Are they randomly appearing/disappearing while in the game?  Are they always the same areas?  
Does it appear like the gaps are 'cell'/chunk sized? (40x40x40 voxels)

Can you provide any picture/screenshot of this behavior? 
0 0

(I was writing this post for 2 hours, followed by a power outage, but here we go again!)

1. Yeah they are 😉 I probably should have been more clear about that. The only crash I have left atm (sometimes) is when the application is shut down, but that's avoidable by letting Windows clean up the memory instead of doing it myself, so I'm just ignoring that.

2. What I discovered yesterday, that if I instead of drawing all valid VBOs, I only draw the ones that are in renderScene->begin() / renderScene->end(), I end up with chunks missing in a rather consistent location. If I draw all valid VBOs, the world is jittering and random chunks disappear randomly. (a chunk is considered valid when it hasn't been deleted and when a new VBO has not yet been generated for that chunk). I'm assuming the renderScene method is the more correct one, so I'll be going onward with that (it still causes missing chunks).

3. I'll be comparing the code with the demo, seeing as that as soon as I added movement, it never fully worked to begin with (as you can see in one of the previous posts). See below.

4. With the renderScene drawing method, the gaps are already existent pre-movement (everything is displaying properly using the draw-all). Using the renderScene method, the gaps are consistent in location, although not consistent in whether or not they show up. They show up about 70% of the time.


Code compare:
- Variables are moved from the main function to the class variables. The class itself is created on the heap, and all variables are created on the heap as well.
- The demo uses a separate clipmapView to initialise the materials. My version uses the same clipmapView for both.
- Their movement is done through direct manipulation. Mine is doing through the location of the player.
- My version has a time delay between initialisation, and the actual start of the thread.
- Demo runs rendering on the DrawGLScene function, mine runs it in the main thread. The demo has the cell generation on the main thread. Moving mine to the main thread, makes it more consistent but still goes wrong from time to time. It also drops my FPS down significantly whenever it's loading cells.
- Demo sets scale during rendering, I set it during initialisation.
- I keep track of the cells in a TMap<CellId, TVector<VBO>> rather than a TMap<CellId, VBO> to be able to delete them safely without multithreading issues with the rendering thread.
- Demo runs using wireframe, I'm using a single buffer containing vertices, uvs, and normals.
- Demo saves VBOs per cell, then per medium. I save them per medium, then per cell.
- The demo works! ... ':-D


Disappearing chunks

Same chunks, sort of

These seem to be the chunks that are disappearing??? (on the left, above the terrain)

Clearer image of the above

And another example in a single image (on the left, slightly above the disappeared terrain)
And sometimes it works

0 0
I forgot to include the latest version of the code, woops.
0 0

for (int a = size - 1; a > 0; --a)
l_Vertices.push_back( glm::vec3( cellData->vertices[ medium ][ a ].x, cellData->vertices[ medium ][ a ].y, cellData->vertices[ medium ][ a ].z ) );

Not sure if it is related, it seems "a" never hits zero. This leaves the first vertex in the array out of the loop.
0 0
Fixed that, it removed a couple of the tiny fragments of the world that were see-through 😉 Still has a couple left, but not my main concern right now... Thanks though ^_^
0 0

Managed to find the issue:
1. I had two loops in one another, both using "int i", meaning 2 variables with the same name
2. Apparently the scale of a cell can change during runtime, post-creation. I'm currently re-creating the ModelMatrix every frame which seemed to fix the issues.

Thanks for the help guys! 😃

0 0