Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/multires_reshape_subdivide.cc
| Show All 24 Lines | |||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "multires_reshape.h" | #include "multires_reshape.h" | ||||
| static void multires_subdivide_create_object_space_linear_grids(Mesh *mesh) | static void multires_subdivide_create_object_space_linear_grids(Mesh *mesh) | ||||
| { | { | ||||
| const float(*positions)[3] = BKE_mesh_vert_positions(mesh); | const float(*positions)[3] = BKE_mesh_vert_positions(mesh); | ||||
| const MPoly *polys = BKE_mesh_polys(mesh); | const MPoly *polys = BKE_mesh_polys(mesh); | ||||
| const MLoop *loops = BKE_mesh_loops(mesh); | const blender::Span<int> corner_verts = mesh->corner_verts(); | ||||
| MDisps *mdisps = static_cast<MDisps *>( | MDisps *mdisps = static_cast<MDisps *>( | ||||
| CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop)); | CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop)); | ||||
| const int totpoly = mesh->totpoly; | const int totpoly = mesh->totpoly; | ||||
| for (int p = 0; p < totpoly; p++) { | for (int p = 0; p < totpoly; p++) { | ||||
| const MPoly *poly = &polys[p]; | const MPoly *poly = &polys[p]; | ||||
| float poly_center[3]; | float poly_center[3]; | ||||
| BKE_mesh_calc_poly_center(poly, &loops[poly->loopstart], positions, poly_center); | BKE_mesh_calc_poly_center(poly, &corner_verts[poly->loopstart], positions, poly_center); | ||||
| for (int l = 0; l < poly->totloop; l++) { | for (int l = 0; l < poly->totloop; l++) { | ||||
| const int loop_index = poly->loopstart + l; | const int loop_index = poly->loopstart + l; | ||||
| float(*disps)[3] = mdisps[loop_index].disps; | float(*disps)[3] = mdisps[loop_index].disps; | ||||
| mdisps[loop_index].totdisp = 4; | mdisps[loop_index].totdisp = 4; | ||||
| mdisps[loop_index].level = 1; | mdisps[loop_index].level = 1; | ||||
| int prev_loop_index = l - 1 >= 0 ? loop_index - 1 : loop_index + poly->totloop - 1; | int prev_loop_index = l - 1 >= 0 ? loop_index - 1 : loop_index + poly->totloop - 1; | ||||
| int next_loop_index = l + 1 < poly->totloop ? loop_index + 1 : poly->loopstart; | int next_loop_index = l + 1 < poly->totloop ? loop_index + 1 : poly->loopstart; | ||||
| const MLoop *loop = &loops[loop_index]; | const int vert = corner_verts[loop_index]; | ||||
| const MLoop *loop_next = &loops[next_loop_index]; | const int vert_next = corner_verts[next_loop_index]; | ||||
| const MLoop *loop_prev = &loops[prev_loop_index]; | const int vert_prev = corner_verts[prev_loop_index]; | ||||
| copy_v3_v3(disps[0], poly_center); | copy_v3_v3(disps[0], poly_center); | ||||
| mid_v3_v3v3(disps[1], positions[loop->v], positions[loop_next->v]); | mid_v3_v3v3(disps[1], positions[vert], positions[vert_next]); | ||||
| mid_v3_v3v3(disps[2], positions[loop->v], positions[loop_prev->v]); | mid_v3_v3v3(disps[2], positions[vert], positions[vert_prev]); | ||||
| copy_v3_v3(disps[3], positions[loop->v]); | copy_v3_v3(disps[3], positions[vert]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void multires_subdivide_create_tangent_displacement_linear_grids(Object *object, | void multires_subdivide_create_tangent_displacement_linear_grids(Object *object, | ||||
| MultiresModifierData *mmd) | MultiresModifierData *mmd) | ||||
| { | { | ||||
| Mesh *coarse_mesh = static_cast<Mesh *>(object->data); | Mesh *coarse_mesh = static_cast<Mesh *>(object->data); | ||||
| Show All 29 Lines | |||||