This adds support for attaching gizmos for input values. The goal is to make it easier for users to set input values intuitively in the 3D viewport. We went through multiple different possible designs until we settled on the one implemented here. We picked it for it's flexibility and ease of use when using geometry node assets. The core principle in the design is that **gizmos are attached to existing input values instead of being the input value themselves**. This actually fits the existing concept of gizmos in Blender well, but may be a bit unintutitive in a node setup at first. The attachment is done using links in the node editor. The most basic usage of the node is to link a Value node to the new Linear Gizmo node. This attaches the gizmo to the input value and allows you to change it from the 3D view. The attachment is indicated by the gizmo icon in the sockets which are controlled by a gizmo as well as the back-link (notice the double link) when the gizmo is active. The core principle makes it straight forward to control the same node setup from the 3D view with gizmos, or by manually changing input values, or by driving the input values procedurally. If the input value is controlled indirectly by other inputs, it's often possible to **automatically propagate** the gizmo to the actual input. Backpropagation does not work for all nodes, although more nodes can be supported over time. This patch adds the first three gizmo nodes which cover common use cases: * **Linear Gizmo**: Creates a gizmo that controls a float or integer value using a linear movement of e.g. an arrow in the 3D viewport. * **Dial Gizmo**: Creates a circular gizmo in the 3D viewport that can be rotated to change the attached angle input. * **Transform Gizmo**: Creates a simple gizmo for location, rotation and scale. In the future, more built-in gizmos and potentially the ability for custom gizmos could be added. All gizmo nodes have a **Transform** geometry output. Using it is optional but it is recommended when the gizmo is used to control inputs that affect a geometry. When it is used, Blender will automatically transform the gizmos together with the geometry that they control. To achieve this, the output should be merged with the generated geometry using the *Join Geometry* node. The data contained in *Transform* output is not visible geometry, but just internal information that helps Blender to give a better user experience when using gizmos. The gizmo nodes have a multi-input socket. This allows **controlling multiple values** with the same gizmo. Only a small set of **gizmo shapes** is supported initially. It might be extended in the future but one goal is to give the gizmos used by different node group assets a familiar look and feel. A similar constraint exists for **colors**. Currently, one can choose from a fixed set of colors which can be modified in the theme settings. The set of **visible gizmos** is determined by a multiple factors because it's not really feasible to show all possible gizmos at all times. To see any of the geometry nodes gizmos, the "Active Modifier" option has to be enabled in the "Viewport Gizmos" popover. Then all gizmos are drawn for which at least one of the following is true: * The gizmo controls an input of the active modifier of the active object. * The gizmo controls a value in a selected node in an open node editor. * The gizmo controls a pinned value in an open node editor. Pinning works by clicking the gizmo icon next to the value. Pull Request: https://projects.blender.org/blender/blender/pulls/112677
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
struct NodesModifierData;
|
|
struct Object;
|
|
|
|
namespace blender::bke::bake {
|
|
struct ModifierCache;
|
|
}
|
|
namespace blender::nodes::geo_eval_log {
|
|
class GeoModifierLog;
|
|
}
|
|
|
|
/**
|
|
* Rebuild the list of properties based on the sockets exposed as the modifier's node group
|
|
* inputs. If any properties correspond to the old properties by name and type, carry over
|
|
* the values.
|
|
*/
|
|
void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd);
|
|
|
|
namespace blender {
|
|
|
|
struct NodesModifierRuntime {
|
|
/**
|
|
* Contains logged information from the last evaluation.
|
|
* This can be used to help the user to debug a node tree.
|
|
* This is a shared pointer because we might want to keep it around in some cases after the
|
|
* evaluation (e.g. for gizmo backpropagation).
|
|
*/
|
|
std::shared_ptr<nodes::geo_eval_log::GeoModifierLog> eval_log;
|
|
/**
|
|
* Simulation cache that is shared between original and evaluated modifiers. This allows the
|
|
* original modifier to be removed, without also removing the simulation state which may still be
|
|
* used by the evaluated modifier.
|
|
*/
|
|
std::shared_ptr<bke::bake::ModifierCache> cache;
|
|
};
|
|
|
|
void nodes_modifier_data_block_destruct(NodesModifierDataBlock *data_block, bool do_id_user);
|
|
|
|
} // namespace blender
|