mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-06-22 03:40:42 +08:00
Merge pull request #173 from pps83/master
fix for #108 and workaround to avoid crash in #171
This commit is contained in:
commit
2049e1a089
@ -64,7 +64,7 @@ class MeshPredictionSchemeTexCoordsPortableDecoder
|
||||
}
|
||||
|
||||
bool SetParentAttribute(const PointAttribute *att) override {
|
||||
if (att->attribute_type() != GeometryAttribute::POSITION)
|
||||
if (!att || att->attribute_type() != GeometryAttribute::POSITION)
|
||||
return false; // Invalid attribute type.
|
||||
if (att->num_components() != 3)
|
||||
return false; // Currently works only for 3 component positions.
|
||||
|
@ -59,7 +59,7 @@ const PointAttribute *SequentialAttributeDecoder::GetPortableAttribute() {
|
||||
// If needed, copy point to attribute value index mapping from the final
|
||||
// attribute to the portable attribute.
|
||||
if (!attribute_->is_mapping_identity() &&
|
||||
portable_attribute_->is_mapping_identity()) {
|
||||
portable_attribute_ && portable_attribute_->is_mapping_identity()) {
|
||||
portable_attribute_->SetExplicitMapping(attribute_->indices_map_size());
|
||||
for (PointIndex i(0); i < attribute_->indices_map_size(); ++i) {
|
||||
portable_attribute_->SetPointMapEntry(i, attribute_->mapped_index(i));
|
||||
|
@ -31,7 +31,8 @@ std::unique_ptr<Mesh> ReadMeshFromFile(const std::string &file_name,
|
||||
std::unique_ptr<Mesh> mesh(new Mesh());
|
||||
// Analyze file extension.
|
||||
const std::string extension =
|
||||
parser::ToLower(file_name.substr(file_name.size() - 4));
|
||||
parser::ToLower(file_name.size() >= 4 ?
|
||||
file_name.substr(file_name.size() - 4) : file_name);
|
||||
if (extension == ".obj") {
|
||||
// Wavefront OBJ file format.
|
||||
ObjDecoder obj_decoder;
|
||||
|
@ -25,7 +25,8 @@ std::unique_ptr<PointCloud> ReadPointCloudFromFile(
|
||||
const std::string &file_name) {
|
||||
std::unique_ptr<PointCloud> pc(new PointCloud());
|
||||
// Analyze file extension.
|
||||
const std::string extension = file_name.substr(file_name.size() - 4);
|
||||
const std::string extension = file_name.size() >= 4 ?
|
||||
file_name.substr(file_name.size() - 4) : file_name;
|
||||
if (extension == ".obj") {
|
||||
// Wavefront OBJ file format.
|
||||
ObjDecoder obj_decoder;
|
||||
|
@ -134,8 +134,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Save the decoded geometry into a file.
|
||||
// TODO(ostava): Currently only .ply and .obj are supported.
|
||||
const std::string extension =
|
||||
options.output.substr(options.output.size() - 4);
|
||||
const std::string extension = options.output.size() >= 4 ?
|
||||
options.output.substr(options.output.size() - 4) : options.output;
|
||||
if (extension == ".obj") {
|
||||
draco::ObjEncoder obj_encoder;
|
||||
if (mesh) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user