Gives the kernel a reference to be tested against, and a route for a caller with no compute queue available. It builds the unjoined ribbon form only (no miter, no width averaging across shared positions), so use it to check span indexing and vertex counts rather than ribbon geometry. Not a general geometry utility, and not intended for per-frame use at scale.
973{
974 const auto vertex_at = [&indices](uint32_t k) {
975 return indices.empty() ? k : indices[k];
976 };
977
978 auto result = layout;
980 dst.clear();
981
982 MillOffsets off;
983 if (!offsets_from(layout, off)) {
984 return result;
985 }
986
987 std::vector<uint32_t> prefix;
988 build_prefix(runs, prefix);
989 const uint32_t total = prefix.empty() ? 0U : prefix.back();
990 if (total == 0) {
991 return result;
992 }
993
994 dst.assign(
static_cast<size_t>(total) * layout.
stride_bytes, 0);
995 result.vertex_count = total;
996
997 const HostRecords rec {
998 .src = reinterpret_cast<const uint32_t*>(src.data()),
999 .dst = reinterpret_cast<uint32_t*>(dst.data()),
1000 .stride_words = off.stride_words
1001 };
1002
1006
1007 for (size_t r = 0; r < runs.size(); ++r) {
1008 const auto&
run = runs[r];
1009 const uint32_t emitted = prefix[r + 1] - prefix[r];
1010 const uint32_t base = prefix[r];
1011 const uint32_t voff =
run.vertex_offset;
1012
1013 for (uint32_t local = 0; local < emitted; ++local) {
1014 const uint32_t out = base + local;
1015
1016 const bool is_tri = is_triangle_topology(
run.topology);
1022 const auto wire_uv = [](uint32_t c) {
1023 return glm::vec2(c == 0U ? 21.0F : 20.0F, c == 1U ? 1.0F : 0.0F);
1024 };
1025
1027 rec.copy_vertex(out, vertex_at(voff + local));
1028 if (wire) {
1029 rec.write_uv(out, off.uv, wire_uv(local % 3U));
1030 }
1031 continue;
1032 }
1033
1036 && !as_point) {
1037 const uint32_t tri = local / 3U;
1038 const uint32_t c = local - tri * 3U;
1039 uint32_t a = 0;
1040 uint32_t b1 = tri + 1U;
1041 uint32_t b2 = tri + 2U;
1043 a = tri;
1044 if ((tri & 1U) == 1U) {
1045 std::swap(a, b1);
1046 }
1047 }
1048 const uint32_t
pick = c == 0
U ? a : (c == 1U ? b1 : b2);
1049 rec.copy_vertex(out, vertex_at(voff + pick));
1050 if (wire) {
1051 rec.write_uv(out, off.uv, wire_uv(c));
1052 }
1053 continue;
1054 }
1055
1056 const uint32_t corner = local % 6U;
1057 const uint32_t quad = local / 6U;
1058
1059 if (as_point) {
1061 ? voff + quad
1062 : vertex_at(voff + quad);
1063 const glm::vec3 p = rec.read_pos(s, off.position);
1064 const float h = rec.read_extent(s, scalar_offset, spec.
fallback_extent)
1066
1067 glm::vec3 rx;
1068 glm::vec3 ry;
1069 if (world_plane) {
1070 rx = glm::vec3(h, 0.0F, 0.0F);
1071 ry = glm::vec3(0.0F, h, 0.0F);
1072 } else {
1073 const glm::vec3 n = host_view_normal(p, view.
eye);
1074 const glm::vec3 up = std::abs(n.y) < 0.99F
1075 ? glm::vec3(0.0F, 1.0F, 0.0F)
1076 : glm::
vec3(1.0F, 0.0F, 0.0F);
1077 rx = glm::normalize(glm::cross(up, n)) * h;
1078 ry = glm::normalize(glm::cross(n, rx)) * h;
1079 }
1080
1081 glm::vec3 o;
1082 glm::vec2 uv;
1083 switch (corner) {
1084 case 1:
1085 o = rx - ry;
1086 uv = { 1.0F, 0.0F };
1087 break;
1088 case 2:
1089 case 4:
1090 o = rx + ry;
1091 uv = { 1.0F, 1.0F };
1092 break;
1093 case 5:
1094 o = -rx + ry;
1095 uv = { 0.0F, 1.0F };
1096 break;
1097 default:
1098 o = -rx - ry;
1099 uv = { 0.0F, 0.0F };
1100 break;
1101 }
1102
1103 rec.copy_vertex(out, s);
1104 if (billboard) {
1105 rec.write_pos(out, off.position, p);
1106 rec.write_tangent(out, off.tangent,
1107 glm::vec4((uv * 2.0F - glm::vec2(1.0F)) * h, 0.0F, 0.0F));
1108 } else {
1109 rec.write_pos(out, off.position, p + o);
1110 }
1112 rec.write_uv(out, off.uv, uv + glm::vec2(10.0F));
1113 }
1114 continue;
1115 }
1116
1118 ? voff + quad * 2U
1119 : voff + quad;
1120 const uint32_t s1 = s0 + 1U;
1121
1122 const glm::vec3 p0 = rec.read_pos(s0, off.position);
1123 const glm::vec3 p1 = rec.read_pos(s1, off.position);
1124 const glm::vec3 d = p1 - p0;
1125
1126 if (glm::length(d) < 1e-6F) {
1127 rec.write_pos(out, off.position, p0);
1128 if (billboard) {
1129 rec.write_tangent(out, off.tangent, glm::vec4(0.0F));
1130 }
1131 continue;
1132 }
1133
1134 const float h0 = rec.read_extent(s0, scalar_offset, spec.
fallback_extent)
1136 const float h1 = rec.read_extent(s1, scalar_offset, spec.
fallback_extent)
1138
1139 const glm::vec3 e0 = host_side_at(
1140 p0, d, view.
eye, h0, world_plane);
1141 const glm::vec3 e1 = host_side_at(
1142 p1, d, view.
eye, h1, world_plane);
1143
1144 glm::vec3 pos;
1146 glm::vec2 uv;
1147 switch (corner) {
1148 case 1:
1149 pos = p0 + e0;
1150 uv = { 0.0F, 0.0F };
1151 break;
1152 case 2:
1153 case 4:
1154 pos = p1 + e1;
1156 uv = { 1.0F, 0.0F };
1157 break;
1158 case 5:
1159 pos = p1 - e1;
1161 uv = { 1.0F, 1.0F };
1162 break;
1163 default:
1164 pos = p0 - e0;
1165 uv = { 0.0F, 1.0F };
1166 break;
1167 }
1168
1169 rec.copy_vertex(out, pick);
1170 if (billboard) {
1171 const float sign = (corner == 0
U || corner == 3U || corner == 5U) ? -1.0F : 1.0F;
1172 const float half_w = (corner == 0
U || corner == 1U || corner == 3U) ? h0 : h1;
1173 rec.write_pos(out, off.position, pick == s0 ? p0 : p1);
1174 rec.write_tangent(out, off.tangent,
1175 glm::vec4(d / glm::length(d), sign * half_w));
1176 } else {
1177 rec.write_pos(out, off.position, pos);
1178 }
1180 rec.write_uv(out, off.uv, wire_uv(corner % 3U));
1182 rec.write_uv(out, off.uv, uv);
1183 }
1184 }
1185 }
1186
1187 return result;
1188}
uint32_t stride_bytes
Total bytes per vertex (stride in Vulkan terms) e.g., 3 floats (position) + 3 floats (normal) = 24 by...
uint32_t vertex_count
Total number of vertices in this buffer.
@ WorldPlane
Held in the XY plane, viewpoint ignored.
bool synthesize_uv
Write 0..1 UVs across each ribbon and quad instead of copying the source.
float fallback_extent
Extent used when the layout carries no scalar attribute.
float width_scale
World units of total ribbon width per unit of a vertex's scalar.
bool billboard_instances
Keep point quads and ribbons unexpanded for an instanced draw.
bool use_vertex_extent
Take ribbon width and point size from each vertex's own scalar (LineVertex::thickness,...
float point_scale
World units per unit of a vertex's own size, on point spans.