Improve usage of Line types
This commit is contained in:
@@ -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>;
|
||||
}
|
||||
}
|
@@ -187,21 +187,21 @@ namespace JabyEngine {
|
||||
|
||||
// ###################################################################
|
||||
|
||||
static constexpr GPU::internal::SingleLine<GPU::Vertex> LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const GPU::Vertex& end_point) {
|
||||
static constexpr GPU::LINE_F_SINGLE LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const GPU::Vertex& end_point) {
|
||||
return GPU::LINE_F::create(color, start_point, end_point);
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static constexpr GPU::internal::MultiLine<GPU::Vertex, sizeof...(ARGS)> LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const ARGS&...rest) {
|
||||
static constexpr GPU::LINE_F_MULTI<sizeof...(ARGS) + 1> LINE_F(const GPU::Color24& color, const GPU::Vertex& start_point, const ARGS&...rest) {
|
||||
return GPU::LINE_F::create(color, start_point, rest...);
|
||||
}
|
||||
|
||||
static constexpr GPU::internal::SingleLine<GPU::ColorVertex> LINE_G(const GPU::ColorVertex& start_point, const GPU::ColorVertex& end_point) {
|
||||
static constexpr GPU::LINE_G_SINGLE LINE_G(const GPU::ColorVertex& start_point, const GPU::ColorVertex& end_point) {
|
||||
return GPU::LINE_G::create(start_point, end_point);
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static constexpr GPU::internal::MultiLine<GPU::ColorVertex, sizeof...(ARGS)> LINE_G(const GPU::ColorVertex& start_point, const ARGS&...rest) {
|
||||
static constexpr GPU::LINE_G_MULTI<sizeof...(ARGS) + 1> LINE_G(const GPU::ColorVertex& start_point, const ARGS&...rest) {
|
||||
return GPU::LINE_G::create(start_point, rest...);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user