flame-engine / flame

A Flutter based game engine.
https://flame-engine.org
MIT License
8.98k stars 879 forks source link

feat: Make it easier work with the Mesh class [flame_3d] #3212

Open luanpotter opened 3 days ago

luanpotter commented 3 days ago

Description

Currently it is quite hard to operate with the Mesh class, because the list of surfaces is kept private.

I understand the concern with immutability, and the fact that the aabb must be recalculated when anything change. Sadly I don't think Dart provides us with patterns to fully automate updating the aabb. We need a way to update the meshes, so this is a compromise:

This also adds an add method that takes a Surface object witch is extremely handy (even though it allows for post-modifications).

If we prefer to go a truly fully immutable route, we instead need helper methods to copy and recreate meshes with given set of changes. I am happy to take a stab at that option too.

Checklist

Breaking Change?