Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SortReverseAndStore.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
16{
17 // Sort so that highest values are first (we want to first process closer hits and we process stack top to bottom)
20
21 // Count how many results are less than the max value
23 int num_results = closer.CountTrues();
24
25 // Shift the values so that only the ones that are less than max are kept
26 values = values.ReinterpretAsInt().ShiftComponents4Minus(num_results).ReinterpretAsFloat();
27 ioIdentifiers = ioIdentifiers.ShiftComponents4Minus(num_results);
28
29 // Store the values
30 values.StoreFloat4(reinterpret_cast<Float4 *>(outValues));
31
32 return num_results;
33}
34
40{
41 // Sort the hits
43
44 // Return the amount of hits
45 return inValue.CountTrues();
46}
47
#define JPH_NAMESPACE_END
Definition Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
AllocateFunction Allocate
Definition Memory.cpp:59
JPH_INLINE int CountAndSortTrues(UVec4Arg inValue, UVec4 &ioIdentifiers)
Definition SortReverseAndStore.h:39
JPH_NAMESPACE_BEGIN JPH_INLINE int SortReverseAndStore(Vec4Arg inValues, float inMaxValue, UVec4 &ioIdentifiers, float *outValues)
Definition SortReverseAndStore.h:15
Class that holds 4 float values. Convert to Vec4 to perform calculations.
Definition Float4.h:11
Definition UVec4.h:12
static JPH_INLINE UVec4 sSort4True(UVec4Arg inValue, UVec4Arg inIndex)
Definition UVec4.inl:222
Definition Vec4.h:14
static JPH_INLINE UVec4 sLess(Vec4Arg inV1, Vec4Arg inV2)
Less than (component wise)
Definition Vec4.inl:180
static JPH_INLINE void sSort4Reverse(Vec4 &ioValue, UVec4 &ioIndex)
Definition Vec4.inl:325
static JPH_INLINE Vec4 sReplicate(float inV)
Replicate inV across all components.
Definition Vec4.inl:74