|
26 | 26 | from .typed import ArrayLike, Dict, Iterable, NDArray, Optional, Set, Union, float64 |
27 | 27 |
|
28 | 28 | # create a default logger |
29 | | -log = logging.getLogger("trimesh") |
| 29 | +log = logging.getLogger(__name__) |
30 | 30 |
|
31 | 31 | ABC = abc.ABC |
32 | 32 | now = time.time |
@@ -1489,25 +1489,35 @@ def concatenate( |
1489 | 1489 | except BaseException: |
1490 | 1490 | pass |
1491 | 1491 |
|
| 1492 | + # concatenate vertex attributes that are valid for every mesh |
1492 | 1493 | vertex_attributes = {} |
1493 | | - # concatenate vertex attributes |
1494 | 1494 | for key in is_mesh[0].vertex_attributes.keys(): |
1495 | | - # make sure every mesh has the attribute |
1496 | | - # and that the attribute is valid for that mesh |
| 1495 | + # make sure every mesh has a valid attribute |
1497 | 1496 | if all(len(m.vertex_attributes.get(key, [])) == len(m.vertices) for m in is_mesh): |
1498 | | - vertex_attributes[key] = np.concatenate( |
1499 | | - [mesh.vertex_attributes.get(key, []) for mesh in is_mesh], axis=0 |
1500 | | - ) |
| 1497 | + try: |
| 1498 | + vertex_attributes[key] = np.concatenate( |
| 1499 | + [mesh.vertex_attributes.get(key, []) for mesh in is_mesh], axis=0 |
| 1500 | + ) |
| 1501 | + except BaseException: |
| 1502 | + log.warning( |
| 1503 | + f"Failed to concatenate `vertex_attribute['{key}']`", exc_info=True |
| 1504 | + ) |
1501 | 1505 |
|
| 1506 | + # concatenate face attributes that are valid for every mesh |
1502 | 1507 | face_attributes = {} |
1503 | | - # concatenate valid face attributes |
1504 | 1508 | for key in is_mesh[0].face_attributes.keys(): |
1505 | | - # an attribute can only be concatenated if |
1506 | | - # if is valid on every mesh we're concatenating |
| 1509 | + # an attribute can only be concatenated if it's valid for every mesh |
1507 | 1510 | if all(len(m.face_attributes.get(key, [])) == len(m.faces) for m in is_mesh): |
1508 | | - face_attributes[key] = np.concatenate( |
1509 | | - [mesh.face_attributes.get(key, []) for mesh in is_mesh], axis=0 |
1510 | | - ) |
| 1511 | + try: |
| 1512 | + # stack along axis 0 |
| 1513 | + face_attributes[key] = np.concatenate( |
| 1514 | + [mesh.face_attributes.get(key, []) for mesh in is_mesh], axis=0 |
| 1515 | + ) |
| 1516 | + except BaseException: |
| 1517 | + # could have failed because attribute had different shapes |
| 1518 | + log.warning( |
| 1519 | + f"Failed to concatenate `face_attribute['{key}']`", exc_info=True |
| 1520 | + ) |
1511 | 1521 |
|
1512 | 1522 | # create the mesh object |
1513 | 1523 | result = trimesh_type( |
|
0 commit comments