Skip to content

Commit

Permalink
Merge pull request #3523 from CombatExtended-Continued/minor-render-opt
Browse files Browse the repository at this point in the history
Memoize Y-offset for pawn rendering
  • Loading branch information
N7Huntsman authored Nov 4, 2024
2 parents 572ff7c + 82de6a4 commit 08bcf98
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/CombatExtended/Harmony/Harmony_PawnRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ private static void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material mat, int laye
muzzleJump = -muzzleJump;
casingOffset.x *= -1;
}
matrix.SetTRS(position + posVec.RotatedBy(matrix.rotation.eulerAngles.y) + recoilOffset, Quaternion.AngleAxis(matrix.rotation.eulerAngles.y + muzzleJump, Vector3.up), scale);

float yAngle = matrix.rotation.eulerAngles.y;
matrix.SetTRS(position + posVec.RotatedBy(yAngle) + recoilOffset, Quaternion.AngleAxis(yAngle + muzzleJump, Vector3.up), scale);
CompEquippable compEquippable = eq.TryGetComp<CompEquippable>();
if (compEquippable != null && compEquippable.PrimaryVerb is Verb_ShootCE verbCE)
{
verbCE.drawPos = casingDrawPos + (casingOffset + posVec).RotatedBy(matrix.rotation.eulerAngles.y);
verbCE.drawPos = casingDrawPos + (casingOffset + posVec).RotatedBy(yAngle);
}
if (eq is WeaponPlatform platform)
{
Expand Down

0 comments on commit 08bcf98

Please sign in to comment.