|
CeresEngine 0.2.0
A game development framework
|
Every constraint has a strength that determines where it sits in the hierarchy; strong constraints are always satisfied in preference to weaker ones. More...
#include <CeresEngine/Foundation/Constraint/ConstraintStrength.hpp>
Public Member Functions | |
| constexpr | ConstraintStrength (const ConstraintSymbolicWeight &symbolicWeight, const double w) |
| constexpr | ConstraintStrength (const double a, const double b, const double c, const double w=1.0) |
| Construct a strength from three weight factors. | |
| bool | isRequired () const |
| Check if this strength signals a required constraint. | |
| const ConstraintSymbolicWeight & | getSymbolicWeight () const |
| Get the 3-tuple symbolic weight. | |
| double | getWeight () const |
| Get the 3-tuple symbolic weight. | |
| double | getAdjustedWeight () const |
| Gets the adjusted weight as a double. | |
Static Public Attributes | |
| static const ConstraintStrength | required |
| Constraints with this strength must be satisfied. | |
| static const ConstraintStrength | strong {1, 0, 0} |
| The default strength for edit constraints. | |
| static const ConstraintStrength | medium {0, 1, 0} |
| Medium constraint strength. | |
| static const ConstraintStrength | weak {0, 0, 1} |
| The default strength for stay constraints. | |
Private Attributes | |
| ConstraintSymbolicWeight | mSymbolicWeight |
| double | mWeight = 1.0 |
Friends | |
| bool | operator== (const ConstraintStrength &lhs, const ConstraintStrength &rhs) |
| bool | operator!= (const ConstraintStrength &lhs, const ConstraintStrength &rhs) |
| bool | operator<= (const ConstraintStrength &lhs, const ConstraintStrength &rhs) |
| bool | operator< (const ConstraintStrength &lhs, const ConstraintStrength &rhs) |
| bool | operator>= (const ConstraintStrength &lhs, const ConstraintStrength &rhs) |
| bool | operator> (const ConstraintStrength &lhs, const ConstraintStrength &rhs) |
| ConstraintStrength | operator* (ConstraintStrength lhs, double w) |
Every constraint has a strength that determines where it sits in the hierarchy; strong constraints are always satisfied in preference to weaker ones.
Since we want to be able to express preferences as well as requirements in the constraint system, we need a specification for how conflicting preferences are to be traded off. In a constraint hierarchy each constraint has a strength. The 'required' strength is special, in that required constraints must be satisfied. The other strengths all label non- required constraints.
A constraint of a given strength completely dominates any constraint with a weaker strength. In the hierarchy theory, a comparator is used to compare different possible solutions to the constraints and select among them. Within this framework a number of variations are possible.
One decision is whether we only compare solutions on a constraint-by-constraint basis (a local comparator), or whether we take some aggregate measure of the unsatisfied constraints of a given strength (a global comparator). A second choice is whether we are concerned only whether a constraint is satisfied or not (a predicate comparator), or whether we also want to know how nearly satisfied it is (a metric comparator).
Constraints whose domain is a metric space, for example the reals, can have an associated error function. The error in satisfying a constraint is zero if and only if the constraint is satisfied, and becomes larger the less nearly satisfied it is. For a given collection of constraints, Cassowary finds a locally-error-better or a weighted-sum-better solution.
|
inlineconstexpr |
|
inlineconstexpr |
Construct a strength from three weight factors.
| a | 'Strong' weight |
| b | 'Medium weight |
| c | 'Weak' weight |
| w | The weight factor. |
|
inline |
Gets the adjusted weight as a double.
|
inline |
Get the 3-tuple symbolic weight.
|
inline |
Get the 3-tuple symbolic weight.
|
inline |
Check if this strength signals a required constraint.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
inlinestatic |
Medium constraint strength.
|
private |
|
private |
|
inlinestatic |
Constraints with this strength must be satisfied.
Used by default for constraints provided by the programmer.
|
inlinestatic |
The default strength for edit constraints.
|
inlinestatic |
The default strength for stay constraints.