rojo-rbx / rbx-dom

Roblox DOM and (de)serialization implementation in Rust
MIT License
113 stars 45 forks source link

Add Model.WorldPivotData custom getter/setter #393

Closed kennethloeffler closed 7 months ago

kennethloeffler commented 7 months ago

This PR closes #391 by adding a custom getter/setter for Model.WorldPivotData.

I'm a little shaky about what ought to happen when the setter receives a nil. It likely means that the model's PrimaryPart was set to nil elsewhere... I think the safest option is probably to do nothing?

kennethloeffler commented 7 months ago

So, in my dazed confusion I did mess this up a little bit.

Model.WorldPivotData is only unoccupied for a newly created Model. If I set the pivot whatsoever, the property remains occupied regardless of if the model has a PrimaryPart or not. With this in mind, the if instance.PrimaryPart == nil then bit is crap and should be removed.

This also means that when we want the property to be unoccupied (i.e. when the setter receives a nil), we may have to create a new Model instance. I'm not sure if this level of accuracy is necessary, but we should keep it in mind