@@ -1157,6 +1157,7 @@ struct GeometryPartitionImpl {
11571157};
11581158
11591159struct GeometryDataImpl : GeometryData {
1160+ bool has_vertices = false ;
11601161 Vec3AttributesImpl positions;
11611162 Vec3AttributesImpl normals;
11621163 Vec3AttributesImpl tangents;
@@ -1176,6 +1177,8 @@ struct GeometryDataImpl : GeometryData {
11761177 return res;
11771178 }
11781179
1180+ bool hasVertices () const override { return has_vertices; }
1181+
11791182 Vec3Attributes getPositions () const override { return positions; }
11801183 Vec3Attributes getNormals () const override { return patchAttributes<Vec3Attributes>(normals); }
11811184 Vec2Attributes getUVs (int index) const override { return patchAttributes<Vec2Attributes>(uvs[index]); }
@@ -3126,16 +3129,22 @@ static OptionalError<Object*> parseAnimationCurve(const Scene& scene, const Elem
31263129 return curve;
31273130}
31283131
3129- static OptionalError<Object*> parseGeometry (const Element& element, GeometryImpl& geom, std::vector<ParseDataJob> &jobs, bool ignore_geometry , Allocator& allocator) {
3132+ static OptionalError<Object*> parseGeometry (const Element& element, GeometryImpl& geom, std::vector<ParseDataJob> &jobs, u16 flags , Allocator& allocator) {
31303133 assert (element.first_property );
31313134
3132- if (!parseGeometryMaterials (geom, element, jobs)) return Error (" Invalid materials" );
3135+ const bool ignore_geometry = (flags & (u16 )LoadFlags::IGNORE_GEOMETRY) != 0 ;
3136+ const bool keep_matertial_map = (flags & (u16 )LoadFlags::KEEP_MATERIAL_MAP) != 0 ;
3137+
3138+ if (keep_matertial_map || !ignore_geometry) {
3139+ if (!parseGeometryMaterials (geom, element, jobs)) return Error (" Invalid materials" );
3140+ }
31333141
31343142 const Element* vertices_element = findChild (element, " Vertices" );
31353143 if (!vertices_element || !vertices_element->first_property ) {
31363144 return &geom;
31373145 }
31383146
3147+ geom.has_vertices = true ;
31393148 const Element* polys_element = findChild (element, " PolygonVertexIndex" );
31403149 if (!polys_element || !polys_element->first_property ) return Error (" Indices missing" );
31413150
@@ -3451,9 +3460,7 @@ static bool parseObjects(const Element& root, Scene& scene, u16 flags, Allocator
34513460 if (last_prop && last_prop->value == " Mesh" )
34523461 {
34533462 GeometryImpl* geom = allocator.allocate <GeometryImpl>(scene, *iter.second .element );
3454- if (!ignore_geometry || keep_matertial_map) {
3455- parseGeometry (*iter.second .element , *geom, jobs, ignore_geometry, allocator);
3456- }
3463+ parseGeometry (*iter.second .element , *geom, jobs, flags, allocator);
34573464 obj = geom;
34583465 scene.m_geometries .push_back (geom);
34593466 }
0 commit comments