mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Merge pull request #6864 from sethalves/js-list-entity-joint-names
expose getJointNames for entities to js
This commit is contained in:
commit
42ac96607a
7 changed files with 50 additions and 8 deletions
|
@ -772,8 +772,14 @@ int RenderableModelEntityItem::getJointIndex(const QString& name) const {
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// TODO -- expose a way to list joint names
|
||||
// RenderableModelEntityItem::QStringList getJointNames() const {
|
||||
// rig->nameOfJoint(i);
|
||||
// }
|
||||
QStringList RenderableModelEntityItem::getJointNames() const {
|
||||
QStringList result;
|
||||
if (_model && _model->isActive()) {
|
||||
RigPointer rig = _model->getRig();
|
||||
int jointCount = rig->getJointStateCount();
|
||||
for (int jointIndex = 0; jointIndex < jointCount; jointIndex++) {
|
||||
result << rig->nameOfJoint(jointIndex);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
virtual void resizeJointArrays(int newSize = -1) override;
|
||||
|
||||
virtual int getJointIndex(const QString& name) const override;
|
||||
virtual QStringList getJointNames() const override;
|
||||
|
||||
private:
|
||||
QVariantMap parseTexturesToMap(QString textures);
|
||||
|
|
|
@ -396,6 +396,7 @@ public:
|
|||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override { return false; }
|
||||
|
||||
virtual int getJointIndex(const QString& name) const { return -1; }
|
||||
virtual QStringList getJointNames() const { return QStringList(); }
|
||||
|
||||
virtual void loader() {} // called indirectly when urls for geometry are updated
|
||||
|
||||
|
|
|
@ -977,6 +977,18 @@ int EntityScriptingInterface::getJointIndex(const QUuid& entityID, const QString
|
|||
if (!_entityTree) {
|
||||
return -1;
|
||||
}
|
||||
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
|
||||
return entity->getJointIndex(name);
|
||||
int result;
|
||||
QMetaObject::invokeMethod(_entityTree.get(), "getJointIndex", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(int, result), Q_ARG(QUuid, entityID), Q_ARG(QString, name));
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) {
|
||||
if (!_entityTree) {
|
||||
return QStringList();
|
||||
}
|
||||
QStringList result;
|
||||
QMetaObject::invokeMethod(_entityTree.get(), "getJointNames", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(QStringList, result), Q_ARG(QUuid, entityID));
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ public slots:
|
|||
const QVector<glm::vec3>& translations);
|
||||
|
||||
Q_INVOKABLE int getJointIndex(const QUuid& entityID, const QString& name);
|
||||
Q_INVOKABLE QStringList getJointNames(const QUuid& entityID);
|
||||
|
||||
signals:
|
||||
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
|
|
@ -1358,7 +1358,6 @@ void EntityTree::trackIncomingEntityLastEdited(quint64 lastEditedTime, int bytes
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void EntityTree::callLoader(EntityItemID entityID) {
|
||||
// this is used to bounce from the networking thread to the main thread
|
||||
EntityItemPointer entity = findEntityByEntityItemID(entityID);
|
||||
|
@ -1366,3 +1365,21 @@ void EntityTree::callLoader(EntityItemID entityID) {
|
|||
entity->loader();
|
||||
}
|
||||
}
|
||||
|
||||
int EntityTree::getJointIndex(const QUuid& entityID, const QString& name) const {
|
||||
EntityTree* nonConstThis = const_cast<EntityTree*>(this);
|
||||
EntityItemPointer entity = nonConstThis->findEntityByEntityItemID(entityID);
|
||||
if (!entity) {
|
||||
return -1;
|
||||
}
|
||||
return entity->getJointIndex(name);
|
||||
}
|
||||
|
||||
QStringList EntityTree::getJointNames(const QUuid& entityID) const {
|
||||
EntityTree* nonConstThis = const_cast<EntityTree*>(this);
|
||||
EntityItemPointer entity = nonConstThis->findEntityByEntityItemID(entityID);
|
||||
if (!entity) {
|
||||
return QStringList();
|
||||
}
|
||||
return entity->getJointNames();
|
||||
}
|
||||
|
|
|
@ -236,6 +236,10 @@ public:
|
|||
return _deletedEntityItemIDs.contains(id);
|
||||
}
|
||||
|
||||
// these are used to call through to EntityItems
|
||||
Q_INVOKABLE int getJointIndex(const QUuid& entityID, const QString& name) const;
|
||||
Q_INVOKABLE QStringList getJointNames(const QUuid& entityID) const;
|
||||
|
||||
public slots:
|
||||
void callLoader(EntityItemID entityID);
|
||||
|
||||
|
|
Loading…
Reference in a new issue