mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-30 16:50:15 +02:00
Merge pull request #8238 from hyperlogic/bug-fix/jumbo-fish
Support for scale property on model overlays
This commit is contained in:
commit
e18d664204
5 changed files with 58 additions and 36 deletions
|
@ -19,8 +19,7 @@ QString const ModelOverlay::TYPE = "model";
|
||||||
|
|
||||||
ModelOverlay::ModelOverlay()
|
ModelOverlay::ModelOverlay()
|
||||||
: _model(std::make_shared<Model>(std::make_shared<Rig>())),
|
: _model(std::make_shared<Model>(std::make_shared<Rig>())),
|
||||||
_modelTextures(QVariantMap()),
|
_modelTextures(QVariantMap())
|
||||||
_updateModel(false)
|
|
||||||
{
|
{
|
||||||
_model->init();
|
_model->init();
|
||||||
_isLoaded = false;
|
_isLoaded = false;
|
||||||
|
@ -44,7 +43,11 @@ void ModelOverlay::update(float deltatime) {
|
||||||
if (_updateModel) {
|
if (_updateModel) {
|
||||||
_updateModel = false;
|
_updateModel = false;
|
||||||
_model->setSnapModelToCenter(true);
|
_model->setSnapModelToCenter(true);
|
||||||
_model->setScaleToFit(true, getDimensions());
|
if (_scaleToFit) {
|
||||||
|
_model->setScaleToFit(true, getScale() * getDimensions());
|
||||||
|
} else {
|
||||||
|
_model->setScale(getScale());
|
||||||
|
}
|
||||||
_model->setRotation(getRotation());
|
_model->setRotation(getRotation());
|
||||||
_model->setTranslation(getPosition());
|
_model->setTranslation(getPosition());
|
||||||
_model->setURL(_url);
|
_model->setURL(_url);
|
||||||
|
@ -84,16 +87,31 @@ void ModelOverlay::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelOverlay::setProperties(const QVariantMap& properties) {
|
void ModelOverlay::setProperties(const QVariantMap& properties) {
|
||||||
auto position = getPosition();
|
auto origPosition = getPosition();
|
||||||
auto rotation = getRotation();
|
auto origRotation = getRotation();
|
||||||
|
auto origDimensions = getDimensions();
|
||||||
|
auto origScale = getScale();
|
||||||
|
|
||||||
Volume3DOverlay::setProperties(properties);
|
Base3DOverlay::setProperties(properties);
|
||||||
|
|
||||||
if (position != getPosition() || rotation != getRotation()) {
|
auto scale = properties["scale"];
|
||||||
_updateModel = true;
|
if (scale.isValid()) {
|
||||||
|
setScale(vec3FromVariant(scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto dimensions = properties["dimensions"];
|
||||||
|
if (dimensions.isValid()) {
|
||||||
|
_scaleToFit = true;
|
||||||
|
setDimensions(vec3FromVariant(dimensions));
|
||||||
|
} else if (scale.isValid()) {
|
||||||
|
// if "scale" property is set but "dimentions" is not.
|
||||||
|
// do NOT scale to fit.
|
||||||
|
_scaleToFit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (origPosition != getPosition() || origRotation != getRotation() || origDimensions != getDimensions() || origScale != getScale()) {
|
||||||
_updateModel = true;
|
_updateModel = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto urlValue = properties["url"];
|
auto urlValue = properties["url"];
|
||||||
if (urlValue.isValid() && urlValue.canConvert<QString>()) {
|
if (urlValue.isValid() && urlValue.canConvert<QString>()) {
|
||||||
|
@ -123,8 +141,11 @@ QVariant ModelOverlay::getProperty(const QString& property) {
|
||||||
if (property == "url") {
|
if (property == "url") {
|
||||||
return _url.toString();
|
return _url.toString();
|
||||||
}
|
}
|
||||||
if (property == "dimensions" || property == "scale" || property == "size") {
|
if (property == "dimensions" || property == "size") {
|
||||||
return vec3toVariant(_model->getScaleToFitDimensions());
|
return vec3toVariant(getDimensions());
|
||||||
|
}
|
||||||
|
if (property == "scale") {
|
||||||
|
return vec3toVariant(getScale());
|
||||||
}
|
}
|
||||||
if (property == "textures") {
|
if (property == "textures") {
|
||||||
if (_modelTextures.size() > 0) {
|
if (_modelTextures.size() > 0) {
|
||||||
|
|
|
@ -45,7 +45,8 @@ private:
|
||||||
QVariantMap _modelTextures;
|
QVariantMap _modelTextures;
|
||||||
|
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
bool _updateModel;
|
bool _updateModel = { false };
|
||||||
|
bool _scaleToFit = { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ModelOverlay_h
|
#endif // hifi_ModelOverlay_h
|
||||||
|
|
|
@ -31,7 +31,7 @@ void Volume3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
|
|
||||||
auto dimensions = properties["dimensions"];
|
auto dimensions = properties["dimensions"];
|
||||||
|
|
||||||
// if "dimensions" property was not there, check to see if they included aliases: scale
|
// if "dimensions" property was not there, check to see if they included aliases: scale, size
|
||||||
if (!dimensions.isValid()) {
|
if (!dimensions.isValid()) {
|
||||||
dimensions = properties["scale"];
|
dimensions = properties["scale"];
|
||||||
if (!dimensions.isValid()) {
|
if (!dimensions.isValid()) {
|
||||||
|
|
Loading…
Reference in a new issue