Comments (4)
If we really want to allow full access to everything from multiple threads, we can just use specs
for the game. Using an ECS is overkill, though.
I don't think anything needs to be mutated by multiple threads, so an RwLock
won't be necessary. When #57 is resolved, we'll just put a small loop that drains a Receiver
and changes the World
into the main loop. #58 can also be resolved by simply passing a &mut World
.
Giving an add_handler
method to the event manager also has the problem of running into borrow checker and lifetime inference problems, which I'd like to avoid for now, so we'd have to pass an Rc<RefCell<...>>
. I think the current solution is good enough without requiring any major borrowck gymnastics.
from plantex.
Using an ECS is overkill, though.
I agree.
I don't think anything needs to be mutated by multiple threads, so an
RwLock
won't be necessary.
Whether or not we need an RwLock
or Mutex
does not depend on how many threads mutate the world, but how many threads have access to the world, right? If we only have one not-main thread (which doesn't access the world at all), then of course you're right and we can avoid the little overhead of atomic operations.
When #57 is resolved, we'll just put a small loop that drains a
Receiver
and changes theWorld
into the main loop.
I agree, I also planned on doing exactly that.
#58 can also be resolved by simply passing a
&mut World
.
To what? I'm not sure I understand what you are suggesting. #58 is also about updating the view.
The world can potentially mutated at multiple spots in our program. One important example is the player's interaction with the world. Currently, when a click event is forwarded to the player via the EventHandler
trait. The handle_event()
methods receives &mut self
, but nothing else. To mutate the world on a click we could
- add a
&mut World
parameter to thehandle_event()
method - queue the click event within the player and pass
&mut World
toPlayer::update()
to apply the event later - Save a
RefCell<World>
(or similar) within the player to allow mutating the world via&mut Player
(even&Player
...)
I don't like (1.) because it again mixes different concerns and grows function signatures. I don't like (2.) because this makes our code more complex than it needs to be and everyone thinks Rust is annoying
So again, I think that we should pass at least some inner-mutability-containers around to avoid those problems.
from plantex.
Well, we wouldn't need a queue of click events, just a bool flag (or a few)
would be enough. But other than that you're right.
from plantex.
This was tackled in #71. While we might want to improve the design in the future, I'll close this issue for now.
from plantex.
Related Issues (20)
- Fix License badge and usage info
- Tracking issue: shadow HOT 8
- Tracking issue: HDR and friends HOT 5
- view frustum culling to improve performance #RenderWhatMatters HOT 2
- Lower-resolution bloom HOT 1
- Optimize performance of particle system HOT 1
- CI: Validate Shaders
- Move Vertex Buffer building to chunk loader thread HOT 2
- GLSL 4.00 required HOT 1
- instant segfault on start HOT 9
- Git credential.helper Fehler HOT 3
- glium dependency has a broken link HOT 4
- Cargo build fails HOT 1
- Fails to execute HOT 1
- Use configuration parameters for context creation
- Implement instancing for pillar rendering HOT 1
- Dynamic Chunk loading is off by a bit HOT 1
- Write down convention for shaders HOT 1
- Fix wrong indexing of Inner_Position HOT 1
- Perspective matrix should use the correct aspect ratio
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plantex.