Skip to content

Initial-ish code review. #1

@rburema

Description

@rburema

Since the library didn't really exist yet before this point, we didn't really have to work with PR's. One downside is that you can't really review to work done in the same way though -- so have this 'issue' instead.

printf("\rError adding mesh\n");

  • You really don't want print statements in a library! -- At least not ones that aren't opt-in (opt-out by default).
    I've noticed we're importing spdlog anyway, maybe should make use of that to make this into a debug thing.

for (size_t i = 0; i < vertices.size(); ++i)

  • You can use ranges::enumerate here instead, I think.

throw std::runtime_error("Vertices should be <float, float, float> and indices should be (grouped by face as) <int, int, int>.");

throw std::runtime_error("Couldn't unwrap UV's!");

  • These aren't caught in Uranium when called (see the review there...)

float best_outlier_angle = 1.0;

float face_best_angle = -1.0f;

  • I know this'll be fine in practice, but I always get a little antsy if I see 'limit' values that could actually occur
    (like, it's technically possible to have a dot-product of 1.0 between two vectors).
    It's probably better to have something that's a little bigger than |1.0| exactly -- I might even have gone with (-)numeric_limits<float>::infinity().

for (auto iterator = unprocessed_faces.begin; iterator != unprocessed_faces.end; ++iterator)

for (auto iterator = projected_faces_groups.begin(); iterator != projected_faces_groups.end(); ++iterator)

  • You can use structured binding to get (references to) both the key and value of an iterated map-item like so;
    for(auto [key, value] : projected_faces_groups) { ... }
    (Also; key and value will both be refs, no need to put auto& that'll just confuse the compiler.)

if (assigned1)

if (! assigned1)

  • These are blocks with repeated code. It's not too bad, but consider something like;
     constexpr bool unassigned = false
     auto face_struct_list = {
       {face.i1, unassigned, new_indices_groups.find(face.i1) }
       {face.i2, unassigned, new_indices_groups.find(face.i2) }
       {face.i3, unassigned, new_indices_groups.find(face.i3) }
     }
    
    Then for either block you can use something like;
     ranges::for_each(face_struct_list,
     	[](auto& tuple)
     	{
     		auto [idx, assigned, it] = tuple;
     		// ... rest of loop-code
     	});
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions