mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 21:11:50 +00:00
add entity to TextNote
This commit is contained in:
parent
767fa7c7a9
commit
dc29f65fa8
5 changed files with 39 additions and 5 deletions
|
|
@ -10,6 +10,14 @@ void TextNote::setText(std::wstring_view text) {
|
||||||
this->text = text;
|
this->text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextNote::setEntity(entityid_t eid) {
|
||||||
|
this->entity = eid;
|
||||||
|
}
|
||||||
|
|
||||||
|
entityid_t TextNote::getEntity() const {
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
const std::wstring& TextNote::getText() const {
|
const std::wstring& TextNote::getText() const {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "constants.hpp"
|
||||||
#include "presets/NotePreset.hpp"
|
#include "presets/NotePreset.hpp"
|
||||||
|
|
||||||
/// @brief 3D text instance
|
/// @brief 3D text instance
|
||||||
|
|
@ -7,6 +8,7 @@ class TextNote {
|
||||||
std::wstring text;
|
std::wstring text;
|
||||||
NotePreset preset;
|
NotePreset preset;
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
|
entityid_t entity = ENTITY_NONE;
|
||||||
|
|
||||||
glm::vec3 xAxis {1, 0, 0};
|
glm::vec3 xAxis {1, 0, 0};
|
||||||
glm::vec3 yAxis {0, 1, 0};
|
glm::vec3 yAxis {0, 1, 0};
|
||||||
|
|
@ -14,6 +16,8 @@ public:
|
||||||
TextNote(std::wstring text, NotePreset preset, glm::vec3 position);
|
TextNote(std::wstring text, NotePreset preset, glm::vec3 position);
|
||||||
|
|
||||||
void setText(std::wstring_view text);
|
void setText(std::wstring_view text);
|
||||||
|
void setEntity(entityid_t eid);
|
||||||
|
entityid_t getEntity() const;
|
||||||
|
|
||||||
const std::wstring& getText() const;
|
const std::wstring& getText() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,18 @@
|
||||||
#include "graphics/core/Shader.hpp"
|
#include "graphics/core/Shader.hpp"
|
||||||
#include "graphics/core/DrawContext.hpp"
|
#include "graphics/core/DrawContext.hpp"
|
||||||
#include "presets/NotePreset.hpp"
|
#include "presets/NotePreset.hpp"
|
||||||
|
#include "world/Level.hpp"
|
||||||
|
#include "objects/Entities.hpp"
|
||||||
|
#include "objects/Entity.hpp"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
|
|
||||||
TextsRenderer::TextsRenderer(
|
TextsRenderer::TextsRenderer(
|
||||||
Batch3D& batch, const Assets& assets, const Frustum& frustum
|
const Level& level,
|
||||||
|
Batch3D& batch,
|
||||||
|
const Assets& assets,
|
||||||
|
const Frustum& frustum
|
||||||
)
|
)
|
||||||
: batch(batch), assets(assets), frustum(frustum) {
|
: level(level), batch(batch), assets(assets), frustum(frustum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextsRenderer::renderNote(
|
void TextsRenderer::renderNote(
|
||||||
|
|
@ -31,6 +37,13 @@ void TextsRenderer::renderNote(
|
||||||
const auto& preset = note.getPreset();
|
const auto& preset = note.getPreset();
|
||||||
auto pos = note.getPosition();
|
auto pos = note.getPosition();
|
||||||
|
|
||||||
|
entityid_t eid = note.getEntity();
|
||||||
|
if (eid != ENTITY_NONE) {
|
||||||
|
if (auto entity = level.entities->get(eid)) {
|
||||||
|
pos += entity->getTransform().displayPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (util::distance2(pos, camera.position) >
|
if (util::distance2(pos, camera.position) >
|
||||||
util::sqr(preset.renderDistance / camera.zoom)) {
|
util::sqr(preset.renderDistance / camera.zoom)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,10 @@ class Batch3D;
|
||||||
class Frustum;
|
class Frustum;
|
||||||
class TextNote;
|
class TextNote;
|
||||||
struct EngineSettings;
|
struct EngineSettings;
|
||||||
|
class Level;
|
||||||
|
|
||||||
class TextsRenderer {
|
class TextsRenderer {
|
||||||
|
const Level& level;
|
||||||
Batch3D& batch;
|
Batch3D& batch;
|
||||||
const Assets& assets;
|
const Assets& assets;
|
||||||
const Frustum& frustum;
|
const Frustum& frustum;
|
||||||
|
|
@ -31,7 +33,12 @@ class TextsRenderer {
|
||||||
bool projected
|
bool projected
|
||||||
);
|
);
|
||||||
public:
|
public:
|
||||||
TextsRenderer(Batch3D& batch, const Assets& assets, const Frustum& frustum);
|
TextsRenderer(
|
||||||
|
const Level& level,
|
||||||
|
Batch3D& batch,
|
||||||
|
const Assets& assets,
|
||||||
|
const Frustum& frustum
|
||||||
|
);
|
||||||
|
|
||||||
void render(
|
void render(
|
||||||
const DrawContext& context,
|
const DrawContext& context,
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,11 @@ WorldRenderer::WorldRenderer(
|
||||||
assets, level, *player.chunks, &engine.getSettings().graphics
|
assets, level, *player.chunks, &engine.getSettings().graphics
|
||||||
)),
|
)),
|
||||||
particles(std::make_unique<ParticlesRenderer>(
|
particles(std::make_unique<ParticlesRenderer>(
|
||||||
assets, level, *player.chunks, engine.getSettings().graphics
|
assets, level, *player.chunks, engine.getSettings().graphics
|
||||||
|
)),
|
||||||
|
texts(std::make_unique<TextsRenderer>(
|
||||||
|
level, *batch3d, assets, *frustumCulling
|
||||||
)),
|
)),
|
||||||
texts(std::make_unique<TextsRenderer>(*batch3d, assets, *frustumCulling)),
|
|
||||||
blockWraps(std::make_unique<BlockWrapsRenderer>(
|
blockWraps(std::make_unique<BlockWrapsRenderer>(
|
||||||
assets, level.content, *player.chunks
|
assets, level.content, *player.chunks
|
||||||
)) {
|
)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue