diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-03 08:56:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-03 08:56:16 +0300 |
commit | d28b29d428cc7fc7eb29f2302b5d80fc63a9f870 (patch) | |
tree | 50fbd244dddfd2419a7be61926ce52a1039d1589 /source | |
parent | 6cb39720638735e0517c82ffe9698b5cb31060d9 (diff) |
GPU: add negated normal conversion functions
Saves having to negate to a temporary variable.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/GPU_vertex_format.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_format.c | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 7a271caf079..74a86fbcb40 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -112,6 +112,8 @@ typedef struct GPUPackedNormal { } GPUPackedNormal; GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]); +GPUPackedNormal GPU_normal_convert_i10_v3_negated(const float data[3]); GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]); +GPUPackedNormal GPU_normal_convert_i10_s3_negated(const short data[3]); #endif /* __GPU_VERTEX_FORMAT_H__ */ diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index ca636d2e231..24f4a1a53f1 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -478,8 +478,20 @@ GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]) return n; } +GPUPackedNormal GPU_normal_convert_i10_v3_negated(const float data[3]) +{ + GPUPackedNormal n = { .x = quantize(-data[0]), .y = quantize(-data[1]), .z = quantize(-data[2]) }; + return n; +} + GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]) { GPUPackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; return n; } + +GPUPackedNormal GPU_normal_convert_i10_s3_negated(const short data[3]) +{ + GPUPackedNormal n = { .x = convert_i16(-data[0]), .y = convert_i16(-data[1]), .z = convert_i16(-data[2]) }; + return n; +} |