FiguraMC / Figura

Extensively customize your character with Figura!
https://modrinth.com/mod/figura
GNU Lesser General Public License v2.1
225 stars 44 forks source link

models:partToWorldMatrix() does not update #215

Open Gakuto1112 opened 4 months ago

Gakuto1112 commented 4 months ago

Description

models:getModelWorldPos() models:partToWorldMatrix() does not update its matrix in first person perspective if the model's parent type is Item.

This issue does not occur if the parent type of the model is not item or in third person perspective.

How to reproduce

  1. Set the parent type of a model to Item.
  2. Get the matrix of the Item model with models:getModelWorldPos() models:partToWorldMatrix() in first person perspective.
  3. You will see that the matrix will not update and remain in the same state as it was in third person perspective.

I attached the example avatar that describes this issue.

This avatar has two anchors that emit particles. One is at the top of the player head and emits green particles, and another one is at the item that the player holds and emits red particles. In first person perspective, green particles are following their anchor. However, red particles are standing still in the place where they were last in the third-person perspective.

The image that describes this issue

Expected behavior

The item model matrix will update even if in first person perspective. In case of the example avatar, red particles still follow in first person perspective.

Enviroments

Item Version
Minecraft 1.20.1
Fabric Loader 0.15.7
Fabric API 0.92.1+1.20.1
Figura 0.1.4+1.20.1

No other mod installed.

Attachments

TestAvatar.zip

4P5 commented 4 months ago

Do you mean partToWorldMatrix()? getModelWorldPos() isn't a method in Figura

kcin2001 commented 4 months ago

theres also an option to update the matrix in first person

Gakuto1112 commented 4 months ago

Do you mean partToWorldMatrix()? getModelWorldPos() isn't a method in Figura

Oh sorry. You are right. models:getModelWorldPos() is a self-defined function.

Gakuto1112 commented 4 months ago

theres also an option to update the matrix in first person

Of course, "First-person matrices" option is enabled. (The UI is in Japanese. Sorry.)

image

KitCat962 commented 4 months ago

This is expected. partToWorldMatrix is the cached result of the previous time the part rendered, and will not update when the part does not render.

First Person Matrices has to do with Vanilla Parts having their getOriginRot updated in first person, not partToWorldMatrix

Gakuto1112 commented 4 months ago

This is expected. partToWorldMatrix is the cached result of the previous time the part rendered, and will not update when the part does not render.

First Person Matrices has to do with Vanilla Parts having their getOriginRot updated in first person, not partToWorldMatrix

I see. I thought that it is a specification of Figura, but I thought that it might be a bug, so I posted this.

PoolloverNathan commented 4 months ago

What if, for ease-of-use purposes, the existing behavior was moved to something like partToWorldMatrixRaw and partToWorldMatrix recalculated it (like getPositionMatrix)?

Edit: Nevermind, that could be breaking. A new function recalculatePartToWorldMatrix wouldn't be, though, and would probably be easy to use.