mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:02:55 +02:00
Add gettable naturalPosition property for model entities
This commit is contained in:
parent
fc80e427b9
commit
67760fad79
3 changed files with 14 additions and 2 deletions
|
@ -114,7 +114,8 @@ _glowLevelChanged(false),
|
||||||
_localRenderAlphaChanged(false),
|
_localRenderAlphaChanged(false),
|
||||||
|
|
||||||
_defaultSettings(true),
|
_defaultSettings(true),
|
||||||
_naturalDimensions(1.0f, 1.0f, 1.0f)
|
_naturalDimensions(1.0f, 1.0f, 1.0f),
|
||||||
|
_naturalPosition(0.0f, 0.0f, 0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +129,11 @@ void EntityItemProperties::setSittingPoints(const QVector<SittingPoint>& sitting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityItemProperties::setNaturalPosition(const glm::vec3& min, const glm::vec3& max) {
|
||||||
|
glm::vec3 radius = (max - min) / 2.0f;
|
||||||
|
_naturalPosition = max - radius;
|
||||||
|
}
|
||||||
|
|
||||||
bool EntityItemProperties::animationSettingsChanged() const {
|
bool EntityItemProperties::animationSettingsChanged() const {
|
||||||
return _animationSettingsChanged;
|
return _animationSettingsChanged;
|
||||||
}
|
}
|
||||||
|
@ -378,6 +384,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(dimensions);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(dimensions);
|
||||||
if (!skipDefaults) {
|
if (!skipDefaults) {
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(naturalDimensions); // gettable, but not settable
|
COPY_PROPERTY_TO_QSCRIPTVALUE(naturalDimensions); // gettable, but not settable
|
||||||
|
COPY_PROPERTY_TO_QSCRIPTVALUE(naturalPosition);
|
||||||
}
|
}
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(rotation);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(rotation);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(velocity);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(velocity);
|
||||||
|
|
|
@ -193,6 +193,9 @@ public:
|
||||||
const glm::vec3& getNaturalDimensions() const { return _naturalDimensions; }
|
const glm::vec3& getNaturalDimensions() const { return _naturalDimensions; }
|
||||||
void setNaturalDimensions(const glm::vec3& value) { _naturalDimensions = value; }
|
void setNaturalDimensions(const glm::vec3& value) { _naturalDimensions = value; }
|
||||||
|
|
||||||
|
const glm::vec3& getNaturalPosition() const { return _naturalPosition; }
|
||||||
|
void setNaturalPosition(const glm::vec3& min, const glm::vec3& max);
|
||||||
|
|
||||||
const QStringList& getTextureNames() const { return _textureNames; }
|
const QStringList& getTextureNames() const { return _textureNames; }
|
||||||
void setTextureNames(const QStringList& value) { _textureNames = value; }
|
void setTextureNames(const QStringList& value) { _textureNames = value; }
|
||||||
|
|
||||||
|
@ -232,6 +235,7 @@ private:
|
||||||
QVector<SittingPoint> _sittingPoints;
|
QVector<SittingPoint> _sittingPoints;
|
||||||
QStringList _textureNames;
|
QStringList _textureNames;
|
||||||
glm::vec3 _naturalDimensions;
|
glm::vec3 _naturalDimensions;
|
||||||
|
glm::vec3 _naturalPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(EntityItemProperties);
|
Q_DECLARE_METATYPE(EntityItemProperties);
|
||||||
|
|
|
@ -118,6 +118,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit
|
||||||
results.setSittingPoints(geometry->sittingPoints);
|
results.setSittingPoints(geometry->sittingPoints);
|
||||||
Extents meshExtents = geometry->getUnscaledMeshExtents();
|
Extents meshExtents = geometry->getUnscaledMeshExtents();
|
||||||
results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum);
|
results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum);
|
||||||
|
results.setNaturalPosition(meshExtents.minimum, meshExtents.maximum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue