AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
MergeSplitThresholds.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agx/ICloneable.h>
20#include <agx/BitState.h>
22
24
25namespace agxSDK
26{
28
34 {
35 public:
39 using MixFunction = std::function<agx::Real( agx::Real, agx::Real )>;
40
41 public:
45 void set( const agx::UInt index, agx::Real value );
46
50 agx::Real get( const agx::UInt index ) const;
51
55 agx::UInt getNumValues() const;
56
60 agx::Bool isGlobal() const;
61
66 agx::Real get( const agx::UInt index, const MergeSplitThresholds* other, MergeSplitThresholds::MixFunction mixFunc ) const;
67
68 public:
72 virtual void resetToDefault() = 0;
73
76
80 virtual void store( agxStream::OutputArchive& out ) const override;
81
85 virtual void restore( agxStream::InputArchive& in ) override;
86
90 virtual void storeLightData( agxStream::StorageStream& str ) const override;
91
95 virtual void restoreLightData( agxStream::StorageStream& str ) override;
97
98 protected:
102 MergeSplitThresholds( const agx::UInt numValues );
103
108
113 void cloneValuesTo( MergeSplitThresholds& target ) const;
114
115 private:
116 friend class MergeSplitHandler;
117
118 enum BitOptions
119 {
120 GLOBAL_THRESHOLDS = 1 << 0
121 };
122
123 using Options = agx::BitState<BitOptions, agx::Int32>;
124
125 Options& getOptions();
126 const Options& getOptions() const;
127
128 private:
129 agx::RealVector m_values;
130 Options m_options;
131 };
132
134 {
135 agxAssert( index < m_values.size() );
136 return m_values[ index ];
137 }
138
140 {
141 return (agx::UInt)m_values.size();
142 }
143
145 {
146 return m_options.Is( GLOBAL_THRESHOLDS );
147 }
148
149 inline MergeSplitThresholds::Options& MergeSplitThresholds::getOptions()
150 {
151 return m_options;
152 }
153
154 inline const MergeSplitThresholds::Options& MergeSplitThresholds::getOptions() const
155 {
156 return m_options;
157 }
158
160 {
161 // Value from this if:
162 // 1. other is not given
163 // 2. this is identical to other
164 // 3. other is global - i.e., this may contain unique values which overrides global
165 return other == nullptr || this == other || other->isGlobal() ?
166 get( index ) :
167 // Value from other if:
168 // 1. other is given (implicit)
169 // 2. this is global
170 this->isGlobal() ?
171 other->get( index ) :
172 // Mix values if both are given and none is global.
173 mixFunc( get( index ), other->get( index ) );
174 }
175}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
#define AGXPHYSICS_EXPORT
Base class for a merge split algorithm handling a set of merged bodies.
Base class for thresholds/constants/values used in agxSDK::MergeSplitAlgorithm.
void set(const agx::UInt index, agx::Real value)
Assign value given index and value.
virtual void resetToDefault()=0
Restore all thresholds to default.
std::function< agx::Real(agx::Real, agx::Real)> MixFunction
Mixing two values function signature given two values and the return value is the mix.
agx::Real get(const agx::UInt index) const
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
size_t size() const
Definition: Container.h:134
Interface class for a cloneable reference counted object.
Definition: ICloneable.h:30
#define agxAssert(expr)
Definition: debug.h:143
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition: Integer.h:40
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:41