Skip to content

Commit 8518280

Browse files
committed
fix(sim camera): remove framerate for direct camera render flag
1 parent f60a7ed commit 8518280

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/sim/camera.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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) {
8688
void 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

9496
void 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;

src/sim/camera.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class SimCameraSet {
7070
std::mutex buffer_lock;
7171
mjtNum last_ts = 0;
7272
void render_all();
73+
void render_single(const std::string& id, mjrContext& ctx, mjvScene& scene,
74+
mjvOption& opt);
7375
};
7476
} // namespace sim
7577
} // namespace rcs

0 commit comments

Comments
 (0)