Refactor: Subdiv: Add utility to evaluate all limit points in a grid
This commit is contained in:
parent
90049e15d6
commit
527e18043c
@ -258,6 +258,10 @@ inline int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG &subdiv_ccg, const
|
||||
void BKE_subdiv_ccg_eval_limit_point(const SubdivCCG &subdiv_ccg,
|
||||
const SubdivCCGCoord &coord,
|
||||
float r_point[3]);
|
||||
void BKE_subdiv_ccg_eval_limit_positions(const SubdivCCG &subdiv_ccg,
|
||||
const CCGKey &key,
|
||||
int grid_index,
|
||||
blender::MutableSpan<blender::float3> r_limit_positions);
|
||||
|
||||
enum SubdivCCGAdjacencyType {
|
||||
SUBDIV_CCG_ADJACENT_NONE,
|
||||
|
@ -1709,4 +1709,21 @@ void BKE_subdiv_ccg_eval_limit_point(const SubdivCCG &subdiv_ccg,
|
||||
eval_limit_point(subdiv, ptex_face_index, u, v, r_point);
|
||||
}
|
||||
|
||||
void BKE_subdiv_ccg_eval_limit_positions(const SubdivCCG &subdiv_ccg,
|
||||
const CCGKey &key,
|
||||
const int grid_index,
|
||||
const MutableSpan<float3> r_limit_positions)
|
||||
{
|
||||
SubdivCCGCoord coord{};
|
||||
coord.grid_index = grid_index;
|
||||
for (const int y : IndexRange(key.grid_size)) {
|
||||
for (const int x : IndexRange(key.grid_size)) {
|
||||
const int i = CCG_grid_xy_to_index(key.grid_size, x, y);
|
||||
coord.x = x;
|
||||
coord.y = y;
|
||||
BKE_subdiv_ccg_eval_limit_point(subdiv_ccg, coord, r_limit_positions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -38,18 +38,10 @@ static BLI_NOINLINE void calc_limit_positions(const SubdivCCG &subdiv_ccg,
|
||||
const MutableSpan<float3> limit_positions)
|
||||
{
|
||||
const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
|
||||
for (const int grid : grids) {
|
||||
const int start = grid * key.grid_area;
|
||||
for (const int y : IndexRange(key.grid_size)) {
|
||||
for (const int x : IndexRange(key.grid_size)) {
|
||||
const int offset = CCG_grid_xy_to_index(key.grid_size, x, y);
|
||||
SubdivCCGCoord coord{};
|
||||
coord.grid_index = grid;
|
||||
coord.x = x;
|
||||
coord.y = y;
|
||||
BKE_subdiv_ccg_eval_limit_point(subdiv_ccg, coord, limit_positions[start + offset]);
|
||||
}
|
||||
}
|
||||
for (const int i : grids.index_range()) {
|
||||
const int start = i * key.grid_area;
|
||||
BKE_subdiv_ccg_eval_limit_positions(
|
||||
subdiv_ccg, key, grids[i], limit_positions.slice(start, key.grid_area));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user