snake-biscuits / io_import_rbsp

Blender Addon for importing Titanfall Engine maps
GNU General Public License v3.0
15 stars 1 forks source link

Load Faster & Use Less RAM #1

Open snake-biscuits opened 2 years ago

snake-biscuits commented 2 years ago

Use the bpy .foreach_set method with NumPy to speed up mesh assembly. Can also use the new Vertex lookup method from bsp_tool/src/glview.cpp to save some time

VertexReservedClass -> NumPy array will likely be the hardest step

snake-biscuits commented 1 year ago

bpy.types.Mesh.from_pydata might be a better solution[^1] Profiling tools do exist,[^2][^3] and it is also possible to run Blender "headless" to compare different approaches. Regardless,: finding a performant way to load large maps (e.g. Apex Legends maps) will make development much easier.

[^1]: b3d.interplanety.org: How to create mesh through the Blender Python API [^2]: wiki.blender.org: Profiling Python Code [^3]: devtalk.blender.org: Plugin-Profiler | benchmark / debug your bpy work

snake-biscuits commented 1 year ago

Another option would be to merge meshes for each model, Blender attaches a lot of metadata to objects, so reducing groups could be helpful

Maintaining the "mesh groups" defined by bsp.LEVEL_INFO for worldspawn should help with visibility etc. This would allow for hiding or even skipping decals & skybox, as well as clearly detecting transparent geometry & materials

snake-biscuits commented 1 year ago

Another option would be to merge meshes for each model

Specifically, merging meshes into models before generating them, which should improve import speed (theoretically)

snake-biscuits commented 1 year ago

Just wrapped up an update for faster load times in https://github.com/snake-biscuits/bsp_tool/issues/80 Should be able to update to that version of bsp_tool pretty soon Though I might make it bsp_tool version 0.5.0

snake-biscuits commented 1 year ago

Mesh(...).from_pydata is the way to go (no numpy required) uvs & vertex colour could get tricky

I do need to take a proper look at vertex colour Need to check w/ Fifty & others to check VertexReservedX structs are all synced up That's for another issue though