mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:10:49 +02:00
fixing shape entity
This commit is contained in:
parent
87d26a9d86
commit
568ba6f777
5 changed files with 41 additions and 9 deletions
|
@ -363,6 +363,14 @@ bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityRenderer::updateModelTransform() {
|
||||||
|
bool success = false;
|
||||||
|
auto newModelTransform = _entity->getTransformToCenter(success);
|
||||||
|
if (success) {
|
||||||
|
_modelTransform = newModelTransform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) {
|
void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) {
|
||||||
DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__);
|
DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__);
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
|
@ -419,4 +427,4 @@ void EntityRenderer::addMaterial(graphics::MaterialLayer material, const std::st
|
||||||
void EntityRenderer::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) {
|
void EntityRenderer::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) {
|
||||||
std::lock_guard<std::mutex> lock(_materialsLock);
|
std::lock_guard<std::mutex> lock(_materialsLock);
|
||||||
_materials[parentMaterialName].remove(material);
|
_materials[parentMaterialName].remove(material);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ protected:
|
||||||
virtual void doRender(RenderArgs* args) = 0;
|
virtual void doRender(RenderArgs* args) = 0;
|
||||||
|
|
||||||
bool isFading() const { return _isFading; }
|
bool isFading() const { return _isFading; }
|
||||||
|
void updateModelTransform();
|
||||||
virtual bool isTransparent() const { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; }
|
virtual bool isTransparent() const { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; }
|
||||||
inline bool isValidRenderItem() const { return _renderItemID != Item::INVALID_ITEM_ID; }
|
inline bool isValidRenderItem() const { return _renderItemID != Item::INVALID_ITEM_ID; }
|
||||||
|
|
||||||
|
|
|
@ -97,16 +97,25 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
addMaterial(graphics::MaterialLayer(_material, 0), "0");
|
addMaterial(graphics::MaterialLayer(_material, 0), "0");
|
||||||
|
|
||||||
_shape = entity->getShape();
|
_shape = entity->getShape();
|
||||||
_position = entity->getWorldPosition();
|
});
|
||||||
_dimensions = entity->getScaledDimensions();
|
|
||||||
_orientation = entity->getWorldOrientation();
|
|
||||||
_renderTransform = getModelTransform();
|
|
||||||
|
|
||||||
if (_shape == entity::Sphere) {
|
void* key = (void*)this;
|
||||||
_renderTransform.postScale(SPHERE_ENTITY_SCALE);
|
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () {
|
||||||
}
|
withWriteLock([&] {
|
||||||
|
auto entity = getEntity();
|
||||||
|
_position = entity->getWorldPosition();
|
||||||
|
_dimensions = entity->getScaledDimensions();
|
||||||
|
_orientation = entity->getWorldOrientation();
|
||||||
|
bool success = false;
|
||||||
|
auto newModelTransform = entity->getTransformToCenter(success);
|
||||||
|
_renderTransform = success ? newModelTransform : getModelTransform();
|
||||||
|
|
||||||
_renderTransform.postScale(_dimensions);
|
if (_shape == entity::Sphere) {
|
||||||
|
_renderTransform.postScale(SPHERE_ENTITY_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
_renderTransform.postScale(_dimensions);
|
||||||
|
});;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "GLMHelpers.h"
|
#include "GLMHelpers.h"
|
||||||
|
|
||||||
|
using namespace render;
|
||||||
using namespace render::entities;
|
using namespace render::entities;
|
||||||
|
|
||||||
static const int FIXED_FONT_POINT_SIZE = 40;
|
static const int FIXED_FONT_POINT_SIZE = 40;
|
||||||
|
@ -64,6 +65,17 @@ bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
||||||
|
void* key = (void*)this;
|
||||||
|
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () {
|
||||||
|
withWriteLock([&] {
|
||||||
|
auto entity = getEntity();
|
||||||
|
_position = entity->getWorldPosition();
|
||||||
|
updateModelTransform();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
~TextEntityRenderer();
|
~TextEntityRenderer();
|
||||||
private:
|
private:
|
||||||
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
|
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
|
||||||
|
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
|
||||||
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
|
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
|
||||||
virtual void doRender(RenderArgs* args) override;
|
virtual void doRender(RenderArgs* args) override;
|
||||||
int _geometryID{ 0 };
|
int _geometryID{ 0 };
|
||||||
|
@ -34,6 +35,7 @@ private:
|
||||||
bool _faceCamera;
|
bool _faceCamera;
|
||||||
glm::vec3 _dimensions;
|
glm::vec3 _dimensions;
|
||||||
glm::vec3 _textColor;
|
glm::vec3 _textColor;
|
||||||
|
glm::vec3 _position;
|
||||||
glm::vec3 _backgroundColor;
|
glm::vec3 _backgroundColor;
|
||||||
QString _text;
|
QString _text;
|
||||||
float _lineHeight;
|
float _lineHeight;
|
||||||
|
|
Loading…
Reference in a new issue