mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 11:54:20 +02:00
Merge pull request #13808 from dback2/createEntitiesGrabbable
Use Create Entities as Grabbable option when adding asset to world
This commit is contained in:
commit
02f53c4ee5
6 changed files with 21 additions and 8 deletions
|
@ -186,6 +186,8 @@ Windows.ScrollingWindow {
|
|||
return;
|
||||
}
|
||||
|
||||
var grabbable = MenuInterface.isOptionChecked("Create Entities As Grabbable (except Zones, Particles, and Lights)");
|
||||
|
||||
if (defaultURL.endsWith(".jpg") || defaultURL.endsWith(".png")) {
|
||||
var name = assetProxyModel.data(treeView.selection.currentIndex);
|
||||
var modelURL = "https://hifi-content.s3.amazonaws.com/DomainContent/production/default-image-model.fbx";
|
||||
|
@ -195,7 +197,7 @@ Windows.ScrollingWindow {
|
|||
var collisionless = true;
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation)));
|
||||
var gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 0);
|
||||
Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, collisionless, position, gravity);
|
||||
Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, collisionless, grabbable, position, gravity);
|
||||
} else {
|
||||
var SHAPE_TYPE_NONE = 0;
|
||||
var SHAPE_TYPE_SIMPLE_HULL = 1;
|
||||
|
@ -281,7 +283,7 @@ Windows.ScrollingWindow {
|
|||
print("Asset browser - adding asset " + url + " (" + name + ") to world.");
|
||||
|
||||
// Entities.addEntity doesn't work from QML, so we use this.
|
||||
Entities.addModelEntity(name, url, "", shapeType, dynamic, collisionless, addPosition, gravity);
|
||||
Entities.addModelEntity(name, url, "", shapeType, dynamic, collisionless, grabbable, addPosition, gravity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -186,6 +186,8 @@ Rectangle {
|
|||
return;
|
||||
}
|
||||
|
||||
var grabbable = MenuInterface.isOptionChecked("Create Entities As Grabbable (except Zones, Particles, and Lights)");
|
||||
|
||||
if (defaultURL.endsWith(".jpg") || defaultURL.endsWith(".png")) {
|
||||
var name = assetProxyModel.data(treeView.selection.currentIndex);
|
||||
var modelURL = "https://hifi-content.s3.amazonaws.com/DomainContent/production/default-image-model.fbx";
|
||||
|
@ -195,7 +197,7 @@ Rectangle {
|
|||
var collisionless = true;
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation)));
|
||||
var gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 0);
|
||||
Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, collisionless, position, gravity);
|
||||
Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, collisionless, grabbable, position, gravity);
|
||||
} else {
|
||||
var SHAPE_TYPE_NONE = 0;
|
||||
var SHAPE_TYPE_SIMPLE_HULL = 1;
|
||||
|
@ -281,7 +283,7 @@ Rectangle {
|
|||
print("Asset browser - adding asset " + url + " (" + name + ") to world.");
|
||||
|
||||
// Entities.addEntity doesn't work from QML, so we use this.
|
||||
Entities.addModelEntity(name, url, "", shapeType, dynamic, collisionless, addPosition, gravity);
|
||||
Entities.addModelEntity(name, url, "", shapeType, dynamic, collisionless, grabbable, addPosition, gravity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7302,6 +7302,8 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) {
|
|||
}
|
||||
properties.setCollisionless(true); // Temporarily set so that doesn't collide with avatar.
|
||||
properties.setVisible(false); // Temporarily set so that don't see at large unresized dimensions.
|
||||
bool grabbable = (Menu::getInstance()->isOptionChecked(MenuOption::CreateEntitiesGrabbable));
|
||||
properties.setUserData(grabbable ? GRABBABLE_USER_DATA : NOT_GRABBABLE_USER_DATA);
|
||||
glm::vec3 positionOffset = getMyAvatar()->getWorldOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
|
||||
properties.setPosition(getMyAvatar()->getWorldPosition() + positionOffset);
|
||||
properties.setRotation(getMyAvatar()->getWorldOrientation());
|
||||
|
@ -7344,7 +7346,6 @@ void Application::addAssetToWorldCheckModelSize() {
|
|||
auto name = properties.getName();
|
||||
auto dimensions = properties.getDimensions();
|
||||
|
||||
const QString GRABBABLE_USER_DATA = "{\"grabbableKey\":{\"grabbable\":true}}";
|
||||
bool doResize = false;
|
||||
|
||||
const glm::vec3 DEFAULT_DIMENSIONS = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||
|
@ -7388,7 +7389,8 @@ void Application::addAssetToWorldCheckModelSize() {
|
|||
if (!name.toLower().endsWith(PNG_EXTENSION) && !name.toLower().endsWith(JPG_EXTENSION)) {
|
||||
properties.setCollisionless(false);
|
||||
}
|
||||
properties.setUserData(GRABBABLE_USER_DATA);
|
||||
bool grabbable = (Menu::getInstance()->isOptionChecked(MenuOption::CreateEntitiesGrabbable));
|
||||
properties.setUserData(grabbable ? GRABBABLE_USER_DATA : NOT_GRABBABLE_USER_DATA);
|
||||
properties.setLastEdited(usecTimestampNow());
|
||||
entityScriptingInterface->editEntity(entityID, properties);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace MenuOption {
|
|||
const QString CrashOutOfBoundsVectorAccessThreaded = "Out of Bounds Vector Access (threaded)";
|
||||
const QString CrashNewFault = "New Fault";
|
||||
const QString CrashNewFaultThreaded = "New Fault (threaded)";
|
||||
const QString CreateEntitiesGrabbable = "Create Entities As Grabbable (except Zones, Particles, and Lights)";
|
||||
const QString DeadlockInterface = "Deadlock Interface";
|
||||
const QString UnresponsiveInterface = "Unresponsive Interface";
|
||||
const QString DecreaseAvatarSize = "Decrease Avatar Size";
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include <EntityScriptClient.h>
|
||||
#include <Profile.h>
|
||||
|
||||
const QString GRABBABLE_USER_DATA = "{\"grabbableKey\":{\"grabbable\":true}}";
|
||||
const QString NOT_GRABBABLE_USER_DATA = "{\"grabbableKey\":{\"grabbable\":false}}";
|
||||
|
||||
EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership) :
|
||||
_entityTree(NULL),
|
||||
|
@ -303,7 +305,7 @@ bool EntityScriptingInterface::addLocalEntityCopy(EntityItemProperties& properti
|
|||
}
|
||||
|
||||
QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QString& modelUrl, const QString& textures,
|
||||
const QString& shapeType, bool dynamic, bool collisionless,
|
||||
const QString& shapeType, bool dynamic, bool collisionless, bool grabbable,
|
||||
const glm::vec3& position, const glm::vec3& gravity) {
|
||||
_activityTracking.addedEntityCount++;
|
||||
|
||||
|
@ -314,6 +316,7 @@ QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QStrin
|
|||
properties.setShapeTypeFromString(shapeType);
|
||||
properties.setDynamic(dynamic);
|
||||
properties.setCollisionless(collisionless);
|
||||
properties.setUserData(grabbable ? GRABBABLE_USER_DATA : NOT_GRABBABLE_USER_DATA);
|
||||
properties.setPosition(position);
|
||||
properties.setGravity(gravity);
|
||||
if (!textures.isEmpty()) {
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
class EntityTree;
|
||||
class MeshProxy;
|
||||
|
||||
extern const QString GRABBABLE_USER_DATA;
|
||||
extern const QString NOT_GRABBABLE_USER_DATA;
|
||||
|
||||
// helper factory to compose standardized, async metadata queries for "magic" Entity properties
|
||||
// like .script and .serverScripts. This is used for automated testing of core scripting features
|
||||
// as well as to provide early adopters a self-discoverable, consistent way to diagnose common
|
||||
|
@ -237,7 +240,7 @@ public slots:
|
|||
/// temporary method until addEntity can be used from QJSEngine
|
||||
/// Deliberately not adding jsdoc, only used internally.
|
||||
Q_INVOKABLE QUuid addModelEntity(const QString& name, const QString& modelUrl, const QString& textures, const QString& shapeType, bool dynamic,
|
||||
bool collisionless, const glm::vec3& position, const glm::vec3& gravity);
|
||||
bool collisionless, bool grabbable, const glm::vec3& position, const glm::vec3& gravity);
|
||||
|
||||
/**jsdoc
|
||||
* Create a clone of an entity. A clone can be created by a client that doesn't have rez permissions in the current domain.
|
||||
|
|
Loading…
Reference in a new issue