refactor WorldRenderer
This commit is contained in:
parent
f9f4d2037f
commit
e9163f4228
@ -216,15 +216,20 @@ void WorldRenderer::renderLevel(
|
||||
const Camera& camera,
|
||||
const EngineSettings& settings,
|
||||
float delta,
|
||||
bool pause
|
||||
bool pause,
|
||||
bool hudVisible
|
||||
) {
|
||||
auto assets = engine->getAssets();
|
||||
const auto& assets = *engine->getAssets();
|
||||
|
||||
texts->renderTexts(
|
||||
*batch3d, ctx, assets, camera, settings, hudVisible, false
|
||||
);
|
||||
|
||||
bool culling = engine->getSettings().graphics.frustumCulling.get();
|
||||
float fogFactor =
|
||||
15.0f / static_cast<float>(settings.chunks.loadDistance.get() - 2);
|
||||
|
||||
auto& entityShader = assets->require<Shader>("entity");
|
||||
auto& entityShader = assets.require<Shader>("entity");
|
||||
setupWorldShader(entityShader, camera, settings, fogFactor);
|
||||
skybox->bind();
|
||||
|
||||
@ -238,7 +243,7 @@ void WorldRenderer::renderLevel(
|
||||
particles->render(camera, delta * !pause);
|
||||
modelBatch->render();
|
||||
|
||||
auto& shader = assets->require<Shader>("main");
|
||||
auto& shader = assets.require<Shader>("main");
|
||||
setupWorldShader(shader, camera, settings, fogFactor);
|
||||
|
||||
drawChunks(level->chunks.get(), camera, shader);
|
||||
@ -388,16 +393,12 @@ void WorldRenderer::draw(
|
||||
|
||||
// Drawing background sky plane
|
||||
skybox->draw(pctx, camera, assets, worldInfo.daytime, worldInfo.fog);
|
||||
|
||||
|
||||
/* Actually world render with depth buffer on */ {
|
||||
DrawContext ctx = wctx.sub();
|
||||
ctx.setDepthTest(true);
|
||||
ctx.setCullFace(true);
|
||||
texts->renderTexts(
|
||||
*batch3d, ctx, assets, camera, settings, hudVisible, false
|
||||
);
|
||||
renderLevel(ctx, camera, settings, delta, pause);
|
||||
renderLevel(ctx, camera, settings, delta, pause, hudVisible);
|
||||
// Debug lines
|
||||
if (hudVisible) {
|
||||
if (player->debug) {
|
||||
|
||||
@ -112,7 +112,8 @@ public:
|
||||
const Camera& camera,
|
||||
const EngineSettings& settings,
|
||||
float delta,
|
||||
bool pause
|
||||
bool pause,
|
||||
bool hudVisible
|
||||
);
|
||||
|
||||
void clear();
|
||||
|
||||
@ -550,7 +550,7 @@ void Entities::renderDebug(
|
||||
}
|
||||
|
||||
void Entities::render(
|
||||
Assets* assets,
|
||||
const Assets& assets,
|
||||
ModelBatch& batch,
|
||||
const Frustum* frustum,
|
||||
float delta,
|
||||
|
||||
@ -194,7 +194,7 @@ public:
|
||||
LineBatch& batch, const Frustum* frustum, const DrawContext& ctx
|
||||
);
|
||||
void render(
|
||||
Assets* assets,
|
||||
const Assets& assets,
|
||||
ModelBatch& batch,
|
||||
const Frustum* frustum,
|
||||
float delta,
|
||||
|
||||
@ -12,9 +12,9 @@
|
||||
|
||||
using namespace rigging;
|
||||
|
||||
void ModelReference::refresh(const Assets* assets) {
|
||||
void ModelReference::refresh(const Assets& assets) {
|
||||
if (updateFlag) {
|
||||
model = assets->get<model::Model>(name);
|
||||
model = assets.get<model::Model>(name);
|
||||
updateFlag = false;
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,7 @@ void SkeletonConfig::update(Skeleton& skeleton, glm::mat4 matrix) const {
|
||||
}
|
||||
|
||||
void SkeletonConfig::render(
|
||||
Assets* assets,
|
||||
const Assets& assets,
|
||||
ModelBatch& batch,
|
||||
Skeleton& skeleton,
|
||||
const glm::mat4& matrix
|
||||
|
||||
@ -32,7 +32,7 @@ namespace rigging {
|
||||
model::Model* model;
|
||||
bool updateFlag;
|
||||
|
||||
void refresh(const Assets* assets);
|
||||
void refresh(const Assets& assets);
|
||||
};
|
||||
|
||||
class Bone {
|
||||
@ -111,7 +111,7 @@ namespace rigging {
|
||||
|
||||
void update(Skeleton& skeleton, glm::mat4 matrix) const;
|
||||
void render(
|
||||
Assets* assets,
|
||||
const Assets& assets,
|
||||
ModelBatch& batch,
|
||||
Skeleton& skeleton,
|
||||
const glm::mat4& matrix
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user