improve terse entity logging. change how action data sending is triggered

This commit is contained in:
Seth Alves 2015-11-10 13:58:09 -08:00
parent d043011a11
commit 5e4f30b2bb
4 changed files with 91 additions and 10 deletions

View file

@ -17,6 +17,7 @@
#include "OctreeSendThread.h"
#include "OctreeServer.h"
#include "OctreeServerConsts.h"
#include "OctreeLogging.h"
quint64 startSceneSleepTime = 0;
quint64 endSceneSleepTime = 0;
@ -571,9 +572,9 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
if (somethingToSend) {
qDebug() << "Hit PPS Limit, packetsSentThisInterval =" << packetsSentThisInterval
<< " maxPacketsPerInterval = " << maxPacketsPerInterval
<< " clientMaxPacketsPerInterval = " << clientMaxPacketsPerInterval;
qCDebug(octree) << "Hit PPS Limit, packetsSentThisInterval =" << packetsSentThisInterval
<< " maxPacketsPerInterval = " << maxPacketsPerInterval
<< " clientMaxPacketsPerInterval = " << clientMaxPacketsPerInterval;
}

View file

@ -1770,6 +1770,7 @@ void EntityItem::serializeActions(bool& success, QByteArray& result) const {
serializedActionsStream << serializedActions;
if (result.size() >= _maxActionsDataSize) {
qDebug() << "EntityItem::serializeActions size is too large -- " << result.size() << ">=" << _maxActionsDataSize;
success = false;
return;
}

View file

@ -611,7 +611,8 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,
const QVariantMap& arguments) {
QUuid actionID = QUuid::createUuid();
auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>();
bool success = actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
bool success = true;
actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
// create this action even if the entity doesn't have physics info. it will often be the
// case that a script adds an action immediately after an object is created, and the physicsInfo
// is computed asynchronously.
@ -620,17 +621,18 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,
// }
EntityActionType actionType = EntityActionInterface::actionTypeFromString(actionTypeString);
if (actionType == ACTION_TYPE_NONE) {
success = false;
return false;
}
EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments);
if (action) {
entity->addAction(simulation, action);
success = entity->addAction(simulation, action);
auto nodeList = DependencyManager::get<NodeList>();
const QUuid myNodeID = nodeList->getSessionUUID();
if (entity->getSimulatorID() != myNodeID) {
entity->flagForOwnership();
}
return true;
return false; // Physics will cause a packet to be sent, so don't send from here.
}
return false;
});
@ -656,9 +658,12 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid&
}
bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) {
return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
return entity->removeAction(simulation, actionID);
bool success = false;
actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
success = entity->removeAction(simulation, actionID);
return false; // Physics will cause a packet to be sent, so don't send from here.
});
return success;
}
QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) {

View file

@ -612,6 +612,14 @@ EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entit
}
void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<QString>& changedProperties) {
static quint64 lastTerseLog = 0;
quint64 now = usecTimestampNow();
if (now - lastTerseLog > USECS_PER_SECOND) {
qCDebug(entities) << "-------------------------";
}
lastTerseLog = now;
if (properties.simulationOwnerChanged()) {
int simIndex = changedProperties.indexOf("simulationOwner");
if (simIndex >= 0) {
@ -619,6 +627,70 @@ void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<Q
changedProperties[simIndex] = QString("simulationOwner:") + QString::number((int)simOwner.getPriority());
}
}
if (properties.velocityChanged()) {
int index = changedProperties.indexOf("velocity");
if (index >= 0) {
glm::vec3 value = properties.getVelocity();
QString changeHint = "0";
if (value.x + value.y + value.z > 0) {
changeHint = "+";
} else if (value.x + value.y + value.z < 0) {
changeHint = "-";
}
changedProperties[index] = QString("velocity:") + changeHint;
}
}
if (properties.gravityChanged()) {
int index = changedProperties.indexOf("gravity");
if (index >= 0) {
glm::vec3 value = properties.getGravity();
QString changeHint = "0";
if (value.x + value.y + value.z > 0) {
changeHint = "+";
} else if (value.x + value.y + value.z < 0) {
changeHint = "-";
}
changedProperties[index] = QString("gravity:") + changeHint;
}
}
if (properties.actionDataChanged()) {
int index = changedProperties.indexOf("actionData");
if (index >= 0) {
QByteArray value = properties.getActionData();
QString changeHint = "0";
if (value.size() > 0) {
changeHint = "+";
}
changedProperties[index] = QString("actionData:") + changeHint;
}
}
if (properties.ignoreForCollisionsChanged()) {
int index = changedProperties.indexOf("ignoreForCollisions");
if (index >= 0) {
bool value = properties.getIgnoreForCollisions();
QString changeHint = "0";
if (value) {
changeHint = "1";
}
changedProperties[index] = QString("ignoreForCollisions:") + changeHint;
}
}
if (properties.collisionsWillMoveChanged()) {
int index = changedProperties.indexOf("collisionsWillMove");
if (index >= 0) {
bool value = properties.getCollisionsWillMove();
QString changeHint = "0";
if (value) {
changeHint = "1";
}
changedProperties[index] = QString("collisionsWillMove:") + changeHint;
}
}
}
int EntityTree::processEditPacketData(NLPacket& packet, const unsigned char* editData, int maxLength,
@ -673,7 +745,9 @@ int EntityTree::processEditPacketData(NLPacket& packet, const unsigned char* edi
if (wantTerseEditLogging()) {
QList<QString> changedProperties = properties.listChangedProperties();
fixupTerseEditLogging(properties, changedProperties);
qCDebug(entities) << "edit" << entityItemID.toString() << changedProperties;
QString itemName =
existingEntity->getName() != "" ? existingEntity->getName() : entityItemID.toString();
qCDebug(entities) << "edit" << itemName << changedProperties;
}
endLogging = usecTimestampNow();
@ -703,7 +777,7 @@ int EntityTree::processEditPacketData(NLPacket& packet, const unsigned char* edi
if (wantTerseEditLogging()) {
QList<QString> changedProperties = properties.listChangedProperties();
fixupTerseEditLogging(properties, changedProperties);
qCDebug(entities) << "add" << entityItemID.toString() << changedProperties;
qCDebug(entities) << "add" << entityItemID << changedProperties;
}
endLogging = usecTimestampNow();