The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I'm migrating my Godot 3.5.1 project to Godot 4.1, using a debug_draw module to draw a 2D grid in a plane of 3D scene, is running ok with 100 x 100 grid lines, but when i extend grid size to 200 x 200 only first 256 lines are shown, and then i've a runtine error in debugger window that shows:

  • E 0:00:01:0151 debugdraw3d.gd:292 @ process(): Condition "mesh->surfacecount == RenderingServer::MAXMESH_SURFACES" is true.
  • <C++ Source> drivers/gles3/storage/meshstorage.cpp:110 @ meshadd_surface()
  • debugdraw3d.gd:292 @ process() MeshInstance.gd:503 @ physicsprocess()

This occurs when i run mi.mesh.surface_end() instruction, and the mesh object is configured in _init() as:
- mi = MeshInstance3D.new()
- mi.mesh = ImmediateMesh.new()

How can i increase MAXMESHSURFACES value of RenderingServer constant? I can't find a parameter to change in Project - Settings - General - Rendering...

Thanks & hugs! Mikel

Godot version 4.1
in Engine by (14 points)

It looks like this happens because your mesh contains too many surfaces. This is a constant because there is no practical reason to want so many, so it was fixed to some high maximum to make the code simpler I guess.

Is there a reason you use so many? It sounds like a misuse. Surfaces are needed only when you want more than one material in your mesh. Usually to draw a grid you should only need one.

Yes i've solved the issue! thanks Zylann for your clarification :)

The question is that when i migrate this debugdraw addon script from GD3 to GD4, i've adapted from ImmediateGeometry to MeshInstance3D+ImmediateMesh, and then translated code from ig.begin(Mesh.PRIMITIVELINES) to mi.mesh.surfacebegin(Mesh.PRIMITIVELINES), that is located in a for loop to draw lines added to itemstodraw Array, then i've MAXMESHSURFACES assertion error in GD4 that before don't occurs with ImmediateGeometry in GD3.

The solution for now is to move mi.mesh.surfacebegin(Mesh.PRIMITIVELINES) out and before the for loop where array items are drawn, and mi.mesh.surface_end() after it, so don't increase the surfaces avoiding the mistake of exceeding the limit of meshes, drawing all grid lines with the same surface ok.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.