mirror of
https://github.com/overte-org/overte.git
synced 2025-04-18 00:26:33 +02:00
Merge pull request #14993 from SamGondelman/untexture
Case 21071: Handle models with no materials
This commit is contained in:
commit
92168f60c6
4 changed files with 11 additions and 18 deletions
|
@ -53,7 +53,7 @@ bool ShapeEntityRenderer::needsRenderUpdate() const {
|
|||
}
|
||||
|
||||
auto mat = _materials.find("0");
|
||||
if (mat != _materials.end() && (mat->second.needsUpdate() || mat->second.areTexturesLoading())) {
|
||||
if (mat != _materials.end() && mat->second.shouldUpdate()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ bool ShapeEntityRenderer::useMaterialPipeline(const graphics::MultiMaterial& mat
|
|||
|
||||
ShapeKey ShapeEntityRenderer::getShapeKey() {
|
||||
auto mat = _materials.find("0");
|
||||
if (mat != _materials.end() && (mat->second.needsUpdate() || mat->second.areTexturesLoading())) {
|
||||
if (mat != _materials.end() && mat->second.shouldUpdate()) {
|
||||
RenderPipelines::updateMultiMaterial(mat->second);
|
||||
}
|
||||
|
||||
|
|
|
@ -456,11 +456,11 @@ public:
|
|||
graphics::MaterialKey getMaterialKey() const { return graphics::MaterialKey(_schemaBuffer.get<graphics::MultiMaterial::Schema>()._key); }
|
||||
const gpu::TextureTablePointer& getTextureTable() const { return _textureTable; }
|
||||
|
||||
bool needsUpdate() const { return _needsUpdate; }
|
||||
void setNeedsUpdate(bool needsUpdate) { _needsUpdate = needsUpdate; }
|
||||
|
||||
void setTexturesLoading(bool value) { _texturesLoading = value; }
|
||||
bool areTexturesLoading() const { return _texturesLoading; }
|
||||
void setInitialized() { _initialized = true; }
|
||||
|
||||
bool shouldUpdate() const { return !_initialized || _needsUpdate || _texturesLoading; }
|
||||
|
||||
int getTextureCount() const { calculateMaterialInfo(); return _textureCount; }
|
||||
size_t getTextureSize() const { calculateMaterialInfo(); return _textureSize; }
|
||||
|
@ -471,6 +471,7 @@ private:
|
|||
gpu::TextureTablePointer _textureTable { std::make_shared<gpu::TextureTable>() };
|
||||
bool _needsUpdate { false };
|
||||
bool _texturesLoading { false };
|
||||
bool _initialized { false };
|
||||
|
||||
mutable size_t _textureSize { 0 };
|
||||
mutable int _textureCount { 0 };
|
||||
|
|
|
@ -83,7 +83,7 @@ void MeshPartPayload::updateKey(const render::ItemKey& key) {
|
|||
ItemKey::Builder builder(key);
|
||||
builder.withTypeShape();
|
||||
|
||||
if (_drawMaterials.needsUpdate() || _drawMaterials.areTexturesLoading()) {
|
||||
if (_drawMaterials.shouldUpdate()) {
|
||||
RenderPipelines::updateMultiMaterial(_drawMaterials);
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ void ModelMeshPartPayload::updateKey(const render::ItemKey& key) {
|
|||
builder.withDeformed();
|
||||
}
|
||||
|
||||
if (_drawMaterials.needsUpdate() || _drawMaterials.areTexturesLoading()) {
|
||||
if (_drawMaterials.shouldUpdate()) {
|
||||
RenderPipelines::updateMultiMaterial(_drawMaterials);
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, PrimitiveMode pr
|
|||
return;
|
||||
}
|
||||
|
||||
if (_drawMaterials.needsUpdate() || _drawMaterials.areTexturesLoading()) {
|
||||
if (_drawMaterials.shouldUpdate()) {
|
||||
RenderPipelines::updateMultiMaterial(_drawMaterials);
|
||||
}
|
||||
|
||||
|
|
|
@ -382,11 +382,6 @@ void RenderPipelines::bindMaterial(graphics::MaterialPointer& material, gpu::Bat
|
|||
void RenderPipelines::updateMultiMaterial(graphics::MultiMaterial& multiMaterial) {
|
||||
auto& schemaBuffer = multiMaterial.getSchemaBuffer();
|
||||
|
||||
if (multiMaterial.size() == 0) {
|
||||
schemaBuffer.edit<graphics::MultiMaterial::Schema>() = graphics::MultiMaterial::Schema();
|
||||
return;
|
||||
}
|
||||
|
||||
auto& drawMaterialTextures = multiMaterial.getTextureTable();
|
||||
multiMaterial.setTexturesLoading(false);
|
||||
|
||||
|
@ -732,14 +727,11 @@ void RenderPipelines::updateMultiMaterial(graphics::MultiMaterial& multiMaterial
|
|||
schema._key = (uint32_t)schemaKey._flags.to_ulong();
|
||||
schemaBuffer.edit<graphics::MultiMaterial::Schema>() = schema;
|
||||
multiMaterial.setNeedsUpdate(false);
|
||||
multiMaterial.setInitialized();
|
||||
}
|
||||
|
||||
void RenderPipelines::bindMaterials(graphics::MultiMaterial& multiMaterial, gpu::Batch& batch, bool enableTextures) {
|
||||
if (multiMaterial.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (multiMaterial.needsUpdate() || multiMaterial.areTexturesLoading()) {
|
||||
if (multiMaterial.shouldUpdate()) {
|
||||
updateMultiMaterial(multiMaterial);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue