@@ -32,10 +32,12 @@ SimCameraSet::SimCameraSet(
3232 cameras{},
3333 render_on_demand{render_on_demand} {
3434 for (auto const & [id, cam] : cameras_cfg) {
35+ if (!this ->render_on_demand ) {
3536 this ->sim ->register_rendering_callback (
3637 [this ](const std::string& id, mjrContext& ctx, mjvScene& scene,
3738 mjvOption& opt) { this ->frame_callback (id, ctx, scene, opt); },
3839 id, cam.frame_rate , cam.resolution_width , cam.resolution_height );
40+ }
3941
4042 mjvCamera mjcam;
4143 mjv_defaultCamera (&mjcam);
@@ -86,13 +88,18 @@ std::optional<FrameSet> SimCameraSet::get_timestamp_frameset(float ts) {
8688void SimCameraSet::render_all () {
8789 for (auto const & [id, cam] : this ->cameras_cfg ) {
8890 mjrContext* ctx = this ->sim ->renderer .get_context (id);
89- this ->frame_callback (id, *ctx, this ->sim ->renderer .scene ,
91+ this ->render_single (id, *ctx, this ->sim ->renderer .scene ,
9092 this ->sim ->renderer .opt );
9193 }
9294}
9395
9496void SimCameraSet::frame_callback (const std::string& id, mjrContext& ctx,
9597 mjvScene& scene, mjvOption& opt) {
98+ this ->render_single (id, ctx, scene, opt);
99+ }
100+
101+ void SimCameraSet::render_single (const std::string& id, mjrContext& ctx,
102+ mjvScene& scene, mjvOption& opt) {
96103 mjrRect viewport = mjr_maxViewport (&ctx);
97104 int W = viewport.width ;
98105 int H = viewport.height ;
0 commit comments