mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 08:28:22 +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
|
// we have a _parentID but no parent pointer, or our parent pointer was to the wrong thing
|
||||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||||
if (!parentFinder) {
|
if (!parentFinder) {
|
||||||
|
qDebug() << "SpatiallyNestable::getParentPointer -- no parentFinder";
|
||||||
success = false;
|
success = false;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
_parent = parentFinder->find(parentID, success);
|
_parent = parentFinder->find(parentID, success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
qDebug() << "parentFinder failed for " << parentID;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +120,7 @@ SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success) cons
|
||||||
if (parent || parentID.isNull()) {
|
if (parent || parentID.isNull()) {
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
|
qDebug() << "SpatiallyNestable::getParentPointer -- couldn't resolve parent: " << parentID;
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,9 +395,15 @@ void SpatiallyNestable::setOrientation(const glm::quat& orientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 SpatiallyNestable::getVelocity(bool& success) const {
|
glm::vec3 SpatiallyNestable::getVelocity(bool& success) const {
|
||||||
glm::vec3 parentVelocity = getParentVelocity(success);
|
|
||||||
Transform parentTransform = getParentTransform(success);
|
|
||||||
glm::vec3 result;
|
glm::vec3 result;
|
||||||
|
glm::vec3 parentVelocity = getParentVelocity(success);
|
||||||
|
if (!success) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Transform parentTransform = getParentTransform(success);
|
||||||
|
if (!success) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
_velocityLock.withReadLock([&] {
|
_velocityLock.withReadLock([&] {
|
||||||
// TODO: take parent angularVelocity into account.
|
// TODO: take parent angularVelocity into account.
|
||||||
result = parentVelocity + parentTransform.getRotation() * _velocity;
|
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 SpatiallyNestable::getParentVelocity(bool& success) const {
|
||||||
glm::vec3 result;
|
glm::vec3 result;
|
||||||
SpatiallyNestablePointer parent = getParentPointer(success);
|
SpatiallyNestablePointer parent = getParentPointer(success);
|
||||||
if (success && parent) {
|
if (!success) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (parent) {
|
||||||
result = parent->getVelocity(success);
|
result = parent->getVelocity(success);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 SpatiallyNestable::getAngularVelocity(bool& success) const {
|
glm::vec3 SpatiallyNestable::getAngularVelocity(bool& success) const {
|
||||||
glm::vec3 parentAngularVelocity = getParentAngularVelocity(success);
|
|
||||||
Transform parentTransform = getParentTransform(success);
|
|
||||||
glm::vec3 result;
|
glm::vec3 result;
|
||||||
|
glm::vec3 parentAngularVelocity = getParentAngularVelocity(success);
|
||||||
|
if (!success) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Transform parentTransform = getParentTransform(success);
|
||||||
|
if (!success) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
_angularVelocityLock.withReadLock([&] {
|
_angularVelocityLock.withReadLock([&] {
|
||||||
result = parentAngularVelocity + parentTransform.getRotation() * _angularVelocity;
|
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 SpatiallyNestable::getParentAngularVelocity(bool& success) const {
|
||||||
glm::vec3 result;
|
glm::vec3 result;
|
||||||
SpatiallyNestablePointer parent = getParentPointer(success);
|
SpatiallyNestablePointer parent = getParentPointer(success);
|
||||||
if (success && parent) {
|
if (!success) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (parent) {
|
||||||
result = parent->getAngularVelocity(success);
|
result = parent->getAngularVelocity(success);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -672,6 +693,16 @@ QList<SpatiallyNestablePointer> SpatiallyNestable::getChildren() const {
|
||||||
return children;
|
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 {
|
const Transform SpatiallyNestable::getAbsoluteJointTransformInObjectFrame(int jointIndex) const {
|
||||||
Transform jointTransformInObjectFrame;
|
Transform jointTransformInObjectFrame;
|
||||||
glm::vec3 position = getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
glm::vec3 position = getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||||
|
|
|
@ -116,6 +116,8 @@ public:
|
||||||
virtual void setLocalScale(const glm::vec3& scale);
|
virtual void setLocalScale(const glm::vec3& scale);
|
||||||
|
|
||||||
QList<SpatiallyNestablePointer> getChildren() const;
|
QList<SpatiallyNestablePointer> getChildren() const;
|
||||||
|
bool hasChildren() const;
|
||||||
|
|
||||||
NestableType getNestableType() const { return _nestableType; }
|
NestableType getNestableType() const { return _nestableType; }
|
||||||
|
|
||||||
// this object's frame
|
// this object's frame
|
||||||
|
|
Loading…
Reference in a new issue