OpenShadingLanguage icon indicating copy to clipboard operation
OpenShadingLanguage copied to clipboard

Mismatch between sizeof(Partio::ParticleIndex), sizeof(size_t), sizeof(int)

Open StefanBruens opened this issue 3 years ago • 0 comments

There is some assumption Partio uses size_t for its index type:

https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/7e34ce27c7f759b40333a99cf26860f99c9ba2dd/src/liboslexec/pointcloud.cpp#L360-L365

which is apparently wrong (for the last 12 years): https://github.com/wdas/partio/blob/7cb3743c6e19c04ac049c05f8f81af2f24410ea3/src/lib/Partio.h#L55 typedef uint64_t ParticleIndex;

On 32 bit archs the compilation then fails due to: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/7e34ce27c7f759b40333a99cf26860f99c9ba2dd/src/liboslexec/pointcloud.cpp#L114-L118

Wouldn't it be better change it to unsigned long* out_indices in RendererServices::pointcloud_search? (This may require a version bump for 64bit archs, but only if size_t != unsigned long. For 32bit archs, the current code does not work anyway). Dito for pointcloud_get.

StefanBruens avatar Apr 08 '22 15:04 StefanBruens