Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static void calculate_uvs( | ||||
| MeshComponent mesh_component; | MeshComponent mesh_component; | ||||
| mesh_component.replace(mesh, GeometryOwnershipType::Editable); | mesh_component.replace(mesh, GeometryOwnershipType::Editable); | ||||
| OutputAttribute_Typed<float2> uv_attribute = | OutputAttribute_Typed<float2> uv_attribute = | ||||
| mesh_component.attribute_try_get_for_output_only<float2>("uv_map", ATTR_DOMAIN_CORNER); | mesh_component.attribute_try_get_for_output_only<float2>("uv_map", ATTR_DOMAIN_CORNER); | ||||
| MutableSpan<float2> uvs = uv_attribute.as_span(); | MutableSpan<float2> uvs = uv_attribute.as_span(); | ||||
| const float dx = (size_x == 0.0f) ? 0.0f : 1.0f / size_x; | const float dx = (size_x == 0.0f) ? 0.0f : 1.0f / size_x; | ||||
| const float dy = (size_y == 0.0f) ? 0.0f : 1.0f / size_y; | const float dy = (size_y == 0.0f) ? 0.0f : 1.0f / size_y; | ||||
| for (const int i : loops.index_range()) { | for (const int i : iter_indices(loops)) { | ||||
| const float3 &co = verts[loops[i].v].co; | const float3 &co = verts[loops[i].v].co; | ||||
| uvs[i].x = (co.x + size_x * 0.5f) * dx; | uvs[i].x = (co.x + size_x * 0.5f) * dx; | ||||
| uvs[i].y = (co.y + size_y * 0.5f) * dy; | uvs[i].y = (co.y + size_y * 0.5f) * dy; | ||||
| } | } | ||||
| uv_attribute.save(); | uv_attribute.save(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines | |||||