mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 12:59:54 +02:00
Fix "good" collision not subdividing OBJ meshes by group
This commit is contained in:
parent
be23d07621
commit
c8cccc5ec7
3 changed files with 27 additions and 8 deletions
|
@ -307,7 +307,7 @@ bool RenderableModelEntityItem::findDetailedParabolaIntersection(const glm::vec3
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::getCollisionGeometryResource() {
|
void RenderableModelEntityItem::getCollisionGeometryResource() {
|
||||||
QUrl hullURL(getCompoundShapeURL());
|
QUrl hullURL(getCollisionShapeURL());
|
||||||
QUrlQuery queryArgs(hullURL);
|
QUrlQuery queryArgs(hullURL);
|
||||||
queryArgs.addQueryItem("collision-hull", "");
|
queryArgs.addQueryItem("collision-hull", "");
|
||||||
hullURL.setQuery(queryArgs);
|
hullURL.setQuery(queryArgs);
|
||||||
|
@ -316,8 +316,9 @@ void RenderableModelEntityItem::getCollisionGeometryResource() {
|
||||||
|
|
||||||
void RenderableModelEntityItem::setShapeType(ShapeType type) {
|
void RenderableModelEntityItem::setShapeType(ShapeType type) {
|
||||||
ModelEntityItem::setShapeType(type);
|
ModelEntityItem::setShapeType(type);
|
||||||
if (getShapeType() == SHAPE_TYPE_COMPOUND) {
|
auto shapeType = getShapeType();
|
||||||
if (!_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
|
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
|
if (!_compoundShapeResource && !getCollisionShapeURL().isEmpty()) {
|
||||||
getCollisionGeometryResource();
|
getCollisionGeometryResource();
|
||||||
}
|
}
|
||||||
} else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
|
} else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
|
||||||
|
@ -344,8 +345,11 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const {
|
||||||
ShapeType type = getShapeType();
|
ShapeType type = getShapeType();
|
||||||
|
|
||||||
auto model = getModel();
|
auto model = getModel();
|
||||||
if (type == SHAPE_TYPE_COMPOUND) {
|
auto shapeType = getShapeType();
|
||||||
if (!model || getCompoundShapeURL().isEmpty()) {
|
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
|
auto shapeURL = getCollisionShapeURL();
|
||||||
|
|
||||||
|
if (!model || shapeURL.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +359,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model->isLoaded()) {
|
if (model->isLoaded()) {
|
||||||
if (!getCompoundShapeURL().isEmpty() && !_compoundShapeResource) {
|
if (!shapeURL.isEmpty() && !_compoundShapeResource) {
|
||||||
const_cast<RenderableModelEntityItem*>(this)->getCollisionGeometryResource();
|
const_cast<RenderableModelEntityItem*>(this)->getCollisionGeometryResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +514,15 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& meshes = model->getGeometry()->getMeshes();
|
std::vector<std::shared_ptr<const graphics::Mesh>> compoundMeshes;
|
||||||
|
if (type == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
|
auto& fbxMeshes = _compoundShapeResource->getFBXGeometry().meshes;
|
||||||
|
compoundMeshes.reserve(fbxMeshes.size());
|
||||||
|
for (auto& fbxMesh : fbxMeshes) {
|
||||||
|
compoundMeshes.push_back(fbxMesh._mesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto& meshes = (type == SHAPE_TYPE_SIMPLE_COMPOUND ? compoundMeshes : model->getGeometry()->getMeshes());
|
||||||
int32_t numMeshes = (int32_t)(meshes.size());
|
int32_t numMeshes = (int32_t)(meshes.size());
|
||||||
|
|
||||||
const int MAX_ALLOWED_MESH_COUNT = 1000;
|
const int MAX_ALLOWED_MESH_COUNT = 1000;
|
||||||
|
@ -744,7 +756,7 @@ bool RenderableModelEntityItem::shouldBePhysical() const {
|
||||||
auto model = getModel();
|
auto model = getModel();
|
||||||
// If we have a model, make sure it hasn't failed to download.
|
// 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.
|
// 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.
|
||||||
if (model && getShapeType() == SHAPE_TYPE_COMPOUND && model->didCollisionGeometryRequestFail()) {
|
if (model && (getShapeType() == SHAPE_TYPE_COMPOUND || getShapeType() == SHAPE_TYPE_SIMPLE_COMPOUND) && model->didCollisionGeometryRequestFail()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (model && getShapeType() != SHAPE_TYPE_NONE && model->didVisualGeometryRequestFail()) {
|
} else if (model && getShapeType() != SHAPE_TYPE_NONE && model->didVisualGeometryRequestFail()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -554,6 +554,10 @@ QString ModelEntityItem::getCompoundShapeURL() const {
|
||||||
return _compoundShapeURL.get();
|
return _compoundShapeURL.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ModelEntityItem::getCollisionShapeURL() const {
|
||||||
|
return getShapeType() == SHAPE_TYPE_COMPOUND ? getCompoundShapeURL() : getModelURL();
|
||||||
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setColor(const rgbColor& value) {
|
void ModelEntityItem::setColor(const rgbColor& value) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
memcpy(_color, value, sizeof(_color));
|
memcpy(_color, value, sizeof(_color));
|
||||||
|
|
|
@ -70,6 +70,9 @@ public:
|
||||||
static const QString DEFAULT_COMPOUND_SHAPE_URL;
|
static const QString DEFAULT_COMPOUND_SHAPE_URL;
|
||||||
QString getCompoundShapeURL() const;
|
QString getCompoundShapeURL() const;
|
||||||
|
|
||||||
|
// Returns the URL used for the collision shape
|
||||||
|
QString getCollisionShapeURL() const;
|
||||||
|
|
||||||
void setColor(const rgbColor& value);
|
void setColor(const rgbColor& value);
|
||||||
void setColor(const xColor& value);
|
void setColor(const xColor& value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue