26 const float dx = (size_x == 0.0f) ? 0.0f : 1.0f / size_x;
27 const float dy = (size_y == 0.0f) ? 0.0f : 1.0f / size_y;
29 for (const int i : range) {
30 const float3 &co = verts[loops[i].v].co;
31 uv_attribute.span[i].x = (co.x + size_x * 0.5f) * dx;
32 uv_attribute.span[i].y = (co.y + size_y * 0.5f) * dy;
36 uv_attribute.finish();
45 const int edges_x = verts_x - 1;
46 const int edges_y = verts_y - 1;
48 edges_x * verts_y + edges_y * verts_x,
50 edges_x * edges_y * 4,
58 const float dx = edges_x == 0 ? 0.0f : size_x / edges_x;
59 const float dy = edges_y == 0 ? 0.0f : size_y / edges_y;
60 const float x_shift = edges_x / 2.0f;
61 const float y_shift = edges_y / 2.0f;
63 for (
const int x : x_range) {
64 const int y_offset =
x * verts_y;
66 for (
const int y : y_range) {
67 const int vert_index = y_offset +
y;
68 verts[vert_index].co[0] = (
x - x_shift) * dx;
69 verts[vert_index].co[1] = (
y - y_shift) * dy;
70 verts[vert_index].co[2] = 0.0f;
77 const int y_edges_start = 0;
78 const int x_edges_start = verts_x * edges_y;
79 const short edge_flag = (edges_x == 0 || edges_y == 0) ?
ME_LOOSEEDGE :
84 for (
const int x : x_range) {
85 const int y_vert_offset =
x * verts_y;
86 const int y_edge_offset = y_edges_start +
x * edges_y;
88 for (
const int y : y_range) {
89 const int vert_index = y_vert_offset +
y;
90 MEdge &edge = edges[y_edge_offset +
y];
92 edge.v2 = vert_index + 1;
93 edge.flag = edge_flag;
101 for (
const int y : y_range) {
102 const int x_edge_offset = x_edges_start +
y * edges_x;
104 for (
const int x : x_range) {
105 const int vert_index =
x * verts_y +
y;
106 MEdge &edge = edges[x_edge_offset +
x];
107 edge.v1 = vert_index;
108 edge.v2 = vert_index + verts_y;
109 edge.flag = edge_flag;
116 for (
const int x : x_range) {
117 const int y_offset =
x * edges_y;
119 for (
const int y : y_range) {
120 const int poly_index = y_offset +
y;
121 const int loop_index = poly_index * 4;
122 MPoly &poly = polys[poly_index];
125 const int vert_index =
x * verts_y +
y;
127 MLoop &loop_a = loops[loop_index];
128 loop_a.
v = vert_index;
129 loop_a.
e = x_edges_start + edges_x *
y +
x;
130 MLoop &loop_b = loops[loop_index + 1];
131 loop_b.
v = vert_index + verts_y;
132 loop_b.
e = y_edges_start + edges_y * (
x + 1) +
y;
133 MLoop &loop_c = loops[loop_index + 2];
134 loop_c.
v = vert_index + verts_y + 1;
135 loop_c.e = x_edges_start + edges_x * (
y + 1) +
x;
136 MLoop &loop_d = loops[loop_index + 3];
137 loop_d.
v = vert_index + 1;
138 loop_d.e = y_edges_start + edges_y *
x +
y;
161 .
description(
N_(
"Side length of the plane in the X direction"));
166 .
description(
N_(
"Side length of the plane in the Y direction"));
182 const float size_x =
params.extract_input<
float>(
"Size X");
183 const float size_y =
params.extract_input<
float>(
"Size Y");
184 const int verts_x =
params.extract_input<
int>(
"Vertices X");
185 const int verts_y =
params.extract_input<
int>(
"Vertices Y");
186 if (verts_x < 1 || verts_y < 1) {
187 params.set_default_remaining_outputs();
General operations, lookup, etc. for materials.
void BKE_id_material_eval_ensure_default_slot(struct ID *id)
struct Mesh * BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_MESH_PRIMITIVE_GRID
void nodeRegisterType(struct bNodeType *ntype)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
constexpr IndexRange index_range() const
GSpanAttributeWriter lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type)
StringRefNull description() const
MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
static void calculate_uvs(Mesh *mesh, Span< MVert > verts, Span< MLoop > loops, const float size_x, const float size_y)
Mesh * create_grid_mesh(int verts_x, int verts_y, float size_x, float size_y)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_mesh_primitive_grid()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
static GeometrySet create_with_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare