godotengine / godot

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

More helpful error message for `Condition "!v.is_finite()" is true` #97708

Open suhankins opened 1 month ago

suhankins commented 1 month ago

Tested versions

System information

Godot v4.3.stable (77dcf97d8) - Windows 10.0.22631 - GLES3 (Compatibility) - Intel(R) Iris(R) Xe Graphics (Intel Corporation; 32.0.101.5972) - 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz (8 Threads)

Issue description

Moving MeshInstance to an infinite or NaN coordinate causes this error

E 0:00:02:0077   instance_set_transform: Condition "!v.is_finite()" is true.
  <C++ Source>   servers/rendering/renderer_scene_cull.cpp:935 @ instance_set_transform()

That's great, but it's difficult to understand what does it mean. It would be better if error message read "Infinite coordinate provided to a mesh" or something like that so developers could more easily understand what happened and what do they need to look for in their code (i.e. divisions by zero)

Steps to reproduce

  1. Create a MeshInstance3D
  2. Set mesh to Cube
  3. Assign a new script to it
    
    extends Node3D

func _ready() -> void: self.position.x = NAN



### Minimal reproduction project (MRP)

N/A
huwpascoe commented 1 month ago

Also consider that this can happen if scale/rotation are set to crazy values so it needs to cover those cases too. "Invalid Transform" or something.

suhankins commented 1 month ago

I think "Invalid transform" is still too vague. It doesn't tell developer what did they do wrong and what they should do to fix it. Maybe "NaN or Infinity used in transform"?

Ideally it would tell you whether it's Infinity, -Infinity, or NaN, and in which property it is, e.g. "NaN in scale X", though I imagine it would be harder to implement.