3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 00:55:42 +02:00

More metavoxel bits.

This commit is contained in:
Andrzej Kapolka 2013-12-11 18:00:17 -08:00
parent dce9599201
commit 5ec9017d3b
8 changed files with 58 additions and 14 deletions

View file

@ -2320,6 +2320,15 @@ void Application::updateParticles(float deltaTime) {
}
}
void Application::updateMetavoxels(float deltaTime) {
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateMetavoxels()");
if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {
_metavoxels.simulate(deltaTime);
}
}
void Application::updateTransmitter(float deltaTime) {
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateTransmitter()");
@ -2465,6 +2474,7 @@ void Application::update(float deltaTime) {
updateAvatars(deltaTime, mouseRayOrigin, mouseRayDirection); //loop through all the other avatars and simulate them...
updateMyAvatarSimulation(deltaTime); // Simulate myself
updateParticles(deltaTime); // Simulate particle cloud movements
updateMetavoxels(deltaTime); // update metavoxels
updateTransmitter(deltaTime); // transmitter drive or pick
updateCamera(deltaTime); // handle various camera tweaks like off axis projection
updateDialogs(deltaTime); // update various stats dialogs if present
@ -2999,7 +3009,14 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
_voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
}
}
// also, metavoxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... metavoxels...");
_metavoxels.render();
}
// render the ambient occlusion effect if enabled
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),

View file

@ -269,6 +269,7 @@ private:
void updateThreads(float deltaTime);
void updateMyAvatarSimulation(float deltaTime);
void updateParticles(float deltaTime);
void updateMetavoxels(float deltaTime);
void updateTransmitter(float deltaTime);
void updateCamera(float deltaTime);
void updateDialogs(float deltaTime);

View file

@ -281,7 +281,8 @@ Menu::Menu() :
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ParticleCloud, 0, false);
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Shadows, 0, false);
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, false);
QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options");

View file

@ -209,6 +209,7 @@ namespace MenuOption {
const QString Login = "Login";
const QString LookAtIndicator = "Look-at Indicator";
const QString LookAtVectors = "Look-at Vectors";
const QString Metavoxels = "Metavoxels";
const QString Mirror = "Mirror";
const QString MoveWithLean = "Move with Lean";
const QString NewVoxelCullingMode = "New Voxel Culling Mode";

View file

@ -10,16 +10,16 @@
#include "MetavoxelSystem.h"
class DebugVisitor : public MetavoxelVisitor {
class PointVisitor : public MetavoxelVisitor {
public:
virtual bool visit(const MetavoxelInfo& info);
};
bool DebugVisitor::visit(const MetavoxelInfo& info) {
bool PointVisitor::visit(const MetavoxelInfo& info) {
QRgb color = info.attributeValues.at(0).getInlineValue<QRgb>();
qDebug("%g %g %g %g %d %d %d %d\n", info.minimum.x, info.minimum.y, info.minimum.z, info.size,
qRed(color), qGreen(color), qBlue(color), qAlpha(color));
QRgb normal = info.attributeValues.at(1).getInlineValue<QRgb>();
return true;
}
@ -29,12 +29,20 @@ void MetavoxelSystem::init() {
p1 += 1;
p1 += 2;
AttributePointer diffuseColor = AttributeRegistry::getInstance()->getAttribute("diffuseColor");
AttributePointer color = AttributeRegistry::getInstance()->getAttribute("color");
void* white = encodeInline(qRgba(0xFF, 0xFF, 0xFF, 0xFF));
_data.setAttributeValue(p1, AttributeValue(diffuseColor, &white));
DebugVisitor visitor;
_data.visitVoxels(QVector<AttributePointer>() << diffuseColor, visitor);
_data.setAttributeValue(p1, AttributeValue(color, &white));
}
void MetavoxelSystem::simulate(float deltaTime) {
QVector<AttributePointer> attributes;
attributes << AttributeRegistry::getInstance()->getColorAttribute();
attributes << AttributeRegistry::getInstance()->getNormalAttribute();
PointVisitor visitor;
_data.visitVoxels(attributes, visitor);
}
void MetavoxelSystem::render() {
}

View file

@ -17,6 +17,9 @@ public:
void init();
void simulate(float deltaTime);
void render();
private:
MetavoxelData _data;

View file

@ -10,8 +10,9 @@
AttributeRegistry AttributeRegistry::_instance;
AttributeRegistry::AttributeRegistry() {
registerAttribute(AttributePointer(new QRgbAttribute("diffuseColor")));
AttributeRegistry::AttributeRegistry() :
_colorAttribute(registerAttribute(new QRgbAttribute("color"))),
_normalAttribute(registerAttribute(new QRgbAttribute("normal"))) {
}
AttributePointer AttributeRegistry::registerAttribute(AttributePointer attribute) {
@ -91,7 +92,6 @@ void* QRgbAttribute::createAveraged(void* values[]) const {
totalBlue += qBlue(value);
totalAlpha += qAlpha(value);
}
const int SHIFT_FACTOR = 3;
return encodeInline(qRgba(totalRed / AVERAGE_COUNT, totalGreen / AVERAGE_COUNT,
totalBlue / AVERAGE_COUNT, totalAlpha / AVERAGE_COUNT));
}

View file

@ -29,6 +29,11 @@ public:
AttributeRegistry();
/// Registers an attribute with the system. The registry assumes ownership of the object.
/// \return either the pointer passed as an argument, if the attribute wasn't already registered, or the existing
/// attribute
AttributePointer registerAttribute(Attribute* attribute) { return registerAttribute(AttributePointer(attribute)); }
/// Registers an attribute with the system.
/// \return either the pointer passed as an argument, if the attribute wasn't already registered, or the existing
/// attribute
@ -37,11 +42,19 @@ public:
/// Retrieves an attribute by name.
AttributePointer getAttribute(const QString& name) const { return _attributes.value(name); }
/// Returns a reference to the standard QRgb "color" attribute.
const AttributePointer& getColorAttribute() const { return _colorAttribute; }
/// Returns a reference to the standard QRgb "normal" attribute.
const AttributePointer& getNormalAttribute() const { return _normalAttribute; }
private:
static AttributeRegistry _instance;
QHash<QString, AttributePointer> _attributes;
AttributePointer _colorAttribute;
AttributePointer _normalAttribute;
};
/// Converts a value to a void pointer.