mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 03:03:35 +02:00
provide a way for scripts to get information about what actions an entity has and what the arguments of those actions are
This commit is contained in:
parent
c0c1116c69
commit
0970f010a4
15 changed files with 136 additions and 30 deletions
|
@ -30,6 +30,7 @@ public:
|
||||||
virtual const EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
|
virtual const EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
|
||||||
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
|
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
|
||||||
virtual bool updateArguments(QVariantMap arguments) { assert(false); return false; }
|
virtual bool updateArguments(QVariantMap arguments) { assert(false); return false; }
|
||||||
|
virtual QVariantMap getArguments() { assert(false); return QVariantMap(); }
|
||||||
|
|
||||||
virtual QByteArray serialize();
|
virtual QByteArray serialize();
|
||||||
virtual void deserialize(QByteArray serializedArguments);
|
virtual void deserialize(QByteArray serializedArguments);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "QVariantGLM.h"
|
||||||
#include "avatar/MyAvatar.h"
|
#include "avatar/MyAvatar.h"
|
||||||
#include "avatar/AvatarManager.h"
|
#include "avatar/AvatarManager.h"
|
||||||
|
|
||||||
|
@ -118,6 +119,21 @@ bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap AvatarActionHold::getArguments() {
|
||||||
|
QVariantMap arguments;
|
||||||
|
lockForRead();
|
||||||
|
if (_parametersSet) {
|
||||||
|
arguments["relativePosition"] = glmToQMap(_relativePosition);
|
||||||
|
arguments["relativeRotation"] = glmToQMap(_relativeRotation);
|
||||||
|
arguments["timeScale"] = _linearTimeScale;
|
||||||
|
arguments["hand"] = _hand;
|
||||||
|
}
|
||||||
|
unlock();
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray AvatarActionHold::serialize() {
|
QByteArray AvatarActionHold::serialize() {
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QDataStream dataStream(&ba, QIODevice::WriteOnly);
|
QDataStream dataStream(&ba, QIODevice::WriteOnly);
|
||||||
|
|
|
@ -25,6 +25,8 @@ public:
|
||||||
virtual EntityActionType getType() { return ACTION_TYPE_HOLD; }
|
virtual EntityActionType getType() { return ACTION_TYPE_HOLD; }
|
||||||
|
|
||||||
virtual bool updateArguments(QVariantMap arguments);
|
virtual bool updateArguments(QVariantMap arguments);
|
||||||
|
virtual QVariantMap getArguments();
|
||||||
|
|
||||||
virtual void updateActionWorker(float deltaTimeStep);
|
virtual void updateActionWorker(float deltaTimeStep);
|
||||||
|
|
||||||
virtual QByteArray serialize();
|
virtual QByteArray serialize();
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
virtual const EntityItemWeakPointer getOwnerEntity() const = 0;
|
virtual const EntityItemWeakPointer getOwnerEntity() const = 0;
|
||||||
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) = 0;
|
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) = 0;
|
||||||
virtual bool updateArguments(QVariantMap arguments) = 0;
|
virtual bool updateArguments(QVariantMap arguments) = 0;
|
||||||
|
virtual QVariantMap getArguments() = 0;
|
||||||
|
|
||||||
virtual QByteArray serialize() = 0;
|
virtual QByteArray serialize() = 0;
|
||||||
virtual void deserialize(QByteArray serializedArguments) = 0;
|
virtual void deserialize(QByteArray serializedArguments) = 0;
|
||||||
|
|
|
@ -1492,7 +1492,6 @@ void EntityItem::setActionData(QByteArray actionData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EntityItem::serializeActionData() {
|
bool EntityItem::serializeActionData() {
|
||||||
if (_objectActions.size() == 0) {
|
if (_objectActions.size() == 0) {
|
||||||
_actionData = QByteArray();
|
_actionData = QByteArray();
|
||||||
|
@ -1521,7 +1520,15 @@ bool EntityItem::serializeActionData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QByteArray EntityItem::getActionData() const {
|
const QByteArray EntityItem::getActionData() const {
|
||||||
return _actionData;
|
return _actionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap EntityItem::getActionArguments(const QUuid& actionID) {
|
||||||
|
QVariantMap result;
|
||||||
|
if (_objectActions.contains(actionID)) {
|
||||||
|
EntityActionPointer action = _objectActions[actionID];
|
||||||
|
result = action->getArguments();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -386,6 +386,8 @@ public:
|
||||||
void setActionData(QByteArray actionData);
|
void setActionData(QByteArray actionData);
|
||||||
const QByteArray getActionData() const;
|
const QByteArray getActionData() const;
|
||||||
bool hasActions() { return !_objectActions.empty(); }
|
bool hasActions() { return !_objectActions.empty(); }
|
||||||
|
QList<QUuid> getActionIDs() { return _objectActions.keys(); }
|
||||||
|
QVariantMap getActionArguments(const QUuid& actionID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ void EntityScriptingInterface::setEntityTree(EntityTree* modelTree) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void bidForSimulationOwnership(EntityItemProperties& properties) {
|
void bidForSimulationOwnership(EntityItemProperties& properties) {
|
||||||
// We make a bid for simulation ownership by declaring our sessionID as simulation owner
|
// We make a bid for simulation ownership by declaring our sessionID as simulation owner
|
||||||
// in the outgoing properties. The EntityServer may accept the bid or might not.
|
// in the outgoing properties. The EntityServer may accept the bid or might not.
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||||
|
@ -113,7 +113,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit
|
||||||
if (entity) {
|
if (entity) {
|
||||||
results = entity->getProperties();
|
results = entity->getProperties();
|
||||||
|
|
||||||
// TODO: improve sitting points and naturalDimensions in the future,
|
// TODO: improve sitting points and naturalDimensions in the future,
|
||||||
// for now we've included the old sitting points model behavior for entity types that are models
|
// for now we've included the old sitting points model behavior for entity types that are models
|
||||||
// we've also added this hack for setting natural dimensions of models
|
// we've also added this hack for setting natural dimensions of models
|
||||||
if (entity->getType() == EntityTypes::Model) {
|
if (entity->getType() == EntityTypes::Model) {
|
||||||
|
@ -149,15 +149,15 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties proper
|
||||||
if (properties.hasTerseUpdateChanges()) {
|
if (properties.hasTerseUpdateChanges()) {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||||
|
|
||||||
if (entity->getSimulatorID() == myNodeID) {
|
if (entity->getSimulatorID() == myNodeID) {
|
||||||
// we think we already own the simulation, so make sure to send ALL TerseUpdate properties
|
// we think we already own the simulation, so make sure to send ALL TerseUpdate properties
|
||||||
entity->getAllTerseUpdateProperties(properties);
|
entity->getAllTerseUpdateProperties(properties);
|
||||||
// TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object
|
// TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object
|
||||||
// is dynamic AND it is active in the physics simulation then we could chose to NOT queue an update
|
// is dynamic AND it is active in the physics simulation then we could chose to NOT queue an update
|
||||||
// and instead let the physics simulation decide when to send a terse update. This would remove
|
// and instead let the physics simulation decide when to send a terse update. This would remove
|
||||||
// the "slide-no-rotate" glitch (and typical a double-update) that we see during the "poke rolling
|
// the "slide-no-rotate" glitch (and typical a double-update) that we see during the "poke rolling
|
||||||
// balls" test. However, even if we solve this problem we still need to provide a "slerp the visible
|
// balls" test. However, even if we solve this problem we still need to provide a "slerp the visible
|
||||||
// proxy toward the true physical position" feature to hide the final glitches in the remote watcher's
|
// proxy toward the true physical position" feature to hide the final glitches in the remote watcher's
|
||||||
// simulation.
|
// simulation.
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
||||||
EntityItemID result;
|
EntityItemID result;
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
_entityTree->lockForRead();
|
_entityTree->lockForRead();
|
||||||
EntityItemPointer closestEntity = _entityTree->findClosestEntity(center, radius);
|
EntityItemPointer closestEntity = _entityTree->findClosestEntity(center, radius);
|
||||||
|
@ -264,8 +264,8 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionBlock
|
||||||
return findRayIntersectionWorker(ray, Octree::Lock, precisionPicking);
|
return findRayIntersectionWorker(ray, Octree::Lock, precisionPicking);
|
||||||
}
|
}
|
||||||
|
|
||||||
RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorker(const PickRay& ray,
|
RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorker(const PickRay& ray,
|
||||||
Octree::lockType lockType,
|
Octree::lockType lockType,
|
||||||
bool precisionPicking) {
|
bool precisionPicking) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,8 +273,8 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
OctreeElement* element;
|
OctreeElement* element;
|
||||||
EntityItemPointer intersectedEntity = NULL;
|
EntityItemPointer intersectedEntity = NULL;
|
||||||
result.intersects = _entityTree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face,
|
result.intersects = _entityTree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face,
|
||||||
(void**)&intersectedEntity, lockType, &result.accurate,
|
(void**)&intersectedEntity, lockType, &result.accurate,
|
||||||
precisionPicking);
|
precisionPicking);
|
||||||
if (result.intersects && intersectedEntity) {
|
if (result.intersects && intersectedEntity) {
|
||||||
result.entityID = intersectedEntity->getEntityItemID();
|
result.entityID = intersectedEntity->getEntityItemID();
|
||||||
|
@ -318,15 +318,15 @@ bool EntityScriptingInterface::getSendPhysicsUpdates() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RayToEntityIntersectionResult::RayToEntityIntersectionResult() :
|
RayToEntityIntersectionResult::RayToEntityIntersectionResult() :
|
||||||
intersects(false),
|
intersects(false),
|
||||||
accurate(true), // assume it's accurate
|
accurate(true), // assume it's accurate
|
||||||
entityID(),
|
entityID(),
|
||||||
properties(),
|
properties(),
|
||||||
distance(0),
|
distance(0),
|
||||||
face(),
|
face(),
|
||||||
entity(NULL)
|
entity(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) {
|
QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) {
|
||||||
|
@ -341,7 +341,7 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c
|
||||||
|
|
||||||
obj.setProperty("distance", value.distance);
|
obj.setProperty("distance", value.distance);
|
||||||
|
|
||||||
QString faceName = "";
|
QString faceName = "";
|
||||||
// handle BoxFace
|
// handle BoxFace
|
||||||
switch (value.face) {
|
switch (value.face) {
|
||||||
case MIN_X_FACE:
|
case MIN_X_FACE:
|
||||||
|
@ -446,35 +446,35 @@ bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(Line
|
||||||
if (!_entityTree) {
|
if (!_entityTree) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));
|
EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID;
|
qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityTypes::EntityType entityType = entity->getType();
|
EntityTypes::EntityType entityType = entity->getType();
|
||||||
|
|
||||||
if (entityType != EntityTypes::Line) {
|
if (entityType != EntityTypes::Line) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto now = usecTimestampNow();
|
auto now = usecTimestampNow();
|
||||||
|
|
||||||
LineEntityItem* lineEntity = static_cast<LineEntityItem*>(entity.get());
|
LineEntityItem* lineEntity = static_cast<LineEntityItem*>(entity.get());
|
||||||
_entityTree->lockForWrite();
|
_entityTree->lockForWrite();
|
||||||
bool success = actor(*lineEntity);
|
bool success = actor(*lineEntity);
|
||||||
entity->setLastEdited(now);
|
entity->setLastEdited(now);
|
||||||
entity->setLastBroadcast(now);
|
entity->setLastBroadcast(now);
|
||||||
_entityTree->unlock();
|
_entityTree->unlock();
|
||||||
|
|
||||||
_entityTree->lockForRead();
|
_entityTree->lockForRead();
|
||||||
EntityItemProperties properties = entity->getProperties();
|
EntityItemProperties properties = entity->getProperties();
|
||||||
_entityTree->unlock();
|
_entityTree->unlock();
|
||||||
|
|
||||||
properties.setLinePointsDirty();
|
properties.setLinePointsDirty();
|
||||||
properties.setLastEdited(now);
|
properties.setLastEdited(now);
|
||||||
|
|
||||||
|
|
||||||
queueEntityMessage(PacketTypeEntityEdit, entityID, properties);
|
queueEntityMessage(PacketTypeEntityEdit, entityID, properties);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -509,7 +509,6 @@ bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& poin
|
||||||
{
|
{
|
||||||
return lineEntity.appendPoint(point);
|
return lineEntity.appendPoint(point);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -585,9 +584,27 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid&
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) {
|
bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) {
|
||||||
return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
|
return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
|
||||||
return entity->removeAction(simulation, actionID);
|
return entity->removeAction(simulation, actionID);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) {
|
||||||
|
QVector<QUuid> result;
|
||||||
|
actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
|
||||||
|
QList<QUuid> actionIDs = entity->getActionIDs();
|
||||||
|
result = QVector<QUuid>::fromList(actionIDs);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap EntityScriptingInterface::getActionArguments(const QUuid& entityID, const QUuid& actionID) {
|
||||||
|
QVariantMap result;
|
||||||
|
actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
|
||||||
|
result = entity->getActionArguments(actionID);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public slots:
|
||||||
Q_INVOKABLE bool setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value);
|
Q_INVOKABLE bool setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value);
|
||||||
Q_INVOKABLE bool setVoxel(QUuid entityID, const glm::vec3& position, int value);
|
Q_INVOKABLE bool setVoxel(QUuid entityID, const glm::vec3& position, int value);
|
||||||
Q_INVOKABLE bool setAllVoxels(QUuid entityID, int value);
|
Q_INVOKABLE bool setAllVoxels(QUuid entityID, int value);
|
||||||
|
|
||||||
Q_INVOKABLE bool setAllPoints(QUuid entityID, const QVector<glm::vec3>& points);
|
Q_INVOKABLE bool setAllPoints(QUuid entityID, const QVector<glm::vec3>& points);
|
||||||
Q_INVOKABLE bool appendPoint(QUuid entityID, const glm::vec3& point);
|
Q_INVOKABLE bool appendPoint(QUuid entityID, const glm::vec3& point);
|
||||||
|
|
||||||
|
@ -131,6 +131,8 @@ public slots:
|
||||||
Q_INVOKABLE QUuid addAction(const QString& actionTypeString, const QUuid& entityID, const QVariantMap& arguments);
|
Q_INVOKABLE QUuid addAction(const QString& actionTypeString, const QUuid& entityID, const QVariantMap& arguments);
|
||||||
Q_INVOKABLE bool updateAction(const QUuid& entityID, const QUuid& actionID, const QVariantMap& arguments);
|
Q_INVOKABLE bool updateAction(const QUuid& entityID, const QUuid& actionID, const QVariantMap& arguments);
|
||||||
Q_INVOKABLE bool deleteAction(const QUuid& entityID, const QUuid& actionID);
|
Q_INVOKABLE bool deleteAction(const QUuid& entityID, const QUuid& actionID);
|
||||||
|
Q_INVOKABLE QVector<QUuid> getActionIDs(const QUuid& entityID);
|
||||||
|
Q_INVOKABLE QVariantMap getActionArguments(const QUuid& entityID, const QUuid& actionID);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||||
|
@ -165,7 +167,7 @@ private:
|
||||||
void queueEntityMessage(PacketType packetType, EntityItemID entityID, const EntityItemProperties& properties);
|
void queueEntityMessage(PacketType packetType, EntityItemID entityID, const EntityItemProperties& properties);
|
||||||
|
|
||||||
/// actually does the work of finding the ray intersection, can be called in locking mode or tryLock mode
|
/// actually does the work of finding the ray intersection, can be called in locking mode or tryLock mode
|
||||||
RayToEntityIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType,
|
RayToEntityIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType,
|
||||||
bool precisionPicking);
|
bool precisionPicking);
|
||||||
|
|
||||||
EntityTree* _entityTree;
|
EntityTree* _entityTree;
|
||||||
|
|
|
@ -34,7 +34,9 @@ public:
|
||||||
virtual void removeFromSimulation(EntitySimulation* simulation) const;
|
virtual void removeFromSimulation(EntitySimulation* simulation) const;
|
||||||
virtual const EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
|
virtual const EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
|
||||||
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
|
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
|
||||||
|
|
||||||
virtual bool updateArguments(QVariantMap arguments) { return false; }
|
virtual bool updateArguments(QVariantMap arguments) { return false; }
|
||||||
|
virtual QVariantMap getArguments() { return QVariantMap(); }
|
||||||
|
|
||||||
// this is called from updateAction and should be overridden by subclasses
|
// this is called from updateAction and should be overridden by subclasses
|
||||||
virtual void updateActionWorker(float deltaTimeStep) {}
|
virtual void updateActionWorker(float deltaTimeStep) {}
|
||||||
|
@ -62,6 +64,7 @@ protected:
|
||||||
virtual glm::vec3 getAngularVelocity();
|
virtual glm::vec3 getAngularVelocity();
|
||||||
virtual void setAngularVelocity(glm::vec3 angularVelocity);
|
virtual void setAngularVelocity(glm::vec3 angularVelocity);
|
||||||
|
|
||||||
|
void lockForRead() { _lock.lockForRead(); }
|
||||||
bool tryLockForRead() { return _lock.tryLockForRead(); }
|
bool tryLockForRead() { return _lock.tryLockForRead(); }
|
||||||
void lockForWrite() { _lock.lockForWrite(); }
|
void lockForWrite() { _lock.lockForWrite(); }
|
||||||
bool tryLockForWrite() { return _lock.tryLockForWrite(); }
|
bool tryLockForWrite() { return _lock.tryLockForWrite(); }
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "QVariantGLM.h"
|
||||||
|
|
||||||
#include "ObjectActionOffset.h"
|
#include "ObjectActionOffset.h"
|
||||||
|
|
||||||
const uint16_t ObjectActionOffset::offsetVersion = 1;
|
const uint16_t ObjectActionOffset::offsetVersion = 1;
|
||||||
|
@ -115,6 +117,16 @@ bool ObjectActionOffset::updateArguments(QVariantMap arguments) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap ObjectActionOffset::getArguments() {
|
||||||
|
QVariantMap arguments;
|
||||||
|
lockForRead();
|
||||||
|
arguments["pointToOffsetFrom"] = glmToQMap(_pointToOffsetFrom);
|
||||||
|
arguments["linearTimeScale"] = _linearTimeScale;
|
||||||
|
arguments["linearDistance"] = _linearDistance;
|
||||||
|
unlock();
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray ObjectActionOffset::serialize() {
|
QByteArray ObjectActionOffset::serialize() {
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QDataStream dataStream(&ba, QIODevice::WriteOnly);
|
QDataStream dataStream(&ba, QIODevice::WriteOnly);
|
||||||
|
|
|
@ -25,6 +25,8 @@ public:
|
||||||
virtual EntityActionType getType() { return ACTION_TYPE_OFFSET; }
|
virtual EntityActionType getType() { return ACTION_TYPE_OFFSET; }
|
||||||
|
|
||||||
virtual bool updateArguments(QVariantMap arguments);
|
virtual bool updateArguments(QVariantMap arguments);
|
||||||
|
virtual QVariantMap getArguments();
|
||||||
|
|
||||||
virtual void updateActionWorker(float deltaTimeStep);
|
virtual void updateActionWorker(float deltaTimeStep);
|
||||||
|
|
||||||
virtual QByteArray serialize();
|
virtual QByteArray serialize();
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "QVariantGLM.h"
|
||||||
|
|
||||||
#include "ObjectActionSpring.h"
|
#include "ObjectActionSpring.h"
|
||||||
|
|
||||||
const uint16_t ObjectActionSpring::springVersion = 1;
|
const uint16_t ObjectActionSpring::springVersion = 1;
|
||||||
|
@ -150,6 +152,24 @@ bool ObjectActionSpring::updateArguments(QVariantMap arguments) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap ObjectActionSpring::getArguments() {
|
||||||
|
QVariantMap arguments;
|
||||||
|
lockForRead();
|
||||||
|
|
||||||
|
if (_positionalTargetSet) {
|
||||||
|
arguments["linearTimeScale"] = _linearTimeScale;
|
||||||
|
arguments["targetPosition"] = glmToQMap(_positionalTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_rotationalTargetSet) {
|
||||||
|
arguments["targetRotation"] = glmToQMap(_rotationalTarget);
|
||||||
|
arguments["angularTimeScale"] = _angularTimeScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock();
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray ObjectActionSpring::serialize() {
|
QByteArray ObjectActionSpring::serialize() {
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QDataStream dataStream(&ba, QIODevice::WriteOnly);
|
QDataStream dataStream(&ba, QIODevice::WriteOnly);
|
||||||
|
|
|
@ -25,6 +25,8 @@ public:
|
||||||
virtual EntityActionType getType() { return ACTION_TYPE_SPRING; }
|
virtual EntityActionType getType() { return ACTION_TYPE_SPRING; }
|
||||||
|
|
||||||
virtual bool updateArguments(QVariantMap arguments);
|
virtual bool updateArguments(QVariantMap arguments);
|
||||||
|
virtual QVariantMap getArguments();
|
||||||
|
|
||||||
virtual void updateActionWorker(float deltaTimeStep);
|
virtual void updateActionWorker(float deltaTimeStep);
|
||||||
|
|
||||||
virtual QByteArray serialize();
|
virtual QByteArray serialize();
|
||||||
|
|
|
@ -24,6 +24,22 @@ QVariantList rgbColorToQList(rgbColor& v) {
|
||||||
return QVariantList() << (int)(v[0]) << (int)(v[1]) << (int)(v[2]);
|
return QVariantList() << (int)(v[0]) << (int)(v[1]) << (int)(v[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap glmToQMap(const glm::vec3& g) {
|
||||||
|
QVariantMap p;
|
||||||
|
p["x"] = g.x;
|
||||||
|
p["y"] = g.y;
|
||||||
|
p["z"] = g.z;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap glmToQMap(const glm::quat& g) {
|
||||||
|
QVariantMap q;
|
||||||
|
q["x"] = g.x;
|
||||||
|
q["y"] = g.y;
|
||||||
|
q["z"] = g.z;
|
||||||
|
q["w"] = g.w;
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 qListToGlmVec3(const QVariant q) {
|
glm::vec3 qListToGlmVec3(const QVariant q) {
|
||||||
|
|
|
@ -21,6 +21,9 @@ QVariantList glmToQList(const glm::vec3& g);
|
||||||
QVariantList glmToQList(const glm::quat& g);
|
QVariantList glmToQList(const glm::quat& g);
|
||||||
QVariantList rgbColorToQList(rgbColor& v);
|
QVariantList rgbColorToQList(rgbColor& v);
|
||||||
|
|
||||||
|
QVariantMap glmToQMap(const glm::vec3& g);
|
||||||
|
QVariantMap glmToQMap(const glm::quat& g);
|
||||||
|
|
||||||
glm::vec3 qListToGlmVec3(const QVariant q);
|
glm::vec3 qListToGlmVec3(const QVariant q);
|
||||||
glm::quat qListToGlmQuat(const QVariant q);
|
glm::quat qListToGlmQuat(const QVariant q);
|
||||||
void qListtoRgbColor(const QVariant q, rgbColor returnValue);
|
void qListtoRgbColor(const QVariant q, rgbColor returnValue);
|
||||||
|
|
Loading…
Reference in a new issue