Skip to content

feat: std mod #1513

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

Merged
merged 9 commits into from
Jul 21, 2025
Merged

feat: std mod #1513

merged 9 commits into from
Jul 21, 2025

Conversation

lursz
Copy link
Contributor

@lursz lursz commented Jul 18, 2025

No description provided.

@lursz lursz requested a review from Copilot July 18, 2025 12:01
Copy link

github-actions bot commented Jul 18, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@ddd34def4012ec41ec46c00cb154616d1d09b9f3
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@ddd34def4012ec41ec46c00cb154616d1d09b9f3
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@ddd34def4012ec41ec46c00cb154616d1d09b9f3

benchmark
view benchmark

commit
view commit

Copilot

This comment was marked as resolved.

@software-mansion software-mansion deleted a comment from Copilot AI Jul 18, 2025
@software-mansion software-mansion deleted a comment from Copilot AI Jul 18, 2025
@software-mansion software-mansion deleted a comment from Copilot AI Jul 18, 2025
@lursz lursz linked an issue Jul 18, 2025 that may be closed by this pull request
@lursz lursz marked this pull request as ready for review July 21, 2025 09:25
@aleksanderkatan
Copy link
Contributor

aleksanderkatan commented Jul 21, 2025

Where do we put the line on which operations have an infix variant? Right now it is only + - / *, the likes of == ! < ... don't. Should modulo be infixable? (if so, it would be another ticket anyway)
Edit: I added an issue for this #1519

Copy link
Contributor

@aleksanderkatan aleksanderkatan left a comment

Choose a reason for hiding this comment

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

Here's your sticker

image

Comment on lines 165 to 173
const createMixedComponentWise2 = <T extends { x: number; y: number }>(
vecConstructor: (x: number, y: number) => T,
) => {
return (op: BinaryOp) => (a: T | number, b: T | number) =>
vecConstructor(
op(typeof a === 'number' ? a : a.x, typeof b === 'number' ? b : b.x),
op(typeof a === 'number' ? a : a.y, typeof b === 'number' ? b : b.y),
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

The way this is written makes it usable for two vector operations as well. We could replace binaryComponentWise with this and simplify the ifs in std operators a little. Probably a job for #1336

Copy link
Contributor

@aleksanderkatan aleksanderkatan left a comment

Choose a reason for hiding this comment

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

All gucci

Copy link
Contributor

@reczkok reczkok left a comment

Choose a reason for hiding this comment

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

Jak się człowiek śpieszy to się diabeł cieszy

eng: Wait a little

@reczkok reczkok requested a review from aleksanderkatan July 21, 2025 15:46
Copy link
Contributor

@reczkok reczkok left a comment

Choose a reason for hiding this comment

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

Great work 👷

Copy link
Contributor

@aleksanderkatan aleksanderkatan left a comment

Choose a reason for hiding this comment

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

🧹🧹🧹 it is so much cleaner now!

@lursz lursz merged commit c213302 into main Jul 21, 2025
6 checks passed
@lursz lursz deleted the feat/std-mod branch July 22, 2025 09:47
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.

feat: Add mod operator to std
3 participants