-
Notifications
You must be signed in to change notification settings - Fork 0
Concurrent chunck generation #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
5763f5e
d4cee84
a728e5c
896a2e8
924db76
fabf0df
ce0838e
6d523bf
1894cc0
380efbb
8b4d0de
63f71b6
5d79769
88646cb
dfcdb35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| package world | ||
|
|
||
| import ( | ||
| "github.com/go-gl/mathgl/mgl64" | ||
| "maps" | ||
| "math" | ||
| "sync" | ||
|
|
||
| "github.com/go-gl/mathgl/mgl64" | ||
| ) | ||
|
|
||
| // Loader implements the loading of the world. A loader can typically be moved around the world to load | ||
|
|
@@ -98,21 +99,31 @@ func (l *Loader) Load(tx *Tx, n int) { | |
| if len(l.loadQueue) == 0 { | ||
| break | ||
| } | ||
|
|
||
| pos := l.loadQueue[0] | ||
| c := tx.w.chunk(pos) | ||
|
|
||
| l.viewer.ViewChunk(pos, l.w.Dimension(), c.BlockEntities, c.Chunk) | ||
| l.w.addViewer(tx, c, l) | ||
|
|
||
| l.loaded[pos] = c | ||
| w := tx.World() | ||
| w.loadChunkAsync(tx, pos, func(tx2 *Tx, chunk *Column) { | ||
| if tx == tx2 || l.World() == tx2.World() { | ||
| l.viewChunk(tx2, pos, chunk) | ||
| } | ||
| }) | ||
|
HashimTheArab marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| // Shift the first element from the load queue off so that we can take a new one during the next | ||
| // iteration. | ||
| l.loadQueue = l.loadQueue[1:] | ||
| } | ||
| } | ||
|
|
||
| // viewChunk adds chunk to the Viewer. | ||
| func (l *Loader) viewChunk(tx *Tx, pos ChunkPos, c *Column) { | ||
| if l.viewer == nil { | ||
| return | ||
| } | ||
| l.viewer.ViewChunk(pos, l.w.Dimension(), c.BlockEntities, c.Chunk) | ||
| l.w.addViewer(tx, c, l) | ||
|
|
||
| l.loaded[pos] = c | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Async callback writes to map without mutexHigh Severity
Reviewed by Cursor Bugbot for commit 8b4d0de. Configure here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. map is protected by transaction
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the finding is still valid pls ask ai |
||
|
|
||
| // Chunk attempts to return a chunk at the given ChunkPos. If the chunk is not loaded, the second return value will | ||
| // be false. | ||
| func (l *Loader) Chunk(pos ChunkPos) (*Column, bool) { | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.