Axiom.Core.Entity.ReevaluateVertexProcessing C# (CSharp) Method

ReevaluateVertexProcessing() protected method

Trigger an evaluation of whether hardware skinning is supported for this entity.
protected ReevaluateVertexProcessing ( ) : void
return void
		protected internal void ReevaluateVertexProcessing()
		{
			// init
			this.hardwareAnimation = false;
			//this.vertexProgramInUse = false; // assume false because we just assign this
			bool firstPass = true;

			// check for each sub entity
			foreach ( SubEntity subEntity in this.subEntityList )
			{
				// grab the material and make sure it is loaded first
				Material m = subEntity.Material;
				m.Load();

				Technique t = m.GetBestTechnique();

				if ( t == null )
				{
					// no supported techniques
					continue;
				}

				Pass p = t.GetPass( 0 );

				if ( p == null )
				{
					// no passes, so invalid
					continue;
				}

				if ( p.HasVertexProgram )
				{
					// If one material uses a vertex program, set this flag
					// Causes some special processing like forcing a separate light cap
					//this.vertexProgramInUse = true;

					if ( this.HasSkeleton )
					{
						// All materials must support skinning for us to consider using
						// hardware animation - if one fails we use software
						bool skeletallyAnimated = p.VertexProgram.IsSkeletalAnimationIncluded;
						subEntity.HardwareSkinningEnabled = skeletallyAnimated;
						subEntity.VertexProgramInUse = true;
						if ( firstPass )
						{
							this.hardwareAnimation = skeletallyAnimated;
							firstPass = false;
						}
						else
						{
							this.hardwareAnimation = this.hardwareAnimation && skeletallyAnimated;
						}
					}

					VertexAnimationType animType = VertexAnimationType.None;
					if ( subEntity.SubMesh.useSharedVertices )
					{
						animType = this.mesh.SharedVertexDataAnimationType;
					}
					else
					{
						animType = subEntity.SubMesh.VertexAnimationType;
					}
					if ( animType == VertexAnimationType.Morph )
					{
						// All materials must support morph animation for us to consider using
						// hardware animation - if one fails we use software
						if ( firstPass )
						{
							this.hardwareAnimation = p.VertexProgram.IsMorphAnimationIncluded;
							firstPass = false;
						}
						else
						{
							this.hardwareAnimation = this.hardwareAnimation && p.VertexProgram.IsMorphAnimationIncluded;
						}
					}
					else if ( animType == VertexAnimationType.Pose )
					{
						// All materials must support pose animation for us to consider using
						// hardware animation - if one fails we use software
						if ( firstPass )
						{
							this.hardwareAnimation = p.VertexProgram.PoseAnimationCount > 0;
							if ( subEntity.SubMesh.useSharedVertices )
							{
								this.hardwarePoseCount = p.VertexProgram.PoseAnimationCount;
							}
							else
							{
								subEntity.HardwarePoseCount = p.VertexProgram.PoseAnimationCount;
							}
							firstPass = false;
						}
						else
						{
							this.hardwareAnimation = this.hardwareAnimation && p.VertexProgram.PoseAnimationCount > 0;
							if ( subEntity.SubMesh.useSharedVertices )
							{
								this.hardwarePoseCount =
										(ushort)
										Utility.Max( this.hardwarePoseCount, p.VertexProgram.PoseAnimationCount );
							}
							else
							{
								subEntity.HardwarePoseCount = (ushort)Utility.Max( subEntity.HardwarePoseCount,
																					p.VertexProgram.PoseAnimationCount );
							}
						}
					}
				}
			}
		}