mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 02:23:57 +02:00
commit
2c8cab9360
31 changed files with 251 additions and 91 deletions
|
@ -226,6 +226,7 @@
|
|||
var elRescaleDimensionsButton = document.getElementById("dimension-rescale-button");
|
||||
|
||||
var elParentID = document.getElementById("property-parent-id");
|
||||
var elParentJointIndex = document.getElementById("property-parent-joint-index");
|
||||
|
||||
var elRegistrationX = document.getElementById("property-reg-x");
|
||||
var elRegistrationY = document.getElementById("property-reg-y");
|
||||
|
@ -456,6 +457,7 @@
|
|||
elDimensionsZ.value = properties.dimensions.z.toFixed(2);
|
||||
|
||||
elParentID.value = properties.parentID;
|
||||
elParentJointIndex.value = properties.parentJointIndex;
|
||||
|
||||
elRegistrationX.value = properties.registrationPoint.x.toFixed(2);
|
||||
elRegistrationY.value = properties.registrationPoint.y.toFixed(2);
|
||||
|
@ -671,6 +673,7 @@
|
|||
elDimensionsZ.addEventListener('change', dimensionsChangeFunction);
|
||||
|
||||
elParentID.addEventListener('change', createEmitTextPropertyUpdateFunction('parentID'));
|
||||
elParentJointIndex.addEventListener('change', createEmitNumberPropertyUpdateFunction('parentJointIndex'));
|
||||
|
||||
var registrationChangeFunction = createEmitVec3PropertyUpdateFunction(
|
||||
'registrationPoint', elRegistrationX, elRegistrationY, elRegistrationZ);
|
||||
|
@ -1067,6 +1070,12 @@
|
|||
<input type="text" id="property-parent-id">
|
||||
</div>
|
||||
</div>
|
||||
<div class="property">
|
||||
<span class="label" style="float: left; margin-right: 6px">ParentJointIndex</span>
|
||||
<div class="value" style="overflow: hidden;">
|
||||
<input type="text" id="property-parent-joint-index">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="property">
|
||||
<div class="label">Registration</div>
|
||||
|
|
|
@ -2419,6 +2419,9 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt
|
|||
exportTree->addEntity(entityItem->getEntityItemID(), properties);
|
||||
}
|
||||
|
||||
// remap IDs on export so that we aren't publishing the IDs of entities in our domain
|
||||
exportTree->remapIDs();
|
||||
|
||||
exportTree->writeToJSONFile(filename.toLocal8Bit().constData());
|
||||
|
||||
// restore the main window's active state
|
||||
|
@ -2441,6 +2444,10 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
|
|||
properties.setPosition(properties.getPosition() - root);
|
||||
exportTree->addEntity(id, properties);
|
||||
}
|
||||
|
||||
// remap IDs on export so that we aren't publishing the IDs of entities in our domain
|
||||
exportTree->remapIDs();
|
||||
|
||||
exportTree->writeToSVOFile(filename.toLocal8Bit().constData());
|
||||
} else {
|
||||
qCDebug(interfaceapp) << "No models were selected";
|
||||
|
@ -2485,6 +2492,7 @@ bool Application::importEntities(const QString& urlOrFilename) {
|
|||
|
||||
bool success = _entityClipboard->readFromURL(url.toString());
|
||||
if (success) {
|
||||
_entityClipboard->remapIDs();
|
||||
_entityClipboard->reaverageOctreeElements();
|
||||
}
|
||||
return success;
|
||||
|
|
|
@ -201,6 +201,7 @@ void Avatar::simulate(float deltaTime) {
|
|||
_skeletonModel.getRig()->copyJointsFromJointData(_jointData);
|
||||
_skeletonModel.simulate(deltaTime, _hasNewJointRotations || _hasNewJointTranslations);
|
||||
simulateAttachments(deltaTime);
|
||||
locationChanged(); // joints changed, so if there are any children, update them.
|
||||
_hasNewJointRotations = false;
|
||||
_hasNewJointTranslations = false;
|
||||
}
|
||||
|
@ -868,6 +869,17 @@ glm::vec3 Avatar::getJointTranslation(int index) const {
|
|||
return translation;
|
||||
}
|
||||
|
||||
glm::quat Avatar::getAbsoluteJointRotationInObjectFrame(int index) const {
|
||||
glm::quat rotation;
|
||||
_skeletonModel.getAbsoluteJointRotationInRigFrame(index, rotation);
|
||||
return Quaternions::Y_180 * rotation;
|
||||
}
|
||||
|
||||
glm::vec3 Avatar::getAbsoluteJointTranslationInObjectFrame(int index) const {
|
||||
glm::vec3 translation;
|
||||
_skeletonModel.getAbsoluteJointTranslationInRigFrame(index, translation);
|
||||
return Quaternions::Y_180 * translation;
|
||||
}
|
||||
|
||||
int Avatar::getJointIndex(const QString& name) const {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
|
@ -1145,12 +1157,12 @@ glm::quat Avatar::getRightPalmRotation() {
|
|||
return rightRotation;
|
||||
}
|
||||
|
||||
void Avatar::setPosition(const glm::vec3 position) {
|
||||
void Avatar::setPosition(const glm::vec3& position) {
|
||||
AvatarData::setPosition(position);
|
||||
updateAttitude();
|
||||
}
|
||||
|
||||
void Avatar::setOrientation(const glm::quat orientation) {
|
||||
void Avatar::setOrientation(const glm::quat& orientation) {
|
||||
AvatarData::setOrientation(orientation);
|
||||
updateAttitude();
|
||||
}
|
||||
|
|
|
@ -108,6 +108,9 @@ public:
|
|||
virtual int getJointIndex(const QString& name) const;
|
||||
virtual QStringList getJointNames() const;
|
||||
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
||||
|
||||
virtual void setFaceModelURL(const QUrl& faceModelURL);
|
||||
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL);
|
||||
virtual void setAttachmentData(const QVector<AttachmentData>& attachmentData);
|
||||
|
@ -155,8 +158,8 @@ public:
|
|||
void setMotionState(AvatarMotionState* motionState) { _motionState = motionState; }
|
||||
AvatarMotionState* getMotionState() { return _motionState; }
|
||||
|
||||
virtual void setPosition(glm::vec3 position);
|
||||
virtual void setOrientation(glm::quat orientation);
|
||||
virtual void setPosition(const glm::vec3& position) override;
|
||||
virtual void setOrientation(const glm::quat& orientation) override;
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
|
@ -622,7 +622,8 @@ QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QS
|
|||
fileDialog.setAcceptMode(acceptMode);
|
||||
QUrl fileUrl(directory);
|
||||
if (acceptMode == QFileDialog::AcceptSave) {
|
||||
fileDialog.setFileMode(QFileDialog::Directory);
|
||||
// TODO -- Setting this breaks the dialog on Linux. Does it help something on other platforms?
|
||||
// fileDialog.setFileMode(QFileDialog::Directory);
|
||||
fileDialog.selectFile(fileUrl.fileName());
|
||||
}
|
||||
if (fileDialog.exec()) {
|
||||
|
|
|
@ -374,6 +374,16 @@ bool Rig::getJointRotation(int jointIndex, glm::quat& rotation) const {
|
|||
}
|
||||
}
|
||||
|
||||
bool Rig::getAbsoluteJointRotationInRigFrame(int jointIndex, glm::quat& rotation) const {
|
||||
QReadLocker readLock(&_externalPoseSetLock);
|
||||
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) {
|
||||
rotation = _externalPoseSet._absolutePoses[jointIndex].rot;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Rig::getJointTranslation(int jointIndex, glm::vec3& translation) const {
|
||||
QReadLocker readLock(&_externalPoseSetLock);
|
||||
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._relativePoses.size()) {
|
||||
|
@ -384,6 +394,16 @@ bool Rig::getJointTranslation(int jointIndex, glm::vec3& translation) const {
|
|||
}
|
||||
}
|
||||
|
||||
bool Rig::getAbsoluteJointTranslationInRigFrame(int jointIndex, glm::vec3& translation) const {
|
||||
QReadLocker readLock(&_externalPoseSetLock);
|
||||
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) {
|
||||
translation = _externalPoseSet._absolutePoses[jointIndex].trans;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Rig::getJointCombinedRotation(int jointIndex, glm::quat& result, const glm::quat& rotation) const {
|
||||
// AJT: TODO: used by attachments
|
||||
ASSERT(false);
|
||||
|
|
|
@ -129,10 +129,12 @@ public:
|
|||
|
||||
// geometry space (thread-safe)
|
||||
bool getJointRotation(int jointIndex, glm::quat& rotation) const;
|
||||
|
||||
// geometry space (thread-safe)
|
||||
bool getJointTranslation(int jointIndex, glm::vec3& translation) const;
|
||||
|
||||
// rig space (thread-safe)
|
||||
bool getAbsoluteJointRotationInRigFrame(int jointIndex, glm::quat& rotation) const;
|
||||
bool getAbsoluteJointTranslationInRigFrame(int jointIndex, glm::vec3& translation) const;
|
||||
|
||||
// legacy
|
||||
bool getJointCombinedRotation(int jointIndex, glm::quat& result, const glm::quat& rotation) const;
|
||||
|
||||
|
|
|
@ -1625,10 +1625,10 @@ void AvatarData::setBodyRoll(float bodyRoll) {
|
|||
setOrientation(glm::quat(glm::radians(eulerAngles)));
|
||||
}
|
||||
|
||||
void AvatarData::setPosition(const glm::vec3 position) {
|
||||
void AvatarData::setPosition(const glm::vec3& position) {
|
||||
SpatiallyNestable::setPosition(position);
|
||||
}
|
||||
|
||||
void AvatarData::setOrientation(const glm::quat orientation) {
|
||||
void AvatarData::setOrientation(const glm::quat& orientation) {
|
||||
SpatiallyNestable::setOrientation(orientation);
|
||||
}
|
||||
|
|
|
@ -201,8 +201,8 @@ public:
|
|||
float getBodyRoll() const;
|
||||
void setBodyRoll(float bodyRoll);
|
||||
|
||||
virtual void setPosition(glm::vec3 position);
|
||||
virtual void setOrientation(glm::quat orientation);
|
||||
virtual void setPosition(const glm::vec3& position) override;
|
||||
virtual void setOrientation(const glm::quat& orientation) override;
|
||||
|
||||
void nextAttitude(glm::vec3 position, glm::quat orientation); // Can be safely called at any time.
|
||||
void startCapture(); // start/end of the period in which the latest values are about to be captured for camera, etc.
|
||||
|
|
|
@ -44,7 +44,7 @@ RenderableModelEntityItem::~RenderableModelEntityItem() {
|
|||
}
|
||||
}
|
||||
|
||||
void RenderableModelEntityItem::setDimensions(const glm::vec3 value) {
|
||||
void RenderableModelEntityItem::setDimensions(const glm::vec3& value) {
|
||||
_dimensionsInitialized = true;
|
||||
ModelEntityItem::setDimensions(value);
|
||||
}
|
||||
|
@ -565,20 +565,20 @@ bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
glm::quat RenderableModelEntityItem::getJointRotation(int index) const {
|
||||
glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const {
|
||||
if (_model) {
|
||||
glm::quat result;
|
||||
if (_model->getJointRotation(index, result)) {
|
||||
if (_model->getAbsoluteJointRotationInRigFrame(index, result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return glm::quat();
|
||||
}
|
||||
|
||||
glm::vec3 RenderableModelEntityItem::getJointTranslation(int index) const {
|
||||
glm::vec3 RenderableModelEntityItem::getAbsoluteJointTranslationInObjectFrame(int index) const {
|
||||
if (_model) {
|
||||
glm::vec3 result;
|
||||
if (_model->getJointTranslation(index, result)) {
|
||||
if (_model->getAbsoluteJointTranslationInRigFrame(index, result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
virtual ~RenderableModelEntityItem();
|
||||
|
||||
virtual void setDimensions(const glm::vec3 value) override;
|
||||
virtual void setDimensions(const glm::vec3& value) override;
|
||||
|
||||
virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const override;
|
||||
virtual bool setProperties(const EntityItemProperties& properties) override;
|
||||
|
@ -67,9 +67,9 @@ public:
|
|||
|
||||
virtual bool contains(const glm::vec3& point) const override;
|
||||
|
||||
// these are in the frame of this object
|
||||
virtual glm::quat getJointRotation(int index) const override;
|
||||
virtual glm::vec3 getJointTranslation(int index) const override;
|
||||
// these are in the frame of this object (model space)
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
||||
|
||||
private:
|
||||
void remapTextures();
|
||||
|
|
|
@ -1192,7 +1192,7 @@ const Transform EntityItem::getTransformToCenter() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void EntityItem::setDimensions(const glm::vec3 value) {
|
||||
void EntityItem::setDimensions(const glm::vec3& value) {
|
||||
if (value.x <= 0.0f || value.y <= 0.0f || value.z <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ public:
|
|||
|
||||
/// Dimensions in meters (0.0 - TREE_SCALE)
|
||||
inline const glm::vec3 getDimensions() const { return getScale(); }
|
||||
virtual void setDimensions(const glm::vec3 value);
|
||||
virtual void setDimensions(const glm::vec3& value);
|
||||
|
||||
float getGlowLevel() const { return _glowLevel; }
|
||||
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
|
||||
|
@ -379,8 +379,8 @@ public:
|
|||
QList<EntityActionPointer> getActionsOfType(EntityActionType typeToGet);
|
||||
|
||||
// these are in the frame of this object
|
||||
virtual glm::quat getJointRotation(int index) const { return glm::quat(); }
|
||||
virtual glm::vec3 getJointTranslation(int index) const { return glm::vec3(0.0f); }
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override { return glm::quat(); }
|
||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override { return glm::vec3(0.0f); }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -1780,6 +1780,12 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
|||
if (zPNeighborIDChanged()) {
|
||||
out += "zPNeighborID";
|
||||
}
|
||||
if (parentIDChanged()) {
|
||||
out += "parentID";
|
||||
}
|
||||
if (parentJointIndexChanged()) {
|
||||
out += "parentJointIndex";
|
||||
}
|
||||
|
||||
getAnimation().listChangedProperties(out);
|
||||
getKeyLight().listChangedProperties(out);
|
||||
|
@ -1790,6 +1796,6 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
|||
return out;
|
||||
}
|
||||
|
||||
bool EntityItemProperties::parentDependentPropertyChanged() {
|
||||
bool EntityItemProperties::parentDependentPropertyChanged() const {
|
||||
return localPositionChanged() || positionChanged() || localRotationChanged() || rotationChanged();
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
{ return (float)(usecTimestampNow() - getLastEdited()) / (float)USECS_PER_SECOND; }
|
||||
EntityPropertyFlags getChangedProperties() const;
|
||||
|
||||
bool parentDependentPropertyChanged(); // was there a changed in a property that requires parent info to interpret?
|
||||
bool parentDependentPropertyChanged() const; // was there a changed in a property that requires parent info to interpret?
|
||||
|
||||
AACube getMaximumAACube() const;
|
||||
AABox getAABox() const;
|
||||
|
|
|
@ -64,7 +64,7 @@ void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {
|
|||
}
|
||||
}
|
||||
|
||||
EntityItemProperties convertLocationToScriptSemantics(EntityItemProperties entitySideProperties) {
|
||||
EntityItemProperties convertLocationToScriptSemantics(const EntityItemProperties& entitySideProperties) {
|
||||
// In EntityTree code, properties.position and properties.rotation are relative to the parent. In javascript,
|
||||
// they are in world-space. The local versions are put into localPosition and localRotation and position and
|
||||
// rotation are converted from local to world space.
|
||||
|
@ -85,7 +85,7 @@ EntityItemProperties convertLocationToScriptSemantics(EntityItemProperties entit
|
|||
}
|
||||
|
||||
|
||||
EntityItemProperties convertLocationFromScriptSemantics(EntityItemProperties scriptSideProperties) {
|
||||
EntityItemProperties convertLocationFromScriptSemantics(const EntityItemProperties& scriptSideProperties) {
|
||||
// convert position and rotation properties from world-space to local, unless localPosition and localRotation
|
||||
// are set. If they are set, they overwrite position and rotation.
|
||||
EntityItemProperties entitySideProperties = scriptSideProperties;
|
||||
|
@ -190,7 +190,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit
|
|||
return convertLocationToScriptSemantics(results);
|
||||
}
|
||||
|
||||
QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties scriptSideProperties) {
|
||||
QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) {
|
||||
EntityItemProperties properties = scriptSideProperties;
|
||||
EntityItemID entityID(id);
|
||||
// If we have a local entity tree set, then also update it.
|
||||
|
@ -201,17 +201,25 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script
|
|||
|
||||
bool updatedEntity = false;
|
||||
_entityTree->withWriteLock([&] {
|
||||
if (scriptSideProperties.parentDependentPropertyChanged()) {
|
||||
// if the script sets a location property but didn't include parent information, grab the needed
|
||||
// properties from the entity.
|
||||
if (!scriptSideProperties.parentIDChanged() || !scriptSideProperties.parentJointIndexChanged()) {
|
||||
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
|
||||
if (entity && !scriptSideProperties.parentIDChanged()) {
|
||||
properties.setParentID(entity->getParentID());
|
||||
}
|
||||
if (entity && !scriptSideProperties.parentJointIndexChanged()) {
|
||||
properties.setParentJointIndex(entity->getParentJointIndex());
|
||||
}
|
||||
if (scriptSideProperties.parentDependentPropertyChanged() ||
|
||||
scriptSideProperties.parentIDChanged() || scriptSideProperties.parentJointIndexChanged()) {
|
||||
// All of parentID, parentJointIndex, position, rotation are needed to make sense of any of them.
|
||||
// If any of these changed, pull any missing properties from the entity.
|
||||
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
|
||||
if (!entity) {
|
||||
return;
|
||||
}
|
||||
if (!scriptSideProperties.parentIDChanged()) {
|
||||
properties.setParentID(entity->getParentID());
|
||||
}
|
||||
if (!scriptSideProperties.parentJointIndexChanged()) {
|
||||
properties.setParentJointIndex(entity->getParentJointIndex());
|
||||
}
|
||||
if (!scriptSideProperties.localPositionChanged() && !scriptSideProperties.positionChanged()) {
|
||||
properties.setPosition(entity->getPosition());
|
||||
}
|
||||
if (!scriptSideProperties.localRotationChanged() && !scriptSideProperties.rotationChanged()) {
|
||||
properties.setRotation(entity->getOrientation());
|
||||
}
|
||||
}
|
||||
properties = convertLocationFromScriptSemantics(properties);
|
||||
|
@ -801,19 +809,19 @@ glm::vec3 EntityScriptingInterface::localCoordsToVoxelCoords(const QUuid& entity
|
|||
}
|
||||
}
|
||||
|
||||
glm::vec3 EntityScriptingInterface::getJointTranslation(const QUuid& entityID, int jointIndex) {
|
||||
glm::vec3 EntityScriptingInterface::getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
return modelEntity->getJointTranslation(jointIndex);
|
||||
return modelEntity->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||
} else {
|
||||
return glm::vec3(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
glm::quat EntityScriptingInterface::getJointRotation(const QUuid& entityID, int jointIndex) {
|
||||
glm::quat EntityScriptingInterface::getAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
return modelEntity->getJointRotation(jointIndex);
|
||||
return modelEntity->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
||||
} else {
|
||||
return glm::quat();
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public slots:
|
|||
|
||||
/// edits a model updating only the included properties, will return the identified EntityItemID in case of
|
||||
/// successful edit, if the input entityID is for an unknown model this function will have no effect
|
||||
Q_INVOKABLE QUuid editEntity(QUuid entityID, EntityItemProperties properties);
|
||||
Q_INVOKABLE QUuid editEntity(QUuid entityID, const EntityItemProperties& properties);
|
||||
|
||||
/// deletes a model
|
||||
Q_INVOKABLE void deleteEntity(QUuid entityID);
|
||||
|
@ -148,9 +148,9 @@ public slots:
|
|||
Q_INVOKABLE glm::vec3 worldCoordsToVoxelCoords(const QUuid& entityID, glm::vec3 worldCoords);
|
||||
Q_INVOKABLE glm::vec3 voxelCoordsToLocalCoords(const QUuid& entityID, glm::vec3 voxelCoords);
|
||||
Q_INVOKABLE glm::vec3 localCoordsToVoxelCoords(const QUuid& entityID, glm::vec3 localCoords);
|
||||
|
||||
Q_INVOKABLE glm::vec3 getJointTranslation(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE glm::quat getJointRotation(const QUuid& entityID, int jointIndex);
|
||||
|
||||
Q_INVOKABLE glm::vec3 getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE glm::quat getAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex);
|
||||
|
||||
signals:
|
||||
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "EntitiesLogging.h"
|
||||
#include "RecurseOctreeToMapOperator.h"
|
||||
#include "LogHandler.h"
|
||||
#include "RemapIDOperator.h"
|
||||
|
||||
static const quint64 DELETED_ENTITIES_EXTRA_USECS_TO_CONSIDER = USECS_PER_MSEC * 50;
|
||||
|
||||
|
@ -740,6 +741,14 @@ void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<Q
|
|||
changedProperties[index] = QString("userData:") + changeHint;
|
||||
}
|
||||
}
|
||||
|
||||
if (properties.parentJointIndexChanged()) {
|
||||
int index = changedProperties.indexOf("parentJointIndex");
|
||||
if (index >= 0) {
|
||||
quint16 value = properties.getParentJointIndex();
|
||||
changedProperties[index] = QString("parentJointIndex:") + QString::number((int)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned char* editData, int maxLength,
|
||||
|
@ -1186,6 +1195,11 @@ bool EntityTree::sendEntitiesOperation(OctreeElementPointer element, void* extra
|
|||
return true;
|
||||
}
|
||||
|
||||
void EntityTree::remapIDs() {
|
||||
RemapIDOperator theOperator;
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
}
|
||||
|
||||
bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues) {
|
||||
if (! entityDescription.contains("Entities")) {
|
||||
entityDescription["Entities"] = QVariantList();
|
||||
|
|
|
@ -196,6 +196,8 @@ public:
|
|||
bool wantTerseEditLogging() const { return _wantTerseEditLogging; }
|
||||
void setWantTerseEditLogging(bool value) { _wantTerseEditLogging = value; }
|
||||
|
||||
void remapIDs();
|
||||
|
||||
bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues);
|
||||
bool readFromMap(QVariantMap& entityDescription);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ LightEntityItem::LightEntityItem(const EntityItemID& entityItemID) : EntityItem(
|
|||
_cutoff = PI;
|
||||
}
|
||||
|
||||
void LightEntityItem::setDimensions(const glm::vec3 value) {
|
||||
void LightEntityItem::setDimensions(const glm::vec3& value) {
|
||||
if (_isSpotlight) {
|
||||
// If we are a spotlight, treat the z value as our radius or length, and
|
||||
// recalculate the x/y dimensions to properly encapsulate the spotlight.
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
|
||||
virtual void setDimensions(const glm::vec3 value);
|
||||
virtual void setDimensions(const glm::vec3& value);
|
||||
|
||||
// methods for getting/setting all properties of an entity
|
||||
virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const;
|
||||
|
|
33
libraries/entities/src/RemapIDOperator.cpp
Normal file
33
libraries/entities/src/RemapIDOperator.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// RemapIDOperator.cpp
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Seth Alves on 2015-12-6.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
#include "EntityTree.h"
|
||||
#include "RemapIDOperator.h"
|
||||
|
||||
QUuid RemapIDOperator::remap(const QUuid& oldID) {
|
||||
if (oldID.isNull()) {
|
||||
return oldID;
|
||||
}
|
||||
if (!_oldToNew.contains(oldID)) {
|
||||
_oldToNew[oldID] = QUuid::createUuid();
|
||||
}
|
||||
return _oldToNew[oldID];
|
||||
}
|
||||
|
||||
bool RemapIDOperator::postRecursion(OctreeElementPointer element) {
|
||||
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
|
||||
entityTreeElement->forEachEntity([&](EntityItemPointer entityItem) {
|
||||
entityItem->setID(remap(entityItem->getID()));
|
||||
entityItem->setParentID(remap(entityItem->getParentID()));
|
||||
});
|
||||
return true;
|
||||
}
|
30
libraries/entities/src/RemapIDOperator.h
Normal file
30
libraries/entities/src/RemapIDOperator.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// RemapIDOperator.h
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Seth Alves on 2015-12-6.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_RemapIDOperator_h
|
||||
#define hifi_RemapIDOperator_h
|
||||
|
||||
#include "Octree.h"
|
||||
|
||||
// this will change all the IDs in an EntityTree. Parent/Child relationships are maintained.
|
||||
|
||||
class RemapIDOperator : public RecurseOctreeOperator {
|
||||
public:
|
||||
RemapIDOperator() : RecurseOctreeOperator() {}
|
||||
~RemapIDOperator() {}
|
||||
virtual bool preRecursion(OctreeElementPointer element) { return true; }
|
||||
virtual bool postRecursion(OctreeElementPointer element);
|
||||
private:
|
||||
QUuid remap(const QUuid& oldID);
|
||||
QHash<QUuid, QUuid> _oldToNew;
|
||||
};
|
||||
|
||||
#endif // hifi_RemapIDOperator_h
|
|
@ -41,7 +41,7 @@ TextEntityItem::TextEntityItem(const EntityItemID& entityItemID) : EntityItem(en
|
|||
|
||||
const float TEXT_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
|
||||
|
||||
void TextEntityItem::setDimensions(const glm::vec3 value) {
|
||||
void TextEntityItem::setDimensions(const glm::vec3& value) {
|
||||
// NOTE: Text Entities always have a "depth" of 1cm.
|
||||
EntityItem::setDimensions(glm::vec3(value.x, value.y, TEXT_ENTITY_ITEM_FIXED_DEPTH));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
|
||||
virtual void setDimensions(const glm::vec3 value);
|
||||
virtual void setDimensions(const glm::vec3& value);
|
||||
virtual ShapeType getShapeType() const { return SHAPE_TYPE_BOX; }
|
||||
|
||||
// methods for getting/setting all properties of an entity
|
||||
|
|
|
@ -34,7 +34,7 @@ WebEntityItem::WebEntityItem(const EntityItemID& entityItemID) : EntityItem(enti
|
|||
|
||||
const float WEB_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
|
||||
|
||||
void WebEntityItem::setDimensions(const glm::vec3 value) {
|
||||
void WebEntityItem::setDimensions(const glm::vec3& value) {
|
||||
// NOTE: Web Entities always have a "depth" of 1cm.
|
||||
EntityItem::setDimensions(glm::vec3(value.x, value.y, WEB_ENTITY_ITEM_FIXED_DEPTH));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
|
||||
virtual void setDimensions(const glm::vec3 value);
|
||||
virtual void setDimensions(const glm::vec3& value);
|
||||
virtual ShapeType getShapeType() const { return SHAPE_TYPE_BOX; }
|
||||
|
||||
// methods for getting/setting all properties of an entity
|
||||
|
|
|
@ -766,6 +766,14 @@ bool Model::getJointTranslation(int jointIndex, glm::vec3& translation) const {
|
|||
return _rig->getJointTranslation(jointIndex, translation);
|
||||
}
|
||||
|
||||
bool Model::getAbsoluteJointRotationInRigFrame(int jointIndex, glm::quat& rotation) const {
|
||||
return _rig->getAbsoluteJointRotationInRigFrame(jointIndex, rotation);
|
||||
}
|
||||
|
||||
bool Model::getAbsoluteJointTranslationInRigFrame(int jointIndex, glm::vec3& translation) const {
|
||||
return _rig->getAbsoluteJointTranslationInRigFrame(jointIndex, translation);
|
||||
}
|
||||
|
||||
bool Model::getJointCombinedRotation(int jointIndex, glm::quat& rotation) const {
|
||||
return _rig->getJointCombinedRotation(jointIndex, rotation, _rotation);
|
||||
}
|
||||
|
|
|
@ -166,6 +166,10 @@ public:
|
|||
bool getJointRotation(int jointIndex, glm::quat& rotation) const;
|
||||
bool getJointTranslation(int jointIndex, glm::vec3& translation) const;
|
||||
|
||||
// model frame
|
||||
bool getAbsoluteJointRotationInRigFrame(int jointIndex, glm::quat& rotation) const;
|
||||
bool getAbsoluteJointTranslationInRigFrame(int jointIndex, glm::vec3& translation) const;
|
||||
|
||||
/// Returns the index of the parent of the indexed joint, or -1 if not found.
|
||||
int getParentJointIndex(int jointIndex) const;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void SpatiallyNestable::forgetChild(SpatiallyNestablePointer newChild) const {
|
|||
});
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setParentID(const QUuid parentID) {
|
||||
void SpatiallyNestable::setParentID(const QUuid& parentID) {
|
||||
if (_parentID != parentID) {
|
||||
_parentID = parentID;
|
||||
_parentKnowsMe = false;
|
||||
|
@ -99,7 +99,7 @@ void SpatiallyNestable::setParentID(const QUuid parentID) {
|
|||
parentChanged();
|
||||
}
|
||||
|
||||
glm::vec3 SpatiallyNestable::worldToLocal(glm::vec3 position, QUuid parentID, int parentJointIndex) {
|
||||
glm::vec3 SpatiallyNestable::worldToLocal(const glm::vec3& position, const QUuid& parentID, int parentJointIndex) {
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
Transform parentTransform;
|
||||
if (parentFinder) {
|
||||
|
@ -122,7 +122,7 @@ glm::vec3 SpatiallyNestable::worldToLocal(glm::vec3 position, QUuid parentID, in
|
|||
return result.getTranslation();
|
||||
}
|
||||
|
||||
glm::quat SpatiallyNestable::worldToLocal(glm::quat orientation, QUuid parentID, int parentJointIndex) {
|
||||
glm::quat SpatiallyNestable::worldToLocal(const glm::quat& orientation, const QUuid& parentID, int parentJointIndex) {
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
Transform parentTransform;
|
||||
if (parentFinder) {
|
||||
|
@ -144,7 +144,7 @@ glm::quat SpatiallyNestable::worldToLocal(glm::quat orientation, QUuid parentID,
|
|||
return result.getRotation();
|
||||
}
|
||||
|
||||
glm::vec3 SpatiallyNestable::localToWorld(glm::vec3 position, QUuid parentID, int parentJointIndex) {
|
||||
glm::vec3 SpatiallyNestable::localToWorld(const glm::vec3& position, const QUuid& parentID, int parentJointIndex) {
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
Transform parentTransform;
|
||||
if (parentFinder) {
|
||||
|
@ -162,7 +162,7 @@ glm::vec3 SpatiallyNestable::localToWorld(glm::vec3 position, QUuid parentID, in
|
|||
return result.getTranslation();
|
||||
}
|
||||
|
||||
glm::quat SpatiallyNestable::localToWorld(glm::quat orientation, QUuid parentID, int parentJointIndex) {
|
||||
glm::quat SpatiallyNestable::localToWorld(const glm::quat& orientation, const QUuid& parentID, int parentJointIndex) {
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
Transform parentTransform;
|
||||
if (parentFinder) {
|
||||
|
@ -188,7 +188,7 @@ glm::vec3 SpatiallyNestable::getPosition(int jointIndex) const {
|
|||
return getTransform(jointIndex).getTranslation();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setPosition(glm::vec3 position) {
|
||||
void SpatiallyNestable::setPosition(const glm::vec3& position) {
|
||||
Transform parentTransform = getParentTransform();
|
||||
Transform myWorldTransform;
|
||||
_transformLock.withWriteLock([&] {
|
||||
|
@ -207,7 +207,7 @@ glm::quat SpatiallyNestable::getOrientation(int jointIndex) const {
|
|||
return getTransform(jointIndex).getRotation();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setOrientation(glm::quat orientation) {
|
||||
void SpatiallyNestable::setOrientation(const glm::quat& orientation) {
|
||||
Transform parentTransform = getParentTransform();
|
||||
Transform myWorldTransform;
|
||||
_transformLock.withWriteLock([&] {
|
||||
|
@ -232,13 +232,13 @@ const Transform SpatiallyNestable::getTransform(int jointIndex) const {
|
|||
// this returns the world-space transform for this object. It finds its parent's transform (which may
|
||||
// cause this object's parent to query its parent, etc) and multiplies this object's local transform onto it.
|
||||
Transform worldTransform = getTransform();
|
||||
Transform jointInObjectFrame = getJointTransformInObjectFrame(jointIndex);
|
||||
Transform jointInObjectFrame = getAbsoluteJointTransformInObjectFrame(jointIndex);
|
||||
Transform jointInWorldFrame;
|
||||
Transform::mult(jointInWorldFrame, worldTransform, jointInObjectFrame);
|
||||
return jointInWorldFrame;
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setTransform(const Transform transform) {
|
||||
void SpatiallyNestable::setTransform(const Transform& transform) {
|
||||
Transform parentTransform = getParentTransform();
|
||||
_transformLock.withWriteLock([&] {
|
||||
Transform::inverseMult(_transform, parentTransform, transform);
|
||||
|
@ -259,7 +259,7 @@ glm::vec3 SpatiallyNestable::getScale(int jointIndex) const {
|
|||
return getScale();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setScale(glm::vec3 scale) {
|
||||
void SpatiallyNestable::setScale(const glm::vec3& scale) {
|
||||
_transformLock.withWriteLock([&] {
|
||||
_transform.setScale(scale);
|
||||
});
|
||||
|
@ -274,7 +274,7 @@ const Transform SpatiallyNestable::getLocalTransform() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setLocalTransform(const Transform transform) {
|
||||
void SpatiallyNestable::setLocalTransform(const Transform& transform) {
|
||||
_transformLock.withWriteLock([&] {
|
||||
_transform = transform;
|
||||
});
|
||||
|
@ -289,7 +289,7 @@ glm::vec3 SpatiallyNestable::getLocalPosition() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setLocalPosition(glm::vec3 position) {
|
||||
void SpatiallyNestable::setLocalPosition(const glm::vec3& position) {
|
||||
_transformLock.withWriteLock([&] {
|
||||
_transform.setTranslation(position);
|
||||
});
|
||||
|
@ -304,7 +304,7 @@ glm::quat SpatiallyNestable::getLocalOrientation() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setLocalOrientation(glm::quat orientation) {
|
||||
void SpatiallyNestable::setLocalOrientation(const glm::quat& orientation) {
|
||||
_transformLock.withWriteLock([&] {
|
||||
_transform.setRotation(orientation);
|
||||
});
|
||||
|
@ -319,7 +319,7 @@ glm::vec3 SpatiallyNestable::getLocalScale() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setLocalScale(glm::vec3 scale) {
|
||||
void SpatiallyNestable::setLocalScale(const glm::vec3& scale) {
|
||||
_transformLock.withWriteLock([&] {
|
||||
_transform.setScale(scale);
|
||||
});
|
||||
|
@ -339,13 +339,13 @@ QList<SpatiallyNestablePointer> SpatiallyNestable::getChildren() const {
|
|||
return children;
|
||||
}
|
||||
|
||||
const Transform SpatiallyNestable::getJointTransformInObjectFrame(int jointIndex) const {
|
||||
Transform jointInObjectFrame;
|
||||
glm::vec3 position = getJointTranslation(jointIndex);
|
||||
glm::quat orientation = getJointRotation(jointIndex);
|
||||
jointInObjectFrame.setRotation(orientation);
|
||||
jointInObjectFrame.setTranslation(position);
|
||||
return jointInObjectFrame;
|
||||
const Transform SpatiallyNestable::getAbsoluteJointTransformInObjectFrame(int jointIndex) const {
|
||||
Transform jointTransformInObjectFrame;
|
||||
glm::vec3 position = getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||
glm::quat orientation = getAbsoluteJointRotationInObjectFrame(jointIndex);
|
||||
jointTransformInObjectFrame.setRotation(orientation);
|
||||
jointTransformInObjectFrame.setTranslation(position);
|
||||
return jointTransformInObjectFrame;
|
||||
}
|
||||
|
||||
SpatiallyNestablePointer SpatiallyNestable::getThisPointer() const {
|
||||
|
|
|
@ -42,32 +42,32 @@ public:
|
|||
virtual void setID(const QUuid& id) { _id = id; }
|
||||
|
||||
virtual const QUuid getParentID() const { return _parentID; }
|
||||
virtual void setParentID(const QUuid parentID);
|
||||
virtual void setParentID(const QUuid& parentID);
|
||||
|
||||
virtual quint16 getParentJointIndex() const { return _parentJointIndex; }
|
||||
virtual void setParentJointIndex(quint16 parentJointIndex) { _parentJointIndex = parentJointIndex; }
|
||||
|
||||
static glm::vec3 worldToLocal(glm::vec3 position, QUuid parentID, int parentJointIndex);
|
||||
static glm::quat worldToLocal(glm::quat orientation, QUuid parentID, int 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);
|
||||
|
||||
static glm::vec3 localToWorld(glm::vec3 position, QUuid parentID, int parentJointIndex);
|
||||
static glm::quat localToWorld(glm::quat orientation, QUuid parentID, int parentJointIndex);
|
||||
static glm::vec3 localToWorld(const glm::vec3& position, const QUuid& parentID, int parentJointIndex);
|
||||
static glm::quat localToWorld(const glm::quat& orientation, const QUuid& parentID, int parentJointIndex);
|
||||
|
||||
// world frame
|
||||
virtual const Transform getTransform() const;
|
||||
virtual void setTransform(const Transform transform);
|
||||
virtual void setTransform(const Transform& transform);
|
||||
|
||||
virtual Transform getParentTransform() const;
|
||||
|
||||
virtual glm::vec3 getPosition() const;
|
||||
virtual void setPosition(glm::vec3 position);
|
||||
virtual void setPosition(const glm::vec3& position);
|
||||
|
||||
virtual glm::quat getOrientation() const;
|
||||
virtual glm::quat getOrientation(int jointIndex) const;
|
||||
virtual void setOrientation(glm::quat orientation);
|
||||
virtual void setOrientation(const glm::quat& orientation);
|
||||
|
||||
virtual glm::vec3 getScale() const;
|
||||
virtual void setScale(glm::vec3 scale);
|
||||
virtual void setScale(const glm::vec3& scale);
|
||||
|
||||
// get world-frame values for a specific joint
|
||||
virtual const Transform getTransform(int jointIndex) const;
|
||||
|
@ -76,24 +76,24 @@ public:
|
|||
|
||||
// object's parent's frame
|
||||
virtual const Transform getLocalTransform() const;
|
||||
virtual void setLocalTransform(const Transform transform);
|
||||
virtual void setLocalTransform(const Transform& transform);
|
||||
|
||||
virtual glm::vec3 getLocalPosition() const;
|
||||
virtual void setLocalPosition(glm::vec3 position);
|
||||
virtual void setLocalPosition(const glm::vec3& position);
|
||||
|
||||
virtual glm::quat getLocalOrientation() const;
|
||||
virtual void setLocalOrientation(glm::quat orientation);
|
||||
virtual void setLocalOrientation(const glm::quat& orientation);
|
||||
|
||||
virtual glm::vec3 getLocalScale() const;
|
||||
virtual void setLocalScale(glm::vec3 scale);
|
||||
virtual void setLocalScale(const glm::vec3& scale);
|
||||
|
||||
QList<SpatiallyNestablePointer> getChildren() const;
|
||||
NestableTypes::NestableType getNestableType() const { return _nestableType; }
|
||||
|
||||
// this object's frame
|
||||
virtual const Transform getJointTransformInObjectFrame(int jointIndex) const;
|
||||
virtual glm::quat getJointRotation(int index) const { assert(false); return glm::quat(); }
|
||||
virtual glm::vec3 getJointTranslation(int index) const { assert(false); return glm::vec3(); }
|
||||
virtual const Transform getAbsoluteJointTransformInObjectFrame(int jointIndex) const;
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const { assert(false); return glm::quat(); }
|
||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const { assert(false); return glm::vec3(); }
|
||||
|
||||
SpatiallyNestablePointer getThisPointer() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue