Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

math.compress

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static int compress(int* output, int index, int4 val, bool4 mask);

Parameters

Parameter Description
output Pointer to packed output array where enabled components should be stored to.
index Index into output array where first enabled component should be stored to.
val The value to to compress.
mask Mask indicating which components are enabled.

Returns

int Index to element after the last one stored.

Description

Packs components with an enabled mask to the left.

This function is also known as left packing. The effect of this function is to filter out components that are not enabled and leave an output buffer tightly packed with only the enabled components. A common use case is if you perform intersection tests on arrays of data in structure of arrays (SoA) form and need to produce an output array of the things that intersected.


Declaration

public static int compress(uint* output, int index, uint4 val, bool4 mask);

Parameters

Parameter Description
output Pointer to packed output array where enabled components should be stored to.
index Index into output array where first enabled component should be stored to.
val The value to to compress.
mask Mask indicating which components are enabled.

Returns

int Index to element after the last one stored.

Description

Packs components with an enabled mask to the left.

This function is also known as left packing. The effect of this function is to filter out components that are not enabled and leave an output buffer tightly packed with only the enabled components. A common use case is if you perform intersection tests on arrays of data in structure of arrays (SoA) form and need to produce an output array of the things that intersected.


Declaration

public static int compress(float* output, int index, float4 val, bool4 mask);

Parameters

Parameter Description
output Pointer to packed output array where enabled components should be stored to.
index Index into output array where first enabled component should be stored to.
val The value to to compress.
mask Mask indicating which components are enabled.

Returns

int Index to element after the last one stored.

Description

Packs components with an enabled mask to the left.

This function is also known as left packing. The effect of this function is to filter out components that are not enabled and leave an output buffer tightly packed with only the enabled components. A common use case is if you perform intersection tests on arrays of data in structure of arrays (SoA) form and need to produce an output array of the things that intersected.