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/kotlinesque #548

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Feature/kotlinesque #548

wants to merge 1 commit into from

Conversation

elect86
Copy link
Member

@elect86 elect86 commented Jun 14, 2023

As titled, this is an attempt for making Scenery more confortable for Kotlin users

I tried to leave the style as much as possible untouched

…e first "Basic" test:

- added some fake constructors call for initializing the object directly after the instantiation
- added an `inline reified` counterpart for `Image.fromResource`
- added an `Image::toTexture` function
- added the operator overloading `plusAssign` for adding element(s) to the scene
- minors
@ctrueden
Copy link
Member

Rebased over current mainline.

Copy link
Member

@ctrueden ctrueden left a comment

Choose a reason for hiding this comment

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

I have no strong opinions about what is more kotlinesque, so I just made a couple of random comments. 🎲

val camlight = PointLight(3.0f) {
intensity = 5.0f
}
cam += camlight
Copy link
Member

Choose a reason for hiding this comment

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

This is a neat trick. But I find it odd to override plusAssign but not plus. The implication, which is not true for these types, is that cam + camlight would be a new camera object with the light added, and only because the += was used does it get assigned back into the same cam variable. Is this a pattern Kotlin users often use for mutators, to override only the += but not +?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep

Copy link
Member

Choose a reason for hiding this comment

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

Huh, I guess it's convenient, so I'll swallow my feelings of mathematical discomfort 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

We might say this is one of the example on the border line, some people will assume this to be an operator abuse, others don't

But that's where I like to give the choice :)


lights.forEach(scene::addChild)
scene += lights
Copy link
Member

Choose a reason for hiding this comment

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

Assuming the += trick is deemed kosher by @skalarproduktraum, the fact that you can += a whole list of children at once is very cool!

@skalarproduktraum skalarproduktraum added the dd-hackathon-2023 A result of the 2023 Dresden hackathon label Jun 15, 2023
@kephale
Copy link
Member

kephale commented Jun 9, 2024

@skalarproduktraum @elect86 can this PR be wrapped up easily?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dd-hackathon-2023 A result of the 2023 Dresden hackathon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants