Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.c
| Show First 20 Lines • Show All 2,528 Lines • ▼ Show 20 Lines | if (vcol_layers & (1 << i)) { | ||||
| CustomData_get_named_layer_index(cd_vdata, CD_PROP_COLOR, layer_name) == -1) { | CustomData_get_named_layer_index(cd_vdata, CD_PROP_COLOR, layer_name) == -1) { | ||||
| BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); | BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); | ||||
| GPU_vertformat_alias_add(&format, attr_name); | GPU_vertformat_alias_add(&format, attr_name); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Sculpt Vertex Colors */ | /* Sculpt Vertex Colors */ | ||||
| if (U.experimental.use_sculpt_vertex_colors) { | |||||
| for (int i = 0; i < 8; i++) { | for (int i = 0; i < 8; i++) { | ||||
| if (svcol_layers & (1 << i)) { | if (svcol_layers & (1 << i)) { | ||||
| char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | ||||
| const char *layer_name = CustomData_get_layer_name(cd_vdata, CD_PROP_COLOR, i); | const char *layer_name = CustomData_get_layer_name(cd_vdata, CD_PROP_COLOR, i); | ||||
| GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | ||||
| BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name); | BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name); | ||||
| GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | ||||
| if (i == CustomData_get_render_layer(cd_vdata, CD_PROP_COLOR)) { | if (i == CustomData_get_render_layer(cd_vdata, CD_PROP_COLOR)) { | ||||
| GPU_vertformat_alias_add(&format, "c"); | GPU_vertformat_alias_add(&format, "c"); | ||||
| } | } | ||||
| if (i == CustomData_get_active_layer(cd_vdata, CD_PROP_COLOR)) { | if (i == CustomData_get_active_layer(cd_vdata, CD_PROP_COLOR)) { | ||||
| GPU_vertformat_alias_add(&format, "ac"); | GPU_vertformat_alias_add(&format, "ac"); | ||||
| } | } | ||||
| /* Gather number of auto layers. */ | /* Gather number of auto layers. */ | ||||
| /* We only do `vcols` that are not overridden by `uvs`. */ | /* We only do `vcols` that are not overridden by `uvs`. */ | ||||
| if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, layer_name) == -1) { | if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, layer_name) == -1) { | ||||
| BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); | BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); | ||||
| GPU_vertformat_alias_add(&format, attr_name); | GPU_vertformat_alias_add(&format, attr_name); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| GPUVertBuf *vbo = buf; | GPUVertBuf *vbo = buf; | ||||
| GPU_vertbuf_init_with_format(vbo, &format); | GPU_vertbuf_init_with_format(vbo, &format); | ||||
| GPU_vertbuf_data_alloc(vbo, mr->loop_len); | GPU_vertbuf_data_alloc(vbo, mr->loop_len); | ||||
| typedef struct gpuMeshVcol { | typedef struct gpuMeshVcol { | ||||
| ushort r, g, b, a; | ushort r, g, b, a; | ||||
| } gpuMeshVcol; | } gpuMeshVcol; | ||||
| Show All 26 Lines | if (vcol_layers & (1 << i)) { | ||||
| vcol_data->r = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->r]); | vcol_data->r = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->r]); | ||||
| vcol_data->g = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->g]); | vcol_data->g = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->g]); | ||||
| vcol_data->b = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->b]); | vcol_data->b = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mloopcol->b]); | ||||
| vcol_data->a = unit_float_to_ushort_clamp(mloopcol->a * (1.0f / 255.0f)); | vcol_data->a = unit_float_to_ushort_clamp(mloopcol->a * (1.0f / 255.0f)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (svcol_layers & (1 << i)) { | if (svcol_layers & (1 << i) && U.experimental.use_sculpt_vertex_colors) { | ||||
| if (mr->extract_type == MR_EXTRACT_BMESH) { | if (mr->extract_type == MR_EXTRACT_BMESH) { | ||||
| int cd_ofs = CustomData_get_n_offset(cd_vdata, CD_PROP_COLOR, i); | int cd_ofs = CustomData_get_n_offset(cd_vdata, CD_PROP_COLOR, i); | ||||
| BMIter f_iter; | BMIter f_iter; | ||||
| BMFace *efa; | BMFace *efa; | ||||
| BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (efa, &f_iter, mr->bm, BM_FACES_OF_MESH) { | ||||
| BMLoop *l_iter, *l_first; | BMLoop *l_iter, *l_first; | ||||
| l_iter = l_first = BM_FACE_FIRST_LOOP(efa); | l_iter = l_first = BM_FACE_FIRST_LOOP(efa); | ||||
| do { | do { | ||||
| ▲ Show 20 Lines • Show All 3,028 Lines • Show Last 20 Lines | |||||