Page MenuHome

Cleanup: Move (edit)mesh_tangent.c to C++
ClosedPublic

Authored by Lukas Stockner (lukasstockner97) on Aug 5 2022, 10:40 PM.

Details

Summary

This changes the two tangent-related files in BKE to C++ in preparation for the C++ Mikktspace port in D15589.
For now, they still use the original Mikktspace.

Diff Detail

Repository
rB Blender

Event Timeline

Lukas Stockner (lukasstockner97) requested review of this revision.Aug 5 2022, 10:40 PM
Lukas Stockner (lukasstockner97) created this revision.
Sergey Sharybin (sergey) requested changes to this revision.Aug 8 2022, 10:43 AM

Please follow the patch submission guidelines: https://wiki.blender.org/wiki/Process/Contributing_Code#Guidelines specifically the description section of it.

It might also be good idea to use buildbot to verify such changes which deeply affect the build process are fine on all platforms.

source/blender/blenkernel/intern/editmesh_tangent.cc
246–247

Not sure why initialization from NULL got replaced with 0. I'd imagine it would be something SMikkTSpaceContext sContext = {nullptr};, or, even SMikkTSpaceContext sContext = {};,

395–396

Clang gives the following error: editmesh_tangent.cc:394:34: error: static_cast from 'struct BMLoop *(*)[3]' to 'const BMLoop *(*)[3]' is not allowed

This revision now requires changes to proceed.Aug 8 2022, 10:43 AM
Lukas Stockner (lukasstockner97) marked 2 inline comments as done.

Addressed review, updated description.
I'll also run the buildbot.

source/blender/blenkernel/intern/editmesh_tangent.cc
246–247

My logic was that {nullptr} is misleading since this doesn't really have anything to do with pointers, we're just zero-initializing the object.
However, after a second thought, this doesn't work in C++ anyways of course.

The structs in question come from Mikktspace, so I can't just do the clean thing and add default values to the entries. For now until D15589 is done, explicitly setting all elements is good enough, there's only one that wasn't set already anyways.

source/blender/blenkernel/intern/editmesh_tangent.cc
246–248
SMikkTSpaceContext sContext{};
SMikkTSpaceInterface sInterface{};
  • Rebased
  • Added empty initializer

The const_cast compilation error is still there on Linux: https://builder.blender.org/admin/#/builders/136/builds/17
Might be caused by an older GCC used in the release environment since I am unable to reproduce the issue locally.

Replaced the const_cast with a C-style cast, seems to work in source/blender/blenkernel/intern/bvhutils.cc so I'm hopeful.
I'll poke Buildbot.

This revision was not accepted when it landed; it landed in state Needs Review.Sep 7 2022, 1:01 AM
This revision was automatically updated to reflect the committed changes.