summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-20 20:10:12 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-20 20:10:12 +0000
commita19011b730ac6d770e3b42cde3a10961495a417d (patch)
treea3d1e4de3c709167d226725ddd768a9ecd662ff5 /game
parentCommon code between straight/curve network geometry shaders (diff)
downloadilt-a19011b730ac6d770e3b42cde3a10961495a417d.tar.bz2
ilt-a19011b730ac6d770e3b42cde3a10961495a417d.tar.xz
ilt-a19011b730ac6d770e3b42cde3a10961495a417d.zip
Implement basic network curve part shader
Diffstat (limited to 'game')
-rw-r--r--game/network/rail.cpp7
-rw-r--r--game/network/rail.h1
2 files changed, 5 insertions, 3 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index efe4e2d..46c129b 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -155,8 +155,8 @@ RailLinkCurve::RailLinkCurve(NetworkLinkHolder<RailLinkCurve> & instances, const
Link({a, normalize(arc.first + half_pi)}, {b, normalize(arc.second - half_pi)},
glm::length(RelativePosition3D(a->pos - c)) * arc_length(arc)),
LinkCurve {c, glm::length(RelativePosition3D(ends[0].node->pos - c)), arc},
- instance {instances.vertices.acquire(ends[0].node->pos, ends[1].node->pos, c, round_sleepers(length / 2000.F))}
-
+ instance {instances.vertices.acquire(ends[0].node->pos, ends[1].node->pos, c, round_sleepers(length / 2000.F),
+ half_pi - arc.first, half_pi - arc.second)}
{
if (glGenVertexArrays) {
const auto & e0p {ends[0].node->pos};
@@ -198,7 +198,8 @@ template<> NetworkLinkHolder<RailLinkCurve>::NetworkLinkHolder()
{
VertexArrayObject {vao}
.addAttribs<RailLinkCurve::Vertex, &RailLinkCurve::Vertex::a, &RailLinkCurve::Vertex::b,
- &RailLinkCurve::Vertex::c, &RailLinkCurve::Vertex::textureRepeats>(vertices.bufferName());
+ &RailLinkCurve::Vertex::c, &RailLinkCurve::Vertex::textureRepeats, &RailLinkCurve::Vertex::aangle,
+ &RailLinkCurve::Vertex::bangle>(vertices.bufferName());
}
namespace {
diff --git a/game/network/rail.h b/game/network/rail.h
index b6a9ebe..39dfdc9 100644
--- a/game/network/rail.h
+++ b/game/network/rail.h
@@ -64,6 +64,7 @@ public:
struct Vertex {
GlobalPosition3D a, b, c;
float textureRepeats;
+ float aangle, bangle;
};
private: