mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:35:08 +02:00
Merge branch 'team-teaching' of https://github.com/highfidelity/hifi into punk
This commit is contained in:
commit
a71df42ca4
43 changed files with 661 additions and 745 deletions
|
@ -104,6 +104,9 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
|
|||
|
||||
// write the new settings to the json file
|
||||
persistToFile();
|
||||
|
||||
// reload the master and user config so that the merged config is right
|
||||
_configMap.loadMasterAndUserConfig(argumentList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3310,6 +3310,13 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
|||
float originSphereRadius = 0.05f;
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
|
||||
// render JS/scriptable overlays
|
||||
{
|
||||
PerformanceTimer perfTimer("3dOverlays");
|
||||
_overlays.renderWorld(false);
|
||||
}
|
||||
|
||||
// render models...
|
||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
||||
PerformanceTimer perfTimer("entities");
|
||||
|
@ -3337,12 +3344,6 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
|||
}
|
||||
}
|
||||
|
||||
// render JS/scriptable overlays
|
||||
{
|
||||
PerformanceTimer perfTimer("3dOverlays");
|
||||
_overlays.renderWorld(false);
|
||||
}
|
||||
|
||||
// render the ambient occlusion effect if enabled
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
|
||||
PerformanceTimer perfTimer("ambientOcclusion");
|
||||
|
|
|
@ -126,6 +126,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
} else {
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
// FIXME Remove non Batch version of renderWireCube once we use the render pipeline
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,15 +11,12 @@
|
|||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <TextRenderer.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "Text3DOverlay.h"
|
||||
|
||||
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
|
||||
const float DEFAULT_BACKGROUND_ALPHA = 0.7f;
|
||||
const float DEFAULT_MARGIN = 0.1f;
|
||||
const int FIXED_FONT_POINT_SIZE = 40;
|
||||
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation
|
||||
const float LINE_SCALE_RATIO = 1.2f;
|
||||
|
||||
|
@ -50,6 +47,7 @@ Text3DOverlay::Text3DOverlay(const Text3DOverlay* text3DOverlay) :
|
|||
}
|
||||
|
||||
Text3DOverlay::~Text3DOverlay() {
|
||||
delete _textRenderer;
|
||||
}
|
||||
|
||||
xColor Text3DOverlay::getBackgroundColor() {
|
||||
|
@ -106,8 +104,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
|
||||
|
||||
// Same font properties as textSize()
|
||||
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
|
||||
float maxHeight = (float)textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
|
||||
float maxHeight = (float)_textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
|
||||
|
||||
float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
|
||||
|
||||
|
@ -124,7 +121,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
|
||||
|
||||
glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
|
||||
textRenderer->draw(0, 0, _text, textColor);
|
||||
_textRenderer->draw(0, 0, _text, textColor);
|
||||
|
||||
glDisable(GL_CLIP_PLANE0);
|
||||
glDisable(GL_CLIP_PLANE1);
|
||||
|
@ -228,10 +225,9 @@ Text3DOverlay* Text3DOverlay::createClone() const {
|
|||
}
|
||||
|
||||
QSizeF Text3DOverlay::textSize(const QString& text) const {
|
||||
auto textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
|
||||
auto extents = textRenderer->computeExtent(text);
|
||||
auto extents = _textRenderer->computeExtent(text);
|
||||
|
||||
float maxHeight = (float)textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
|
||||
float maxHeight = (float)_textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
|
||||
float pointToWorldScale = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
|
||||
|
||||
return QSizeF(extents.x, extents.y) * pointToWorldScale;
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
#include <QString>
|
||||
|
||||
#include <RenderArgs.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
#include "Planar3DOverlay.h"
|
||||
|
||||
const int FIXED_FONT_POINT_SIZE = 40;
|
||||
|
||||
class Text3DOverlay : public Planar3DOverlay {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -58,6 +62,8 @@ public:
|
|||
private:
|
||||
void enableClipPlane(GLenum plane, float x, float y, float z, float w);
|
||||
|
||||
TextRenderer* _textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
|
||||
|
||||
QString _text;
|
||||
xColor _backgroundColor;
|
||||
float _backgroundAlpha;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
#include "TextOverlay.h"
|
||||
|
||||
|
@ -39,6 +38,7 @@ TextOverlay::TextOverlay(const TextOverlay* textOverlay) :
|
|||
}
|
||||
|
||||
TextOverlay::~TextOverlay() {
|
||||
delete _textRenderer;
|
||||
}
|
||||
|
||||
xColor TextOverlay::getBackgroundColor() {
|
||||
|
@ -79,9 +79,6 @@ void TextOverlay::render(RenderArgs* args) {
|
|||
glm::vec2 topLeft(left, top);
|
||||
glm::vec2 bottomRight(right, bottom);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
|
||||
|
||||
// Same font properties as textSize()
|
||||
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, DEFAULT_FONT_WEIGHT);
|
||||
|
||||
const int leftAdjust = -1; // required to make text render relative to left edge of bounds
|
||||
const int topAdjust = -2; // required to make text render relative to top edge of bounds
|
||||
|
@ -90,7 +87,7 @@ void TextOverlay::render(RenderArgs* args) {
|
|||
|
||||
float alpha = getAlpha();
|
||||
glm::vec4 textColor = {_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, alpha };
|
||||
textRenderer->draw(x, y, _text, textColor);
|
||||
_textRenderer->draw(x, y, _text, textColor);
|
||||
}
|
||||
|
||||
void TextOverlay::setProperties(const QScriptValue& properties) {
|
||||
|
@ -163,8 +160,7 @@ QScriptValue TextOverlay::getProperty(const QString& property) {
|
|||
}
|
||||
|
||||
QSizeF TextOverlay::textSize(const QString& text) const {
|
||||
auto textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, DEFAULT_FONT_WEIGHT);
|
||||
auto extents = textRenderer->computeExtent(text);
|
||||
auto extents = _textRenderer->computeExtent(text);
|
||||
|
||||
return QSizeF(extents.x, extents.y);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <QString>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
#include "Overlay.h"
|
||||
#include "Overlay2D.h"
|
||||
|
@ -58,6 +59,9 @@ public:
|
|||
QSizeF textSize(const QString& text) const; // Pixels
|
||||
|
||||
private:
|
||||
|
||||
TextRenderer* _textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, DEFAULT_FONT_WEIGHT);
|
||||
|
||||
QString _text;
|
||||
xColor _backgroundColor;
|
||||
float _backgroundAlpha;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
//
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <gpu/GLBackend.h>
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
|
@ -392,6 +393,87 @@ void EntityTreeRenderer::leaveAllEntities() {
|
|||
_lastAvatarPosition = _viewState->getAvatarPosition() + glm::vec3((float)TREE_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::applyZonePropertiesToScene(const ZoneEntityItem* zone) {
|
||||
QSharedPointer<SceneScriptingInterface> scene = DependencyManager::get<SceneScriptingInterface>();
|
||||
if (zone) {
|
||||
if (!_hasPreviousZone) {
|
||||
_previousKeyLightColor = scene->getKeyLightColor();
|
||||
_previousKeyLightIntensity = scene->getKeyLightIntensity();
|
||||
_previousKeyLightAmbientIntensity = scene->getKeyLightAmbientIntensity();
|
||||
_previousKeyLightDirection = scene->getKeyLightDirection();
|
||||
_previousStageSunModelEnabled = scene->isStageSunModelEnabled();
|
||||
_previousStageLongitude = scene->getStageLocationLongitude();
|
||||
_previousStageLatitude = scene->getStageLocationLatitude();
|
||||
_previousStageAltitude = scene->getStageLocationAltitude();
|
||||
_previousStageHour = scene->getStageDayTime();
|
||||
_previousStageDay = scene->getStageYearTime();
|
||||
_hasPreviousZone = true;
|
||||
}
|
||||
scene->setKeyLightColor(zone->getKeyLightColorVec3());
|
||||
scene->setKeyLightIntensity(zone->getKeyLightIntensity());
|
||||
scene->setKeyLightAmbientIntensity(zone->getKeyLightAmbientIntensity());
|
||||
scene->setKeyLightDirection(zone->getKeyLightDirection());
|
||||
scene->setStageSunModelEnable(zone->getStageProperties().getSunModelEnabled());
|
||||
scene->setStageLocation(zone->getStageProperties().getLongitude(), zone->getStageProperties().getLatitude(),
|
||||
zone->getStageProperties().getAltitude());
|
||||
scene->setStageDayTime(zone->getStageProperties().calculateHour());
|
||||
scene->setStageYearTime(zone->getStageProperties().calculateDay());
|
||||
|
||||
if (zone->getBackgroundMode() == BACKGROUND_MODE_ATMOSPHERE) {
|
||||
EnvironmentData data = zone->getEnvironmentData();
|
||||
glm::vec3 keyLightDirection = scene->getKeyLightDirection();
|
||||
glm::vec3 inverseKeyLightDirection = keyLightDirection * -1.0f;
|
||||
|
||||
// NOTE: is this right? It seems like the "sun" should be based on the center of the
|
||||
// atmosphere, not where the camera is.
|
||||
glm::vec3 keyLightLocation = _viewState->getAvatarPosition()
|
||||
+ (inverseKeyLightDirection * data.getAtmosphereOuterRadius());
|
||||
|
||||
data.setSunLocation(keyLightLocation);
|
||||
|
||||
const float KEY_LIGHT_INTENSITY_TO_SUN_BRIGHTNESS_RATIO = 20.0f;
|
||||
float sunBrightness = scene->getKeyLightIntensity() * KEY_LIGHT_INTENSITY_TO_SUN_BRIGHTNESS_RATIO;
|
||||
data.setSunBrightness(sunBrightness);
|
||||
|
||||
_viewState->overrideEnvironmentData(data);
|
||||
scene->getSkyStage()->setBackgroundMode(model::SunSkyStage::SKY_DOME);
|
||||
|
||||
} else {
|
||||
_viewState->endOverrideEnvironmentData();
|
||||
auto stage = scene->getSkyStage();
|
||||
if (zone->getBackgroundMode() == BACKGROUND_MODE_SKYBOX) {
|
||||
stage->getSkybox()->setColor(zone->getSkyboxProperties().getColorVec3());
|
||||
if (zone->getSkyboxProperties().getURL().isEmpty()) {
|
||||
stage->getSkybox()->setCubemap(gpu::TexturePointer());
|
||||
} else {
|
||||
// Update the Texture of the Skybox with the one pointed by this zone
|
||||
auto cubeMap = DependencyManager::get<TextureCache>()->getTexture(zone->getSkyboxProperties().getURL(), CUBE_TEXTURE);
|
||||
stage->getSkybox()->setCubemap(cubeMap->getGPUTexture());
|
||||
}
|
||||
stage->setBackgroundMode(model::SunSkyStage::SKY_BOX);
|
||||
} else {
|
||||
stage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_hasPreviousZone) {
|
||||
scene->setKeyLightColor(_previousKeyLightColor);
|
||||
scene->setKeyLightIntensity(_previousKeyLightIntensity);
|
||||
scene->setKeyLightAmbientIntensity(_previousKeyLightAmbientIntensity);
|
||||
scene->setKeyLightDirection(_previousKeyLightDirection);
|
||||
scene->setStageSunModelEnable(_previousStageSunModelEnabled);
|
||||
scene->setStageLocation(_previousStageLongitude, _previousStageLatitude,
|
||||
_previousStageAltitude);
|
||||
scene->setStageDayTime(_previousStageHour);
|
||||
scene->setStageYearTime(_previousStageDay);
|
||||
_hasPreviousZone = false;
|
||||
}
|
||||
_viewState->endOverrideEnvironmentData();
|
||||
scene->getSkyStage()->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through
|
||||
}
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
||||
RenderArgs::RenderSide renderSide,
|
||||
RenderArgs::DebugFlags renderDebugFlags) {
|
||||
|
@ -400,9 +482,18 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
|||
|
||||
ViewFrustum* frustum = (renderMode == RenderArgs::SHADOW_RENDER_MODE) ?
|
||||
_viewState->getShadowViewFrustum() : _viewState->getCurrentViewFrustum();
|
||||
|
||||
|
||||
// Setup batch transform matrices
|
||||
gpu::Batch batch;
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
frustum->evalProjectionMatrix(projMat);
|
||||
frustum->evalViewTransform(viewMat);
|
||||
batch.setProjectionTransform(projMat);
|
||||
batch.setViewTransform(viewMat);
|
||||
|
||||
RenderArgs args(this, frustum, getSizeScale(), getBoundaryLevelAdjust(),
|
||||
renderMode, renderSide, renderDebugFlags);
|
||||
renderMode, renderSide, renderDebugFlags, &batch);
|
||||
|
||||
_tree->lockForRead();
|
||||
|
||||
|
@ -411,91 +502,17 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
|||
_bestZoneVolume = std::numeric_limits<float>::max();
|
||||
_tree->recurseTreeWithOperation(renderOperation, &args);
|
||||
|
||||
QSharedPointer<SceneScriptingInterface> scene = DependencyManager::get<SceneScriptingInterface>();
|
||||
|
||||
if (_bestZone) {
|
||||
if (!_hasPreviousZone) {
|
||||
_previousKeyLightColor = scene->getKeyLightColor();
|
||||
_previousKeyLightIntensity = scene->getKeyLightIntensity();
|
||||
_previousKeyLightAmbientIntensity = scene->getKeyLightAmbientIntensity();
|
||||
_previousKeyLightDirection = scene->getKeyLightDirection();
|
||||
_previousStageSunModelEnabled = scene->isStageSunModelEnabled();
|
||||
_previousStageLongitude = scene->getStageLocationLongitude();
|
||||
_previousStageLatitude = scene->getStageLocationLatitude();
|
||||
_previousStageAltitude = scene->getStageLocationAltitude();
|
||||
_previousStageHour = scene->getStageDayTime();
|
||||
_previousStageDay = scene->getStageYearTime();
|
||||
_hasPreviousZone = true;
|
||||
}
|
||||
scene->setKeyLightColor(_bestZone->getKeyLightColorVec3());
|
||||
scene->setKeyLightIntensity(_bestZone->getKeyLightIntensity());
|
||||
scene->setKeyLightAmbientIntensity(_bestZone->getKeyLightAmbientIntensity());
|
||||
scene->setKeyLightDirection(_bestZone->getKeyLightDirection());
|
||||
scene->setStageSunModelEnable(_bestZone->getStageProperties().getSunModelEnabled());
|
||||
scene->setStageLocation(_bestZone->getStageProperties().getLongitude(), _bestZone->getStageProperties().getLatitude(),
|
||||
_bestZone->getStageProperties().getAltitude());
|
||||
scene->setStageDayTime(_bestZone->getStageProperties().calculateHour());
|
||||
scene->setStageYearTime(_bestZone->getStageProperties().calculateDay());
|
||||
|
||||
if (_bestZone->getBackgroundMode() == BACKGROUND_MODE_ATMOSPHERE) {
|
||||
EnvironmentData data = _bestZone->getEnvironmentData();
|
||||
glm::vec3 keyLightDirection = scene->getKeyLightDirection();
|
||||
glm::vec3 inverseKeyLightDirection = keyLightDirection * -1.0f;
|
||||
|
||||
// NOTE: is this right? It seems like the "sun" should be based on the center of the
|
||||
// atmosphere, not where the camera is.
|
||||
glm::vec3 keyLightLocation = _viewState->getAvatarPosition()
|
||||
+ (inverseKeyLightDirection * data.getAtmosphereOuterRadius());
|
||||
|
||||
data.setSunLocation(keyLightLocation);
|
||||
|
||||
const float KEY_LIGHT_INTENSITY_TO_SUN_BRIGHTNESS_RATIO = 20.0f;
|
||||
float sunBrightness = scene->getKeyLightIntensity() * KEY_LIGHT_INTENSITY_TO_SUN_BRIGHTNESS_RATIO;
|
||||
data.setSunBrightness(sunBrightness);
|
||||
|
||||
_viewState->overrideEnvironmentData(data);
|
||||
scene->getSkyStage()->setBackgroundMode(model::SunSkyStage::SKY_DOME);
|
||||
|
||||
} else {
|
||||
_viewState->endOverrideEnvironmentData();
|
||||
auto stage = scene->getSkyStage();
|
||||
if (_bestZone->getBackgroundMode() == BACKGROUND_MODE_SKYBOX) {
|
||||
stage->getSkybox()->setColor(_bestZone->getSkyboxProperties().getColorVec3());
|
||||
if (_bestZone->getSkyboxProperties().getURL().isEmpty()) {
|
||||
stage->getSkybox()->setCubemap(gpu::TexturePointer());
|
||||
} else {
|
||||
// Update the Texture of the Skybox with the one pointed by this zone
|
||||
auto cubeMap = DependencyManager::get<TextureCache>()->getTexture(_bestZone->getSkyboxProperties().getURL(), CUBE_TEXTURE);
|
||||
stage->getSkybox()->setCubemap(cubeMap->getGPUTexture());
|
||||
}
|
||||
stage->setBackgroundMode(model::SunSkyStage::SKY_BOX);
|
||||
} else {
|
||||
stage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (_hasPreviousZone) {
|
||||
scene->setKeyLightColor(_previousKeyLightColor);
|
||||
scene->setKeyLightIntensity(_previousKeyLightIntensity);
|
||||
scene->setKeyLightAmbientIntensity(_previousKeyLightAmbientIntensity);
|
||||
scene->setKeyLightDirection(_previousKeyLightDirection);
|
||||
scene->setStageSunModelEnable(_previousStageSunModelEnabled);
|
||||
scene->setStageLocation(_previousStageLongitude, _previousStageLatitude,
|
||||
_previousStageAltitude);
|
||||
scene->setStageDayTime(_previousStageHour);
|
||||
scene->setStageYearTime(_previousStageDay);
|
||||
_hasPreviousZone = false;
|
||||
}
|
||||
_viewState->endOverrideEnvironmentData();
|
||||
scene->getSkyStage()->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through
|
||||
}
|
||||
applyZonePropertiesToScene(_bestZone);
|
||||
|
||||
// we must call endScene while we still have the tree locked so that no one deletes a model
|
||||
// on us while rendering the scene
|
||||
Model::endScene(renderMode, &args);
|
||||
_tree->unlock();
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
glPopMatrix();
|
||||
|
||||
// stats...
|
||||
_meshesConsidered = args._meshesConsidered;
|
||||
_meshesRendered = args._meshesRendered;
|
||||
|
@ -561,57 +578,36 @@ const FBXGeometry* EntityTreeRenderer::getCollisionGeometryForEntity(const Entit
|
|||
return result;
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::renderElementProxy(EntityTreeElement* entityTreeElement) {
|
||||
void EntityTreeRenderer::renderElementProxy(EntityTreeElement* entityTreeElement, RenderArgs* args) {
|
||||
auto deferredLighting = DependencyManager::get<DeferredLightingEffect>();
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
Transform transform;
|
||||
|
||||
glm::vec3 elementCenter = entityTreeElement->getAACube().calcCenter();
|
||||
float elementSize = entityTreeElement->getScale();
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x, elementCenter.y, elementCenter.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(elementSize, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
auto drawWireCube = [&](glm::vec3 offset, float size, glm::vec4 color) {
|
||||
transform.setTranslation(elementCenter + offset);
|
||||
batch.setModelTransform(transform);
|
||||
deferredLighting->renderWireCube(batch, size, color);
|
||||
};
|
||||
|
||||
drawWireCube(glm::vec3(), elementSize, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
if (_displayElementChildProxies) {
|
||||
// draw the children
|
||||
float halfSize = elementSize / 2.0f;
|
||||
float quarterSize = elementSize / 4.0f;
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.5f, 0.5f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.5f, 0.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.5f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
drawWireCube(glm::vec3(-quarterSize, -quarterSize, -quarterSize), halfSize, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
drawWireCube(glm::vec3(quarterSize, -quarterSize, -quarterSize), halfSize, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
drawWireCube(glm::vec3(-quarterSize, quarterSize, -quarterSize), halfSize, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
drawWireCube(glm::vec3(-quarterSize, -quarterSize, quarterSize), halfSize, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
drawWireCube(glm::vec3(quarterSize, quarterSize, quarterSize), halfSize, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
drawWireCube(glm::vec3(-quarterSize, quarterSize, quarterSize), halfSize, glm::vec4(0.0f, 0.5f, 0.5f, 1.0f));
|
||||
drawWireCube(glm::vec3(quarterSize, -quarterSize, quarterSize), halfSize, glm::vec4(0.5f, 0.0f, 0.0f, 1.0f));
|
||||
drawWireCube(glm::vec3(quarterSize, quarterSize, -quarterSize), halfSize, glm::vec4(0.0f, 0.5f, 0.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -628,43 +624,31 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
|
|||
glm::vec3 minCenter = minCube.calcCenter();
|
||||
glm::vec3 entityBoxCenter = entityBox.calcCenter();
|
||||
glm::vec3 entityBoxScale = entityBox.getScale();
|
||||
|
||||
auto deferredLighting = DependencyManager::get<DeferredLightingEffect>();
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
Transform transform;
|
||||
|
||||
// draw the max bounding cube
|
||||
glPushMatrix();
|
||||
glTranslatef(maxCenter.x, maxCenter.y, maxCenter.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(maxCube.getScale(), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
transform.setTranslation(maxCenter);
|
||||
batch.setModelTransform(transform);
|
||||
deferredLighting->renderWireCube(batch, maxCube.getScale(), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
|
||||
// draw the min bounding cube
|
||||
glPushMatrix();
|
||||
glTranslatef(minCenter.x, minCenter.y, minCenter.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(minCube.getScale(), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
transform.setTranslation(minCenter);
|
||||
batch.setModelTransform(transform);
|
||||
deferredLighting->renderWireCube(batch, minCube.getScale(), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
|
||||
// draw the entityBox bounding box
|
||||
glPushMatrix();
|
||||
glTranslatef(entityBoxCenter.x, entityBoxCenter.y, entityBoxCenter.z);
|
||||
glScalef(entityBoxScale.x, entityBoxScale.y, entityBoxScale.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
transform.setTranslation(entityBoxCenter);
|
||||
transform.setScale(entityBoxScale);
|
||||
batch.setModelTransform(transform);
|
||||
deferredLighting->renderWireCube(batch, 1.0f, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
|
||||
|
||||
glm::vec3 position = entity->getPosition();
|
||||
glm::vec3 center = entity->getCenter();
|
||||
glm::vec3 dimensions = entity->getDimensions();
|
||||
glm::quat rotation = entity->getRotation();
|
||||
|
||||
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, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
// Rotated bounding box
|
||||
batch.setModelTransform(entity->getTransformToCenter());
|
||||
deferredLighting->renderWireCube(batch, 1.0f, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -682,7 +666,7 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
|
|||
bool isShadowMode = args->_renderMode == RenderArgs::SHADOW_RENDER_MODE;
|
||||
|
||||
if (!isShadowMode && _displayModelElementProxy && numberOfEntities > 0) {
|
||||
renderElementProxy(entityTreeElement);
|
||||
renderElementProxy(entityTreeElement, args);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
|
|
|
@ -125,7 +125,8 @@ protected:
|
|||
virtual Octree* createTree() { return new EntityTree(true); }
|
||||
|
||||
private:
|
||||
void renderElementProxy(EntityTreeElement* entityTreeElement);
|
||||
void applyZonePropertiesToScene(const ZoneEntityItem* zone);
|
||||
void renderElementProxy(EntityTreeElement* entityTreeElement, RenderArgs* args);
|
||||
void checkAndCallPreload(const EntityItemID& entityID);
|
||||
void checkAndCallUnload(const EntityItemID& entityID);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <gpu/Batch.h>
|
||||
|
||||
#include <DeferredLightingEffect.h>
|
||||
#include <PerfStat.h>
|
||||
|
@ -24,17 +25,8 @@ EntityItem* RenderableBoxEntityItem::factory(const EntityItemID& entityID, const
|
|||
|
||||
void RenderableBoxEntityItem::render(RenderArgs* args) {
|
||||
PerformanceTimer perfTimer("RenderableBoxEntityItem::render");
|
||||
assert(getType() == EntityTypes::Box);
|
||||
glm::vec3 position = getPosition();
|
||||
glm::vec3 center = getCenter();
|
||||
glm::vec3 dimensions = getDimensions();
|
||||
glm::quat rotation = getRotation();
|
||||
|
||||
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());
|
||||
|
||||
Q_ASSERT(getType() == EntityTypes::Box);
|
||||
glm::vec4 cubeColor(toGlm(getXColor()), getLocalRenderAlpha());
|
||||
|
||||
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
|
||||
bool highlightSimulationOwnership = false;
|
||||
|
@ -43,22 +35,15 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
|||
const QUuid& myNodeID = nodeList->getSessionUUID();
|
||||
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
|
||||
}
|
||||
|
||||
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 (highlightSimulationOwnership) {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
|
||||
} else {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
|
||||
}
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
batch.setModelTransform(getTransformToCenter());
|
||||
if (highlightSimulationOwnership) {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.0f, cubeColor);
|
||||
} else {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(batch, 1.0f, cubeColor);
|
||||
}
|
||||
|
||||
RenderableDebugableEntityItem::render(this, args);
|
||||
};
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <gpu/Batch.h>
|
||||
|
||||
#include <DeferredLightingEffect.h>
|
||||
#include <PhysicsEngine.h>
|
||||
|
||||
|
@ -21,48 +24,24 @@
|
|||
|
||||
void RenderableDebugableEntityItem::renderBoundingBox(EntityItem* entity, RenderArgs* args,
|
||||
float puffedOut, glm::vec4& color) {
|
||||
glm::vec3 position = entity->getPosition();
|
||||
glm::vec3 center = entity->getCenter();
|
||||
glm::vec3 dimensions = entity->getDimensions();
|
||||
glm::quat rotation = entity->getRotation();
|
||||
|
||||
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 + puffedOut, color);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
batch.setModelTransform(entity->getTransformToCenter());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(batch, 1.0f + puffedOut, color);
|
||||
}
|
||||
|
||||
void RenderableDebugableEntityItem::renderHoverDot(EntityItem* entity, RenderArgs* args) {
|
||||
glm::vec3 position = entity->getPosition();
|
||||
glm::vec3 center = entity->getCenter();
|
||||
glm::vec3 dimensions = entity->getDimensions();
|
||||
glm::quat rotation = entity->getRotation();
|
||||
glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
const int SLICES = 8, STACKS = 8;
|
||||
float radius = 0.05f;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y + dimensions.y + radius, 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(radius, radius, radius);
|
||||
|
||||
const int SLICES = 8;
|
||||
const int STACKS = 8;
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, SLICES, STACKS, blueColor);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
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) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <gpu/Batch.h>
|
||||
|
||||
#include <DeferredLightingEffect.h>
|
||||
#include <GLMHelpers.h>
|
||||
|
@ -31,12 +32,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
|
|||
glm::quat rotation = getRotation();
|
||||
float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z);
|
||||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
float colorR = getColor()[RED_INDEX] / MAX_COLOR;
|
||||
float colorG = getColor()[GREEN_INDEX] / MAX_COLOR;
|
||||
float colorB = getColor()[BLUE_INDEX] / MAX_COLOR;
|
||||
|
||||
glm::vec3 color = glm::vec3(colorR, colorG, colorB);
|
||||
glm::vec3 color = toGlm(getXColor());
|
||||
|
||||
float intensity = getIntensity();
|
||||
float exponent = getExponent();
|
||||
|
@ -49,21 +45,12 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
|
|||
DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
|
||||
color, intensity);
|
||||
}
|
||||
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
glm::vec4 color(diffuseR, diffuseG, diffuseB, 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);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(0.5f, 15, 15, color);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
batch.setModelTransform(getTransformToCenter());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(batch, 0.5f, 15, 15, glm::vec4(color, 1.0f));
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <gpu/Batch.h>
|
||||
|
||||
#include <DeferredLightingEffect.h>
|
||||
#include <PerfStat.h>
|
||||
|
@ -24,18 +25,15 @@ EntityItem* RenderableLineEntityItem::factory(const EntityItemID& entityID, cons
|
|||
|
||||
void RenderableLineEntityItem::render(RenderArgs* args) {
|
||||
PerformanceTimer perfTimer("RenderableLineEntityItem::render");
|
||||
assert(getType() == EntityTypes::Line);
|
||||
glm::vec3 position = getPosition();
|
||||
glm::vec3 dimensions = getDimensions();
|
||||
glm::quat rotation = getRotation();
|
||||
Q_ASSERT(getType() == EntityTypes::Line);
|
||||
glm::vec3 p1 = ENTITY_ITEM_ZERO_VEC3;
|
||||
glm::vec3 p2 = getDimensions();
|
||||
glm::vec4 lineColor(toGlm(getXColor()), 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);
|
||||
glm::vec3 p1 = {0.0f, 0.0f, 0.0f};
|
||||
glm::vec3& p2 = dimensions;
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderLine(p1, p2, lineColor, lineColor);
|
||||
glPopMatrix();
|
||||
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
batch.setModelTransform(getTransformToCenter());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderLine(batch, p1, p2, lineColor, lineColor);
|
||||
|
||||
RenderableDebugableEntityItem::render(this, args);
|
||||
};
|
||||
|
|
|
@ -128,7 +128,6 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
bool didDraw = false;
|
||||
if (drawAsModel && !highlightSimulationOwnership) {
|
||||
remapTextures();
|
||||
glPushMatrix();
|
||||
{
|
||||
float alpha = getLocalRenderAlpha();
|
||||
|
||||
|
@ -188,7 +187,6 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
}
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (!didDraw) {
|
||||
|
@ -396,7 +394,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
|||
// to the visual model and apply them to the collision model (without regard for the
|
||||
// collision model's extents).
|
||||
|
||||
glm::vec3 scale = _dimensions / renderGeometry.getUnscaledMeshExtents().size();
|
||||
glm::vec3 scale = getDimensions() / renderGeometry.getUnscaledMeshExtents().size();
|
||||
// multiply each point by scale before handing the point-set off to the physics engine.
|
||||
// also determine the extents of the collision model.
|
||||
AABox box;
|
||||
|
|
|
@ -30,8 +30,7 @@ RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const Ent
|
|||
}
|
||||
|
||||
void RenderableParticleEffectEntityItem::render(RenderArgs* args) {
|
||||
|
||||
assert(getType() == EntityTypes::ParticleEffect);
|
||||
Q_ASSERT(getType() == EntityTypes::ParticleEffect);
|
||||
PerformanceTimer perfTimer("RenderableParticleEffectEntityItem::render");
|
||||
|
||||
if (_texturesChangedFlag) {
|
||||
|
@ -45,143 +44,67 @@ void RenderableParticleEffectEntityItem::render(RenderArgs* args) {
|
|||
_texturesChangedFlag = false;
|
||||
}
|
||||
|
||||
if (!_texture) {
|
||||
renderUntexturedQuads(args);
|
||||
} else if (_texture && !_texture->isLoaded()) {
|
||||
renderUntexturedQuads(args);
|
||||
} else {
|
||||
renderTexturedQuads(args);
|
||||
bool textured = _texture && _texture->isLoaded();
|
||||
updateQuads(args, textured);
|
||||
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
if (textured) {
|
||||
batch.setUniformTexture(0, _texture->getGPUTexture());
|
||||
}
|
||||
batch.setModelTransform(getTransformToCenter());
|
||||
DependencyManager::get<GeometryCache>()->renderVertices(batch, gpu::QUADS, _cacheID);
|
||||
};
|
||||
|
||||
void RenderableParticleEffectEntityItem::renderUntexturedQuads(RenderArgs* args) {
|
||||
|
||||
float particleRadius = getParticleRadius();
|
||||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glm::vec4 particleColor(getColor()[RED_INDEX] / MAX_COLOR,
|
||||
getColor()[GREEN_INDEX] / MAX_COLOR,
|
||||
getColor()[BLUE_INDEX] / MAX_COLOR,
|
||||
getLocalRenderAlpha());
|
||||
|
||||
glm::vec3 upOffset = args->_viewFrustum->getUp() * particleRadius;
|
||||
glm::vec3 rightOffset = args->_viewFrustum->getRight() * particleRadius;
|
||||
|
||||
QVector<glm::vec3> vertices(getLivingParticleCount() * VERTS_PER_PARTICLE);
|
||||
quint32 count = 0;
|
||||
for (quint32 i = _particleHeadIndex; i != _particleTailIndex; i = (i + 1) % _maxParticles) {
|
||||
glm::vec3 pos = _particlePositions[i];
|
||||
|
||||
// generate corners of quad, aligned to face the camera
|
||||
vertices.append(pos - rightOffset + upOffset);
|
||||
vertices.append(pos + rightOffset + upOffset);
|
||||
vertices.append(pos + rightOffset - upOffset);
|
||||
vertices.append(pos - rightOffset - upOffset);
|
||||
count++;
|
||||
}
|
||||
|
||||
// just double checking, cause if this invarient is false, we might have memory corruption bugs.
|
||||
assert(count == getLivingParticleCount());
|
||||
|
||||
// update geometry cache with all the verts in model coordinates.
|
||||
DependencyManager::get<GeometryCache>()->updateVertices(_cacheID, vertices, particleColor);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glm::vec3 position = getPosition();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::quat rotation = getRotation();
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glm::vec3 positionToCenter = getCenter() - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderVertices(gpu::QUADS, _cacheID);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
static glm::vec3 zSortAxis;
|
||||
static bool zSort(const glm::vec3& rhs, const glm::vec3& lhs) {
|
||||
return glm::dot(rhs, ::zSortAxis) > glm::dot(lhs, ::zSortAxis);
|
||||
}
|
||||
|
||||
void RenderableParticleEffectEntityItem::renderTexturedQuads(RenderArgs* args) {
|
||||
|
||||
void RenderableParticleEffectEntityItem::updateQuads(RenderArgs* args, bool textured) {
|
||||
float particleRadius = getParticleRadius();
|
||||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glm::vec4 particleColor(getColor()[RED_INDEX] / MAX_COLOR,
|
||||
getColor()[GREEN_INDEX] / MAX_COLOR,
|
||||
getColor()[BLUE_INDEX] / MAX_COLOR,
|
||||
getLocalRenderAlpha());
|
||||
|
||||
QVector<glm::vec3> positions(getLivingParticleCount());
|
||||
quint32 count = 0;
|
||||
for (quint32 i = _particleHeadIndex; i != _particleTailIndex; i = (i + 1) % _maxParticles) {
|
||||
positions.append(_particlePositions[i]);
|
||||
count++;
|
||||
}
|
||||
|
||||
// just double checking, cause if this invarient is false, we might have memory corruption bugs.
|
||||
assert(count == getLivingParticleCount());
|
||||
|
||||
// sort particles back to front
|
||||
::zSortAxis = args->_viewFrustum->getDirection();
|
||||
qSort(positions.begin(), positions.end(), zSort);
|
||||
|
||||
QVector<glm::vec3> vertices(getLivingParticleCount() * VERTS_PER_PARTICLE);
|
||||
QVector<glm::vec2> textureCoords(getLivingParticleCount() * VERTS_PER_PARTICLE);
|
||||
|
||||
glm::vec4 particleColor(toGlm(getXColor()), getLocalRenderAlpha());
|
||||
|
||||
glm::vec3 upOffset = args->_viewFrustum->getUp() * particleRadius;
|
||||
glm::vec3 rightOffset = args->_viewFrustum->getRight() * particleRadius;
|
||||
|
||||
|
||||
QVector<glm::vec3> vertices;
|
||||
QVector<glm::vec3> positions;
|
||||
QVector<glm::vec2> textureCoords;
|
||||
vertices.reserve(getLivingParticleCount() * VERTS_PER_PARTICLE);
|
||||
|
||||
if (textured) {
|
||||
positions.reserve(getLivingParticleCount());
|
||||
textureCoords.reserve(getLivingParticleCount() * VERTS_PER_PARTICLE);
|
||||
|
||||
for (quint32 i = _particleHeadIndex; i != _particleTailIndex; i = (i + 1) % _maxParticles) {
|
||||
positions.append(_particlePositions[i]);
|
||||
|
||||
textureCoords.append(glm::vec2(0, 1));
|
||||
textureCoords.append(glm::vec2(1, 1));
|
||||
textureCoords.append(glm::vec2(1, 0));
|
||||
textureCoords.append(glm::vec2(0, 0));
|
||||
}
|
||||
|
||||
// sort particles back to front
|
||||
::zSortAxis = args->_viewFrustum->getDirection();
|
||||
qSort(positions.begin(), positions.end(), zSort);
|
||||
}
|
||||
|
||||
for (int i = 0; i < positions.size(); i++) {
|
||||
glm::vec3 pos = positions[i];
|
||||
glm::vec3 pos = (textured) ? positions[i] : _particlePositions[i];
|
||||
|
||||
// generate corners of quad aligned to face the camera.
|
||||
vertices.append(pos - rightOffset + upOffset);
|
||||
vertices.append(pos + rightOffset + upOffset);
|
||||
vertices.append(pos + rightOffset - upOffset);
|
||||
vertices.append(pos - rightOffset - upOffset);
|
||||
|
||||
textureCoords.append(glm::vec2(0, 1));
|
||||
textureCoords.append(glm::vec2(1, 1));
|
||||
textureCoords.append(glm::vec2(1, 0));
|
||||
textureCoords.append(glm::vec2(0, 0));
|
||||
}
|
||||
|
||||
// update geometry cache with all the verts in model coordinates.
|
||||
DependencyManager::get<GeometryCache>()->updateVertices(_cacheID, vertices, textureCoords, particleColor);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, _texture->getID());
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glm::vec3 position = getPosition();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::quat rotation = getRotation();
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glm::vec3 positionToCenter = getCenter() - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderVertices(gpu::QUADS, _cacheID);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
if (textured) {
|
||||
DependencyManager::get<GeometryCache>()->updateVertices(_cacheID, vertices, textureCoords, particleColor);
|
||||
} else {
|
||||
DependencyManager::get<GeometryCache>()->updateVertices(_cacheID, vertices, particleColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ public:
|
|||
RenderableParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
virtual void render(RenderArgs* args);
|
||||
|
||||
void renderUntexturedQuads(RenderArgs* args);
|
||||
void renderTexturedQuads(RenderArgs* args);
|
||||
void updateQuads(RenderArgs* args, bool textured);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <gpu/Batch.h>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <DeferredLightingEffect.h>
|
||||
|
@ -25,35 +26,17 @@ EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, co
|
|||
|
||||
void RenderableSphereEntityItem::render(RenderArgs* args) {
|
||||
PerformanceTimer perfTimer("RenderableSphereEntityItem::render");
|
||||
assert(getType() == EntityTypes::Sphere);
|
||||
glm::vec3 position = getPosition();
|
||||
glm::vec3 center = getCenter();
|
||||
glm::vec3 dimensions = getDimensions();
|
||||
glm::quat rotation = getRotation();
|
||||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glm::vec4 sphereColor(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);
|
||||
|
||||
// TODO: it would be cool to select different slices/stacks geometry based on the size of the sphere
|
||||
// and the distance to the viewer. This would allow us to reduce the triangle count for smaller spheres
|
||||
// that aren't close enough to see the tessellation and use larger triangle count for spheres that would
|
||||
// expose that effect
|
||||
const int SLICES = 15;
|
||||
const int STACKS = 15;
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, SLICES, STACKS, sphereColor);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
Q_ASSERT(getType() == EntityTypes::Sphere);
|
||||
glm::vec4 sphereColor(toGlm(getXColor()), getLocalRenderAlpha());
|
||||
|
||||
// TODO: it would be cool to select different slices/stacks geometry based on the size of the sphere
|
||||
// and the distance to the viewer. This would allow us to reduce the triangle count for smaller spheres
|
||||
// that aren't close enough to see the tessellation and use larger triangle count for spheres that would
|
||||
// expose that effect
|
||||
const int SLICES = 15, STACKS = 15;
|
||||
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
batch.setModelTransform(getTransformToCenter());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(batch, 0.5f, SLICES, STACKS, sphereColor);
|
||||
};
|
||||
|
|
|
@ -16,12 +16,10 @@
|
|||
#include <DeferredLightingEffect.h>
|
||||
#include <GeometryCache.h>
|
||||
#include <PerfStat.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
#include "RenderableTextEntityItem.h"
|
||||
#include "GLMHelpers.h"
|
||||
|
||||
const int FIXED_FONT_POINT_SIZE = 40;
|
||||
|
||||
EntityItem* RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableTextEntityItem(entityID, properties);
|
||||
|
@ -57,24 +55,17 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, glm::vec4(toGlm(getBackgroundColorX()), alpha));
|
||||
DependencyManager::get<DeferredLightingEffect>()->releaseSimpleProgram();
|
||||
|
||||
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f);
|
||||
|
||||
glTranslatef(-(halfDimensions.x - leftMargin), halfDimensions.y - topMargin, 0.0f);
|
||||
glm::vec4 textColor(toGlm(getTextColorX()), alpha);
|
||||
// this is a ratio determined through experimentation
|
||||
const float scaleFactor = 0.08f * _lineHeight;
|
||||
glScalef(scaleFactor, -scaleFactor, scaleFactor);
|
||||
glm::vec2 bounds(dimensions.x / scaleFactor, dimensions.y / scaleFactor);
|
||||
textRenderer->draw(0, 0, _text, textColor, bounds);
|
||||
_textRenderer->draw(0, 0, _text, textColor, bounds);
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void RenderableTextEntityItem::enableClipPlane(GLenum plane, float x, float y, float z, float w) {
|
||||
GLdouble coefficients[] = { x, y, z, w };
|
||||
glClipPlane(plane, coefficients);
|
||||
glEnable(plane);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#define hifi_RenderableTextEntityItem_h
|
||||
|
||||
#include <TextEntityItem.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
const int FIXED_FONT_POINT_SIZE = 40;
|
||||
|
||||
class RenderableTextEntityItem : public TextEntityItem {
|
||||
public:
|
||||
|
@ -21,12 +24,12 @@ public:
|
|||
RenderableTextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
TextEntityItem(entityItemID, properties)
|
||||
{ }
|
||||
~RenderableTextEntityItem() { delete _textRenderer; }
|
||||
|
||||
virtual void render(RenderArgs* args);
|
||||
|
||||
|
||||
private:
|
||||
void enableClipPlane(GLenum plane, float x, float y, float z, float w);
|
||||
|
||||
TextRenderer* _textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -121,10 +121,10 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
glm::vec3 point = intersection.intersection;
|
||||
point -= getPosition();
|
||||
point = glm::inverse(getRotation()) * point;
|
||||
point /= _dimensions;
|
||||
point /= getDimensions();
|
||||
point += 0.5f;
|
||||
point.y = 1.0f - point.y;
|
||||
point *= _dimensions * METERS_TO_INCHES * DPI;
|
||||
point *= getDimensions() * METERS_TO_INCHES * DPI;
|
||||
// Forward the mouse event.
|
||||
QMouseEvent mappedEvent(event->type(),
|
||||
QPoint((int)point.x, (int)point.y),
|
||||
|
@ -139,7 +139,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
QObject::connect(renderer, &EntityTreeRenderer::mouseMoveOnEntity, forwardMouseEvent);
|
||||
}
|
||||
|
||||
glm::vec2 dims = glm::vec2(_dimensions);
|
||||
glm::vec2 dims = glm::vec2(getDimensions());
|
||||
dims *= METERS_TO_INCHES * DPI;
|
||||
// The offscreen surface is idempotent for resizes (bails early
|
||||
// if it's a no-op), so it's safe to just call resize every frame
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include "RenderableZoneEntityItem.h"
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <gpu/Batch.h>
|
||||
|
||||
#include <DeferredLightingEffect.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
|
@ -90,49 +93,36 @@ void RenderableZoneEntityItem::updateGeometry() {
|
|||
}
|
||||
|
||||
void RenderableZoneEntityItem::render(RenderArgs* args) {
|
||||
Q_ASSERT(getType() == EntityTypes::Zone);
|
||||
|
||||
if (_drawZoneBoundaries) {
|
||||
switch (getShapeType()) {
|
||||
case SHAPE_TYPE_COMPOUND: {
|
||||
PerformanceTimer perfTimer("zone->renderCompound");
|
||||
updateGeometry();
|
||||
|
||||
if (_model && _model->isActive()) {
|
||||
PerformanceTimer perfTimer("zone->renderCompound");
|
||||
glPushMatrix();
|
||||
_model->renderInScene(getLocalRenderAlpha(), args);
|
||||
glPopMatrix();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SHAPE_TYPE_BOX:
|
||||
case SHAPE_TYPE_SPHERE: {
|
||||
PerformanceTimer perfTimer("zone->renderPrimitive");
|
||||
glm::vec3 position = getPosition();
|
||||
glm::vec3 center = getCenter();
|
||||
glm::vec3 dimensions = getDimensions();
|
||||
glm::quat rotation = getRotation();
|
||||
glm::vec4 DEFAULT_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
glm::vec4 DEFAULT_COLOR(1.0f, 1.0f, 1.0f, getLocalRenderAlpha());
|
||||
Q_ASSERT(args->_batch);
|
||||
gpu::Batch& batch = *args->_batch;
|
||||
batch.setModelTransform(getTransformToCenter());
|
||||
|
||||
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);
|
||||
|
||||
auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
|
||||
|
||||
if (getShapeType() == SHAPE_TYPE_SPHERE) {
|
||||
const int SLICES = 15;
|
||||
const int STACKS = 15;
|
||||
deferredLightingEffect->renderWireSphere(0.5f, SLICES, STACKS, DEFAULT_COLOR);
|
||||
} else {
|
||||
deferredLightingEffect->renderWireCube(1.0f, DEFAULT_COLOR);
|
||||
}
|
||||
} glPopMatrix();
|
||||
} glPopMatrix();
|
||||
auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
|
||||
|
||||
if (getShapeType() == SHAPE_TYPE_SPHERE) {
|
||||
const int SLICES = 15, STACKS = 15;
|
||||
deferredLightingEffect->renderWireSphere(batch, 0.5f, SLICES, STACKS, DEFAULT_COLOR);
|
||||
} else {
|
||||
deferredLightingEffect->renderWireCube(batch, 1.0f, DEFAULT_COLOR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -101,8 +101,8 @@ void BoxEntityItem::debugDump() const {
|
|||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << " BOX EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) :
|
|||
_lastEditedFromRemoteInRemoteTime(0),
|
||||
_created(UNKNOWN_CREATED_TIME),
|
||||
_changedOnServer(0),
|
||||
_position(ENTITY_ITEM_ZERO_VEC3),
|
||||
_dimensions(ENTITY_ITEM_DEFAULT_DIMENSIONS),
|
||||
_rotation(ENTITY_ITEM_DEFAULT_ROTATION),
|
||||
_transform(ENTITY_ITEM_DEFAULT_ROTATION,
|
||||
ENTITY_ITEM_DEFAULT_DIMENSIONS,
|
||||
ENTITY_ITEM_DEFAULT_POSITION),
|
||||
_glowLevel(ENTITY_ITEM_DEFAULT_GLOW_LEVEL),
|
||||
_localRenderAlpha(ENTITY_ITEM_DEFAULT_LOCAL_RENDER_ALPHA),
|
||||
_density(ENTITY_ITEM_DEFAULT_DENSITY),
|
||||
|
@ -319,8 +319,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
}
|
||||
|
||||
// if this bitstream indicates that this node is the simulation owner, ignore any physics-related updates.
|
||||
glm::vec3 savePosition = _position;
|
||||
glm::quat saveRotation = _rotation;
|
||||
glm::vec3 savePosition = getPosition();
|
||||
glm::quat saveRotation = getRotation();
|
||||
// glm::vec3 saveVelocity = _velocity;
|
||||
// glm::vec3 saveAngularVelocity = _angularVelocity;
|
||||
// glm::vec3 saveGravity = _gravity;
|
||||
|
@ -624,8 +624,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
if (_simulatorID == myNodeID && !_simulatorID.isNull()) {
|
||||
// the packet that produced this bitstream originally came from physics simulations performed by
|
||||
// this node, so our version has to be newer than what the packet contained.
|
||||
_position = savePosition;
|
||||
_rotation = saveRotation;
|
||||
setPosition(savePosition);
|
||||
setRotation(saveRotation);
|
||||
// _velocity = saveVelocity;
|
||||
// _angularVelocity = saveAngularVelocity;
|
||||
// _gravity = saveGravity;
|
||||
|
@ -636,10 +636,11 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
}
|
||||
|
||||
void EntityItem::debugDump() const {
|
||||
auto position = getPosition();
|
||||
qCDebug(entities) << "EntityItem id:" << getEntityItemID();
|
||||
qCDebug(entities, " edited ago:%f", getEditedAgo());
|
||||
qCDebug(entities, " position:%f,%f,%f", _position.x, _position.y, _position.z);
|
||||
qCDebug(entities) << " dimensions:" << _dimensions;
|
||||
qCDebug(entities, " position:%f,%f,%f", position.x, position.y, position.z);
|
||||
qCDebug(entities) << " dimensions:" << getDimensions();
|
||||
}
|
||||
|
||||
// adjust any internal timestamps to fix clock skew for this server
|
||||
|
@ -662,8 +663,8 @@ void EntityItem::adjustEditPacketForClockSkew(unsigned char* editPacketBuffer, s
|
|||
#endif
|
||||
}
|
||||
|
||||
float EntityItem::computeMass() const {
|
||||
return _density * _volumeMultiplier * _dimensions.x * _dimensions.y * _dimensions.z;
|
||||
float EntityItem::computeMass() const {
|
||||
return _density * _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z;
|
||||
}
|
||||
|
||||
void EntityItem::setDensity(float density) {
|
||||
|
@ -688,8 +689,8 @@ void EntityItem::setMass(float mass) {
|
|||
// Setting the mass actually changes the _density (at fixed volume), however
|
||||
// we must protect the density range to help maintain stability of physics simulation
|
||||
// therefore this method might not accept the mass that is supplied.
|
||||
|
||||
float volume = _volumeMultiplier * _dimensions.x * _dimensions.y * _dimensions.z;
|
||||
|
||||
float volume = _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z;
|
||||
|
||||
// compute new density
|
||||
const float MIN_VOLUME = 1.0e-6f; // 0.001mm^3
|
||||
|
@ -993,10 +994,30 @@ void EntityItem::recordCreationTime() {
|
|||
_lastSimulated = _created;
|
||||
}
|
||||
|
||||
void EntityItem::setCenterPosition(const glm::vec3& position) {
|
||||
Transform transformToCenter = getTransformToCenter();
|
||||
transformToCenter.setTranslation(position);
|
||||
setTranformToCenter(transformToCenter);
|
||||
}
|
||||
|
||||
// TODO: doesn't this need to handle rotation?
|
||||
glm::vec3 EntityItem::getCenter() const {
|
||||
return _position + (_dimensions * (glm::vec3(0.5f,0.5f,0.5f) - _registrationPoint));
|
||||
const Transform EntityItem::getTransformToCenter() const {
|
||||
Transform result = getTransform();
|
||||
if (getRegistrationPoint() != ENTITY_ITEM_HALF_VEC3) { // If it is not already centered, translate to center
|
||||
result.postTranslate(ENTITY_ITEM_HALF_VEC3 - getRegistrationPoint()); // Position to center
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void EntityItem::setTranformToCenter(const Transform& transform) {
|
||||
if (getRegistrationPoint() == ENTITY_ITEM_HALF_VEC3) {
|
||||
// If it is already centered, just call setTransform
|
||||
setTransform(transform);
|
||||
return;
|
||||
}
|
||||
|
||||
Transform copy = transform;
|
||||
copy.postTranslate(getRegistrationPoint() - ENTITY_ITEM_HALF_VEC3); // Center to position
|
||||
setTransform(copy);
|
||||
}
|
||||
|
||||
/// The maximum bounding cube for the entity, independent of it's rotation.
|
||||
|
@ -1004,13 +1025,13 @@ glm::vec3 EntityItem::getCenter() const {
|
|||
///
|
||||
AACube EntityItem::getMaximumAACube() const {
|
||||
// * we know that the position is the center of rotation
|
||||
glm::vec3 centerOfRotation = _position; // also where _registration point is
|
||||
glm::vec3 centerOfRotation = getPosition(); // also where _registration point is
|
||||
|
||||
// * we know that the registration point is the center of rotation
|
||||
// * we can calculate the length of the furthest extent from the registration point
|
||||
// as the dimensions * max (registrationPoint, (1.0,1.0,1.0) - registrationPoint)
|
||||
glm::vec3 registrationPoint = (_dimensions * _registrationPoint);
|
||||
glm::vec3 registrationRemainder = (_dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint));
|
||||
glm::vec3 registrationPoint = (getDimensions() * getRegistrationPoint());
|
||||
glm::vec3 registrationRemainder = (getDimensions() * (glm::vec3(1.0f, 1.0f, 1.0f) - getRegistrationPoint()));
|
||||
glm::vec3 furthestExtentFromRegistration = glm::max(registrationPoint, registrationRemainder);
|
||||
|
||||
// * we know that if you rotate in any direction you would create a sphere
|
||||
|
@ -1032,13 +1053,13 @@ AACube EntityItem::getMinimumAACube() const {
|
|||
// _position represents the position of the registration point.
|
||||
glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint;
|
||||
|
||||
glm::vec3 unrotatedMinRelativeToEntity = - (_dimensions * _registrationPoint);
|
||||
glm::vec3 unrotatedMaxRelativeToEntity = _dimensions * registrationRemainder;
|
||||
glm::vec3 unrotatedMinRelativeToEntity = - (getDimensions() * getRegistrationPoint());
|
||||
glm::vec3 unrotatedMaxRelativeToEntity = getDimensions() * registrationRemainder;
|
||||
Extents unrotatedExtentsRelativeToRegistrationPoint = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
|
||||
Extents rotatedExtentsRelativeToRegistrationPoint = unrotatedExtentsRelativeToRegistrationPoint.getRotated(getRotation());
|
||||
|
||||
// shift the extents to be relative to the position/registration point
|
||||
rotatedExtentsRelativeToRegistrationPoint.shiftBy(_position);
|
||||
rotatedExtentsRelativeToRegistrationPoint.shiftBy(getPosition());
|
||||
|
||||
// the cube that best encompasses extents is...
|
||||
AABox box(rotatedExtentsRelativeToRegistrationPoint);
|
||||
|
@ -1056,13 +1077,13 @@ AABox EntityItem::getAABox() const {
|
|||
// _position represents the position of the registration point.
|
||||
glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint;
|
||||
|
||||
glm::vec3 unrotatedMinRelativeToEntity = - (_dimensions * _registrationPoint);
|
||||
glm::vec3 unrotatedMaxRelativeToEntity = _dimensions * registrationRemainder;
|
||||
glm::vec3 unrotatedMinRelativeToEntity = - (getDimensions() * _registrationPoint);
|
||||
glm::vec3 unrotatedMaxRelativeToEntity = getDimensions() * registrationRemainder;
|
||||
Extents unrotatedExtentsRelativeToRegistrationPoint = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
|
||||
Extents rotatedExtentsRelativeToRegistrationPoint = unrotatedExtentsRelativeToRegistrationPoint.getRotated(getRotation());
|
||||
|
||||
// shift the extents to be relative to the position/registration point
|
||||
rotatedExtentsRelativeToRegistrationPoint.shiftBy(_position);
|
||||
rotatedExtentsRelativeToRegistrationPoint.shiftBy(getPosition());
|
||||
|
||||
return AABox(rotatedExtentsRelativeToRegistrationPoint);
|
||||
}
|
||||
|
@ -1083,7 +1104,7 @@ AABox EntityItem::getAABox() const {
|
|||
void EntityItem::setRadius(float value) {
|
||||
float diameter = value * 2.0f;
|
||||
float maxDimension = sqrt((diameter * diameter) / 3.0f);
|
||||
_dimensions = glm::vec3(maxDimension, maxDimension, maxDimension);
|
||||
setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
||||
}
|
||||
|
||||
// TODO: get rid of all users of this function...
|
||||
|
@ -1091,7 +1112,7 @@ void EntityItem::setRadius(float value) {
|
|||
// ... cornerToCornerLength = sqrt(3 x maxDimension ^ 2)
|
||||
// ... radius = sqrt(3 x maxDimension ^ 2) / 2.0f;
|
||||
float EntityItem::getRadius() const {
|
||||
return 0.5f * glm::length(_dimensions);
|
||||
return 0.5f * glm::length(getDimensions());
|
||||
}
|
||||
|
||||
bool EntityItem::contains(const glm::vec3& point) const {
|
||||
|
@ -1114,10 +1135,10 @@ void EntityItem::updatePositionInDomainUnits(const glm::vec3& value) {
|
|||
}
|
||||
|
||||
void EntityItem::updatePosition(const glm::vec3& value) {
|
||||
auto delta = glm::distance(_position, value);
|
||||
auto delta = glm::distance(getPosition(), value);
|
||||
if (delta > IGNORE_POSITION_DELTA) {
|
||||
_dirtyFlags |= EntityItem::DIRTY_POSITION;
|
||||
_position = value;
|
||||
setPosition(value);
|
||||
if (delta > ACTIVATION_POSITION_DELTA) {
|
||||
_dirtyFlags |= EntityItem::DIRTY_PHYSICS_ACTIVATION;
|
||||
}
|
||||
|
@ -1130,9 +1151,9 @@ void EntityItem::updateDimensionsInDomainUnits(const glm::vec3& value) {
|
|||
}
|
||||
|
||||
void EntityItem::updateDimensions(const glm::vec3& value) {
|
||||
auto delta = glm::distance(_dimensions, value);
|
||||
auto delta = glm::distance(getDimensions(), value);
|
||||
if (delta > IGNORE_DIMENSIONS_DELTA) {
|
||||
_dimensions = value;
|
||||
setDimensions(value);
|
||||
if (delta > ACTIVATION_DIMENSIONS_DELTA) {
|
||||
// rebuilding the shape will always activate
|
||||
_dirtyFlags |= (EntityItem::DIRTY_SHAPE | EntityItem::DIRTY_MASS);
|
||||
|
@ -1141,10 +1162,10 @@ void EntityItem::updateDimensions(const glm::vec3& value) {
|
|||
}
|
||||
|
||||
void EntityItem::updateRotation(const glm::quat& rotation) {
|
||||
if (_rotation != rotation) {
|
||||
_rotation = rotation;
|
||||
if (getRotation() != rotation) {
|
||||
setRotation(rotation);
|
||||
|
||||
auto alignmentDot = glm::abs(glm::dot(_rotation, rotation));
|
||||
auto alignmentDot = glm::abs(glm::dot(getRotation(), rotation));
|
||||
if (alignmentDot < IGNORE_ALIGNMENT_DOT) {
|
||||
_dirtyFlags |= EntityItem::DIRTY_ROTATION;
|
||||
}
|
||||
|
@ -1159,7 +1180,7 @@ void EntityItem::updateMass(float mass) {
|
|||
// we must protect the density range to help maintain stability of physics simulation
|
||||
// therefore this method might not accept the mass that is supplied.
|
||||
|
||||
float volume = _volumeMultiplier * _dimensions.x * _dimensions.y * _dimensions.z;
|
||||
float volume = _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z;
|
||||
|
||||
// compute new density
|
||||
float newDensity = _density;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <OctreeElement.h> // for OctreeElement::AppendState
|
||||
#include <OctreePacketData.h>
|
||||
#include <ShapeInfo.h>
|
||||
#include <Transform.h>
|
||||
|
||||
#include "EntityItemID.h"
|
||||
#include "EntityItemProperties.h"
|
||||
|
@ -175,21 +176,27 @@ public:
|
|||
|
||||
// attributes applicable to all entity types
|
||||
EntityTypes::EntityType getType() const { return _type; }
|
||||
const glm::vec3& getPosition() const { return _position; } /// get position in meters
|
||||
|
||||
void setPosition(const glm::vec3& value) {
|
||||
_position = value;
|
||||
}
|
||||
inline glm::vec3 getCenterPosition() const { return getTransformToCenter().getTranslation(); }
|
||||
void setCenterPosition(const glm::vec3& position);
|
||||
|
||||
const Transform getTransformToCenter() const;
|
||||
void setTranformToCenter(const Transform& transform);
|
||||
|
||||
inline const Transform& getTransform() const { return _transform; }
|
||||
inline void setTransform(const Transform& transform) { _transform = transform; }
|
||||
|
||||
/// Position in meters (0.0 - TREE_SCALE)
|
||||
inline const glm::vec3& getPosition() const { return _transform.getTranslation(); }
|
||||
inline void setPosition(const glm::vec3& value) { _transform.setTranslation(value); }
|
||||
|
||||
inline const glm::quat& getRotation() const { return _transform.getRotation(); }
|
||||
inline void setRotation(const glm::quat& rotation) { _transform.setRotation(rotation); }
|
||||
|
||||
/// Dimensions in meters (0.0 - TREE_SCALE)
|
||||
inline const glm::vec3& getDimensions() const { return _transform.getScale(); }
|
||||
inline virtual void setDimensions(const glm::vec3& value) { _transform.setScale(glm::abs(value)); }
|
||||
|
||||
glm::vec3 getCenter() const;
|
||||
|
||||
const glm::vec3& getDimensions() const { return _dimensions; } /// get dimensions in meters
|
||||
|
||||
/// set dimensions in meter units (0.0 - TREE_SCALE)
|
||||
virtual void setDimensions(const glm::vec3& value) { _dimensions = glm::abs(value); }
|
||||
|
||||
const glm::quat& getRotation() const { return _rotation; }
|
||||
void setRotation(const glm::quat& rotation) { _rotation = rotation; }
|
||||
|
||||
float getGlowLevel() const { return _glowLevel; }
|
||||
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
|
||||
|
@ -299,7 +306,7 @@ public:
|
|||
|
||||
virtual bool isReadyToComputeShape() { return true; }
|
||||
virtual void computeShapeInfo(ShapeInfo& info);
|
||||
virtual float getVolumeEstimate() const { return _dimensions.x * _dimensions.y * _dimensions.z; }
|
||||
virtual float getVolumeEstimate() const { return getDimensions().x * getDimensions().y * getDimensions().z; }
|
||||
|
||||
/// return preferred shape type (actual physical shape may differ)
|
||||
virtual ShapeType getShapeType() const { return SHAPE_TYPE_NONE; }
|
||||
|
@ -362,9 +369,7 @@ protected:
|
|||
quint64 _created;
|
||||
quint64 _changedOnServer;
|
||||
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _dimensions;
|
||||
glm::quat _rotation;
|
||||
Transform _transform;
|
||||
float _glowLevel;
|
||||
float _localRenderAlpha;
|
||||
float _density = ENTITY_ITEM_DEFAULT_DENSITY; // kg/m^3
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
// There is a minor performance gain when comparing/copying an existing glm::vec3 rather than
|
||||
// creating a new one on the stack so we declare the ZERO_VEC3 constant as an optimization.
|
||||
const glm::vec3 ENTITY_ITEM_ZERO_VEC3(0.0f);
|
||||
const glm::vec3 ENTITY_ITEM_ZERO_VEC3 = glm::vec3(0.0f);
|
||||
const glm::vec3 ENTITY_ITEM_ONE_VEC3 = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||
const glm::vec3 ENTITY_ITEM_HALF_VEC3 = ENTITY_ITEM_ONE_VEC3 / 2.0f;
|
||||
|
||||
const bool ENTITY_ITEM_DEFAULT_LOCKED = false;
|
||||
const QString ENTITY_ITEM_DEFAULT_USER_DATA = QString("");
|
||||
|
@ -31,11 +33,12 @@ const bool ENTITY_ITEM_DEFAULT_VISIBLE = true;
|
|||
|
||||
const QString ENTITY_ITEM_DEFAULT_SCRIPT = QString("");
|
||||
const QString ENTITY_ITEM_DEFAULT_COLLISION_SOUND_URL = QString("");
|
||||
const glm::vec3 ENTITY_ITEM_DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f, 0.5f, 0.5f); // center
|
||||
const glm::vec3 ENTITY_ITEM_DEFAULT_REGISTRATION_POINT = ENTITY_ITEM_HALF_VEC3; // center
|
||||
|
||||
const float ENTITY_ITEM_IMMORTAL_LIFETIME = -1.0f; /// special lifetime which means the entity lives for ever
|
||||
const float ENTITY_ITEM_DEFAULT_LIFETIME = ENTITY_ITEM_IMMORTAL_LIFETIME;
|
||||
|
||||
const glm::vec3 ENTITY_ITEM_DEFAULT_POSITION = ENTITY_ITEM_ZERO_VEC3;
|
||||
const glm::quat ENTITY_ITEM_DEFAULT_ROTATION;
|
||||
const float ENTITY_ITEM_DEFAULT_WIDTH = 0.1f;
|
||||
const glm::vec3 ENTITY_ITEM_DEFAULT_DIMENSIONS = glm::vec3(ENTITY_ITEM_DEFAULT_WIDTH);
|
||||
|
|
|
@ -47,10 +47,10 @@ void LightEntityItem::setDimensions(const glm::vec3& value) {
|
|||
// recalculate the x/y dimensions to properly encapsulate the spotlight.
|
||||
const float length = value.z;
|
||||
const float width = length * glm::sin(glm::radians(_cutoff));
|
||||
_dimensions = glm::vec3(width, width, length);
|
||||
EntityItem::setDimensions(glm::vec3(width, width, length));
|
||||
} else {
|
||||
float maxDimension = glm::max(value.x, value.y, value.z);
|
||||
_dimensions = glm::vec3(maxDimension, maxDimension, maxDimension);
|
||||
EntityItem::setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,12 @@ void LightEntityItem::setIsSpotlight(bool value) {
|
|||
_isSpotlight = value;
|
||||
|
||||
if (_isSpotlight) {
|
||||
const float length = _dimensions.z;
|
||||
const float length = getDimensions().z;
|
||||
const float width = length * glm::sin(glm::radians(_cutoff));
|
||||
_dimensions = glm::vec3(width, width, length);
|
||||
setDimensions(glm::vec3(width, width, length));
|
||||
} else {
|
||||
float maxDimension = glm::max(_dimensions.x, _dimensions.y, _dimensions.z);
|
||||
_dimensions = glm::vec3(maxDimension, maxDimension, maxDimension);
|
||||
float maxDimension = glm::max(getDimensions().x, getDimensions().y, getDimensions().z);
|
||||
setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ void LightEntityItem::setCutoff(float value) {
|
|||
if (_isSpotlight) {
|
||||
// If we are a spotlight, adjusting the cutoff will affect the area we encapsulate,
|
||||
// so update the dimensions to reflect this.
|
||||
const float length = _dimensions.z;
|
||||
const float length = getDimensions().z;
|
||||
const float width = length * glm::sin(glm::radians(_cutoff));
|
||||
_dimensions = glm::vec3(width, width, length);
|
||||
setDimensions(glm::vec3(width, width, length));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,8 @@ void LineEntityItem::debugDump() const {
|
|||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << " LINE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
}
|
||||
|
||||
|
|
|
@ -276,8 +276,8 @@ void ParticleEffectEntityItem::debugDump() const {
|
|||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << "PA EFFECT EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
}
|
||||
|
||||
|
|
|
@ -119,8 +119,8 @@ void SphereEntityItem::debugDump() const {
|
|||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << "SHPERE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ const float TEXT_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
|
|||
|
||||
void TextEntityItem::setDimensions(const glm::vec3& value) {
|
||||
// NOTE: Text Entities always have a "depth" of 1cm.
|
||||
_dimensions = glm::vec3(value.x, value.y, TEXT_ENTITY_ITEM_FIXED_DEPTH);
|
||||
EntityItem::setDimensions(glm::vec3(value.x, value.y, TEXT_ENTITY_ITEM_FIXED_DEPTH));
|
||||
}
|
||||
|
||||
EntityItemProperties TextEntityItem::getProperties() const {
|
||||
|
@ -136,7 +136,7 @@ bool TextEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const
|
|||
PlaneShape plane;
|
||||
|
||||
const glm::vec3 UNROTATED_NORMAL(0.0f, 0.0f, -1.0f);
|
||||
glm::vec3 normal = _rotation * UNROTATED_NORMAL;
|
||||
glm::vec3 normal = getRotation() * UNROTATED_NORMAL;
|
||||
plane.setNormal(normal);
|
||||
plane.setPoint(getPosition()); // the position is definitely a point on our plane
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ const float WEB_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
|
|||
|
||||
void WebEntityItem::setDimensions(const glm::vec3& value) {
|
||||
// NOTE: Web Entities always have a "depth" of 1cm.
|
||||
_dimensions = glm::vec3(value.x, value.y, WEB_ENTITY_ITEM_FIXED_DEPTH);
|
||||
EntityItem::setDimensions(glm::vec3(value.x, value.y, WEB_ENTITY_ITEM_FIXED_DEPTH));
|
||||
}
|
||||
|
||||
EntityItemProperties WebEntityItem::getProperties() const {
|
||||
|
@ -113,7 +113,7 @@ bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const g
|
|||
PlaneShape plane;
|
||||
|
||||
const glm::vec3 UNROTATED_NORMAL(0.0f, 0.0f, -1.0f);
|
||||
glm::vec3 normal = _rotation * UNROTATED_NORMAL;
|
||||
glm::vec3 normal = getRotation() * UNROTATED_NORMAL;
|
||||
plane.setNormal(normal);
|
||||
plane.setPoint(getPosition()); // the position is definitely a point on our plane
|
||||
|
||||
|
|
|
@ -218,8 +218,8 @@ void ZoneEntityItem::debugDump() const {
|
|||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << " ZoneEntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " keyLightColor:" << _keyLightColor[0] << "," << _keyLightColor[1] << "," << _keyLightColor[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
qCDebug(entities) << " _keyLightIntensity:" << _keyLightIntensity;
|
||||
qCDebug(entities) << " _keyLightAmbientIntensity:" << _keyLightAmbientIntensity;
|
||||
|
|
|
@ -76,10 +76,12 @@ GLBackend::GLBackend() :
|
|||
_output()
|
||||
{
|
||||
initTransform();
|
||||
initInput();
|
||||
}
|
||||
|
||||
GLBackend::~GLBackend() {
|
||||
killTransform();
|
||||
killInput();
|
||||
}
|
||||
|
||||
void GLBackend::render(Batch& batch) {
|
||||
|
|
|
@ -200,7 +200,9 @@ protected:
|
|||
void do_setInputFormat(Batch& batch, uint32 paramOffset);
|
||||
void do_setInputBuffer(Batch& batch, uint32 paramOffset);
|
||||
void do_setIndexBuffer(Batch& batch, uint32 paramOffset);
|
||||
|
||||
|
||||
void initInput();
|
||||
void killInput();
|
||||
void updateInput();
|
||||
struct InputStageState {
|
||||
bool _invalidFormat;
|
||||
|
@ -238,7 +240,7 @@ protected:
|
|||
void do_setModelTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setViewTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setProjectionTransform(Batch& batch, uint32 paramOffset);
|
||||
|
||||
|
||||
void initTransform();
|
||||
void killTransform();
|
||||
void updateTransform();
|
||||
|
|
|
@ -46,6 +46,24 @@ static const GLenum attributeSlotToClassicAttribName[NUM_CLASSIC_ATTRIBS] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
void GLBackend::initInput() {
|
||||
glPushClientAttrib(GL_VERTEX_ARRAY);
|
||||
glPushClientAttrib(GL_NORMAL_ARRAY);
|
||||
glPushClientAttrib(GL_COLOR_ARRAY);
|
||||
glPushClientAttrib(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
for (int i = 0; i < NUM_CLASSIC_ATTRIBS; i++) {
|
||||
_input._attributeActivation[i] = glIsEnabled(attributeSlotToClassicAttribName[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void GLBackend::killInput() {
|
||||
glPopClientAttrib(); // GL_VERTEX_ARRAY
|
||||
glPopClientAttrib(); // GL_NORMAL_ARRAY
|
||||
glPopClientAttrib(); // GL_COLOR_ARRAY
|
||||
glPopClientAttrib(); // GL_TEXTURE_COORD_ARRAY
|
||||
}
|
||||
|
||||
void GLBackend::updateInput() {
|
||||
if (_input._invalidFormat || _input._buffersState.any()) {
|
||||
|
||||
|
@ -69,8 +87,7 @@ void GLBackend::updateInput() {
|
|||
if (i < NUM_CLASSIC_ATTRIBS) {
|
||||
if (newState) {
|
||||
glEnableClientState(attributeSlotToClassicAttribName[i]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
glDisableClientState(attributeSlotToClassicAttribName[i]);
|
||||
}
|
||||
} else {
|
||||
|
@ -147,6 +164,9 @@ void GLBackend::updateInput() {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
// everything format related should be in sync now
|
||||
_input._invalidFormat = false;
|
||||
|
|
|
@ -99,48 +99,67 @@ void DeferredLightingEffect::bindSimpleProgram() {
|
|||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch) {
|
||||
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(batch, true, true, true);
|
||||
batch._glUseProgram(_simpleProgram.programId());
|
||||
batch._glUniform1f(_glowIntensityLocation, DependencyManager::get<GlowEffect>()->getIntensity());
|
||||
batch._glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::releaseSimpleProgram() {
|
||||
glEnable(GL_BLEND);
|
||||
_simpleProgram.release();
|
||||
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false, false);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, color);
|
||||
releaseSimpleProgram();
|
||||
void DeferredLightingEffect::releaseSimpleProgram(gpu::Batch& batch) {
|
||||
batch._glEnable(GL_BLEND);
|
||||
batch._glUseProgram(0);
|
||||
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(batch, true, false, false);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, color, false);
|
||||
releaseSimpleProgram();
|
||||
void DeferredLightingEffect::renderSolidSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color) {
|
||||
bindSimpleProgram(batch);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(batch, radius, slices, stacks, color);
|
||||
releaseSimpleProgram(batch);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderSolidCube(float size, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(size, color);
|
||||
releaseSimpleProgram();
|
||||
void DeferredLightingEffect::renderWireSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color) {
|
||||
bindSimpleProgram(batch);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(batch, radius, slices, stacks, color, false);
|
||||
releaseSimpleProgram(batch);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) {
|
||||
bindSimpleProgram(batch);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(batch, size, color);
|
||||
releaseSimpleProgram(batch);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderWireCube(float size, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(size, color);
|
||||
releaseSimpleProgram();
|
||||
gpu::Batch batch;
|
||||
renderWireCube(batch, size, color);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
void DeferredLightingEffect::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) {
|
||||
bindSimpleProgram(batch);
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(batch, size, color);
|
||||
releaseSimpleProgram(batch);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner,
|
||||
const glm::vec4& color) {
|
||||
bindSimpleProgram(batch);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, minCorner, maxCorner, color);
|
||||
releaseSimpleProgram(batch);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderLine(p1, p2, color1, color2);
|
||||
releaseSimpleProgram();
|
||||
}
|
||||
|
||||
|
||||
void DeferredLightingEffect::renderSolidCone(float base, float height, int slices, int stacks) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderCone(base, height, slices, stacks);
|
||||
releaseSimpleProgram();
|
||||
bindSimpleProgram(batch);
|
||||
DependencyManager::get<GeometryCache>()->renderLine(batch, p1, p2, color1, color2);
|
||||
releaseSimpleProgram(batch);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::addPointLight(const glm::vec3& position, float radius, const glm::vec3& color,
|
||||
|
|
|
@ -38,28 +38,32 @@ public:
|
|||
|
||||
/// Sets up the state necessary to render static untextured geometry with the simple program.
|
||||
void bindSimpleProgram();
|
||||
void bindSimpleProgram(gpu::Batch& batch);
|
||||
|
||||
/// Tears down the state necessary to render static untextured geometry with the simple program.
|
||||
void releaseSimpleProgram();
|
||||
void releaseSimpleProgram(gpu::Batch& batch);
|
||||
|
||||
//// Renders a solid sphere with the simple program.
|
||||
void renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color);
|
||||
void renderSolidSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color);
|
||||
|
||||
//// Renders a wireframe sphere with the simple program.
|
||||
void renderWireSphere(float radius, int slices, int stacks, const glm::vec4& color);
|
||||
void renderWireSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color);
|
||||
|
||||
//// Renders a solid cube with the simple program.
|
||||
void renderSolidCube(float size, const glm::vec4& color);
|
||||
void renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color);
|
||||
|
||||
//// Renders a wireframe cube with the simple program.
|
||||
// FIXME Remove non Batch version once Cube3DOverlay uses the render pipeline
|
||||
void renderWireCube(float size, const glm::vec4& color);
|
||||
void renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color);
|
||||
|
||||
//// Renders a quad with the simple program.
|
||||
void renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color);
|
||||
|
||||
//// Renders a line with the simple program.
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2);
|
||||
|
||||
//// Renders a solid cone with the simple program.
|
||||
void renderSolidCone(float base, float height, int slices, int stacks);
|
||||
|
||||
/// Adds a point light to render for the current frame.
|
||||
void addPointLight(const glm::vec3& position, float radius, const glm::vec3& color = glm::vec3(0.0f, 0.0f, 0.0f),
|
||||
|
|
|
@ -56,6 +56,12 @@ const int NUM_BYTES_PER_VERTEX = NUM_COORDS_PER_VERTEX * sizeof(GLfloat);
|
|||
const int NUM_BYTES_PER_INDEX = sizeof(GLushort);
|
||||
|
||||
void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) {
|
||||
gpu::Batch batch;
|
||||
renderSphere(batch, radius, slices, stacks, color, solid, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) {
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
|
||||
Vec2Pair radiusKey(glm::vec2(radius, slices), glm::vec2(stacks, 0));
|
||||
|
@ -279,8 +285,6 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm
|
|||
gpu::BufferView normalsView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element);
|
||||
gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(streamFormat);
|
||||
batch.setInputBuffer(VERTICES_SLOT, verticesView);
|
||||
batch.setInputBuffer(NORMALS_SLOT, normalsView);
|
||||
|
@ -292,14 +296,6 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm
|
|||
} else {
|
||||
batch.drawIndexed(gpu::LINES, indices);
|
||||
}
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderCone(float base, float height, int slices, int stacks) {
|
||||
|
@ -402,7 +398,14 @@ void GeometryCache::renderCone(float base, float height, int slices, int stacks)
|
|||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) {
|
||||
gpu::Batch batch;
|
||||
renderGrid(batch, xDivisions, yDivisions, color);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color) {
|
||||
IntPair key(xDivisions, yDivisions);
|
||||
Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions), glm::vec3(color.z, color.y, xDivisions));
|
||||
|
||||
|
@ -470,25 +473,21 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4&
|
|||
gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);
|
||||
gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(streamFormat);
|
||||
batch.setInputBuffer(VERTICES_SLOT, verticesView);
|
||||
batch.setInputBuffer(COLOR_SLOT, colorView);
|
||||
batch.draw(gpu::LINES, vertices, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) {
|
||||
gpu::Batch batch;
|
||||
renderGrid(batch, x, y, width, height, rows, cols, color, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
}
|
||||
|
||||
// TODO: properly handle the x,y,w,h changing for an ID
|
||||
// TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that??
|
||||
void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) {
|
||||
void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) {
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(renderutils) << "GeometryCache::renderGrid(x["<<x<<"], "
|
||||
"y["<<y<<"],"
|
||||
|
@ -580,20 +579,11 @@ void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, in
|
|||
|
||||
gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);
|
||||
gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(streamFormat);
|
||||
batch.setInputBuffer(VERTICES_SLOT, verticesView);
|
||||
batch.setInputBuffer(COLOR_SLOT, colorView);
|
||||
batch.draw(gpu::LINES, vertices, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color) {
|
||||
|
@ -792,24 +782,27 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
|
|||
}
|
||||
|
||||
void GeometryCache::renderVertices(gpu::Primitive primitiveType, int id) {
|
||||
gpu::Batch batch;
|
||||
renderVertices(batch, primitiveType, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id) {
|
||||
BatchItemDetails& details = _registeredVertices[id];
|
||||
if (details.isCreated) {
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(primitiveType, details.vertices, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void GeometryCache::renderSolidCube(float size, const glm::vec4& color) {
|
||||
gpu::Batch batch;
|
||||
renderSolidCube(batch, size, color);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) {
|
||||
Vec2Pair colorKey(glm::vec2(color.x, color.y), glm::vec2(color.z, color.y));
|
||||
const int FLOATS_PER_VERTEX = 3;
|
||||
const int VERTICES_PER_FACE = 4;
|
||||
|
@ -915,25 +908,21 @@ void GeometryCache::renderSolidCube(float size, const glm::vec4& color) {
|
|||
gpu::BufferView normalsView(verticesBuffer, NORMALS_OFFSET, verticesBuffer->getSize(), VERTEX_STRIDE, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element);
|
||||
gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(streamFormat);
|
||||
batch.setInputBuffer(VERTICES_SLOT, verticesView);
|
||||
batch.setInputBuffer(NORMALS_SLOT, normalsView);
|
||||
batch.setInputBuffer(COLOR_SLOT, colorView);
|
||||
batch.setIndexBuffer(gpu::UINT8, _solidCubeIndexBuffer, 0);
|
||||
batch.drawIndexed(gpu::TRIANGLES, indices);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderWireCube(float size, const glm::vec4& color) {
|
||||
gpu::Batch batch;
|
||||
renderWireCube(batch, size, color);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) {
|
||||
Vec2Pair colorKey(glm::vec2(color.x, color.y),glm::vec2(color.z, color.y));
|
||||
const int FLOATS_PER_VERTEX = 3;
|
||||
const int VERTICES_PER_EDGE = 2;
|
||||
|
@ -1003,24 +992,20 @@ void GeometryCache::renderWireCube(float size, const glm::vec4& color) {
|
|||
gpu::BufferView verticesView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);
|
||||
gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(streamFormat);
|
||||
batch.setInputBuffer(VERTICES_SLOT, verticesView);
|
||||
batch.setInputBuffer(COLOR_SLOT, colorView);
|
||||
batch.setIndexBuffer(gpu::UINT8, _wireCubeIndexBuffer, 0);
|
||||
batch.drawIndexed(gpu::LINES, indices);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) {
|
||||
gpu::Batch batch;
|
||||
renderBevelCornersRect(batch, x, y, width, height, bevelDistance, color, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) {
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance));
|
||||
BatchItemDetails& details = registered ? _registeredBevelRects[id] : _bevelRects[key];
|
||||
|
@ -1113,21 +1098,18 @@ void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height,
|
|||
delete[] vertexBuffer;
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::QUADS, 4, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {
|
||||
gpu::Batch batch;
|
||||
renderQuad(batch, minCorner, maxCorner, color, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color);
|
||||
BatchItemDetails& details = registered ? _registeredQuad2D[id] : _quad2D[key];
|
||||
|
@ -1193,23 +1175,22 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC
|
|||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::QUADS, 4, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner,
|
||||
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
|
||||
const glm::vec4& color, int id) {
|
||||
gpu::Batch batch;
|
||||
renderQuad(batch, minCorner, maxCorner, texCoordMinCorner, texCoordMaxCorner, color, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner,
|
||||
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
|
||||
const glm::vec4& color, int id) {
|
||||
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
Vec4PairVec4 key(Vec4Pair(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y),
|
||||
|
@ -1282,27 +1263,18 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC
|
|||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
//glBindTexture(GL_TEXTURE_2D, _currentTextureID); // this is quad specific...
|
||||
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::QUADS, 4, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
// glBindTexture(GL_TEXTURE_2D, 0);
|
||||
// glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
|
||||
gpu::Batch batch;
|
||||
renderQuad(batch, minCorner, maxCorner, color, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color);
|
||||
BatchItemDetails& details = registered ? _registeredQuad3D[id] : _quad3D[key];
|
||||
|
@ -1368,18 +1340,9 @@ void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxC
|
|||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::QUADS, 4, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft,
|
||||
|
@ -1387,6 +1350,17 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom
|
|||
const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,
|
||||
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
|
||||
const glm::vec4& color, int id) {
|
||||
gpu::Batch batch;
|
||||
renderQuad(batch, topLeft, bottomLeft, bottomRight, topRight, texCoordTopLeft, texCoordBottomLeft,
|
||||
texCoordBottomRight, texCoordTopRight, color, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft,
|
||||
const glm::vec3& bottomRight, const glm::vec3& topRight,
|
||||
const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,
|
||||
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
|
||||
const glm::vec4& color, int id) {
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(renderutils) << "renderQuad() vec3 + texture VBO...";
|
||||
|
@ -1470,31 +1444,18 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom
|
|||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
//glBindTexture(GL_TEXTURE_2D, _currentTextureID); // this is quad specific...
|
||||
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::QUADS, 4, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
// TODO: The callers of this method (renderMagnifier and renderReticle) assume that we won't disable an unbind
|
||||
// the texture after rendering. I'm not sure if this is correct in general but it's currently required for the
|
||||
// oculus overlay to work.
|
||||
//glBindTexture(GL_TEXTURE_2D, 0);
|
||||
//glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
|
||||
gpu::Batch batch;
|
||||
renderDashedLine(batch, start, end, color, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w)));
|
||||
BatchItemDetails& details = registered ? _registeredDashedLines[id] : _dashedLines[key];
|
||||
|
@ -1594,18 +1555,9 @@ void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& en
|
|||
#endif
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::LINES, details.vertices, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1659,6 +1611,13 @@ void GeometryCache::BatchItemDetails::clear() {
|
|||
|
||||
void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id) {
|
||||
gpu::Batch batch;
|
||||
renderLine(batch, p1, p2, color1, color2, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id) {
|
||||
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
Vec3Pair key(p1, p2);
|
||||
|
@ -1735,21 +1694,19 @@ void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
|||
#endif
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
// this is what it takes to render a quad
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::LINES, 2, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2,
|
||||
void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color1, const glm::vec4& color2, int id) {
|
||||
gpu::Batch batch;
|
||||
renderLine(batch, p1, p2, color1, color2, id);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id) {
|
||||
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
|
@ -1827,18 +1784,10 @@ void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2,
|
|||
#endif
|
||||
}
|
||||
|
||||
gpu::Batch batch;
|
||||
|
||||
// this is what it takes to render a quad
|
||||
batch.setInputFormat(details.streamFormat);
|
||||
batch.setInputStream(0, *details.stream);
|
||||
batch.draw(gpu::LINES, 2, 0);
|
||||
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -135,70 +135,113 @@ public:
|
|||
|
||||
void renderCone(float base, float height, int slices, int stacks);
|
||||
|
||||
void renderSphere(float radius, int slices, int stacks, const glm::vec3& color, bool solid = true, int id = UNKNOWN_ID)
|
||||
void renderSphere(float radius, int slices, int stacks, const glm::vec3& color, bool solid = true, int id = UNKNOWN_ID)
|
||||
{ renderSphere(radius, slices, stacks, glm::vec4(color, 1.0f), solid, id); }
|
||||
void renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec3& color, bool solid = true, int id = UNKNOWN_ID)
|
||||
{ renderSphere(batch, radius, slices, stacks, glm::vec4(color, 1.0f), solid, id); }
|
||||
|
||||
void renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid = true, int id = UNKNOWN_ID);
|
||||
void renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid = true, int id = UNKNOWN_ID);
|
||||
|
||||
void renderGrid(int xDivisions, int yDivisions, const glm::vec4& color);
|
||||
void renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color);
|
||||
void renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderSolidCube(float size, const glm::vec4& color);
|
||||
void renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color);
|
||||
void renderWireCube(float size, const glm::vec4& color);
|
||||
void renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color);
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(int x, int y, int width, int height, const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderQuad(glm::vec2(x,y), glm::vec2(x + width, y + height), color, id); }
|
||||
void renderQuad(gpu::Batch& batch, int x, int y, int width, int height, const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderQuad(batch, glm::vec2(x,y), glm::vec2(x + width, y + height), color, id); }
|
||||
|
||||
// TODO: I think there's a bug in this version of the renderQuad() that's not correctly rebuilding the vbos
|
||||
// if the color changes by the corners are the same, as evidenced by the audio meter which should turn white
|
||||
// when it's clipping
|
||||
void renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner,
|
||||
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner,
|
||||
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft,
|
||||
const glm::vec3& bottomRight, const glm::vec3& topRight,
|
||||
const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,
|
||||
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft,
|
||||
const glm::vec3& bottomRight, const glm::vec3& topRight,
|
||||
const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,
|
||||
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, color, color, id); }
|
||||
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, color, color, id); }
|
||||
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); }
|
||||
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); }
|
||||
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, color, color, id); }
|
||||
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, color, color, id); }
|
||||
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
|
||||
void renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec3& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, glm::vec4(color, 1.0f), id); }
|
||||
void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec3& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, glm::vec4(color, 1.0f), id); }
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, color, color, id); }
|
||||
void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, color, color, id); }
|
||||
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); }
|
||||
void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); }
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
|
||||
void updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color);
|
||||
void updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color);
|
||||
void updateVertices(int id, const QVector<glm::vec3>& points, const QVector<glm::vec2>& texCoords, const glm::vec4& color);
|
||||
void renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id);
|
||||
void renderVertices(gpu::Primitive primitiveType, int id);
|
||||
|
||||
/// Loads geometry from the specified URL.
|
||||
|
|
|
@ -9,14 +9,12 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include <gpu/Batch.h>
|
||||
#include <gpu/GLBackend.h>
|
||||
#include <gpu/GPUConfig.h>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QGLWidget>
|
||||
#include <QNetworkReply>
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QResizeEvent>
|
||||
#include <QPainter>
|
||||
#include <QRunnable>
|
||||
#include <QThreadPool>
|
||||
#include <qimagereader.h>
|
||||
|
@ -27,7 +25,6 @@
|
|||
#include "RenderUtilsLogging.h"
|
||||
#include "TextureCache.h"
|
||||
|
||||
#include "gpu/GLBackend.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
|
@ -247,6 +244,12 @@ GLuint TextureCache::getPrimarySpecularTextureID() {
|
|||
}
|
||||
|
||||
void TextureCache::setPrimaryDrawBuffers(bool color, bool normal, bool specular) {
|
||||
gpu::Batch batch;
|
||||
setPrimaryDrawBuffers(batch, color, normal, specular);
|
||||
gpu::GLBackend::renderBatch(batch);
|
||||
}
|
||||
|
||||
void TextureCache::setPrimaryDrawBuffers(gpu::Batch& batch, bool color, bool normal, bool specular) {
|
||||
GLenum buffers[3];
|
||||
int bufferCount = 0;
|
||||
if (color) {
|
||||
|
@ -258,7 +261,7 @@ void TextureCache::setPrimaryDrawBuffers(bool color, bool normal, bool specular)
|
|||
if (specular) {
|
||||
buffers[bufferCount++] = GL_COLOR_ATTACHMENT2;
|
||||
}
|
||||
glDrawBuffers(bufferCount, buffers);
|
||||
batch._glDrawBuffers(bufferCount, buffers);
|
||||
}
|
||||
|
||||
gpu::FramebufferPointer TextureCache::getSecondaryFramebuffer() {
|
||||
|
|
|
@ -20,11 +20,14 @@
|
|||
|
||||
#include <QImage>
|
||||
#include <QMap>
|
||||
#include <QGLWidget>
|
||||
#include <QColor>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <ResourceCache.h>
|
||||
|
||||
namespace gpu {
|
||||
class Batch;
|
||||
}
|
||||
class NetworkTexture;
|
||||
|
||||
typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
||||
|
@ -80,6 +83,7 @@ public:
|
|||
|
||||
/// Enables or disables draw buffers on the primary framebuffer. Note: the primary framebuffer must be bound.
|
||||
void setPrimaryDrawBuffers(bool color, bool normal = false, bool specular = false);
|
||||
void setPrimaryDrawBuffers(gpu::Batch& batch, bool color, bool normal = false, bool specular = false);
|
||||
|
||||
/// Returns a pointer to the secondary framebuffer object, used as an additional render target when performing full
|
||||
/// screen effects.
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
class ViewFrustum;
|
||||
class OctreeRenderer;
|
||||
namespace gpu {
|
||||
class Batch;
|
||||
}
|
||||
|
||||
class RenderArgs {
|
||||
public:
|
||||
|
@ -34,6 +37,7 @@ public:
|
|||
RenderMode renderMode = DEFAULT_RENDER_MODE,
|
||||
RenderSide renderSide = MONO,
|
||||
DebugFlags debugFlags = RENDER_DEBUG_NONE,
|
||||
gpu::Batch* batch = nullptr,
|
||||
|
||||
int elementsTouched = 0,
|
||||
int itemsRendered = 0,
|
||||
|
@ -58,6 +62,7 @@ public:
|
|||
_renderMode(renderMode),
|
||||
_renderSide(renderSide),
|
||||
_debugFlags(debugFlags),
|
||||
_batch(batch),
|
||||
|
||||
_elementsTouched(elementsTouched),
|
||||
_itemsRendered(itemsRendered),
|
||||
|
@ -84,6 +89,7 @@ public:
|
|||
RenderMode _renderMode;
|
||||
RenderSide _renderSide;
|
||||
DebugFlags _debugFlags;
|
||||
gpu::Batch* _batch;
|
||||
|
||||
int _elementsTouched;
|
||||
int _itemsRendered;
|
||||
|
|
|
@ -34,7 +34,14 @@ public:
|
|||
Transform() :
|
||||
_rotation(1.0f, 0, 0, 0),
|
||||
_scale(1.0f),
|
||||
_translation(0),
|
||||
_translation(0.0f),
|
||||
_flags(FLAG_CACHE_INVALID_BITSET) // invalid cache
|
||||
{
|
||||
}
|
||||
Transform(Quat rotation, Vec3 scale, Vec3 translation) :
|
||||
_rotation(rotation),
|
||||
_scale(scale),
|
||||
_translation(translation),
|
||||
_flags(FLAG_CACHE_INVALID_BITSET) // invalid cache
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue