mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 19:13:38 +02:00
add way to enable Model for collisions
This commit is contained in:
parent
6d27987226
commit
7530f8ec1e
2 changed files with 18 additions and 2 deletions
|
@ -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<JointState> 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;
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
|
||||
void setBlendshapeCoefficients(const QVector<float>& coefficients) { _blendshapeCoefficients = coefficients; }
|
||||
const QVector<float>& 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<JointState> _jointStates;
|
||||
|
||||
bool _shapesAreDirty;
|
||||
bool _enableCollisionShapes; /// build collision shapes for joints
|
||||
QVector<Shape*> _jointShapes;
|
||||
|
||||
float _boundingRadius;
|
||||
|
|
Loading…
Reference in a new issue