Merge pull request #3893 from ey6es/master

Fixes for erroneous download percentages (resources and metavoxels); warning fix, metavoxel edit fix.
This commit is contained in:
Philip Rosedale 2014-12-03 14:03:07 -08:00
commit 5c59fc786d
5 changed files with 17 additions and 9 deletions

View file

@ -1438,7 +1438,7 @@ void Audio::renderToolBox(int x, int y, bool boxed) {
static const float PULSE_MAX = 1.0f; static const float PULSE_MAX = 1.0f;
static const float PULSE_FREQUENCY = 1.0f; // in Hz static const float PULSE_FREQUENCY = 1.0f; // in Hz
qint64 now = usecTimestampNow(); qint64 now = usecTimestampNow();
if (now - _iconPulseTimeReference > USECS_PER_SECOND) { if (now - _iconPulseTimeReference > (qint64)USECS_PER_SECOND) {
// Prevents t from getting too big, which would diminish glm::cos precision // Prevents t from getting too big, which would diminish glm::cos precision
_iconPulseTimeReference = now - ((now - _iconPulseTimeReference) % USECS_PER_SECOND); _iconPulseTimeReference = now - ((now - _iconPulseTimeReference) % USECS_PER_SECOND);
} }

View file

@ -884,7 +884,8 @@ void ImportHeightfieldTool::updateSpanner() {
} }
HeightfieldBrushTool::HeightfieldBrushTool(MetavoxelEditor* editor, const QString& name) : HeightfieldBrushTool::HeightfieldBrushTool(MetavoxelEditor* editor, const QString& name) :
MetavoxelTool(editor, name, false) { MetavoxelTool(editor, name, false),
_positionValid(false) {
QWidget* widget = new QWidget(); QWidget* widget = new QWidget();
widget->setLayout(_form = new QFormLayout()); widget->setLayout(_form = new QFormLayout());
@ -911,8 +912,10 @@ void HeightfieldBrushTool::render() {
float distance; float distance;
if (!Application::getInstance()->getMetavoxels()->findFirstRayHeightfieldIntersection(origin, direction, distance)) { if (!Application::getInstance()->getMetavoxels()->findFirstRayHeightfieldIntersection(origin, direction, distance)) {
_positionValid = false;
return; return;
} }
_positionValid = true;
Application::getInstance()->getMetavoxels()->renderHeightfieldCursor( Application::getInstance()->getMetavoxels()->renderHeightfieldCursor(
_position = origin + distance * direction, _radius->value()); _position = origin + distance * direction, _radius->value());
} }
@ -924,7 +927,7 @@ bool HeightfieldBrushTool::eventFilter(QObject* watched, QEvent* event) {
_radius->setValue(_radius->value() * glm::pow(2.0f, angle * ANGLE_SCALE)); _radius->setValue(_radius->value() * glm::pow(2.0f, angle * ANGLE_SCALE));
return true; return true;
} else if (event->type() == QEvent::MouseButtonPress) { } else if (event->type() == QEvent::MouseButtonPress && _positionValid) {
MetavoxelEditMessage message = { createEdit(static_cast<QMouseEvent*>(event)->button() == Qt::RightButton) }; MetavoxelEditMessage message = { createEdit(static_cast<QMouseEvent*>(event)->button() == Qt::RightButton) };
Application::getInstance()->getMetavoxels()->applyEdit(message, true); Application::getInstance()->getMetavoxels()->applyEdit(message, true);
return true; return true;
@ -1103,7 +1106,8 @@ void VoxelMaterialSpannerTool::applyEdit(const AttributePointer& attribute, cons
} }
VoxelBrushTool::VoxelBrushTool(MetavoxelEditor* editor, const QString& name) : VoxelBrushTool::VoxelBrushTool(MetavoxelEditor* editor, const QString& name) :
MetavoxelTool(editor, name, false, true) { MetavoxelTool(editor, name, false, true),
_positionValid(false) {
QWidget* widget = new QWidget(); QWidget* widget = new QWidget();
widget->setLayout(_form = new QFormLayout()); widget->setLayout(_form = new QFormLayout());
@ -1132,8 +1136,10 @@ void VoxelBrushTool::render() {
if (!(Application::getInstance()->getMetavoxels()->findFirstRayHeightfieldIntersection( if (!(Application::getInstance()->getMetavoxels()->findFirstRayHeightfieldIntersection(
origin, direction, heightfieldDistance) | origin, direction, heightfieldDistance) |
Application::getInstance()->getMetavoxels()->findFirstRayVoxelIntersection(origin, direction, voxelDistance))) { Application::getInstance()->getMetavoxels()->findFirstRayVoxelIntersection(origin, direction, voxelDistance))) {
_positionValid = false;
return; return;
} }
_positionValid = true;
Application::getInstance()->getMetavoxels()->renderVoxelCursor( Application::getInstance()->getMetavoxels()->renderVoxelCursor(
_position = origin + qMin(heightfieldDistance, voxelDistance) * direction, _radius->value()); _position = origin + qMin(heightfieldDistance, voxelDistance) * direction, _radius->value());
} }
@ -1145,7 +1151,7 @@ bool VoxelBrushTool::eventFilter(QObject* watched, QEvent* event) {
_radius->setValue(_radius->value() * glm::pow(2.0f, angle * ANGLE_SCALE)); _radius->setValue(_radius->value() * glm::pow(2.0f, angle * ANGLE_SCALE));
return true; return true;
} else if (event->type() == QEvent::MouseButtonPress) { } else if (event->type() == QEvent::MouseButtonPress && _positionValid) {
MetavoxelEditMessage message = { createEdit(static_cast<QMouseEvent*>(event)->button() == Qt::RightButton) }; MetavoxelEditMessage message = { createEdit(static_cast<QMouseEvent*>(event)->button() == Qt::RightButton) };
Application::getInstance()->getMetavoxels()->applyEdit(message, true); Application::getInstance()->getMetavoxels()->applyEdit(message, true);
return true; return true;

View file

@ -326,6 +326,7 @@ protected:
QDoubleSpinBox* _radius; QDoubleSpinBox* _radius;
glm::vec3 _position; glm::vec3 _position;
bool _positionValid;
}; };
/// Allows raising or lowering parts of the heightfield. /// Allows raising or lowering parts of the heightfield.
@ -456,6 +457,7 @@ protected:
QDoubleSpinBox* _radius; QDoubleSpinBox* _radius;
glm::vec3 _position; glm::vec3 _position;
bool _positionValid;
}; };
/// Allows texturing parts of the voxel field. /// Allows texturing parts of the voxel field.

