Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
| Show All 18 Lines | |||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "bmesh.h" | |||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| static bNodeSocketTemplate geo_node_mesh_primitive_grid_in[] = { | static bNodeSocketTemplate geo_node_mesh_primitive_grid_in[] = { | ||||
| {SOCK_FLOAT, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, | {SOCK_FLOAT, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, | ||||
| {SOCK_INT, N_("Vertices X"), 3, 0.0f, 0.0f, 0.0f, 2, 1000}, | {SOCK_INT, N_("Vertices X"), 3, 0.0f, 0.0f, 0.0f, 2, 1000}, | ||||
| {SOCK_INT, N_("Vertices Y"), 3, 0.0f, 0.0f, 0.0f, 2, 1000}, | {SOCK_INT, N_("Vertices Y"), 3, 0.0f, 0.0f, 0.0f, 2, 1000}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | for (const int y : IndexRange(edges_y)) { | ||||
| MLoop &loop_d = loops[loop_index++]; | MLoop &loop_d = loops[loop_index++]; | ||||
| loop_d.v = vert_index + 1; | loop_d.v = vert_index + 1; | ||||
| loop_d.e = y_edges_start + edges_y * x + y; | loop_d.e = y_edges_start + edges_y * x + y; | ||||
| } | } | ||||
| } | } | ||||
| calculate_uvs(mesh, verts, loops, size); | calculate_uvs(mesh, verts, loops, size); | ||||
| return mesh; | /* Fix for T86874, converting to BMesh and then back. */ | ||||
| BMeshCreateParams bm_create_params = {0}; | |||||
| bm_create_params.use_toolflags = true; | |||||
| BMeshFromMeshParams bm_from_mesh_params = {0}; | |||||
| bm_from_mesh_params.calc_face_normal = true; | |||||
| BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bm_create_params, &bm_from_mesh_params); | |||||
| Mesh *result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh); | |||||
| return result; | |||||
| } | } | ||||
| static void geo_node_mesh_primitive_grid_exec(GeoNodeExecParams params) | static void geo_node_mesh_primitive_grid_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const float size = params.extract_input<float>("Size"); | const float size = params.extract_input<float>("Size"); | ||||
| const int verts_x = params.extract_input<int>("Vertices X"); | const int verts_x = params.extract_input<int>("Vertices X"); | ||||
| const int verts_y = params.extract_input<int>("Vertices Y"); | const int verts_y = params.extract_input<int>("Vertices Y"); | ||||
| if (verts_x < 2 || verts_y < 2) { | if (verts_x < 2 || verts_y < 2) { | ||||
| Show All 22 Lines | |||||