common/animation/blending_job.cc
// Blends all layers of the job to its output.

Blends all layers of the job to its output.
Blends all layers of the job to its output .
void BlendLayers(ProcessArgs* _args)
			{
				assert(_args);
				for (const BlendingJob::Layer* layer = _args->job.layers.begin;
					layer < _args->job.layers.end; ++layer)
				{
					assert(layer->transform.end >=
						layer->transform.begin + _args->num_soa_joints);
					assert(!layer->joint_weights.begin ||
						(layer->joint_weights.end >=
							layer->joint_weights.begin + _args->num_soa_joints));
					if (layer->weight <= 0.f)
					{
						continue;
					}
					_args->accumulated_weight += layer->weight;
					const math::SimdFloat4 layer_weight =
						math::simd_float4::Load1(layer->weight);
					if (layer->joint_weights.begin)
					{
						++_args->num_partial_passes;
						if (_args->num_passes == 0)
						{
							for (size_t i = 0; i < _args->num_soa_joints; ++i)
							{
								const math::SoaTransform& src = layer->transform.begin[i];
								math::SoaTransform* dest = _args->job.output.begin + i;
								const math::SimdFloat4 weight =
									layer_weight * math::Max0(layer->joint_weights.begin[i]);
								_args->accumulated_weights[i] = weight;
								BLEND_1ST_PASS(src, weight, dest);
							}
						}
						else
						{
							for (size_t i = 0; i < _args->num_soa_joints; ++i)
							{
								const math::SoaTransform& src = layer->transform.begin[i];
								math::SoaTransform* dest = _args->job.output.begin + i;
								const math::SimdFloat4 weight =
									layer_weight * math::Max0(layer->joint_weights.begin[i]);
								_args->accumulated_weights[i] =
									_args->accumulated_weights[i] + weight;
								BLEND_N_PASS(src, weight, dest);
							}
						}
					}
					else
					{
						if (_args->num_passes == 0)
						{
							for (size_t i = 0; i < _args->num_soa_joints; ++i)
							{
								const math::SoaTransform& src = layer->transform.begin[i];
								math::SoaTransform* dest = _args->job.output.begin + i;
								_args->accumulated_weights[i] = layer_weight;
								BLEND_1ST_PASS(src, layer_weight, dest);
							}
						}
						else
						{
							for (size_t i = 0; i < _args->num_soa_joints; ++i)
							{
								const math::SoaTransform& src = layer->transform.begin[i];
								math::SoaTransform* dest = _args->job.output.begin + i;
								_args->accumulated_weights[i] =
									_args->accumulated_weights[i] + layer_weight;
								BLEND_N_PASS(src, layer_weight, dest);
							}
						}
					}
					++_args->num_passes;
				}
			}
void BlendLayers ( ProcessArgs * _args ) { assert ( _args ) ; for ( const BlendingJob :: Layer * layer = _args -> job . layers . begin ; layer < _args -> job . layers . end ; ++ layer ) { assert ( layer -> transform . end >= layer -> transform . begin + _args -> num_soa_joints ) ; assert ( ! layer -> joint_weights . begin || ( layer -> joint_weights . end >= layer -> joint_weights . begin + _args -> num_soa_joints ) ) ; if ( layer -> weight <= 0.f ) { continue ; } _args -> accumulated_weight += layer -> weight ; const math :: SimdFloat4 layer_weight = math :: simd_float4 :: Load1 ( layer -> weight ) ; if ( layer -> joint_weights . begin ) { ++ _args -> num_partial_passes ; if ( _args -> num_passes == 0 ) { for ( size_t i = 0 ; i < _args -> num_soa_joints ; ++ i ) { const math :: SoaTransform & src = layer -> transform . begin [ i ] ; math :: SoaTransform * dest = _args -> job . output . begin + i ; const math :: SimdFloat4 weight = layer_weight * math :: Max0 ( layer -> joint_weights . begin [ i ] ) ; _args -> accumulated_weights [ i ] = weight ; BLEND_1ST_PASS ( src , weight , dest ) ; } } else { for ( size_t i = 0 ; i < _args -> num_soa_joints ; ++ i ) { const math :: SoaTransform & src = layer -> transform . begin [ i ] ; math :: SoaTransform * dest = _args -> job . output . begin + i ; const math :: SimdFloat4 weight = layer_weight * math :: Max0 ( layer -> joint_weights . begin [ i ] ) ; _args -> accumulated_weights [ i ] = _args -> accumulated_weights [ i ] + weight ; BLEND_N_PASS ( src , weight , dest ) ; } } } else { if ( _args -> num_passes == 0 ) { for ( size_t i = 0 ; i < _args -> num_soa_joints ; ++ i ) { const math :: SoaTransform & src = layer -> transform . begin [ i ] ; math :: SoaTransform * dest = _args -> job . output . begin + i ; _args -> accumulated_weights [ i ] = layer_weight ; BLEND_1ST_PASS ( src , layer_weight , dest ) ; } } else { for ( size_t i = 0 ; i < _args -> num_soa_joints ; ++ i ) { const math :: SoaTransform & src = layer -> transform . begin [ i ] ; math :: SoaTransform * dest = _args -> job . output . begin + i ; _args -> accumulated_weights [ i ] = _args -> accumulated_weights [ i ] + layer_weight ; BLEND_N_PASS ( src , layer_weight , dest ) ; } } } ++ _args -> num_passes ; } }
Blends all layers of the job to its output.
Blends all layers of the job to its output .
// Iterates through all layers and blend them to the output.
 // Asserts buffer sizes, which must never fail as it has been validated.
 // Skip irrelevant layers.
 // Accumulates global weights.
 // This layer has per-joint weights.
 // This is a full layer.
 // One more pass blended.
