diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-27 17:55:30 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-27 17:55:30 +0100 |
commit | 4f34ed9c949785784f0006f971b5fd2bb9508553 (patch) | |
tree | 20f6627a2f441212365d05d04160a5a6a97063e7 /game/scenary | |
parent | Merge remote-tracking branch 'origin/assimp-normals' (diff) | |
parent | Revert "Export mesh size and primitive type" (diff) | |
download | ilt-4f34ed9c949785784f0006f971b5fd2bb9508553.tar.bz2 ilt-4f34ed9c949785784f0006f971b5fd2bb9508553.tar.xz ilt-4f34ed9c949785784f0006f971b5fd2bb9508553.zip |
Merge branch 'instancing-pt2'
Diffstat (limited to 'game/scenary')
-rw-r--r-- | game/scenary/foliage.cpp | 11 | ||||
-rw-r--r-- | game/scenary/plant.cpp | 6 | ||||
-rw-r--r-- | game/scenary/plant.h | 7 |
3 files changed, 12 insertions, 12 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp index 35be051..0913c6e 100644 --- a/game/scenary/foliage.cpp +++ b/game/scenary/foliage.cpp @@ -26,14 +26,15 @@ Foliage::render(const SceneShader & shader) const if (texture) { texture->bind(); } - glBindVertexArray(instanceVAO); - glDrawElementsInstanced( - bodyMesh->type(), bodyMesh->count(), GL_UNSIGNED_INT, nullptr, static_cast<GLsizei>(count)); - glBindVertexArray(0); + bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count)); } } void -Foliage::shadows(const ShadowMapper &) const +Foliage::shadows(const ShadowMapper & mapper) const { + if (const auto count = instances.count()) { + mapper.dynamicPointInst.use(); + bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count)); + } } diff --git a/game/scenary/plant.cpp b/game/scenary/plant.cpp index 678d4a7..2a79807 100644 --- a/game/scenary/plant.cpp +++ b/game/scenary/plant.cpp @@ -1,7 +1,7 @@ #include "plant.h" +#include "location.hpp" -Plant::Plant(std::shared_ptr<const Foliage> type, Location position) : - type {std::move(type)}, - location {this->type->instances.acquire(glm::translate(position.pos) * rotate_ypr(position.rot))} +Plant::Plant(std::shared_ptr<const Foliage> type, const Location & position) : + type {std::move(type)}, location {this->type->instances.acquire(position.getTransform())} { } diff --git a/game/scenary/plant.h b/game/scenary/plant.h index 77c5979..82ab0e5 100644 --- a/game/scenary/plant.h +++ b/game/scenary/plant.h @@ -2,9 +2,8 @@ #include "foliage.h" #include "game/worldobject.h" -#include "location.hpp" -#include "maths.h" -#include <glm/gtx/transform.hpp> + +class Location; class Plant : public WorldObject { std::shared_ptr<const Foliage> type; @@ -16,5 +15,5 @@ class Plant : public WorldObject { } public: - Plant(std::shared_ptr<const Foliage> type, Location position); + Plant(std::shared_ptr<const Foliage> type, const Location & position); }; |