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,
|
void BKE_subdiv_ccg_eval_limit_point(const SubdivCCG &subdiv_ccg,
|
||||||
const SubdivCCGCoord &coord,
|
const SubdivCCGCoord &coord,
|
||||||
float r_point[3]);
|
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 {
|
enum SubdivCCGAdjacencyType {
|
||||||
SUBDIV_CCG_ADJACENT_NONE,
|
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);
|
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 MutableSpan<float3> limit_positions)
|
||||||
{
|
{
|
||||||
const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
|
const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
|
||||||
for (const int grid : grids) {
|
for (const int i : grids.index_range()) {
|
||||||
const int start = grid * key.grid_area;
|
const int start = i * key.grid_area;
|
||||||
for (const int y : IndexRange(key.grid_size)) {
|
BKE_subdiv_ccg_eval_limit_positions(
|
||||||
for (const int x : IndexRange(key.grid_size)) {
|
subdiv_ccg, key, grids[i], limit_positions.slice(start, key.grid_area));
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user