summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/scenary/foliage.cpp3
-rw-r--r--game/scenary/foliage.h3
-rw-r--r--game/scenary/plant.cpp2
-rw-r--r--game/scenary/plant.h2
-rw-r--r--game/vehicles/railVehicle.cpp9
-rw-r--r--game/vehicles/railVehicleClass.cpp8
-rw-r--r--game/vehicles/railVehicleClass.h1
7 files changed, 18 insertions, 10 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp
index 702a52c..c258b77 100644
--- a/game/scenary/foliage.cpp
+++ b/game/scenary/foliage.cpp
@@ -15,7 +15,8 @@ void
Foliage::postLoad()
{
texture = getTexture();
- bodyMesh->configureVAO(instanceVAO).addAttribs<glm::mat4>(instances.bufferName(), 1);
+ bodyMesh->configureVAO(instanceVAO)
+ .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1);
}
void
diff --git a/game/scenary/foliage.h b/game/scenary/foliage.h
index b72a9c2..5a9d2de 100644
--- a/game/scenary/foliage.h
+++ b/game/scenary/foliage.h
@@ -15,7 +15,8 @@ class Foliage : public Asset, public Renderable, public StdTypeDefs<Foliage> {
glVertexArray instanceVAO;
public:
- mutable InstanceVertices<glm::mat4> instances;
+ using LocationVertex = std::pair<glm::mat4, Position3D>;
+ mutable InstanceVertices<LocationVertex> instances;
void render(const SceneShader &) const override;
void shadows(const ShadowMapper &) const override;
diff --git a/game/scenary/plant.cpp b/game/scenary/plant.cpp
index 4fb3cb5..b39c28b 100644
--- a/game/scenary/plant.cpp
+++ b/game/scenary/plant.cpp
@@ -2,6 +2,6 @@
#include "location.h"
Plant::Plant(std::shared_ptr<const Foliage> type, const Location & position) :
- type {std::move(type)}, location {this->type->instances.acquire(position.getTransform())}
+ type {std::move(type)}, location {this->type->instances.acquire(position.getRotationTransform(), position.pos)}
{
}
diff --git a/game/scenary/plant.h b/game/scenary/plant.h
index 82ab0e5..77c9ff7 100644
--- a/game/scenary/plant.h
+++ b/game/scenary/plant.h
@@ -7,7 +7,7 @@ class Location;
class Plant : public WorldObject {
std::shared_ptr<const Foliage> type;
- InstanceVertices<glm::mat4>::InstanceProxy location;
+ InstanceVertices<Foliage::LocationVertex>::InstanceProxy location;
void
tick(TickDuration) override
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp
index 1ed904d..6e6e18f 100644
--- a/game/vehicles/railVehicle.cpp
+++ b/game/vehicles/railVehicle.cpp
@@ -14,15 +14,18 @@
RailVehicle::RailVehicle(RailVehicleClassPtr rvc) :
RailVehicleClass::Instance {rvc->instances.acquire()}, rvClass {std::move(rvc)},
location {[this](const BufferedLocation * l) {
- this->get()->body = l->getTransform();
+ this->get()->body = l->getRotationTransform();
+ this->get()->bodyPos = l->position();
}},
bogies {{
{[this](const BufferedLocation * l) {
- this->get()->front = l->getTransform();
+ this->get()->front = l->getRotationTransform();
+ this->get()->frontPos = l->position();
},
Position3D {0, rvClass->wheelBase / 2.F, 0}},
{[this](const BufferedLocation * l) {
- this->get()->back = l->getTransform();
+ this->get()->back = l->getRotationTransform();
+ this->get()->backPos = l->position();
},
Position3D {0, -rvClass->wheelBase / 2.F, 0}},
}}
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index 324148c..7a6a9fe 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -35,13 +35,15 @@ void
RailVehicleClass::postLoad()
{
texture = getTexture();
- bodyMesh->configureVAO(instanceVAO).addAttribs<LocationVertex, &LocationVertex::body>(instances.bufferName(), 1);
+ bodyMesh->configureVAO(instanceVAO)
+ .addAttribs<LocationVertex, &LocationVertex::body, &LocationVertex::bodyPos>(instances.bufferName(), 1);
bogies.front()
->configureVAO(instancesBogiesVAO.front())
- .addAttribs<LocationVertex, &LocationVertex::front>(instances.bufferName(), 1);
+ .addAttribs<LocationVertex, &LocationVertex::front, &LocationVertex::frontPos>(instances.bufferName(), 1);
bogies.back()
->configureVAO(instancesBogiesVAO.back())
- .addAttribs<LocationVertex, &LocationVertex::back>(instances.bufferName(), 1);
+ .addAttribs<LocationVertex, &LocationVertex::back, &LocationVertex::backPos>(instances.bufferName(), 1);
+ static_assert(sizeof(LocationVertex) == 228UL);
}
void
diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h
index 4668d7d..16dce01 100644
--- a/game/vehicles/railVehicleClass.h
+++ b/game/vehicles/railVehicleClass.h
@@ -20,6 +20,7 @@ public:
struct LocationVertex {
glm::mat4 body, front, back;
+ Position3D bodyPos, frontPos, backPos;
};
std::array<Mesh::Ptr, 2> bogies;