Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "rtxpy" %}
{% set version = "0.0.4" %}
{% set version = "0.0.5" %}

package:
name: {{ name|lower }}
Expand All @@ -20,8 +20,8 @@ requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- git
- conda-forge::cmake
- conda-forge::git
- cuda-nvcc
- cuda-cudart-dev
- cuda-nvrtc-dev
Expand All @@ -39,6 +39,7 @@ requirements:
- python >=3.10
- numpy >=1.21,<3 # [py<313]
- numpy >=2.0,<3 # [py>=313]
- numba >=0.56
- cupy >=12.0
- cuda-version >=12
- __cuda # [linux]
Expand Down
12 changes: 12 additions & 0 deletions rtxpy/rtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,18 @@ def get_geometry_count(self) -> int:
"""
return len(_state.gas_entries)

def has_geometry(self, geometry_id: str) -> bool:
"""
Check if a geometry with the given ID exists.

Args:
geometry_id: The ID of the geometry to check.

Returns:
True if the geometry exists, False otherwise.
"""
return geometry_id in _state.gas_entries

def clear_scene(self) -> None:
"""
Remove all geometries and reset to single-GAS mode.
Expand Down
31 changes: 30 additions & 1 deletion rtxpy/tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,36 @@ def test_cupy_buffers_multi_gas(test_cupy):
np.testing.assert_almost_equal(hits_np[0], 10.0, decimal=1)


@pytest.mark.parametrize("test_cupy", [False, True])
def test_has_geometry(test_cupy):
"""Test has_geometry() query method."""
if test_cupy:
if not has_cupy:
pytest.skip("cupy not available")
import cupy
backend = cupy
else:
backend = np

rtx = RTX()
rtx.clear_scene()

# Should not exist initially
assert rtx.has_geometry("test_geo") == False

# Add geometry
verts = backend.float32([0, 0, 0, 1, 0, 0, 0.5, 1, 0])
tris = backend.int32([0, 1, 2])
rtx.add_geometry("test_geo", verts, tris)

# Should exist now
assert rtx.has_geometry("test_geo") == True

# Remove and check again
rtx.remove_geometry("test_geo")
assert rtx.has_geometry("test_geo") == False


# =============================================================================
# Primitive ID and Instance ID Tests
# =============================================================================
Expand All @@ -946,7 +976,6 @@ def test_primitive_ids_single_gas(test_cupy):

rtx = RTX()
rtx.clear_scene()

# Create a mesh with 2 triangles (a quad)
# Triangle 0: vertices 0,1,2 (bottom-left triangle)
# Triangle 1: vertices 2,1,3 (top-right triangle)
Expand Down
Loading