more debugging prints

This commit is contained in:
Seth Alves 2015-11-11 16:03:08 -08:00
parent f07d5d9d3f
commit 07f3d8eca0
5 changed files with 52 additions and 31 deletions

View file

@ -304,3 +304,24 @@ QDataStream& operator>>(QDataStream& stream, EntityActionType& entityActionType)
entityActionType = (EntityActionType)actionTypeAsInt;
return stream;
}
QString serializedActionsToDebugString(QByteArray data) {
if (data.size() == 0) {
return QString();
}
QVector<QByteArray> serializedActions;
QDataStream serializedActionsStream(data);
serializedActionsStream >> serializedActions;
QString result;
foreach(QByteArray serializedAction, serializedActions) {
QDataStream serializedActionStream(serializedAction);
EntityActionType actionType;
QUuid actionID;
serializedActionStream >> actionType;
serializedActionStream >> actionID;
result += EntityActionInterface::actionTypeToString(actionType) + "-" + actionID.toString() + " ";
}
return result;
}

View file

@ -89,4 +89,6 @@ typedef std::shared_ptr<EntityActionInterface> EntityActionPointer;
QDataStream& operator<<(QDataStream& stream, const EntityActionType& entityActionType);
QDataStream& operator>>(QDataStream& stream, EntityActionType& entityActionType);
QString serializedActionsToDebugString(QByteArray data);
#endif // hifi_EntityActionInterface_h

View file

@ -630,11 +630,11 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
dataAt += bytes;
bytesRead += bytes;
if (wantTerseEditLogging() && _simulationOwner != newSimOwner) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << newSimOwner;
}
if (_simulationOwner.set(newSimOwner)) {
_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID;
if (wantTerseEditLogging()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << newSimOwner;
}
}
}
{ // When we own the simulation we don't accept updates to the entity's transform/velocities
@ -740,7 +740,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
// this "new" data is actually slightly out of date. We calculate the time we need to skip forward and
// use our simulation helper routine to get a best estimate of where the entity should be.
float skipTimeForward = (float)(now - lastSimulatedFromBufferAdjusted) / (float)(USECS_PER_SECOND);
// we want to extrapolate the motion forward to compensate for packet travel time, but
// we don't want the side effect of flag setting.
simulateKinematicMotion(skipTimeForward, false);
@ -748,7 +748,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
if (overwriteLocalData) {
if (!_simulationOwner.matchesValidID(myNodeID)) {
_lastSimulated = now;
}
}
@ -1500,33 +1499,36 @@ void EntityItem::updateCreated(uint64_t value) {
}
void EntityItem::setSimulationOwner(const QUuid& id, quint8 priority) {
if (_simulationOwner.set(id, priority)) {
if (wantTerseEditLogging()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << id;
}
if (wantTerseEditLogging() && (id != _simulationOwner.getID() || priority != _simulationOwner.getPriority())) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << id << priority;
}
_simulationOwner.set(id, priority);
}
void EntityItem::setSimulationOwner(const SimulationOwner& owner) {
if (_simulationOwner.set(owner)) {
if (wantTerseEditLogging()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << owner;
}
if (wantTerseEditLogging() && _simulationOwner != owner) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << owner;
}
_simulationOwner.set(owner);
}
void EntityItem::updateSimulatorID(const QUuid& value) {
if (wantTerseEditLogging() && _simulationOwner.getID() != value) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << value;
}
if (_simulationOwner.setID(value)) {
_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID;
if (wantTerseEditLogging()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << value;
}
}
}
void EntityItem::clearSimulationOwnership() {
if (wantTerseEditLogging() && !_simulationOwner.isNull()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now null";
}
_simulationOwner.clear();
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now null";
// don't bother setting the DIRTY_SIMULATOR_ID flag because clearSimulationOwnership()
// is only ever called entity-server-side and the flags are only used client-side
//_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID;
@ -1669,7 +1671,7 @@ void EntityItem::deserializeActionsInternal() {
return;
}
EntityTreePointer entityTree = _element ? _element->getTree() : nullptr;
EntityTreePointer entityTree = getTree();
assert(entityTree);
EntitySimulation* simulation = entityTree ? entityTree->getSimulation() : nullptr;
assert(simulation);

View file

@ -197,13 +197,11 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
properties.setVelocityChanged(false);
properties.setAngularVelocityChanged(false);
properties.setAccelerationChanged(false);
}
// if (wantTerseEditLogging()) {
// if (properties.simulationOwnerChanged()) {
// qCDebug(entities) << "sim ownership for" << entity->getDebugName() << "is now" << senderID;
// }
// }
if (wantTerseEditLogging()) {
qCDebug(entities) << senderNode->getUUID() << "physical edits suppressed";
}
}
}
// else client accepts what the server says
@ -666,10 +664,7 @@ void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<Q
int index = changedProperties.indexOf("actionData");
if (index >= 0) {
QByteArray value = properties.getActionData();
QString changeHint = "0";
if (value.size() > 0) {
changeHint = "+";
}
QString changeHint = serializedActionsToDebugString(value);
changedProperties[index] = QString("actionData:") + changeHint;
}
}
@ -763,7 +758,8 @@ int EntityTree::processEditPacketData(NLPacket& packet, const unsigned char* edi
if (wantTerseEditLogging()) {
QList<QString> changedProperties = properties.listChangedProperties();
fixupTerseEditLogging(properties, changedProperties);
qCDebug(entities) << "edit" << existingEntity->getDebugName() << changedProperties;
qCDebug(entities) << senderNode->getUUID() << "edit" <<
existingEntity->getDebugName() << changedProperties;
}
endLogging = usecTimestampNow();
@ -793,7 +789,7 @@ int EntityTree::processEditPacketData(NLPacket& packet, const unsigned char* edi
if (wantTerseEditLogging()) {
QList<QString> changedProperties = properties.listChangedProperties();
fixupTerseEditLogging(properties, changedProperties);
qCDebug(entities) << "add" << entityItemID << changedProperties;
qCDebug(entities) << senderNode->getUUID() << "add" << entityItemID << changedProperties;
}
endLogging = usecTimestampNow();

View file

@ -157,7 +157,7 @@ void SimulationOwner::test() {
}
bool SimulationOwner::operator!=(const SimulationOwner& other) {
return (_id != other._id && _priority != other._priority);
return (_id != other._id || _priority != other._priority);
}
SimulationOwner& SimulationOwner::operator=(const SimulationOwner& other) {