mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 19:33:01 +02:00
fix rendering of simulation ownership debug info
This commit is contained in:
parent
759a4a323b
commit
4df87ec4e8
4 changed files with 59 additions and 50 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
|
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
|
#include <ObjectMotionState.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
|
||||||
#include "RenderableBoxEntityItem.h"
|
#include "RenderableBoxEntityItem.h"
|
||||||
|
@ -27,23 +28,45 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
||||||
PerformanceTimer perfTimer("RenderableBoxEntityItem::render");
|
PerformanceTimer perfTimer("RenderableBoxEntityItem::render");
|
||||||
Q_ASSERT(getType() == EntityTypes::Box);
|
Q_ASSERT(getType() == EntityTypes::Box);
|
||||||
glm::vec4 cubeColor(toGlm(getXColor()), getLocalRenderAlpha());
|
glm::vec4 cubeColor(toGlm(getXColor()), getLocalRenderAlpha());
|
||||||
|
|
||||||
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
|
|
||||||
bool highlightSimulationOwnership = false;
|
|
||||||
if (debugSimulationOwnership) {
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
const QUuid& myNodeID = nodeList->getSessionUUID();
|
|
||||||
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT(args->_batch);
|
Q_ASSERT(args->_batch);
|
||||||
gpu::Batch& batch = *args->_batch;
|
gpu::Batch& batch = *args->_batch;
|
||||||
batch.setModelTransform(getTransformToCenter());
|
batch.setModelTransform(getTransformToCenter());
|
||||||
if (highlightSimulationOwnership) {
|
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(batch, 1.0f, cubeColor);
|
||||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.0f, cubeColor);
|
|
||||||
} else {
|
|
||||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(batch, 1.0f, cubeColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderableDebugableEntityItem::render(this, args);
|
// 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
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,9 +15,8 @@
|
||||||
|
|
||||||
#include <gpu/GPUConfig.h>
|
#include <gpu/GPUConfig.h>
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
|
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
#include <PhysicsEngine.h>
|
#include <ObjectMotionState.h>
|
||||||
|
|
||||||
#include "RenderableDebugableEntityItem.h"
|
#include "RenderableDebugableEntityItem.h"
|
||||||
|
|
||||||
|
@ -26,42 +25,43 @@ void RenderableDebugableEntityItem::renderBoundingBox(EntityItem* entity, Render
|
||||||
float puffedOut, glm::vec4& color) {
|
float puffedOut, glm::vec4& color) {
|
||||||
Q_ASSERT(args->_batch);
|
Q_ASSERT(args->_batch);
|
||||||
gpu::Batch& batch = *args->_batch;
|
gpu::Batch& batch = *args->_batch;
|
||||||
batch.setModelTransform(entity->getTransformToCenter());
|
Transform transform = entity->getTransformToCenter();
|
||||||
|
transform.postScale(entity->getDimensions());
|
||||||
|
batch.setModelTransform(transform);
|
||||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.0f + puffedOut, color);
|
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.0f + puffedOut, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableDebugableEntityItem::renderHoverDot(EntityItem* entity, RenderArgs* args) {
|
|
||||||
const int SLICES = 8, STACKS = 8;
|
|
||||||
float radius = 0.05f;
|
|
||||||
glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
|
|
||||||
|
|
||||||
Q_ASSERT(args->_batch);
|
|
||||||
gpu::Batch& batch = *args->_batch;
|
|
||||||
Transform transform = entity->getTransformToCenter();
|
|
||||||
// Cancel true dimensions and set scale to 2 * radius (diameter)
|
|
||||||
transform.postScale(2.0f * glm::vec3(radius, radius, radius) / entity->getDimensions());
|
|
||||||
batch.setModelTransform(transform);
|
|
||||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(batch, 0.5f, SLICES, STACKS, blueColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) {
|
void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) {
|
||||||
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
|
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
|
||||||
|
Q_ASSERT(args->_batch);
|
||||||
|
gpu::Batch& batch = *args->_batch;
|
||||||
|
Transform transform = entity->getTransformToCenter();
|
||||||
|
transform.postScale(entity->getDimensions());
|
||||||
|
batch.setModelTransform(transform);
|
||||||
|
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
const QUuid& myNodeID = nodeList->getSessionUUID();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (debugSimulationOwnership) {
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
|
if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
|
||||||
glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f);
|
glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
renderBoundingBox(entity, args, 0.2f, redColor);
|
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.16f, redColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now - entity->getLastBroadcast() < 0.2f * USECS_PER_SECOND) {
|
if (now - entity->getLastBroadcast() < 0.2f * USECS_PER_SECOND) {
|
||||||
glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f);
|
glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f);
|
||||||
renderBoundingBox(entity, args, 0.3f, yellowColor);
|
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.24f, yellowColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
|
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
|
||||||
if (motionState && motionState->isActive()) {
|
if (motionState && motionState->isActive()) {
|
||||||
renderHoverDot(entity, args);
|
glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.32f, blueColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
class RenderableDebugableEntityItem {
|
class RenderableDebugableEntityItem {
|
||||||
public:
|
public:
|
||||||
static void renderBoundingBox(EntityItem* entity, RenderArgs* args, float puffedOut, glm::vec4& color);
|
static void renderBoundingBox(EntityItem* entity, RenderArgs* args, float puffedOut, glm::vec4& color);
|
||||||
static void renderHoverDot(EntityItem* entity, RenderArgs* args);
|
|
||||||
static void render(EntityItem* entity, RenderArgs* args);
|
static void render(EntityItem* entity, RenderArgs* args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -201,14 +201,6 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
glm::vec3 position = getPosition();
|
glm::vec3 position = getPosition();
|
||||||
glm::vec3 dimensions = getDimensions();
|
glm::vec3 dimensions = getDimensions();
|
||||||
|
|
||||||
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
|
|
||||||
bool highlightSimulationOwnership = false;
|
|
||||||
if (debugSimulationOwnership) {
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
const QUuid& myNodeID = nodeList->getSessionUUID();
|
|
||||||
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasModel()) {
|
if (hasModel()) {
|
||||||
if (_model) {
|
if (_model) {
|
||||||
if (QUrl(getModelURL()) != _model->getURL()) {
|
if (QUrl(getModelURL()) != _model->getURL()) {
|
||||||
|
@ -274,11 +266,6 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlightSimulationOwnership) {
|
|
||||||
glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
|
|
||||||
RenderableDebugableEntityItem::renderBoundingBox(this, args, 0.0f, greenColor);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
|
glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
RenderableDebugableEntityItem::renderBoundingBox(this, args, 0.0f, greenColor);
|
RenderableDebugableEntityItem::renderBoundingBox(this, args, 0.0f, greenColor);
|
||||||
|
|
Loading…
Reference in a new issue