41 using T = decltype(dummy);
42 const VArray<T> &values_typed = values.typed<T>();
43 for (const int i : values.index_range()) {
44 const float3 position = math::transform_point(object_to_world, positions[i]);
45 const T &value = values_typed[i];
48 size_t numstr_len = 0;
49 if constexpr (std::is_same_v<T, bool>) {
50 numstr_len = SNPRINTF_RLEN(numstr,
"%s", value ?
"True" :
"False");
52 else if constexpr (std::is_same_v<T, int8_t>) {
53 numstr_len = SNPRINTF_RLEN(numstr,
"%d", int(value));
55 else if constexpr (std::is_same_v<T, int>) {
56 numstr_len = SNPRINTF_RLEN(numstr,
"%d", value);
58 else if constexpr (std::is_same_v<T, int2>) {
59 numstr_len = SNPRINTF_RLEN(numstr,
"(%d, %d)", value.x, value.y);
61 else if constexpr (std::is_same_v<T, float>) {
62 numstr_len = SNPRINTF_RLEN(numstr,
"%g", value);
64 else if constexpr (std::is_same_v<T, float2>) {
65 numstr_len = SNPRINTF_RLEN(numstr,
"(%g, %g)", value.x, value.y);
67 else if constexpr (std::is_same_v<T, float3>) {
68 numstr_len = SNPRINTF_RLEN(numstr,
"(%g, %g, %g)", value.x, value.y, value.z);
70 else if constexpr (std::is_same_v<T, ColorGeometry4b>) {
71 const ColorGeometry4f color = value.decode();
72 numstr_len = SNPRINTF_RLEN(
73 numstr,
"(%.3f, %.3f, %.3f, %.3f)", color.r, color.g, color.b, color.a);
75 else if constexpr (std::is_same_v<T, ColorGeometry4f>) {
76 numstr_len = SNPRINTF_RLEN(
77 numstr,
"(%.3f, %.3f, %.3f, %.3f)", value.r, value.g, value.b, value.a);
79 else if constexpr (std::is_same_v<T, math::Quaternion>) {
80 numstr_len = SNPRINTF_RLEN(
81 numstr,
"(%.3f, %.3f, %.3f, %.3f)", value.w, value.x, value.y, value.z);
84 BLI_assert_unreachable();
88 dt, position, numstr, numstr_len, 0, 0, DRW_TEXT_CACHE_GLOBALSPACE, col, true, true);
125 const float4x4 &object_to_world =
object.object_to_world();
130 if (instances->attributes().contains(
".viewer")) {
131 add_instance_attributes_to_text_cache(
138 switch (
object.type) {
140 const Mesh *mesh =
static_cast<Mesh *
>(
object.data);
141 add_attributes_to_text_cache(mesh->attributes(), object_to_world);
146 add_attributes_to_text_cache(pointcloud->
attributes(), object_to_world);
150 const Curve *curve =
static_cast<Curve *
>(
object.data);
151 if (curve->curve_eval) {
153 add_attributes_to_text_cache(curves.attributes(), object_to_world);
158 const Curves *curves_id =
static_cast<Curves *
>(
object.data);
160 add_attributes_to_text_cache(curves.attributes(), object_to_world);
void OVERLAY_viewer_attribute_text(const Object &object)