Duplicate code in update function

Hi @caroline

In the 09-scene-graph Model.swift, the code in the override func update(deltaTime: Float) is duplicate, I’m wondering if there is any reason for it?

for mesh in meshes
    {
        if let animationClip = currentAnimation  // πŸ‘ˆ
        {
            mesh.skeleton?.updatePose(animationClip:animationClip, at:currentTime)  // πŸ‘ˆ
            mesh.transform?.currentTransform = .identity()
        }
        else
        {
            if let animationClip = currentAnimation  // πŸ‘ˆ, this code cannot run, since we are in the else state?
            {
                mesh.skeleton?.updatePose(animationClip:animationClip, at:currentTime)  // πŸ‘ˆ
            }
            mesh.transform?.setCurrentTransform(at: currentTime)
        }
    }

thx

1 Like

What a great catch! No, it doesn’t look like it’s there for any reason at all. It must have snuck in there at the beginning of the chapter, as it’s not in Chapter 8, Character Animation.

Thank you. I’ll revise that for the next edition.

1 Like