Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_particles.c
| Show First 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | static void particle_calculate_parent_uvs(ParticleSystem *psys, | ||||
| if (psmd == NULL) { | if (psmd == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| const int emit_from = psmd->psys->part->from; | const int emit_from = psmd->psys->part->from; | ||||
| if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ParticleData *particle = &psys->particles[parent_index]; | ParticleData *particle = &psys->particles[parent_index]; | ||||
| Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd); | |||||
| int num = particle->num_dmcache; | int num = particle->num_dmcache; | ||||
| if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) { | if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) { | ||||
| if (particle->num < psmd->mesh_final->totface) { | if (particle->num < mesh_final->totface) { | ||||
| num = particle->num; | num = particle->num; | ||||
| } | } | ||||
| } | } | ||||
| if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) { | if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) { | ||||
| MFace *mface = &psmd->mesh_final->mface[num]; | MFace *mface = &mesh_final->mface[num]; | ||||
| for (int j = 0; j < num_uv_layers; j++) { | for (int j = 0; j < num_uv_layers; j++) { | ||||
| psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]); | psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void particle_calculate_parent_mcol(ParticleSystem *psys, | static void particle_calculate_parent_mcol(ParticleSystem *psys, | ||||
| ParticleSystemModifierData *psmd, | ParticleSystemModifierData *psmd, | ||||
| const int num_uv_layers, | const int num_uv_layers, | ||||
| const int parent_index, | const int parent_index, | ||||
| /*const*/ MCol **mcols, | /*const*/ MCol **mcols, | ||||
| MCol *r_mcol) | MCol *r_mcol) | ||||
| { | { | ||||
| if (psmd == NULL) { | if (psmd == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| const int emit_from = psmd->psys->part->from; | const int emit_from = psmd->psys->part->from; | ||||
| if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ParticleData *particle = &psys->particles[parent_index]; | ParticleData *particle = &psys->particles[parent_index]; | ||||
| Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd); | |||||
| int num = particle->num_dmcache; | int num = particle->num_dmcache; | ||||
| if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) { | if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) { | ||||
| if (particle->num < psmd->mesh_final->totface) { | if (particle->num < mesh_final->totface) { | ||||
| num = particle->num; | num = particle->num; | ||||
| } | } | ||||
| } | } | ||||
| if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) { | if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) { | ||||
| MFace *mface = &psmd->mesh_final->mface[num]; | MFace *mface = &mesh_final->mface[num]; | ||||
| for (int j = 0; j < num_uv_layers; j++) { | for (int j = 0; j < num_uv_layers; j++) { | ||||
| psys_interpolate_mcol(mcols[j] + num, mface->v4, particle->fuv, &r_mcol[j]); | psys_interpolate_mcol(mcols[j] + num, mface->v4, particle->fuv, &r_mcol[j]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Used by interpolated children. */ | /* Used by interpolated children. */ | ||||
| static void particle_interpolate_children_uvs(ParticleSystem *psys, | static void particle_interpolate_children_uvs(ParticleSystem *psys, | ||||
| ParticleSystemModifierData *psmd, | ParticleSystemModifierData *psmd, | ||||
| const int num_uv_layers, | const int num_uv_layers, | ||||
| const int child_index, | const int child_index, | ||||
| /*const*/ MTFace **mtfaces, | /*const*/ MTFace **mtfaces, | ||||
| float (*r_uv)[2]) | float (*r_uv)[2]) | ||||
| { | { | ||||
| if (psmd == NULL) { | if (psmd == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| const int emit_from = psmd->psys->part->from; | const int emit_from = psmd->psys->part->from; | ||||
| if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ChildParticle *particle = &psys->child[child_index]; | ChildParticle *particle = &psys->child[child_index]; | ||||
| int num = particle->num; | int num = particle->num; | ||||
| Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd); | |||||
| if (num != DMCACHE_NOTFOUND) { | if (num != DMCACHE_NOTFOUND) { | ||||
| MFace *mface = &psmd->mesh_final->mface[num]; | MFace *mface = &mesh_final->mface[num]; | ||||
| for (int j = 0; j < num_uv_layers; j++) { | for (int j = 0; j < num_uv_layers; j++) { | ||||
| psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]); | psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void particle_interpolate_children_mcol(ParticleSystem *psys, | static void particle_interpolate_children_mcol(ParticleSystem *psys, | ||||
| ParticleSystemModifierData *psmd, | ParticleSystemModifierData *psmd, | ||||
| const int num_col_layers, | const int num_col_layers, | ||||
| const int child_index, | const int child_index, | ||||
| /*const*/ MCol **mcols, | /*const*/ MCol **mcols, | ||||
| MCol *r_mcol) | MCol *r_mcol) | ||||
| { | { | ||||
| if (psmd == NULL) { | if (psmd == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| const int emit_from = psmd->psys->part->from; | const int emit_from = psmd->psys->part->from; | ||||
| if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ChildParticle *particle = &psys->child[child_index]; | ChildParticle *particle = &psys->child[child_index]; | ||||
| Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd); | |||||
| int num = particle->num; | int num = particle->num; | ||||
| if (num != DMCACHE_NOTFOUND) { | if (num != DMCACHE_NOTFOUND) { | ||||
| MFace *mface = &psmd->mesh_final->mface[num]; | MFace *mface = &mesh_final->mface[num]; | ||||
| for (int j = 0; j < num_col_layers; j++) { | for (int j = 0; j < num_col_layers; j++) { | ||||
| psys_interpolate_mcol(mcols[j] + num, mface->v4, particle->fuv, &r_mcol[j]); | psys_interpolate_mcol(mcols[j] + num, mface->v4, particle->fuv, &r_mcol[j]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void particle_calculate_uvs(ParticleSystem *psys, | static void particle_calculate_uvs(ParticleSystem *psys, | ||||
| ParticleSystemModifierData *psmd, | ParticleSystemModifierData *psmd, | ||||
| ▲ Show 20 Lines • Show All 435 Lines • ▼ Show 20 Lines | static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit, | ||||
| ParticleSystem *psys, | ParticleSystem *psys, | ||||
| ModifierData *md, | ModifierData *md, | ||||
| ParticleHairCache *cache) | ParticleHairCache *cache) | ||||
| { | { | ||||
| int active_uv = 0; | int active_uv = 0; | ||||
| int active_col = 0; | int active_col = 0; | ||||
| ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; | ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; | ||||
| Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd); | |||||
| if (psmd != NULL && psmd->mesh_final != NULL) { | if (psmd != NULL && mesh_final != NULL) { | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPUV)) { | if (CustomData_has_layer(&mesh_final->ldata, CD_MLOOPUV)) { | ||||
| cache->num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPUV); | cache->num_uv_layers = CustomData_number_of_layers(&mesh_final->ldata, CD_MLOOPUV); | ||||
| active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPUV); | active_uv = CustomData_get_active_layer(&mesh_final->ldata, CD_MLOOPUV); | ||||
| } | } | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL)) { | if (CustomData_has_layer(&mesh_final->ldata, CD_MLOOPCOL)) { | ||||
| cache->num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPCOL); | cache->num_col_layers = CustomData_number_of_layers(&mesh_final->ldata, CD_MLOOPCOL); | ||||
| active_col = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL); | active_col = CustomData_get_active_layer(&mesh_final->ldata, CD_MLOOPCOL); | ||||
| } | } | ||||
| } | } | ||||
| GPUVertBufRaw data_step, seg_step; | GPUVertBufRaw data_step, seg_step; | ||||
| GPUVertBufRaw uv_step[MAX_MTFACE]; | GPUVertBufRaw uv_step[MAX_MTFACE]; | ||||
| GPUVertBufRaw col_step[MAX_MCOL]; | GPUVertBufRaw col_step[MAX_MCOL]; | ||||
| MTFace *mtfaces[MAX_MTFACE] = {NULL}; | MTFace *mtfaces[MAX_MTFACE] = {NULL}; | ||||
| Show All 27 Lines | static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit, | ||||
| GPU_vertbuf_attr_get_raw_data(cache->proc_strand_seg_buf, seg_id, &seg_step); | GPU_vertbuf_attr_get_raw_data(cache->proc_strand_seg_buf, seg_id, &seg_step); | ||||
| /* 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(&format_uv); | cache->proc_uv_buf[i] = GPU_vertbuf_create_with_format(&format_uv); | ||||
| 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]); | ||||
| const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); | const char *name = CustomData_get_layer_name(&mesh_final->ldata, CD_MLOOPUV, i); | ||||
| uint hash = BLI_ghashutil_strhash_p(name); | uint hash = BLI_ghashutil_strhash_p(name); | ||||
| int n = 0; | int n = 0; | ||||
| BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "u%u", hash); | BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "u%u", hash); | ||||
| BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%u", hash); | BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%u", hash); | ||||
| if (i == active_uv) { | if (i == active_uv) { | ||||
| BLI_strncpy(cache->uv_layer_names[i][n], "u", MAX_LAYER_NAME_LEN); | BLI_strncpy(cache->uv_layer_names[i][n], "u", MAX_LAYER_NAME_LEN); | ||||
| } | } | ||||
| } | } | ||||
| /* Vertex colors */ | /* Vertex colors */ | ||||
| for (int i = 0; i < cache->num_col_layers; i++) { | for (int i = 0; i < cache->num_col_layers; i++) { | ||||
| cache->proc_col_buf[i] = GPU_vertbuf_create_with_format(&format_col); | cache->proc_col_buf[i] = GPU_vertbuf_create_with_format(&format_col); | ||||
| GPU_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); | GPU_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); | ||||
| GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); | GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); | ||||
| const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); | const char *name = CustomData_get_layer_name(&mesh_final->ldata, CD_MLOOPCOL, i); | ||||
| uint hash = BLI_ghashutil_strhash_p(name); | uint hash = BLI_ghashutil_strhash_p(name); | ||||
| int n = 0; | int n = 0; | ||||
| BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "c%u", hash); | BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "c%u", hash); | ||||
| /* We only do vcols auto name that are not overridden by uvs */ | /* We only do vcols auto name that are not overridden by uvs */ | ||||
| if (CustomData_get_named_layer_index(&psmd->mesh_final->ldata, CD_MLOOPUV, name) == -1) { | if (CustomData_get_named_layer_index(&mesh_final->ldata, CD_MLOOPUV, name) == -1) { | ||||
| BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%u", hash); | BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%u", hash); | ||||
| } | } | ||||
| if (i == active_col) { | if (i == active_col) { | ||||
| BLI_strncpy(cache->col_layer_names[i][n], "c", MAX_LAYER_NAME_LEN); | BLI_strncpy(cache->col_layer_names[i][n], "c", MAX_LAYER_NAME_LEN); | ||||
| } | } | ||||
| } | } | ||||
| if (cache->num_uv_layers || cache->num_col_layers) { | if (cache->num_uv_layers || cache->num_col_layers) { | ||||
| BKE_mesh_tessface_ensure(psmd->mesh_final); | BKE_mesh_tessface_ensure(mesh_final); | ||||
| if (cache->num_uv_layers) { | if (cache->num_uv_layers) { | ||||
| for (int j = 0; j < cache->num_uv_layers; j++) { | for (int j = 0; j < cache->num_uv_layers; j++) { | ||||
| mtfaces[j] = (MTFace *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MTFACE, j); | mtfaces[j] = (MTFace *)CustomData_get_layer_n(&mesh_final->fdata, CD_MTFACE, j); | ||||
| } | } | ||||
| } | } | ||||
| if (cache->num_col_layers) { | if (cache->num_col_layers) { | ||||
| for (int j = 0; j < cache->num_col_layers; j++) { | for (int j = 0; j < cache->num_col_layers; j++) { | ||||
| mcols[j] = (MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, j); | mcols[j] = (MCol *)CustomData_get_layer_n(&mesh_final->fdata, CD_MCOL, j); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (edit != NULL && edit->pathcache != NULL) { | if (edit != NULL && edit->pathcache != NULL) { | ||||
| particle_batch_cache_fill_strands_data(psys, | particle_batch_cache_fill_strands_data(psys, | ||||
| psmd, | psmd, | ||||
| edit->pathcache, | edit->pathcache, | ||||
| ▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, | ||||
| int num_col_layers = 0; | int num_col_layers = 0; | ||||
| int active_uv = 0; | int active_uv = 0; | ||||
| int active_col = 0; | int active_col = 0; | ||||
| MTFace **mtfaces = NULL; | MTFace **mtfaces = NULL; | ||||
| MCol **mcols = NULL; | MCol **mcols = NULL; | ||||
| float(**parent_uvs)[2] = NULL; | float(**parent_uvs)[2] = NULL; | ||||
| MCol **parent_mcol = NULL; | MCol **parent_mcol = NULL; | ||||
| Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd); | |||||
| if (psmd != NULL) { | if (psmd != NULL) { | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPUV)) { | if (CustomData_has_layer(&mesh_final->ldata, CD_MLOOPUV)) { | ||||
| num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPUV); | num_uv_layers = CustomData_number_of_layers(&mesh_final->ldata, CD_MLOOPUV); | ||||
| active_uv = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPUV); | active_uv = CustomData_get_active_layer(&mesh_final->ldata, CD_MLOOPUV); | ||||
| } | } | ||||
| if (CustomData_has_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL)) { | if (CustomData_has_layer(&mesh_final->ldata, CD_MLOOPCOL)) { | ||||
| num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->ldata, CD_MLOOPCOL); | num_col_layers = CustomData_number_of_layers(&mesh_final->ldata, CD_MLOOPCOL); | ||||
| active_col = CustomData_get_active_layer(&psmd->mesh_final->ldata, CD_MLOOPCOL); | active_col = CustomData_get_active_layer(&mesh_final->ldata, CD_MLOOPCOL); | ||||
| } | } | ||||
| } | } | ||||
| GPU_vertformat_clear(&format); | GPU_vertformat_clear(&format); | ||||
| /* initialize vertex format */ | /* initialize vertex format */ | ||||
| attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | ||||
| attr_id.tan = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | attr_id.tan = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | ||||
| attr_id.ind = GPU_vertformat_attr_add(&format, "ind", GPU_COMP_I32, 1, GPU_FETCH_INT); | attr_id.ind = GPU_vertformat_attr_add(&format, "ind", GPU_COMP_I32, 1, GPU_FETCH_INT); | ||||
| 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++) { | ||||
| const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); | const char *name = CustomData_get_layer_name(&mesh_final->ldata, CD_MLOOPUV, i); | ||||
| char uuid[32]; | char uuid[32]; | ||||
| BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name)); | BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(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, "u"); | GPU_vertformat_alias_add(&format, "u"); | ||||
| } | } | ||||
| } | } | ||||
| for (int i = 0; i < num_uv_layers; i++) { | for (int i = 0; i < num_uv_layers; i++) { | ||||
| const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); | const char *name = CustomData_get_layer_name(&mesh_final->ldata, CD_MLOOPUV, i); | ||||
| char uuid[32]; | char uuid[32]; | ||||
| BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name)); | BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name)); | ||||
| col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| if (i == active_col) { | if (i == active_col) { | ||||
| GPU_vertformat_alias_add(&format, "c"); | GPU_vertformat_alias_add(&format, "c"); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| hair_cache->pos = GPU_vertbuf_create_with_format(&format); | hair_cache->pos = GPU_vertbuf_create_with_format(&format); | ||||
| GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); | GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); | ||||
| GPUIndexBufBuilder elb; | GPUIndexBufBuilder elb; | ||||
| GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, hair_cache->elems_len, hair_cache->point_len); | GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, hair_cache->elems_len, hair_cache->point_len); | ||||
| if (num_uv_layers || num_col_layers) { | if (num_uv_layers || num_col_layers) { | ||||
| BKE_mesh_tessface_ensure(psmd->mesh_final); | BKE_mesh_tessface_ensure(mesh_final); | ||||
| if (num_uv_layers) { | if (num_uv_layers) { | ||||
| mtfaces = MEM_mallocN(sizeof(*mtfaces) * num_uv_layers, "Faces UV layers"); | mtfaces = MEM_mallocN(sizeof(*mtfaces) * num_uv_layers, "Faces UV layers"); | ||||
| for (int i = 0; i < num_uv_layers; i++) { | for (int i = 0; i < num_uv_layers; i++) { | ||||
| mtfaces[i] = (MTFace *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MTFACE, i); | mtfaces[i] = (MTFace *)CustomData_get_layer_n(&mesh_final->fdata, CD_MTFACE, i); | ||||
| } | } | ||||
| } | } | ||||
| if (num_col_layers) { | if (num_col_layers) { | ||||
| mcols = MEM_mallocN(sizeof(*mcols) * num_col_layers, "Color layers"); | mcols = MEM_mallocN(sizeof(*mcols) * num_col_layers, "Color layers"); | ||||
| for (int i = 0; i < num_col_layers; i++) { | for (int i = 0; i < num_col_layers; i++) { | ||||
| mcols[i] = (MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, i); | mcols[i] = (MCol *)CustomData_get_layer_n(&mesh_final->fdata, CD_MCOL, i); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (edit != NULL && edit->pathcache != NULL) { | if (edit != NULL && edit->pathcache != NULL) { | ||||
| curr_point = particle_batch_cache_fill_segments(psys, | curr_point = particle_batch_cache_fill_segments(psys, | ||||
| psmd, | psmd, | ||||
| edit->pathcache, | edit->pathcache, | ||||
| ▲ Show 20 Lines • Show All 461 Lines • Show Last 20 Lines | |||||