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

Using templated parameters for indices and vertex positions #2

Closed
IntellectualKitty opened this issue Apr 14, 2017 · 4 comments
Closed

Comments

@IntellectualKitty
Copy link

If templated parameters were used for indices (common types include uint8_t, uint16_t, uint32_t, unsigned short, and unsigned int) and vertex positions (float, double), the library would be more flexible with regard to the potential needs of users.

@zeux
Copy link
Owner

zeux commented Jul 21, 2017

This is now fixed for indices in master - all functions that accept index buffers have templated overloads.

I do not plan on supporting double-precision vertex positions at this time since that would introduce extra complexity and this is a very niche use case.

@zeux zeux closed this as completed Jul 21, 2017
@tfiner
Copy link

tfiner commented Mar 3, 2021

Just registering my desire for double-precision vertex support. I know that this is old and there don't appear to be many requests for it. I need it for data that is from planetary scale down to less than one meter. I try to to keep doubles around as long as possible and use some of the techniques in Cozzi & Ring's 3D Engine Design for Virtual Globes (namely eye relative coordinates and splitting double precision into two floats).

Also, double precision support doesn't have to use templates in the API, you could just add overloads of double* instead. That still leaves open the possibility to use templates in the implementation files to minimize duplication.

@zeux
Copy link
Owner

zeux commented Mar 25, 2021

FWIW this is very unlikely to happen because of the extra overloads/variants it introduces to many APIs and implementations, and because the typical use case involves single-precision floats as this is the format GPUs support natively. However one important note is that most algorithms don't output positional data, and as such it's actually okay to - for example:

  • Generate a temporary floating point buffer that contains "localized" input positions (by subtracting the midpoint of the input mesh from the positions in doubles, and truncating the results to float)
  • Run whatever algorithm in meshoptimizer is interesting, which would typically result in a new triangle order / index set
  • Discard the original temporary buffer and use the result from step 2 with the original double-precision positions

This should provide results that are pretty similar to running the original algorithms directly on double precision inputs.

@tfiner
Copy link

tfiner commented Mar 25, 2021

Thank you. That all sounds pretty reasonable and I will give that a try.

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

No branches or pull requests

3 participants