Cleanup: Cycles: rename some legacy names to new ones
This commit is contained in:
@@ -43,7 +43,7 @@ template<bool is_subd> struct MikkMeshWrapper {
|
||||
const Mesh *mesh,
|
||||
float3 *tangent,
|
||||
float *tangent_sign)
|
||||
: mesh(mesh), texface(NULL), orco(NULL), tangent(tangent), tangent_sign(tangent_sign)
|
||||
: mesh(mesh), uv(NULL), orco(NULL), tangent(tangent), tangent_sign(tangent_sign)
|
||||
{
|
||||
const AttributeSet &attributes = is_subd ? mesh->subd_attributes : mesh->attributes;
|
||||
|
||||
@@ -63,7 +63,7 @@ template<bool is_subd> struct MikkMeshWrapper {
|
||||
else {
|
||||
Attribute *attr_uv = attributes.find(ustring(layer_name));
|
||||
if (attr_uv != NULL) {
|
||||
texface = attr_uv->data_float2();
|
||||
uv = attr_uv->data_float2();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,9 +120,9 @@ template<bool is_subd> struct MikkMeshWrapper {
|
||||
{
|
||||
/* TODO: Check whether introducing a template boolean in order to
|
||||
* turn this into a constexpr is worth it. */
|
||||
if (texface != NULL) {
|
||||
if (uv != NULL) {
|
||||
const int corner_index = CornerIndex(face_num, vert_num);
|
||||
float2 tfuv = texface[corner_index];
|
||||
float2 tfuv = uv[corner_index];
|
||||
return mikk::float3(tfuv.x, tfuv.y, 1.0f);
|
||||
}
|
||||
else if (orco != NULL) {
|
||||
@@ -175,6 +175,7 @@ template<bool is_subd> struct MikkMeshWrapper {
|
||||
|
||||
float3 *vertex_normal;
|
||||
float2 *texface;
|
||||
float2 *uv;
|
||||
float3 *orco;
|
||||
float3 orco_loc, inv_orco_size;
|
||||
|
||||
@@ -828,8 +829,8 @@ static void create_mesh(Scene *scene,
|
||||
const blender::bke::MeshNormalDomain normals_domain = b_mesh.normals_domain(true);
|
||||
int numfaces = (!subdivision) ? b_mesh.corner_tris().size() : faces.size();
|
||||
|
||||
bool use_loop_normals = normals_domain == blender::bke::MeshNormalDomain::Corner &&
|
||||
(mesh->get_subdivision_type() != Mesh::SUBDIVISION_CATMULL_CLARK);
|
||||
bool use_corner_normals = normals_domain == blender::bke::MeshNormalDomain::Corner &&
|
||||
(mesh->get_subdivision_type() != Mesh::SUBDIVISION_CATMULL_CLARK);
|
||||
|
||||
/* If no faces, create empty mesh. */
|
||||
if (faces.is_empty()) {
|
||||
@@ -841,7 +842,7 @@ static void create_mesh(Scene *scene,
|
||||
const blender::VArraySpan sharp_faces = *b_attributes.lookup<bool>(
|
||||
"sharp_face", blender::bke::AttrDomain::Face);
|
||||
blender::Span<blender::float3> corner_normals;
|
||||
if (use_loop_normals) {
|
||||
if (use_corner_normals) {
|
||||
corner_normals = b_mesh.corner_normals();
|
||||
}
|
||||
|
||||
@@ -872,7 +873,7 @@ static void create_mesh(Scene *scene,
|
||||
Attribute *attr_N = attributes.add(ATTR_STD_VERTEX_NORMAL);
|
||||
float3 *N = attr_N->data_float3();
|
||||
|
||||
if (subdivision || !(use_loop_normals && !corner_normals.is_empty())) {
|
||||
if (subdivision || !(use_corner_normals && !corner_normals.is_empty())) {
|
||||
const blender::Span<blender::float3> vert_normals = b_mesh.vert_normals();
|
||||
for (const int i : vert_normals.index_range()) {
|
||||
N[i] = make_float3(vert_normals[i][0], vert_normals[i][1], vert_normals[i][2]);
|
||||
@@ -940,7 +941,7 @@ static void create_mesh(Scene *scene,
|
||||
std::fill(shader, shader + numtris, 0);
|
||||
}
|
||||
|
||||
if (!sharp_faces.is_empty() && !(use_loop_normals && !corner_normals.is_empty())) {
|
||||
if (!sharp_faces.is_empty() && !(use_corner_normals && !corner_normals.is_empty())) {
|
||||
const blender::Span<int> tri_faces = b_mesh.corner_tri_faces();
|
||||
for (const int i : corner_tris.index_range()) {
|
||||
smooth[i] = !sharp_faces[tri_faces[i]];
|
||||
@@ -951,7 +952,7 @@ static void create_mesh(Scene *scene,
|
||||
std::fill(smooth, smooth + numtris, normals_domain != blender::bke::MeshNormalDomain::Face);
|
||||
}
|
||||
|
||||
if (use_loop_normals && !corner_normals.is_empty()) {
|
||||
if (use_corner_normals && !corner_normals.is_empty()) {
|
||||
for (const int i : corner_tris.index_range()) {
|
||||
const blender::int3 &tri = corner_tris[i];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -975,7 +976,7 @@ static void create_mesh(Scene *scene,
|
||||
int *subd_ptex_offset = mesh->get_subd_ptex_offset().data();
|
||||
int *subd_face_corners = mesh->get_subd_face_corners().data();
|
||||
|
||||
if (!sharp_faces.is_empty() && !use_loop_normals) {
|
||||
if (!sharp_faces.is_empty() && !use_corner_normals) {
|
||||
for (int i = 0; i < numfaces; i++) {
|
||||
subd_smooth[i] = !sharp_faces[i];
|
||||
}
|
||||
|
||||
@@ -88,15 +88,16 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
|
||||
|
||||
BL::Mesh mesh = (b_ob_info.object_data.is_a(&RNA_Mesh)) ? BL::Mesh(b_ob_info.object_data) :
|
||||
BL::Mesh(PointerRNA_NULL);
|
||||
const bool split_faces = (mesh) && (subdivision_type == Mesh::SUBDIVISION_NONE) &&
|
||||
(static_cast<const ::Mesh *>(mesh.ptr.data)->normals_domain(true) ==
|
||||
blender::bke::MeshNormalDomain::Corner);
|
||||
|
||||
if (b_ob_info.is_real_object_data()) {
|
||||
if (mesh) {
|
||||
/* Make a copy to split faces if we use auto-smooth, otherwise not needed.
|
||||
* Also in edit mode do we need to make a copy, to ensure data layers like
|
||||
* UV are not empty. */
|
||||
if (mesh.is_editmode() || (mesh.normals_domain() == BL::Mesh::normals_domain_CORNER &&
|
||||
subdivision_type == Mesh::SUBDIVISION_NONE))
|
||||
{
|
||||
if (mesh.is_editmode() || split_faces) {
|
||||
BL::Depsgraph depsgraph(PointerRNA_NULL);
|
||||
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
|
||||
}
|
||||
@@ -119,12 +120,14 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((bool)mesh && subdivision_type == Mesh::SUBDIVISION_NONE) {
|
||||
if (mesh.normals_domain() == BL::Mesh::normals_domain_CORNER) {
|
||||
if (mesh) {
|
||||
if (split_faces) {
|
||||
mesh.split_faces();
|
||||
}
|
||||
|
||||
mesh.calc_loop_triangles();
|
||||
if (subdivision_type == Mesh::SUBDIVISION_NONE) {
|
||||
mesh.calc_loop_triangles();
|
||||
}
|
||||
}
|
||||
|
||||
return mesh;
|
||||
|
||||
Reference in New Issue
Block a user