Skip to content

Commit

Permalink
Add Component Visualizer sub-documents
Browse files Browse the repository at this point in the history
  • Loading branch information
ibbles committed Sep 12, 2021
1 parent 6a5c476 commit f7b2b15
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Component Visualizer - Handle input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
2021-08-26_12:32:42

# Component Visualizer - Handle input

There is `HandleInputDelta` and `HandleInputKey`.
When you have determined that a change is going to happen (all checks passed) then call `Modify` on the edited object, do the change, and then call `NotifyPropertyModified` and `GEditor->RedrawLevelEditingViewports`.

```cpp
bool FMyVisualizer::HandleInputDelta(
FEditorViewportClient* ViewportClient,
FViewport* Viewport,
FVector& DeltaTranslate,
FRotator& DeltaRotate,
FVector& DeltaScale)
{
UMyComponent* My = GetSelectedMy();
if (My == nullptr)
{
return false;
}
if (DeltaTranslate.IsZero())
{
return true;
}
My->Modify();
My->MyProperty += DeltaRotate;
NotifyPropertyModified(
My,
FindFProperty<FProperty>(
Class, GET_MEMBER_NAME_CHECKED(UMyComponent, MyProperty)
)
);
GEditor->RedrawLevelEditingViewports()
}
```
Getting the edited Component is complicated.
The strategy I've seen uses Hit Proxies that store a pointer to the Component and a Hit Proxy callback on the Visualizer that read that pointer and remembers it for use in `HandleInputDelta`.
[[2020-08-06_18:48:41]] [Component visualizer](./Component%20visualizer.md)
5 changes: 5 additions & 0 deletions Component Visualizer - Hit Proxies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
2021-08-26_12:47:43

# Component Visualizer - Hit Proxies

[[2020-08-06_18:48:41]] [Component visualizer](./Component%20visualizer.md)
41 changes: 41 additions & 0 deletions Component Visualizer - Widget location.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
2021-08-26_08:50:46

# Component Visualizer - Widget location

Unreal Editor uses a Transform Widget to let the user transform objects.
The transformed object can be an Actor in the level, a Component in an Actor, or a custom attribute of a Component.
By "attribute" I mean anything that a Component might have, often a UProperty.
For example one of the control points of a spline.

![A transformation widget on a spline control point](Images/ComponentVisualiser_WidgetLocation_example.png)

The editor provide code for transforming Actors and Components, but custom attributes require custom code.
The custom code lives in the Component Visualizer associated with the Component type.
The Component Visualizer has three virtual methods that deal with interactive transformations:
- `GetWidgetLocation`
- `HandleInputDelta`
- `IsVisualizingArchetype`

These functions are called by Unreal Editor from `FEditorViewportClient::Draw`.
There is also `ISCSEditorCustomization` which seem related but I know nothing about it.

`GetWidgetLocation` should provide the location, in world space, where the transformation widget should be placed.

```cpp
bool FMyVisualizer::GetWidgetLocation(
const FEditorViewportClient* ViewportClient, FVector& OutLocation) const
{
UMyComponent* MyComponent = GetEditedMy();
if (MyComponent == nullptr)
{
return false;
}
OutLocation = MyComponent->MyVectorUProperty;
return true;
}
```
Getting the edited Component is complicated.
The strategy I've seen uses Hit Proxies that store a pointer to the Component and a Hit Proxy callback on the Visualizer that read that pointer and remembers it for use in `GetWidgetLocation`.
[[2020-08-06_18:48:41]] [Component visualizer](./Component%20visualizer.md)

0 comments on commit f7b2b15

Please sign in to comment.