Replies: 1 comment
-
Hey @freylint! First off, thank you for starting this discussion! I'd like to emphasize that constructive criticism is always welcome, and if your analysis is helping you improve your understanding of what needs to be done, then keep going! However, I have to say that from my perspective, critiquing the current implementation seems a bit beside the point. What's important, in my opinion, is what purpose that implementation achieves, and what else we want it to achieve going forward. What the code does specifically to achieve that purpose is secondary, an implementation detail. And not a very deliberate implementation detail at that. It's just how it ended up, given the goals I had when writing it, and the constraints I was working under. It would look very differently, if someone else had written it, or if I had put more effort into it, instead of focusing on the kernel side. So you don't need to convince me that it has to change. Of course does, we want it do more interesting things 😁 I would suggest we go about it like this:
As for step 1., cataloguing what the code currently does, here's my first attempt:
This is a short list, and a lot of it doesn't pull its own weight (like the non-trivial and non-working camera control). Which is why I think that a total rewrite that doesn't preserve every detail of the current implementation could be an option. As for step 2., what I'd like to see in the future, here's a partial list (partial, because I'm sure we can come up with a lot more, given time):
As for steps 3. and beyond, if I were to do this on my own, I would probably keep extending the current But as I've stated before, I'm not going to work on this any time soon. Since you seem willing to do it, I'm happy to give you a lot of leeway. If you think Bevy is the right way forward (just using it as an example, I know you've expressed doubts about that), I'm happy to go with that, even though I would have done it differently. Okay, enough rambling. I'd like to address a few specific points from your post.
That's interesting! I never though about it in this way, but I do think it's on point.
Two comments about that:
|
Beta Was this translation helpful? Give feedback.
-
Relevant Matrix Conversation
Based on your response I feel its best to first justify an ECS, then justify Bevy, and finally Propose a potentially more fitting alternative which incorporates my disagreements with the bevy project.
Note: Due to the length of this I've inserted anchors into this post. Please quote (or anchors in matrix) when referring to a specific section.
Table of Contents
Where We Are
The way I conceptualize the current implementation is that it functions as a very low level implementation of the actor models. Its quite elegant at this scale, but I worry that it will run into ownership issues as fj-viewer is scaled or forked to build a hypothetical editor.
I quite like the efficiency of the current implementation, but I think it won't scale if fornjot wants to scale past a model viewer.
The issue I have with this is covered in more detail in Catherine West's blogpost on the benefits of ECS in gamedev or its associated talk. I highly suggest you are familiarize yourself with these before participating in this discussion.
Directions and requirements
I see four architectures we could go with
The Current Direction
My issues with the current architecture are more or less already covered in Catherine's talk, but I'd like to go through an example in the actual project that demonstrates my concern for continuing in this direction, the interaction between input and camera rotation.
First lets take a look at the start of this interaction, the (input)Handler struct:
So viewing this struct definition in isolation, I parse it as something like:
where
movement
,rotation
, andzoom
are caches for messages to be sent to the camera.That seems good so far. How about we look at how this data gets used?
Allright, so after reading this I can update my parsing of
(input)Handler
.And due to the mutation of
Camera
in the function signatureI start to conceptualize this as a function that updates the camera position and rotation by sending a mutation request via the
CameraMovementRequest
message structure.so weve got a data flow like: User Input -> InputHandler -> MovementRequest -> Movement(Camera)
Which in this high level representation of what the code is doing is fantastic!
Let's take a look to see what the code is actually doing though.
So I'm reading this as applying a movement to
camera
by passing a mutable reference to camera to the movement type?This seems super confusing by itself so lets look at the function we're calling here.
Okay so the
Movement
type is directly mutating the camera state.This is a functional, and when I'm not being unfair for analytical purposes, quite understandable function, but I think there's room for improvement.
This seems to be modelling the behavior of the actor model using low level rust.
Which admittedly is quite an awesome achievement.
It does, however, make me question if the code would be easier to understand and maintain if we stepped up a level of abstraction and formally adopted the actor model.
Switching to a more formal actor model
Using an existing ECS
Using a bespoke ECS
Beta Was this translation helpful? Give feedback.
All reactions