mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 09:09:53 +02:00
collisions and dimensions seem to be working
This commit is contained in:
parent
ae7a46fbca
commit
9142b7123d
3 changed files with 23 additions and 20 deletions
|
@ -183,12 +183,10 @@ void RenderableModelEntityItem::updateModelBounds() {
|
||||||
bool overridingModelTransform = model->isOverridingModelTransformAndOffset();
|
bool overridingModelTransform = model->isOverridingModelTransformAndOffset();
|
||||||
glm::vec3 scaledDimensions = getScaledDimensions();
|
glm::vec3 scaledDimensions = getScaledDimensions();
|
||||||
glm::vec3 registrationPoint = getRegistrationPoint();
|
glm::vec3 registrationPoint = getRegistrationPoint();
|
||||||
QString modelURL = getModelURL();
|
|
||||||
if (!overridingModelTransform &&
|
if (!overridingModelTransform &&
|
||||||
(model->getScaleToFitDimensions() != scaledDimensions ||
|
(model->getScaleToFitDimensions() != scaledDimensions ||
|
||||||
model->getRegistrationPoint() != registrationPoint ||
|
model->getRegistrationPoint() != registrationPoint ||
|
||||||
model->getURL() != modelURL ||
|
!model->getIsScaledToFit() || _needsToRescaleModel)) {
|
||||||
!model->getIsScaledToFit())) {
|
|
||||||
// The machinery for updateModelBounds will give existing models the opportunity to fix their
|
// The machinery for updateModelBounds will give existing models the opportunity to fix their
|
||||||
// translation/rotation/scale/registration. The first two are straightforward, but the latter two
|
// translation/rotation/scale/registration. The first two are straightforward, but the latter two
|
||||||
// have guards to make sure they don't happen after they've already been set. Here we reset those guards.
|
// have guards to make sure they don't happen after they've already been set. Here we reset those guards.
|
||||||
|
@ -201,6 +199,7 @@ void RenderableModelEntityItem::updateModelBounds() {
|
||||||
model->setSnapModelToRegistrationPoint(true, registrationPoint);
|
model->setSnapModelToRegistrationPoint(true, registrationPoint);
|
||||||
updateRenderItems = true;
|
updateRenderItems = true;
|
||||||
model->scaleToFit();
|
model->scaleToFit();
|
||||||
|
_needsToRescaleModel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
|
@ -718,7 +717,7 @@ void RenderableModelEntityItem::setJointMap(std::vector<int> jointMap) {
|
||||||
int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) {
|
int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) {
|
||||||
int result = -1;
|
int result = -1;
|
||||||
int mapSize = (int) _jointMap.size();
|
int mapSize = (int) _jointMap.size();
|
||||||
if (modelJointIndex >=0 && modelJointIndex < mapSize) {
|
if (modelJointIndex >= 0 && modelJointIndex < mapSize) {
|
||||||
result = _jointMap[modelJointIndex];
|
result = _jointMap[modelJointIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,18 +736,20 @@ bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderableModelEntityItem::shouldBePhysical() const {
|
bool RenderableModelEntityItem::shouldBePhysical() const {
|
||||||
auto model = getModel();
|
bool physicalModelLoaded = false;
|
||||||
// If we have a model, make sure it hasn't failed to download.
|
|
||||||
// If it has, we'll report back that we shouldn't be physical so that physics aren't held waiting for us to be ready.
|
|
||||||
ShapeType shapeType = getShapeType();
|
ShapeType shapeType = getShapeType();
|
||||||
if (model) {
|
if (shapeType >= SHAPE_TYPE_SIMPLE_HULL && shapeType <= SHAPE_TYPE_STATIC_MESH) {
|
||||||
if ((shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) && model->didCollisionGeometryRequestFail()) {
|
auto model = getModel();
|
||||||
return false;
|
// If we have a model, make sure it hasn't failed to download.
|
||||||
} else if (shapeType != SHAPE_TYPE_NONE && model->didVisualGeometryRequestFail()) {
|
// If it has, we'll report back that we shouldn't be physical so that physics aren't held waiting for us to be ready.
|
||||||
return false;
|
physicalModelLoaded = model && !model->didVisualGeometryRequestFail();
|
||||||
}
|
} else if (shapeType == SHAPE_TYPE_COMPOUND) {
|
||||||
|
physicalModelLoaded = _collisionGeometryResource && !_collisionGeometryResource->isFailed();
|
||||||
|
} else if (shapeType != SHAPE_TYPE_NONE) {
|
||||||
|
physicalModelLoaded = true;
|
||||||
}
|
}
|
||||||
return !isDead() && shapeType != SHAPE_TYPE_NONE && !isLocalEntity() && QUrl(_modelURL).isValid();
|
|
||||||
|
return physicalModelLoaded && !isDead() && !isLocalEntity() && QUrl(_modelURL).isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int RenderableModelEntityItem::getJointParent(int index) const {
|
int RenderableModelEntityItem::getJointParent(int index) const {
|
||||||
|
@ -1247,6 +1248,8 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
_model->setPrimitiveMode(_primitiveMode, scene);
|
_model->setPrimitiveMode(_primitiveMode, scene);
|
||||||
_model->setCullWithParent(_cullWithParent, scene);
|
_model->setCullWithParent(_cullWithParent, scene);
|
||||||
_model->setRenderWithZones(_renderWithZones, scene);
|
_model->setRenderWithZones(_renderWithZones, scene);
|
||||||
|
entity->locationChanged();
|
||||||
|
entity->dimensionsChanged();
|
||||||
});
|
});
|
||||||
if (didVisualGeometryRequestSucceed) {
|
if (didVisualGeometryRequestSucceed) {
|
||||||
emit DependencyManager::get<scriptable::ModelProviderFactory>()->
|
emit DependencyManager::get<scriptable::ModelProviderFactory>()->
|
||||||
|
@ -1255,6 +1258,7 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
_didLastVisualGeometryRequestSucceed = didVisualGeometryRequestSucceed;
|
_didLastVisualGeometryRequestSucceed = didVisualGeometryRequestSucceed;
|
||||||
entity->_originalTexturesRead = false;
|
entity->_originalTexturesRead = false;
|
||||||
entity->_needsJointSimulation = true;
|
entity->_needsJointSimulation = true;
|
||||||
|
entity->_needsToRescaleModel = true;
|
||||||
emit requestRenderUpdate();
|
emit requestRenderUpdate();
|
||||||
});
|
});
|
||||||
model->setLoadingPriority(EntityTreeRenderer::getEntityLoadingPriority(*entity));
|
model->setLoadingPriority(EntityTreeRenderer::getEntityLoadingPriority(*entity));
|
||||||
|
@ -1288,7 +1292,6 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
|
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<EntityScriptingInterface>().data(), "editEntity",
|
QMetaObject::invokeMethod(DependencyManager::get<EntityScriptingInterface>().data(), "editEntity",
|
||||||
Qt::QueuedConnection, Q_ARG(QUuid, entity->getEntityItemID()), Q_ARG(EntityItemProperties, properties));
|
Qt::QueuedConnection, Q_ARG(QUuid, entity->getEntityItemID()), Q_ARG(EntityItemProperties, properties));
|
||||||
entity->_dimensionsInitialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity->_originalTexturesRead) {
|
if (!entity->_originalTexturesRead) {
|
||||||
|
@ -1340,9 +1343,10 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needsUpdate = false;
|
||||||
if (!_texturesLoaded && model->getGeometry() && model->getGeometry()->areTexturesLoaded()) {
|
if (!_texturesLoaded && model->getGeometry() && model->getGeometry()->areTexturesLoaded()) {
|
||||||
_texturesLoaded = true;
|
_texturesLoaded = true;
|
||||||
model->updateRenderItems();
|
needsUpdate = true;
|
||||||
} else if (!_texturesLoaded) {
|
} else if (!_texturesLoaded) {
|
||||||
emit requestRenderUpdate();
|
emit requestRenderUpdate();
|
||||||
}
|
}
|
||||||
|
@ -1368,13 +1372,13 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
emit requestRenderUpdate();
|
emit requestRenderUpdate();
|
||||||
} else {
|
} else {
|
||||||
_allProceduralMaterialsLoaded = true;
|
_allProceduralMaterialsLoaded = true;
|
||||||
model->setRenderItemsNeedUpdate();
|
needsUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the individual mesh parts of a model finish fading, they will mark their Model as needing updating
|
// When the individual mesh parts of a model finish fading, they will mark their Model as needing updating
|
||||||
// we will watch for that and ask the model to update it's render items
|
// we will watch for that and ask the model to update it's render items
|
||||||
if (model->getRenderItemsNeedUpdate()) {
|
if (needsUpdate || model->getRenderItemsNeedUpdate()) {
|
||||||
model->updateRenderItems();
|
model->updateRenderItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ private:
|
||||||
bool _originalTexturesRead { false };
|
bool _originalTexturesRead { false };
|
||||||
bool _dimensionsInitialized { true };
|
bool _dimensionsInitialized { true };
|
||||||
bool _needsJointSimulation { false };
|
bool _needsJointSimulation { false };
|
||||||
|
bool _needsToRescaleModel { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace render { namespace entities {
|
namespace render { namespace entities {
|
||||||
|
|
|
@ -186,7 +186,6 @@ public:
|
||||||
bool isActive() const { return isLoaded(); }
|
bool isActive() const { return isLoaded(); }
|
||||||
|
|
||||||
bool didVisualGeometryRequestFail() const { return _visualGeometryRequestFailed; }
|
bool didVisualGeometryRequestFail() const { return _visualGeometryRequestFailed; }
|
||||||
bool didCollisionGeometryRequestFail() const { return _collisionGeometryRequestFailed; }
|
|
||||||
|
|
||||||
glm::mat4 getWorldToHFMMatrix() const;
|
glm::mat4 getWorldToHFMMatrix() const;
|
||||||
|
|
||||||
|
@ -477,7 +476,6 @@ protected:
|
||||||
uint32_t _deleteGeometryCounter { 0 };
|
uint32_t _deleteGeometryCounter { 0 };
|
||||||
|
|
||||||
bool _visualGeometryRequestFailed { false };
|
bool _visualGeometryRequestFailed { false };
|
||||||
bool _collisionGeometryRequestFailed { false };
|
|
||||||
|
|
||||||
bool _renderItemsNeedUpdate { false };
|
bool _renderItemsNeedUpdate { false };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue