From ebae87136fbd8847a9d4abf4997f41c11153c787 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 26 May 2015 20:57:58 -0700 Subject: [PATCH] debugging --- libraries/entities/src/EntityItem.cpp | 13 ++++++-- .../entities/src/EntityItemProperties.cpp | 2 +- .../entities/src/EntityScriptingInterface.cpp | 1 + libraries/entities/src/PolyVoxEntityItem.cpp | 30 ++++++++++++------- libraries/octree/src/OctreePacketData.cpp | 1 + 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 8cc373e5cc..94ad553c70 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -432,6 +432,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef // If this is from the same sever packet, then check against any local changes since we got // the most recent packet from this server time if (_lastEdited > _lastEditedFromRemote) { + qDebug() << "_lastEdited > _lastEditedFromRemote"; ignoreServerPacket = true; } } else { @@ -439,6 +440,14 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef // If we've changed our local tree more recently than the new data from this packet // then we will not be changing our values, instead we just read and skip the data if (_lastEdited > lastEditedFromBufferAdjusted) { + qDebug() << "_lastEdited > lastEditedFromBufferAdjusted"; + qDebug() << "_lastEdited =" << _lastEdited; + qDebug() << "lastEditedFromBuffer - clockSkew =" << lastEditedFromBuffer - clockSkew; + qDebug() << "lastEditedFromBufferAdjusted =" << lastEditedFromBufferAdjusted; + qDebug() << "lastEditedFromBuffer =" << lastEditedFromBuffer; + qDebug() << "clockSkew =" << clockSkew; + qDebug() << "now = " << now; + ignoreServerPacket = true; } } @@ -660,12 +669,12 @@ void EntityItem::adjustEditPacketForClockSkew(unsigned char* editPacketBuffer, s memcpy(&lastEditedInLocalTime, dataAt, sizeof(lastEditedInLocalTime)); quint64 lastEditedInServerTime = lastEditedInLocalTime + clockSkew; memcpy(dataAt, &lastEditedInServerTime, sizeof(lastEditedInServerTime)); - #ifdef WANT_DEBUG + //#ifdef WANT_DEBUG qCDebug(entities, "EntityItem::adjustEditPacketForClockSkew()..."); qCDebug(entities) << " lastEditedInLocalTime: " << lastEditedInLocalTime; qCDebug(entities) << " clockSkew: " << clockSkew; qCDebug(entities) << " lastEditedInServerTime: " << lastEditedInServerTime; - #endif + //#endif } float EntityItem::computeMass() const { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index fed8242e07..a9747ffe3a 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -539,7 +539,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) { _stage.copyFromScriptValue(object, _defaultSettings); _atmosphere.copyFromScriptValue(object, _defaultSettings); _skybox.copyFromScriptValue(object, _defaultSettings); - _lastEdited = usecTimestampNow(); + _lastEdited = usecTimestampNow(); // ??? } QScriptValue EntityItemPropertiesToScriptValue(QScriptEngine* engine, const EntityItemProperties& properties) { diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 6541c66865..0abc01fbd9 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -402,6 +402,7 @@ bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& c PolyVoxEntityItem* polyVoxEntity = static_cast(entity); _entityTree->lockForWrite(); polyVoxEntity->setSphere(center, radius, value); + // entity->setLastEdited(usecTimestampNow()); _entityTree->unlock(); _entityTree->lockForRead(); diff --git a/libraries/entities/src/PolyVoxEntityItem.cpp b/libraries/entities/src/PolyVoxEntityItem.cpp index b61ce79236..bf99ecd408 100644 --- a/libraries/entities/src/PolyVoxEntityItem.cpp +++ b/libraries/entities/src/PolyVoxEntityItem.cpp @@ -62,8 +62,11 @@ bool PolyVoxEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(voxelVolumeSize, setVoxelVolumeSize); SET_ENTITY_PROPERTY_FROM_PROPERTIES(voxelData, setVoxelData); + qDebug() << "PolyVoxEntityItem::setProperties somethingChanged =" << somethingChanged + << "prop has voxel-data =" << properties.getChangedProperties().getHasProperty(PROP_VOXEL_DATA); + if (somethingChanged) { - bool wantDebug = false; + bool wantDebug = true; if (wantDebug) { uint64_t now = usecTimestampNow(); int elapsed = now - getLastEdited(); @@ -76,18 +79,23 @@ bool PolyVoxEntityItem::setProperties(const EntityItemProperties& properties) { } int PolyVoxEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, - ReadBitstreamToTreeParams& args, - EntityPropertyFlags& propertyFlags, bool overwriteLocalData) { + ReadBitstreamToTreeParams& args, + EntityPropertyFlags& propertyFlags, bool overwriteLocalData) { int bytesRead = 0; const unsigned char* dataAt = data; - qDebug() << "PolyVoxEntityItem::readEntitySubclassDataFromBuffer"; + qDebug() << "PolyVoxEntityItem::readEntitySubclassDataFromBuffer" + << "propertyFlags.getHasProperty(PROP_VOXEL_DATA) =" << propertyFlags.getHasProperty(PROP_VOXEL_DATA) + << "overwriteLocalData =" << overwriteLocalData; + READ_ENTITY_PROPERTY(PROP_COLOR, rgbColor, setColor); READ_ENTITY_PROPERTY(PROP_VOXEL_VOLUME_SIZE, glm::vec3, setVoxelVolumeSize); READ_ENTITY_PROPERTY(PROP_VOXEL_DATA, QByteArray, setVoxelData); + + return bytesRead; } @@ -102,18 +110,20 @@ EntityPropertyFlags PolyVoxEntityItem::getEntityProperties(EncodeBitstreamParams } void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params, - EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData, - EntityPropertyFlags& requestedProperties, - EntityPropertyFlags& propertyFlags, - EntityPropertyFlags& propertiesDidntFit, - int& propertyCount, - OctreeElement::AppendState& appendState) const { + EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData, + EntityPropertyFlags& requestedProperties, + EntityPropertyFlags& propertyFlags, + EntityPropertyFlags& propertiesDidntFit, + int& propertyCount, + OctreeElement::AppendState& appendState) const { bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor()); APPEND_ENTITY_PROPERTY(PROP_VOXEL_VOLUME_SIZE, getVoxelVolumeSize()); APPEND_ENTITY_PROPERTY(PROP_VOXEL_DATA, getVoxelData()); + + qDebug() << "PolyVoxEntityItem::appendSubclassData successPropertyFits =" << successPropertyFits; } void PolyVoxEntityItem::debugDump() const { diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index ed30c619ca..416cdffe32 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -591,5 +591,6 @@ int OctreePacketData::uppackDataFromBytes(const unsigned char* dataBytes, QByteA dataBytes += sizeof(length); QByteArray value((const char*)dataBytes, length); result = value; + qDebug() << "OctreePacketData::uppackDataFromBytes uppacked " << length; return sizeof(length) + length; }