Skip to content

Commit

Permalink
Merge branch 'bugfix/gh-312' into 'main'
Browse files Browse the repository at this point in the history
Support num_tiles = 1 in example_render_opengl

Closes GH-312

See merge request omniverse/warp!727
  • Loading branch information
shi-eric committed Sep 16, 2024
2 parents 3b00f16 + 9540472 commit ee92dcd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions warp/examples/core/example_render_opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

class Example:
def __init__(self, num_tiles=4, custom_tile_arrangement=False):
if num_tiles < 1:
raise ValueError("num_tiles must be greater than or equal to 1.")

self.renderer = wp.render.OpenGLRenderer(vsync=False)
instance_ids = []

Expand All @@ -31,16 +34,15 @@ def __init__(self, num_tiles=4, custom_tile_arrangement=False):
positions = None
sizes = None

if num_tiles > 1:
# set up instances to hide one of the capsules in each tile
for i in range(num_tiles):
instances = [j for j in np.arange(13) if j != i + 2]
instance_ids.append(instances)
if custom_tile_arrangement:
angle = np.pi * 2.0 / num_tiles * i
positions.append((int(np.cos(angle) * 150 + 250), int(np.sin(angle) * 150 + 250)))
sizes.append((150, 150))
self.renderer.setup_tiled_rendering(instance_ids, tile_positions=positions, tile_sizes=sizes)
# set up instances to hide one of the capsules in each tile
for i in range(num_tiles):
instances = [j for j in np.arange(13) if j != i + 2]
instance_ids.append(instances)
if custom_tile_arrangement:
angle = np.pi * 2.0 / num_tiles * i
positions.append((int(np.cos(angle) * 150 + 250), int(np.sin(angle) * 150 + 250)))
sizes.append((150, 150))
self.renderer.setup_tiled_rendering(instance_ids, tile_positions=positions, tile_sizes=sizes)

self.renderer.render_ground()

Expand Down

0 comments on commit ee92dcd

Please sign in to comment.