Mesh: Replace MLoop struct with generic attributes #104424
|
@ -1056,7 +1056,8 @@ inline blender::Span<blender::float3> Mesh::vert_positions() const
|
|||
}
|
||||
inline blender::MutableSpan<blender::float3> Mesh::vert_positions_for_write()
|
||||
{
|
||||
return {reinterpret_cast<blender::float3 *>(BKE_mesh_vert_positions_for_write(this)), this->totvert};
|
||||
return {reinterpret_cast<blender::float3 *>(BKE_mesh_vert_positions_for_write(this)),
|
||||
this->totvert};
|
||||
}
|
||||
|
||||
inline blender::Span<MEdge> Mesh::edges() const
|
||||
|
|
|
@ -17,7 +17,7 @@ struct ReportList;
|
|||
* split normals can be used to recreate the full tangent space.
|
||||
* NOTE: * The mesh should be made of only tris and quads!
|
||||
*/
|
||||
void BKE_mesh_calc_loop_tangent_single_ex(const float (*positions)[3],
|
||||
void BKE_mesh_calc_loop_tangent_single_ex(const float (*vert_positions)[3],
|
||||
int numVerts,
|
||||
const struct MLoop *mloops,
|
||||
float (*r_looptangent)[4],
|
||||
|
@ -41,7 +41,7 @@ void BKE_mesh_calc_loop_tangent_single(struct Mesh *mesh,
|
|||
/**
|
||||
* See: #BKE_editmesh_loop_tangent_calc (matching logic).
|
||||
*/
|
||||
void BKE_mesh_calc_loop_tangent_ex(const float (*positions)[3],
|
||||
void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
|
||||
const struct MPoly *mpoly,
|
||||
uint mpoly_len,
|
||||
const struct MLoop *mloop,
|
||||
|
|
|
@ -576,7 +576,7 @@ typedef struct SculptSession {
|
|||
struct Depsgraph *depsgraph;
|
||||
|
||||
/* These are always assigned to base mesh data when using PBVH_FACES and PBVH_GRIDS. */
|
||||
float (*positions)[3];
|
||||
float (*vert_positions)[3];
|
||||
const struct MPoly *mpoly;
|
||||
const struct MLoop *mloop;
|
||||
|
||||
|
|
|
@ -586,7 +586,7 @@ static void bvhtree_from_mesh_setup_data(BVHTree *tree,
|
|||
|
||||
r_data->tree = tree;
|
||||
|
||||
r_data->positions = reinterpret_cast<const float(*)[3]>(positions);
|
||||
r_data->vert_positions = positions;
|
||||
r_data->edge = edge;
|
||||
r_data->face = face;
|
||||
r_data->loop = loop;
|
||||
|
|
|
@ -1628,6 +1628,7 @@ void BKE_mesh_legacy_convert_verts_to_positions(Mesh *mesh)
|
|||
});
|
||||
|
||||
CustomData_free_layers(&mesh->vdata, CD_MVERT, mesh->totvert);
|
||||
mesh->mvert = nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -76,7 +76,7 @@ struct BKEMeshToTangent {
|
|||
int num_polys; /* number of polygons */
|
||||
};
|
||||
|
||||
void BKE_mesh_calc_loop_tangent_single_ex(const float (*positions)[3],
|
||||
void BKE_mesh_calc_loop_tangent_single_ex(const float (*vert_positions)[3],
|
||||
const int /*numVerts*/,
|
||||
const MLoop *mloops,
|
||||
float (*r_looptangent)[4],
|
||||
|
@ -91,7 +91,7 @@ void BKE_mesh_calc_loop_tangent_single_ex(const float (*positions)[3],
|
|||
BKEMeshToTangent mesh_to_tangent;
|
||||
mesh_to_tangent.mpolys = mpolys;
|
||||
mesh_to_tangent.mloops = mloops;
|
||||
mesh_to_tangent.positions = positions;
|
||||
mesh_to_tangent.positions = vert_positions;
|
||||
mesh_to_tangent.luvs = loopuvs;
|
||||
mesh_to_tangent.loop_normals = loop_normals;
|
||||
mesh_to_tangent.tangents = r_looptangent;
|
||||
|
@ -385,7 +385,7 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_mesh_calc_loop_tangent_ex(const float (*positions)[3],
|
||||
void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
|
||||
const MPoly *mpoly,
|
||||
const uint mpoly_len,
|
||||
const MLoop *mloop,
|
||||
|
@ -490,7 +490,7 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*positions)[3],
|
|||
mesh2tangent->face_as_quad_map = face_as_quad_map;
|
||||
mesh2tangent->num_face_as_quad_map = num_face_as_quad_map;
|
||||
#endif
|
||||
mesh2tangent->positions = positions;
|
||||
mesh2tangent->positions = vert_positions;
|
||||
mesh2tangent->vert_normals = vert_normals;
|
||||
mesh2tangent->mpoly = mpoly;
|
||||
mesh2tangent->mloop = mloop;
|
||||
|
|
|
@ -1695,7 +1695,7 @@ static void sculpt_update_object(
|
|||
|
||||
/* These are assigned to the base mesh in Multires. This is needed because Face Sets operators
|
||||
* and tools use the Face Sets data from the base mesh when Multires is active. */
|
||||
ss->positions = BKE_mesh_vert_positions_for_write(me);
|
||||
ss->vert_positions = BKE_mesh_vert_positions_for_write(me);
|
||||
ss->mpoly = BKE_mesh_polys(me);
|
||||
ss->mloop = BKE_mesh_loops(me);
|
||||
}
|
||||
|
@ -1703,7 +1703,7 @@ static void sculpt_update_object(
|
|||
ss->totvert = me->totvert;
|
||||
ss->totpoly = me->totpoly;
|
||||
ss->totfaces = me->totpoly;
|
||||
ss->positions = BKE_mesh_vert_positions_for_write(me);
|
||||
ss->vert_positions = BKE_mesh_vert_positions_for_write(me);
|
||||
ss->mpoly = BKE_mesh_polys(me);
|
||||
ss->mloop = BKE_mesh_loops(me);
|
||||
ss->multires.active = false;
|
||||
|
|
|
@ -2072,7 +2072,7 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
|
|||
* Otherwise, take the current vert. */
|
||||
const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
|
||||
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
|
||||
const float3 &mv_curr = ss->positions[v_index];
|
||||
const float3 &mv_curr = ss->vert_positions[v_index];
|
||||
|
||||
/* If the vertex is selected */
|
||||
if (!(use_face_sel || use_vert_sel) || select_vert[v_index]) {
|
||||
|
@ -2099,7 +2099,7 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
|
|||
for (int k = 0; k < mp->totloop; k++, ml_other++) {
|
||||
const uint v_other_index = ml_other->v;
|
||||
if (v_other_index != v_index) {
|
||||
const float3 &mv_other = ss->positions[v_other_index];
|
||||
const float3 &mv_other = ss->vert_positions[v_other_index];
|
||||
|
||||
/* Get the direction from the selected vert to the neighbor. */
|
||||
float other_dir[3];
|
||||
|
@ -3307,7 +3307,7 @@ static void do_vpaint_brush_smear(bContext *C,
|
|||
const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v :
|
||||
vd.vert_indices[vd.i];
|
||||
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
|
||||
const float3 &mv_curr = &ss->positions[v_index];
|
||||
const float3 &mv_curr = &ss->vert_positions[v_index];
|
||||
|
||||
/* if the vertex is selected for painting. */
|
||||
if (!use_vert_sel || select_vert[v_index]) {
|
||||
|
@ -3344,7 +3344,7 @@ static void do_vpaint_brush_smear(bContext *C,
|
|||
for (int k = 0; k < mp->totloop; k++, ml_other++) {
|
||||
const uint v_other_index = ml_other->v;
|
||||
if (v_other_index != v_index) {
|
||||
const float3 &mv_other = &ss->positions[v_other_index];
|
||||
const float3 &mv_other = &ss->vert_positions[v_other_index];
|
||||
|
||||
/* Get the direction from the
|
||||
* selected vert to the neighbor. */
|
||||
|
|
|
@ -116,7 +116,7 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, PBVHVertRef vertex)
|
|||
const float(*positions)[3] = BKE_pbvh_get_positions(ss->pbvh);
|
||||
return positions[vertex.i];
|
||||
}
|
||||
return ss->positions[vertex.i];
|
||||
return ss->vert_positions[vertex.i];
|
||||
}
|
||||
case PBVH_BMESH:
|
||||
return ((BMVert *)vertex.i)->co;
|
||||
|
@ -207,7 +207,7 @@ const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, PBVHVertRef
|
|||
}
|
||||
|
||||
/* Sculpting on the base mesh. */
|
||||
return ss->positions[vertex.i];
|
||||
return ss->vert_positions[vertex.i];
|
||||
}
|
||||
|
||||
/* Everything else, such as sculpting on multires. */
|
||||
|
@ -295,7 +295,7 @@ float (*SCULPT_mesh_deformed_positions_get(SculptSession *ss))[3]
|
|||
if (ss->shapekey_active || ss->deform_modifiers_active) {
|
||||
return BKE_pbvh_get_positions(ss->pbvh);
|
||||
}
|
||||
return ss->positions;
|
||||
return ss->vert_positions;
|
||||
case PBVH_BMESH:
|
||||
case PBVH_GRIDS:
|
||||
return nullptr;
|
||||
|
|
|
@ -124,7 +124,7 @@ template<typename ImageBuffer> class PaintingKernel {
|
|||
SculptSession *ss;
|
||||
const Brush *brush;
|
||||
const int thread_id;
|
||||
const float (*positions_)[3];
|
||||
const float3 *vert_positions_;
|
||||
|
||||
float4 brush_color;
|
||||
float brush_strength;
|
||||
|
@ -140,7 +140,10 @@ template<typename ImageBuffer> class PaintingKernel {
|
|||
const Brush *brush,
|
||||
const int thread_id,
|
||||
const float (*positions)[3])
|
||||
: ss(ss), brush(brush), thread_id(thread_id), positions_(positions)
|
||||
: ss(ss),
|
||||
brush(brush),
|
||||
thread_id(thread_id),
|
||||
vert_positions_(reinterpret_cast<const float3 *>(positions))
|
||||
{
|
||||
init_brush_strength();
|
||||
init_brush_test();
|
||||
|
@ -268,9 +271,9 @@ template<typename ImageBuffer> class PaintingKernel {
|
|||
barycentric_weights.y,
|
||||
1.0f - barycentric_weights.x - barycentric_weights.y);
|
||||
interp_v3_v3v3v3(result,
|
||||
positions_[vert_indices[0]],
|
||||
positions_[vert_indices[1]],
|
||||
positions_[vert_indices[2]],
|
||||
vert_positions_[vert_indices[0]],
|
||||
vert_positions_[vert_indices[1]],
|
||||
vert_positions_[vert_indices[2]],
|
||||
barycentric);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
|||
|
||||
/* No need for float comparison here (memory is exactly equal or not). */
|
||||
index = unode->index;
|
||||
float(*positions)[3] = ss->positions;
|
||||
float(*positions)[3] = ss->vert_positions;
|
||||
|
||||
if (ss->shapekey_active) {
|
||||
float(*vertCos)[3];
|
||||
|
|
|
@ -620,7 +620,7 @@ static void mesh_looptri_raycast_backface_culling_cb(void *userdata,
|
|||
BVHTreeRayHit *hit)
|
||||
{
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
|
||||
const float(*positions)[3] = data->positions;
|
||||
const float(*positions)[3] = data->vert_positions;
|
||||
const MLoopTri *lt = &data->looptri[index];
|
||||
const float *vtri_co[3] = {
|
||||
positions[data->loop[lt->tri[0]].v],
|
||||
|
|
|
@ -60,7 +60,7 @@ struct MultiresBakeResult {
|
|||
};
|
||||
|
||||
struct MResolvePixelData {
|
||||
const float (*positions)[3];
|
||||
const float (*vert_positions)[3];
|
||||
const float (*vert_normals)[3];
|
||||
MPoly *mpoly;
|
||||
const int *material_indices;
|
||||
|
@ -125,7 +125,7 @@ static void multiresbake_get_normal(const MResolvePixelData *data,
|
|||
copy_v3_v3(r_normal, data->precomputed_normals[poly_index]);
|
||||
}
|
||||
else {
|
||||
BKE_mesh_calc_poly_normal(mp, &data->mloop[mp->loopstart], data->positions, r_normal);
|
||||
BKE_mesh_calc_poly_normal(mp, &data->mloop[mp->loopstart], data->vert_positions, r_normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ static void do_multires_bake(MultiresBakeRender *bkr,
|
|||
handle->data.mpoly = mpoly;
|
||||
handle->data.material_indices = static_cast<const int *>(
|
||||
CustomData_get_layer_named(&dm->polyData, CD_PROP_INT32, "material_index"));
|
||||
handle->data.positions = positions;
|
||||
handle->data.vert_positions = positions;
|
||||
handle->data.vert_normals = vert_normals;
|
||||
handle->data.mloopuv = mloopuv;
|
||||
BKE_image_get_tile_uv(ima, tile->tile_number, handle->data.uv_offset);
|
||||
|
|
Loading…
Reference in New Issue