mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 18:53:37 +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* key = (void*)this;
|
||||
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () {
|
||||
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] () {
|
||||
withWriteLock([&] {
|
||||
auto entity = getEntity();
|
||||
_position = entity->getWorldPosition();
|
||||
_dimensions = entity->getScaledDimensions();
|
||||
updateModelTransform();
|
||||
_renderTransform = getModelTransform();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||
_textColor = toGlm(entity->getTextColorX());
|
||||
_backgroundColor = toGlm(entity->getBackgroundColorX());
|
||||
_dimensions = entity->getScaledDimensions();
|
||||
_faceCamera = entity->getFaceCamera();
|
||||
_lineHeight = entity->getLineHeight();
|
||||
_text = entity->getText();
|
||||
_textColor = toGlm(entity->getTextColorX());
|
||||
_backgroundColor = toGlm(entity->getBackgroundColorX());
|
||||
_faceCamera = entity->getFaceCamera();
|
||||
_lineHeight = entity->getLineHeight();
|
||||
_text = entity->getText();
|
||||
}
|
||||
|
||||
|
||||
void TextEntityRenderer::doRender(RenderArgs* args) {
|
||||
PerformanceTimer perfTimer("RenderableTextEntityItem::render");
|
||||
|
||||
|
||||
Transform modelTransform;
|
||||
glm::vec3 dimensions;
|
||||
withReadLock([&] {
|
||||
modelTransform = _renderTransform;
|
||||
dimensions = _dimensions;
|
||||
});
|
||||
static const float SLIGHTLY_BEHIND = -0.005f;
|
||||
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
||||
bool transparent = fadeRatio < 1.0f;
|
||||
glm::vec4 textColor = glm::vec4(_textColor, fadeRatio);
|
||||
glm::vec4 backgroundColor = glm::vec4(_backgroundColor, fadeRatio);
|
||||
const glm::vec3& dimensions = _dimensions;
|
||||
|
||||
|
||||
// Render background
|
||||
glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, 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);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
|
||||
const auto& modelTransform = getModelTransform();
|
||||
auto transformToTopLeft = modelTransform;
|
||||
if (_faceCamera) {
|
||||
//rotate about vertical to face the camera
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
bool _faceCamera;
|
||||
glm::vec3 _dimensions;
|
||||
glm::vec3 _textColor;
|
||||
glm::vec3 _position;
|
||||
Transform _renderTransform;
|
||||
glm::vec3 _backgroundColor;
|
||||
QString _text;
|
||||
float _lineHeight;
|
||||
|
|
Loading…
Reference in a new issue