diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 03e0cac620..6bd04d18cf 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -43,6 +43,7 @@ Model::Model(QObject* parent) : _snappedToCenter(false), _rootIndex(-1), _shapesAreDirty(true), + _enableCollisionShapes(false), _boundingRadius(0.0f), _boundingShape(), _boundingShapeLocalOffset(0.0f), @@ -201,6 +202,17 @@ QVector Model::createJointStates(const FBXGeometry& geometry) { return jointStates; } +void Model::setEnableCollisionShapes(bool enable) { + if (enable != _enableCollisionShapes) { + _enableCollisionShapes = enable; + if (_enableCollisionShapes) { + rebuildShapes(); + } else { + clearShapes(); + } + } +} + void Model::init() { if (!_program.isLinked()) { _program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model.vert"); @@ -568,7 +580,7 @@ bool Model::updateGeometry() { model->setURL(attachment.url); _attachments.append(model); } - if (!_jointShapes.isEmpty()) { + if (_enableCollisionShapes) { rebuildShapes(); } needFullUpdate = true; diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 64868c6751..04c457f265 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -68,6 +68,8 @@ public: void setBlendshapeCoefficients(const QVector& coefficients) { _blendshapeCoefficients = coefficients; } const QVector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } + + void setEnableCollisionShapes(bool enable); bool isActive() const { return _geometry && _geometry->isLoaded(); } @@ -186,8 +188,10 @@ protected: bool _snappedToCenter; /// are we currently snapped to center int _rootIndex; - bool _shapesAreDirty; QVector _jointStates; + + bool _shapesAreDirty; + bool _enableCollisionShapes; /// build collision shapes for joints QVector _jointShapes; float _boundingRadius;