[Bf-blender-cvs] [2343dcf0d27] blender2.8: Gawain: Use common prefix for packed normal
Campbell Barton
noreply at git.blender.org
Thu Jun 29 10:48:45 CEST 2017
Commit: 2343dcf0d272c0cbc3f185d674eb93d24b4f29e7
Author: Campbell Barton
Date: Thu Jun 29 18:52:39 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB2343dcf0d272c0cbc3f185d674eb93d24b4f29e7
Gawain: Use common prefix for packed normal
===================================================================
M intern/gawain/gawain/vertex_format.h
M intern/gawain/src/vertex_format.c
M source/blender/draw/intern/draw_cache_impl_mesh.c
===================================================================
diff --git a/intern/gawain/gawain/vertex_format.h b/intern/gawain/gawain/vertex_format.h
index 3b2a3be4209..ab61722db60 100644
--- a/intern/gawain/gawain/vertex_format.h
+++ b/intern/gawain/gawain/vertex_format.h
@@ -72,7 +72,7 @@ typedef struct {
int y : 10;
int z : 10;
int w : 2; // 0 by default, can manually set to { -2, -1, 0, 1 }
-} PackedNormal;
+} Gwn_PackedNormal;
-PackedNormal convert_i10_v3(const float data[3]);
-PackedNormal convert_i10_s3(const short data[3]);
+Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]);
+Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]);
diff --git a/intern/gawain/src/vertex_format.c b/intern/gawain/src/vertex_format.c
index 139a76cf7ef..34704db3359 100644
--- a/intern/gawain/src/vertex_format.c
+++ b/intern/gawain/src/vertex_format.c
@@ -251,7 +251,7 @@ void VertexFormat_pack(Gwn_VertFormat* format)
// OpenGL ES packs in a different order as desktop GL but component conversion is the same.
-// Of the code here, only struct PackedNormal needs to change.
+// Of the code here, only struct Gwn_PackedNormal needs to change.
#define SIGNED_INT_10_MAX 511
#define SIGNED_INT_10_MIN -512
@@ -283,14 +283,14 @@ static int convert_i16(short x)
// TODO: round?
}
-PackedNormal convert_i10_v3(const float data[3])
+Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3])
{
- PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) };
+ Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) };
return n;
}
-PackedNormal convert_i10_s3(const short data[3])
+Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3])
{
- PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) };
+ Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) };
return n;
}
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 8cfb99d654c..13b94c00dc6 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -1425,9 +1425,9 @@ static void add_overlay_tri(
if (vbo_nor) {
/* TODO real loop normal */
- PackedNormal lnor = convert_i10_v3(bm_looptri[0]->f->no);
+ Gwn_PackedNormal lnor = GWN_normal_convert_i10_v3(bm_looptri[0]->f->no);
for (uint i = 0; i < 3; i++) {
- PackedNormal vnor = convert_i10_v3(bm_looptri[i]->v->no);
+ Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(bm_looptri[i]->v->no);
GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
GWN_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor);
}
@@ -1465,7 +1465,7 @@ static void add_overlay_loose_edge(
if (vbo_nor) {
for (int i = 0; i < 2; ++i) {
- PackedNormal vnor = convert_i10_v3((&eed->v1)[i]->no);
+ Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3((&eed->v1)[i]->no);
GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
}
}
@@ -1491,7 +1491,7 @@ static void add_overlay_loose_vert(
}
if (vbo_nor) {
- PackedNormal vnor = convert_i10_v3(eve->no);
+ Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(eve->no);
GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor);
}
@@ -2007,20 +2007,20 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
rdata, i, use_hide, &tri_vert_cos, &tri_nor, &tri_vert_nors, &is_smooth))
{
if (is_smooth) {
- PackedNormal snor_pack[3] = {
- convert_i10_s3(tri_vert_nors[0]),
- convert_i10_s3(tri_vert_nors[1]),
- convert_i10_s3(tri_vert_nors[2])
+ Gwn_PackedNormal snor_pack[3] = {
+ GWN_normal_convert_i10_s3(tri_vert_nors[0]),
+ GWN_normal_convert_i10_s3(tri_vert_nors[1]),
+ GWN_normal_convert_i10_s3(tri_vert_nors[2])
};
- PackedNormal *snor[3] = { &snor_pack[0], &snor_pack[1], &snor_pack[2] };
+ Gwn_PackedNormal *snor[3] = { &snor_pack[0], &snor_pack[1], &snor_pack[2] };
GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor[0]);
GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor[1]);
GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor[2]);
}
else {
- PackedNormal snor_pack = convert_i10_s3(tri_nor);
- PackedNormal *snor = &snor_pack;
+ Gwn_PackedNormal snor_pack = GWN_normal_convert_i10_s3(tri_nor);
+ Gwn_PackedNormal *snor = &snor_pack;
GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor);
GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor);
@@ -3095,16 +3095,16 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
if (mesh_render_data_edge_vcos_manifold_pnors(rdata, i, &vcos1, &vcos2, &pnor1, &pnor2, &is_manifold)) {
- PackedNormal n1value = { .x = 0, .y = 0, .z = +511 };
- PackedNormal n2value = { .x = 0, .y = 0, .z = -511 };
+ Gwn_PackedNormal n1value = { .x = 0, .y = 0, .z = +511 };
+ Gwn_PackedNormal n2value = { .x = 0, .y = 0, .z = -511 };
if (is_manifold) {
- n1value = convert_i10_v3(pnor1);
- n2value = convert_i10_v3(pnor2);
+ n1value = GWN_normal_convert_i10_v3(pnor1);
+ n2value = GWN_normal_convert_i10_v3(pnor2);
}
- const PackedNormal *n1 = &n1value;
- const PackedNormal *n2 = &n2value;
+ const Gwn_PackedNormal *n1 = &n1value;
+ const Gwn_PackedNormal *n2 = &n2value;
GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1);
GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1);
@@ -3257,8 +3257,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me)
if (mesh_render_data_pnors_pcenter_select_get(rdata, i, pnor, pcenter, &selected)) {
- PackedNormal nor = { .x = 0, .y = 0, .z = -511 };
- nor = convert_i10_v3(pnor);
+ Gwn_PackedNormal nor = { .x = 0, .y = 0, .z = -511 };
+ nor = GWN_normal_convert_i10_v3(pnor);
nor.w = selected ? 1 : 0;
GWN_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor);
More information about the Bf-blender-cvs
mailing list