diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-11-06 11:37:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-11-06 12:09:56 +0300 |
commit | 1ffdb1b472f91425db0248170a8f3ba78f37fa09 (patch) | |
tree | 40d4b64c1753c805c5cc61f2cbdd661673a3b9ae /source/blender/blenlib/BLI_voxel.h | |
parent | 4b316e78b6cd87617e5a445f17ec38c763ba9c9c (diff) |
Fix T46696: Voxel crash indexing over INT_MAX
Use int64_t for index values.
Diffstat (limited to 'source/blender/blenlib/BLI_voxel.h')
-rw-r--r-- | source/blender/blenlib/BLI_voxel.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h index 7b92ac05d29..815d319b6db 100644 --- a/source/blender/blenlib/BLI_voxel.h +++ b/source/blender/blenlib/BLI_voxel.h @@ -33,7 +33,11 @@ */ /** find the index number of a voxel, given x/y/z integer coords and resolution vector */ -#define BLI_VOXEL_INDEX(x, y, z, res) ((z) * (res)[1] * (res)[0] + (y) * (res)[0] + (x)) + +#define BLI_VOXEL_INDEX(x, y, z, res) \ + ((int64_t)(x) + \ + (int64_t)(y) * (int64_t)(res)[0] + \ + (int64_t)(z) * (int64_t)(res)[0] * (int64_t)(res)[1]) /* all input coordinates must be in bounding box 0.0 - 1.0 */ float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]); |