[Bf-blender-cvs] [d28b29d428c] master: GPU: add negated normal conversion functions
Campbell Barton
noreply at git.blender.org
Thu Jan 3 07:04:55 CET 2019
Commit: d28b29d428cc7fc7eb29f2302b5d80fc63a9f870
Author: Campbell Barton
Date: Thu Jan 3 16:56:16 2019 +1100
Branches: master
https://developer.blender.org/rBd28b29d428cc7fc7eb29f2302b5d80fc63a9f870
GPU: add negated normal conversion functions
Saves having to negate to a temporary variable.
===================================================================
M source/blender/gpu/GPU_vertex_format.h
M source/blender/gpu/intern/gpu_vertex_format.c
===================================================================
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;
+}
More information about the Bf-blender-cvs
mailing list