mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #4733 from sethalves/box-stacking
improve display of owned boxes and models when simulation-ownership debug menu is enabled
This commit is contained in:
commit
2bf7387723
3 changed files with 48 additions and 23 deletions
|
@ -35,6 +35,14 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
|||
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
|
||||
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
|
||||
|
||||
|
||||
bool highlightSimulationOwnership = false;
|
||||
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid& myNodeID = nodeList->getSessionUUID();
|
||||
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
|
@ -43,8 +51,11 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
|||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
|
||||
if (highlightSimulationOwnership) {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
|
||||
} else {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
|
||||
}
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
|
||||
};
|
||||
|
|
|
@ -109,6 +109,33 @@ void RenderableModelEntityItem::remapTextures() {
|
|||
}
|
||||
|
||||
|
||||
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) {
|
||||
PerformanceTimer perfTimer("RMEIrender");
|
||||
assert(getType() == EntityTypes::Model);
|
||||
|
@ -117,7 +144,6 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
|
||||
glm::vec3 position = getPosition();
|
||||
glm::vec3 dimensions = getDimensions();
|
||||
float size = glm::length(dimensions);
|
||||
|
||||
bool highlightSimulationOwnership = false;
|
||||
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
|
||||
|
@ -126,6 +152,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
||||
}
|
||||
|
||||
bool didDraw = false;
|
||||
if (drawAsModel && !highlightSimulationOwnership) {
|
||||
remapTextures();
|
||||
glPushMatrix();
|
||||
|
@ -179,34 +206,20 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
if (args && (args->_renderMode == RenderArgs::SHADOW_RENDER_MODE)) {
|
||||
if (movingOrAnimating) {
|
||||
_model->renderInScene(alpha, args);
|
||||
didDraw = true;
|
||||
}
|
||||
} else {
|
||||
_model->renderInScene(alpha, args);
|
||||
didDraw = true;
|
||||
}
|
||||
} else {
|
||||
// if we couldn't get a model, then just draw a cube
|
||||
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
|
||||
glPopMatrix();
|
||||
}
|
||||
} else {
|
||||
// if we couldn't get a model, then just draw a cube
|
||||
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
} else {
|
||||
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (!didDraw) {
|
||||
renderBoundingBox(args);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
|
||||
virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
|
||||
|
||||
void renderBoundingBox(RenderArgs* args);
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual bool supportsDetailedRayIntersection() const { return true; }
|
||||
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
|
|
Loading…
Reference in a new issue