Skip to content

VariantParser: Fix reading negated identifiers, replace inf_neg with -inf#101618

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
aaronfranke:var-parser-neg-ident
Mar 7, 2025
Merged

VariantParser: Fix reading negated identifiers, replace inf_neg with -inf#101618
Repiteo merged 1 commit into
godotengine:masterfrom
aaronfranke:var-parser-neg-ident

Conversation

@aaronfranke
Copy link
Copy Markdown
Member

@aaronfranke aaronfranke commented Jan 16, 2025

This PR is a subset of PR #100414 that fixes VariantParser to allow for reading negative identifiers in .tscn files, and also changes the serialization of negative infinity from inf_neg to just -inf. In the current master, the code assumes that anything starting with - is a finite number.

To test this PR, I made a new project with a Node3D and gave it a tool script like this:

@tool
extends Node3D

func _ready():
	print(position) # Prints (0.0, 0.0, 0.0) the first time, then (inf, -inf, nan) after the scene is saved and re-opened.
	position.x = INF
	position.y = -INF
	position.z = NAN

Note: The reason I previously did not have this change separated out is because I wanted to go straight from inf_neg to -INF instead of going through -inf first, but it seems PR #100414 was a bit too much to review in one go.

Note: We should also cherry-pick most of these changes to older Godot versions, except for the inf_neg writing change, so that older versions can read new files saved with -inf, but the old versions should keep writing inf_neg to match older patch releases in those minor versions. However, this is not vital since -inf is a very rare value to serialize to a .tscn file, especially because it is currently not possible to read or write such values in the editor inspector.

@aaronfranke aaronfranke added this to the 4.4 milestone Jan 16, 2025
@aaronfranke aaronfranke requested a review from a team as a code owner January 16, 2025 00:59
@Repiteo Repiteo requested a review from RandomShaper January 24, 2025 20:30
@akien-mga akien-mga changed the title VariantParser: Fix reading negated identifiers, replace inf_neg with -inf VariantParser: Fix reading negated identifiers, replace inf_neg with -inf Jan 30, 2025
@aaronfranke aaronfranke modified the milestones: 4.4, 4.5 Feb 13, 2025
Copy link
Copy Markdown
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

@Repiteo Repiteo merged commit 9c07d31 into godotengine:master Mar 7, 2025
@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented Mar 7, 2025

Thanks!

@nikitalita
Copy link
Copy Markdown
Contributor

the rtos_fix change ends up breaking compatibility with version 3 resources, when we explicitly support that in VariantWriter::write when the p_compat flag is true; we ought to respect that and write inf_neg if it is true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants