-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CSGMesh not working with procedural ArrayMesh #23364
Conversation
Seems to work well with the example script but now when I add a CSGMesh node and select a shape nothing appears (GLES2) servers/visual_server.cpp:969 - Condition ' array_len == 0 ' is true. Related: 7aea850#commitcomment-31031330 |
I'm not sure CSG works with GLES2... |
It works but have some performance problems and errors with CSGPolygon and CSGMesh. |
I was able to see it with GLES2. This patch does not touch the renderer. |
This should be tested with an index array before merging, I will be able to try that out later this evening. |
Tested again with the following script, it seems to work as expected: extends Spatial
func _ready():
var vertices = PoolVector3Array()
var indices = PoolIntArray()
var mesh = ArrayMesh.new()
var arrays = []
arrays.resize(ArrayMesh.ARRAY_MAX)
vertices.push_back(Vector3(0,1,-2))
vertices.push_back(Vector3(1,1,-2))
vertices.push_back(Vector3(1,0,-2))
indices.push_back(0)
indices.push_back(1)
indices.push_back(2)
arrays[ArrayMesh.ARRAY_VERTEX] = vertices
arrays[ArrayMesh.ARRAY_INDEX] = indices
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
var body = CSGMesh.new()
body.mesh = mesh
add_child(body) |
@NewNodeGames The shape not updating in the editor appears to be a separate editor bug. I noticed if you change to CubeMesh/SphereMesh/etc and no mesh is visible, you can get it to show up by changing another property on the CSGMesh. I may get some time to look more into that tomorrow. |
With this script appears the triangle without apply your patch and csg mesh node shows the primitives again. |
I did a fix in a bit less intrusive way, but thanks for finding out about this |
Those variables could really use more explicit names... :) |
I was trying to make some procedural CSG geometry using a CSGMesh and the triangles were not visible at all. To test, I made an empty scene with a camera at the origin (translation [0,0,0], rotation [0,0,0]), and a spatial node with the following script:
This should show a single triangle, but currently it doesn't. After some inspection, it looks like CSGMesh::_build_brush() had some typos with the input vertex and output vertex count switched around, and was not merging the vertices correctly. With my changes, the above code runs correctly and shows a triangle.