Cleaning up physics shapes
Before Leadwerks 3 existed, Leadwerks 2 used a little tool called "Phygen" to generate collision shape files for 3D models:
The user would input the parameters and then save that file with the same name as the model it was to be associated with, with the PHY file extension. This was not a very good system, but the idea of storing a physics shape in a PHY file that was automatically loaded along with the model was a good one.
In Leadwerks 3 we implemented prefabs to make it easier to have a ready-to-use game model. However, after using the system for a while it became obvious that 90% of your models just need a simple collision shape and no other special settings. The prefab system was overkill for a simple static model.
I've simplified physics shapes by adding physics shape generation in the model editor, for convex decomposition, boxes, spheres, cones, and cylinders. When you generate a physics shape it is created automatically from the model's bounds and saved as a PHY file alongside the model. Whenever that model is loaded, the engine will look for an associated physics shape file and load it at the same time.
The physics tab has been simplified with no more confusing physics shape fields to be adjusted:
However, under the hood the ability to assign an arbitrary physics shape to any entity is still there. If your map depends on this feature there is a hidden setting in the config file you can use to retain this feature in the editor. Just open your Leadwerks.cfg file and set the "EnableLegacyFeatures" value to 1 and it will appear. Existing maps will be unaffected, even if you don't enable this feature.
These changes improve the workflow because now you just open up a model, generate a shape of any type, save it, and you have a model with physics ready to go. It does mean physics shapes are more strongly associated with models, and I originally intended them to be assigned to any old entity. However, in practice the ability to set a physics shape to a light or camera or something in the editor is pretty useless, and it's better to focus on the way it's used 99% of the time instead of designing for edge cases.
- 10
10 Comments
Recommended Comments