Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
124 stars 2 forks source link

Rework core data model implementation #702

Open Frooxius opened 8 months ago

Frooxius commented 8 months ago

Is your feature request related to a problem? Please describe.

FrooxEngine's data model is one of the most powerful features, upon which nearly everything else is built. It provides implicit synchronization and persistence, with very little effort, giving Resonite it's highly dynamic and collaborative nature.

However currently this comes with certain costs, as some common usage patterns end up causing significant amount of overhead. Notably any behaviors that are continuously changing the data model (such as IK or Dynamic Bones) have their changes explicitly tracked every single frame.

The implementation of the data model has also been done in a way that makes it easier to reason about the data model function, but has significant performance and memory overheads and poor cache locality. There is significant overhead associated with every field on a component for example, both during initialization and runtime.

Lastly, the data model still has some limitations and specifics for particular type of application - a 3D game engine application. Its versatility and use cases go beyond that, but those are harder to leverage with current implementation.

Describe the solution you'd like

I've been working on a design for a new fresh implementation that will resolve the above problems and provide a foundation for many subsequent engine optimizations and expansions.

There are many things that come to this design to describe in detail here, but here is a quick summary:

Describe alternatives you've considered

There are no viable alternatives if we want to resolve above problems. Incremental updates to the data model would not be sufficient.

Additional Context

This will not be worked on immediately as of this issue. However this is the first step we'll take when we start working on major optimizations, as the data model is major source of performance issues and a pre-requisite for many more performance optimizations.

Many additional optimizations and applications will be built on top, but this is going to be the first step.

Reworking the data model will likely be a large process too, especially to ensure compatibility with previous one.

shadowpanther commented 8 months ago
  • Mixing different systems within a domain will be supported too. This will allow part of the data model to be synced to particular devices, without the overhead of the entire 3D world - allowing for light clients to join (e.g. allowing users to join on mobile devices with mostly just voice data and simplifies representation of the user or using the data model to sync state to simpler IoT devices (like Raspberry Pi) without needing to load the entire 3D world)

Does that mean that for example the Headless would be able to just take the role of syncing and streaming "hub" and discard all 3D info and related calculations, lowering the load on itself?

Frooxius commented 8 months ago

@shadowpanther No, it doesn't mean that.

If you want to host 3D session, it needs to host the 3D systems. You can't really host those without "hosting" them.

We can have the headless skip certain things and calculations that are known to not be necessary, but problem is determining what's not necessary - say someone has behavior that depends on the user's IK being solved and it runs on host (headless) - not solving the IK would break this behavior.

Similarly if there are systems, say culling that determine on the headless who gets what data streams, they still need to be computed.

What you're thinking is more of a "relay", but you'd still need an actual "host" of the session that computes the session stuff.

shadowpanther commented 8 months ago

Okay, that's fair.

gameboycjp commented 8 months ago

I wonder if giving Domain Chunks the ability to be saved separately, or even hosted by external clients, would be viable? Could be useful for, say, a world with a bunch of user-owned rooms.

Frooxius commented 8 months ago

@gameboycjp That'll be inherent property of domain chunks and the major reason for them - they allow for sharding - splitting large sessions into multiple hosting nodes.

TisFoolish commented 7 months ago

Will this allow for stuff like 2D slots that only have an x and y, simple rotation, etc? Will it affect UIX? Having 2D slots could make UIX conceptually easier if their values directly tie into UIX.

ShadowJonathan commented 7 months ago

I saw someone mention the idea of making a 4D space, a-la 4D toys and 4D golf.

Would such a thing be directly possible with domains? Or would it require mods to introduce new datatypes?

Frooxius commented 7 months ago

I saw someone mention the idea of making a 4D space, a-la 4D toys and 4D golf.

Would such a thing be directly possible with domains? Or would it require mods to introduce new datatypes?

Nothing ever requires mods, anything can be implemented if we prioritize it.

The question here is, will we introduce official support for 4D worlds.

I'd say that's more unlikely to happen anytime soon, given how niche that is and how complicated that actually is - it's not just coordinates, but also rendering, physics, interactions and so on. There is a lot of complex stuff you need to do for 4D worlds and most of it you can't get off the shelf.

This means it's likely months, possibly years of work to have a fully featured support for 4D worlds. And given how niche that is, we're very unlikely to make that kind of time investment over other features.

It would have to be more likely implemented through community support. The in-game mechanisms should be sufficient to achieve that.

BaxterOttoman commented 5 months ago

I mentioned an idea at Rucio and he suggested I put it in here. I think it may be useful to have a data type for values that are streamed out which don't need to be reliably received. They can be lost and don't need to be acknowledged and don't cause delta messages.

Nytra commented 5 months ago

That's basically a ValueStream which is already used for some stuff like voice and user position streams, which is why those things never desync. They are just not accessible to use directly in creations right now.

BaxterOttoman commented 5 months ago

Yeah, I think that kind of thing would be useful to have access to for a lot of things.