mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 09:04:33 +02:00
set grabbable user data in addModelEntity, pass grabbable from asset browser
This commit is contained in:
parent
544a6504f2
commit
8db0711b5b
5 changed files with 16 additions and 7 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7325,7 +7325,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);
|
||||
|
|
|
@ -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