Skip to content

Commit 5040330

Browse files
authored
update_drawable_setting (#171)
1 parent 572ab53 commit 5040330

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

include/guik/viewer/async_light_viewer_context.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class AsyncLightViewerContext {
4545
void use_arcball_camera_control(double distance = 80.0, double theta = 0.0, double phi = -60.0f * M_PI / 180.0f);
4646
void use_fps_camera_control(double fovy_deg = 60.0);
4747

48+
void update_drawable_setting(const std::string& name, const ShaderSetting& shader_setting);
49+
4850
// utility methods to directly create and update drawables
4951
// PointCloudBuffer
5052
void update_points(const std::string& name, const float* data, int stride, int num_points, const ShaderSetting& shader_setting);

src/guik/viewer/async_light_viewer_context.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ void AsyncLightViewerContext::use_fps_camera_control(double fovy_deg) {
8585
guik::viewer()->invoke([=] { context->use_fps_camera_control(fovy_deg); });
8686
}
8787

88+
void AsyncLightViewerContext::update_drawable_setting(const std::string& name, const ShaderSetting& shader_setting) {
89+
guik::viewer()->invoke([=] {
90+
auto drawable = context->find_drawable(name);
91+
if (!drawable.first || !drawable.second) {
92+
std::cerr << "warning: drawable not found (name=" << name << ")" << std::endl;
93+
return;
94+
}
95+
*drawable.first = shader_setting;
96+
});
97+
}
98+
8899
// PointCloudBuffer
89100
void AsyncLightViewerContext::update_points(const std::string& name, const float* data, int stride, int num_points, const ShaderSetting& shader_setting) {
90101
std::vector<float> buffer(data, data + stride / sizeof(float) * num_points);

src/python/guik.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,8 @@ void define_guik(py::module_& m) {
648648
py::arg("phi") = -60.0 * M_PI / 180.0)
649649
.def("use_fps_camera_control", &guik::AsyncLightViewerContext::use_fps_camera_control, py::arg("fovy_deg") = 60.0)
650650

651+
.def("update_drawable_setting", &guik::AsyncLightViewerContext::update_drawable_setting, py::arg("name"), py::arg("setting"))
652+
651653
.def(
652654
"update_points",
653655
[](guik::AsyncLightViewerContext& context, const std::string& name, const Eigen::Matrix<float, -1, -1, Eigen::RowMajor>& points, const guik::ShaderSetting& shader_setting) {

0 commit comments

Comments
 (0)