| 339 | // ── Vector and matrix types ── |
| 340 | |
| 341 | void testVectorTypes() { |
| 342 | rcx::NodeTree tree; |
| 343 | rcx::Node root; |
| 344 | root.kind = rcx::NodeKind::Struct; |
| 345 | root.name = "Vectors"; |
| 346 | root.structTypeName = "Vectors"; |
| 347 | root.parentId = 0; |
| 348 | int ri = tree.addNode(root); |
| 349 | uint64_t rootId = tree.nodes[ri].id; |
| 350 | |
| 351 | rcx::Node v2; |
| 352 | v2.kind = rcx::NodeKind::Vec2; |
| 353 | v2.name = "pos2d"; |
| 354 | v2.parentId = rootId; |
| 355 | v2.offset = 0; |
| 356 | tree.addNode(v2); |
| 357 | |
| 358 | rcx::Node v3; |
| 359 | v3.kind = rcx::NodeKind::Vec3; |
| 360 | v3.name = "pos3d"; |
| 361 | v3.parentId = rootId; |
| 362 | v3.offset = 8; |
| 363 | tree.addNode(v3); |
| 364 | |
| 365 | rcx::Node v4; |
| 366 | v4.kind = rcx::NodeKind::Vec4; |
| 367 | v4.name = "color"; |
| 368 | v4.parentId = rootId; |
| 369 | v4.offset = 20; |
| 370 | tree.addNode(v4); |
| 371 | |
| 372 | rcx::Node mat; |
| 373 | mat.kind = rcx::NodeKind::Mat4x4; |
| 374 | mat.name = "transform"; |
| 375 | mat.parentId = rootId; |
| 376 | mat.offset = 36; |
| 377 | tree.addNode(mat); |
| 378 | |
| 379 | QString result = rcx::renderCpp(tree, rootId); |
| 380 | |
| 381 | QVERIFY(result.contains("float pos2d[2];")); |
| 382 | QVERIFY(result.contains("float pos3d[3];")); |
| 383 | QVERIFY(result.contains("float color[4];")); |
| 384 | QVERIFY(result.contains("float transform[4][4];")); |
| 385 | } |
| 386 | |
| 387 | // ── String types ── |
| 388 | |