dirty physics on useOriginalPivot change, other small fix for compound shapes

This commit is contained in:
HifiExperiments 2021-02-03 17:35:17 -08:00
parent 56fa143ee6
commit ace6bf6c5b
2 changed files with 13 additions and 3 deletions

View file

@ -456,10 +456,11 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
// multiply each point by scale before handing the point-set off to the physics engine.
// also determine the extents of the collision model.
glm::vec3 registrationOffset = dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint());
glm::vec3 offset = model->getSnapModelToRegistrationPoint() ? model->getOffset() : glm::vec3(0.0f);
for (int32_t i = 0; i < pointCollection.size(); i++) {
for (int32_t j = 0; j < pointCollection[i].size(); j++) {
// back compensate for registration so we can apply that offset to the shapeInfo later
pointCollection[i][j] = scaleToFit * (pointCollection[i][j] + model->getOffset()) - registrationOffset;
pointCollection[i][j] = scaleToFit * (pointCollection[i][j] + offset) - registrationOffset;
}
}
shapeInfo.setParams(type, 0.5f * extents, getCompoundShapeURL() + model->getSnapModelToRegistrationPoint());

View file

@ -721,10 +721,19 @@ QVector<float> ModelEntityItem::getBlendshapeCoefficientVector() {
}
void ModelEntityItem::setUseOriginalPivot(bool value) {
bool changed = false;
withWriteLock([&] {
_needsRenderUpdate |= _useOriginalPivot != value;
_useOriginalPivot = value;
if (_useOriginalPivot != value) {
_needsRenderUpdate = true;
_useOriginalPivot = value;
changed = true;
}
});
if (changed) {
markDirtyFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
locationChanged();
}
}
bool ModelEntityItem::getUseOriginalPivot() const {