mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 00:44:38 +02:00
fix softEntity edge cases
This commit is contained in:
parent
5b82c7bc41
commit
283b9a8003
7 changed files with 27 additions and 15 deletions
|
@ -352,10 +352,10 @@ void Avatar::updateAvatarEntities() {
|
||||||
void Avatar::relayJointDataToChildren() {
|
void Avatar::relayJointDataToChildren() {
|
||||||
forEachChild([&](SpatiallyNestablePointer child) {
|
forEachChild([&](SpatiallyNestablePointer child) {
|
||||||
if (child->getNestableType() == NestableType::Entity) {
|
if (child->getNestableType() == NestableType::Entity) {
|
||||||
auto modelEntity = std::dynamic_pointer_cast<RenderableModelEntityItem>(child);
|
auto modelEntity = std::dynamic_pointer_cast<RenderableModelEntityItem>(child);
|
||||||
if (modelEntity) {
|
if (modelEntity) {
|
||||||
if (modelEntity->getRelayParentJoints()) {
|
if (modelEntity->getRelayParentJoints()) {
|
||||||
if (!(modelEntity->getJointMapCompleted())) {
|
if (!modelEntity->getJointMapCompleted() || _reconstructSoftEntitiesJointMap) {
|
||||||
QStringList modelJointNames = modelEntity->getJointNames();
|
QStringList modelJointNames = modelEntity->getJointNames();
|
||||||
int numJoints = modelJointNames.count();
|
int numJoints = modelJointNames.count();
|
||||||
std::vector<int> map;
|
std::vector<int> map;
|
||||||
|
@ -365,7 +365,6 @@ void Avatar::relayJointDataToChildren() {
|
||||||
int avatarJointIndex = getJointIndex(jointName);
|
int avatarJointIndex = getJointIndex(jointName);
|
||||||
glm::quat jointRotation;
|
glm::quat jointRotation;
|
||||||
glm::vec3 jointTranslation;
|
glm::vec3 jointTranslation;
|
||||||
qDebug() << avatarJointIndex;
|
|
||||||
if (avatarJointIndex < 0) {
|
if (avatarJointIndex < 0) {
|
||||||
jointRotation = modelEntity->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
jointRotation = modelEntity->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
||||||
jointTranslation = modelEntity->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
jointTranslation = modelEntity->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||||
|
@ -385,7 +384,6 @@ void Avatar::relayJointDataToChildren() {
|
||||||
int numJoints = modelJointNames.count();
|
int numJoints = modelJointNames.count();
|
||||||
for (int jointIndex = 0; jointIndex < numJoints; jointIndex++) {
|
for (int jointIndex = 0; jointIndex < numJoints; jointIndex++) {
|
||||||
int avatarJointIndex = modelEntity->avatarJointIndex(jointIndex);
|
int avatarJointIndex = modelEntity->avatarJointIndex(jointIndex);
|
||||||
int index = modelEntity->getJointIndex(modelJointNames.at(jointIndex));
|
|
||||||
glm::quat jointRotation;
|
glm::quat jointRotation;
|
||||||
glm::vec3 jointTranslation;
|
glm::vec3 jointTranslation;
|
||||||
if (avatarJointIndex >=0) {
|
if (avatarJointIndex >=0) {
|
||||||
|
@ -406,6 +404,7 @@ void Avatar::relayJointDataToChildren() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_reconstructSoftEntitiesJointMap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime, bool inView) {
|
void Avatar::simulate(float deltaTime, bool inView) {
|
||||||
|
@ -1259,6 +1258,7 @@ void Avatar::setModelURLFinished(bool success) {
|
||||||
invalidateJointIndicesCache();
|
invalidateJointIndicesCache();
|
||||||
|
|
||||||
_isAnimatingScale = true;
|
_isAnimatingScale = true;
|
||||||
|
_reconstructSoftEntitiesJointMap = true;
|
||||||
|
|
||||||
if (!success && _skeletonModelURL != AvatarData::defaultFullAvatarModelUrl()) {
|
if (!success && _skeletonModelURL != AvatarData::defaultFullAvatarModelUrl()) {
|
||||||
const int MAX_SKELETON_DOWNLOAD_ATTEMPTS = 4; // NOTE: we don't want to be as generous as ResourceCache is, we only want 4 attempts
|
const int MAX_SKELETON_DOWNLOAD_ATTEMPTS = 4; // NOTE: we don't want to be as generous as ResourceCache is, we only want 4 attempts
|
||||||
|
|
|
@ -383,6 +383,7 @@ protected:
|
||||||
bool _isAnimatingScale { false };
|
bool _isAnimatingScale { false };
|
||||||
bool _mustFadeIn { false };
|
bool _mustFadeIn { false };
|
||||||
bool _isFading { false };
|
bool _isFading { false };
|
||||||
|
bool _reconstructSoftEntitiesJointMap { false };
|
||||||
float _modelScale { 1.0f };
|
float _modelScale { 1.0f };
|
||||||
|
|
||||||
static int _jointConesID;
|
static int _jointConesID;
|
||||||
|
|
|
@ -209,12 +209,6 @@ void RenderableModelEntityItem::updateModelBounds() {
|
||||||
updateRenderItems = true;
|
updateRenderItems = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getRelayParentJoints()) {
|
|
||||||
model->setOverrideTransform(true);
|
|
||||||
} else {
|
|
||||||
model->setOverrideTransform(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model->getScaleToFitDimensions() != getScaledDimensions() ||
|
if (model->getScaleToFitDimensions() != getScaledDimensions() ||
|
||||||
model->getRegistrationPoint() != getRegistrationPoint()) {
|
model->getRegistrationPoint() != getRegistrationPoint()) {
|
||||||
// The machinery for updateModelBounds will give existing models the opportunity to fix their
|
// The machinery for updateModelBounds will give existing models the opportunity to fix their
|
||||||
|
@ -718,7 +712,10 @@ void RenderableModelEntityItem::setJointMap(std::vector<int> jointMap) {
|
||||||
if (jointMap.size() > 0) {
|
if (jointMap.size() > 0) {
|
||||||
_jointMap = jointMap;
|
_jointMap = jointMap;
|
||||||
_jointMapCompleted = true;
|
_jointMapCompleted = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_jointMapCompleted = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) {
|
int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) {
|
||||||
|
@ -865,7 +862,7 @@ glm::vec3 RenderableModelEntityItem::getLocalJointTranslation(int index) const {
|
||||||
void RenderableModelEntityItem::setOverrideTransform(const Transform& transform, const glm::vec3& offset) {
|
void RenderableModelEntityItem::setOverrideTransform(const Transform& transform, const glm::vec3& offset) {
|
||||||
auto model = getModel();
|
auto model = getModel();
|
||||||
if (model) {
|
if (model) {
|
||||||
model->overrideModelTransform(transform, offset);
|
model->overrideModelTransformAndOffset(transform, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,6 +969,17 @@ void RenderableModelEntityItem::simulateRelayedJoints() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderableModelEntityItem::stopModelOverrideIfNoParent() {
|
||||||
|
auto model = getModel();
|
||||||
|
if (model) {
|
||||||
|
bool overriding = model->isOverridingModelTransformAndOffset();
|
||||||
|
QUuid parentID = getParentID();
|
||||||
|
if (overriding && (!_relayParentJoints || parentID.isNull())) {
|
||||||
|
model->stopTransformAndOffsetOverride();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::copyAnimationJointDataToModel() {
|
void RenderableModelEntityItem::copyAnimationJointDataToModel() {
|
||||||
auto model = getModel();
|
auto model = getModel();
|
||||||
if (!model || !model->isLoaded()) {
|
if (!model || !model->isLoaded()) {
|
||||||
|
@ -1323,6 +1331,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->updateModelBounds();
|
entity->updateModelBounds();
|
||||||
|
entity->stopModelOverrideIfNoParent();
|
||||||
|
|
||||||
if (model->isVisible() != _visible) {
|
if (model->isVisible() != _visible) {
|
||||||
// FIXME: this seems like it could be optimized if we tracked our last known visible state in
|
// FIXME: this seems like it could be optimized if we tracked our last known visible state in
|
||||||
|
|
|
@ -81,6 +81,7 @@ public:
|
||||||
void setCollisionShape(const btCollisionShape* shape) override;
|
void setCollisionShape(const btCollisionShape* shape) override;
|
||||||
|
|
||||||
virtual bool contains(const glm::vec3& point) const override;
|
virtual bool contains(const glm::vec3& point) const override;
|
||||||
|
void stopModelOverrideIfNoParent();
|
||||||
|
|
||||||
virtual bool shouldBePhysical() const override;
|
virtual bool shouldBePhysical() const override;
|
||||||
void simulateRelayedJoints();
|
void simulateRelayedJoints();
|
||||||
|
|
|
@ -1369,7 +1369,7 @@ void Model::deleteGeometry() {
|
||||||
_collisionGeometry.reset();
|
_collisionGeometry.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::overrideModelTransform(const Transform& transform, const glm::vec3& offset) {
|
void Model::overrideModelTransformAndOffset(const Transform& transform, const glm::vec3& offset) {
|
||||||
_overrideTranslation = transform.getTranslation();
|
_overrideTranslation = transform.getTranslation();
|
||||||
_overrideRotation = transform.getRotation();
|
_overrideRotation = transform.getRotation();
|
||||||
_overrideModelTransform = true;
|
_overrideModelTransform = true;
|
||||||
|
|
|
@ -208,8 +208,9 @@ public:
|
||||||
|
|
||||||
void setTranslation(const glm::vec3& translation);
|
void setTranslation(const glm::vec3& translation);
|
||||||
void setRotation(const glm::quat& rotation);
|
void setRotation(const glm::quat& rotation);
|
||||||
void overrideModelTransform(const Transform& transform, const glm::vec3& offset);
|
void overrideModelTransformAndOffset(const Transform& transform, const glm::vec3& offset);
|
||||||
void setOverrideTransform(bool override) { _overrideModelTransform = override; };
|
bool isOverridingModelTransformAndOffset() { return _overrideModelTransform; };
|
||||||
|
void stopTransformAndOffsetOverride() { _overrideModelTransform = false; };
|
||||||
void setTransformNoUpdateRenderItems(const Transform& transform); // temporary HACK
|
void setTransformNoUpdateRenderItems(const Transform& transform); // temporary HACK
|
||||||
|
|
||||||
const glm::vec3& getTranslation() const { return _translation; }
|
const glm::vec3& getTranslation() const { return _translation; }
|
||||||
|
|
|
@ -165,7 +165,7 @@ function wearAttachment(attachment) {
|
||||||
position: attachment.position,
|
position: attachment.position,
|
||||||
rotation: attachment.rotation,
|
rotation: attachment.rotation,
|
||||||
parentJointIndex: -1
|
parentJointIndex: -1
|
||||||
});
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue