mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 01:14:17 +02:00
sort out script interface changes
This commit is contained in:
parent
a769cfdaf2
commit
f522334c99
7 changed files with 37 additions and 43 deletions
|
@ -840,7 +840,7 @@ RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(cons
|
|||
(void**)&intersectedEntity, lockType, &result.accurate,
|
||||
precisionPicking);
|
||||
if (result.intersects && intersectedEntity) {
|
||||
result.entityID = intersectedEntity->getEntityItemID();
|
||||
result.entityID = intersectedEntity->getEntityItemID().id;
|
||||
result.properties = intersectedEntity->getProperties();
|
||||
result.intersection = ray.origin + (ray.direction * result.distance);
|
||||
result.entity = intersectedEntity;
|
||||
|
|
|
@ -99,7 +99,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (intersection.entityID.id == getID()) {
|
||||
if (intersection.entityID == getID()) {
|
||||
if (event->button() == Qt::MouseButton::RightButton) {
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
AbstractViewStateInterface::instance()->postLambdaEvent([this] {
|
||||
|
|
|
@ -20,13 +20,7 @@
|
|||
#include <QScriptEngine>
|
||||
#include <QUuid>
|
||||
|
||||
// const uint32_t UNKNOWN_ENTITY_TOKEN = 0xFFFFFFFF;
|
||||
// const uint32_t NEW_ENTITY = 0xFFFFFFFF;
|
||||
// const uint32_t UNKNOWN_ENTITY_ID = 0xFFFFFFFF;
|
||||
|
||||
const QUuid NEW_ENTITY;
|
||||
const QUuid UNKNOWN_ENTITY_ID;
|
||||
|
||||
const QUuid UNKNOWN_ENTITY_ID; // null uuid
|
||||
|
||||
/// Abstract ID for editing model items. Used in EntityItem JS API.
|
||||
class EntityItemID {
|
||||
|
@ -43,7 +37,7 @@ public:
|
|||
};
|
||||
|
||||
inline bool operator<(const EntityItemID& a, const EntityItemID& b) {
|
||||
return a.id == b.id;
|
||||
return a.id < b.id;
|
||||
}
|
||||
|
||||
inline bool operator==(const EntityItemID& a, const EntityItemID& b) {
|
||||
|
|
|
@ -68,11 +68,11 @@ void bidForSimulationOwnership(EntityItemProperties& properties) {
|
|||
|
||||
|
||||
|
||||
EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& properties) {
|
||||
QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties) {
|
||||
|
||||
EntityItemProperties propertiesWithSimID = properties;
|
||||
|
||||
EntityItemID id = EntityItemID(QUuid::createUuid());
|
||||
EntityItemID id = EntityItemID(UNKNOWN_ENTITY_ID);
|
||||
|
||||
// If we have a local entity tree set, then also update it.
|
||||
bool success = true;
|
||||
|
@ -95,10 +95,10 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro
|
|||
queueEntityMessage(PacketTypeEntityAddOrEdit, id, propertiesWithSimID);
|
||||
}
|
||||
|
||||
return id;
|
||||
return id.id;
|
||||
}
|
||||
|
||||
EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID identity) {
|
||||
EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identity) {
|
||||
EntityItemProperties results;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
|
@ -126,7 +126,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID
|
|||
return results;
|
||||
}
|
||||
|
||||
EntityItemID EntityScriptingInterface::editEntity(EntityItemID id, const EntityItemProperties& properties) {
|
||||
QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& properties) {
|
||||
EntityItemID entityID(id);
|
||||
// If we have a local entity tree set, then also update it.
|
||||
if (_entityTree) {
|
||||
|
@ -153,7 +153,7 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID id, const EntityI
|
|||
return id;
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::deleteEntity(EntityItemID id) {
|
||||
void EntityScriptingInterface::deleteEntity(QUuid id) {
|
||||
EntityItemID entityID(id);
|
||||
bool shouldDelete = true;
|
||||
|
||||
|
@ -179,17 +179,17 @@ void EntityScriptingInterface::deleteEntity(EntityItemID id) {
|
|||
}
|
||||
}
|
||||
|
||||
EntityItemID EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
||||
QUuid result;
|
||||
QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
||||
EntityItemID result;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
const EntityItem* closestEntity = _entityTree->findClosestEntity(center, radius);
|
||||
_entityTree->unlock();
|
||||
if (closestEntity) {
|
||||
result = closestEntity->getEntityItemID().id;
|
||||
result = closestEntity->getEntityItemID();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result.id;
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,8 +201,8 @@ void EntityScriptingInterface::dumpTree() const {
|
|||
}
|
||||
}
|
||||
|
||||
QVector<EntityItemID> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const {
|
||||
QVector<EntityItemID> result;
|
||||
QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const {
|
||||
QVector<QUuid> result;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
QVector<const EntityItem*> entities;
|
||||
|
@ -210,14 +210,14 @@ QVector<EntityItemID> EntityScriptingInterface::findEntities(const glm::vec3& ce
|
|||
_entityTree->unlock();
|
||||
|
||||
foreach (const EntityItem* entity, entities) {
|
||||
result << entity->getEntityItemID();
|
||||
result << entity->getEntityItemID().id;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QVector<EntityItemID> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {
|
||||
QVector<EntityItemID> result;
|
||||
QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {
|
||||
QVector<QUuid> result;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
AABox box(corner, dimensions);
|
||||
|
@ -226,7 +226,7 @@ QVector<EntityItemID> EntityScriptingInterface::findEntitiesInBox(const glm::vec
|
|||
_entityTree->unlock();
|
||||
|
||||
foreach (const EntityItem* entity, entities) {
|
||||
result << entity->getEntityItemID();
|
||||
result << entity->getEntityItemID().id;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -353,7 +353,8 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
|
|||
value.intersects = object.property("intersects").toVariant().toBool();
|
||||
value.accurate = object.property("accurate").toVariant().toBool();
|
||||
QScriptValue entityIDValue = object.property("entityID");
|
||||
EntityItemIDfromScriptValue(entityIDValue, value.entityID);
|
||||
// EntityItemIDfromScriptValue(entityIDValue, value.entityID);
|
||||
quuidFromScriptValue(entityIDValue, value.entityID);
|
||||
QScriptValue entityPropertiesValue = object.property("properties");
|
||||
if (entityPropertiesValue.isValid()) {
|
||||
EntityItemPropertiesFromScriptValue(entityPropertiesValue, value.properties);
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
RayToEntityIntersectionResult();
|
||||
bool intersects;
|
||||
bool accurate;
|
||||
EntityItemID entityID;
|
||||
QUuid entityID;
|
||||
EntityItemProperties properties;
|
||||
float distance;
|
||||
BoxFace face;
|
||||
|
@ -70,31 +70,31 @@ public slots:
|
|||
Q_INVOKABLE bool canRez();
|
||||
|
||||
/// adds a model with the specific properties
|
||||
Q_INVOKABLE EntityItemID addEntity(const EntityItemProperties& properties);
|
||||
Q_INVOKABLE QUuid addEntity(const EntityItemProperties& properties);
|
||||
|
||||
/// gets the current model properties for a specific model
|
||||
/// this function will not find return results in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE EntityItemProperties getEntityProperties(EntityItemID entityID);
|
||||
Q_INVOKABLE EntityItemProperties getEntityProperties(QUuid entityID);
|
||||
|
||||
/// edits a model updating only the included properties, will return the identified EntityItemID in case of
|
||||
/// successful edit, if the input entityID is for an unknown model this function will have no effect
|
||||
Q_INVOKABLE EntityItemID editEntity(EntityItemID entityID, const EntityItemProperties& properties);
|
||||
Q_INVOKABLE QUuid editEntity(QUuid entityID, const EntityItemProperties& properties);
|
||||
|
||||
/// deletes a model
|
||||
Q_INVOKABLE void deleteEntity(EntityItemID entityID);
|
||||
Q_INVOKABLE void deleteEntity(QUuid entityID);
|
||||
|
||||
/// finds the closest model to the center point, within the radius
|
||||
/// will return a EntityItemID.isKnownID = false if no models are in the radius
|
||||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE EntityItemID findClosestEntity(const glm::vec3& center, float radius) const;
|
||||
Q_INVOKABLE QUuid findClosestEntity(const glm::vec3& center, float radius) const;
|
||||
|
||||
/// finds models within the search sphere specified by the center point and radius
|
||||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE QVector<EntityItemID> findEntities(const glm::vec3& center, float radius) const;
|
||||
Q_INVOKABLE QVector<QUuid> findEntities(const glm::vec3& center, float radius) const;
|
||||
|
||||
/// finds models within the search sphere specified by the center point and radius
|
||||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE QVector<EntityItemID> findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const;
|
||||
Q_INVOKABLE QVector<QUuid> findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const;
|
||||
|
||||
/// If the scripting context has visible entities, this will determine a ray intersection, the results
|
||||
/// may be inaccurate if the engine is unable to access the visible entities, in which case result.accurate
|
||||
|
@ -142,7 +142,6 @@ signals:
|
|||
|
||||
void deletingEntity(const EntityItemID& entityID);
|
||||
void addingEntity(const EntityItemID& entityID);
|
||||
void changingEntityID(const EntityItemID& oldEntityID, const EntityItemID& newEntityID);
|
||||
void clearingEntities();
|
||||
|
||||
private:
|
||||
|
|
|
@ -1062,7 +1062,7 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
|||
|
||||
EntityItem* entity = addEntity(entityItemID, properties);
|
||||
if (!entity) {
|
||||
qCDebug(entities) << "adding Entity failed:" << entityItemID << entity->getType();
|
||||
qCDebug(entities) << "adding Entity failed:" << entityItemID << properties.getType();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ MovingEntitiesOperator::~MovingEntitiesOperator() {
|
|||
|
||||
|
||||
void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACube& newCube) {
|
||||
EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getID());
|
||||
EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getEntityItemID());
|
||||
AABox newCubeClamped = newCube.clamp(0.0f, (float)TREE_SCALE);
|
||||
|
||||
if (_wantDebug) {
|
||||
|
@ -68,7 +68,7 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub
|
|||
}
|
||||
|
||||
if (!oldContainingElement) {
|
||||
qCDebug(entities) << "UNEXPECTED!!!! attempting to move entity "<< entity->getID()
|
||||
qCDebug(entities) << "UNEXPECTED!!!! attempting to move entity "<< entity->getEntityItemID()
|
||||
<< "that has no containing element. ";
|
||||
return; // bail without adding.
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub
|
|||
|
||||
if (_wantDebug) {
|
||||
qCDebug(entities) << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------";
|
||||
qCDebug(entities) << " details.entity:" << details.entity->getID();
|
||||
qCDebug(entities) << " details.entity:" << details.entity->getEntityItemID();
|
||||
qCDebug(entities) << " details.oldContainingElementCube:" << details.oldContainingElementCube;
|
||||
qCDebug(entities) << " details.newCube:" << details.newCube;
|
||||
qCDebug(entities) << " details.newCubeClamped:" << details.newCubeClamped;
|
||||
|
@ -122,7 +122,7 @@ bool MovingEntitiesOperator::shouldRecurseSubTree(OctreeElement* element) {
|
|||
if (_wantDebug) {
|
||||
qCDebug(entities) << "MovingEntitiesOperator::shouldRecurseSubTree() details["<< detailIndex <<"]-----------------------------";
|
||||
qCDebug(entities) << " element:" << element->getAACube();
|
||||
qCDebug(entities) << " details.entity:" << details.entity->getID();
|
||||
qCDebug(entities) << " details.entity:" << details.entity->getEntityItemID();
|
||||
qCDebug(entities) << " details.oldContainingElementCube:" << details.oldContainingElementCube;
|
||||
qCDebug(entities) << " details.newCube:" << details.newCube;
|
||||
qCDebug(entities) << " details.newCubeClamped:" << details.newCubeClamped;
|
||||
|
@ -167,7 +167,7 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) {
|
|||
qCDebug(entities) << "MovingEntitiesOperator::preRecursion() details["<< detailIndex <<"]-----------------------------";
|
||||
qCDebug(entities) << " entityTreeElement:" << entityTreeElement->getAACube();
|
||||
qCDebug(entities) << " entityTreeElement->bestFitBounds(details.newCube):" << entityTreeElement->bestFitBounds(details.newCube);
|
||||
qCDebug(entities) << " details.entity:" << details.entity->getID();
|
||||
qCDebug(entities) << " details.entity:" << details.entity->getEntityItemID();
|
||||
qCDebug(entities) << " details.oldContainingElementCube:" << details.oldContainingElementCube;
|
||||
qCDebug(entities) << " entityTreeElement:" << entityTreeElement;
|
||||
qCDebug(entities) << " details.newCube:" << details.newCube;
|
||||
|
@ -193,7 +193,7 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) {
|
|||
|
||||
// If this element is the best fit for the new bounds of this entity then add the entity to the element
|
||||
if (!details.newFound && entityTreeElement->bestFitBounds(details.newCube)) {
|
||||
QUuid entityItemID = details.entity->getID();
|
||||
EntityItemID entityItemID = details.entity->getEntityItemID();
|
||||
// remove from the old before adding
|
||||
EntityTreeElement* oldElement = details.entity->getElement();
|
||||
if (oldElement != entityTreeElement) {
|
||||
|
|
Loading…
Reference in a new issue