Mesh: Replace auto smooth with node group #108014
|
@ -27,7 +27,7 @@ extern "C" {
|
||||||
|
|
||||||
/* Blender file format version. */
|
/* Blender file format version. */
|
||||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||||
#define BLENDER_FILE_SUBVERSION 7
|
#define BLENDER_FILE_SUBVERSION 8
|
||||||
|
|
||||||
/* Minimum Blender version that supports reading file written with the current
|
/* Minimum Blender version that supports reading file written with the current
|
||||||
* version. Older Blender versions will test this and show a warning if the file
|
* version. Older Blender versions will test this and show a warning if the file
|
||||||
|
|
|
@ -323,12 +323,6 @@ const float (*BKE_mesh_vert_normals_ensure(const struct Mesh *mesh))[3];
|
||||||
*/
|
*/
|
||||||
const float (*BKE_mesh_poly_normals_ensure(const struct Mesh *mesh))[3];
|
const float (*BKE_mesh_poly_normals_ensure(const struct Mesh *mesh))[3];
|
||||||
|
|
||||||
/**
|
|
||||||
* See #Mesh::corner_normals().
|
|
||||||
* \warning May return null if the mesh is empty or has no polygons.
|
|
||||||
*/
|
|
||||||
const float (*BKE_mesh_corner_normals_ensure(const struct Mesh *mesh))[3];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve write access to the cached vertex normals, ensuring that they are allocated but *not*
|
* Retrieve write access to the cached vertex normals, ensuring that they are allocated but *not*
|
||||||
* that they are calculated. The provided vertex normals should be the same as if they were
|
* that they are calculated. The provided vertex normals should be the same as if they were
|
||||||
|
|
|
@ -478,11 +478,6 @@ blender::Span<blender::float3> Mesh::corner_normals() const
|
||||||
return this->runtime->corner_normals;
|
return this->runtime->corner_normals;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float (*BKE_mesh_corner_normals_ensure(const Mesh *mesh))[3]
|
|
||||||
{
|
|
||||||
return reinterpret_cast<const float(*)[3]>(mesh->corner_normals().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr,
|
void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr,
|
||||||
const int numLoops,
|
const int numLoops,
|
||||||
const char data_type)
|
const char data_type)
|
||||||
|
|
|
@ -154,8 +154,12 @@ static void version_mesh_objects_replace_auto_smooth(Main &bmain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_versions_after_linking_400(FileData * /*fd*/, Main * /*bmain*/)
|
void do_versions_after_linking_400(FileData * /*fd*/, Main *bmain)
|
||||||
{
|
{
|
||||||
|
if (!MAIN_VERSION_ATLEAST(bmain, 400, 8)) {
|
||||||
|
version_mesh_objects_replace_auto_smooth(*bmain);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Versioning code until next subversion bump goes here.
|
* Versioning code until next subversion bump goes here.
|
||||||
*
|
*
|
||||||
|
@ -170,7 +174,6 @@ void do_versions_after_linking_400(FileData * /*fd*/, Main * /*bmain*/)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Keep this block, even when empty. */
|
/* Keep this block, even when empty. */
|
||||||
version_mesh_objects_replace_auto_smooth(*bmain);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -478,7 +478,7 @@ static void rna_MeshLoop_normal_get(PointerRNA *ptr, float *values)
|
||||||
{
|
{
|
||||||
Mesh *me = rna_mesh(ptr);
|
Mesh *me = rna_mesh(ptr);
|
||||||
const int index = rna_MeshLoop_index_get(ptr);
|
const int index = rna_MeshLoop_index_get(ptr);
|
||||||
const float(*loop_normals)[3] = BKE_mesh_corner_normals_ensure(me);
|
const blender::Span<blender::float3> loop_normals = me->corner_normals();
|
||||||
copy_v3_v3(values, loop_normals[index]);
|
copy_v3_v3(values, loop_normals[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,8 +511,9 @@ static void rna_MeshLoop_bitangent_get(PointerRNA *ptr, float *values)
|
||||||
{
|
{
|
||||||
Mesh *me = rna_mesh(ptr);
|
Mesh *me = rna_mesh(ptr);
|
||||||
const int index = rna_MeshLoop_index_get(ptr);
|
const int index = rna_MeshLoop_index_get(ptr);
|
||||||
const float(*loop_normals)[3] = BKE_mesh_corner_normals_ensure(me);
|
const blender::Span<blender::float3> loop_normals = me->corner_normals();
|
||||||
const float(*vec)[4] = CustomData_get_layer(&me->ldata, CD_MLOOPTANGENT);
|
const float(*vec)[4] = static_cast<const float(*)[4]>(
|
||||||
|
CustomData_get_layer(&me->ldata, CD_MLOOPTANGENT));
|
||||||
|
|
||||||
if (vec) {
|
if (vec) {
|
||||||
cross_v3_v3v3(values, loop_normals[index], vec[index]);
|
cross_v3_v3v3(values, loop_normals[index], vec[index]);
|
||||||
|
@ -686,7 +687,7 @@ static void rna_MeshLoopTriangle_normal_get(PointerRNA *ptr, float *values)
|
||||||
static void rna_MeshLoopTriangle_split_normals_get(PointerRNA *ptr, float *values)
|
static void rna_MeshLoopTriangle_split_normals_get(PointerRNA *ptr, float *values)
|
||||||
{
|
{
|
||||||
Mesh *me = rna_mesh(ptr);
|
Mesh *me = rna_mesh(ptr);
|
||||||
const float(*loop_normals)[3] = BKE_mesh_corner_normals_ensure(me);
|
const blender::Span<blender::float3> loop_normals = me->corner_normals();
|
||||||
const MLoopTri *lt = (const MLoopTri *)ptr->data;
|
const MLoopTri *lt = (const MLoopTri *)ptr->data;
|
||||||
copy_v3_v3(values + 0, loop_normals[lt->tri[0]]);
|
copy_v3_v3(values + 0, loop_normals[lt->tri[0]]);
|
||||||
copy_v3_v3(values + 3, loop_normals[lt->tri[1]]);
|
copy_v3_v3(values + 3, loop_normals[lt->tri[1]]);
|
||||||
|
@ -1675,12 +1676,13 @@ int rna_Mesh_poly_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_p
|
||||||
static void rna_Mesh_corner_normals_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
static void rna_Mesh_corner_normals_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
const Mesh *mesh = rna_mesh(ptr);
|
const Mesh *mesh = rna_mesh(ptr);
|
||||||
const float(*normals)[3] = BKE_mesh_corner_normals_ensure(mesh);
|
const blender::Span<blender::float3> normals = mesh->corner_normals();
|
||||||
if (!normals) {
|
if (normals.is_empty()) {
|
||||||
iter->valid = false;
|
iter->valid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rna_iterator_array_begin(iter, (void *)normals, sizeof(float[3]), mesh->totloop, false, nullptr);
|
rna_iterator_array_begin(
|
||||||
|
iter, (void *)normals.data(), sizeof(float[3]), mesh->totloop, false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rna_Mesh_corner_normals_length(PointerRNA *ptr)
|
static int rna_Mesh_corner_normals_length(PointerRNA *ptr)
|
||||||
|
@ -1692,14 +1694,14 @@ static int rna_Mesh_corner_normals_length(PointerRNA *ptr)
|
||||||
int rna_Mesh_corner_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
|
int rna_Mesh_corner_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
|
||||||
{
|
{
|
||||||
const Mesh *mesh = rna_mesh(ptr);
|
const Mesh *mesh = rna_mesh(ptr);
|
||||||
const float(*normals)[3] = BKE_mesh_corner_normals_ensure(mesh);
|
const blender::Span<blender::float3> normals = mesh->corner_normals();
|
||||||
if (index < 0 || index >= mesh->totloop || !normals) {
|
if (index < 0 || index >= mesh->totloop || normals.is_empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Casting away const is okay because this RNA type doesn't allow changing the value. */
|
/* Casting away const is okay because this RNA type doesn't allow changing the value. */
|
||||||
r_ptr->owner_id = (ID *)&mesh->id;
|
r_ptr->owner_id = (ID *)&mesh->id;
|
||||||
r_ptr->type = &RNA_MeshNormalValue;
|
r_ptr->type = &RNA_MeshNormalValue;
|
||||||
r_ptr->data = (float *)normals[index];
|
r_ptr->data = (float *)&normals[index];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue