Skip to content

Commit

Permalink
Update DualQuaternionSkinner.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCake authored and MadCake committed Jun 17, 2020
1 parent e898e78 commit afe6452
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Code/DQ skinning/DualQuaternionSkinner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ public void UpdatePerVertexCompensationCoef()
this.ApplyMorphs();
}

int GetVertexTextureHeight(int vertexCount, int textureWidth)
{
int textureHeight = this.mf.sharedMesh.vertexCount / textureWidth;
if (this.mf.sharedMesh.vertexCount % textureWidth != 0)
{
textureHeight++;
}
return textureHeight;
}

void GrabMeshFromSkinnedMeshRenderer()
{
this.ReleaseBuffers();
Expand Down Expand Up @@ -364,11 +374,7 @@ void GrabMeshFromSkinnedMeshRenderer()

// initiate textures and buffers

int textureHeight = this.mf.sharedMesh.vertexCount / textureWidth;
if (this.mf.sharedMesh.vertexCount % textureWidth != 0)
{
textureHeight++;
}
int textureHeight = GetVertexTextureHeight(this.mf.sharedMesh.vertexCount, textureWidth);

this.rtSkinnedData_1 = new RenderTexture(textureWidth, textureHeight, 0, RenderTextureFormat.ARGBFloat)
{
Expand Down Expand Up @@ -616,7 +622,7 @@ void Update()
this.materialPropertyBlock.SetTexture("skinned_data_1", this.rtSkinnedData_1);
this.materialPropertyBlock.SetTexture("skinned_data_2", this.rtSkinnedData_2);
this.materialPropertyBlock.SetTexture("skinned_data_3", this.rtSkinnedData_3);
this.materialPropertyBlock.SetInt("skinned_tex_height", this.mf.sharedMesh.vertexCount / textureWidth);
this.materialPropertyBlock.SetInt("skinned_tex_height", GetVertexTextureHeight(this.mf.sharedMesh.vertexCount, textureWidth));
this.materialPropertyBlock.SetInt("skinned_tex_width", textureWidth);

this.mr.SetPropertyBlock(this.materialPropertyBlock);
Expand Down

0 comments on commit afe6452

Please sign in to comment.