mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
clean up handling of success flag and some debugging prints
This commit is contained in:
parent
1ae47b17f0
commit
3f922240d0
2 changed files with 39 additions and 6 deletions
|
@ -101,11 +101,13 @@ SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success) cons
|
|||
// we have a _parentID but no parent pointer, or our parent pointer was to the wrong thing
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
if (!parentFinder) {
|
||||
qDebug() << "SpatiallyNestable::getParentPointer -- no parentFinder";
|
||||
success = false;
|
||||
return nullptr;
|
||||
}
|
||||
_parent = parentFinder->find(parentID, success);
|
||||
if (!success) {
|
||||
qDebug() << "parentFinder failed for " << parentID;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -118,6 +120,7 @@ SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success) cons
|
|||
if (parent || parentID.isNull()) {
|
||||
success = true;
|
||||
} else {
|
||||
qDebug() << "SpatiallyNestable::getParentPointer -- couldn't resolve parent: " << parentID;
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
@ -392,9 +395,15 @@ void SpatiallyNestable::setOrientation(const glm::quat& orientation) {
|
|||
}
|
||||
|
||||
glm::vec3 SpatiallyNestable::getVelocity(bool& success) const {
|
||||
glm::vec3 parentVelocity = getParentVelocity(success);
|
||||
Transform parentTransform = getParentTransform(success);
|
||||
glm::vec3 result;
|
||||
glm::vec3 parentVelocity = getParentVelocity(success);
|
||||
if (!success) {
|
||||
return result;
|
||||
}
|
||||
Transform parentTransform = getParentTransform(success);
|
||||
if (!success) {
|
||||
return result;
|
||||
}
|
||||
_velocityLock.withReadLock([&] {
|
||||
// TODO: take parent angularVelocity into account.
|
||||
result = parentVelocity + parentTransform.getRotation() * _velocity;
|
||||
|
@ -431,16 +440,25 @@ void SpatiallyNestable::setVelocity(const glm::vec3& velocity) {
|
|||
glm::vec3 SpatiallyNestable::getParentVelocity(bool& success) const {
|
||||
glm::vec3 result;
|
||||
SpatiallyNestablePointer parent = getParentPointer(success);
|
||||
if (success && parent) {
|
||||
if (!success) {
|
||||
return result;
|
||||
}
|
||||
if (parent) {
|
||||
result = parent->getVelocity(success);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
glm::vec3 SpatiallyNestable::getAngularVelocity(bool& success) const {
|
||||
glm::vec3 parentAngularVelocity = getParentAngularVelocity(success);
|
||||
Transform parentTransform = getParentTransform(success);
|
||||
glm::vec3 result;
|
||||
glm::vec3 parentAngularVelocity = getParentAngularVelocity(success);
|
||||
if (!success) {
|
||||
return result;
|
||||
}
|
||||
Transform parentTransform = getParentTransform(success);
|
||||
if (!success) {
|
||||
return result;
|
||||
}
|
||||
_angularVelocityLock.withReadLock([&] {
|
||||
result = parentAngularVelocity + parentTransform.getRotation() * _angularVelocity;
|
||||
});
|
||||
|
@ -475,7 +493,10 @@ void SpatiallyNestable::setAngularVelocity(const glm::vec3& angularVelocity) {
|
|||
glm::vec3 SpatiallyNestable::getParentAngularVelocity(bool& success) const {
|
||||
glm::vec3 result;
|
||||
SpatiallyNestablePointer parent = getParentPointer(success);
|
||||
if (success && parent) {
|
||||
if (!success) {
|
||||
return result;
|
||||
}
|
||||
if (parent) {
|
||||
result = parent->getAngularVelocity(success);
|
||||
}
|
||||
return result;
|
||||
|
@ -672,6 +693,16 @@ QList<SpatiallyNestablePointer> SpatiallyNestable::getChildren() const {
|
|||
return children;
|
||||
}
|
||||
|
||||
bool SpatiallyNestable::hasChildren() const {
|
||||
bool result = false;
|
||||
_childrenLock.withReadLock([&] {
|
||||
if (_children.size() > 0) {
|
||||
result = true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
const Transform SpatiallyNestable::getAbsoluteJointTransformInObjectFrame(int jointIndex) const {
|
||||
Transform jointTransformInObjectFrame;
|
||||
glm::vec3 position = getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||
|
|
|
@ -116,6 +116,8 @@ public:
|
|||
virtual void setLocalScale(const glm::vec3& scale);
|
||||
|
||||
QList<SpatiallyNestablePointer> getChildren() const;
|
||||
bool hasChildren() const;
|
||||
|
||||
NestableType getNestableType() const { return _nestableType; }
|
||||
|
||||
// this object's frame
|
||||
|
|
Loading…
Reference in a new issue