From 439630ae86b01b714574335d4dd2e583f724dba3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 10 Oct 2024 00:59:41 +0100 Subject: Include foliage yaw rotation in vertex, pass through instead of whole model rotation matrix --- game/scenary/foliage.cpp | 5 +++-- game/scenary/foliage.h | 7 ++++++- game/scenary/plant.cpp | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'game/scenary') diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp index 1e7424e..c90d5be 100644 --- a/game/scenary/foliage.cpp +++ b/game/scenary/foliage.cpp @@ -15,8 +15,9 @@ Foliage::postLoad() { texture = getTexture(); bodyMesh->configureVAO(instanceVAO) - .addAttribs(instances.bufferName(), 1); - VertexArrayObject {instancePointVAO}.addAttribs( + .addAttribs( + instances.bufferName(), 1); + VertexArrayObject {instancePointVAO}.addAttribs( instances.bufferName()); } diff --git a/game/scenary/foliage.h b/game/scenary/foliage.h index 824a644..5da63f0 100644 --- a/game/scenary/foliage.h +++ b/game/scenary/foliage.h @@ -17,7 +17,12 @@ class Foliage : public Asset, public Renderable, public StdTypeDefs { glVertexArray instancePointVAO; public: - using LocationVertex = std::pair; + struct LocationVertex { + glm::mat3 rotation; + float yaw; + GlobalPosition3D position; + }; + mutable InstanceVertices 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 b39c28b..2006225 100644 --- a/game/scenary/plant.cpp +++ b/game/scenary/plant.cpp @@ -2,6 +2,7 @@ #include "location.h" Plant::Plant(std::shared_ptr type, const Location & position) : - type {std::move(type)}, location {this->type->instances.acquire(position.getRotationTransform(), position.pos)} + type {std::move(type)}, + location {this->type->instances.acquire(position.getRotationTransform(), position.rot.y, position.pos)} { } -- cgit v1.2.3