mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
call locationChanged when receiving changing avatar joints over the network. RenderableModelEntityItem uses locationChanged to relay updates to _model
This commit is contained in:
parent
4982ef5943
commit
6c033d9603
7 changed files with 31 additions and 3 deletions
|
@ -994,6 +994,9 @@ int Avatar::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
if (_moving && _motionState) {
|
||||
_motionState->addDirtyFlags(Simulation::DIRTY_POSITION);
|
||||
}
|
||||
if (_moving || _hasNewJointRotations || _hasNewJointTranslations) {
|
||||
locationChanged();
|
||||
}
|
||||
endUpdate();
|
||||
|
||||
return bytesRead;
|
||||
|
|
|
@ -624,3 +624,11 @@ glm::vec3 RenderableModelEntityItem::getAbsoluteJointTranslationInObjectFrame(in
|
|||
}
|
||||
return glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
void RenderableModelEntityItem::locationChanged() {
|
||||
EntityItem::locationChanged();
|
||||
if (_model && _model->isActive()) {
|
||||
_model->setRotation(getRotation());
|
||||
_model->setTranslation(getPosition());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
||||
|
||||
virtual void loader() override;
|
||||
virtual void locationChanged() override;
|
||||
|
||||
private:
|
||||
void remapTextures();
|
||||
|
|
|
@ -749,6 +749,14 @@ void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<Q
|
|||
changedProperties[index] = QString("parentJointIndex:") + QString::number((int)value);
|
||||
}
|
||||
}
|
||||
|
||||
if (properties.parentIDChanged()) {
|
||||
int index = changedProperties.indexOf("parentID");
|
||||
if (index >= 0) {
|
||||
QUuid value = properties.getParentID();
|
||||
changedProperties[index] = QString("parentID:") + value.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned char* editData, int maxLength,
|
||||
|
|
|
@ -95,6 +95,9 @@ const float METERS_PER_MILLIMETER = 0.01f;
|
|||
void Model::setScaleInternal(const glm::vec3& scale) {
|
||||
if (glm::distance(_scale, scale) > METERS_PER_MILLIMETER) {
|
||||
_scale = scale;
|
||||
if (_scale.x == 0.0f || _scale.y == 0.0f || _scale.z == 0.0f) {
|
||||
assert(false);
|
||||
}
|
||||
initJointTransforms();
|
||||
}
|
||||
}
|
||||
|
@ -1210,7 +1213,7 @@ bool Model::initWhenReady(render::ScenePointer scene) {
|
|||
auto renderPayload = std::make_shared<MeshPartPayload::Payload>(renderItem);
|
||||
_renderItems.insert(item, renderPayload);
|
||||
pendingChanges.resetItem(item, renderPayload);
|
||||
pendingChanges.updateItem<MeshPartPayload>(item, [&](MeshPartPayload& data) {
|
||||
pendingChanges.updateItem<MeshPartPayload>(item, [=](MeshPartPayload& data) {
|
||||
data.updateTransform(transform, offset);
|
||||
data.notifyLocationChanged();
|
||||
});
|
||||
|
|
|
@ -99,6 +99,11 @@ void SpatiallyNestable::setParentID(const QUuid& parentID) {
|
|||
parentChanged();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setParentJointIndex(quint16 parentJointIndex) {
|
||||
_parentJointIndex = parentJointIndex;
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 SpatiallyNestable::worldToLocal(const glm::vec3& position, const QUuid& parentID, int parentJointIndex) {
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
Transform parentTransform;
|
||||
|
|
|
@ -38,11 +38,11 @@ public:
|
|||
virtual const QUuid& getID() const { return _id; }
|
||||
virtual void setID(const QUuid& id) { _id = id; }
|
||||
|
||||
virtual const QUuid getParentID() const { return _parentID; }
|
||||
virtual QUuid getParentID() const { return _parentID; }
|
||||
virtual void setParentID(const QUuid& parentID);
|
||||
|
||||
virtual quint16 getParentJointIndex() const { return _parentJointIndex; }
|
||||
virtual void setParentJointIndex(quint16 parentJointIndex) { _parentJointIndex = parentJointIndex; }
|
||||
virtual void setParentJointIndex(quint16 parentJointIndex);
|
||||
|
||||
static glm::vec3 worldToLocal(const glm::vec3& position, const QUuid& parentID, int parentJointIndex);
|
||||
static glm::quat worldToLocal(const glm::quat& orientation, const QUuid& parentID, int parentJointIndex);
|
||||
|
|
Loading…
Reference in a new issue