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

Faster wireframe gen #5299

Merged
merged 1 commit into from May 3, 2023
Merged

Conversation

slimbuck
Copy link
Member

@slimbuck slimbuck commented May 3, 2023

Use Set to track line hashes and use plain math instead of bit math. Also correctly support meshes with more than 65535 vertices.

This change results in roughly double the speed generation of indices.

@slimbuck slimbuck added the area: graphics Graphics related issue label May 3, 2023
@slimbuck slimbuck requested a review from a team May 3, 2023 11:30
@slimbuck slimbuck self-assigned this May 3, 2023
@LeXXik
Copy link
Contributor

LeXXik commented May 3, 2023

I am curious to read about the info that led you to swap out bitwise operations.

@slimbuck
Copy link
Member Author

slimbuck commented May 3, 2023

w3 schools says:

JavaScript Uses 32 bits Bitwise Operands

JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers.

Before a bitwise operation is performed, JavaScript converts numbers to 32 bits signed integers.

After the bitwise operation is performed, the result is converted back to 64 bits JavaScript numbers.

@slimbuck
Copy link
Member Author

slimbuck commented May 3, 2023

@LeXXik, using set makes a bigger difference than bit operations for performance. I kept the vanilla math over bit operations so it'd work correctly for meshes with more than 65536 vertices.

@slimbuck slimbuck merged commit e801e51 into playcanvas:main May 3, 2023
7 checks passed
@slimbuck slimbuck deleted the wireframe-speedup branch May 3, 2023 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants