mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:00:44 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into permissions-grid
This commit is contained in:
commit
e16d1fdc23
8 changed files with 76 additions and 21 deletions
|
@ -14,6 +14,10 @@
|
||||||
ClipboardScriptingInterface::ClipboardScriptingInterface() {
|
ClipboardScriptingInterface::ClipboardScriptingInterface() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 ClipboardScriptingInterface::getContentsDimensions() {
|
||||||
|
return qApp->getEntityClipboard()->getContentsDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
float ClipboardScriptingInterface::getClipboardContentsLargestDimension() {
|
float ClipboardScriptingInterface::getClipboardContentsLargestDimension() {
|
||||||
return qApp->getEntityClipboard()->getContentsLargestDimension();
|
return qApp->getEntityClipboard()->getContentsLargestDimension();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ signals:
|
||||||
void readyToImport();
|
void readyToImport();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
glm::vec3 getContentsDimensions(); /// returns the overall dimensions of everything on the blipboard
|
||||||
float getClipboardContentsLargestDimension(); /// returns the largest dimension of everything on the clipboard
|
float getClipboardContentsLargestDimension(); /// returns the largest dimension of everything on the clipboard
|
||||||
bool importEntities(const QString& filename);
|
bool importEntities(const QString& filename);
|
||||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
||||||
|
|
|
@ -632,13 +632,6 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int numBytesRead = sourceBuffer - startPosition;
|
int numBytesRead = sourceBuffer - startPosition;
|
||||||
|
|
||||||
if (numBytesRead != buffer.size()) {
|
|
||||||
if (shouldLogError(now)) {
|
|
||||||
qCWarning(avatars) << "AvatarData packet size mismatch: expected " << numBytesRead << " received " << buffer.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_averageBytesReceived.updateAverage(numBytesRead);
|
_averageBytesReceived.updateAverage(numBytesRead);
|
||||||
return numBytesRead;
|
return numBytesRead;
|
||||||
}
|
}
|
||||||
|
@ -1270,6 +1263,10 @@ static const QString JSON_AVATAR_DISPLAY_NAME = QStringLiteral("displayName");
|
||||||
static const QString JSON_AVATAR_ATTACHEMENTS = QStringLiteral("attachments");
|
static const QString JSON_AVATAR_ATTACHEMENTS = QStringLiteral("attachments");
|
||||||
static const QString JSON_AVATAR_ENTITIES = QStringLiteral("attachedEntities");
|
static const QString JSON_AVATAR_ENTITIES = QStringLiteral("attachedEntities");
|
||||||
static const QString JSON_AVATAR_SCALE = QStringLiteral("scale");
|
static const QString JSON_AVATAR_SCALE = QStringLiteral("scale");
|
||||||
|
static const QString JSON_AVATAR_VERSION = QStringLiteral("version");
|
||||||
|
|
||||||
|
static const int JSON_AVATAR_JOINT_ROTATIONS_IN_RELATIVE_FRAME_VERSION = 0;
|
||||||
|
static const int JSON_AVATAR_JOINT_ROTATIONS_IN_ABSOLUTE_FRAME_VERSION = 1;
|
||||||
|
|
||||||
QJsonValue toJsonValue(const JointData& joint) {
|
QJsonValue toJsonValue(const JointData& joint) {
|
||||||
QJsonArray result;
|
QJsonArray result;
|
||||||
|
@ -1293,6 +1290,8 @@ JointData jointDataFromJsonValue(const QJsonValue& json) {
|
||||||
QJsonObject AvatarData::toJson() const {
|
QJsonObject AvatarData::toJson() const {
|
||||||
QJsonObject root;
|
QJsonObject root;
|
||||||
|
|
||||||
|
root[JSON_AVATAR_VERSION] = JSON_AVATAR_JOINT_ROTATIONS_IN_ABSOLUTE_FRAME_VERSION;
|
||||||
|
|
||||||
if (!getSkeletonModelURL().isEmpty()) {
|
if (!getSkeletonModelURL().isEmpty()) {
|
||||||
root[JSON_AVATAR_BODY_MODEL] = getSkeletonModelURL().toString();
|
root[JSON_AVATAR_BODY_MODEL] = getSkeletonModelURL().toString();
|
||||||
}
|
}
|
||||||
|
@ -1359,6 +1358,15 @@ QJsonObject AvatarData::toJson() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::fromJson(const QJsonObject& json) {
|
void AvatarData::fromJson(const QJsonObject& json) {
|
||||||
|
|
||||||
|
int version;
|
||||||
|
if (json.contains(JSON_AVATAR_VERSION)) {
|
||||||
|
version = json[JSON_AVATAR_VERSION].toInt();
|
||||||
|
} else {
|
||||||
|
// initial data did not have a version field.
|
||||||
|
version = JSON_AVATAR_JOINT_ROTATIONS_IN_RELATIVE_FRAME_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
// The head setOrientation likes to overwrite the avatar orientation,
|
// The head setOrientation likes to overwrite the avatar orientation,
|
||||||
// so lets do the head first
|
// so lets do the head first
|
||||||
// Most head data is relative to the avatar, and needs no basis correction,
|
// Most head data is relative to the avatar, and needs no basis correction,
|
||||||
|
@ -1424,20 +1432,28 @@ void AvatarData::fromJson(const QJsonObject& json) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Joint rotations are relative to the avatar, so they require no basis correction
|
|
||||||
if (json.contains(JSON_AVATAR_JOINT_ARRAY)) {
|
if (json.contains(JSON_AVATAR_JOINT_ARRAY)) {
|
||||||
QVector<JointData> jointArray;
|
if (version == JSON_AVATAR_JOINT_ROTATIONS_IN_RELATIVE_FRAME_VERSION) {
|
||||||
QJsonArray jointArrayJson = json[JSON_AVATAR_JOINT_ARRAY].toArray();
|
// because we don't have the full joint hierarchy skeleton of the model,
|
||||||
jointArray.reserve(jointArrayJson.size());
|
// we can't properly convert from relative rotations into absolute rotations.
|
||||||
int i = 0;
|
quint64 now = usecTimestampNow();
|
||||||
for (const auto& jointJson : jointArrayJson) {
|
if (shouldLogError(now)) {
|
||||||
auto joint = jointDataFromJsonValue(jointJson);
|
qCWarning(avatars) << "Version 0 avatar recordings not supported. using default rotations";
|
||||||
jointArray.push_back(joint);
|
}
|
||||||
setJointData(i, joint.rotation, joint.translation);
|
} else {
|
||||||
_jointData[i].rotationSet = true; // Have to do that to broadcast the avatar new pose
|
QVector<JointData> jointArray;
|
||||||
i++;
|
QJsonArray jointArrayJson = json[JSON_AVATAR_JOINT_ARRAY].toArray();
|
||||||
|
jointArray.reserve(jointArrayJson.size());
|
||||||
|
int i = 0;
|
||||||
|
for (const auto& jointJson : jointArrayJson) {
|
||||||
|
auto joint = jointDataFromJsonValue(jointJson);
|
||||||
|
jointArray.push_back(joint);
|
||||||
|
setJointData(i, joint.rotation, joint.translation);
|
||||||
|
_jointData[i].rotationSet = true; // Have to do that to broadcast the avatar new pose
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
setRawJointData(jointArray);
|
||||||
}
|
}
|
||||||
setRawJointData(jointArray);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1121,6 +1121,27 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QUuid> EntityScriptingInterface::getChildrenIDs(const QUuid& parentID) {
|
||||||
|
QVector<QUuid> result;
|
||||||
|
if (!_entityTree) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(parentID);
|
||||||
|
if (!entity) {
|
||||||
|
qDebug() << "EntityScriptingInterface::getChildrenIDs - no entity with ID" << parentID;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
_entityTree->withReadLock([&] {
|
||||||
|
entity->forEachChild([&](SpatiallyNestablePointer child) {
|
||||||
|
result.push_back(child->getID());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {
|
QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {
|
||||||
QVector<QUuid> result;
|
QVector<QUuid> result;
|
||||||
if (!_entityTree) {
|
if (!_entityTree) {
|
||||||
|
|
|
@ -171,6 +171,7 @@ public slots:
|
||||||
|
|
||||||
Q_INVOKABLE int getJointIndex(const QUuid& entityID, const QString& name);
|
Q_INVOKABLE int getJointIndex(const QUuid& entityID, const QString& name);
|
||||||
Q_INVOKABLE QStringList getJointNames(const QUuid& entityID);
|
Q_INVOKABLE QStringList getJointNames(const QUuid& entityID);
|
||||||
|
Q_INVOKABLE QVector<QUuid> getChildrenIDs(const QUuid& parentID);
|
||||||
Q_INVOKABLE QVector<QUuid> getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex);
|
Q_INVOKABLE QVector<QUuid> getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -1284,6 +1284,7 @@ class ContentsDimensionOperator : public RecurseOctreeOperator {
|
||||||
public:
|
public:
|
||||||
virtual bool preRecursion(OctreeElementPointer element);
|
virtual bool preRecursion(OctreeElementPointer element);
|
||||||
virtual bool postRecursion(OctreeElementPointer element) { return true; }
|
virtual bool postRecursion(OctreeElementPointer element) { return true; }
|
||||||
|
glm::vec3 getDimensions() const { return _contentExtents.size(); }
|
||||||
float getLargestDimension() const { return _contentExtents.largestDimension(); }
|
float getLargestDimension() const { return _contentExtents.largestDimension(); }
|
||||||
private:
|
private:
|
||||||
Extents _contentExtents;
|
Extents _contentExtents;
|
||||||
|
@ -1295,6 +1296,12 @@ bool ContentsDimensionOperator::preRecursion(OctreeElementPointer element) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 EntityTree::getContentsDimensions() {
|
||||||
|
ContentsDimensionOperator theOperator;
|
||||||
|
recurseTreeWithOperator(&theOperator);
|
||||||
|
return theOperator.getDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
float EntityTree::getContentsLargestDimension() {
|
float EntityTree::getContentsLargestDimension() {
|
||||||
ContentsDimensionOperator theOperator;
|
ContentsDimensionOperator theOperator;
|
||||||
recurseTreeWithOperator(&theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
|
|
|
@ -207,6 +207,7 @@ public:
|
||||||
bool skipThoseWithBadParents) override;
|
bool skipThoseWithBadParents) override;
|
||||||
virtual bool readFromMap(QVariantMap& entityDescription) override;
|
virtual bool readFromMap(QVariantMap& entityDescription) override;
|
||||||
|
|
||||||
|
glm::vec3 getContentsDimensions();
|
||||||
float getContentsLargestDimension();
|
float getContentsLargestDimension();
|
||||||
|
|
||||||
virtual void resetEditStats() override {
|
virtual void resetEditStats() override {
|
||||||
|
|
|
@ -28,7 +28,9 @@ Settings::~Settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::remove(const QString& key) {
|
void Settings::remove(const QString& key) {
|
||||||
_manager->remove(key);
|
if (key == "" || _manager->contains(key)) {
|
||||||
|
_manager->remove(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Settings::childGroups() const {
|
QStringList Settings::childGroups() const {
|
||||||
|
@ -72,7 +74,9 @@ void Settings::endGroup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setValue(const QString& name, const QVariant& value) {
|
void Settings::setValue(const QString& name, const QVariant& value) {
|
||||||
_manager->setValue(name, value);
|
if (_manager->value(name) != value) {
|
||||||
|
_manager->setValue(name, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant Settings::value(const QString& name, const QVariant& defaultValue) const {
|
QVariant Settings::value(const QString& name, const QVariant& defaultValue) const {
|
||||||
|
|
Loading…
Reference in a new issue