main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
7 changed files with 47 additions and 37 deletions
Showing only changes of commit 3b8a050fc1 - Show all commits

View File

@ -387,7 +387,7 @@ TEST(BKE_fcurve, BKE_fcurve_calc_range)
/* Curve samples. */ /* Curve samples. */
const int sample_start = 1; const int sample_start = 1;
const int sample_end = 20; const int sample_end = 20;
fcurve_store_samples(fcu, NULL, sample_start, sample_end, fcurve_samplingcb_evalcurve); fcurve_store_samples(fcu, nullptr, sample_start, sample_end, fcurve_samplingcb_evalcurve);
success = BKE_fcurve_calc_range(fcu, &min, &max, true); success = BKE_fcurve_calc_range(fcu, &min, &max, true);
EXPECT_TRUE(success) << "FCurve samples should have a range."; EXPECT_TRUE(success) << "FCurve samples should have a range.";
@ -421,8 +421,11 @@ TEST(BKE_fcurve, BKE_fcurve_calc_bounds)
bool success; bool success;
/* All keys. */ /* All keys. */
success = BKE_fcurve_calc_bounds( success = BKE_fcurve_calc_bounds(fcu,
fcu, false /* select only */, false /* include handles */, NULL /* frame range */, &bounds); false /* select only */,
false /* include handles */,
nullptr /* frame range */,
&bounds);
EXPECT_TRUE(success) << "A non-empty FCurve should have bounds."; EXPECT_TRUE(success) << "A non-empty FCurve should have bounds.";
EXPECT_FLOAT_EQ(fcu->bezt[0].vec[1][0], bounds.xmin); EXPECT_FLOAT_EQ(fcu->bezt[0].vec[1][0], bounds.xmin);
EXPECT_FLOAT_EQ(fcu->bezt[4].vec[1][0], bounds.xmax); EXPECT_FLOAT_EQ(fcu->bezt[4].vec[1][0], bounds.xmax);
@ -430,16 +433,22 @@ TEST(BKE_fcurve, BKE_fcurve_calc_bounds)
EXPECT_FLOAT_EQ(fcu->bezt[2].vec[1][1], bounds.ymax); EXPECT_FLOAT_EQ(fcu->bezt[2].vec[1][1], bounds.ymax);
/* Only selected. */ /* Only selected. */
success = BKE_fcurve_calc_bounds( success = BKE_fcurve_calc_bounds(fcu,
fcu, true /* select only */, false /* include handles */, NULL /* frame range */, &bounds); true /* select only */,
false /* include handles */,
nullptr /* frame range */,
&bounds);
EXPECT_FALSE(success) EXPECT_FALSE(success)
<< "Using selected keyframes only should not find bounds if nothing is selected."; << "Using selected keyframes only should not find bounds if nothing is selected.";
fcu->bezt[1].f2 |= SELECT; fcu->bezt[1].f2 |= SELECT;
fcu->bezt[3].f2 |= SELECT; fcu->bezt[3].f2 |= SELECT;
success = BKE_fcurve_calc_bounds( success = BKE_fcurve_calc_bounds(fcu,
fcu, true /* select only */, false /* include handles */, NULL /* frame range */, &bounds); true /* select only */,
false /* include handles */,
nullptr /* frame range */,
&bounds);
EXPECT_TRUE(success) << "Selected keys should have been found."; EXPECT_TRUE(success) << "Selected keys should have been found.";
EXPECT_FLOAT_EQ(fcu->bezt[1].vec[1][0], bounds.xmin); EXPECT_FLOAT_EQ(fcu->bezt[1].vec[1][0], bounds.xmin);
EXPECT_FLOAT_EQ(fcu->bezt[3].vec[1][0], bounds.xmax); EXPECT_FLOAT_EQ(fcu->bezt[3].vec[1][0], bounds.xmax);
@ -447,8 +456,11 @@ TEST(BKE_fcurve, BKE_fcurve_calc_bounds)
EXPECT_FLOAT_EQ(fcu->bezt[3].vec[1][1], bounds.ymax); EXPECT_FLOAT_EQ(fcu->bezt[3].vec[1][1], bounds.ymax);
/* Including handles. */ /* Including handles. */
success = BKE_fcurve_calc_bounds( success = BKE_fcurve_calc_bounds(fcu,
fcu, false /* select only */, true /* include handles */, NULL /* frame range */, &bounds); false /* select only */,
true /* include handles */,
nullptr /* frame range */,
&bounds);
EXPECT_TRUE(success) << "A non-empty FCurve should have bounds including handles."; EXPECT_TRUE(success) << "A non-empty FCurve should have bounds including handles.";
EXPECT_FLOAT_EQ(fcu->bezt[0].vec[0][0], bounds.xmin); EXPECT_FLOAT_EQ(fcu->bezt[0].vec[0][0], bounds.xmin);
EXPECT_FLOAT_EQ(fcu->bezt[4].vec[2][0], bounds.xmax); EXPECT_FLOAT_EQ(fcu->bezt[4].vec[2][0], bounds.xmax);
@ -499,10 +511,13 @@ TEST(BKE_fcurve, BKE_fcurve_calc_bounds)
/* Curve samples. */ /* Curve samples. */
const int sample_start = 1; const int sample_start = 1;
const int sample_end = 20; const int sample_end = 20;
fcurve_store_samples(fcu, NULL, sample_start, sample_end, fcurve_samplingcb_evalcurve); fcurve_store_samples(fcu, nullptr, sample_start, sample_end, fcurve_samplingcb_evalcurve);
success = BKE_fcurve_calc_bounds( success = BKE_fcurve_calc_bounds(fcu,
fcu, false /* select only */, false /* include handles */, NULL /* frame range */, &bounds); false /* select only */,
false /* include handles */,
nullptr /* frame range */,
&bounds);
EXPECT_TRUE(success) << "FCurve samples should have a range."; EXPECT_TRUE(success) << "FCurve samples should have a range.";
EXPECT_FLOAT_EQ(sample_start, bounds.xmin); EXPECT_FLOAT_EQ(sample_start, bounds.xmin);

