mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 22:40:12 +02:00
try harder to get queryAABoxes to be correct
This commit is contained in:
parent
7a4dad8e51
commit
2ad15f7568
3 changed files with 32 additions and 25 deletions
|
@ -74,14 +74,16 @@ void RenderableModelEntityItem::loader() {
|
||||||
|
|
||||||
void RenderableModelEntityItem::setDimensions(const glm::vec3& value) {
|
void RenderableModelEntityItem::setDimensions(const glm::vec3& value) {
|
||||||
_dimensionsInitialized = true;
|
_dimensionsInitialized = true;
|
||||||
ModelEntityItem::setDimensions(value);
|
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
|
AACube queryAACube = getQueryAACube(success);
|
||||||
|
|
||||||
|
ModelEntityItem::setDimensions(value);
|
||||||
|
|
||||||
AACube maxAACube = getMaximumAACube(success);
|
AACube maxAACube = getMaximumAACube(success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AACube queryAACube = getQueryAACube(success);
|
|
||||||
|
|
||||||
if (!success || !queryAACube.contains(maxAACube)) {
|
if (!success || !queryAACube.contains(maxAACube)) {
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
|
|
|
@ -1202,11 +1202,35 @@ const Transform EntityItem::getTransformToCenter(bool& success) const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityItem::checkAndAdjustQueryAACube() {
|
||||||
|
bool maxAACubeSuccess;
|
||||||
|
AACube maxAACube = getMaximumAACube(maxAACubeSuccess);
|
||||||
|
if (maxAACubeSuccess) {
|
||||||
|
if (!_queryAACubeSet || !_queryAACube.contains(maxAACube)) {
|
||||||
|
// allow server to patch up broken queryAACubes
|
||||||
|
EntityTreePointer tree = getTree();
|
||||||
|
if (tree) {
|
||||||
|
qDebug() << "EntityItem::checkAndAdjustQueryAACube" << getName();
|
||||||
|
EntityItemProperties properties;
|
||||||
|
properties.setQueryAACube(maxAACube);
|
||||||
|
tree->updateEntity(getID(), properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntityItem::setParentID(const QUuid& parentID) {
|
||||||
|
SpatiallyNestable::setParentID(parentID);
|
||||||
|
checkAndAdjustQueryAACube();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EntityItem::setDimensions(const glm::vec3& value) {
|
void EntityItem::setDimensions(const glm::vec3& value) {
|
||||||
if (value.x <= 0.0f || value.y <= 0.0f || value.z <= 0.0f) {
|
if (value.x <= 0.0f || value.y <= 0.0f || value.z <= 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setScale(value);
|
setScale(value);
|
||||||
|
checkAndAdjustQueryAACube();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The maximum bounding cube for the entity, independent of it's rotation.
|
/// The maximum bounding cube for the entity, independent of it's rotation.
|
||||||
|
@ -1299,26 +1323,6 @@ AABox EntityItem::getAABox(bool& success) const {
|
||||||
return _cachedAABox;
|
return _cachedAABox;
|
||||||
}
|
}
|
||||||
|
|
||||||
AACube EntityItem::getQueryAACube(bool& success) const {
|
|
||||||
AACube queryAACube = SpatiallyNestable::getQueryAACube(success);
|
|
||||||
bool maxAACubeSuccess;
|
|
||||||
AACube maxAACube = getMaximumAACube(maxAACubeSuccess);
|
|
||||||
if (success) {
|
|
||||||
// allow server to patch up broken queryAACubes
|
|
||||||
if (maxAACubeSuccess && !queryAACube.contains(maxAACube)) {
|
|
||||||
getThisPointer()->setQueryAACube(maxAACube);
|
|
||||||
}
|
|
||||||
return _queryAACube;
|
|
||||||
}
|
|
||||||
// this is for when we've loaded an older json file that didn't have queryAACube properties.
|
|
||||||
success = maxAACubeSuccess;
|
|
||||||
if (maxAACubeSuccess) {
|
|
||||||
getThisPointer()->setQueryAACube(maxAACube);
|
|
||||||
}
|
|
||||||
return _queryAACube;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: This should only be used in cases of old bitstreams which only contain radius data
|
// NOTE: This should only be used in cases of old bitstreams which only contain radius data
|
||||||
// 0,0,0 --> maxDimension,maxDimension,maxDimension
|
// 0,0,0 --> maxDimension,maxDimension,maxDimension
|
||||||
// ... has a corner to corner distance of glm::length(maxDimension,maxDimension,maxDimension)
|
// ... has a corner to corner distance of glm::length(maxDimension,maxDimension,maxDimension)
|
||||||
|
|
|
@ -179,6 +179,10 @@ public:
|
||||||
QString getDescription() const { return _description; }
|
QString getDescription() const { return _description; }
|
||||||
void setDescription(QString value) { _description = value; }
|
void setDescription(QString value) { _description = value; }
|
||||||
|
|
||||||
|
void checkAndAdjustQueryAACube();
|
||||||
|
|
||||||
|
virtual void setParentID(const QUuid& parentID);
|
||||||
|
|
||||||
/// Dimensions in meters (0.0 - TREE_SCALE)
|
/// Dimensions in meters (0.0 - TREE_SCALE)
|
||||||
inline const glm::vec3 getDimensions() const { return getScale(); }
|
inline const glm::vec3 getDimensions() const { return getScale(); }
|
||||||
virtual void setDimensions(const glm::vec3& value);
|
virtual void setDimensions(const glm::vec3& value);
|
||||||
|
@ -238,9 +242,6 @@ public:
|
||||||
AACube getMinimumAACube(bool& success) const;
|
AACube getMinimumAACube(bool& success) const;
|
||||||
AABox getAABox(bool& success) const; /// axis aligned bounding box in world-frame (meters)
|
AABox getAABox(bool& success) const; /// axis aligned bounding box in world-frame (meters)
|
||||||
|
|
||||||
using SpatiallyNestable::getQueryAACube;
|
|
||||||
virtual AACube getQueryAACube(bool& success) const override;
|
|
||||||
|
|
||||||
const QString& getScript() const { return _script; }
|
const QString& getScript() const { return _script; }
|
||||||
void setScript(const QString& value) { _script = value; }
|
void setScript(const QString& value) { _script = value; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue