Blender V4.3
node_geo_input_instance_scale.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
7#include "BLI_math_matrix.hh"
8
9#include "BKE_instances.hh"
10
12
14{
15 b.add_output<decl::Vector>("Scale").field_source();
16}
17
19 public:
20 InstanceScaleFieldInput() : bke::InstancesFieldInput(CPPType::get<float3>(), "Scale") {}
21
23 const IndexMask & /*mask*/) const final
24 {
25 const Span<float4x4> transforms = instances.transforms();
26 return VArray<float3>::ForFunc(instances.instances_num(), [transforms](const int i) {
27 return math::to_scale<true>(transforms[i]);
28 });
29 }
30
31 uint64_t hash() const override
32 {
33 return 8346343;
34 }
35
36 bool is_equal_to(const fn::FieldNode &other) const override
37 {
38 return dynamic_cast<const InstanceScaleFieldInput *>(&other) != nullptr;
39 }
40};
41
43{
44 Field<float3> scale{std::make_shared<InstanceScaleFieldInput>()};
45 params.set_output("Scale", std::move(scale));
46}
47
48static void node_register()
49{
50 static blender::bke::bNodeType ntype;
51 geo_node_type_base(&ntype, GEO_NODE_INPUT_INSTANCE_SCALE, "Instance Scale", NODE_CLASS_INPUT);
53 ntype.declare = node_declare;
55}
57
58} // namespace blender::nodes::node_geo_input_instance_scale_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static VArray ForFunc(const int64_t size, GetFunc get_func)
GVArray get_varray_for_context(const bke::Instances &instances, const IndexMask &) const final
local_group_size(16, 16) .push_constant(Type b
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
unsigned __int64 uint64_t
Definition stdint.h:90
Defines a node type.
Definition BKE_node.hh:218
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:339
NodeDeclareFunction declare
Definition BKE_node.hh:347