mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 17:39:46 +00:00
cleanup
This commit is contained in:
parent
42f28dd96e
commit
7d3584629f
2 changed files with 36 additions and 32 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
static debug::Logger logger("content-gfx-cache");
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
#include "typedefs.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "maths/UVRegion.hpp"
|
||||
#include "graphics/commons/Model.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
class Content;
|
||||
class Assets;
|
||||
class Atlas;
|
||||
|
|
@ -17,10 +16,39 @@ struct UVRegion;
|
|||
struct Variant;
|
||||
struct GraphicsSettings;
|
||||
|
||||
inline constexpr int GFXC_MAX_VARIANTS = 16;
|
||||
inline constexpr int GFXC_SIDES = 6;
|
||||
|
||||
class ContentGfxCache {
|
||||
static constexpr int GFXC_MAX_VARIANTS = 16;
|
||||
static constexpr int GFXC_SIDES = 6;
|
||||
public:
|
||||
ContentGfxCache(
|
||||
const Content& content,
|
||||
const Assets& assets,
|
||||
const GraphicsSettings& settings
|
||||
);
|
||||
~ContentGfxCache();
|
||||
|
||||
static inline size_t getRegionIndex(
|
||||
blockid_t id, uint8_t variant, int side, bool opaque
|
||||
) {
|
||||
return ((id * GFXC_SIDES + side) * GFXC_MAX_VARIANTS + variant) * 2 +
|
||||
opaque;
|
||||
}
|
||||
|
||||
inline const UVRegion& getRegion(
|
||||
blockid_t id, uint8_t variant, int side, bool dense
|
||||
) const {
|
||||
return sideregions[getRegionIndex(id, variant, side, !dense)];
|
||||
}
|
||||
|
||||
const model::Model& getModel(
|
||||
blockid_t id, uint8_t variant, uint8_t rotation = 0
|
||||
) const;
|
||||
|
||||
void refresh(const Block& block, const Atlas& atlas);
|
||||
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
const Content& content;
|
||||
const Assets& assets;
|
||||
const GraphicsSettings& settings;
|
||||
|
|
@ -42,29 +70,4 @@ class ContentGfxCache {
|
|||
uint8_t variantIndex,
|
||||
const Atlas& atlas
|
||||
);
|
||||
public:
|
||||
ContentGfxCache(
|
||||
const Content& content,
|
||||
const Assets& assets,
|
||||
const GraphicsSettings& settings
|
||||
);
|
||||
~ContentGfxCache();
|
||||
|
||||
static inline size_t getRegionIndex(
|
||||
blockid_t id, uint8_t variant, int side, bool opaque
|
||||
) {
|
||||
return ((id * GFXC_SIDES + side) * GFXC_MAX_VARIANTS + variant) * 2 + opaque;
|
||||
}
|
||||
|
||||
inline const UVRegion& getRegion(blockid_t id, uint8_t variant, int side, bool dense) const {
|
||||
return sideregions[getRegionIndex(id, variant, side, !dense)];
|
||||
}
|
||||
|
||||
const model::Model& getModel(
|
||||
blockid_t id, uint8_t variant, uint8_t rotation = 0
|
||||
) const;
|
||||
|
||||
void refresh(const Block& block, const Atlas& atlas);
|
||||
|
||||
void refresh();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue