Drawable Renderer (#1570), [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
committed by
Bart Louwers
parent
fffbfcfbb5
commit
89d3a7bae9
@@ -193,11 +193,17 @@ public:
|
||||
/// Do something with each attribute
|
||||
void observeAttributes(const std::function<void(const std::string&, VertexAttribute&)>& f) {
|
||||
std::for_each(attrs.begin(), attrs.end(), [&](const auto& kv) {
|
||||
if (kv.second) { f(kv.first, *kv.second); }});
|
||||
if (kv.second) {
|
||||
f(kv.first, *kv.second);
|
||||
}
|
||||
});
|
||||
}
|
||||
void observeAttributes(const std::function<void(const std::string&, const VertexAttribute&)>& f) const {
|
||||
std::for_each(attrs.begin(), attrs.end(), [&](const auto& kv) {
|
||||
if (kv.second) { f(kv.first, *kv.second); }});
|
||||
if (kv.second) {
|
||||
f(kv.first, *kv.second);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
using ResolveDelegate =
|
||||
@@ -227,7 +233,7 @@ protected:
|
||||
AttributeDataType dataType,
|
||||
int size,
|
||||
std::size_t count) const {
|
||||
return std::make_unique<VertexAttribute>(index, dataType, size, count, size*count);
|
||||
return std::make_unique<VertexAttribute>(index, dataType, size, count, size * count);
|
||||
}
|
||||
virtual std::unique_ptr<VertexAttribute> copy(const gfx::VertexAttribute& attr) const {
|
||||
return std::make_unique<VertexAttribute>(attr);
|
||||
|
||||
@@ -38,9 +38,8 @@ void DrawableBuilder::flush() {
|
||||
draw->setShader(shader);
|
||||
draw->setMatrix(matrix);
|
||||
draw->addTweakers(tweakers.begin(), tweakers.end());
|
||||
|
||||
if (auto drawAttrs = getVertexAttributes().clone()) {
|
||||
|
||||
if (auto drawAttrs = getVertexAttributes().clone()) {
|
||||
vertexAttrs.observeAttributes([&](const std::string& iName, const VertexAttribute& iAttr) {
|
||||
if (auto& drawAttr = drawAttrs->getOrAdd(iName)) {
|
||||
for (std::size_t i = 0; i < impl->vertices.elements(); ++i) {
|
||||
|
||||
@@ -28,7 +28,7 @@ void DrawableGLBuilder::init() {
|
||||
if (impl->colors.size() > 1 && impl->colors.size() != impl->vertices.elements()) {
|
||||
impl->colors.clear();
|
||||
}
|
||||
|
||||
|
||||
if (impl->colors.empty()) {
|
||||
colorAttr->set(0, DrawableGL::colorAttrValue(getColor()));
|
||||
} else {
|
||||
|
||||
@@ -343,7 +343,7 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
|
||||
const auto evalColor = evaluated.get<FillColor>().constantOr(Color());
|
||||
const auto fillOpacity = evaluated.get<FillOpacity>().constantOr(1);
|
||||
//const auto fillColor = evalColor * (fillOpacity > 0.0f ? fillOpacity : 1.0f);
|
||||
// const auto fillColor = evalColor * (fillOpacity > 0.0f ? fillOpacity : 1.0f);
|
||||
|
||||
const auto fillRenderPass = (evalColor.a >= 1.0f && fillOpacity >= 1.0f
|
||||
/* && parameters.currentLayer >= parameters.opaquePassCutoff*/)
|
||||
@@ -360,19 +360,19 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
attr->set(0, util::cast<float>(evalColor.toArray()));
|
||||
}
|
||||
if (auto& attr = vertexAttrs.getOrAdd("a_opacity")) {
|
||||
attr->set<gfx::VertexAttribute::float2>(0, { fillOpacity, fillOpacity });
|
||||
attr->set<gfx::VertexAttribute::float2>(0, {fillOpacity, fillOpacity});
|
||||
}
|
||||
|
||||
if (evaluatedPropertiesChange) {
|
||||
//FillLayerUBO fillLayerUBO;
|
||||
//fillLayerUBO.color = evaluated.get<FillColor>();
|
||||
//fillLayerUBO.opacity = evaluated.get<FillOpacity>();
|
||||
//uniformBuffer = context.createUniformBuffer(&fillLayerUBO, sizeof(fillLayerUBO));
|
||||
// FillLayerUBO fillLayerUBO;
|
||||
// fillLayerUBO.color = evaluated.get<FillColor>();
|
||||
// fillLayerUBO.opacity = evaluated.get<FillOpacity>();
|
||||
// uniformBuffer = context.createUniformBuffer(&fillLayerUBO, sizeof(fillLayerUBO));
|
||||
evaluatedPropertiesChange = false;
|
||||
}
|
||||
|
||||
if (tileDrawable) {
|
||||
//tileDrawable->mutableUniformBuffers().addOrReplace("FillLayerUBO", uniformBuffer);
|
||||
// tileDrawable->mutableUniformBuffers().addOrReplace("FillLayerUBO", uniformBuffer);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
if (!newDrawables.empty()) {
|
||||
auto& drawable = newDrawables[0];
|
||||
drawable->setTileID(tileID);
|
||||
//drawable->mutableUniformBuffers().addOrReplace("FillLayerUBO", uniformBuffer);
|
||||
// drawable->mutableUniformBuffers().addOrReplace("FillLayerUBO", uniformBuffer);
|
||||
|
||||
// Track it.
|
||||
tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||
|
||||
Reference in New Issue
Block a user