mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 13:53:11 +02:00
first stab at sending action data across wire
This commit is contained in:
parent
32cf669d8b
commit
fce551099f
2 changed files with 39 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "EntitiesLogging.h"
|
||||
#include "EntityTree.h"
|
||||
#include "EntitySimulation.h"
|
||||
#include "EntityActionFactoryInterface.h"
|
||||
|
||||
bool EntityItem::_sendPhysicsUpdates = true;
|
||||
|
||||
|
@ -1363,7 +1364,6 @@ bool EntityItem::addAction(EntitySimulation* simulation, EntityActionPointer act
|
|||
assert(action->getOwnerEntity().get() == this);
|
||||
|
||||
simulation->addAction(action);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1398,7 +1398,35 @@ void EntityItem::clearActions(EntitySimulation* simulation) {
|
|||
}
|
||||
|
||||
void EntityItem::setActionData(QByteArray actionData) {
|
||||
QVector<QByteArray> serializedActions;
|
||||
QDataStream ds(actionData);
|
||||
ds >> serializedActions;
|
||||
|
||||
foreach(QByteArray serializedAction, serializedActions) {
|
||||
QDataStream dsForAction(serializedAction);
|
||||
EntityActionType actionType;
|
||||
QUuid actionID;
|
||||
dsForAction >> actionType;
|
||||
dsForAction >> actionID;
|
||||
|
||||
if (_objectActions.contains(actionID)) {
|
||||
EntityActionPointer action = _objectActions[actionID];
|
||||
// XXX make sure types match?
|
||||
action->deserializeFromDataStream(dsForAction);
|
||||
} else {
|
||||
auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>();
|
||||
|
||||
EntityTree* entityTree = _element ? _element->getTree() : nullptr;
|
||||
EntitySimulation* simulation = entityTree? entityTree->getSimulation() : nullptr;
|
||||
|
||||
if (entityTree) {
|
||||
EntityItemPointer entity = entityTree->findEntityByEntityItemID(_id);
|
||||
if (actionFactory->factoryBA(simulation, entity, serializedAction)) {
|
||||
// XXX something
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -485,6 +485,16 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID,
|
|||
|
||||
bool success = actor(simulation, entity);
|
||||
_entityTree->unlock();
|
||||
|
||||
// transmit the change
|
||||
_entityTree->lockForRead();
|
||||
EntityItemProperties properties = entity->getProperties();
|
||||
_entityTree->unlock();
|
||||
properties.setActionDataDirty();
|
||||
auto now = usecTimestampNow();
|
||||
properties.setLastEdited(now);
|
||||
queueEntityMessage(PacketTypeEntityEdit, entityID, properties);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue