mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge pull request #7161 from zzmp/fix/overlay-model-scale
Use proper getter for model overlay scaling
This commit is contained in:
commit
3df5d0abad
3 changed files with 23 additions and 22 deletions
|
@ -45,7 +45,7 @@ void ModelOverlay::update(float deltatime) {
|
||||||
_updateModel = false;
|
_updateModel = false;
|
||||||
|
|
||||||
_model.setSnapModelToCenter(true);
|
_model.setSnapModelToCenter(true);
|
||||||
_model.setScale(getScale());
|
_model.setScale(getDimensions());
|
||||||
_model.setRotation(getRotation());
|
_model.setRotation(getRotation());
|
||||||
_model.setTranslation(getPosition());
|
_model.setTranslation(getPosition());
|
||||||
_model.setURL(_url);
|
_model.setURL(_url);
|
||||||
|
@ -82,22 +82,6 @@ void ModelOverlay::render(RenderArgs* args) {
|
||||||
if (!_visible) {
|
if (!_visible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (_model.isActive()) {
|
|
||||||
if (_model.isRenderable()) {
|
|
||||||
float glowLevel = getGlowLevel();
|
|
||||||
Glower* glower = NULL;
|
|
||||||
if (glowLevel > 0.0f) {
|
|
||||||
glower = new Glower(glowLevel);
|
|
||||||
}
|
|
||||||
_model.render(args, getAlpha());
|
|
||||||
if (glower) {
|
|
||||||
delete glower;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelOverlay::setProperties(const QScriptValue &properties) {
|
void ModelOverlay::setProperties(const QScriptValue &properties) {
|
||||||
|
@ -107,10 +91,19 @@ void ModelOverlay::setProperties(const QScriptValue &properties) {
|
||||||
|
|
||||||
Volume3DOverlay::setProperties(properties);
|
Volume3DOverlay::setProperties(properties);
|
||||||
|
|
||||||
if (position != getPosition() || rotation != getRotation() || scale != getDimensions()) {
|
if (position != getPosition() || rotation != getRotation()) {
|
||||||
_model.setScaleToFit(true, getScale());
|
|
||||||
_updateModel = true;
|
_updateModel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scale != getDimensions()) {
|
||||||
|
auto newScale = getDimensions();
|
||||||
|
if (newScale.x <= 0 || newScale.y <= 0 || newScale.z <= 0) {
|
||||||
|
setDimensions(scale);
|
||||||
|
} else {
|
||||||
|
_model.setScaleToFit(true, getDimensions());
|
||||||
|
_updateModel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValue urlValue = properties.property("url");
|
QScriptValue urlValue = properties.property("url");
|
||||||
if (urlValue.isValid() && urlValue.isString()) {
|
if (urlValue.isValid() && urlValue.isString()) {
|
||||||
|
@ -140,7 +133,7 @@ QScriptValue ModelOverlay::getProperty(const QString& property) {
|
||||||
if (property == "url") {
|
if (property == "url") {
|
||||||
return _url.toString();
|
return _url.toString();
|
||||||
}
|
}
|
||||||
if (property == "dimensions") {
|
if (property == "dimensions" || property == "scale" || property == "size") {
|
||||||
return vec3toScriptValue(_scriptEngine, _model.getScaleToFitDimensions());
|
return vec3toScriptValue(_scriptEngine, _model.getScaleToFitDimensions());
|
||||||
}
|
}
|
||||||
if (property == "textures") {
|
if (property == "textures") {
|
||||||
|
|
|
@ -43,7 +43,7 @@ Model::Model(RigPointer rig, QObject* parent) :
|
||||||
_rotation(),
|
_rotation(),
|
||||||
_scale(1.0f, 1.0f, 1.0f),
|
_scale(1.0f, 1.0f, 1.0f),
|
||||||
_scaleToFit(false),
|
_scaleToFit(false),
|
||||||
_scaleToFitDimensions(0.0f),
|
_scaleToFitDimensions(1.0f),
|
||||||
_scaledToFit(false),
|
_scaledToFit(false),
|
||||||
_snapModelToRegistrationPoint(false),
|
_snapModelToRegistrationPoint(false),
|
||||||
_snappedToRegistrationPoint(false),
|
_snappedToRegistrationPoint(false),
|
||||||
|
@ -909,6 +909,14 @@ void Model::setScaleToFit(bool scaleToFit, float largestDimension, bool forceRes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 Model::getScaleToFitDimensions() const {
|
||||||
|
if (_scaleToFitDimensions.y == FAKE_DIMENSION_PLACEHOLDER &&
|
||||||
|
_scaleToFitDimensions.z == FAKE_DIMENSION_PLACEHOLDER) {
|
||||||
|
return glm::vec3(_scaleToFitDimensions.x);
|
||||||
|
}
|
||||||
|
return _scaleToFitDimensions;
|
||||||
|
}
|
||||||
|
|
||||||
void Model::scaleToFit() {
|
void Model::scaleToFit() {
|
||||||
// If our _scaleToFitDimensions.y/z are FAKE_DIMENSION_PLACEHOLDER then it means our
|
// If our _scaleToFitDimensions.y/z are FAKE_DIMENSION_PLACEHOLDER then it means our
|
||||||
// user asked to scale us in a fixed aspect ratio to a single largest dimension, but
|
// user asked to scale us in a fixed aspect ratio to a single largest dimension, but
|
||||||
|
|
|
@ -197,7 +197,7 @@ public:
|
||||||
|
|
||||||
/// enables/disables scale to fit behavior, the model will be automatically scaled to the specified largest dimension
|
/// enables/disables scale to fit behavior, the model will be automatically scaled to the specified largest dimension
|
||||||
bool getIsScaledToFit() const { return _scaledToFit; } /// is model scaled to fit
|
bool getIsScaledToFit() const { return _scaledToFit; } /// is model scaled to fit
|
||||||
const glm::vec3& getScaleToFitDimensions() const { return _scaleToFitDimensions; } /// the dimensions model is scaled to
|
glm::vec3 getScaleToFitDimensions() const; /// the dimensions model is scaled to, including inferred y/z
|
||||||
|
|
||||||
void setCauterizeBones(bool flag) { _cauterizeBones = flag; }
|
void setCauterizeBones(bool flag) { _cauterizeBones = flag; }
|
||||||
bool getCauterizeBones() const { return _cauterizeBones; }
|
bool getCauterizeBones() const { return _cauterizeBones; }
|
||||||
|
|
Loading…
Reference in a new issue