Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raster overlay UI/UX enhancements #649

Merged
merged 26 commits into from
Jan 31, 2024
Merged

Conversation

corybarr
Copy link
Contributor

@corybarr corybarr commented Jan 30, 2024

  • Adds custom UI widgets for CesiumPolygonRasterOverlayPrim and CesiumIonRasterOverlayPrim
  • Adds "Invert Selection" to CesiumPolygonRasterOverlayPrim
  • Makes CesiumPolygonRasterOverlayPrim and CesiumIonRasterOverlayPrim "alpha" attribute a slider
  • Makes BasisCurves created via Quick-Add menu have appropriate settings for type, wrap, and points attributes.
  • Sets ordering of UI groups to match Unreal (polygons->invert->rendering->credits)
  • Constrains cartographic polygon bindings to only be BasisCurves

image

Resolves #633
Resolves #618
Resolves #631

@corybarr corybarr changed the title Raster overlay UI enhancements Raster overlay UI/UX enhancements Jan 30, 2024
@corybarr corybarr marked this pull request as ready for review January 30, 2024 19:52
src/core/src/OmniPolygonRasterOverlay.cpp Outdated Show resolved Hide resolved
Comment on lines 36 to 77
def _build_slider(
stage,
attr_name,
metadata,
property_type,
prim_paths: List[Sdf.Path],
additional_label_kwargs={},
additional_widget_kwargs={},
):
from omni.kit.window.property.templates import HORIZONTAL_SPACING
from omni.kit.property.usd.usd_attribute_model import UsdAttributeModel
from omni.kit.property.usd.usd_property_widget import UsdPropertiesWidgetBuilder

if not attr_name or not property_type:
return

with ui.HStack(spacing=HORIZONTAL_SPACING):
model_kwargs = UsdPropertiesWidgetBuilder.get_attr_value_range_kwargs(metadata)
model = UsdAttributeModel(
stage,
[path.AppendProperty(attr_name) for path in prim_paths],
False,
metadata,
**model_kwargs,
)
UsdPropertiesWidgetBuilder.create_label(attr_name, metadata, additional_label_kwargs)
widget_kwargs = {"model": model, "min": 0.0, "max": 1.0}
widget_kwargs.update(UsdPropertiesWidgetBuilder.get_attr_value_soft_range_kwargs(metadata))

if additional_widget_kwargs:
widget_kwargs.update(additional_widget_kwargs)
with ui.ZStack():
value_widget = UsdPropertiesWidgetBuilder.create_drag_or_slider(
ui.FloatDrag, ui.FloatSlider, **widget_kwargs
)
mixed_overlay = UsdPropertiesWidgetBuilder.create_mixed_text_overlay()
UsdPropertiesWidgetBuilder.create_control_state(
value_widget=value_widget, mixed_overlay=mixed_overlay, **widget_kwargs
)
model.add_value_changed_fn(lambda m, s=stage, p=prim_paths: update_range(s, p))

return model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make this more generic and put in a helper file so it's not duplicated across files? E.g. I imagine the min/max values would be provided as options instead of hardcoded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Pushed. You can now call CustomLayoutProperty("cesium:alpha", build_fn=build_slider(0, 1)) with whichever values you want.

There might be a more Pythonic way to do this (with partial?) but this feels OK. I'm not yet fluently Pythonic, and some of my Python I've been told is like transliterated game-engine C++. This is literally transliterated game-engine C# code: [Range(0,1)].

@lilleyse
Copy link
Contributor

This doesn't need to be addressed now...

If I set a polygon overlay's render method to overlay it appears red. Is this something we have control over, or are we just rendering the pixel color exactly as it comes from native?

image

@corybarr
Copy link
Contributor Author

This doesn't need to be addressed now...

If I set a polygon overlay's render method to overlay it appears red. Is this something we have control over, or are we just rendering the pixel color exactly as it comes from native?

image

We don't have control over it right now, but it's not a major lift. I created a ticket for it. #652

@r-veenstra
Copy link
Contributor

  • Invert selection appears to obey the initial setting on load, but when changing the bool and refreshing the tileset it does not update accordingly. If I save the USDA with the updated bool and reload the stage, it works as expected.
  • Default values for the cartographic polygons appear to be good
  • Changing Invert Selection should probably trigger a tileset refresh (similar to the refresh that occurs when adding or removing polygons from the raster overlay). Though that could be frustrating unless Refresh tileset should not re-download tile data #650 is fixed first

You should be able to test the invert issue with the following zip

TilesetClipping.zip

@r-veenstra
Copy link
Contributor

Thanks, invert issues appear resolved now!

@r-veenstra
Copy link
Contributor

I added basis_curves.GetCurveVertexCountsAttr().Set([4]) to the creation of basis curves, as without this property the curves never render, and the control points never show when trying to edit them

src/core/src/OmniPolygonRasterOverlay.cpp Outdated Show resolved Hide resolved
Comment on lines 9 to 15
def _update_range(stage, prim_paths):
for path in prim_paths:
rasterOverlay = CesiumRasterOverlay.Get(stage, path)
attr = rasterOverlay.GetAlphaAttr()
current_value = attr.Get()
new_value = max(0, min(current_value, 1.0))
attr.Set(new_value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to not hardcode CesiumRasterOverlay? I imagine we'll want to use this widget for other prim types.

Also it's not clear to me how the min/max options that are passed to build_slider are getting set. Seems like 0 and 1 are still hardcoded in a couple places.

Copy link
Contributor Author

@corybarr corybarr Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'd left 0 and 1 in widget_kwargs. Gone now.

I was able to remove the dependency on CesiumRasterOverlay.

Note: There were issues operating on generic prims. For some reason, only class functions to access attributes would work (e.g., GetAlphaAttr) in event handlers. Fortunately, we don't need update_range anyways. It's cruft from an example where bounds and its associated attributes needed to be updated. We might possible run into this in the future if we want to do something like update bounds on generic prims.

@corybarr corybarr merged commit 2c9606b into main Jan 31, 2024
3 checks passed
@corybarr corybarr deleted the raster-overlay-ui-enhancements branch January 31, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants