mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Add ability to paste entities to any host type. Default "domain"
This commit is contained in:
parent
82638e47c4
commit
12446bdb45
6 changed files with 17 additions and 9 deletions
|
@ -4065,7 +4065,7 @@ std::map<QString, QString> Application::prepareServerlessDomainContents(QUrl dom
|
||||||
bool success = tmpTree->readFromByteArray(domainURL.toString(), data);
|
bool success = tmpTree->readFromByteArray(domainURL.toString(), data);
|
||||||
if (success) {
|
if (success) {
|
||||||
tmpTree->reaverageOctreeElements();
|
tmpTree->reaverageOctreeElements();
|
||||||
tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), 0, 0, 0);
|
tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), nullptr, 0, 0, 0);
|
||||||
}
|
}
|
||||||
std::map<QString, QString> namedPaths = tmpTree->getNamedPaths();
|
std::map<QString, QString> namedPaths = tmpTree->getNamedPaths();
|
||||||
|
|
||||||
|
@ -5545,8 +5545,8 @@ bool Application::importEntities(const QString& urlOrFilename, const bool isObse
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<EntityItemID> Application::pasteEntities(float x, float y, float z) {
|
QVector<EntityItemID> Application::pasteEntities(QString entityHostType, float x, float y, float z) {
|
||||||
return _entityClipboard->sendEntities(&_entityEditSender, getEntities()->getTree(), x, y, z);
|
return _entityClipboard->sendEntities(&_entityEditSender, getEntities()->getTree(), entityHostType, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::init() {
|
void Application::init() {
|
||||||
|
|
|
@ -375,7 +375,7 @@ signals:
|
||||||
void awayStateWhenFocusLostInVRChanged(bool enabled);
|
void awayStateWhenFocusLostInVRChanged(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
QVector<EntityItemID> pasteEntities(QString entityHostType, float x, float y, float z);
|
||||||
bool exportEntities(const QString& filename, const QVector<QUuid>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
bool exportEntities(const QString& filename, const QVector<QUuid>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
||||||
bool exportEntities(const QString& filename, float x, float y, float z, float scale);
|
bool exportEntities(const QString& filename, float x, float y, float z, float scale);
|
||||||
bool importEntities(const QString& url, const bool isObservable = true, const qint64 callerId = -1);
|
bool importEntities(const QString& url, const bool isObservable = true, const qint64 callerId = -1);
|
||||||
|
|
|
@ -60,10 +60,11 @@ bool ClipboardScriptingInterface::importEntities(
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<EntityItemID> ClipboardScriptingInterface::pasteEntities(glm::vec3 position) {
|
QVector<EntityItemID> ClipboardScriptingInterface::pasteEntities(glm::vec3 position, QString entityHostType) {
|
||||||
QVector<EntityItemID> retVal;
|
QVector<EntityItemID> retVal;
|
||||||
BLOCKING_INVOKE_METHOD(qApp, "pasteEntities",
|
BLOCKING_INVOKE_METHOD(qApp, "pasteEntities",
|
||||||
Q_RETURN_ARG(QVector<EntityItemID>, retVal),
|
Q_RETURN_ARG(QVector<EntityItemID>, retVal),
|
||||||
|
Q_ARG(QString, entityHostType),
|
||||||
Q_ARG(float, position.x),
|
Q_ARG(float, position.x),
|
||||||
Q_ARG(float, position.y),
|
Q_ARG(float, position.y),
|
||||||
Q_ARG(float, position.z));
|
Q_ARG(float, position.z));
|
||||||
|
|
|
@ -117,10 +117,11 @@ public:
|
||||||
* Pastes the contents of the clipboard into the domain.
|
* Pastes the contents of the clipboard into the domain.
|
||||||
* @function Clipboard.pasteEntities
|
* @function Clipboard.pasteEntities
|
||||||
* @param {Vec3} position - The position to paste the clipboard contents at.
|
* @param {Vec3} position - The position to paste the clipboard contents at.
|
||||||
|
* @param {Entities.EntityHostType} [entityHostType="domain"] - The type of entity to create.
|
||||||
* @returns {Uuid[]} The IDs of the new entities that were created as a result of the paste operation. If entities couldn't
|
* @returns {Uuid[]} The IDs of the new entities that were created as a result of the paste operation. If entities couldn't
|
||||||
* be created then an empty array is returned.
|
* be created then an empty array is returned.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE QVector<EntityItemID> pasteEntities(glm::vec3 position);
|
Q_INVOKABLE QVector<EntityItemID> pasteEntities(glm::vec3 position, QString entityHostType = "domain");
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ClipboardScriptingInterface_h
|
#endif // hifi_ClipboardScriptingInterface_h
|
||||||
|
|
|
@ -2657,11 +2657,12 @@ QByteArray EntityTree::remapActionDataIDs(QByteArray actionData, QHash<EntityIte
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTreePointer localTree,
|
QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTreePointer localTree,
|
||||||
float x, float y, float z) {
|
QString entityHostType, float x, float y, float z) {
|
||||||
SendEntitiesOperationArgs args;
|
SendEntitiesOperationArgs args;
|
||||||
args.ourTree = this;
|
args.ourTree = this;
|
||||||
args.otherTree = localTree;
|
args.otherTree = localTree;
|
||||||
args.root = glm::vec3(x, y, z);
|
args.root = glm::vec3(x, y, z);
|
||||||
|
args.entityHostType = entityHostType;
|
||||||
// If this is called repeatedly (e.g., multiple pastes with the same data), the new elements will clash unless we
|
// If this is called repeatedly (e.g., multiple pastes with the same data), the new elements will clash unless we
|
||||||
// use new identifiers. We need to keep a map so that we can map parent identifiers correctly.
|
// use new identifiers. We need to keep a map so that we can map parent identifiers correctly.
|
||||||
QHash<EntityItemID, EntityItemID> map;
|
QHash<EntityItemID, EntityItemID> map;
|
||||||
|
@ -2750,6 +2751,10 @@ bool EntityTree::sendEntitiesOperation(const OctreeElementPointer& element, void
|
||||||
EntityItemID oldID = item->getEntityItemID();
|
EntityItemID oldID = item->getEntityItemID();
|
||||||
EntityItemID newID = getMapped(oldID);
|
EntityItemID newID = getMapped(oldID);
|
||||||
EntityItemProperties properties = item->getProperties();
|
EntityItemProperties properties = item->getProperties();
|
||||||
|
|
||||||
|
if (args->entityHostType != nullptr) {
|
||||||
|
properties.setEntityHostTypeFromString(args->entityHostType);
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemID oldParentID = properties.getParentID();
|
EntityItemID oldParentID = properties.getParentID();
|
||||||
if (oldParentID.isInvalidID()) { // no parent
|
if (oldParentID.isInvalidID()) { // no parent
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
class SendEntitiesOperationArgs {
|
class SendEntitiesOperationArgs {
|
||||||
public:
|
public:
|
||||||
glm::vec3 root;
|
glm::vec3 root;
|
||||||
|
QString entityHostType;
|
||||||
EntityTree* ourTree;
|
EntityTree* ourTree;
|
||||||
EntityTreePointer otherTree;
|
EntityTreePointer otherTree;
|
||||||
QHash<EntityItemID, EntityItemID>* map;
|
QHash<EntityItemID, EntityItemID>* map;
|
||||||
|
@ -177,7 +178,7 @@ public:
|
||||||
static QByteArray remapActionDataIDs(QByteArray actionData, QHash<EntityItemID, EntityItemID>& map);
|
static QByteArray remapActionDataIDs(QByteArray actionData, QHash<EntityItemID, EntityItemID>& map);
|
||||||
|
|
||||||
QVector<EntityItemID> sendEntities(EntityEditPacketSender* packetSender, EntityTreePointer localTree,
|
QVector<EntityItemID> sendEntities(EntityEditPacketSender* packetSender, EntityTreePointer localTree,
|
||||||
float x, float y, float z);
|
QString entityHostType, float x, float y, float z);
|
||||||
|
|
||||||
void entityChanged(EntityItemPointer entity);
|
void entityChanged(EntityItemPointer entity);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue