From 55bab2efd6925a235730f6c52957467cf572cc8b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 6 Apr 2015 18:09:45 -0700 Subject: [PATCH] put physics into its own logging group --- libraries/physics/src/EntityMotionState.cpp | 19 ++++++++------- libraries/physics/src/ObjectMotionState.cpp | 27 +++++++++++---------- libraries/physics/src/PhysicsEngine.cpp | 2 +- libraries/physics/src/PhysicsLogging.cpp | 14 +++++++++++ libraries/physics/src/PhysicsLogging.h | 14 +++++++++++ libraries/physics/src/ShapeManager.cpp | 2 +- 6 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 libraries/physics/src/PhysicsLogging.cpp create mode 100644 libraries/physics/src/PhysicsLogging.h diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 35eb006655..d84daa6b42 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -16,6 +16,7 @@ #include "EntityMotionState.h" #include "PhysicsEngine.h" #include "PhysicsHelpers.h" +#include "PhysicsLogging.h" QSet* _outgoingEntityList; @@ -108,10 +109,10 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) { #ifdef WANT_DEBUG quint64 now = usecTimestampNow(); - qDebug() << "EntityMotionState::setWorldTransform()... changed entity:" << _entity->getEntityItemID(); - qDebug() << " last edited:" << _entity->getLastEdited() << formatUsecTime(now - _entity->getLastEdited()) << "ago"; - qDebug() << " last simulated:" << _entity->getLastSimulated() << formatUsecTime(now - _entity->getLastSimulated()) << "ago"; - qDebug() << " last updated:" << _entity->getLastUpdated() << formatUsecTime(now - _entity->getLastUpdated()) << "ago"; + qCDebug(physics) << "EntityMotionState::setWorldTransform()... changed entity:" << _entity->getEntityItemID(); + qCDebug(physics) << " last edited:" << _entity->getLastEdited() << formatUsecTime(now - _entity->getLastEdited()) << "ago"; + qCDebug(physics) << " last simulated:" << _entity->getLastSimulated() << formatUsecTime(now - _entity->getLastSimulated()) << "ago"; + qCDebug(physics) << " last updated:" << _entity->getLastUpdated() << formatUsecTime(now - _entity->getLastUpdated()) << "ago"; #endif } @@ -238,9 +239,9 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ #ifdef WANT_DEBUG quint64 now = usecTimestampNow(); - qDebug() << "EntityMotionState::sendUpdate()"; - qDebug() << " EntityItemId:" << _entity->getEntityItemID() << "---------------------------------------------"; - qDebug() << " lastSimulated:" << debugTime(lastSimulated, now); + qCDebug(physics) << "EntityMotionState::sendUpdate()"; + qCDebug(physics) << " EntityItemId:" << _entity->getEntityItemID() << "---------------------------------------------"; + qCDebug(physics) << " lastSimulated:" << debugTime(lastSimulated, now); #endif //def WANT_DEBUG } else { @@ -251,12 +252,12 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ EntityItemID id(_entity->getID()); EntityEditPacketSender* entityPacketSender = static_cast(packetSender); #ifdef WANT_DEBUG - qDebug() << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()..."; + qCDebug(physics) << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()..."; #endif entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties); } else { #ifdef WANT_DEBUG - qDebug() << "EntityMotionState::sendUpdate()... NOT sending update as requested."; + qCDebug(physics) << "EntityMotionState::sendUpdate()... NOT sending update as requested."; #endif } diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 21dead5b0b..c9f416cc37 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -15,6 +15,7 @@ #include "ObjectMotionState.h" #include "PhysicsEngine.h" #include "PhysicsHelpers.h" +#include "PhysicsLogging.h" const float DEFAULT_FRICTION = 0.5f; const float MAX_FRICTION = 10.0f; @@ -161,11 +162,11 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { if (dx2 > MAX_POSITION_ERROR_SQUARED) { #ifdef WANT_DEBUG - qDebug() << ".... (dx2 > MAX_POSITION_ERROR_SQUARED) ...."; - qDebug() << "wasPosition:" << wasPosition; - qDebug() << "bullet position:" << position; - qDebug() << "_sentPosition:" << _sentPosition; - qDebug() << "dx2:" << dx2; + qCDebug(physics) << ".... (dx2 > MAX_POSITION_ERROR_SQUARED) ...."; + qCDebug(physics) << "wasPosition:" << wasPosition; + qCDebug(physics) << "bullet position:" << position; + qCDebug(physics) << "_sentPosition:" << _sentPosition; + qCDebug(physics) << "dx2:" << dx2; #endif return true; @@ -187,17 +188,17 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { #ifdef WANT_DEBUG if ((fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT)) { - qDebug() << ".... ((fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT)) ...."; + qCDebug(physics) << ".... ((fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT)) ...."; - qDebug() << "wasAngularVelocity:" << wasAngularVelocity; - qDebug() << "_sentAngularVelocity:" << _sentAngularVelocity; + qCDebug(physics) << "wasAngularVelocity:" << wasAngularVelocity; + qCDebug(physics) << "_sentAngularVelocity:" << _sentAngularVelocity; - qDebug() << "length wasAngularVelocity:" << glm::length(wasAngularVelocity); - qDebug() << "length _sentAngularVelocity:" << glm::length(_sentAngularVelocity); + qCDebug(physics) << "length wasAngularVelocity:" << glm::length(wasAngularVelocity); + qCDebug(physics) << "length _sentAngularVelocity:" << glm::length(_sentAngularVelocity); - qDebug() << "wasRotation:" << wasRotation; - qDebug() << "bullet actualRotation:" << actualRotation; - qDebug() << "_sentRotation:" << _sentRotation; + qCDebug(physics) << "wasRotation:" << wasRotation; + qCDebug(physics) << "bullet actualRotation:" << actualRotation; + qCDebug(physics) << "_sentRotation:" << _sentRotation; } #endif diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 67e4e0616f..97f1a0ddef 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -88,7 +88,7 @@ void PhysicsEngine::addEntityInternal(EntityItem* entity) { motionState->setKinematic(true, _numSubsteps); _nonPhysicalKinematicObjects.insert(motionState); // We failed to add the entity to the simulation. Probably because we couldn't create a shape for it. - //qDebug() << "failed to add entity " << entity->getEntityItemID() << " to physics engine"; + //qCDebug(physics) << "failed to add entity " << entity->getEntityItemID() << " to physics engine"; } } } diff --git a/libraries/physics/src/PhysicsLogging.cpp b/libraries/physics/src/PhysicsLogging.cpp new file mode 100644 index 0000000000..59d9fad3c3 --- /dev/null +++ b/libraries/physics/src/PhysicsLogging.cpp @@ -0,0 +1,14 @@ +// +// PhysicsLogging.h +// libraries/physics/src +// +// Created by Seth Alves on 4/6/15. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PhysicsLogging.h" + +Q_LOGGING_CATEGORY(physics, "hifi.physics") diff --git a/libraries/physics/src/PhysicsLogging.h b/libraries/physics/src/PhysicsLogging.h new file mode 100644 index 0000000000..8615dca031 --- /dev/null +++ b/libraries/physics/src/PhysicsLogging.h @@ -0,0 +1,14 @@ +// +// PhysicsLogging.h +// libraries/physics/src +// +// Created by Seth Alves on 4/6/15. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +Q_DECLARE_LOGGING_CATEGORY(physics) diff --git a/libraries/physics/src/ShapeManager.cpp b/libraries/physics/src/ShapeManager.cpp index 2c30887e3e..bed7b473da 100644 --- a/libraries/physics/src/ShapeManager.cpp +++ b/libraries/physics/src/ShapeManager.cpp @@ -37,7 +37,7 @@ btCollisionShape* ShapeManager::getShape(const ShapeInfo& info) { const float MIN_SHAPE_DIAGONAL_SQUARED = 3.0e-4f; // 1 cm cube const float MAX_SHAPE_DIAGONAL_SQUARED = 3.0e6f; // 1000 m cube if (diagonal < MIN_SHAPE_DIAGONAL_SQUARED || diagonal > MAX_SHAPE_DIAGONAL_SQUARED) { - // qDebug() << "ShapeManager::getShape -- not making shape due to size" << diagonal; + // qCDebug(physics) << "ShapeManager::getShape -- not making shape due to size" << diagonal; return NULL; } DoubleHashKey key = info.getHash();