Skip to content

Conversation

@James-Rhodes
Copy link
Contributor

Description

I have extended the capability of scaling a SceneObject to allow for scaling by different amounts in each dimension. If the user sets the scaling parameter to a scalar then it will still behave as expected, scaling all dimensions equally. However, if a mitsuba.Vector3f is passed in, then the object will be scaled by the x, y and z dimensions in the coordinate system of the object. This does make the setter for scaling more expensive, however it also adds additional functionality so I think the trade off is worth while personally (open to suggestions though).

I have additionally added tests to ensure that no other behaviour is broken. Please note that I do not have a GPU so I have only been able to run the tests on the CPU using the --cpu flag for pytest.

This is my first time making a pull request so I am very open to criticism and fixing things up as needed. Thanks!

  • Fixes a bug?
    NA.

  • Adds a new Feature?
    This feature allows a user to scale SceneObjects by different amounts in each dimension.

  • Introduces API changes?
    It changes the value returned by the "getter" of scaling from a scalar float to a mitsuba.Vector3f to show the scaling in each direction. The setter signature is also changed to additionally support mitsuba.Vector3f as well as mitsuba.Float. The setter should not be a breaking change though, given scalar values are still supported.

  • Other contributions
    NA

I have supplied a short program that highlights this feature in use below:

import matplotlib.pyplot as plt
import mitsuba as mi

mi.set_variant("llvm_ad_mono_polarized")  # Use CPU
import sionna
from sionna.rt import (
    load_scene,
    Camera,
    ITURadioMaterial,
    SceneObject,
    Receiver,
)


def main():
    scene = load_scene()  # Objects are merged by default
    cam = Camera(position=mi.Point3f(0.0, 0.0, 100), look_at=mi.Point3f(0, 0, 0))
    car_material = ITURadioMaterial(
        "car-material", "metal", thickness=0.01, color=(0.8, 0.1, 0.1)
    )

    car = SceneObject(fname=sionna.rt.scene.low_poly_car, name="unscaled_car", radio_material=car_material)
    scene.edit(add=car)
    car.position = mi.Point3f(0., 5., 0.)

    scaled_car = SceneObject(fname=sionna.rt.scene.low_poly_car, name="scaled_car", radio_material=car_material)
    scene.edit(add=scaled_car)
    scaled_car.position = mi.Point3f(0., -5., 0.)
    scaled_car.scaling = mi.Vector3f(10, 2, 1) # Scale the car by some amount

    # Only here so that a green circle is drawn in the positive x direction
    scene.add(
        Receiver(
            "rx-1",
            position=mi.Point3f(
                10,
                0,
                0,
            ),
            display_radius=2,
        )
    )

    scene.render(camera=cam)
    plt.show()


if __name__ == "__main__":
    main()

Checklist

  • Detailed description
  • Added references to issues and discussions
  • Added / modified documentation as needed
  • Added / modified unit tests as needed
  • Passes all tests
  • Lint the code
  • Performed a self review
  • Ensure you Signed-off the commits. Required to accept contributions!
  • Co-authored with someone? Add Co-authored-by: user@domain and ensure they signed off their commits too

@faycalaa
Copy link
Collaborator

Hi @James-Rhodes,

Thank you for this pull request! We will review it and get back to you.

@faycalaa faycalaa merged commit eb23743 into NVlabs:main Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants