Page MenuHome

Cleanup: Use C++ types and lambdas for mesh normal calculation
AbandonedPublic

Authored by Hans Goudey (HooglyBoogly) on Sep 4 2021, 9:58 PM.

Details

Summary
  • Use threading::parallel_for for multi-threading, for a simpler API, more readable and concise code.
  • Use Span and Array (only internally, the public API is still C) for safer, more automatic memory management.
  • Since code is much less verbose, combine the callbacks into the main function. Note that the accumulation code could be more concise with float3, I just wanted to keep these changes minimal.

@Campbell Barton (campbellbarton), do you have any of the test files you used from D11993?
I'd check those to make sure this doesn't have a performance impact (I wouldn't expect it to).

Diff Detail

Repository
rB Blender
Branch
cleanup-normal-calculation (branched from master)
Build Status
Buildable 19370
Build 19370: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Sep 4 2021, 9:58 PM
Hans Goudey (HooglyBoogly) created this revision.

Used incorrect diff before

  • Merge branch 'master' into temp-vert-normals-cleanup
  • Merge branch 'master' into temp-vert-normals-cleanup
  • Fix: Incorrect assert

I'm currently observing very weird assert behavior in Erindale's flower shop file:

BLI_assert(CustomData_has_layer(&mesh->vdata, CD_NORMAL) || mesh->totvert == 0);
(gdb) print (CustomData_has_layer(&mesh->vdata, CD_NORMAL) || mesh->totvert == 0)
$6 = true
(gdb) print mesh->vdata.layers[1].type
$8 = 8  # CD_NORMAL = 8

These bits of information just don't seem to line up!
However, running Blender with -t 1 makes the issue go away.
Maybe another thread modified the mesh right after this one aborted.

  • Cleanup: Remove redundant code
  • Merge branch 'master' into temp-vert-normals-cleanup
  • Fix assert failure from bad threading in ensure functions
  • Update to latest master