Skip to content

Commit

Permalink
Merge branch 'ccrouzet/ext-fixes' into 'main'
Browse files Browse the repository at this point in the history
Replace Deprecated Usage of `db.internal_state`

See merge request omniverse/warp!846
  • Loading branch information
mmacklin committed Nov 7, 2024
2 parents 5cc8d3c + 6a6aff3 commit dbb7a70
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 46 deletions.
14 changes: 7 additions & 7 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnClothSimulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def update_collider(
db: OgnClothSimulateDatabase,
) -> None:
"""Updates the collider state."""
state = db.internal_state
state = db.per_instance_state

points = omni.warp.nodes.mesh_get_points(db.inputs.collider)
xform = omni.warp.nodes.bundle_get_world_xform(db.inputs.collider)
Expand Down Expand Up @@ -397,7 +397,7 @@ def update_cloth(
db: OgnClothSimulateDatabase,
) -> None:
"""Updates the cloth state."""
state = db.internal_state
state = db.per_instance_state

xform = omni.warp.nodes.bundle_get_world_xform(db.inputs.cloth)

Expand Down Expand Up @@ -425,7 +425,7 @@ def update_cloth(

def step(db: OgnClothSimulateDatabase) -> None:
"""Steps through the simulation."""
state = db.internal_state
state = db.per_instance_state

sim_dt = state.sim_dt / db.inputs.substepCount

Expand Down Expand Up @@ -461,7 +461,7 @@ def step(db: OgnClothSimulateDatabase) -> None:

def simulate(db: OgnClothSimulateDatabase) -> None:
"""Simulates the cloth at the current time."""
state = db.internal_state
state = db.per_instance_state

if USE_GRAPH:
wp.capture_launch(state.graph)
Expand All @@ -474,7 +474,7 @@ def compute(db: OgnClothSimulateDatabase, device: wp.context.Device) -> None:
if not db.inputs.cloth.valid or not db.outputs.cloth.valid:
return

state = db.internal_state
state = db.per_instance_state

if not db.inputs.enabled:
# Pass through the data.
Expand Down Expand Up @@ -633,10 +633,10 @@ def compute(db: OgnClothSimulateDatabase) -> None:
compute(db, device)
except Exception:
db.log_error(traceback.format_exc())
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Fire the execution for the downstream nodes.
db.outputs.execOut = og.ExecutionAttributeState.ENABLED
2 changes: 1 addition & 1 deletion exts/omni.warp/omni/warp/nodes/_impl/OgnFixedTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def compute(db) -> bool:
"""Compute the outputs from the current input"""

timeline = omni.timeline.get_timeline_interface()
context = db.internal_state
context = db.per_instance_state

if not context.initialized:
context.time = db.inputs.start
Expand Down
6 changes: 3 additions & 3 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnGridCreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def compute(db: OgnGridCreateDatabase) -> None:
if not db.outputs.mesh.valid:
return

state = db.internal_state
state = db.per_instance_state

if state.is_valid and not state.attr_tracking.have_attrs_changed(db):
return
Expand Down Expand Up @@ -105,10 +105,10 @@ def compute(db: OgnGridCreateDatabase) -> None:
compute(db)
except Exception:
db.log_error(traceback.format_exc())
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Fire the execution for the downstream nodes.
db.outputs.execOut = og.ExecutionAttributeState.ENABLED
20 changes: 10 additions & 10 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,38 +151,38 @@ def compute(db: OgnKernelDatabase, device: wp.context.Device) -> None:

# Ensure that our internal state is correctly initialized.
timeline = omni.timeline.get_timeline_interface()
if db.internal_state.needs_initialization(db, timeline.is_stopped()):
if not db.internal_state.initialize(db, len(kernel_shape)):
if db.per_instance_state.needs_initialization(db, timeline.is_stopped()):
if not db.per_instance_state.initialize(db, len(kernel_shape)):
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Exit early if there are no outputs defined.
if not db.internal_state.attr_infos[ATTR_PORT_TYPE_OUTPUT]:
if not db.per_instance_state.attr_infos[ATTR_PORT_TYPE_OUTPUT]:
return

# Retrieve the inputs and outputs argument values to pass to the kernel.
inputs, outputs = get_kernel_args(
db.inputs,
db.outputs,
db.internal_state.attr_infos,
db.internal_state.kernel_module,
db.per_instance_state.attr_infos,
db.per_instance_state.kernel_module,
kernel_shape,
)

# Ensure that all array input values are valid.
validate_input_arrays(db.node, db.internal_state.attr_infos, inputs)
validate_input_arrays(db.node, db.per_instance_state.attr_infos, inputs)

# Launch the kernel.
wp.launch(
db.internal_state.kernel_module.compute,
db.per_instance_state.kernel_module.compute,
dim=kernel_shape,
inputs=[inputs],
outputs=[outputs],
)

# Write the output values to the node's attributes.
write_output_attrs(db.outputs, db.internal_state.attr_infos, outputs)
write_output_attrs(db.outputs, db.per_instance_state.attr_infos, outputs)


# Node Entry Point
Expand Down Expand Up @@ -222,7 +222,7 @@ def compute(db: OgnKernelDatabase) -> None:
with wp.ScopedDevice(device):
compute(db, device)
except Exception:
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
db.log_error(traceback.format_exc())
wp.config.quiet = True
return
Expand Down
6 changes: 3 additions & 3 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnMeshFromVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def compute(db: OgnMeshFromVolumeDatabase) -> None:
if not db.inputs.data.memory or db.inputs.data.shape[0] == 0:
return

state = db.internal_state
state = db.per_instance_state

# Initialize the internal state if it hasn't been already.
if state.needs_initialization(db):
Expand Down Expand Up @@ -210,10 +210,10 @@ def compute(db: OgnMeshFromVolumeDatabase) -> None:
compute(db)
except Exception:
db.log_error(traceback.format_exc())
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Fire the execution for the downstream nodes.
db.outputs.execOut = og.ExecutionAttributeState.ENABLED
8 changes: 4 additions & 4 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnParticlesFromMesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def spawn_particles(db: OgnParticlesFromMeshDatabase) -> Tuple[wp.array, int]:
kernel=sample_mesh_kernel,
dim=dims,
inputs=[
db.internal_state.mesh.id,
db.per_instance_state.mesh.id,
extent[0],
db.inputs.maxPoints,
db.inputs.minSdf,
Expand Down Expand Up @@ -224,7 +224,7 @@ def compute(db: OgnParticlesFromMeshDatabase) -> None:
if not db.inputs.mesh.valid or not db.outputs.particles.valid:
return

state = db.internal_state
state = db.per_instance_state

# Initialize the internal state if it hasn't been already.
if state.needs_initialization(db):
Expand Down Expand Up @@ -307,10 +307,10 @@ def compute(db: OgnParticlesFromMeshDatabase) -> None:
compute(db)
except Exception:
db.log_error(traceback.format_exc())
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Fire the execution for the downstream nodes.
db.outputs.execOut = og.ExecutionAttributeState.ENABLED
14 changes: 7 additions & 7 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnParticlesSimulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def update_collider(
db: OgnParticlesSimulateDatabase,
) -> None:
"""Updates the collider state."""
state = db.internal_state
state = db.per_instance_state

points = omni.warp.nodes.mesh_get_points(db.inputs.collider)
xform = omni.warp.nodes.bundle_get_world_xform(db.inputs.collider)
Expand Down Expand Up @@ -398,7 +398,7 @@ def update_particles(
db: OgnParticlesSimulateDatabase,
) -> None:
"""Updates the particles state."""
state = db.internal_state
state = db.per_instance_state

xform = omni.warp.nodes.bundle_get_world_xform(db.inputs.particles)

Expand Down Expand Up @@ -426,7 +426,7 @@ def update_particles(

def step(db: OgnParticlesSimulateDatabase) -> None:
"""Steps through the simulation."""
state = db.internal_state
state = db.per_instance_state

sim_dt = state.sim_dt / db.inputs.substepCount

Expand All @@ -448,7 +448,7 @@ def step(db: OgnParticlesSimulateDatabase) -> None:

def simulate(db: OgnParticlesSimulateDatabase) -> None:
"""Simulates the particles at the current time."""
state = db.internal_state
state = db.per_instance_state

state.model.particle_grid.build(
state.state_0.particle_q,
Expand All @@ -466,7 +466,7 @@ def compute(db: OgnParticlesSimulateDatabase, device: wp.context.Device) -> None
if not db.inputs.particles.valid or not db.outputs.particles.valid:
return

state = db.internal_state
state = db.per_instance_state

if not db.inputs.enabled:
# Pass through the data.
Expand Down Expand Up @@ -556,10 +556,10 @@ def compute(db: OgnParticlesSimulateDatabase) -> None:
compute(db, device)
except Exception:
db.log_error(traceback.format_exc())
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Fire the execution for the downstream nodes.
db.outputs.execOut = og.ExecutionAttributeState.ENABLED
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def compute(db: OgnSampleOceanDeformDatabase) -> None:
if not db.inputs.mesh.valid or not db.outputs.mesh.valid:
return

state = db.internal_state
state = db.per_instance_state

amplitude = max(0.0001, min(1000.0, db.inputs.amplitude))
direction = db.inputs.direction % 6.28318530718
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def initialize(self, device):
def compute(db: OgnSamplePrimFlockingDatabase) -> None:
"""Evaluates the node."""

state = db.internal_state
state = db.per_instance_state

device = wp.get_device()

Expand Down
6 changes: 3 additions & 3 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnTextureWrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def compute(db: OgnTextureWriteDatabase) -> None:
if not db.inputs.data.memory or db.inputs.data.shape[0] == 0:
return

state = db.internal_state
state = db.per_instance_state

if state.needs_initialization(db):
# Initialize the internal state if it hasn't been already.
Expand Down Expand Up @@ -128,10 +128,10 @@ def compute(db: OgnTextureWriteDatabase) -> None:
compute(db)
except Exception:
db.log_error(traceback.format_exc())
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Trigger the execution for the downstream nodes.
db.outputs.execOut = og.ExecutionAttributeState.ENABLED
12 changes: 6 additions & 6 deletions exts/omni.warp/omni/warp/nodes/_impl/OgnWaveSolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def displace(
cell_size: np.ndarray,
) -> None:
"""Displaces the height map with the collider."""
state = db.internal_state
state = db.per_instance_state

# Retrieve some data from the grid mesh.
xform = omni.warp.nodes.bundle_get_world_xform(db.outputs.mesh)
Expand Down Expand Up @@ -264,7 +264,7 @@ def simulate(
sim_dt: bool,
) -> None:
"""Solves the wave simulation."""
state = db.internal_state
state = db.per_instance_state

cell_size_uniform = (cell_size[0] + cell_size[1]) * 0.5
wp.launch(
Expand Down Expand Up @@ -293,7 +293,7 @@ def simulate(

def update_mesh(db: OgnWaveSolveDatabase) -> None:
"""Updates the output grid mesh."""
state = db.internal_state
state = db.per_instance_state

wp.launch(
kernel=update_mesh_kernel,
Expand All @@ -314,7 +314,7 @@ def compute(db: OgnWaveSolveDatabase) -> None:
if not db.outputs.mesh.valid:
return

state = db.internal_state
state = db.per_instance_state

# Compute the number of divisions.
dims = (db.inputs.size / db.inputs.cellSize).astype(int)
Expand Down Expand Up @@ -390,10 +390,10 @@ def compute(db: OgnWaveSolveDatabase) -> None:
compute(db)
except Exception:
db.log_error(traceback.format_exc())
db.internal_state.is_valid = False
db.per_instance_state.is_valid = False
return

db.internal_state.is_valid = True
db.per_instance_state.is_valid = True

# Fire the execution for the downstream nodes.
db.outputs.execOut = og.ExecutionAttributeState.ENABLED

0 comments on commit dbb7a70

Please sign in to comment.