XMVectorSelect

Performs a per-component selection between two input vectors and returns the resulting vector.

Syntax

XMVECTOR XMVectorSelect(
         XMVECTOR V1,
         XMVECTOR V2,
         XMVECTOR Control
)  

Parameters

V1
Type: XMVECTOR 

First vector to compare.

V2
Type: XMVECTOR 

Second vector to compare.

Control
Type: XMVECTOR 

Vector mask used to select a vector component from either V1 or V2. If a component of Control is zero, the returned vector’s corresponding component will be the first vector’s component. If a component of Control is 0xFF, the returned vector’s corresponding component will be the second vector’s component. For full details on how the vector mask works, see the “Remarks”.

Typically, the vector used for Control will be either the output of a vector comparison function (such as XMVectorEqual, XMVectorLess, or XMVectorGreater) or it will be the output of XMVectorSelectControl.

Return value

Type: XMVECTOR 

Returns the result of the per-component selection.

Remarks

If any given bit of Control is set, the corresponding bit from V2 is used, otherwise, the corresponding bit from V1 is used. The following pseudocode demonstrates the operation of the function:

XMVECTOR Result;

Result.u[0] = (V1.u[0] & ~Control.u[0]) | (V2.u[0] & Control.u[0]);
Result.u[1] = (V1.u[1] & ~Control.u[1]) | (V2.u[1] & Control.u[1]);
Result.u[2] = (V1.u[2] & ~Control.u[2]) | (V2.u[2] & Control.u[2]);
Result.u[3] = (V1.u[3] & ~Control.u[3]) | (V2.u[3] & Control.u[3]);

return Result;  

Manual construction of a control vector is not necessary. There are two simple ways of constructing an appropriate control vector:

Requirements

Header: Declared in directxmath.h.