Skip to content
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

Feature/4.0/update core types #465

Merged
merged 18 commits into from
Jul 7, 2023

Conversation

piiertho
Copy link
Member

This updates all core types for godot 4.0.

@piiertho piiertho added the GD4 label May 24, 2023
@piiertho piiertho requested review from chippmann and CedNaru May 24, 2023 15:36
@piiertho piiertho self-assigned this May 24, 2023
@piiertho piiertho force-pushed the feature/4.0/update-reimplemented-core-types branch from fecd58f to 499a0cb Compare May 24, 2023 15:57
/**
* Returns true if the AABB is empty.
*/
fun hasSurface(): Boolean {
Copy link
Member

@CedNaru CedNaru Jun 1, 2023

Choose a reason for hiding this comment

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

Comment is incorrect, it returns false if empty

Copy link
Member Author

Choose a reason for hiding this comment

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

Former comment that I did not checked. Will change it.

/**
* Returns true if the AABB is flat or empty.
*/
fun hasVolume(): Boolean {
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@@ -535,6 +587,237 @@ class Color(
val r = (hex and 0xFFFF) / 65535.0
return Color(r, g, b, a)
}

private val namedColors = arrayOf(
Copy link
Member

Choose a reason for hiding this comment

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

Should add more consistency here. Those names already exist as variables, meaning we create them two times in two different ways (one with constructor and one with hex). Should be merged so we only create them one time.

val Double.signbit: Boolean
get() = sign < 0

fun cubicInterpolate(
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't that go in the MathFuncs.kt you created in that same PR ?

Copy link
Member

@CedNaru CedNaru left a comment

Choose a reason for hiding this comment

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

Seems good overall, didn't expect that many changes to core types since the Alpha. But I got a few nitpicks and questions

Copy link
Contributor

@chippmann chippmann left a comment

Choose a reason for hiding this comment

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

And just as a note: once we redo the tests, we should probably create a test case for each of the reimplemented functions of the core types to make sure they match the implementation of the "real" core types.

Comment on lines +423 to +425
require(size.x >= 0 && size.y >= 0 && size.z >= 0) {
"AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a good idea to crash here? Shouldn't we log an error and return false instead?
I know godot "crashes" in such cases but don't we then have issues if such a call originated from the cpp side?

Same for other usages of require and the likes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should better explain to jetbrains they have a vision regarding preprocessors that is not compatible with game industry.
Here I would expect a debug version of engine to have this require call and crash, to spot problems asap, and a release version without this call.
Anyway, this should not be modified in this PR IMO, as we have a lot of already existing require in core types.

Comment on lines 802 to 804
// Check if the amount of hex digits is valid.

// Check if the amount of hex digits is valid.
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate comment

Comment on lines 810 to 812
// Check if each hex digit is valid.

// Check if each hex digit is valid.
Copy link
Contributor

Choose a reason for hiding this comment

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

again

Comment on lines 311 to 312
// Flip quaternions to shortest path if necessary.
// Flip quaternions to shortest path if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate

Comment on lines 320 to 321
// Calc by Expmap in from_q space.
// Calc by Expmap in from_q space.
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate

Comment on lines 381 to 382
// Flip quaternions to shortest path if necessary.
// Flip quaternions to shortest path if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate

Comment on lines 390 to 391
// Calc by Expmap in from_q space.
// Calc by Expmap in from_q space.
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate

@@ -36,7 +36,7 @@ class StringName : NativeCoreType {
return TransferContext.readReturnValue(VariantType.STRING, false) as String
}

//TODO/4.0: Implement
operator fun <T> invoke(stringOperation: String.() -> T): T = toString().stringOperation()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what I'm looking at here. What would a typical use case of this invoke operator look like?

Copy link
Member

Choose a reason for hiding this comment

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

StringName has a LOOOOOOT of functions that would be cumbersome to reimplement, even as Bridge, and they happen to be the same as the regular Godot String. So instead of spending time implementing that, we decide to just add a utility function that can transform a StringName using the regular Kotlin String methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm i see. but then i would a dd a documentation on the function with a link to this page and a hint that one can reimplement those functions with this operator, and probably also provide an example of such a reimplementation using this operator

@piiertho piiertho requested a review from chippmann June 5, 2023 08:07
@piiertho piiertho requested a review from CedNaru June 5, 2023 08:07
@piiertho piiertho merged commit deadb5a into master Jul 7, 2023
@piiertho piiertho deleted the feature/4.0/update-reimplemented-core-types branch July 7, 2023 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants