Blender  V3.3
node_geo_input_mesh_face_area.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "DNA_mesh_types.h"
4 #include "DNA_meshdata_types.h"
5 
6 #include "BKE_mesh.h"
7 
8 #include "node_geometry_util.hh"
9 
11 
13 {
14  b.add_output<decl::Float>(N_("Area"))
15  .field_source()
16  .description(N_("The surface area of each of the mesh's faces"));
17 }
18 
20  const eAttrDomain domain)
21 {
22  const Mesh *mesh = component.get_for_read();
23  if (mesh == nullptr) {
24  return {};
25  }
26 
27  auto area_fn = [mesh](const int i) -> float {
28  const MPoly *mp = &mesh->mpoly[i];
30  };
31 
32  return component.attributes()->adapt_domain<float>(
34 }
35 
37  public:
38  FaceAreaFieldInput() : GeometryFieldInput(CPPType::get<float>(), "Face Area Field")
39  {
41  }
42 
44  const eAttrDomain domain,
45  IndexMask UNUSED(mask)) const final
46  {
47  if (component.type() == GEO_COMPONENT_TYPE_MESH) {
48  const MeshComponent &mesh_component = static_cast<const MeshComponent &>(component);
49  return construct_face_area_gvarray(mesh_component, domain);
50  }
51  return {};
52  }
53 
54  uint64_t hash() const override
55  {
56  /* Some random constant hash. */
57  return 1346334523;
58  }
59 
60  bool is_equal_to(const fn::FieldNode &other) const override
61  {
62  return dynamic_cast<const FaceAreaFieldInput *>(&other) != nullptr;
63  }
64 };
65 
67 {
68  params.set_output("Area", Field<float>(std::make_shared<FaceAreaFieldInput>()));
69 }
70 
71 } // namespace blender::nodes::node_geo_input_mesh_face_area_cc
72 
74 {
76 
77  static bNodeType ntype;
81  nodeRegisterType(&ntype);
82 }
typedef float(TangentPoint)[2]
eAttrDomain
Definition: BKE_attribute.h:25
@ ATTR_DOMAIN_FACE
Definition: BKE_attribute.h:29
@ GEO_COMPONENT_TYPE_MESH
float BKE_mesh_calc_poly_area(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray)
#define NODE_CLASS_INPUT
Definition: BKE_node.h:345
#define GEO_NODE_INPUT_MESH_FACE_AREA
Definition: BKE_node.h:1480
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define final(a, b, c)
Definition: BLI_hash.h:21
#define UNUSED(x)
static uint8 component(Color32 c, uint i)
Definition: ColorBlock.cpp:108
static VArray ForFunc(const int64_t size, GetFunc get_func)
GVArray get_varray_for_context(const GeometryComponent &component, const eAttrDomain domain, IndexMask UNUSED(mask)) const final
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static VArray< float > construct_face_area_gvarray(const MeshComponent &component, const eAttrDomain domain)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_input_mesh_face_area()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
unsigned __int64 uint64_t
Definition: stdint.h:90
struct MVert * mvert
struct MLoop * mloop
int totpoly
struct MPoly * mpoly
Defines a node type.
Definition: BKE_node.h:226
NodeGeometryExecFunction geometry_node_execute
Definition: BKE_node.h:316
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)