godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.57k stars 20.34k forks source link

ArrayMesh surface_remove() missing in 4.0 #67181

Open Xyotic opened 1 year ago

Xyotic commented 1 year ago

Godot version

4.0 beta 1

System information

Windows 10, Nvidia RTX2080

Issue description

In 4.0, ArrayMesh is missing the 'surface_remove' method and there doenst seem to be an alternative. Accessing the surface array directly and removing an entry also doesnt seem to work. Currently the only way is to use 'clear_surfaces'. Which I think would have a negative performance impact if you'd always clear all surfaces and set new ones. In 3.x 'surface_remove' is still present.

Steps to reproduce

Add a surface to an ArrayMesh via 'add_surface_from_arrays' and try to remove it.

Minimal reproduction project

No response

Calinou commented 1 year ago

See https://github.com/godotengine/godot/pull/41767.

Xyotic commented 1 year ago

Is there a workaround for now that doesnt include the use of 'clear_surfaces'? @Calinou

Zireael07 commented 1 year ago

Seconding, I was using this for some very simple deformations and had to give up on those in 4.0

Xyotic commented 1 year ago

Removing surfaces also seems to be missing from RenderingServer3D. So this server cant be used as a workaround.

prominentdetail commented 1 year ago

This makes it difficult to add surfaces to a mesh without it. Sure you can clear all the surfaces, but if you are relying on the previous surfaces to generate new surfaces, you don't want to clear them all when you need to add each one separately.. :( I'm using MeshDataTool's create_from_surface(mesh, 0).. then commit the surface back into the mesh(while removing the original). So I need to do each surface at a time and I can't do it if I clear the surfaces, because then it just clears ones that I've added.

Edit: Okay, so a workaround I found., I am duplicating the mesh, and refering to the duplicated mesh's surfaces while I clear the original mesh's surfaces. This makes things more bearable. I just clear all the surfaces once, and then create the new surfaces from the duplicated mesh that I've stored at the start.

ze2j commented 1 year ago

I don't know if someone started some work on it, but I started to (re)implement this function and I should be able to make a PR next week for both OpenGL and Vulkan renderers.

nvanfleet commented 1 year ago

I hope this gets in eventually