raise an error when an object creates a .msh segment with too many vertices

This commit is contained in:
SleepKiller 2019-11-20 03:33:01 +13:00
parent 83bdf4788d
commit aa18f5c2b7
2 changed files with 9 additions and 2 deletions

View File

@ -59,10 +59,10 @@ Can't imagine this coming up much (Maybe if you're model is just for collisions
This shouldn't be relevant as any mesh that you haven't assigned a material to is likely to just be collision geometry or shadow geometry.
### Work to be done
- [ ] Raise an error when a .msh segment has more than 32767 vertices.
- [x] Raise an error when a .msh segment has more than 32767 vertices.
- [x] Convert from Blender's coordinate space to .msh cooordinate space.
- [x] Add support for exporting materials. Blender's materials are all based around it's own renderers, so possibly going to need custom UI and properties in order to provide something useful for .msh files.
- [ ] Add support for collision primitives. Blender doesn't seam to support having basic boxes, cylinders or spheres so it's likely some wacky rules and conventions will need to be used by the modeler. "Add a 1m mesh primitive, have "sphere/box/cylinder" in the name and control the size with the object's scale." Less intuitive than I'd like but it might be the best course of action.
- [x] Add support for collision primitives. Blender doesn't seam to support having basic boxes, cylinders or spheres so it's likely some wacky rules and conventions will need to be used by the modeler. "Add a 1m mesh primitive, have "sphere/box/cylinder" in the name and control the size with the object's scale." Less intuitive than I'd like but it might be the best course of action.
- [ ] Investigate and add support for exporting bones and vertex weights.
- [ ] Investigate and add support for exporting animations.
- [ ] Investigate if anything special needs to be done for lod/lowres exporting.

View File

@ -11,6 +11,7 @@ from .msh_utilities import *
SKIPPED_OBJECT_TYPES = {"LATTICE", "CAMERA", "LIGHT", "SPEAKER", "LIGHT_PROBE"}
MESH_OBJECT_TYPES = {"MESH", "CURVE", "SURFACE", "META", "FONT", "GPENCIL"}
MAX_MSH_VERTEX_COUNT = 32767
def gather_models() -> List[Model]:
""" Gathers the Blender objects from the current scene and returns them as a list of
@ -47,6 +48,12 @@ def gather_models() -> List[Model]:
_, _, world_scale = obj.matrix_world.decompose()
world_scale = convert_scale_space(world_scale)
scale_segments(world_scale, model.geometry)
for segment in model.geometry:
if len(segment.positions) > MAX_MSH_VERTEX_COUNT:
raise RuntimeError(f"Object '{obj.name}' has resulted in a .msh geometry segment that has "
f"more than {MAX_MSH_VERTEX_COUNT} vertices! Split the object's mesh up "
f"and try again!")
if get_is_collision_primitive(obj):
model.collisionprimitive = get_collision_primitive(obj)