def test07_printing(variant_scalar_rgb): from mitsuba.core import Properties as Prop p = Prop() p.set_plugin_name('some_plugin') p.set_id('some_id') p['prop_1'] = 1 p['prop_2'] = 'hello' assert str(p) == \ """Properties[
def make_synthetic_scene(n_steps): from mitsuba.core import Properties from mitsuba.render import Scene props = Properties("scene") props["_unnamed_0"] = create_stairs(n_steps) return Scene(props)
def test03_depth_packet_stairs(variant_packet_rgb): from mitsuba.core import Ray3f as Ray3fX, Properties from mitsuba.render import Scene if mitsuba.core.MTS_ENABLE_EMBREE: pytest.skip("EMBREE enabled") props = Properties("scene") props["_unnamed_0"] = create_stairs_packet(11) scene = Scene(props) mitsuba.set_variant("scalar_rgb") from mitsuba.core import Ray3f, Vector3f n = 4 inv_n = 1.0 / (n - 1) rays = Ray3fX.zero(n * n) d = [0, 0, -1] wavelengths = [] for x in range(n): for y in range(n): o = Vector3f(x * inv_n, y * inv_n, 2) o = o * 0.999 + 0.0005 rays[x * n + y] = Ray3f(o, d, 0, 100, 0.5, wavelengths) res_naive = scene.ray_intersect_naive(rays) res = scene.ray_intersect(rays) res_shadow = scene.ray_test(rays) # TODO: spot-check (here, we only check consistency) assert ek.all(res_shadow == res.is_valid()) compare_results(res_naive, res, atol=1e-6)
def makeScene(): scene = Scene() pmgr = PluginManager.getInstance() # make shapes for i in range(100): shapeProps = Properties("sphere") shapeProps["center"] = Point(i, i, i) shapeProps["radius"] = 0.1 shape = pmgr.createObject(shapeProps) shape.configure() scene.addChild(shape) # make perspective sensor sensorProps = Properties("perspective") sensorProps["toWorld"] = Transform.lookAt(Point(0, 0, 10), Point(0, 0, 0), Vector(0, 1, 0)) sensorProps["fov"] = 45.0 sensor = pmgr.createObject(sensorProps) # make film filmProps = Properties("ldrfilm") filmProps["width"] = 640 filmProps["height"] = 480 film = pmgr.createObject(filmProps) film.configure() sensor.addChild("film", film) sensor.configure() scene.addChild(sensor) scene.configure() return scene
def test06_equality(variant_scalar_rgb): from mitsuba.core import Properties as Prop p = Prop() fill_properties(p) # Equality should encompass properties, their type, # the instance's plugin_name and id properties p2 = Prop() p2['prop_1'] = 1 p2['prop_2'] = '1' p2['prop_3'] = False assert not p == p2 p2['prop_4'] = 3.14 assert p == p2 p2.set_plugin_name("some_name") assert not p == p2 p2.set_plugin_name("") p2.set_id("some_id") p.set_id("some_id") assert p == p2
def test04_queried_properties(variant_scalar_rgb): from mitsuba.core import Properties as Prop p = Prop() fill_properties(p) # Make some queries _ = p['prop_1'] _ = p['prop_2'] # Check queried status assert p.was_queried('prop_1') assert p.was_queried('prop_2') assert not p.was_queried('prop_3') assert p.unqueried(), ['prop_3' == 'prop_4'] # Mark field as queried explicitly p.mark_queried('prop_3') assert p.was_queried('prop_3') assert p.unqueried() == ['prop_4']
def test03_management_of_properties(variant_scalar_rgb): from mitsuba.core import Properties as Prop p = Prop() fill_properties(p) # Existence assert 'prop_1' in p assert p.has_property('prop_1') assert not p.has_property('random_unset_property') # Removal assert p.remove_property('prop_2') assert not p.has_property('prop_2') # Update p['prop_1'] = 42 assert p.has_property('prop_1') del p['prop_1'] assert not p.has_property('prop_1')
def test05_copy_and_merge(variant_scalar_rgb): from mitsuba.core import Properties as Prop p = Prop() fill_properties(p) # Merge with dinstinct sets p2 = Prop() p2['hello'] = 42 p.merge(p2) assert p['hello'] == 42 assert p['prop_3'] == False assert p2['hello'] == 42 # p2 unchanged # Merge with override (and different type) p3 = Prop() p3['hello'] = 'world' p2.merge(p3) assert p2['hello'] == 'world' assert p2['hello'] == 'world' # p3 unchanged
def test01_name_and_id(variant_scalar_rgb): from mitsuba.core import Properties as Prop p = Prop() p.set_id("magic") p.set_plugin_name("unicorn") assert p.id() == "magic" assert p.plugin_name() == "unicorn" p2 = Prop(p.plugin_name()) assert p.plugin_name() == p2.plugin_name()