mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
split out calls for rotation and translation
This commit is contained in:
parent
d0c6604be8
commit
9304477233
3 changed files with 33 additions and 13 deletions
|
@ -48,10 +48,11 @@ function getJointData(avatar) {
|
|||
}
|
||||
|
||||
function setJointData(doppelganger, allJointData) {
|
||||
var jointRotations = [];
|
||||
allJointData.forEach(function(jointData, index) {
|
||||
Entities.setAbsoluteJointTranslationInObjectFrame(doppelganger.id, index, jointData.translation);
|
||||
Entities.setAbsoluteJointRotationInObjectFrame(doppelganger.id, index, jointData.rotation);
|
||||
jointRotations.push(jointData.rotation);
|
||||
});
|
||||
Entities.setAbsoluteJointRotationsInObjectFrame(doppelganger.id, jointRotations);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ function rotateDoppelgangerTowardAvatar(doppelganger, avatar) {
|
|||
|
||||
function connectDoppelgangerUpdates() {
|
||||
// Script.update.connect(updateDoppelganger);
|
||||
Script.setInterval(updateDoppelganger, 500);
|
||||
Script.setInterval(updateDoppelganger, 100);
|
||||
}
|
||||
|
||||
function disconnectDoppelgangerUpdates() {
|
||||
|
|
|
@ -874,23 +874,21 @@ bool EntityScriptingInterface::setAbsoluteJointRotationInObjectFrame(const QUuid
|
|||
}
|
||||
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointsDataInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations,
|
||||
const QVector<glm::vec3>& translations) {
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointRotationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
|
||||
int count = glm::max(rotations.size(), translations.size());
|
||||
bool result = false;
|
||||
for (int index = 0; index < count; index++) {
|
||||
for (int index = 0; index < rotations.size(); index++) {
|
||||
result |= modelEntity->setAbsoluteJointRotationInObjectFrame(index, rotations[index]);
|
||||
}
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
_entityTree->withWriteLock([&] {
|
||||
properties = entity->getProperties();
|
||||
// entity->setLastEdited(now);
|
||||
entity->setLastBroadcast(now);
|
||||
});
|
||||
|
||||
|
@ -899,17 +897,25 @@ bool EntityScriptingInterface::setAbsoluteJointsDataInObjectFrame(const QUuid& e
|
|||
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
result = false;
|
||||
for (int index = 0; index < count; index++) {
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointTranslationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::vec3>& translations) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
|
||||
bool result = false;
|
||||
for (int index = 0; index < translations.size(); index++) {
|
||||
result |= modelEntity->setAbsoluteJointTranslationInObjectFrame(index, translations[index]);
|
||||
}
|
||||
now = usecTimestampNow();
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
_entityTree->withWriteLock([&] {
|
||||
properties = entity->getProperties();
|
||||
// entity->setLastEdited(now);
|
||||
entity->setLastBroadcast(now);
|
||||
});
|
||||
|
||||
|
@ -921,3 +927,12 @@ bool EntityScriptingInterface::setAbsoluteJointsDataInObjectFrame(const QUuid& e
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointsDataInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations,
|
||||
const QVector<glm::vec3>& translations) {
|
||||
// for a model with 80 joints, sending both these in one edit packet causes the packet to be too large.
|
||||
return setAbsoluteJointRotationsInObjectFrame(entityID, rotations) ||
|
||||
setAbsoluteJointTranslationsInObjectFrame(entityID, translations);
|
||||
}
|
||||
|
|
|
@ -153,6 +153,10 @@ public slots:
|
|||
Q_INVOKABLE glm::quat getAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE bool setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex, glm::vec3 translation);
|
||||
Q_INVOKABLE bool setAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex, glm::quat rotation);
|
||||
Q_INVOKABLE bool setAbsoluteJointRotationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations);
|
||||
Q_INVOKABLE bool setAbsoluteJointTranslationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::vec3>& translations);
|
||||
Q_INVOKABLE bool setAbsoluteJointsDataInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations,
|
||||
const QVector<glm::vec3>& translations);
|
||||
|
|
Loading…
Reference in a new issue