Skip to content

Attachment normals could be wrong on some cases #122

@albertomelladoc

Description

@albertomelladoc

Hi!

I have checked this project and I was having a really weird issue where the normals of my attachments were wrong. I think this was due to my models skeleton having a really weird base rotation. Finally I found what fixes it in my case. I modified the method of BindAttachment on AnimationInstancingMgr with this:

Vector3[] vertices = attachmentCache.mesh.vertices;
Vector3[] normals = attachmentCache.mesh.normals;

for (int k = 0; k != attachmentCache.mesh.vertexCount; ++k)
{
    vertices[k] = q * vertices[k];
    vertices[k] = vertices[k] + offset;

    normals[k] = q * normals[k];
}

attachmentCache.mesh.vertices = vertices;
attachmentCache.mesh.normals = normals;

I believe that when the vertices of the mesh are modified with the parent rotation on the attachment the normals should also be modified. At least it fixed the issue for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions