code format

This commit is contained in:
2022-12-14 14:14:44 +03:00
parent 1dfca0aeab
commit cb944b62e4
85 changed files with 4451 additions and 3744 deletions

View File

@@ -1,48 +1,47 @@
/*
QGL Material
Ivan Pelipenko peri4ko@yandex.ru
QGL Material
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gltypes.h"
#include "gltexture_manager.h"
#include "gltypes.h"
#include "qglview.h"
using namespace QGLEngineShaders;
Map::Map() {
bitmap_id = 0;
bitmap_id = 0;
color_amount = 1.f;
color_offset = 0.f;
bitmap_scale = QPointF(1., 1.);
use_bitmap = false;
_changed = true;
_layer = 0;
use_bitmap = false;
_changed = true;
_layer = 0;
}
void Map::setBitmapPath(const QString & p) {
bitmap_path = p;
_changed = true;
_changed = true;
}
void Map::load(TextureManager * tm) {
if (bitmap_id == 0)
bitmap_id = tm->loadTexture(bitmap_path, true, _type == mtNormal);
if (bitmap_id == 0) bitmap_id = tm->loadTexture(bitmap_path, true, _type == mtNormal);
}
@@ -60,21 +59,19 @@ void Map::copyToQGLMap(QGLMap & m) const {
}
Material::Material(const QString _name) {
setTypes();
name = _name;
color_diffuse = Qt::white;
name = _name;
color_diffuse = Qt::white;
color_emission = Qt::black;
glass = false;
glass = false;
transparency = reflectivity = 0.f;
map_roughness.color_amount = 0.75f;
map_metalness.color_amount = 0.25f;
iof = 1.f;
dispersion = 0.05f;
_changed = true;
_index = 0;
map_roughness.color_amount = 0.75f;
map_metalness.color_amount = 0.25f;
iof = 1.f;
dispersion = 0.05f;
_changed = true;
_index = 0;
}
@@ -89,63 +86,59 @@ bool Material::hasTransparency() const {
bool Material::isMapsChanged() const {
return map_diffuse ._changed ||
map_normal ._changed ||
map_metalness._changed ||
map_roughness._changed ||
map_emission ._changed ||
map_relief ._changed;
return map_diffuse._changed || map_normal._changed || map_metalness._changed || map_roughness._changed || map_emission._changed ||
map_relief._changed;
}
bool Material::isMapChanged(int type) const {
switch (type) {
case mtDiffuse : return map_diffuse ._changed;
case mtNormal : return map_normal ._changed;
case mtDiffuse: return map_diffuse._changed;
case mtNormal: return map_normal._changed;
case mtMetalness: return map_metalness._changed;
case mtRoughness: return map_roughness._changed;
case mtEmission : return map_emission ._changed;
case mtRelief : return map_relief ._changed;
case mtEmission: return map_emission._changed;
case mtRelief: return map_relief._changed;
}
return false;
}
void Material::load(TextureManager * tm) {
map_diffuse .load(tm);
map_normal .load(tm);
map_diffuse.load(tm);
map_normal.load(tm);
map_metalness.load(tm);
map_roughness.load(tm);
map_emission .load(tm);
map_relief .load(tm);
map_emission.load(tm);
map_relief.load(tm);
}
void Material::setMapsChanged() {
map_diffuse ._changed = true;
map_normal ._changed = true;
map_diffuse._changed = true;
map_normal._changed = true;
map_metalness._changed = true;
map_roughness._changed = true;
map_emission ._changed = true;
map_relief ._changed = true;
map_emission._changed = true;
map_relief._changed = true;
}
void Material::setTypes() {
map_diffuse ._type = mtDiffuse ;
map_normal ._type = mtNormal ;
map_diffuse._type = mtDiffuse;
map_normal._type = mtNormal;
map_metalness._type = mtMetalness;
map_roughness._type = mtRoughness;
map_emission ._type = mtEmission ;
map_relief ._type = mtRelief ;
map_emission._type = mtEmission;
map_relief._type = mtRelief;
}
void Material::detectMaps() {
map_diffuse .use_bitmap = !map_diffuse .bitmap_path.isEmpty();
map_normal .use_bitmap = !map_normal .bitmap_path.isEmpty();
map_diffuse.use_bitmap = !map_diffuse.bitmap_path.isEmpty();
map_normal.use_bitmap = !map_normal.bitmap_path.isEmpty();
map_metalness.use_bitmap = !map_metalness.bitmap_path.isEmpty();
map_roughness.use_bitmap = !map_roughness.bitmap_path.isEmpty();
map_emission .use_bitmap = !map_emission .bitmap_path.isEmpty();
map_relief .use_bitmap = !map_relief .bitmap_path.isEmpty();
map_emission.use_bitmap = !map_emission.bitmap_path.isEmpty();
map_relief.use_bitmap = !map_relief.bitmap_path.isEmpty();
}