mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 01:22:59 +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)) {
|
||||
model->setTranslation(jointPosition + jointRotation * attachment.translation * getUniformScale());
|
||||
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(true);
|
||||
model->simulate(deltaTime);
|
||||
|
|
|
@ -716,6 +716,11 @@ Extents Model::getBindExtents() const {
|
|||
return scaledExtents;
|
||||
}
|
||||
|
||||
glm::vec3 Model::getNaturalDimensions() const {
|
||||
Extents modelMeshExtents = getUnscaledMeshExtents();
|
||||
return modelMeshExtents.maximum - modelMeshExtents.minimum;
|
||||
}
|
||||
|
||||
Extents Model::getMeshExtents() const {
|
||||
if (!isActive()) {
|
||||
return Extents();
|
||||
|
@ -939,8 +944,8 @@ void Blender::run() {
|
|||
Q_ARG(const QVector<glm::vec3>&, normals));
|
||||
}
|
||||
|
||||
void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions) {
|
||||
if (_scaleToFit != scaleToFit || _scaleToFitDimensions != dimensions) {
|
||||
void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions, bool forceRescale) {
|
||||
if (forceRescale || _scaleToFit != scaleToFit || _scaleToFitDimensions != dimensions) {
|
||||
_scaleToFit = scaleToFit;
|
||||
_scaleToFitDimensions = dimensions;
|
||||
_scaledToFit = false; // force rescaling
|
||||
|
|
|
@ -122,8 +122,6 @@ public:
|
|||
void init();
|
||||
void reset();
|
||||
|
||||
void setScaleToFit(bool scaleToFit, const glm::vec3& dimensions);
|
||||
|
||||
void setSnapModelToRegistrationPoint(bool snapModelToRegistrationPoint, const glm::vec3& registrationPoint);
|
||||
bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; }
|
||||
|
||||
|
@ -164,6 +162,7 @@ public:
|
|||
const glm::vec3& getOffset() const { return _offset; }
|
||||
|
||||
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
|
||||
|
||||
void setSnapModelToCenter(bool snapModelToCenter) {
|
||||
|
@ -209,6 +208,8 @@ public:
|
|||
const glm::vec3& getTranslation() const { return _translation; }
|
||||
const glm::quat& getRotation() const { return _rotation; }
|
||||
|
||||
glm::vec3 getNaturalDimensions() const;
|
||||
|
||||
Transform getTransform() const;
|
||||
|
||||
void setScale(const glm::vec3& scale);
|
||||
|
|
Loading…
Reference in a new issue