1 #include "bones/skin.hpp"
2 #include "bones/tendon.hpp"
4 #include "core/binary_reader.hpp"
6 #include "no_op_renderer.hpp"
8 #include "shapes/clipping_shape.hpp"
9 #include "shapes/path_vertex.hpp"
10 #include "shapes/points_path.hpp"
11 #include "shapes/rectangle.hpp"
12 #include "shapes/shape.hpp"
15 TEST_CASE("bound bones load correctly", "[bones]")
17 FILE* fp = fopen("../../test/assets/off_road_car.riv", "r");
18 REQUIRE(fp != nullptr);
20 fseek(fp, 0, SEEK_END);
21 auto length = ftell(fp);
22 fseek(fp, 0, SEEK_SET);
23 uint8_t* bytes = new uint8_t[length];
24 REQUIRE(fread(bytes, 1, length, fp) == length);
25 auto reader = rive::BinaryReader(bytes, length);
26 rive::File* file = nullptr;
28 auto result = rive::File::import(reader, &file);
30 REQUIRE(result == rive::ImportResult::success);
32 REQUIRE(file != nullptr);
33 REQUIRE(file->artboard() != nullptr);
35 auto node = file->artboard()->find("transmission_front_testing");
36 REQUIRE(node != nullptr);
37 REQUIRE(node->is<rive::Shape>());
38 REQUIRE(node->as<rive::Shape>()->paths().size() == 1);
39 auto path = node->as<rive::Shape>()->paths()[0];
40 REQUIRE(path->is<rive::PointsPath>());
41 auto pointsPath = path->as<rive::PointsPath>();
42 REQUIRE(pointsPath->skin() != nullptr);
43 REQUIRE(pointsPath->skin()->tendons().size() == 2);
44 REQUIRE(pointsPath->skin()->tendons()[0]->bone() != nullptr);
45 REQUIRE(pointsPath->skin()->tendons()[1]->bone() != nullptr);
47 for (auto vertex : path->vertices())
49 REQUIRE(vertex->weight() != nullptr);
52 // Ok seems like bones are set up ok.