Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/texture_pointdensity.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| psys_sim_data_free(&sim); | psys_sim_data_free(&sim); | ||||
| } | } | ||||
| static void pointdensity_cache_vertex_color(PointDensity *pd, | static void pointdensity_cache_vertex_color(PointDensity *pd, | ||||
| Object *UNUSED(ob), | Object *UNUSED(ob), | ||||
| Mesh *mesh, | Mesh *mesh, | ||||
| float *data_color) | float *data_color) | ||||
| { | { | ||||
| const MLoop *mloop = BKE_mesh_loops(mesh); | const int *corner_verts = BKE_mesh_corner_verts(mesh); | ||||
| const int totloop = mesh->totloop; | const int totloop = mesh->totloop; | ||||
| char layername[MAX_CUSTOMDATA_LAYER_NAME]; | char layername[MAX_CUSTOMDATA_LAYER_NAME]; | ||||
| int i; | int i; | ||||
| BLI_assert(data_color); | BLI_assert(data_color); | ||||
| if (!CustomData_has_layer(&mesh->ldata, CD_PROP_BYTE_COLOR)) { | if (!CustomData_has_layer(&mesh->ldata, CD_PROP_BYTE_COLOR)) { | ||||
| return; | return; | ||||
| } | } | ||||
| CustomData_validate_layer_name( | CustomData_validate_layer_name( | ||||
| &mesh->ldata, CD_PROP_BYTE_COLOR, pd->vertex_attribute_name, layername); | &mesh->ldata, CD_PROP_BYTE_COLOR, pd->vertex_attribute_name, layername); | ||||
| const MLoopCol *mcol = CustomData_get_layer_named(&mesh->ldata, CD_PROP_BYTE_COLOR, layername); | const MLoopCol *mcol = CustomData_get_layer_named(&mesh->ldata, CD_PROP_BYTE_COLOR, layername); | ||||
| if (!mcol) { | if (!mcol) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Stores the number of MLoops using the same vertex, so we can normalize colors. */ | /* Stores the number of MLoops using the same vertex, so we can normalize colors. */ | ||||
| int *mcorners = MEM_callocN(sizeof(int) * pd->totpoints, "point density corner count"); | int *mcorners = MEM_callocN(sizeof(int) * pd->totpoints, "point density corner count"); | ||||
| for (i = 0; i < totloop; i++) { | for (i = 0; i < totloop; i++) { | ||||
| int v = mloop[i].v; | int v = corner_verts[i]; | ||||
| if (mcorners[v] == 0) { | if (mcorners[v] == 0) { | ||||
| rgb_uchar_to_float(&data_color[v * 3], &mcol[i].r); | rgb_uchar_to_float(&data_color[v * 3], &mcol[i].r); | ||||
| } | } | ||||
| else { | else { | ||||
| float col[3]; | float col[3]; | ||||
| rgb_uchar_to_float(col, &mcol[i].r); | rgb_uchar_to_float(col, &mcol[i].r); | ||||
| add_v3_v3(&data_color[v * 3], col); | add_v3_v3(&data_color[v * 3], col); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||