mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-07 10:40:10 +02:00
fixing up simple-compound logic
This commit is contained in:
parent
2e780c34d1
commit
2ece568f09
4 changed files with 33 additions and 12 deletions
|
@ -250,8 +250,12 @@ bool RenderableModelEntityItem::findDetailedParabolaIntersection(const glm::vec3
|
||||||
face, surfaceNormal, extraInfo, precisionPicking, false);
|
face, surfaceNormal, extraInfo, precisionPicking, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RenderableModelEntityItem::getCollisionShapeURL() const {
|
||||||
|
return getShapeType() == SHAPE_TYPE_COMPOUND ? getCompoundShapeURL() : getModelURL();
|
||||||
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::fetchCollisionGeometryResource() {
|
void RenderableModelEntityItem::fetchCollisionGeometryResource() {
|
||||||
_collisionGeometryResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCompoundShapeURL());
|
_collisionGeometryResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCollisionShapeURL());
|
||||||
if (_collisionGeometryResource) {
|
if (_collisionGeometryResource) {
|
||||||
if (_collisionGeometryResource->isLoaded()) {
|
if (_collisionGeometryResource->isLoaded()) {
|
||||||
markDirtyFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
|
markDirtyFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
|
||||||
|
@ -276,10 +280,10 @@ void RenderableModelEntityItem::setShapeType(ShapeType type) {
|
||||||
ModelEntityItem::setShapeType(type);
|
ModelEntityItem::setShapeType(type);
|
||||||
auto shapeType = getShapeType();
|
auto shapeType = getShapeType();
|
||||||
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
if (!_collisionGeometryResource && !getCompoundShapeURL().isEmpty()) {
|
if (!_collisionGeometryResource && !getCollisionShapeURL().isEmpty()) {
|
||||||
fetchCollisionGeometryResource();
|
fetchCollisionGeometryResource();
|
||||||
}
|
}
|
||||||
} else if (_collisionGeometryResource && !getCompoundShapeURL().isEmpty()) {
|
} else if (_collisionGeometryResource) {
|
||||||
// the compoundURL has been set but the shapeType does not agree
|
// the compoundURL has been set but the shapeType does not agree
|
||||||
_collisionGeometryResource.reset();
|
_collisionGeometryResource.reset();
|
||||||
}
|
}
|
||||||
|
@ -290,7 +294,18 @@ void RenderableModelEntityItem::setCompoundShapeURL(const QString& url) {
|
||||||
ModelEntityItem::setCompoundShapeURL(url);
|
ModelEntityItem::setCompoundShapeURL(url);
|
||||||
if (url != currentCompoundShapeURL && !url.isEmpty()) {
|
if (url != currentCompoundShapeURL && !url.isEmpty()) {
|
||||||
auto shapeType = getShapeType();
|
auto shapeType = getShapeType();
|
||||||
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
if (shapeType == SHAPE_TYPE_COMPOUND) {
|
||||||
|
fetchCollisionGeometryResource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableModelEntityItem::setModelURL(const QString& url) {
|
||||||
|
auto currentModelURL = getModelURL();
|
||||||
|
ModelEntityItem::setModelURL(url);
|
||||||
|
if (url != currentModelURL && !url.isEmpty()) {
|
||||||
|
auto shapeType = getShapeType();
|
||||||
|
if (shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
fetchCollisionGeometryResource();
|
fetchCollisionGeometryResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +315,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const {
|
||||||
auto model = getModel();
|
auto model = getModel();
|
||||||
auto shapeType = getShapeType();
|
auto shapeType = getShapeType();
|
||||||
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
auto shapeURL = getCompoundShapeURL();
|
auto shapeURL = getCollisionShapeURL();
|
||||||
// we need a render geometry with a scale to proceed
|
// we need a render geometry with a scale to proceed
|
||||||
if (model && !model->getURL().isEmpty() && !shapeURL.isEmpty() && _dimensionsInitialized && model->isLoaded()) {
|
if (model && !model->getURL().isEmpty() && !shapeURL.isEmpty() && _dimensionsInitialized && model->isLoaded()) {
|
||||||
if (!_collisionGeometryResource) {
|
if (!_collisionGeometryResource) {
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
|
|
||||||
virtual void setShapeType(ShapeType type) override;
|
virtual void setShapeType(ShapeType type) override;
|
||||||
virtual void setCompoundShapeURL(const QString& url) override;
|
virtual void setCompoundShapeURL(const QString& url) override;
|
||||||
|
virtual void setModelURL(const QString& url) override;
|
||||||
|
|
||||||
virtual bool isReadyToComputeShape() const override;
|
virtual bool isReadyToComputeShape() const override;
|
||||||
virtual void computeShapeInfo(ShapeInfo& shapeInfo) override;
|
virtual void computeShapeInfo(ShapeInfo& shapeInfo) override;
|
||||||
|
@ -119,6 +120,8 @@ private:
|
||||||
bool readyToAnimate() const;
|
bool readyToAnimate() const;
|
||||||
void fetchCollisionGeometryResource();
|
void fetchCollisionGeometryResource();
|
||||||
|
|
||||||
|
QString getCollisionShapeURL() const;
|
||||||
|
|
||||||
GeometryResource::Pointer _collisionGeometryResource;
|
GeometryResource::Pointer _collisionGeometryResource;
|
||||||
std::vector<int> _jointMap;
|
std::vector<int> _jointMap;
|
||||||
QVariantMap _originalTextures;
|
QVariantMap _originalTextures;
|
||||||
|
|
|
@ -254,25 +254,29 @@ void ModelEntityItem::debugDump() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setShapeType(ShapeType type) {
|
void ModelEntityItem::setShapeType(ShapeType type) {
|
||||||
|
bool changed = false;
|
||||||
|
uint32_t flags = 0;
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
if (type != _shapeType) {
|
if (type != _shapeType) {
|
||||||
if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) {
|
if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) {
|
||||||
// dynamic and STATIC_MESH are incompatible
|
// dynamic and STATIC_MESH are incompatible
|
||||||
// since the shape is being set here we clear the dynamic bit
|
// since the shape is being set here we clear the dynamic bit
|
||||||
_dynamic = false;
|
_dynamic = false;
|
||||||
_flags |= Simulation::DIRTY_MOTION_TYPE;
|
flags = Simulation::DIRTY_MOTION_TYPE;
|
||||||
}
|
}
|
||||||
_shapeType = type;
|
_shapeType = type;
|
||||||
_flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS;
|
flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS;
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
markDirtyFlags(flags);
|
||||||
|
locationChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeType ModelEntityItem::getShapeType() const {
|
ShapeType ModelEntityItem::getShapeType() const {
|
||||||
return computeTrueShapeType();
|
|
||||||
}
|
|
||||||
|
|
||||||
ShapeType ModelEntityItem::computeTrueShapeType() const {
|
|
||||||
ShapeType type = resultWithReadLock<ShapeType>([&] { return _shapeType; });
|
ShapeType type = resultWithReadLock<ShapeType>([&] { return _shapeType; });
|
||||||
if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) {
|
if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) {
|
||||||
// dynamic is incompatible with STATIC_MESH
|
// dynamic is incompatible with STATIC_MESH
|
||||||
|
|
|
@ -122,7 +122,6 @@ public:
|
||||||
private:
|
private:
|
||||||
void setAnimationSettings(const QString& value); // only called for old bitstream format
|
void setAnimationSettings(const QString& value); // only called for old bitstream format
|
||||||
bool applyNewAnimationProperties(AnimationPropertyGroup newProperties);
|
bool applyNewAnimationProperties(AnimationPropertyGroup newProperties);
|
||||||
ShapeType computeTrueShapeType() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeJointArrays(int newSize);
|
void resizeJointArrays(int newSize);
|
||||||
|
|
Loading…
Reference in a new issue