Rise
The Vieneo Province
Loading...
Searching...
No Matches
BuildingDrawBatches.h
Go to the documentation of this file.
1#pragma once
2#include "GeometryBounds.h"
3#include <cstdint>
4#include <limits>
5#include <vector>
6
7// Only adjacent triangles with identical building shader/state inputs merge.
8// The original component list remains intact for physics, lights and animation.
10{
11 unsigned component = 0, first = 0, primitives = 0;
12 short texture = 0;
13 unsigned char type = 0;
15};
16
17inline GeometryBounds& AppendBuildingDrawBatch(std::vector<BuildingDrawBatch>& batches,
18 unsigned component, unsigned first, unsigned primitives, short texture, unsigned char type)
19{
20 // Campaign groups can differ even when adjacent signs share a basemap.
21 if (!batches.empty() && primitives && type != 78 && type != 8 && type != 26)
22 {
23 auto& previous = batches.back();
24 if (previous.primitives && previous.texture == texture && previous.type == type &&
25 uint64_t(previous.first) + uint64_t(previous.primitives) * 3 == first &&
26 uint64_t(previous.primitives) + primitives <= (std::numeric_limits<unsigned>::max)())
27 {
28 previous.primitives += primitives;
29 return previous.bounds;
30 }
31 }
32 batches.push_back({component, first, primitives, texture, type, {}});
33 return batches.back().bounds;
34}
GeometryBounds & AppendBuildingDrawBatch(std::vector< BuildingDrawBatch > &batches, unsigned component, unsigned first, unsigned primitives, short texture, unsigned char type)