add 'xray_opacity' NotePreset property
This commit is contained in:
@@ -16,12 +16,13 @@ TextsRenderer::TextsRenderer(
|
||||
: batch(batch), assets(assets), frustum(frustum) {
|
||||
}
|
||||
|
||||
void TextsRenderer::renderText(
|
||||
void TextsRenderer::renderNote(
|
||||
const TextNote& note,
|
||||
const DrawContext& context,
|
||||
const Camera& camera,
|
||||
const EngineSettings& settings,
|
||||
bool hudVisible
|
||||
bool hudVisible,
|
||||
bool frontLayer
|
||||
) {
|
||||
const auto& text = note.getText();
|
||||
const auto& preset = note.getPreset();
|
||||
@@ -31,12 +32,18 @@ void TextsRenderer::renderText(
|
||||
util::sqr(preset.renderDistance / camera.zoom)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Projected notes are displayed on the front layer only
|
||||
if (preset.displayMode == NoteDisplayMode::PROJECTED) {
|
||||
return;
|
||||
}
|
||||
auto& font = assets.require<Font>("normal");
|
||||
float opacity = 1.0f;
|
||||
if (frontLayer) {
|
||||
if (preset.xrayOpacity <= 0.0001f) {
|
||||
return;
|
||||
}
|
||||
opacity = preset.xrayOpacity;
|
||||
}
|
||||
const auto& font = assets.require<Font>("normal");
|
||||
|
||||
glm::vec3 xvec {1, 0, 0};
|
||||
glm::vec3 yvec {0, 1, 0};
|
||||
@@ -53,15 +60,14 @@ void TextsRenderer::renderText(
|
||||
yvec = camera.up;
|
||||
}
|
||||
}
|
||||
|
||||
if (preset.displayMode != NoteDisplayMode::PROJECTED) {
|
||||
if (!frustum.isBoxVisible(pos - xvec * (width * 0.5f),
|
||||
pos + xvec * (width * 0.5f))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
batch.setColor(preset.color);
|
||||
auto color = preset.color;
|
||||
batch.setColor(glm::vec4(color.r, color.g, color.b, color.a * opacity));
|
||||
font.draw(
|
||||
batch,
|
||||
text,
|
||||
@@ -71,7 +77,7 @@ void TextsRenderer::renderText(
|
||||
);
|
||||
}
|
||||
|
||||
void TextsRenderer::renderTexts(
|
||||
void TextsRenderer::render(
|
||||
const DrawContext& context,
|
||||
const Camera& camera,
|
||||
const EngineSettings& settings,
|
||||
@@ -85,7 +91,7 @@ void TextsRenderer::renderTexts(
|
||||
shader.uniformMatrix("u_apply", glm::mat4(1.0f));
|
||||
batch.begin();
|
||||
for (const auto& [id, note] : notes) {
|
||||
renderText(*note, context, camera, settings, hudVisible);
|
||||
renderNote(*note, context, camera, settings, hudVisible, frontLayer);
|
||||
}
|
||||
batch.flush();
|
||||
}
|
||||
|
||||
@@ -21,17 +21,18 @@ class TextsRenderer {
|
||||
std::unordered_map<u64id_t, std::unique_ptr<TextNote>> notes;
|
||||
u64id_t nextNote = 1;
|
||||
|
||||
void renderText(
|
||||
void renderNote(
|
||||
const TextNote& note,
|
||||
const DrawContext& context,
|
||||
const Camera& camera,
|
||||
const EngineSettings& settings,
|
||||
bool hudVisible
|
||||
bool hudVisible,
|
||||
bool frontLayer
|
||||
);
|
||||
public:
|
||||
TextsRenderer(Batch3D& batch, const Assets& assets, const Frustum& frustum);
|
||||
|
||||
void renderTexts(
|
||||
void render(
|
||||
const DrawContext& context,
|
||||
const Camera& camera,
|
||||
const EngineSettings& settings,
|
||||
|
||||
@@ -139,7 +139,7 @@ void WorldRenderer::renderLevel(
|
||||
bool pause,
|
||||
bool hudVisible
|
||||
) {
|
||||
texts->renderTexts(ctx, camera, settings, hudVisible, false);
|
||||
texts->render(ctx, camera, settings, hudVisible, false);
|
||||
|
||||
bool culling = engine->getSettings().graphics.frustumCulling.get();
|
||||
float fogFactor =
|
||||
@@ -332,6 +332,10 @@ void WorldRenderer::draw(
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
DrawContext ctx = wctx.sub();
|
||||
texts->render(ctx, camera, settings, hudVisible, true);
|
||||
}
|
||||
renderBlockOverlay(wctx);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user