mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-09-23 15:33:57 +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 {
|
bool SetParentAttribute(const PointAttribute *att) override {
|
||||||
if (att->attribute_type() != GeometryAttribute::POSITION)
|
if (!att || att->attribute_type() != GeometryAttribute::POSITION)
|
||||||
return false; // Invalid attribute type.
|
return false; // Invalid attribute type.
|
||||||
if (att->num_components() != 3)
|
if (att->num_components() != 3)
|
||||||
return false; // Currently works only for 3 component positions.
|
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
|
// If needed, copy point to attribute value index mapping from the final
|
||||||
// attribute to the portable attribute.
|
// attribute to the portable attribute.
|
||||||
if (!attribute_->is_mapping_identity() &&
|
if (!attribute_->is_mapping_identity() &&
|
||||||
portable_attribute_->is_mapping_identity()) {
|
portable_attribute_ && portable_attribute_->is_mapping_identity()) {
|
||||||
portable_attribute_->SetExplicitMapping(attribute_->indices_map_size());
|
portable_attribute_->SetExplicitMapping(attribute_->indices_map_size());
|
||||||
for (PointIndex i(0); i < attribute_->indices_map_size(); ++i) {
|
for (PointIndex i(0); i < attribute_->indices_map_size(); ++i) {
|
||||||
portable_attribute_->SetPointMapEntry(i, attribute_->mapped_index(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());
|
std::unique_ptr<Mesh> mesh(new Mesh());
|
||||||
// Analyze file extension.
|
// Analyze file extension.
|
||||||
const std::string 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") {
|
if (extension == ".obj") {
|
||||||
// Wavefront OBJ file format.
|
// Wavefront OBJ file format.
|
||||||
ObjDecoder obj_decoder;
|
ObjDecoder obj_decoder;
|
||||||
|
@ -25,7 +25,8 @@ std::unique_ptr<PointCloud> ReadPointCloudFromFile(
|
|||||||
const std::string &file_name) {
|
const std::string &file_name) {
|
||||||
std::unique_ptr<PointCloud> pc(new PointCloud());
|
std::unique_ptr<PointCloud> pc(new PointCloud());
|
||||||
// Analyze file extension.
|
// 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") {
|
if (extension == ".obj") {
|
||||||
// Wavefront OBJ file format.
|
// Wavefront OBJ file format.
|
||||||
ObjDecoder obj_decoder;
|
ObjDecoder obj_decoder;
|
||||||
|
@ -134,8 +134,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Save the decoded geometry into a file.
|
// Save the decoded geometry into a file.
|
||||||
// TODO(ostava): Currently only .ply and .obj are supported.
|
// TODO(ostava): Currently only .ply and .obj are supported.
|
||||||
const std::string extension =
|
const std::string extension = options.output.size() >= 4 ?
|
||||||
options.output.substr(options.output.size() - 4);
|
options.output.substr(options.output.size() - 4) : options.output;
|
||||||
if (extension == ".obj") {
|
if (extension == ".obj") {
|
||||||
draco::ObjEncoder obj_encoder;
|
draco::ObjEncoder obj_encoder;
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user