Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_particles.c
| Show First 20 Lines • Show All 827 Lines • ▼ Show 20 Lines | static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit, | ||||
| int active_uv = 0; | int active_uv = 0; | ||||
| int render_uv = 0; | int render_uv = 0; | ||||
| int active_col = 0; | int active_col = 0; | ||||
| int render_col = 0; | int render_col = 0; | ||||
| ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; | ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; | ||||
| if (psmd != NULL && psmd->mesh_final != NULL) { | if (psmd != NULL && psmd->mesh_final != NULL) { | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPUV)) { | if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_PROP_FLOAT2)) { | ||||
| cache->num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPUV); | cache->num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_PROP_FLOAT2); | ||||
| active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPUV); | active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_PROP_FLOAT2); | ||||
| render_uv = CustomData_get_render_layer(&psmd->mesh_final->ldata, CD_MLOOPUV); | render_uv = CustomData_get_render_layer(&psmd->mesh_final->ldata, CD_PROP_FLOAT2); | ||||
| } | } | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR)) { | if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR)) { | ||||
| cache->num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, | cache->num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, | ||||
| CD_PROP_BYTE_COLOR); | CD_PROP_BYTE_COLOR); | ||||
| if (psmd->mesh_final->active_color_attribute != NULL) { | if (psmd->mesh_final->active_color_attribute != NULL) { | ||||
| active_col = CustomData_get_named_layer(&psmd->mesh_final->ldata, | active_col = CustomData_get_named_layer(&psmd->mesh_final->ldata, | ||||
| CD_PROP_BYTE_COLOR, | CD_PROP_BYTE_COLOR, | ||||
| psmd->mesh_final->active_color_attribute); | psmd->mesh_final->active_color_attribute); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit, | ||||
| /* UV layers */ | /* UV layers */ | ||||
| for (int i = 0; i < cache->num_uv_layers; i++) { | for (int i = 0; i < cache->num_uv_layers; i++) { | ||||
| cache->proc_uv_buf[i] = GPU_vertbuf_create_with_format_ex( | cache->proc_uv_buf[i] = GPU_vertbuf_create_with_format_ex( | ||||
| &format_uv, GPU_USAGE_STATIC | GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY); | &format_uv, GPU_USAGE_STATIC | GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY); | ||||
| GPU_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); | GPU_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); | ||||
| GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); | GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); | ||||
| char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | ||||
| const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); | const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_PROP_FLOAT2, i); | ||||
| GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | ||||
| int n = 0; | int n = 0; | ||||
| BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); | BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); | ||||
| if (i == active_uv) { | if (i == active_uv) { | ||||
| BLI_strncpy(cache->uv_layer_names[i][n++], "au", MAX_LAYER_NAME_LEN); | BLI_strncpy(cache->uv_layer_names[i][n++], "au", MAX_LAYER_NAME_LEN); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, | ||||
| int active_uv = 0; | int active_uv = 0; | ||||
| int active_col = 0; | int active_col = 0; | ||||
| const MTFace **mtfaces = NULL; | const MTFace **mtfaces = NULL; | ||||
| const MCol **mcols = NULL; | const MCol **mcols = NULL; | ||||
| float(**parent_uvs)[2] = NULL; | float(**parent_uvs)[2] = NULL; | ||||
| MCol **parent_mcol = NULL; | MCol **parent_mcol = NULL; | ||||
| if (psmd != NULL) { | if (psmd != NULL) { | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPUV)) { | if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_PROP_FLOAT2)) { | ||||
| num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPUV); | num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_PROP_FLOAT2); | ||||
| active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPUV); | active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_PROP_FLOAT2); | ||||
| } | } | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR)) { | if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR)) { | ||||
| num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR); | num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR); | ||||
| if (psmd->mesh_final->active_color_attribute != NULL) { | if (psmd->mesh_final->active_color_attribute != NULL) { | ||||
| active_col = CustomData_get_named_layer(&psmd->mesh_final->ldata, | active_col = CustomData_get_named_layer(&psmd->mesh_final->ldata, | ||||
| CD_PROP_BYTE_COLOR, | CD_PROP_BYTE_COLOR, | ||||
| psmd->mesh_final->active_color_attribute); | psmd->mesh_final->active_color_attribute); | ||||
| } | } | ||||
| Show All 9 Lines | static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, | ||||
| if (psmd) { | if (psmd) { | ||||
| uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attr format"); | uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attr format"); | ||||
| col_id = MEM_mallocN(sizeof(*col_id) * num_col_layers, "Col attr format"); | col_id = MEM_mallocN(sizeof(*col_id) * num_col_layers, "Col attr format"); | ||||
| for (int i = 0; i < num_uv_layers; i++) { | for (int i = 0; i < num_uv_layers; i++) { | ||||
| char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | ||||
| const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); | const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_PROP_FLOAT2, i); | ||||
| GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | ||||
| BLI_snprintf(uuid, sizeof(uuid), "a%s", attr_safe_name); | BLI_snprintf(uuid, sizeof(uuid), "a%s", attr_safe_name); | ||||
| uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| if (i == active_uv) { | if (i == active_uv) { | ||||
| GPU_vertformat_alias_add(&format, "a"); | GPU_vertformat_alias_add(&format, "a"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 519 Lines • Show Last 20 Lines | |||||