mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:07:07 +02:00
fixed text entity
This commit is contained in:
parent
568ba6f777
commit
694c272424
2 changed files with 17 additions and 14 deletions
|
@ -67,35 +67,39 @@ bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
|
||||||
|
|
||||||
void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
||||||
void* key = (void*)this;
|
void* key = (void*)this;
|
||||||
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () {
|
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] () {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
auto entity = getEntity();
|
_dimensions = entity->getScaledDimensions();
|
||||||
_position = entity->getWorldPosition();
|
|
||||||
updateModelTransform();
|
updateModelTransform();
|
||||||
|
_renderTransform = getModelTransform();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||||
_textColor = toGlm(entity->getTextColorX());
|
_textColor = toGlm(entity->getTextColorX());
|
||||||
_backgroundColor = toGlm(entity->getBackgroundColorX());
|
_backgroundColor = toGlm(entity->getBackgroundColorX());
|
||||||
_dimensions = entity->getScaledDimensions();
|
_faceCamera = entity->getFaceCamera();
|
||||||
_faceCamera = entity->getFaceCamera();
|
_lineHeight = entity->getLineHeight();
|
||||||
_lineHeight = entity->getLineHeight();
|
_text = entity->getText();
|
||||||
_text = entity->getText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextEntityRenderer::doRender(RenderArgs* args) {
|
void TextEntityRenderer::doRender(RenderArgs* args) {
|
||||||
PerformanceTimer perfTimer("RenderableTextEntityItem::render");
|
PerformanceTimer perfTimer("RenderableTextEntityItem::render");
|
||||||
|
|
||||||
|
Transform modelTransform;
|
||||||
|
glm::vec3 dimensions;
|
||||||
|
withReadLock([&] {
|
||||||
|
modelTransform = _renderTransform;
|
||||||
|
dimensions = _dimensions;
|
||||||
|
});
|
||||||
static const float SLIGHTLY_BEHIND = -0.005f;
|
static const float SLIGHTLY_BEHIND = -0.005f;
|
||||||
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
||||||
bool transparent = fadeRatio < 1.0f;
|
bool transparent = fadeRatio < 1.0f;
|
||||||
glm::vec4 textColor = glm::vec4(_textColor, fadeRatio);
|
glm::vec4 textColor = glm::vec4(_textColor, fadeRatio);
|
||||||
glm::vec4 backgroundColor = glm::vec4(_backgroundColor, fadeRatio);
|
glm::vec4 backgroundColor = glm::vec4(_backgroundColor, fadeRatio);
|
||||||
const glm::vec3& dimensions = _dimensions;
|
|
||||||
|
|
||||||
// Render background
|
// Render background
|
||||||
glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, SLIGHTLY_BEHIND);
|
glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, SLIGHTLY_BEHIND);
|
||||||
glm::vec3 maxCorner = glm::vec3(dimensions.x, 0.0f, SLIGHTLY_BEHIND);
|
glm::vec3 maxCorner = glm::vec3(dimensions.x, 0.0f, SLIGHTLY_BEHIND);
|
||||||
|
@ -105,7 +109,6 @@ void TextEntityRenderer::doRender(RenderArgs* args) {
|
||||||
Q_ASSERT(args->_batch);
|
Q_ASSERT(args->_batch);
|
||||||
gpu::Batch& batch = *args->_batch;
|
gpu::Batch& batch = *args->_batch;
|
||||||
|
|
||||||
const auto& modelTransform = getModelTransform();
|
|
||||||
auto transformToTopLeft = modelTransform;
|
auto transformToTopLeft = modelTransform;
|
||||||
if (_faceCamera) {
|
if (_faceCamera) {
|
||||||
//rotate about vertical to face the camera
|
//rotate about vertical to face the camera
|
||||||
|
|
|
@ -35,7 +35,7 @@ private:
|
||||||
bool _faceCamera;
|
bool _faceCamera;
|
||||||
glm::vec3 _dimensions;
|
glm::vec3 _dimensions;
|
||||||
glm::vec3 _textColor;
|
glm::vec3 _textColor;
|
||||||
glm::vec3 _position;
|
Transform _renderTransform;
|
||||||
glm::vec3 _backgroundColor;
|
glm::vec3 _backgroundColor;
|
||||||
QString _text;
|
QString _text;
|
||||||
float _lineHeight;
|
float _lineHeight;
|
||||||
|
|
Loading…
Reference in a new issue