diff options
author | Jacques Lucke <jacques@blender.org> | 2021-02-04 18:36:34 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-02-04 18:36:34 +0300 |
commit | e7af04db0793b6c50194e22cb54ffc08629b8d2e (patch) | |
tree | 2a0717f6c8e417edea8adae721388402fd30db37 /source/blender/nodes | |
parent | 95703d19e0105bf64350b97fc094d4582f388329 (diff) |
Geometry Nodes: new Is Viewport node
This node outputs true when geometry nodes is currently evaluated
for the viewport and false for final renders.
Ref T85277.
Differential Revision: https://developer.blender.org/D10302
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_geometry.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_static_types.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_is_viewport.cc | 47 |
4 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 9982962cabd..aedca4b34fb 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -153,6 +153,7 @@ set(SRC geometry/nodes/node_geo_collection_info.cc geometry/nodes/node_geo_common.cc geometry/nodes/node_geo_edge_split.cc + geometry/nodes/node_geo_is_viewport.cc geometry/nodes/node_geo_join_geometry.cc geometry/nodes/node_geo_object_info.cc geometry/nodes/node_geo_point_distribute.cc diff --git a/source/blender/nodes/NOD_geometry.h b/source/blender/nodes/NOD_geometry.h index 178831d5d96..9b391ab7981 100644 --- a/source/blender/nodes/NOD_geometry.h +++ b/source/blender/nodes/NOD_geometry.h @@ -50,6 +50,7 @@ void register_node_type_geo_align_rotation_to_vector(void); void register_node_type_geo_sample_texture(void); void register_node_type_geo_points_to_volume(void); void register_node_type_geo_collection_info(void); +void register_node_type_geo_is_viewport(void); #ifdef __cplusplus } diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index cbc5f715db0..f9730af0c08 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -292,6 +292,7 @@ DefNode(GeometryNode, GEO_NODE_POINT_TRANSLATE, def_geo_point_translate, "POINT_ DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_SAMPLE_TEXTURE, def_geo_attribute_sample_texture, "ATTRIBUTE_SAMPLE_TEXTURE", AttributeSampleTexture, "Attribute Sample Texture", "") DefNode(GeometryNode, GEO_NODE_POINTS_TO_VOLUME, def_geo_points_to_volume, "POINTS_TO_VOLUME", PointsToVolume, "Points to Volume", "") DefNode(GeometryNode, GEO_NODE_COLLECTION_INFO, def_geo_collection_info, "COLLECTION_INFO", CollectionInfo, "Collection Info", "") +DefNode(GeometryNode, GEO_NODE_IS_VIEWPORT, 0, "IS_VIEWPORT", IsViewport, "Is Viewport", "") /* undefine macros */ #undef DefNode diff --git a/source/blender/nodes/geometry/nodes/node_geo_is_viewport.cc b/source/blender/nodes/geometry/nodes/node_geo_is_viewport.cc new file mode 100644 index 00000000000..667beaa1722 --- /dev/null +++ b/source/blender/nodes/geometry/nodes/node_geo_is_viewport.cc @@ -0,0 +1,47 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "node_geometry_util.hh" + +#include "DEG_depsgraph_query.h" + +static bNodeSocketTemplate geo_node_is_viewport_out[] = { + {SOCK_BOOLEAN, N_("Is Viewport")}, + {-1, ""}, +}; + +namespace blender::nodes { + +static void geo_node_is_viewport_exec(GeoNodeExecParams params) +{ + const Depsgraph *depsgraph = params.depsgraph(); + const eEvaluationMode mode = DEG_get_mode(depsgraph); + const bool is_viewport = mode == DAG_EVAL_VIEWPORT; + + params.set_output("Is Viewport", is_viewport); +} + +} // namespace blender::nodes + +void register_node_type_geo_is_viewport() +{ + static bNodeType ntype; + + geo_node_type_base(&ntype, GEO_NODE_IS_VIEWPORT, "Is Viewport", NODE_CLASS_INPUT, 0); + node_type_socket_templates(&ntype, nullptr, geo_node_is_viewport_out); + ntype.geometry_node_execute = blender::nodes::geo_node_is_viewport_exec; + nodeRegisterType(&ntype); +} |