mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 21:30:33 +02:00
Make sure edit colors are either 100% opaque or 100% transparent.
This commit is contained in:
parent
b278857091
commit
98c51f87d2
1 changed files with 20 additions and 4 deletions
|
@ -1251,8 +1251,11 @@ QColor VoxelColorBoxTool::getColor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelColorBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& maximum) {
|
void VoxelColorBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& maximum) {
|
||||||
|
// ensure that color is either 100% transparent or 100% opaque
|
||||||
|
QColor color = _color->getColor();
|
||||||
|
color.setAlphaF(color.alphaF() > 0.5f ? 1.0f : 0.0f);
|
||||||
MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorBoxEdit(Box(minimum, maximum),
|
MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorBoxEdit(Box(minimum, maximum),
|
||||||
_editor->getGridSpacing(), _color->getColor())) };
|
_editor->getGridSpacing(), color)) };
|
||||||
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,8 +1282,13 @@ QColor VoxelMaterialBoxTool::getColor() {
|
||||||
void VoxelMaterialBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& maximum) {
|
void VoxelMaterialBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& maximum) {
|
||||||
SharedObjectPointer material = _materialEditor->getObject();
|
SharedObjectPointer material = _materialEditor->getObject();
|
||||||
_materialEditor->detachObject();
|
_materialEditor->detachObject();
|
||||||
|
QColor color;
|
||||||
|
if (_texture) {
|
||||||
|
color = _texture->getAverageColor();
|
||||||
|
color.setAlphaF(1.0f);
|
||||||
|
}
|
||||||
MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialBoxEdit(Box(minimum, maximum),
|
MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialBoxEdit(Box(minimum, maximum),
|
||||||
_editor->getGridSpacing(), material, _texture ? _texture->getAverageColor() : QColor())) };
|
_editor->getGridSpacing(), material, color)) };
|
||||||
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1363,8 +1371,11 @@ QColor VoxelColorSphereTool::getColor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelColorSphereTool::applyValue(const glm::vec3& position, float radius) {
|
void VoxelColorSphereTool::applyValue(const glm::vec3& position, float radius) {
|
||||||
|
// ensure that color is either 100% transparent or 100% opaque
|
||||||
|
QColor color = _color->getColor();
|
||||||
|
color.setAlphaF(color.alphaF() > 0.5f ? 1.0f : 0.0f);
|
||||||
MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorSphereEdit(position, radius,
|
MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorSphereEdit(position, radius,
|
||||||
_editor->getGridSpacing(), _color->getColor())) };
|
_editor->getGridSpacing(), color)) };
|
||||||
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1386,8 +1397,13 @@ QColor VoxelMaterialSphereTool::getColor() {
|
||||||
void VoxelMaterialSphereTool::applyValue(const glm::vec3& position, float radius) {
|
void VoxelMaterialSphereTool::applyValue(const glm::vec3& position, float radius) {
|
||||||
SharedObjectPointer material = _materialEditor->getObject();
|
SharedObjectPointer material = _materialEditor->getObject();
|
||||||
_materialEditor->detachObject();
|
_materialEditor->detachObject();
|
||||||
|
QColor color;
|
||||||
|
if (_texture) {
|
||||||
|
color = _texture->getAverageColor();
|
||||||
|
color.setAlphaF(1.0f);
|
||||||
|
}
|
||||||
MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialSphereEdit(position, radius,
|
MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialSphereEdit(position, radius,
|
||||||
_editor->getGridSpacing(), material, _texture ? _texture->getAverageColor() : QColor())) };
|
_editor->getGridSpacing(), material, color)) };
|
||||||
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue