Repository navigation
Expand file tree
/
Copy pathapiCore.cpp
More file actions
1588 lines (1423 loc) · 62.6 KB
/
Copy pathapiCore.cpp
File metadata and controls
1588 lines (1423 loc) · 62.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2022 Robotec.AI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <rgl/api/core.h>
#include <rgl/api/extensions/tape.h>
#include <api/apiCommon.hpp>
#include <tape/TapeCore.hpp>
#include <scene/Scene.hpp>
#include <scene/Entity.hpp>
#include <scene/Mesh.hpp>
#include <scene/Texture.hpp>
#include <graph/NodesCore.hpp>
#include <graph/GraphRunCtx.hpp>
#include <NvtxWrappers.hpp>
extern "C" {
RGL_API rgl_status_t rgl_get_version_info(int32_t* out_major, int32_t* out_minor, int32_t* out_patch)
{
// Short pre-changelog API version history:
// This is a brief shortcut for devs!
// 0.1: PoC via dlopen
// 0.2: added E2E PCL formats (12, 24, 48), ringIds, postRaycastTransform
// 0.3: implemented async calls
// 0.4: added HasMesh to allow optimization
// 0.5: implemented scene management via native API
// 0.6: added gaussian noise API
// 0.7: pre-open-source API cleanup
// 0.8: removed hash and suffix args - will be logged instead
// 0.9: added rgl_configure_logging
// 0.9.1: optimized rgl_mesh_update_vertices
// 0.9.2: remove external dependency (gdt)
// 0.9.3: add API unit tests with fixes, in particular: optix logging
// 0.10.0: entities can now share meshes
// 0.10.1: API const correctness, added INVALID_OBJECT error, minor internal changes
// 0.10.2: Fixed Lidar::getResults writing too many bytes
// 0.11.0: implement Graph API (Gaussian noise temporarily removed)
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_get_version_info(out_major={}, out_minor={}, out_patch={})", (void*) out_major, (void*) out_minor,
(void*) out_patch);
CHECK_ARG(out_major != nullptr);
CHECK_ARG(out_minor != nullptr);
CHECK_ARG(out_patch != nullptr);
*out_major = RGL_VERSION_MAJOR;
*out_minor = RGL_VERSION_MINOR;
*out_patch = RGL_VERSION_PATCH;
});
TAPE_HOOK(out_major, out_minor, out_patch);
return status;
}
void TapeCore::tape_get_version_info(const YAML::Node& yamlNode, PlaybackState& state)
{
int32_t out_major, out_minor, out_patch;
rgl_get_version_info(&out_major, &out_minor, &out_patch);
if (out_major != yamlNode[0].as<int32_t>()) {
RGL_WARN("tape_get_version_info: out_major mismatch");
}
if (out_minor != yamlNode[1].as<int32_t>()) {
RGL_WARN("tape_get_version_info: out_minor mismatch");
}
if (out_patch != yamlNode[2].as<int32_t>()) {
RGL_WARN("tape_get_version_info: out_patch mismatch");
}
}
RGL_API rgl_status_t rgl_get_extension_info(rgl_extension_t extension, int32_t* out_available)
{
auto status = rglSafeCall([&]() {
CHECK_ARG(0 <= extension && extension < RGL_EXTENSION_COUNT);
CHECK_ARG(out_available != nullptr);
switch (extension) {
case RGL_EXTENSION_PCL: *out_available = RGL_BUILD_PCL_EXTENSION; break;
case RGL_EXTENSION_ROS2: *out_available = RGL_BUILD_ROS2_EXTENSION; break;
case RGL_EXTENSION_UDP: *out_available = RGL_BUILD_UDP_EXTENSION; break;
case RGL_EXTENSION_WEATHER: *out_available = RGL_BUILD_WEATHER_EXTENSION; break;
default: throw std::invalid_argument(fmt::format("queried unknown RGL extension: {}", extension));
}
});
TAPE_HOOK(extension, out_available);
return status;
}
void TapeCore::tape_get_extension_info(const YAML::Node& yamlNode, PlaybackState& state)
{
int32_t out_available;
int32_t recorded_available = yamlNode[1].as<int32_t>();
rgl_get_extension_info(static_cast<rgl_extension_t>(yamlNode[0].as<int32_t>()), &out_available);
if (out_available != recorded_available) {
RGL_WARN(
fmt::format("tape_get_extension_info: result mismatch, recorded={}, actual={}", recorded_available, out_available));
}
}
RGL_API rgl_status_t rgl_configure_logging(rgl_log_level_t log_level, const char* log_file_path, bool use_stdout)
{
auto status = rglSafeCall([&]() {
// No logging here, Logger::configure() will print logs after its initialization.
CHECK_ARG(0 <= log_level && log_level <= 6);
Logger::getOrCreate().configure(log_level, log_file_path, use_stdout);
});
TAPE_HOOK(log_level, log_file_path, use_stdout);
return status;
}
void TapeCore::tape_configure_logging(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_configure_logging((rgl_log_level_t) yamlNode[0].as<int>(), yamlNode[1].as<std::string>().c_str(),
yamlNode[2].as<bool>());
}
RGL_API void rgl_get_last_error_string(const char** out_error_string)
{
if (out_error_string == nullptr) {
return;
}
// NO LOGGING HERE SINCE IT MAY THROW!
*out_error_string = getLastErrorString();
}
RGL_API rgl_status_t rgl_cleanup(void)
{
auto status = rglSafeCall([&]() {
// First, delete nodes, because there might be a thread accessing other structures.
while (!Node::instances.empty()) {
auto node = Node::instances.begin()->second;
if (node->hasGraphRunCtx()) {
try {
// This iterates over all nodes and may trigger pending exceptions
node->getGraphRunCtx()->detachAndDestroy();
}
catch (std::exception& e) {
RGL_WARN("rgl_cleanup: caught pending exception in Node {}: {}", node->getName(), e.what());
continue; // Some node has thrown exception so this graph has not been detached, try again
}
}
auto connectedNodes = node->disconnectConnectedNodes();
for (auto&& nodeToRelease : connectedNodes) {
Node::release(nodeToRelease.get());
}
}
Entity::instances.clear();
Mesh::instances.clear();
Texture::instances.clear();
Scene::instance().clear();
});
TAPE_HOOK();
return status;
}
void TapeCore::tape_cleanup(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_cleanup();
state.clear();
}
RGL_API rgl_status_t rgl_mesh_create(rgl_mesh_t* out_mesh, const rgl_vec3f* vertices, int32_t vertex_count,
const rgl_vec3i* indices, int32_t index_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_mesh_create(out_mesh={}, vertices={}, indices={})", (void*) out_mesh, repr(vertices, vertex_count),
repr(indices, index_count, 1));
CHECK_ARG(out_mesh != nullptr);
CHECK_ARG(vertices != nullptr);
CHECK_ARG(vertex_count > 0);
CHECK_ARG(indices != nullptr);
CHECK_ARG(index_count > 0);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
*out_mesh = Mesh::create(reinterpret_cast<const Vec3f*>(vertices), vertex_count,
reinterpret_cast<const Vec3i*>(indices), index_count)
.get();
});
TAPE_HOOK(out_mesh, TAPE_ARRAY(vertices, vertex_count), vertex_count, TAPE_ARRAY(indices, index_count), index_count);
return status;
}
void TapeCore::tape_mesh_create(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_mesh_t mesh = nullptr;
rgl_mesh_create(&mesh, state.getPtr<const rgl_vec3f>(yamlNode[1]), yamlNode[2].as<int32_t>(),
state.getPtr<const rgl_vec3i>(yamlNode[3]), yamlNode[4].as<int32_t>());
state.meshes.insert(std::make_pair(yamlNode[0].as<TapeAPIObjectID>(), mesh));
}
RGL_API rgl_status_t rgl_mesh_set_texture_coords(rgl_mesh_t mesh, const rgl_vec2f* uvs, int32_t uv_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_mesh_set_texture_coords(mesh={}, uvs={}, uv_count={})", (void*) mesh, repr(uvs, uv_count), uv_count);
CHECK_ARG(mesh != nullptr);
CHECK_ARG(uvs != nullptr);
CHECK_ARG(uv_count > 0);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Mesh::validatePtr(mesh)->setTexCoords(reinterpret_cast<const Vec2f*>(uvs), uv_count);
});
TAPE_HOOK(mesh, TAPE_ARRAY(uvs, uv_count), uv_count);
return status;
}
void TapeCore::tape_mesh_set_texture_coords(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_mesh_set_texture_coords(state.meshes.at(yamlNode[0].as<TapeAPIObjectID>()), state.getPtr<const rgl_vec2f>(yamlNode[1]),
yamlNode[2].as<int32_t>());
}
RGL_API rgl_status_t rgl_mesh_set_bone_weights(rgl_mesh_t mesh, const rgl_bone_weights_t* bone_weights,
int32_t bone_weights_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_mesh_set_bone_weights(mesh={}, bone_weights={})", (void*) mesh,
repr(bone_weights, bone_weights_count));
CHECK_ARG(mesh != nullptr);
CHECK_ARG(bone_weights != nullptr);
CHECK_ARG(bone_weights_count > 0);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Mesh::validatePtr(mesh)->setBoneWeights(bone_weights, bone_weights_count);
});
TAPE_HOOK(mesh, TAPE_ARRAY(bone_weights, bone_weights_count), bone_weights_count);
return status;
}
void TapeCore::tape_mesh_set_bone_weights(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_mesh_set_bone_weights(state.meshes.at(yamlNode[0].as<TapeAPIObjectID>()),
state.getPtr<const rgl_bone_weights_t>(yamlNode[1]), yamlNode[2].as<int32_t>());
}
RGL_API rgl_status_t rgl_mesh_set_restposes(rgl_mesh_t mesh, const rgl_mat3x4f* restposes, int32_t restposes_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_mesh_set_restposes(mesh={}, restposes={})", (void*) mesh, repr(restposes, restposes_count));
CHECK_ARG(mesh != nullptr);
CHECK_ARG(restposes != nullptr);
CHECK_ARG(restposes_count > 0);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Mesh::validatePtr(mesh)->setRestposes(reinterpret_cast<const Mat3x4f*>(restposes), restposes_count);
});
TAPE_HOOK(mesh, TAPE_ARRAY(restposes, restposes_count), restposes_count);
return status;
}
void TapeCore::tape_mesh_set_restposes(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_mesh_set_restposes(state.meshes.at(yamlNode[0].as<TapeAPIObjectID>()), state.getPtr<const rgl_mat3x4f>(yamlNode[1]),
yamlNode[2].as<int32_t>());
}
RGL_API rgl_status_t rgl_mesh_destroy(rgl_mesh_t mesh)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_mesh_destroy(mesh={})", (void*) mesh);
CHECK_ARG(mesh != nullptr);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Mesh::release(mesh);
});
TAPE_HOOK(mesh);
return status;
}
void TapeCore::tape_mesh_destroy(const YAML::Node& yamlNode, PlaybackState& state)
{
auto meshId = yamlNode[0].as<TapeAPIObjectID>();
rgl_mesh_destroy(state.meshes.at(meshId));
state.meshes.erase(meshId);
}
rgl_status_t rgl_mesh_is_alive(rgl_mesh_t mesh, bool* out_alive)
{
auto status = rglSafeCall([&]() {
CHECK_ARG(out_alive != nullptr);
*out_alive = Mesh::instances.contains(mesh);
});
TAPE_HOOK(mesh, out_alive);
return status;
}
RGL_API rgl_status_t rgl_entity_create(rgl_entity_t* out_entity, rgl_scene_t scene, rgl_mesh_t mesh)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_create(out_entity={}, scene={}, mesh={})", (void*) out_entity, (void*) scene, (void*) mesh);
CHECK_ARG(out_entity != nullptr);
CHECK_ARG(mesh != nullptr);
CHECK_ARG(scene == nullptr); // TODO: remove once rgl_scene_t param is removed
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
*out_entity = Entity::create(Mesh::validatePtr(mesh)).get();
});
TAPE_HOOK(out_entity, scene, mesh);
return status;
}
void TapeCore::tape_entity_create(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_t entity = nullptr;
rgl_entity_create(&entity, nullptr, state.meshes.at(yamlNode[2].as<TapeAPIObjectID>()));
state.entities.insert(std::make_pair(yamlNode[0].as<TapeAPIObjectID>(), entity));
}
RGL_API rgl_status_t rgl_entity_destroy(rgl_entity_t entity)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_destroy(entity={})", (void*) entity);
CHECK_ARG(entity != nullptr);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
auto entitySafe = Entity::validatePtr(entity);
Scene::instance().removeEntity(entitySafe);
Entity::release(entity);
});
TAPE_HOOK(entity);
return status;
}
void TapeCore::tape_entity_destroy(const YAML::Node& yamlNode, PlaybackState& state)
{
auto entityId = yamlNode[0].as<TapeAPIObjectID>();
rgl_entity_destroy(state.entities.at(entityId));
state.entities.erase(entityId);
}
RGL_API rgl_status_t rgl_entity_set_transform(rgl_entity_t entity, const rgl_mat3x4f* transform)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_set_transform(entity={}, transform={})", (void*) entity, repr(transform, 1));
CHECK_ARG(entity != nullptr);
CHECK_ARG(transform != nullptr);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
auto tf = Mat3x4f::fromRaw(reinterpret_cast<const float*>(&transform->value[0][0]));
Entity::validatePtr(entity)->setTransform(tf);
});
TAPE_HOOK(entity, transform);
return status;
}
void TapeCore::tape_entity_set_transform(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_set_transform(state.entities.at(yamlNode[0].as<TapeAPIObjectID>()),
state.getPtr<const rgl_mat3x4f>(yamlNode[1]));
}
RGL_API rgl_status_t rgl_entity_set_pose_world(rgl_entity_t entity, const rgl_mat3x4f* pose, int32_t bones_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_set_pose_world(entity={}, pose={})", (void*) entity, repr(pose, bones_count));
CHECK_ARG(entity != nullptr);
CHECK_ARG(pose != nullptr);
CHECK_ARG(bones_count > 0);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Entity::validatePtr(entity)->setPoseAndAnimate(reinterpret_cast<const Mat3x4f*>(pose), bones_count);
});
TAPE_HOOK(entity, TAPE_ARRAY(pose, bones_count), bones_count);
return status;
}
void TapeCore::tape_entity_set_pose_world(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_set_pose_world(state.entities.at(yamlNode[0].as<TapeAPIObjectID>()),
state.getPtr<const rgl_mat3x4f>(yamlNode[1]), yamlNode[2].as<int32_t>());
}
RGL_API rgl_status_t rgl_entity_set_id(rgl_entity_t entity, int32_t id)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_set_id(entity={}, id={})", (void*) entity, id);
CHECK_ARG(entity != nullptr);
CHECK_ARG(id != RGL_ENTITY_INVALID_ID);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Entity::validatePtr(entity)->setId(id);
});
TAPE_HOOK(entity, id);
return status;
}
void TapeCore::tape_entity_set_id(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_set_id(state.entities.at(yamlNode[0].as<TapeAPIObjectID>()), yamlNode[1].as<Field<ENTITY_ID_I32>::type>());
}
RGL_API rgl_status_t rgl_entity_set_ignored_by_sensor(rgl_entity_t entity, int32_t sensor_id)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_set_ignored_by_sensor(entity={}, sensor_id={})", (void*) entity, sensor_id);
CHECK_ARG(entity != nullptr);
GraphRunCtx::synchronizeAll();
Entity::validatePtr(entity)->setIgnoredBySensor(sensor_id);
});
TAPE_HOOK(entity, sensor_id);
return status;
}
void TapeCore::tape_entity_set_ignored_by_sensor(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_set_ignored_by_sensor(state.entities.at(yamlNode[0].as<TapeAPIObjectID>()),
yamlNode[1].as<int>());
}
RGL_API rgl_status_t rgl_entity_set_intensity_texture(rgl_entity_t entity, rgl_texture_t texture)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_set_intensity_texture(entity={}, texture={})", (void*) entity, (void*) texture);
CHECK_ARG(entity != nullptr);
CHECK_ARG(texture != nullptr);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Entity::validatePtr(entity)->setIntensityTexture(Texture::validatePtr(texture));
});
TAPE_HOOK(entity, texture);
return status;
}
void TapeCore::tape_entity_set_intensity_texture(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_set_intensity_texture(state.entities.at(yamlNode[0].as<TapeAPIObjectID>()),
state.textures.at(yamlNode[1].as<TapeAPIObjectID>()));
}
RGL_API rgl_status_t rgl_entity_set_laser_retro(rgl_entity_t entity, float retro)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_set_laser_retro(entity={}, retro={})", (void*) entity, retro);
CHECK_ARG(entity != nullptr);
Entity::validatePtr(entity)->setLaserRetro(retro);
});
TAPE_HOOK(entity, retro);
return status;
}
void TapeCore::tape_entity_set_laser_retro(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_set_laser_retro(state.entities.at(yamlNode[0].as<TapeAPIObjectID>()),
yamlNode[1].as<Field<LASER_RETRO_F32>::type>());
}
RGL_API rgl_status_t rgl_entity_apply_external_animation(rgl_entity_t entity, const rgl_vec3f* vertices, int32_t vertex_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_entity_apply_external_animation(entity={}, vertices={})", (void*) entity,
repr(vertices, vertex_count));
CHECK_ARG(entity != nullptr);
CHECK_ARG(vertices != nullptr);
CHECK_ARG(vertex_count > 0);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Entity::validatePtr(entity)->applyExternalAnimation(reinterpret_cast<const Vec3f*>(vertices), vertex_count);
});
TAPE_HOOK(entity, TAPE_ARRAY(vertices, vertex_count), vertex_count);
return status;
}
void TapeCore::tape_entity_apply_external_animation(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_entity_apply_external_animation(state.entities.at(yamlNode[0].as<TapeAPIObjectID>()),
state.getPtr<const rgl_vec3f>(yamlNode[1]), yamlNode[2].as<int32_t>());
}
rgl_status_t rgl_entity_is_alive(rgl_entity_t entity, bool* out_alive)
{
auto status = rglSafeCall([&]() {
CHECK_ARG(out_alive != nullptr);
*out_alive = Entity::instances.contains(entity);
});
TAPE_HOOK(entity, out_alive);
return status;
}
RGL_API rgl_status_t rgl_texture_create(rgl_texture_t* out_texture, const void* texels, int32_t width, int32_t height)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_texture_create(out_texture={}, width={}, height={})", (void*) out_texture, width, height);
CHECK_ARG(out_texture != nullptr);
CHECK_ARG(texels != nullptr);
CHECK_ARG(width > 0);
CHECK_ARG(height > 0);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
*out_texture = Texture::create(texels, width, height).get();
});
TAPE_HOOK(out_texture, TAPE_ARRAY(texels, (width * height * sizeof(TextureTexelFormat))), width, height);
return status;
}
void TapeCore::tape_texture_create(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_texture_t texture = nullptr;
rgl_texture_create(&texture, state.getPtr<const void>(yamlNode[1]), yamlNode[2].as<int32_t>(), yamlNode[3].as<int32_t>());
state.textures.insert(std::make_pair(yamlNode[0].as<TapeAPIObjectID>(), texture));
}
RGL_API rgl_status_t rgl_texture_destroy(rgl_texture_t texture)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_texture_destroy(texture={})", (void*) texture);
CHECK_ARG(texture != nullptr);
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Texture::release(texture);
});
TAPE_HOOK(texture);
return status;
}
void TapeCore::tape_texture_destroy(const YAML::Node& yamlNode, PlaybackState& state)
{
auto textureId = yamlNode[0].as<TapeAPIObjectID>();
rgl_texture_destroy(state.textures.at(textureId));
state.textures.erase(textureId);
}
rgl_status_t rgl_texture_is_alive(rgl_texture_t texture, bool* out_alive)
{
auto status = rglSafeCall([&]() {
CHECK_ARG(out_alive != nullptr);
*out_alive = Texture::instances.contains(texture);
});
TAPE_HOOK(texture, out_alive);
return status;
}
RGL_API rgl_status_t rgl_scene_set_time(rgl_scene_t scene, uint64_t nanoseconds)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_scene_set_time(scene={}, nanoseconds={})", (void*) scene, nanoseconds);
CHECK_ARG(scene == nullptr); // TODO: remove once rgl_scene_t param is removed
GraphRunCtx::synchronizeAll(); // Prevent races with graph threads
Scene::instance().setTime(Time::nanoseconds(nanoseconds));
});
TAPE_HOOK(scene, nanoseconds);
return status;
}
void TapeCore::tape_scene_set_time(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_scene_set_time(nullptr, yamlNode[1].as<uint64_t>());
}
RGL_API rgl_status_t rgl_graph_run(rgl_node_t raw_node)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_run(node={})", repr(raw_node));
CHECK_ARG(raw_node != nullptr);
NvtxRange rg{NVTX_CAT_API, NVTX_COL_CALL, "rgl_graph_run"};
auto node = Node::validatePtr(raw_node);
if (!node->hasGraphRunCtx()) {
GraphRunCtx::createAndAttach(node);
}
node->getGraphRunCtx()->executeAsync();
});
TAPE_HOOK(raw_node);
return status;
}
void TapeCore::tape_graph_run(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_graph_run(state.nodes.at(yamlNode[0].as<TapeAPIObjectID>()));
}
RGL_API rgl_status_t rgl_graph_destroy(rgl_node_t raw_node)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_destroy(node={})", repr(raw_node));
CHECK_ARG(raw_node != nullptr);
auto node = Node::validatePtr(raw_node);
if (node->hasGraphRunCtx()) {
node->getGraphRunCtx()->detachAndDestroy();
}
auto allNodes = node->disconnectConnectedNodes();
for (auto&& nodeToRelease : allNodes) {
Node::release(nodeToRelease.get());
}
});
TAPE_HOOK(raw_node);
return status;
}
void TapeCore::tape_graph_destroy(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_node_t userNode = state.nodes.at(yamlNode[0].as<TapeAPIObjectID>());
std::set<Node::Ptr> graph = Node::validatePtr(userNode)->getConnectedComponentNodes();
std::set<TapeAPIObjectID> graphNodeIds;
for (auto const& graphNode : graph) {
for (auto const& [key, val] : state.nodes) {
auto tapeNodePtr = Node::validatePtr(val).get();
if (graphNode.get() == tapeNodePtr) {
graphNodeIds.insert(key);
break;
}
}
}
rgl_graph_destroy(userNode);
while (!graphNodeIds.empty()) {
TapeAPIObjectID nodeId = *graphNodeIds.begin();
state.nodes.erase(nodeId);
graphNodeIds.erase(nodeId);
}
}
RGL_API rgl_status_t rgl_graph_get_result_size(rgl_node_t node, rgl_field_t field, int32_t* out_count, int32_t* out_size_of)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_get_result_size(node={}, field={}, out_count={}, out_size_of={})", repr(node), field,
(void*) out_count, (void*) out_size_of);
CHECK_ARG(node != nullptr);
NvtxRange rg{NVTX_CAT_API, NVTX_COL_CALL, "rgl_graph_get_result_size"};
auto pointCloudNode = Node::validatePtr<IPointsNode>(node);
pointCloudNode->waitForResults();
auto elemCount = (int32_t) pointCloudNode->getPointCount();
auto elemSize = (int32_t) pointCloudNode->getFieldPointSize(field);
if (out_count != nullptr) {
*out_count = elemCount;
}
if (out_size_of != nullptr) {
*out_size_of = elemSize;
}
});
TAPE_HOOK(node, field, out_count, out_size_of);
return status;
}
void TapeCore::tape_graph_get_result_size(const YAML::Node& yamlNode, PlaybackState& state)
{
int32_t out_count, out_size_of;
rgl_graph_get_result_size(state.nodes.at(yamlNode[0].as<TapeAPIObjectID>()), (rgl_field_t) yamlNode[1].as<int>(),
&out_count, &out_size_of);
auto tape_count = yamlNode[2].as<int32_t>();
auto tape_size_of = yamlNode[3].as<int32_t>();
// These warnings may be caused e.g. by gaussian noise (different seed -> different hits)
if (out_count != tape_count) {
RGL_WARN("tape_graph_get_result_size: actual count ({}) differs from tape count ({})", out_count, tape_count);
}
if (out_size_of != tape_size_of) {
RGL_WARN("tape_graph_get_result_size: actual sizeof ({}) differs from tape sizeof ({})", out_size_of, tape_size_of);
}
}
RGL_API rgl_status_t rgl_graph_get_result_data(rgl_node_t node, rgl_field_t field, void* dst)
{
static auto buffer = HostPinnedArray<char>::create();
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_get_result_data(node={}, field={}, data={})", repr(node), field, (void*) dst);
CHECK_ARG(node != nullptr);
CHECK_ARG(dst != nullptr);
NvtxRange rg{NVTX_CAT_API, NVTX_COL_CALL, "rgl_graph_get_result_data"};
auto pointCloudNode = Node::validatePtr<IPointsNode>(node);
if (!pointCloudNode->hasField(field)) {
auto msg = fmt::format("node {} does not provide field {}", pointCloudNode->getName(), toString(field));
throw InvalidPipeline(msg);
}
// This part is a bit tricky:
// The node is operating in a GraphRunCtx, i.e. in some CUDA stream.
// All its DAAs are bound to that stream. The stream may be busy with processing other nodes.
// We want to copy data without waiting until the aforementioned stream is synchronized.
// Therefore, we want to invoke the copy from the source DAA in a separate stream - copy stream.
// Take note, that since the source DAA is bound to a stream,
// it could be unsafe to issue operations in a different stream.
// E.g. If DAA was resized (data pointer already changed its value), but the reallocation didn't yet happen.
// However, with the current architecture, we can reasonably expect that no DAA is modified by other Node than its owner.
// Therefore, it should be sufficient to wait only for the stream operations issued by the given node (and, obviously, all previous).
// After that, all pending operations on the source DAA are done, and it is safe to use it in the copy stream.
pointCloudNode->waitForResults();
// Temporary optimization to yield better results in AWSIM:
// YieldNode (which has complementary part of this optimization) prefetches XYZ to host mem.
// If we are asked for XYZ from YieldNode, we can use its host cache and immediately memcpy it.
// TODO: This should work for any field in YieldNode (encountered test fails for other fields)
if (auto yieldNode = std::dynamic_pointer_cast<YieldPointsNode>(pointCloudNode)) {
if (field == XYZ_VEC3_F32) {
auto fieldArray = yieldNode->getXYZCache();
size_t size = fieldArray->getCount() * fieldArray->getSizeOf();
memcpy(dst, fieldArray->getRawReadPtr(), size);
return;
}
}
auto fieldArray = pointCloudNode->getFieldData(field);
buffer->resize(fieldArray->getCount() * fieldArray->getSizeOf(), false, false);
void* bufferDst = buffer->getWritePtr();
const void* src = fieldArray->getRawReadPtr();
size_t size = fieldArray->getCount() * fieldArray->getSizeOf();
CHECK_CUDA(cudaMemcpyAsync(bufferDst, src, size, cudaMemcpyDefault, CudaStream::getCopyStream()->getHandle()));
CHECK_CUDA(cudaStreamSynchronize(CudaStream::getCopyStream()->getHandle()));
memcpy(dst, bufferDst, size);
});
TAPE_HOOK(node, field, dst);
return status;
}
void TapeCore::tape_graph_get_result_data(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_node_t node = state.nodes.at(yamlNode[0].as<TapeAPIObjectID>());
rgl_field_t field = (rgl_field_t) yamlNode[1].as<int>();
int32_t out_count, out_size_of;
rgl_graph_get_result_size(node, field, &out_count, &out_size_of);
std::vector<char> tmpVec;
tmpVec.reserve(out_count * out_size_of);
rgl_graph_get_result_data(node, field, tmpVec.data());
}
RGL_API rgl_status_t rgl_graph_node_add_child(rgl_node_t parent, rgl_node_t child)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_node_add_child(parent={}, child={})", repr(parent), repr(child));
CHECK_ARG(parent != nullptr);
CHECK_ARG(child != nullptr);
CHECK_ARG(parent != child);
Node::validatePtr(parent)->addChild(Node::validatePtr(child));
});
TAPE_HOOK(parent, child);
return status;
}
void TapeCore::tape_graph_node_add_child(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_graph_node_add_child(state.nodes.at(yamlNode[0].as<TapeAPIObjectID>()),
state.nodes.at(yamlNode[1].as<TapeAPIObjectID>()));
}
RGL_API rgl_status_t rgl_graph_node_remove_child(rgl_node_t parent, rgl_node_t child)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_node_remove_child(parent={}, child={})", repr(parent), repr(child));
CHECK_ARG(parent != nullptr);
CHECK_ARG(child != nullptr);
Node::validatePtr(parent)->removeChild(Node::validatePtr(child));
});
TAPE_HOOK(parent, child);
return status;
}
void TapeCore::tape_graph_node_remove_child(const YAML::Node& yamlNode, PlaybackState& state)
{
rgl_graph_node_remove_child(state.nodes.at(yamlNode[0].as<TapeAPIObjectID>()),
state.nodes.at(yamlNode[1].as<TapeAPIObjectID>()));
}
RGL_API rgl_status_t rgl_graph_node_set_priority(rgl_node_t node, int32_t priority)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_node_set_priority(node={}, priority={})", repr(node), priority);
CHECK_ARG(node != nullptr);
Node::Ptr nodeShared = Node::validatePtr(node);
if (nodeShared->hasGraphRunCtx()) {
nodeShared->getGraphRunCtx()->synchronize();
}
nodeShared->setPriority(priority);
});
TAPE_HOOK(node, priority);
return status;
}
void TapeCore::tape_graph_node_set_priority(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.at(nodeId);
auto priority = yamlNode[1].as<int32_t>();
rgl_graph_node_set_priority(node, priority);
}
RGL_API rgl_status_t rgl_graph_node_get_priority(rgl_node_t node, int32_t* out_priority)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_graph_node_get_priority(node={}, priority={})", repr(node), (void*) out_priority);
CHECK_ARG(node != nullptr);
CHECK_ARG(out_priority != nullptr);
Node::Ptr nodeShared = Node::validatePtr(node);
// No need to synchronize
*out_priority = nodeShared->getPriority();
});
TAPE_HOOK(node, out_priority);
return status;
}
void TapeCore::tape_graph_node_get_priority(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.at(nodeId);
auto tape_priority = yamlNode[1].as<int32_t>();
int32_t out_priority;
rgl_graph_node_get_priority(node, &out_priority);
if (tape_priority != out_priority) {
RGL_WARN("tape_graph_node_get_priority: actual priority ({}) differs from tape priority ({})", out_priority,
tape_priority);
}
}
RGL_API rgl_status_t rgl_node_rays_from_mat3x4f(rgl_node_t* node, const rgl_mat3x4f* rays, int32_t ray_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_rays_from_mat3x4f(node={}, rays={})", repr(node), repr(rays, ray_count));
CHECK_ARG(node != nullptr);
CHECK_ARG(rays != nullptr);
CHECK_ARG(ray_count > 0);
createOrUpdateNode<FromMat3x4fRaysNode>(node, reinterpret_cast<const Mat3x4f*>(rays), (size_t) ray_count);
});
TAPE_HOOK(node, TAPE_ARRAY(rays, ray_count), ray_count);
return status;
}
void TapeCore::tape_node_rays_from_mat3x4f(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.contains(nodeId) ? state.nodes.at(nodeId) : nullptr;
rgl_node_rays_from_mat3x4f(&node, state.getPtr<const rgl_mat3x4f>(yamlNode[1]), yamlNode[2].as<int32_t>());
state.nodes.insert({nodeId, node});
}
RGL_API rgl_status_t rgl_node_rays_set_ring_ids(rgl_node_t* node, const int32_t* ring_ids, int32_t ring_ids_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_rays_set_ring_ids(node={}, ring_ids={})", repr(node), repr(ring_ids, ring_ids_count));
CHECK_ARG(node != nullptr);
CHECK_ARG(ring_ids != nullptr);
CHECK_ARG(ring_ids_count > 0);
createOrUpdateNode<SetRingIdsRaysNode>(node, ring_ids, (size_t) ring_ids_count);
});
TAPE_HOOK(node, TAPE_ARRAY(ring_ids, ring_ids_count), ring_ids_count);
return status;
}
void TapeCore::tape_node_rays_set_ring_ids(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.contains(nodeId) ? state.nodes.at(nodeId) : nullptr;
rgl_node_rays_set_ring_ids(&node, state.getPtr<const int32_t>(yamlNode[1]), yamlNode[2].as<int32_t>());
state.nodes.insert({nodeId, node});
}
RGL_API rgl_status_t rgl_node_rays_set_range(rgl_node_t* node, const rgl_vec2f* ranges, int32_t ranges_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_rays_set_range(node={}, ranges={})", repr(node), repr(ranges, ranges_count));
CHECK_ARG(node != nullptr);
CHECK_ARG(ranges != nullptr);
CHECK_ARG(ranges_count > 0);
createOrUpdateNode<SetRangeRaysNode>(node, reinterpret_cast<const Vec2f*>(ranges), (size_t) ranges_count);
});
TAPE_HOOK(node, TAPE_ARRAY(ranges, ranges_count), ranges_count);
return status;
}
void TapeCore::tape_node_rays_set_range(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.contains(nodeId) ? state.nodes.at(nodeId) : nullptr;
rgl_node_rays_set_range(&node, state.getPtr<const rgl_vec2f>(yamlNode[1]), yamlNode[2].as<int32_t>());
state.nodes.insert({nodeId, node});
}
RGL_API rgl_status_t rgl_node_rays_set_time_offsets(rgl_node_t* node, const float* offsets, int32_t offsets_count)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_rays_set_time_offsets(node={}, offsets={})", repr(node), repr(offsets, offsets_count));
CHECK_ARG(node != nullptr);
CHECK_ARG(offsets != nullptr);
CHECK_ARG(offsets_count > 0);
createOrUpdateNode<SetTimeOffsetsRaysNode>(node, offsets, (size_t) offsets_count);
});
TAPE_HOOK(node, TAPE_ARRAY(offsets, offsets_count), offsets_count);
return status;
}
void TapeCore::tape_node_rays_set_time_offsets(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.contains(nodeId) ? state.nodes.at(nodeId) : nullptr;
rgl_node_rays_set_time_offsets(&node, state.getPtr<const float>(yamlNode[1]), yamlNode[2].as<int32_t>());
state.nodes.insert({nodeId, node});
}
RGL_API rgl_status_t rgl_node_rays_transform(rgl_node_t* node, const rgl_mat3x4f* transform)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_rays_transform(node={}, transform={})", repr(node), repr(transform));
CHECK_ARG(node != nullptr);
CHECK_ARG(transform != nullptr);
createOrUpdateNode<TransformRaysNode>(node, Mat3x4f::fromRGL(*transform));
});
TAPE_HOOK(node, transform);
return status;
}
void TapeCore::tape_node_rays_transform(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.contains(nodeId) ? state.nodes.at(nodeId) : nullptr;
rgl_node_rays_transform(&node, state.getPtr<const rgl_mat3x4f>(yamlNode[1]));
state.nodes.insert({nodeId, node});
}
RGL_API rgl_status_t rgl_node_points_transform(rgl_node_t* node, const rgl_mat3x4f* transform)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_points_transform(node={}, transform={})", repr(node), repr(transform));
CHECK_ARG(node != nullptr);
CHECK_ARG(transform != nullptr);
createOrUpdateNode<TransformPointsNode>(node, Mat3x4f::fromRGL(*transform));
});
TAPE_HOOK(node, transform);
return status;
}
void TapeCore::tape_node_points_transform(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.contains(nodeId) ? state.nodes.at(nodeId) : nullptr;
rgl_node_points_transform(&node, state.getPtr<const rgl_mat3x4f>(yamlNode[1]));
state.nodes.insert({nodeId, node});
}
RGL_API rgl_status_t rgl_node_raytrace(rgl_node_t* node, rgl_scene_t scene)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_raytrace(node={}, scene={})", repr(node), (void*) scene);
CHECK_ARG(node != nullptr);
CHECK_ARG(scene == nullptr); // TODO: remove once rgl_scene_t param is removed
createOrUpdateNode<RaytraceNode>(node);
auto raytraceNode = Node::validatePtr<RaytraceNode>(*node);
});
TAPE_HOOK(node, scene);
return status;
}
void TapeCore::tape_node_raytrace(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.contains(nodeId) ? state.nodes.at(nodeId) : nullptr;
rgl_node_raytrace(&node, nullptr);
state.nodes.insert({nodeId, node});
}
RGL_API rgl_status_t rgl_node_raytrace_configure_velocity(rgl_node_t node, const rgl_vec3f* linear_velocity,
const rgl_vec3f* angular_velocity)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_raytrace_configure_velocity(node={}, linear_velocity={}, angular_velocity={})", repr(node),
repr(linear_velocity), repr(angular_velocity));
CHECK_ARG(node != nullptr);
CHECK_ARG(linear_velocity != nullptr);
CHECK_ARG(angular_velocity != nullptr);
RaytraceNode::Ptr raytraceNode = Node::validatePtr<RaytraceNode>(node);
raytraceNode->setVelocity(*reinterpret_cast<const Vec3f*>(linear_velocity),
*reinterpret_cast<const Vec3f*>(angular_velocity));
});
TAPE_HOOK(node, linear_velocity, angular_velocity);
return status;
}
void TapeCore::tape_node_raytrace_configure_velocity(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.at(nodeId);
rgl_node_raytrace_configure_velocity(state.nodes.at(nodeId), state.getPtr<const rgl_vec3f>(yamlNode[1]),
state.getPtr<const rgl_vec3f>(yamlNode[2]));
}
RGL_API rgl_status_t rgl_node_raytrace_configure_id(rgl_node_t node, int32_t id)
{
auto status = rglSafeCall([&]() {
RGL_API_LOG("rgl_node_raytrace_configure_id(node={}, id={})", repr(node), id);
CHECK_ARG(node != nullptr);
RaytraceNode::Ptr raytraceNode = Node::validatePtr<RaytraceNode>(node);
raytraceNode->setId(id);
});
TAPE_HOOK(node, id);
return status;
}
void TapeCore::tape_node_raytrace_configure_id(const YAML::Node& yamlNode, PlaybackState& state)
{
auto nodeId = yamlNode[0].as<TapeAPIObjectID>();
rgl_node_t node = state.nodes.at(nodeId);
rgl_node_raytrace_configure_id(node, yamlNode[1].as<int32_t>());
}