mirror of
https://github.com/overte-org/overte.git
synced 2025-04-17 23:09:11 +02:00
fix procedural applying to other things
This commit is contained in:
parent
eb26d9b4e3
commit
b6cb1fcfe7
4 changed files with 34 additions and 5 deletions
|
@ -1442,6 +1442,31 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
|||
emit requestRenderUpdate();
|
||||
}
|
||||
|
||||
if (!_allProceduralMaterialsLoaded) {
|
||||
std::lock_guard<std::mutex> lock(_materialsLock);
|
||||
bool allProceduralMaterialsLoaded = true;
|
||||
for (auto& shapeMaterialPair : _materials) {
|
||||
auto material = shapeMaterialPair.second;
|
||||
while (!material.empty()) {
|
||||
auto mat = material.top();
|
||||
if (mat.material && mat.material->isProcedural() && !mat.material->isReady()) {
|
||||
allProceduralMaterialsLoaded = false;
|
||||
break;
|
||||
}
|
||||
material.pop();
|
||||
}
|
||||
if (!allProceduralMaterialsLoaded) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allProceduralMaterialsLoaded) {
|
||||
emit requestRenderUpdate();
|
||||
} else {
|
||||
_allProceduralMaterialsLoaded = true;
|
||||
model->setRenderItemsNeedUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// When the individual mesh parts of a model finish fading, they will mark their Model as needing updating
|
||||
// we will watch for that and ask the model to update it's render items
|
||||
if (model->getRenderItemsNeedUpdate()) {
|
||||
|
@ -1559,6 +1584,10 @@ void ModelEntityRenderer::addMaterial(graphics::MaterialLayer material, const st
|
|||
if (_model && _model->fetchRenderItemIDs().size() > 0) {
|
||||
_model->addMaterial(material, parentMaterialName);
|
||||
}
|
||||
if (material.material && material.material->isProcedural()) {
|
||||
_allProceduralMaterialsLoaded = false;
|
||||
emit requestRenderUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void ModelEntityRenderer::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) {
|
||||
|
|
|
@ -198,6 +198,7 @@ private:
|
|||
bool _prevModelLoaded { false };
|
||||
|
||||
void processMaterials();
|
||||
bool _allProceduralMaterialsLoaded { false };
|
||||
};
|
||||
|
||||
} } // namespace
|
||||
|
|
|
@ -32,7 +32,7 @@ bool ShapeEntityRenderer::needsRenderUpdate() const {
|
|||
if (resultWithReadLock<bool>([&] {
|
||||
auto mat = _materials.find("0");
|
||||
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() &&
|
||||
mat->second.top().material->isEnabled()) {
|
||||
mat->second.top().material->isReady()) {
|
||||
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
||||
if (procedural->isFading()) {
|
||||
return true;
|
||||
|
@ -88,7 +88,7 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
|||
void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||
withReadLock([&] {
|
||||
auto mat = _materials.find("0");
|
||||
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() && mat->second.top().material->isEnabled()) {
|
||||
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() && mat->second.top().material->isReady()) {
|
||||
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
||||
if (procedural->isFading()) {
|
||||
procedural->setIsFading(Interpolate::calculateFadeRatio(procedural->getFadeStartTime()) < 1.0f);
|
||||
|
@ -136,7 +136,7 @@ bool ShapeEntityRenderer::isTransparent() const {
|
|||
|
||||
auto mat = _materials.find("0");
|
||||
if (mat != _materials.end() && mat->second.top().material) {
|
||||
if (mat->second.top().material->isProcedural() && mat->second.top().material->isEnabled()) {
|
||||
if (mat->second.top().material->isProcedural() && mat->second.top().material->isReady()) {
|
||||
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
||||
if (procedural->isFading()) {
|
||||
return true;
|
||||
|
|
|
@ -493,8 +493,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
|||
batch.setDrawcallUniform(drawcallInfo);
|
||||
}
|
||||
|
||||
if (!_drawMaterials.empty() && _drawMaterials.top().material && _drawMaterials.top().material->isProcedural() &&
|
||||
_drawMaterials.top().material->isReady()) {
|
||||
if (_shapeKey.hasOwnPipeline()) {
|
||||
if (!(enableMaterialProceduralShaders)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue