fixed VPL preview crash with the deformable shape

metadata
Wenzel Jakob 2014-05-20 01:42:09 +02:00
parent c9afd23278
commit f120f9955c
1 changed files with 20 additions and 8 deletions

View File

@ -107,12 +107,19 @@ void VPLShaderManager::setScene(const Scene *scene) {
shape = instantiatedShapes[j]; shape = instantiatedShapes[j];
if (!m_renderer->unregisterGeometry(shape)) if (!m_renderer->unregisterGeometry(shape))
continue; continue;
m_renderer->unregisterShaderForResource(shape->getBSDF()); const BSDF *bsdf = shape->getBSDF();
if (!bsdf)
bsdf = const_cast<Shape *>(shape)->createTriMesh()->getBSDF();
m_renderer->unregisterShaderForResource(bsdf);
} }
} else { } else {
const BSDF *bsdf = shape->getBSDF();
if (!bsdf)
bsdf = const_cast<Shape *>(shape)->createTriMesh()->getBSDF();
if (!m_renderer->unregisterGeometry(shape)) if (!m_renderer->unregisterGeometry(shape))
continue; continue;
m_renderer->unregisterShaderForResource(shape->getBSDF()); m_renderer->unregisterShaderForResource(bsdf);
} }
} }
@ -168,9 +175,13 @@ void VPLShaderManager::setScene(const Scene *scene) {
if (!gpuGeo) if (!gpuGeo)
continue; continue;
Shader *shader = m_renderer->registerShaderForResource(shape->getBSDF()); const BSDF *bsdf = shape->getBSDF();
if (!bsdf)
bsdf = gpuGeo->getTriMesh()->getBSDF();
Shader *shader = m_renderer->registerShaderForResource(bsdf);
if (shader && !shader->isComplete()) { if (shader && !shader->isComplete()) {
m_renderer->unregisterShaderForResource(shape->getBSDF()); m_renderer->unregisterShaderForResource(bsdf);
shader = NULL; shader = NULL;
} }
@ -192,13 +203,14 @@ void VPLShaderManager::setScene(const Scene *scene) {
GPUGeometry *gpuGeo = m_renderer->registerGeometry(shape); GPUGeometry *gpuGeo = m_renderer->registerGeometry(shape);
if (!gpuGeo) if (!gpuGeo)
continue; continue;
const BSDF *bsdf = shape->getBSDF();
Shader *shader = m_renderer->registerShaderForResource(shape->getBSDF()); if (!bsdf)
bsdf = gpuGeo->getTriMesh()->getBSDF();
Shader *shader = m_renderer->registerShaderForResource(bsdf);
if (shader && !shader->isComplete()) { if (shader && !shader->isComplete()) {
m_renderer->unregisterShaderForResource(shape->getBSDF()); m_renderer->unregisterShaderForResource(bsdf);
shader = NULL; shader = NULL;
} }
gpuGeo->setShader(shader); gpuGeo->setShader(shader);
m_geometry.push_back(std::make_pair(gpuGeo, identityTrafo)); m_geometry.push_back(std::make_pair(gpuGeo, identityTrafo));