mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 23:39:26 +02:00
move common debugging rendering into a new class
This commit is contained in:
parent
f3d1b964e3
commit
3765ace7ef
7 changed files with 106 additions and 38 deletions
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// RenderableBoxEntityItem.cpp
|
// RenderableBoxEntityItem.cpp
|
||||||
// interface/src
|
// libraries/entities-renderer/src/
|
||||||
//
|
//
|
||||||
// Created by Brad Hefta-Gaub on 8/6/14.
|
// Created by Brad Hefta-Gaub on 8/6/14.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -36,8 +36,9 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
||||||
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
|
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
|
||||||
|
|
||||||
|
|
||||||
|
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
|
||||||
bool highlightSimulationOwnership = false;
|
bool highlightSimulationOwnership = false;
|
||||||
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
|
if (debugSimulationOwnership) {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
const QUuid& myNodeID = nodeList->getSessionUUID();
|
const QUuid& myNodeID = nodeList->getSessionUUID();
|
||||||
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
||||||
|
@ -58,4 +59,6 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
RenderableDebugableEntityItem::render(args);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// RenderableBoxEntityItem.h
|
// RenderableDebugableEntityItem.h
|
||||||
// interface/src/entities
|
// libraries/entities-renderer/src/
|
||||||
//
|
//
|
||||||
// Created by Brad Hefta-Gaub on 8/6/14.
|
// Created by Brad Hefta-Gaub on 8/6/14.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
@ -13,8 +13,9 @@
|
||||||
#define hifi_RenderableBoxEntityItem_h
|
#define hifi_RenderableBoxEntityItem_h
|
||||||
|
|
||||||
#include <BoxEntityItem.h>
|
#include <BoxEntityItem.h>
|
||||||
|
#include "RenderableDebugableEntityItem.h"
|
||||||
|
|
||||||
class RenderableBoxEntityItem : public BoxEntityItem {
|
class RenderableBoxEntityItem : public BoxEntityItem, public RenderableDebugableEntityItem {
|
||||||
public:
|
public:
|
||||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
//
|
||||||
|
// RenderableDebugableEntityItem.cpp
|
||||||
|
// libraries/entities-renderer/src/
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub on 8/6/14.
|
||||||
|
// 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 <glm/gtx/quaternion.hpp>
|
||||||
|
#include <gpu/GPUConfig.h>
|
||||||
|
#include <DeferredLightingEffect.h>
|
||||||
|
|
||||||
|
#include "RenderableDebugableEntityItem.h"
|
||||||
|
|
||||||
|
|
||||||
|
void RenderableDebugableEntityItem::renderBoundingBox(RenderArgs* args, bool puffedOut) {
|
||||||
|
|
||||||
|
EntityItem* entity = dynamic_cast<EntityItem*>(this);
|
||||||
|
|
||||||
|
glm::vec3 position = entity->getPosition();
|
||||||
|
glm::vec3 center = entity->getCenter();
|
||||||
|
glm::vec3 dimensions = entity->getDimensions();
|
||||||
|
glm::quat rotation = entity->getRotation();
|
||||||
|
// float size = glm::length(dimensions) / 2.0f;
|
||||||
|
|
||||||
|
glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(position.x, position.y, position.z);
|
||||||
|
glm::vec3 axis = glm::axis(rotation);
|
||||||
|
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||||
|
glPushMatrix();
|
||||||
|
glm::vec3 positionToCenter = center - position;
|
||||||
|
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||||
|
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||||
|
if (puffedOut) {
|
||||||
|
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.2f, greenColor);
|
||||||
|
} else {
|
||||||
|
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, greenColor);
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RenderableDebugableEntityItem::render(RenderArgs* args) {
|
||||||
|
EntityItem* entity = dynamic_cast<EntityItem*>(this);
|
||||||
|
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
|
||||||
|
|
||||||
|
if (debugSimulationOwnership) {
|
||||||
|
quint64 now = usecTimestampNow();
|
||||||
|
if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
|
||||||
|
renderBoundingBox(args, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// RenderableBoxEntityItem.h
|
||||||
|
// interface/src/entities
|
||||||
|
//
|
||||||
|
// Created by Seth Alves on 5/1/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
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_RenderableDebugableEntityItem_h
|
||||||
|
#define hifi_RenderableDebugableEntityItem_h
|
||||||
|
|
||||||
|
#include <EntityItem.h>
|
||||||
|
|
||||||
|
class RenderableDebugableEntityItem {
|
||||||
|
public:
|
||||||
|
RenderableDebugableEntityItem() {}
|
||||||
|
virtual ~RenderableDebugableEntityItem() {}
|
||||||
|
|
||||||
|
void renderBoundingBox(RenderArgs* args, bool puffedOut);
|
||||||
|
virtual void render(RenderArgs* args);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_RenderableBoxEntityItem_h
|
|
@ -108,34 +108,6 @@ void RenderableModelEntityItem::remapTextures() {
|
||||||
_currentTextures = _textures;
|
_currentTextures = _textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderableModelEntityItem::renderBoundingBox(RenderArgs* args) {
|
|
||||||
glm::vec3 position = getPosition();
|
|
||||||
glm::vec3 center = getCenter();
|
|
||||||
glm::vec3 dimensions = getDimensions();
|
|
||||||
glm::quat rotation = getRotation();
|
|
||||||
// float size = glm::length(dimensions) / 2.0f;
|
|
||||||
|
|
||||||
const float MAX_COLOR = 255.0f;
|
|
||||||
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR,
|
|
||||||
getColor()[GREEN_INDEX] / MAX_COLOR,
|
|
||||||
getColor()[BLUE_INDEX] / MAX_COLOR,
|
|
||||||
getLocalRenderAlpha());
|
|
||||||
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(position.x, position.y, position.z);
|
|
||||||
glm::vec3 axis = glm::axis(rotation);
|
|
||||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
|
||||||
glPushMatrix();
|
|
||||||
glm::vec3 positionToCenter = center - position;
|
|
||||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
|
||||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
|
||||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
|
|
||||||
glPopMatrix();
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void RenderableModelEntityItem::render(RenderArgs* args) {
|
void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
PerformanceTimer perfTimer("RMEIrender");
|
PerformanceTimer perfTimer("RMEIrender");
|
||||||
assert(getType() == EntityTypes::Model);
|
assert(getType() == EntityTypes::Model);
|
||||||
|
@ -145,8 +117,9 @@ 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;
|
bool highlightSimulationOwnership = false;
|
||||||
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
|
if (debugSimulationOwnership) {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
const QUuid& myNodeID = nodeList->getSessionUUID();
|
const QUuid& myNodeID = nodeList->getSessionUUID();
|
||||||
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
||||||
|
@ -219,8 +192,10 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!didDraw) {
|
if (!didDraw) {
|
||||||
renderBoundingBox(args);
|
renderBoundingBox(args, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RenderableDebugableEntityItem::render(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) {
|
Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) {
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include <ModelEntityItem.h>
|
#include <ModelEntityItem.h>
|
||||||
|
#include "RenderableDebugableEntityItem.h"
|
||||||
|
|
||||||
class Model;
|
class Model;
|
||||||
class EntityTreeRenderer;
|
class EntityTreeRenderer;
|
||||||
|
|
||||||
class RenderableModelEntityItem : public ModelEntityItem {
|
class RenderableModelEntityItem : public ModelEntityItem, public RenderableDebugableEntityItem {
|
||||||
public:
|
public:
|
||||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
|
||||||
|
@ -42,7 +43,6 @@ public:
|
||||||
|
|
||||||
virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
|
virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
|
||||||
|
|
||||||
void renderBoundingBox(RenderArgs* args);
|
|
||||||
virtual void render(RenderArgs* args);
|
virtual void render(RenderArgs* args);
|
||||||
virtual bool supportsDetailedRayIntersection() const { return true; }
|
virtual bool supportsDetailedRayIntersection() const { return true; }
|
||||||
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
|
|
|
@ -304,7 +304,9 @@ public:
|
||||||
glm::mat4 getWorldToEntityMatrix() const;
|
glm::mat4 getWorldToEntityMatrix() const;
|
||||||
glm::vec3 worldToEntity(const glm::vec3& point) const;
|
glm::vec3 worldToEntity(const glm::vec3& point) const;
|
||||||
glm::vec3 entityToWorld(const glm::vec3& point) const;
|
glm::vec3 entityToWorld(const glm::vec3& point) const;
|
||||||
|
|
||||||
|
quint64 getLastEditedFromRemote() { return _lastEditedFromRemote; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static bool _sendPhysicsUpdates;
|
static bool _sendPhysicsUpdates;
|
||||||
|
|
Loading…
Reference in a new issue