Improve usage of Line types

This commit is contained in:
Jaby
2024-01-05 22:56:44 -06:00
parent dfb0a72ec8
commit 322dca67c5
3 changed files with 45 additions and 8 deletions

View File

@@ -69,6 +69,22 @@ namespace JabyEngine {
Vertex start_point;
Body points[N];
Termination end;
template<typename T = Body>
constexpr typename enable_if<is_same<T, Vertex>::value, Vertex>::type operator[](size_t idx) const {
if(idx == 0) {
return this->start_point;
}
return this->points[idx - 1];
}
template<typename T = Body>
constexpr typename enable_if<is_same<T, ColorVertex>::value, ColorVertex>::type operator[](size_t idx) const {
if(idx == 0) {
return ColorVertex::create(this->head.color, this->start_point);
}
return this->points[idx - 1];
}
};
}
@@ -105,5 +121,13 @@ namespace JabyEngine {
return {.head = LineHead::create(start_point.color, IdentityCode, true), .start_point = start_point.position, .points = {rest...}, .end = Termination::create()};
}
};
using LINE_F_SINGLE = internal::SingleLine<Vertex>;
template<size_t N>
using LINE_F_MULTI = internal::MultiLine<Vertex, N - 1>;
using LINE_G_SINGLE = internal::SingleLine<ColorVertex>;
template<size_t N>
using LINE_G_MULTI = internal::MultiLine<ColorVertex, N - 1>;
}
}