Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
Note: this change ignores formatting of ternaries where clang-format
makes a very wrong decision, as well as a few small bits that might need
code adjustment in the future to avoid misformats.
  • Loading branch information
zeux committed Nov 17, 2023
1 parent d57567f commit e2ee634
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions gltf/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ void filterStreams(Mesh& mesh, const MaterialInfo& mi)

if (stream.target)
{
morph_normal = morph_normal || (stream.type == cgltf_attribute_type_normal && !isConstant(stream.data, { 0, 0, 0, 0 }));
morph_tangent = morph_tangent || (stream.type == cgltf_attribute_type_tangent && !isConstant(stream.data, { 0, 0, 0, 0 }));
morph_normal = morph_normal || (stream.type == cgltf_attribute_type_normal && !isConstant(stream.data, {0, 0, 0, 0}));
morph_tangent = morph_tangent || (stream.type == cgltf_attribute_type_tangent && !isConstant(stream.data, {0, 0, 0, 0}));
}

if (stream.type == cgltf_attribute_type_texcoord && stream.index < 32 && (mi.textureSetMask & (1u << stream.index)) != 0)
Expand All @@ -430,7 +430,7 @@ void filterStreams(Mesh& mesh, const MaterialInfo& mi)
if ((stream.type == cgltf_attribute_type_joints || stream.type == cgltf_attribute_type_weights) && !mesh.skin)
continue;

if (stream.type == cgltf_attribute_type_color && isConstant(stream.data, { 1, 1, 1, 1 }))
if (stream.type == cgltf_attribute_type_color && isConstant(stream.data, {1, 1, 1, 1}))
continue;

if (stream.target && stream.type == cgltf_attribute_type_normal && !morph_normal)
Expand Down
7 changes: 3 additions & 4 deletions gltf/parsegltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ static void fixupIndices(std::vector<unsigned int>& indices, cgltf_primitive_typ

static bool isIdAttribute(const char* name)
{
return
strcmp(name, "_ID") == 0 ||
strcmp(name, "_BATCHID") == 0 ||
strncmp(name, "_FEATURE_ID_", 12) == 0;
return strcmp(name, "_ID") == 0 ||
strcmp(name, "_BATCHID") == 0 ||
strncmp(name, "_FEATURE_ID_", 12) == 0;
}

static void parseMeshesGltf(cgltf_data* data, std::vector<Mesh>& meshes, std::vector<std::pair<size_t, size_t> >& mesh_remap)
Expand Down
2 changes: 1 addition & 1 deletion gltf/parseobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static void parseMeshGroupObj(fastObjMesh* obj, const fastObjGroup& og, cgltf_da
unsigned int face_vertex_offset = og.index_offset;
unsigned int face_end_offset = og.face_offset + og.face_count;

for (unsigned int face_offset = og.face_offset; face_offset < face_end_offset; )
for (unsigned int face_offset = og.face_offset; face_offset < face_end_offset;)
{
unsigned int mi = obj->face_materials[face_offset];

Expand Down
2 changes: 1 addition & 1 deletion gltf/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static StreamFormat writeVertexStreamFloat(std::string& bin, const Stream& strea
{
float v[4];
for (int k = 0; k < components; ++k)
v[k] = meshopt_quantizeFloat(a.f[k], bits);
v[k] = meshopt_quantizeFloat(a.f[k], bits);
bin.append(reinterpret_cast<const char*>(v), sizeof(float) * components);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/simplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ static float quadricError(const Quadric& Q, const QuadricGrad* G, size_t attribu
}

// TODO: weight normalization is breaking attribute error somehow
float s = 1;// Q.w == 0.f ? 0.f : 1.f / Q.w;
float s = 1; // Q.w == 0.f ? 0.f : 1.f / Q.w;

return fabsf(r) * s;
}
Expand Down Expand Up @@ -1325,7 +1325,7 @@ static void fillCellQuadrics(Quadric* cell_quadrics, const unsigned int* indices

static void fillCellReservoirs(Reservoir* cell_reservoirs, size_t cell_count, const Vector3* vertex_positions, const float* vertex_colors, size_t vertex_colors_stride, size_t vertex_count, const unsigned int* vertex_cells)
{
static const float dummy_color[] = { 0.f, 0.f, 0.f };
static const float dummy_color[] = {0.f, 0.f, 0.f};

size_t vertex_colors_stride_float = vertex_colors_stride / sizeof(float);

Expand Down Expand Up @@ -1380,7 +1380,7 @@ static void fillCellRemap(unsigned int* cell_remap, float* cell_errors, size_t c

static void fillCellRemap(unsigned int* cell_remap, float* cell_errors, size_t cell_count, const unsigned int* vertex_cells, const Reservoir* cell_reservoirs, const Vector3* vertex_positions, const float* vertex_colors, size_t vertex_colors_stride, float color_weight, size_t vertex_count)
{
static const float dummy_color[] = { 0.f, 0.f, 0.f };
static const float dummy_color[] = {0.f, 0.f, 0.f};

size_t vertex_colors_stride_float = vertex_colors_stride / sizeof(float);

Expand Down

0 comments on commit e2ee634

Please sign in to comment.