Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.c
| Show First 20 Lines • Show All 2,715 Lines • ▼ Show 20 Lines | |||||
| /* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ | ||||
| /** \name Extract Edit UV area stretch | /** \name Extract Edit UV area stretch | ||||
| * \{ */ | * \{ */ | ||||
| static void *extract_stretch_area_init(const MeshRenderData *mr, void *buf) | static void *extract_stretch_area_init(const MeshRenderData *mr, void *buf) | ||||
| { | { | ||||
| static GPUVertFormat format = {0}; | static GPUVertFormat format = {0}; | ||||
| if (format.attr_len == 0) { | if (format.attr_len == 0) { | ||||
| GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_U16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); | GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); | ||||
| } | } | ||||
| 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); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void *UNUSED(data)) | ||||
| } | } | ||||
| mr->cache->tot_area = tot_area; | mr->cache->tot_area = tot_area; | ||||
| mr->cache->tot_uv_area = tot_uv_area; | mr->cache->tot_uv_area = tot_uv_area; | ||||
| /* Convert in place to avoid an extra allocation */ | /* Convert in place to avoid an extra allocation */ | ||||
| uint16_t *poly_stretch = (uint16_t *)area_ratio; | uint16_t *poly_stretch = (uint16_t *)area_ratio; | ||||
| for (int p = 0; p < mr->poly_len; p++) { | for (int p = 0; p < mr->poly_len; p++) { | ||||
| poly_stretch[p] = area_ratio[p] * 65534.0f; | poly_stretch[p] = area_ratio[p] * SHRT_MAX; | ||||
| } | } | ||||
| /* Copy face data for each loop. */ | /* Copy face data for each loop. */ | ||||
| GPUVertBuf *vbo = buf; | GPUVertBuf *vbo = buf; | ||||
| uint16_t *loop_stretch = (uint16_t *)vbo->data; | uint16_t *loop_stretch = (uint16_t *)vbo->data; | ||||
| if (mr->extract_type == MR_EXTRACT_BMESH) { | if (mr->extract_type == MR_EXTRACT_BMESH) { | ||||
| BMFace *efa; | BMFace *efa; | ||||
| ▲ Show 20 Lines • Show All 1,730 Lines • Show Last 20 Lines | |||||