View file

@ -461,10 +461,10 @@ void Stats::display(
if (_metavoxelSendTotal > 0 || _metavoxelReceiveTotal > 0) { if (_metavoxelSendTotal > 0 || _metavoxelReceiveTotal > 0) {
stringstream reliableStats; stringstream reliableStats;
if (_metavoxelSendTotal > 0) { if (_metavoxelSendTotal > 0) {
reliableStats << "Upload: " << (_metavoxelSendProgress * 100 / _metavoxelSendTotal) << "% "; reliableStats << "Upload: " << (_metavoxelSendProgress * 100LL / _metavoxelSendTotal) << "% ";
} }
if (_metavoxelReceiveTotal > 0) { if (_metavoxelReceiveTotal > 0) {
reliableStats << "Download: " << (_metavoxelReceiveProgress * 100 / _metavoxelReceiveTotal) << "%"; reliableStats << "Download: " << (_metavoxelReceiveProgress * 100LL / _metavoxelReceiveTotal) << "%";
} }
verticalOffset += STATS_PELS_PER_LINE; verticalOffset += STATS_PELS_PER_LINE;
drawText(horizontalOffset, verticalOffset, scale, rotation, font, reliableStats.str().c_str(), color); drawText(horizontalOffset, verticalOffset, scale, rotation, font, reliableStats.str().c_str(), color);

View file

@ -109,11 +109,11 @@ public:
/// For loading resources, returns the number of bytes received. /// For loading resources, returns the number of bytes received.
qint64 getBytesReceived() const { return _bytesReceived; } qint64 getBytesReceived() const { return _bytesReceived; }
/// For loading resources, returns the number of total bytes (or zero if unknown). /// For loading resources, returns the number of total bytes (<= zero if unknown).
qint64 getBytesTotal() const { return _bytesTotal; } qint64 getBytesTotal() const { return _bytesTotal; }
/// For loading resources, returns the load progress. /// For loading resources, returns the load progress.
float getProgress() const { return (_bytesTotal == 0) ? 0.0f : (float)_bytesReceived / _bytesTotal; } float getProgress() const { return (_bytesTotal <= 0) ? 0.0f : (float)_bytesReceived / _bytesTotal; }
/// Refreshes the resource. /// Refreshes the resource.
void refresh(); void refresh();