Cleanup: various C/C++ code cleanups, use utility macros
This commit is contained in:
@@ -603,8 +603,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh,
|
||||
}
|
||||
for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) {
|
||||
int ty = source_cd->layers[source_layer_i].type;
|
||||
if (STREQ(source_cd->layers[source_layer_i].name, ".corner_vert") ||
|
||||
STREQ(source_cd->layers[source_layer_i].name, ".corner_edge")) {
|
||||
if (STR_ELEM(source_cd->layers[source_layer_i].name, ".corner_vert", ".corner_edge")) {
|
||||
continue;
|
||||
}
|
||||
const char *name = source_cd->layers[source_layer_i].name;
|
||||
|
||||
@@ -1041,7 +1041,7 @@ static void ccgDM_copyFinalCornerVertArray(DerivedMesh *dm, int *r_corner_verts)
|
||||
CopyFinalLoopArrayData data;
|
||||
data.ccgdm = ccgdm;
|
||||
data.corner_verts = r_corner_verts;
|
||||
data.corner_edges = NULL;
|
||||
data.corner_edges = nullptr;
|
||||
data.grid_size = ccgSubSurf_getGridSize(ss);
|
||||
data.grid_offset = dm->getGridOffset(dm);
|
||||
data.edge_size = ccgSubSurf_getEdgeSize(ss);
|
||||
@@ -1085,7 +1085,7 @@ static void ccgDM_copyFinalCornerEdgeArray(DerivedMesh *dm, int *r_corner_edges)
|
||||
|
||||
CopyFinalLoopArrayData data;
|
||||
data.ccgdm = ccgdm;
|
||||
data.corner_verts = NULL;
|
||||
data.corner_verts = nullptr;
|
||||
data.corner_edges = r_corner_edges;
|
||||
data.grid_size = ccgSubSurf_getGridSize(ss);
|
||||
data.grid_offset = dm->getGridOffset(dm);
|
||||
|
||||
@@ -99,8 +99,8 @@ class ImageEngine {
|
||||
/* Setup the matrix to go from screen UV coordinates to UV texture space coordinates. */
|
||||
float image_resolution[2] = {image_buffer ? image_buffer->x : 1024.0f,
|
||||
image_buffer ? image_buffer->y : 1024.0f};
|
||||
float image_offset[2] = {(float)instance_data->image->offset_x,
|
||||
(float)instance_data->image->offset_y};
|
||||
float image_offset[2] = {float(instance_data->image->offset_x),
|
||||
float(instance_data->image->offset_y)};
|
||||
space->init_ss_to_texture_matrix(
|
||||
draw_ctx->region, image_offset, image_resolution, instance_data->ss_to_texture);
|
||||
|
||||
|
||||
@@ -638,15 +638,15 @@ static void cage2d_draw_rect_edge_handles(const rctf *r,
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X:
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: {
|
||||
const float rad[2] = {0.2f * margin[0], 0.4f * size[1]};
|
||||
imm_draw_point_aspect_2d(pos, r->xmin, 0.f, rad[0], rad[1], solid);
|
||||
imm_draw_point_aspect_2d(pos, r->xmax, 0.f, rad[0], rad[1], solid);
|
||||
imm_draw_point_aspect_2d(pos, r->xmin, 0.0f, rad[0], rad[1], solid);
|
||||
imm_draw_point_aspect_2d(pos, r->xmax, 0.0f, rad[0], rad[1], solid);
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y:
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y: {
|
||||
const float rad[2] = {0.4f * size[0], 0.2f * margin[1]};
|
||||
imm_draw_point_aspect_2d(pos, 0.f, r->ymin, rad[0], rad[1], solid);
|
||||
imm_draw_point_aspect_2d(pos, 0.f, r->ymax, rad[0], rad[1], solid);
|
||||
imm_draw_point_aspect_2d(pos, 0.0f, r->ymin, rad[0], rad[1], solid);
|
||||
imm_draw_point_aspect_2d(pos, 0.0f, r->ymax, rad[0], rad[1], solid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,7 +845,7 @@ static void define_primitive_add_properties(wmOperatorType *ot)
|
||||
static int primitive_circle_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const float points[4][2] = {{0.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f}, {0.5f, 0.0f}};
|
||||
int num_points = sizeof(points) / sizeof(float[2]);
|
||||
int num_points = ARRAY_SIZE(points);
|
||||
|
||||
create_primitive_from_points(C, op, points, num_points, HD_AUTO);
|
||||
|
||||
@@ -880,7 +880,7 @@ void MASK_OT_primitive_circle_add(wmOperatorType *ot)
|
||||
static int primitive_square_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const float points[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}};
|
||||
int num_points = sizeof(points) / sizeof(float[2]);
|
||||
int num_points = ARRAY_SIZE(points);
|
||||
|
||||
create_primitive_from_points(C, op, points, num_points, HD_VECT);
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
|
||||
for (const LibraryAsset &item : asset_items) {
|
||||
uiLayout *col = uiLayoutColumn(layout, false);
|
||||
|
||||
PointerRNA asset_ptr{NULL, &RNA_AssetRepresentation, &item.asset};
|
||||
PointerRNA asset_ptr{nullptr, &RNA_AssetRepresentation, &item.asset};
|
||||
uiLayoutSetContextPointer(col, "asset", &asset_ptr);
|
||||
|
||||
PointerRNA library_ptr{&screen.id,
|
||||
|
||||
@@ -953,7 +953,7 @@ void GPU_material_compile(GPUMaterial *mat)
|
||||
* configurations to ensure compile time remains fast, as these first
|
||||
* entries will be the most commonly used PSOs. As not all PSOs are necessarily
|
||||
* required immediately, this limit should remain low (1-3 at most). */
|
||||
if (mat->default_mat != NULL && mat->default_mat != mat) {
|
||||
if (!ELEM(mat->default_mat, NULL, mat)) {
|
||||
if (mat->default_mat->pass != NULL) {
|
||||
GPUShader *parent_sh = GPU_pass_shader_get(mat->default_mat->pass);
|
||||
if (parent_sh) {
|
||||
|
||||
@@ -52,8 +52,7 @@ static IKPlugin ikplugin_tab[] = {
|
||||
|
||||
static IKPlugin *get_plugin(bPose *pose)
|
||||
{
|
||||
if (!pose || pose->iksolver < 0 ||
|
||||
pose->iksolver >= ((sizeof(ikplugin_tab) / sizeof(IKPlugin)) - 1)) {
|
||||
if (!pose || pose->iksolver < 0 || pose->iksolver >= ((ARRAY_SIZE(ikplugin_tab)) - 1)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ const FormatDescriptor s_d3dFormats[] = {
|
||||
{D3DFMT_L16, 16, 16, 0, 0, 0}, /* DXGI_FORMAT_R16_UNORM */
|
||||
};
|
||||
|
||||
const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
|
||||
const uint s_d3dFormatCount = ARRAY_SIZE(s_d3dFormats);
|
||||
|
||||
} /* namespace */
|
||||
|
||||
|
||||
@@ -62,28 +62,28 @@ static void skip_space(Span<char> &str)
|
||||
static PlyDataTypes type_from_string(Span<char> word)
|
||||
{
|
||||
StringRef input(word.data(), word.size());
|
||||
if (input == "uchar" || input == "uint8") {
|
||||
if (ELEM(input, "uchar", "uint8")) {
|
||||
return PlyDataTypes::UCHAR;
|
||||
}
|
||||
if (input == "char" || input == "int8") {
|
||||
if (ELEM(input, "char", "int8")) {
|
||||
return PlyDataTypes::CHAR;
|
||||
}
|
||||
if (input == "ushort" || input == "uint16") {
|
||||
if (ELEM(input, "ushort", "uint16")) {
|
||||
return PlyDataTypes::USHORT;
|
||||
}
|
||||
if (input == "short" || input == "int16") {
|
||||
if (ELEM(input, "short", "int16")) {
|
||||
return PlyDataTypes::SHORT;
|
||||
}
|
||||
if (input == "uint" || input == "uint32") {
|
||||
if (ELEM(input, "uint", "uint32")) {
|
||||
return PlyDataTypes::UINT;
|
||||
}
|
||||
if (input == "int" || input == "int32") {
|
||||
if (ELEM(input, "int", "int32")) {
|
||||
return PlyDataTypes::INT;
|
||||
}
|
||||
if (input == "float" || input == "float32") {
|
||||
if (ELEM(input, "float", "float32")) {
|
||||
return PlyDataTypes::FLOAT;
|
||||
}
|
||||
if (input == "double" || input == "float64") {
|
||||
if (ELEM(input, "double", "float64")) {
|
||||
return PlyDataTypes::DOUBLE;
|
||||
}
|
||||
return PlyDataTypes::NONE;
|
||||
|
||||
@@ -53,7 +53,7 @@ class ply_import_test : public testing::Test {
|
||||
BLI_hash_mm2a_init(&hash, 0);
|
||||
uint32_t offset = 0;
|
||||
for (uint32_t face_size : data->face_sizes) {
|
||||
BLI_hash_mm2a_add(&hash, (const unsigned char *)&data->face_vertices[offset], face_size * 4);
|
||||
BLI_hash_mm2a_add(&hash, (const uchar *)&data->face_vertices[offset], face_size * 4);
|
||||
offset += face_size;
|
||||
}
|
||||
uint16_t face_hash = BLI_hash_mm2a_end(&hash);
|
||||
@@ -62,9 +62,8 @@ class ply_import_test : public testing::Test {
|
||||
}
|
||||
|
||||
if (!data->edges.is_empty()) {
|
||||
uint16_t edge_hash = BLI_hash_mm2((const unsigned char *)data->edges.data(),
|
||||
data->edges.size() * sizeof(data->edges[0]),
|
||||
0);
|
||||
uint16_t edge_hash = BLI_hash_mm2(
|
||||
(const uchar *)data->edges.data(), data->edges.size() * sizeof(data->edges[0]), 0);
|
||||
ASSERT_EQ(edge_hash, exp.edgehash);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
||||
const int vert_i = orig_corner_verts[corner_i];
|
||||
const int prev_vert_i = orig_corner_verts[corner_i_prev];
|
||||
/* add edge user */
|
||||
eidx = (int)(orig_corner_edges[corner_i_prev]);
|
||||
eidx = int(orig_corner_edges[corner_i_prev]);
|
||||
if (edge_users[eidx] == INVALID_UNUSED) {
|
||||
edge = &orig_edges[eidx];
|
||||
BLI_assert(ELEM(prev_vert_i, edge->v1, edge->v2) && ELEM(vert_i, edge->v1, edge->v2));
|
||||
|
||||
@@ -1177,9 +1177,9 @@ static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObje
|
||||
for (i = 0; i < tris_len; i++, lt++) {
|
||||
float co[3][3];
|
||||
|
||||
tris[i][0] = (uint)corner_verts[lt->tri[0]];
|
||||
tris[i][1] = (uint)corner_verts[lt->tri[1]];
|
||||
tris[i][2] = (uint)corner_verts[lt->tri[2]];
|
||||
tris[i][0] = uint(corner_verts[lt->tri[0]]);
|
||||
tris[i][1] = uint(corner_verts[lt->tri[1]]);
|
||||
tris[i][2] = uint(corner_verts[lt->tri[2]]);
|
||||
|
||||
copy_v3_v3(co[0], coords[tris[i][0]]);
|
||||
copy_v3_v3(co[1], coords[tris[i][1]]);
|
||||
|
||||
@@ -481,7 +481,7 @@ static void do_multires_bake(MultiresBakeRender *bkr,
|
||||
const float(*positions)[3] = (float(*)[3])dm->getVertArray(dm);
|
||||
const MPoly *polys = dm->getPolyArray(dm);
|
||||
float(*mloopuv)[2] = static_cast<float(*)[2]>(dm->getLoopDataArray(dm, CD_PROP_FLOAT2));
|
||||
float *pvtangent = NULL;
|
||||
float *pvtangent = nullptr;
|
||||
|
||||
ListBase threads;
|
||||
int i, tot_thread = bkr->threads > 0 ? bkr->threads : BLI_system_thread_count();
|
||||
|
||||
Reference in New Issue
Block a user