mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:40:11 +02:00
add a way to get a SpatiallyNestable's name without knowing what its type is
This commit is contained in:
parent
ed09dcbdc9
commit
69944cc76d
6 changed files with 30 additions and 2 deletions
|
@ -81,6 +81,10 @@ QVariantMap convertOverlayLocationFromScriptSemantics(const QVariantMap& propert
|
||||||
void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
||||||
QVariantMap properties = originalProperties;
|
QVariantMap properties = originalProperties;
|
||||||
|
|
||||||
|
if (properties["name"].isValid()) {
|
||||||
|
setName(properties["name"].toString());
|
||||||
|
}
|
||||||
|
|
||||||
// carry over some legacy keys
|
// carry over some legacy keys
|
||||||
if (!properties["position"].isValid() && !properties["localPosition"].isValid()) {
|
if (!properties["position"].isValid() && !properties["localPosition"].isValid()) {
|
||||||
if (properties["p1"].isValid()) {
|
if (properties["p1"].isValid()) {
|
||||||
|
@ -207,6 +211,9 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant Base3DOverlay::getProperty(const QString& property) {
|
QVariant Base3DOverlay::getProperty(const QString& property) {
|
||||||
|
if (property == "name") {
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
if (property == "position" || property == "start" || property == "p1" || property == "point") {
|
if (property == "position" || property == "start" || property == "p1" || property == "point") {
|
||||||
return vec3toVariant(getPosition());
|
return vec3toVariant(getPosition());
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ public:
|
||||||
virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); }
|
virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); }
|
||||||
void setOverlayID(OverlayID overlayID) override { setID(overlayID); }
|
void setOverlayID(OverlayID overlayID) override { setID(overlayID); }
|
||||||
|
|
||||||
|
virtual QString getName() const override { return QString("Overlay:") + _name; }
|
||||||
|
void setName(QString name) { _name = name; }
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
virtual bool is3D() const override { return true; }
|
virtual bool is3D() const override { return true; }
|
||||||
|
|
||||||
|
@ -74,6 +77,8 @@ protected:
|
||||||
bool _drawInFront;
|
bool _drawInFront;
|
||||||
bool _isAA;
|
bool _isAA;
|
||||||
bool _isGrabbable { false };
|
bool _isGrabbable { false };
|
||||||
|
|
||||||
|
QString _name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Base3DOverlay_h
|
#endif // hifi_Base3DOverlay_h
|
||||||
|
|
|
@ -357,6 +357,8 @@ class AvatarData : public QObject, public SpatiallyNestable {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual QString getName() const override { return QString("Avatar:") + _displayName; }
|
||||||
|
|
||||||
static const QString FRAME_NAME;
|
static const QString FRAME_NAME;
|
||||||
|
|
||||||
static void fromFrame(const QByteArray& frameData, AvatarData& avatar, bool useFrameSkeleton = true);
|
static void fromFrame(const QByteArray& frameData, AvatarData& avatar, bool useFrameSkeleton = true);
|
||||||
|
|
|
@ -281,7 +281,7 @@ public:
|
||||||
float getAngularDamping() const;
|
float getAngularDamping() const;
|
||||||
void setAngularDamping(float value);
|
void setAngularDamping(float value);
|
||||||
|
|
||||||
QString getName() const;
|
virtual QString getName() const override;
|
||||||
void setName(const QString& value);
|
void setName(const QString& value);
|
||||||
QString getDebugName();
|
QString getDebugName();
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,19 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
||||||
if (entityFound) {
|
if (entityFound) {
|
||||||
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(entities) << "attempted edit on unknown entity: " << id;
|
QString name = "unknown";
|
||||||
|
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||||
|
if (parentFinder) {
|
||||||
|
bool success;
|
||||||
|
auto nestableWP = parentFinder->find(id, success, static_cast<SpatialParentTree*>(_entityTree.get()));
|
||||||
|
if (success) {
|
||||||
|
auto nestable = nestableWP.lock();
|
||||||
|
if (nestable) {
|
||||||
|
name = nestable->getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qCWarning(entities) << "attempted edit on unknown entity: " << id << name;
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ public:
|
||||||
virtual const QUuid getID() const;
|
virtual const QUuid getID() const;
|
||||||
virtual void setID(const QUuid& id);
|
virtual void setID(const QUuid& id);
|
||||||
|
|
||||||
|
virtual QString getName() const { return "SpatiallyNestable"; }
|
||||||
|
|
||||||
virtual const QUuid getParentID() const;
|
virtual const QUuid getParentID() const;
|
||||||
virtual void setParentID(const QUuid& parentID);
|
virtual void setParentID(const QUuid& parentID);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue