mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 06:33:35 +02:00
base scale attachment on the natural dimensions
This commit is contained in:
parent
207c13c3c3
commit
712aff7ad6
3 changed files with 12 additions and 5 deletions
|
@ -684,7 +684,8 @@ void Avatar::simulateAttachments(float deltaTime) {
|
||||||
_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRotation)) {
|
_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRotation)) {
|
||||||
model->setTranslation(jointPosition + jointRotation * attachment.translation * getUniformScale());
|
model->setTranslation(jointPosition + jointRotation * attachment.translation * getUniformScale());
|
||||||
model->setRotation(jointRotation * attachment.rotation);
|
model->setRotation(jointRotation * attachment.rotation);
|
||||||
model->setScaleToFit(true, getUniformScale() * attachment.scale, true); // hack to force rescale
|
float scale = getUniformScale() * attachment.scale;
|
||||||
|
model->setScaleToFit(true, model->getNaturalDimensions() * scale, true); // hack to force rescale
|
||||||
model->setSnapModelToCenter(false); // hack to force resnap
|
model->setSnapModelToCenter(false); // hack to force resnap
|
||||||
model->setSnapModelToCenter(true);
|
model->setSnapModelToCenter(true);
|
||||||
model->simulate(deltaTime);
|
model->simulate(deltaTime);
|
||||||
|
|
|
@ -716,6 +716,11 @@ Extents Model::getBindExtents() const {
|
||||||
return scaledExtents;
|
return scaledExtents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 Model::getNaturalDimensions() const {
|
||||||
|
Extents modelMeshExtents = getUnscaledMeshExtents();
|
||||||
|
return modelMeshExtents.maximum - modelMeshExtents.minimum;
|
||||||
|
}
|
||||||
|
|
||||||
Extents Model::getMeshExtents() const {
|
Extents Model::getMeshExtents() const {
|
||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
return Extents();
|
return Extents();
|
||||||
|
@ -939,8 +944,8 @@ void Blender::run() {
|
||||||
Q_ARG(const QVector<glm::vec3>&, normals));
|
Q_ARG(const QVector<glm::vec3>&, normals));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions) {
|
void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions, bool forceRescale) {
|
||||||
if (_scaleToFit != scaleToFit || _scaleToFitDimensions != dimensions) {
|
if (forceRescale || _scaleToFit != scaleToFit || _scaleToFitDimensions != dimensions) {
|
||||||
_scaleToFit = scaleToFit;
|
_scaleToFit = scaleToFit;
|
||||||
_scaleToFitDimensions = dimensions;
|
_scaleToFitDimensions = dimensions;
|
||||||
_scaledToFit = false; // force rescaling
|
_scaledToFit = false; // force rescaling
|
||||||
|
|
|
@ -122,8 +122,6 @@ public:
|
||||||
void init();
|
void init();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void setScaleToFit(bool scaleToFit, const glm::vec3& dimensions);
|
|
||||||
|
|
||||||
void setSnapModelToRegistrationPoint(bool snapModelToRegistrationPoint, const glm::vec3& registrationPoint);
|
void setSnapModelToRegistrationPoint(bool snapModelToRegistrationPoint, const glm::vec3& registrationPoint);
|
||||||
bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; }
|
bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; }
|
||||||
|
|
||||||
|
@ -164,6 +162,7 @@ public:
|
||||||
const glm::vec3& getOffset() const { return _offset; }
|
const glm::vec3& getOffset() const { return _offset; }
|
||||||
|
|
||||||
void setScaleToFit(bool scaleToFit, float largestDimension = 0.0f, bool forceRescale = false);
|
void setScaleToFit(bool scaleToFit, float largestDimension = 0.0f, bool forceRescale = false);
|
||||||
|
void setScaleToFit(bool scaleToFit, const glm::vec3& dimensions, bool forceRescale = false);
|
||||||
bool getScaleToFit() const { return _scaleToFit; } /// is scale to fit enabled
|
bool getScaleToFit() const { return _scaleToFit; } /// is scale to fit enabled
|
||||||
|
|
||||||
void setSnapModelToCenter(bool snapModelToCenter) {
|
void setSnapModelToCenter(bool snapModelToCenter) {
|
||||||
|
@ -209,6 +208,8 @@ public:
|
||||||
const glm::vec3& getTranslation() const { return _translation; }
|
const glm::vec3& getTranslation() const { return _translation; }
|
||||||
const glm::quat& getRotation() const { return _rotation; }
|
const glm::quat& getRotation() const { return _rotation; }
|
||||||
|
|
||||||
|
glm::vec3 getNaturalDimensions() const;
|
||||||
|
|
||||||
Transform getTransform() const;
|
Transform getTransform() const;
|
||||||
|
|
||||||
void setScale(const glm::vec3& scale);
|
void setScale(const glm::vec3& scale);
|
||||||
|
|
Loading…
Reference in a new issue