View File

@ -63,18 +63,12 @@ TEST(math_rotation_types, Euler3Order)
/* Asserts those match. /* Asserts those match.
* Do not do it in the header to avoid including the DNA header everywhere. * Do not do it in the header to avoid including the DNA header everywhere.
*/ */
BLI_STATIC_ASSERT( BLI_STATIC_ASSERT(int(EulerOrder::XYZ) == int(eRotationModes::ROT_MODE_XYZ), "");
static_cast<int>(EulerOrder::XYZ) == static_cast<int>(eRotationModes::ROT_MODE_XYZ), ""); BLI_STATIC_ASSERT(int(EulerOrder::XZY) == int(eRotationModes::ROT_MODE_XZY), "");
BLI_STATIC_ASSERT( BLI_STATIC_ASSERT(int(EulerOrder::YXZ) == int(eRotationModes::ROT_MODE_YXZ), "");
static_cast<int>(EulerOrder::XZY) == static_cast<int>(eRotationModes::ROT_MODE_XZY), ""); BLI_STATIC_ASSERT(int(EulerOrder::YZX) == int(eRotationModes::ROT_MODE_YZX), "");
BLI_STATIC_ASSERT( BLI_STATIC_ASSERT(int(EulerOrder::ZXY) == int(eRotationModes::ROT_MODE_ZXY), "");
static_cast<int>(EulerOrder::YXZ) == static_cast<int>(eRotationModes::ROT_MODE_YXZ), ""); BLI_STATIC_ASSERT(int(EulerOrder::ZYX) == int(eRotationModes::ROT_MODE_ZYX), "");
BLI_STATIC_ASSERT(
static_cast<int>(EulerOrder::YZX) == static_cast<int>(eRotationModes::ROT_MODE_YZX), "");
BLI_STATIC_ASSERT(
static_cast<int>(EulerOrder::ZXY) == static_cast<int>(eRotationModes::ROT_MODE_ZXY), "");
BLI_STATIC_ASSERT(
static_cast<int>(EulerOrder::ZYX) == static_cast<int>(eRotationModes::ROT_MODE_ZYX), "");
EXPECT_EQ(float3(Euler3(0, 1, 2, EulerOrder::XYZ).ijk()), float3(0, 1, 2)); EXPECT_EQ(float3(Euler3(0, 1, 2, EulerOrder::XYZ).ijk()), float3(0, 1, 2));
EXPECT_EQ(float3(Euler3(0, 1, 2, EulerOrder::XZY).ijk()), float3(0, 2, 1)); EXPECT_EQ(float3(Euler3(0, 1, 2, EulerOrder::XZY).ijk()), float3(0, 2, 1));

View File

@ -112,12 +112,12 @@ void *GPU_debug_capture_scope_create(const char *name)
{ {
/* GPU Frame capture is only enabled when --debug-gpu is specified. */ /* GPU Frame capture is only enabled when --debug-gpu is specified. */
if (!(G.debug & G_DEBUG_GPU)) { if (!(G.debug & G_DEBUG_GPU)) {
return NULL; return nullptr;
} }
Context *ctx = Context::get(); Context *ctx = Context::get();
if (!ctx) { if (!ctx) {
return NULL; return nullptr;
} }
return ctx->debug_capture_scope_create(name); return ctx->debug_capture_scope_create(name);
} }

View File

@ -209,7 +209,7 @@ static ImBuf *get_oiio_ibuf(ImageInput *in, const ReadContext &ctx, char colorsp
if (x_res > 0.0f && y_res > 0.0f) { if (x_res > 0.0f && y_res > 0.0f) {
double scale = 1.0; double scale = 1.0;
auto unit = spec.get_string_attribute("ResolutionUnit", ""); auto unit = spec.get_string_attribute("ResolutionUnit", "");
if (unit == "in" || unit == "inch") { if (ELEM(unit, "in", "inch")) {
scale = 100.0 / 2.54; scale = 100.0 / 2.54;
} }
else if (unit == "cm") { else if (unit == "cm") {

View File

@ -102,30 +102,30 @@ void importer_main(Main *bmain,
Vector<std::string> words{}; Vector<std::string> words{};
splitstr(line, words, " "); splitstr(line, words, " ");
if (strcmp(words[0].c_str(), "format") == 0) { if (STREQ(words[0].c_str(), "format")) {
if (strcmp(words[1].c_str(), "ascii") == 0) { if (STREQ(words[1].c_str(), "ascii")) {
header.type = PlyFormatType::ASCII; header.type = PlyFormatType::ASCII;
} }
else if (strcmp(words[1].c_str(), "binary_big_endian") == 0) { else if (STREQ(words[1].c_str(), "binary_big_endian")) {
header.type = PlyFormatType::BINARY_BE; header.type = PlyFormatType::BINARY_BE;
} }
else if (strcmp(words[1].c_str(), "binary_little_endian") == 0) { else if (STREQ(words[1].c_str(), "binary_little_endian")) {
header.type = PlyFormatType::BINARY_LE; header.type = PlyFormatType::BINARY_LE;
} }
} }
else if (strcmp(words[0].c_str(), "element") == 0) { else if (STREQ(words[0].c_str(), "element")) {
header.elements.append(std::make_pair(words[1], std::stoi(words[2]))); header.elements.append(std::make_pair(words[1], std::stoi(words[2])));
if (strcmp(words[1].c_str(), "vertex") == 0) { if (STREQ(words[1].c_str(), "vertex")) {
header.vertex_count = std::stoi(words[2]); header.vertex_count = std::stoi(words[2]);
} }
else if (strcmp(words[1].c_str(), "face") == 0) { else if (STREQ(words[1].c_str(), "face")) {
header.face_count = std::stoi(words[2]); header.face_count = std::stoi(words[2]);
} }
else if (strcmp(words[1].c_str(), "edge") == 0) { else if (STREQ(words[1].c_str(), "edge")) {
header.edge_count = std::stoi(words[2]); header.edge_count = std::stoi(words[2]);
} }
} }
else if (strcmp(words[0].c_str(), "property") == 0) { else if (STREQ(words[0].c_str(), "property")) {
std::pair<std::string, PlyDataTypes> property; std::pair<std::string, PlyDataTypes> property;
property.first = words[2]; property.first = words[2];
property.second = from_string(words[1]); property.second = from_string(words[1]);

View File

@ -187,7 +187,7 @@ int get_index(const PlyHeader *header, std::string property, PlyDataTypes dataty
std::pair<std::string, PlyDataTypes> pair = {property, datatype}; std::pair<std::string, PlyDataTypes> pair = {property, datatype};
const std::pair<std::string, blender::io::ply::PlyDataTypes> *it = std::find( const std::pair<std::string, blender::io::ply::PlyDataTypes> *it = std::find(
header->properties[0].begin(), header->properties[0].end(), pair); header->properties[0].begin(), header->properties[0].end(), pair);
return (int)(it - header->properties[0].begin()); return int(it - header->properties[0].begin());
} }
Vector<std::string> explode(const StringRef str, const char &ch) Vector<std::string> explode(const StringRef str, const char &ch)

View File

@ -971,6 +971,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
/* must recalculate normals with vgroups since they can displace unevenly #26888. */ /* must recalculate normals with vgroups since they can displace unevenly #26888. */
if (BKE_mesh_vert_normals_are_dirty(mesh) || do_rim || dvert) { if (BKE_mesh_vert_normals_are_dirty(mesh) || do_rim || dvert) {
/* Pass. */
} }
else if (do_shell) { else if (do_shell) {
uint i; uint i;