Fix crash when using Filamat lite library (#1780)

This commit is contained in:
Ben Doherty
2019-10-15 10:49:59 -07:00
committed by GitHub
parent c33f6adf62
commit d0bc23473c
4 changed files with 15 additions and 0 deletions

View File

@@ -73,6 +73,13 @@ android {
}
}
// The filamat library has two variants: full and lite. Here we default to the "full" variant.
// Replace "full" with "lite" to use the filamat-lite variant, which has a smaller binary size
// but comes with certain restrictions. See "Filamat Lite" in libs/filamat/README.md.
defaultConfig {
missingDimensionStrategy 'functionality', 'full'
}
// We use the .filamat extension for materials compiled with matc
// Telling aapt to not compress them allows to load them efficiently
aaptOptions {

View File

@@ -212,6 +212,10 @@ class MainActivity : Activity() {
" material.clearCoat = 1.0;\n" +
"}\n")
// Turn off shader code optimization so this sample is compatible with the "lite"
// variant of the filamat library.
.optimization(MaterialBuilder.Optimization.NONE)
.build()
if (matPackage.isValid) {

View File

@@ -79,6 +79,10 @@ bool GLSLToolsLite::findProperties(
filament::backend::ShaderType type,
const utils::CString& material,
MaterialBuilder::PropertyList& properties) const noexcept {
if (material.empty()) {
return true;
}
const std::string shaderCode = stripComments(material.c_str());
size_t start = 0, end = 0;