Skip to content

Commit 6c26c4f

Browse files
authored
add scale variable to the add_instance binding. (#2566)
* add scale variable to the add_instance binding. Necessary to support scaling of render assets from isaac integration
1 parent 2aa5ed1 commit 6c26c4f

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/esp/bindings/SimBindings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ void initRenderInstanceHelperBindings(py::module& m) {
181181
"use_xyzw_orientations=False, we assume wxyz.)")
182182
.def("add_instance", &RenderInstanceHelper::AddInstance,
183183
py::arg("asset_filepath"), py::arg("semantic_id"),
184+
py::arg("scale") = Mn::Vector3(1.0, 1.0, 1.0),
184185
"R(Add an instance of a render asset to the scene. The asset can be "
185186
"for example a .glb or .obj 3D model file. The instance gets an "
186187
"identity pose; change it later using set_world_poses.)")

src/esp/sim/RenderInstanceHelper.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ RenderInstanceHelper::RenderInstanceHelper(Simulator& sim,
1919
}
2020

2121
int RenderInstanceHelper::AddInstance(const std::string& assetFilepath,
22-
int semanticId) {
22+
int semanticId,
23+
const Magnum::Vector3& scale) {
2324
esp::assets::AssetInfo assetInfo;
2425
assetInfo.filepath = assetFilepath;
2526
assetInfo.forceFlatShading = false;
@@ -28,8 +29,6 @@ int RenderInstanceHelper::AddInstance(const std::string& assetFilepath,
2829
// flags |= RenderAssetInstanceCreationInfo::Flag::IsStatic;
2930
flags |= esp::assets::RenderAssetInstanceCreationInfo::Flag::IsRGBD;
3031
flags |= esp::assets::RenderAssetInstanceCreationInfo::Flag::IsSemantic;
31-
const Corrade::Containers::Optional<Magnum::Vector3> scale =
32-
Cr::Containers::NullOpt;
3332

3433
assets::RenderAssetInstanceCreationInfo creation(assetFilepath, scale, flags,
3534
DEFAULT_LIGHTING_KEY);

src/esp/sim/RenderInstanceHelper.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef ESP_SIM_RENDERINSTANCEHELPER_H_
66
#define ESP_SIM_RENDERINSTANCEHELPER_H_
77

8+
#include <Magnum/Math/Vector3.h>
89
#include <string>
910
#include <vector>
1011

@@ -50,7 +51,11 @@ class RenderInstanceHelper {
5051
* @param assetFilepath can be for example a .glb or .obj 3D model file
5152
* @param semanticId used for semantic rendering
5253
*/
53-
int AddInstance(const std::string& assetFilepath, int semanticId);
54+
int AddInstance(const std::string& assetFilepath,
55+
int semanticId,
56+
const Magnum::Vector3& scale = Magnum::Vector3(1.0,
57+
1.0,
58+
1.0));
5459

5560
/**
5661
* @brief Remove all instances from the scene.

0 commit comments

Comments
 (0)