Blender_bevy_components_workflow icon indicating copy to clipboard operation
Blender_bevy_components_workflow copied to clipboard

Blender's children are transferred over to bevy

Open BUGO07 opened this issue 1 year ago • 9 comments

Please add the mesh data to the first parent component in blender or change the blender plugin to allow not dealing with what's shown in the first picture because otherwise there's just a lot of entities in the scene and it is costing performance, in just a small scene that would not have more than 60 entities otherwise i get 193 entities because of this, and it severely hurts performance to the point where with a 12th gen i5 and a 1080Ti i get ~300fps while doing this normally in bevy i had more than triple that

image

image

BUGO07 avatar Apr 23 '24 13:04 BUGO07

this can also mess because there is no direct way to add colliders (using bevy_rapier3d) so it has to be implemented by code and for mesh colliders Handle<Mesh> has to be queried from the children and when the collider is appended to the child but i also want to modify the velocity component which i added through blender if i try to match it with the entity hit by a raycast it won't match since velocity belongs to the parent while the collider belongs to the child, for shape colliders this can be avoided but for mesh colliders its way more expensive performance-wise to avoid this.

BUGO07 avatar Apr 23 '24 13:04 BUGO07

so basically what i'm saying is that the child entities should not exist and every component should belong to the parent

BUGO07 avatar Apr 23 '24 13:04 BUGO07

Hi @BUGO07 !

  • for the nested "mesh" objects: unfortunately, this is how the gltf loader in Bevy handles the gltf files (and it is actually the standard way of dealing with gltf files, I did some digging and other engines like THREE.js seem to do it similarly) I am not the biggest fan either , although I never noticed significant performance loss, it is indeed not ideal.

    • Have you tried loading a gltf file generated from Blender (not using any of the tooling in this repo) to double check this ? Btw Blender 4.0 has added an additional gltf exporter setting (that I have not yet tried out) perhaps that could help: image
    • if that solves your issue, a new version of auto_export will soon allow you to use all the settings of the standard gltf export
    • if that fails, the only other option I see is processing the whole hierarchy of gltf files in Bevy after they have been loaded, or creating an asset (pre)processor that would transform the gltf file in advance
  • for colliders: there might be a few better solutions: have you checked out the example code in this repo, which processes meshes of entities in order to generate colliders for example ? It is relatively trivial to implement, despite the annoying parent/child relationships.

kaosat-dev avatar Apr 23 '24 21:04 kaosat-dev

Thanks for the response, I will try these in a few hours.

BUGO07 avatar Apr 24 '24 10:04 BUGO07

Okay, I'm using Blender 4.0 and for me the default bevy glTF export only shows GPU Instances in the Scene Graph section, it doesn't show Flatten Object Hierarchy or the other two, which is weird... I'll try a bit more digging.

BUGO07 avatar Apr 24 '24 19:04 BUGO07

I'm updating to 4.1.1 (the latest version right now) to test if it's available there

BUGO07 avatar Apr 24 '24 19:04 BUGO07

4.1.1 does have the Flatten Object Hierarchy option but I don't see any difference between the auto export and blender's default glTF 2.0 export :/

BUGO07 avatar Apr 24 '24 20:04 BUGO07

Actually, I had pressed Ctrl+S after exporting because I guess I'm used to it but by actually using blender's default export for some reason my current collider system doesn't work, there's no colliders to any entities, I'll look into this

BUGO07 avatar Apr 24 '24 20:04 BUGO07

Normal exporting doesn't seem to include any bevy components in the actual glb file (and it still has the nested children), but for some reason the file is actually way bigger, it was 47kb with auto export but it is 5567kb now with normal export, I didn't think auto export was necessary for bevy components to work..

EDIT: I guess it is because with blender's default export it takes all the scenes in so it has normal size + the blueprint sizes

EDIT 2: After thoroughly inspecting the default export settings I found out I didn't have custom properties on, because of this bevy_components pretty much didn't work, after enabling that and trying Flatten Object Hierarchy option on and off I see no difference, I guess only thing I have left to do is flatten it myself :/

BUGO07 avatar Apr 24 '24 20:04 BUGO07

Update from the Blenvy rework: we can now add children to the mesh object itself, which is extremely useful for things like Avian integration or adding NotShadowCaster/NotShadowReceiver.

I think this should address the issues you had even better than simply flattening the hierarchy :) As such, I'm voting to close this.

janhohenheim avatar Aug 03 '24 21:08 janhohenheim

closing this one as , as @janhohenheim says this is now resolved in Blenvy, albeit not by flattening the hierarchy. Feel free to re-open if you disagreed :) (btw I am not going to add hierarchy flattening, as one of the aims of Blenvy is to match everything from Blender as close as possible, including hierarchies)

kaosat-dev avatar Aug 18 '24 11:08 kaosat-dev