mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:58:09 +02:00
Added check for nullptr in GLTFSerializer
This commit is contained in:
parent
8e51664b69
commit
7780095590
1 changed files with 9 additions and 5 deletions
|
@ -158,11 +158,15 @@ template<typename T> bool findPointerInArray(const T *pointer, const T *array, s
|
||||||
bool findAttribute(const QString &name, const cgltf_attribute *attributes, size_t numAttributes, size_t &index) {
|
bool findAttribute(const QString &name, const cgltf_attribute *attributes, size_t numAttributes, size_t &index) {
|
||||||
std::string nameString = name.toStdString();
|
std::string nameString = name.toStdString();
|
||||||
for (size_t i = 0; i < numAttributes; i++) {
|
for (size_t i = 0; i < numAttributes; i++) {
|
||||||
|
if (attributes->name == nullptr) {
|
||||||
|
qDebug(modelformat) << "GLTFSerializer: attribute with a null pointer name string";
|
||||||
|
} else {
|
||||||
if (strcmp(nameString.c_str(), attributes->name) == 0) {
|
if (strcmp(nameString.c_str(), attributes->name) == 0) {
|
||||||
index = i;
|
index = i;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,7 +1076,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
size_t normalAttributeIndex = 0;
|
size_t normalAttributeIndex = 0;
|
||||||
if (findAttribute("NORMAL", target.attributes, target.attributes_count, normalAttributeIndex)) {
|
if (findAttribute("NORMAL", target.attributes, target.attributes_count, normalAttributeIndex)) {
|
||||||
if (!generateTargetData(target.attributes[normalAttributeIndex].data, weight, normals)) {
|
if (!generateTargetData(target.attributes[normalAttributeIndex].data, weight, normals)) {
|
||||||
qWarning(modelformat) << "Invalid accessor type on generateTargetData vertices for model " << _url;
|
qWarning(modelformat) << "Invalid NORMAL accessor on generateTargetData vertices for model " << _url;
|
||||||
hfmModel.loadErrorCount++;
|
hfmModel.loadErrorCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1080,7 +1084,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
size_t positionAttributeIndex = 0;
|
size_t positionAttributeIndex = 0;
|
||||||
if (findAttribute("POSITION", target.attributes, target.attributes_count, positionAttributeIndex)) {
|
if (findAttribute("POSITION", target.attributes, target.attributes_count, positionAttributeIndex)) {
|
||||||
if (!generateTargetData(target.attributes[positionAttributeIndex].data, weight, vertices)) {
|
if (!generateTargetData(target.attributes[positionAttributeIndex].data, weight, vertices)) {
|
||||||
qWarning(modelformat) << "Invalid accessor type on generateTargetData vertices for model " << _url;
|
qWarning(modelformat) << "Invalid POSITION accessor on generateTargetData vertices for model " << _url;
|
||||||
hfmModel.loadErrorCount++;
|
hfmModel.loadErrorCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue