test(P4-06): glTF nested node hierarchy
This commit is contained in:
@@ -443,6 +443,30 @@ std::string node_rotation_scale_fixture() {
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::string node_nested_fixture() {
|
||||
std::vector<unsigned char> blob;
|
||||
const float points[3][3] = {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}};
|
||||
for (const auto& p : points) {
|
||||
append_float_le(&blob, p[0]);
|
||||
append_float_le(&blob, p[1]);
|
||||
append_float_le(&blob, p[2]);
|
||||
}
|
||||
const std::string uri = "data:application/octet-stream;base64," + encode_base64(blob);
|
||||
char buffer[2048];
|
||||
std::snprintf(buffer, sizeof(buffer),
|
||||
"{\"asset\":{\"version\":\"2.0\"},"
|
||||
"\"buffers\":[{\"uri\":\"%s\",\"byteLength\":%zu}],"
|
||||
"\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":36}],"
|
||||
"\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":3,"
|
||||
"\"type\":\"VEC3\"}],"
|
||||
"\"meshes\":[{\"primitives\":[{\"attributes\":{\"POSITION\":0}}]}],"
|
||||
"\"nodes\":[{\"translation\":[10,0,0],\"children\":[1]},"
|
||||
"{\"mesh\":0,\"translation\":[0,20,0]}],"
|
||||
"\"scenes\":[{\"nodes\":[0]}],\"scene\":0}",
|
||||
uri.c_str(), blob.size());
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::string minimal_external_buffer_json() {
|
||||
return
|
||||
"{\"asset\":{\"version\":\"2.0\"},"
|
||||
@@ -647,6 +671,23 @@ int run(const char* plugin_path, const char* work_dir) {
|
||||
if (bodies) host.free(bodies);
|
||||
}
|
||||
|
||||
{
|
||||
const std::string json = node_nested_fixture();
|
||||
VdeBody* bodies = nullptr;
|
||||
std::size_t count = 0;
|
||||
g_host_error.clear();
|
||||
const int rc = format->read_memory(&host, json.data(), json.size(), &bodies, &count);
|
||||
check(rc == VDE_PLUGIN_OK, "nested node read OK");
|
||||
check(count == 1, "nested node body count=1");
|
||||
if (count == 1) {
|
||||
const double lo[3] = {10.0, 20.0, 0.0};
|
||||
const double hi[3] = {11.0, 21.0, 0.0};
|
||||
check(bbox_matches(host, bodies[0], lo, hi), "nested node bbox");
|
||||
}
|
||||
for (std::size_t i = 0; i < count; ++i) host.body_destroy(bodies[i]);
|
||||
if (bodies) host.free(bodies);
|
||||
}
|
||||
|
||||
// 5) 错误路径:显式失败 + set_error,不允许静默成功
|
||||
auto expect_read_failure = [&](const std::string& json, const char* label) {
|
||||
g_host_error.clear();
|
||||
|
||||
Reference in New Issue
Block a user