drwhut / tabletop-club

An open-source platform for playing tabletop games in a physics-based 3D environment for Windows, macOS, and Linux! Made with the Godot Engine.
https://tabletopclub.net
MIT License
1.3k stars 57 forks source link

Configure the way the centre-of-mass of objects is adjusted. #208

Closed drwhut closed 1 year ago

drwhut commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, the game adjusts the centre-of-mass (COM) of all custom objects to be the centre of the object's volume. While this is suitable for the majority of objects, it would be nice to be able to 1. turn off the automatic adjustment, and 2. automatically adjust it based on the average of all of the vertices, rather than the volume.

Describe the solution you'd like Add a new property to the config.cfg file:

; The current behaviour: set the COM to the middle of the object's volume.
com_adjust = "volume"

; Set the COM to the average point of all the objects' vertices.
com_adjust = "geometry"

; Turn off automatic adjustment, the COM will be the origin of the object (0, 0, 0).
com_adjust = "off"

Describe alternatives you've considered I have considered just leaving it up to the creator of the model to make sure the COM is at (0, 0, 0) - but I think having automatic adjustment is very convenient, and if the creator does want to set the COM themselves, they can still do so with this method by turning automatic adjustment off.

Additional context This idea was thought off during the development of #142, as d4 sometimes bounced off of the table and landed on another face when setting their value (which is incorrect behaviour). This I deduced was due to a wonky COM.

The possible values for the com_adjust property were based on the options that Blender gives in setting the origin of an object.