mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 21:13:31 +02:00
renderBoundingBox() for sim-ownership debug
This commit is contained in:
parent
0e12cdc39e
commit
6497ac6c82
4 changed files with 15 additions and 45 deletions
libraries/entities-renderer/src
|
@ -9,6 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "RenderableBoxEntityItem.h"
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
|
@ -18,7 +20,7 @@
|
|||
#include <ObjectMotionState.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "RenderableBoxEntityItem.h"
|
||||
#include "RenderableDebugableEntityItem.h"
|
||||
|
||||
EntityItemPointer RenderableBoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return EntityItemPointer(new RenderableBoxEntityItem(entityID, properties));
|
||||
|
@ -34,39 +36,5 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
|||
batch.setModelTransform(getTransformToCenter());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(batch, 1.0f, cubeColor);
|
||||
|
||||
// TODO: use RenderableDebugableEntityItem::render (instead of the hack below)
|
||||
// when we fix the scaling bug that breaks RenderableDebugableEntityItem for boxes.
|
||||
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
Transform transform = getTransformToCenter();
|
||||
//transform.postScale(entity->getDimensions()); // HACK: this line breaks for BoxEntityItem
|
||||
batch.setModelTransform(transform);
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid& myNodeID = nodeList->getSessionUUID();
|
||||
bool highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
||||
if (highlightSimulationOwnership) {
|
||||
glm::vec4 greenColor(0.0f, 1.0f, 0.2f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.08f, greenColor);
|
||||
}
|
||||
|
||||
quint64 now = usecTimestampNow();
|
||||
if (now - getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
|
||||
glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.16f, redColor);
|
||||
}
|
||||
|
||||
if (now - getLastBroadcast() < 0.2f * USECS_PER_SECOND) {
|
||||
glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.24f, yellowColor);
|
||||
}
|
||||
|
||||
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(getPhysicsInfo());
|
||||
if (motionState && motionState->isActive()) {
|
||||
glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.32f, blueColor);
|
||||
}
|
||||
}
|
||||
//RenderableDebugableEntityItem::render(this, args); // TODO: use this instead of the hack above
|
||||
RenderableDebugableEntityItem::render(this, args);
|
||||
};
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#define hifi_RenderableBoxEntityItem_h
|
||||
|
||||
#include <BoxEntityItem.h>
|
||||
#include "RenderableDebugableEntityItem.h"
|
||||
#include "RenderableEntityItem.h"
|
||||
|
||||
class RenderableBoxEntityItem : public BoxEntityItem {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
//
|
||||
|
||||
|
||||
#include "RenderableDebugableEntityItem.h"
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
|
@ -18,15 +19,13 @@
|
|||
#include <DeferredLightingEffect.h>
|
||||
#include <ObjectMotionState.h>
|
||||
|
||||
#include "RenderableDebugableEntityItem.h"
|
||||
|
||||
|
||||
void RenderableDebugableEntityItem::renderBoundingBox(EntityItem* entity, RenderArgs* args,
|
||||
float puffedOut, glm::vec4& color) {
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
Transform transform = entity->getTransformToCenter();
|
||||
transform.postScale(entity->getDimensions());
|
||||
//transform.postScale(entity->getDimensions());
|
||||
batch.setModelTransform(transform);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.0f + puffedOut, color);
|
||||
}
|
||||
|
@ -44,24 +43,24 @@ void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args)
|
|||
bool highlightSimulationOwnership = (entity->getSimulatorID() == myNodeID);
|
||||
if (highlightSimulationOwnership) {
|
||||
glm::vec4 greenColor(0.0f, 1.0f, 0.2f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.08f, greenColor);
|
||||
renderBoundingBox(entity, args, 0.08f, greenColor);
|
||||
}
|
||||
|
||||
quint64 now = usecTimestampNow();
|
||||
if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
|
||||
glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.16f, redColor);
|
||||
renderBoundingBox(entity, args, 0.16f, redColor);
|
||||
}
|
||||
|
||||
if (now - entity->getLastBroadcast() < 0.2f * USECS_PER_SECOND) {
|
||||
glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.24f, yellowColor);
|
||||
renderBoundingBox(entity, args, 0.24f, yellowColor);
|
||||
}
|
||||
|
||||
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
|
||||
if (motionState && motionState->isActive()) {
|
||||
glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.32f, blueColor);
|
||||
renderBoundingBox(entity, args, 0.32f, blueColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "RenderableSphereEntityItem.h"
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
|
@ -18,7 +20,7 @@
|
|||
#include <DeferredLightingEffect.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "RenderableSphereEntityItem.h"
|
||||
#include "RenderableDebugableEntityItem.h"
|
||||
|
||||
EntityItemPointer RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return EntityItemPointer(new RenderableSphereEntityItem(entityID, properties));
|
||||
|
@ -39,4 +41,6 @@ void RenderableSphereEntityItem::render(RenderArgs* args) {
|
|||
gpu::Batch& batch = *args->_batch;
|
||||
batch.setModelTransform(getTransformToCenter());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(batch, 0.5f, SLICES, STACKS, sphereColor);
|
||||
|
||||
RenderableDebugableEntityItem::render(this, args);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue