Clash Detection Engine Encapsulation

Overview

A helper class ClashDetection that encapsulates clash detection engine (omni.physx.clashdetection) operations and resides in clash_detect.py file.

ClashDetection Class

class ClashDetection

Handles setup, configuration, and processing of clash detections.

Constructor

__init__()

Initializes a new instance of the ClashDetection class, setting up the clash detection API and context.

Returns

None

Methods

destroy()

Releases the clash detection API and context. Should be called to clean up resources when the clash detection is no longer needed.

Returns

None

reset()

Resets the clash detection context to its initial state, clearing any existing configurations or data.

Returns

None

get_nb_overlaps() int

Returns the number of overlaps (clashes) detected in the current context.

Returns

The number of detected overlaps (clashes).

set_settings(settings: Dict[str, Any], stage: Usd.Stage = None) bool

Configures the clash detection settings based on the provided dictionary.

Note

Settings which are not provided in the dictionary are left unchanged.

Optionally takes a USD stage to apply settings relevant to the stage.

Parameters
  • settings – A dictionary of settings to apply.

  • stage – An optional USD stage to apply settings to.

Returns

True if settings were successfully applied, False otherwise.

set_scope(stage: Usd.Stage, obj_a: str, obj_b: str) bool

Sets the scope of clash detection to specific objects within a USD stage.

  • If both obj_a and obj_b are empty -> process full scene.

  • If only the obj_a list contains items -> limit processing only to obj_a items.

  • If obj_a and obj_b lists contain items -> process obj_a against obj_b.

Parameters
  • stage – The USD stage.

  • obj_a – The first object or group of objects.

  • obj_b – The second object or group of objects.

Returns

True if the scope was successfully set, False otherwise.

create_pipeline() int

Initializes the clash detection pipeline.

Returns

The number of steps in the pipeline.

get_pipeline_step_data(index: int) Any

Retrieves data for a specific step in the clash detection pipeline.

Parameters

index – The index of the pipeline step.

Returns

Data for the specified pipeline step.

run_pipeline_step(index: int)

Executes a specific step in the clash detection pipeline.

Parameters

index – The index of the pipeline step to run.

Returns

None

get_overlap_data(overlap_index: int, frame_index: int) Any

Retrieves data for a specific overlap detected during clash detection.

Parameters
  • overlap_index – The index of the overlap.

  • frame_index – The frame index for the overlap.

Returns

Data for the specified overlap.

get_overlap_report(overlap_index: int, frame_index: int, mesh_index: MeshIndex, flags: OverlapReportFlag) Any

Generates a report for a specific overlap.

Parameters
  • overlap_index – The index of the overlap.

  • frame_index – The frame index for the overlap.

  • mesh_index – The mesh index (MeshIndex).

  • flags – Flags to specify the report details (OverlapReportFlag).

Returns

A report for the specified overlap.

process_overlap(stage: Usd.Stage, idx: int, existing_clash_info_items: Dict[str, ClashInfo], query_identifier: int, setting_tolerance: float) Optional[ClashInfo]

Processes a detected overlap, updating or creating a ClashInfo object as necessary.

Parameters
  • stage – The USD stage.

  • idx – The index of the overlap.

  • existing_clash_info_items – A dictionary of existing clash info items.

  • query_identifier – The identifier for the clash query.

  • setting_tolerance – The tolerance setting for clash detection.

Returns

A ClashInfo object if it’s a new clash, None otherwise.

fetch_and_save_overlaps(stage: Usd.Stage, clash_data: ClashData, clash_query: ClashQuery) None

Fetches detected overlaps and saves them to the provided ClashData object. This method is a generator that yields progress updates.

Parameters
  • stage – The USD stage.

  • clash_data – The ClashData object to save overlaps to.

  • clash_query – The ClashQuery object.

Returns

None

Properties

clash_detect_api

Returns the underlying clash detection API interface used by this instance.

Returns

Clash detection engine API.

clash_detect_context

Provides access to the current clash detection context.

Returns

Clash detection engine API context.