terse logging for sim ownership

This commit is contained in:
Seth Alves 2015-11-11 08:51:10 -08:00
parent c2b0ccd6b3
commit 31ebe5dba1
3 changed files with 30 additions and 11 deletions

View file

@ -632,6 +632,9 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
if (_simulationOwner.set(newSimOwner)) { if (_simulationOwner.set(newSimOwner)) {
_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID; _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 { // When we own the simulation we don't accept updates to the entity's transform/velocities
@ -996,6 +999,11 @@ EntityTreePointer EntityItem::getTree() const {
return tree; return tree;
} }
bool EntityItem::wantTerseEditLogging() {
EntityTreePointer tree = getTree();
return tree ? tree->wantTerseEditLogging() : false;
}
glm::mat4 EntityItem::getEntityToWorldMatrix() const { glm::mat4 EntityItem::getEntityToWorldMatrix() const {
glm::mat4 translation = glm::translate(getPosition()); glm::mat4 translation = glm::translate(getPosition());
glm::mat4 rotation = glm::mat4_cast(getRotation()); glm::mat4 rotation = glm::mat4_cast(getRotation());
@ -1492,21 +1500,33 @@ void EntityItem::updateCreated(uint64_t value) {
} }
void EntityItem::setSimulationOwner(const QUuid& id, quint8 priority) { void EntityItem::setSimulationOwner(const QUuid& id, quint8 priority) {
_simulationOwner.set(id, priority); if (_simulationOwner.set(id, priority)) {
if (wantTerseEditLogging()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << id;
}
}
} }
void EntityItem::setSimulationOwner(const SimulationOwner& owner) { void EntityItem::setSimulationOwner(const SimulationOwner& owner) {
_simulationOwner.set(owner); if (_simulationOwner.set(owner)) {
if (wantTerseEditLogging()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << owner;
}
}
} }
void EntityItem::updateSimulatorID(const QUuid& value) { void EntityItem::updateSimulatorID(const QUuid& value) {
if (_simulationOwner.setID(value)) { if (_simulationOwner.setID(value)) {
_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID; _dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID;
if (wantTerseEditLogging()) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << value;
}
} }
} }
void EntityItem::clearSimulationOwnership() { void EntityItem::clearSimulationOwnership() {
_simulationOwner.clear(); _simulationOwner.clear();
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now null";
// don't bother setting the DIRTY_SIMULATOR_ID flag because clearSimulationOwnership() // 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 // is only ever called entity-server-side and the flags are only used client-side
//_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID; //_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID;

View file

@ -307,6 +307,7 @@ public:
QString getName() const { return _name; } QString getName() const { return _name; }
void setName(const QString& value) { _name = value; } void setName(const QString& value) { _name = value; }
QString getDebugName() { return _name != "" ? _name : getID().toString(); }
bool getVisible() const { return _visible; } bool getVisible() const { return _visible; }
void setVisible(bool value) { _visible = value; } void setVisible(bool value) { _visible = value; }
@ -381,6 +382,7 @@ public:
void setPhysicsInfo(void* data) { _physicsInfo = data; } void setPhysicsInfo(void* data) { _physicsInfo = data; }
EntityTreeElementPointer getElement() const { return _element; } EntityTreeElementPointer getElement() const { return _element; }
EntityTreePointer getTree() const; EntityTreePointer getTree() const;
bool wantTerseEditLogging();
static void setSendPhysicsUpdates(bool value) { _sendPhysicsUpdates = value; } static void setSendPhysicsUpdates(bool value) { _sendPhysicsUpdates = value; }
static bool getSendPhysicsUpdates() { return _sendPhysicsUpdates; } static bool getSendPhysicsUpdates() { return _sendPhysicsUpdates; }

View file

@ -199,12 +199,11 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
properties.setAccelerationChanged(false); properties.setAccelerationChanged(false);
} }
if (wantTerseEditLogging()) { // if (wantTerseEditLogging()) {
if (properties.simulationOwnerChanged()) { // if (properties.simulationOwnerChanged()) {
QString itemName = entity->getName() != "" ? entity->getName() : entity->getID().toString(); // qCDebug(entities) << "sim ownership for" << entity->getDebugName() << "is now" << senderID;
qCDebug(entities) << "sim ownership for" << itemName << "is now" << senderID; // }
} // }
}
} }
// else client accepts what the server says // else client accepts what the server says
@ -764,9 +763,7 @@ int EntityTree::processEditPacketData(NLPacket& packet, const unsigned char* edi
if (wantTerseEditLogging()) { if (wantTerseEditLogging()) {
QList<QString> changedProperties = properties.listChangedProperties(); QList<QString> changedProperties = properties.listChangedProperties();
fixupTerseEditLogging(properties, changedProperties); fixupTerseEditLogging(properties, changedProperties);
QString itemName = qCDebug(entities) << "edit" << existingEntity->getDebugName() << changedProperties;
existingEntity->getName() != "" ? existingEntity->getName() : entityItemID.toString();
qCDebug(entities) << "edit" << itemName << changedProperties;
} }
endLogging = usecTimestampNow(); endLogging = usecTimestampNow();