Page MenuHome

Moving mesh_evaluate.c to CC/C++
ClosedPublic

Authored by Jagannadhan Ravi (easythrees) on Jun 29 2021, 7:29 PM.

Details

Summary

Cleanup: Moving mesh_evaluate and mesh_normals to C++.

No functional changes.

Diff Detail

Repository
rB Blender
Branch
arcpatch-D11744 (branched from master)
Build Status
Buildable 15632
Build 15632: arc lint + arc unit

Event Timeline

Jagannadhan Ravi (easythrees) requested review of this revision.Jun 29 2021, 7:29 PM
Jagannadhan Ravi (easythrees) created this revision.

Looks good except for one small comment inline.

For some more context, see previous comments in D11688. Next time please just update the patch instead of creating a new one like we said in chat.

source/blender/blenkernel/intern/mesh_evaluate.cc
352–354

I think without the . before the name it still counts as a designated initializer, which isn't supported by the C++ 17 standard. I would do this like you did below:

MeshCalcNormalsData data;
data.mpolys = mpolys;
data.mloop = mloop;
...

Please check for other places like that in these changes. I see one a few lines above with the same struct.

Jagannadhan Ravi (easythrees) marked an inline comment as done.

Fixed the other structs, passes unit tests.

Ray Molenkamp (LazyDodo) added inline comments.
source/blender/blenkernel/intern/mesh_evaluate.cc
352–354

This one stumped me for a bit, my initial reaction was this shouldn't even build, but it does...

this is due to name of the fields inside the struct and the variables we put in having identical names, and the way side effects work, this essentially evaluates to:

MeshCalcNormalsData data = {
  mpolys,
  mloop,
...

So as long as the order in the struct matches the order in the initializer, this will work, but

  1. it doesn't do what you think it does
  2. if the order of the struct ever changes, it would break. ... likely silently

so follow @Hans Goudey (HooglyBoogly) 's guidance here.

I'll still mention this to Campbell before committing, but it looks good to me now.

This revision is now accepted and ready to land.Jun 30 2021, 6:28 PM
Campbell Barton (campbellbarton) requested changes to this revision.Jul 1 2021, 3:31 AM

Generally fine with this, mesh_normals.c has since been split into it's own file, so I assume this would be moved to C++ instead.

This patch also misses clang-formatting.

source/blender/blenlib/BLI_linklist_stack.h
122 ↗(On Diff #38973)

Committed separately to master, since it's more of a general change.

This revision now requires changes to proceed.Jul 1 2021, 3:31 AM

Generally fine with this, mesh_normals.c has since been split into it's own file, so I assume this would be moved to C++ instead.

This patch also misses clang-formatting.

Hi, I'm a little confused, are you saying we need to move mesh_normals.c to C++ as well? Also, how can I apply clang-formatting on Windows?

updated for mesh_normals.c

This gives a lot of warnings with clang-tidy still.

Hopefully clang-tidy will be happy now :)

Campbell Barton (campbellbarton) requested changes to this revision.EditedJul 6 2021, 6:47 AM

Final TODO's

This revision now requires changes to proceed.Jul 6 2021, 6:47 AM

Cleanup: Moving mesh_evaluate and mesh_normals to C++.

No functional changes.

This revision is now accepted and ready to land.Jul 7 2021, 5:59 AM