OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
landscape.cpp
Go to the documentation of this file.
1#include "landscape.h"
2
3#include <Tempest/Log>
4#include <cstddef>
5
7#include "gothic.h"
8
9using namespace Tempest;
10
12 :mesh(packed) {
13 auto& device = Resources::device();
14
15 meshletDesc = Resources::ssbo(packed.meshletBounds.data(), packed.meshletBounds.size()*sizeof(packed.meshletBounds[0]));
16 bvhNodes = Resources::ssbo(packed.bvhNodes.data(), packed.bvhNodes.size()*sizeof(packed.bvhNodes[0]));
17 //bvhNodes = Resources::ssbo(packed.bvh8Nodes.data(), packed.bvh8Nodes.size()*sizeof(packed.bvh8Nodes[0]));
18
19 blocks.reserve(packed.subMeshes.size());
20 for(size_t i=0; i<packed.subMeshes.size(); ++i) {
21 auto& sub = packed.subMeshes[i];
22 auto id = uint32_t(sub.iboOffset/PackedMesh::MaxInd);
23 auto material = Resources::loadMaterial(sub.material,true);
24
25 if(material.alpha==Material::AdditiveLight || sub.iboLength==0) {
26 continue;
27 }
28
29 if(Gothic::options().doRayQuery) {
30 mesh.sub[i].blas = device.blas(mesh.vbo,mesh.ibo,sub.iboOffset,sub.iboLength);
31 }
32
33 Block b;
34 b.mesh = visual.get(mesh,material,sub.iboOffset,sub.iboLength,&packed.meshletBounds[id],DrawCommands::Landscape);
35 b.mesh.setObjMatrix(Matrix4x4::mkIdentity());
36 blocks.emplace_back(std::move(b));
37 }
38 }
static auto options() -> const Options &
Definition gothic.cpp:496
Landscape(VisualObjects &visual, const PackedMesh &wmesh)
Definition landscape.cpp:11
@ AdditiveLight
Definition material.h:25
std::vector< BVHNode > bvhNodes
Definition packedmesh.h:80
std::vector< Cluster > meshletBounds
Definition packedmesh.h:74
std::vector< SubMesh > subMeshes
Definition packedmesh.h:73
static Tempest::StorageBuffer ssbo(const void *data, size_t size)
Definition resources.h:125
static Material loadMaterial(const zenkit::Material &src, bool enableAlphaTest)
static Tempest::Device & device()
Definition resources.h:83
Tempest::VertexBuffer< Vertex > vbo
Definition staticmesh.h:50
Tempest::IndexBuffer< uint32_t > ibo
Definition staticmesh.h:51
std::vector< SubMesh > sub
Definition staticmesh.h:55
const StaticMesh * mesh() const
Item get(const StaticMesh &mesh, const Material &mat, size_t iboOffset, size_t iboLength, bool staticDraw)