blob: 37d03f8ccb328707e276fc89bc4208405607596f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "network.h"
#include <gfx/gl/shader.h>
#include <gfx/models/texture.h>
template<typename T>
void
NetworkOf<T>::render(const Shader & shader) const
{
if constexpr (std::is_base_of_v<Renderable, T>) {
shader.setModel(Location {}, Shader::Program::StaticPos);
texture->Bind();
links.apply(&Renderable::render, shader);
}
}
template<typename T>
void
NetworkOf<T>::joinLinks(const LinkPtr & l) const
{
for (const auto & ol : links.objects) {
Network::joinLinks(l, ol);
}
}
template<typename T>
LinkPtr
NetworkOf<T>::intersectRayLinks(const Ray & ray) const
{
// Click link
if (const auto link = std::find_if(links.objects.begin(), links.objects.end(),
[&ray](const std::shared_ptr<T> & link) {
return link->intersectRay(ray);
});
link != links.objects.end()) {
return *link;
}
return {};
}
template<typename T>
LinkPtr
NetworkOf<T>::addStraight(glm::vec3 n1, glm::vec3 n2)
{
return addLink<typename T::StraightLink>(n1, n2);
}
template<typename T>
LinkPtr
NetworkOf<T>::addJoins(glm::vec3 n1, glm::vec3 n2)
{
return addLink<typename T::StraightLink>(n1, n2);
}
|