This adds a new Camera Info node to Geometry Nodes. It provides information about the passed in camera like its projection matrix and focus distance. This can be used for camera culling which was must more complex before. It also allows building other view-dependent effects. Pull Request: https://projects.blender.org/blender/blender/pulls/135311
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
* The macros below reduce the boilerplate needed to implement basic equality operators for
|
|
* structs. These macros could be removed starting with C++20, because then we can use defaulted
|
|
* comparison operators: https://en.cppreference.com/w/cpp/language/default_comparisons
|
|
*
|
|
* Using these macros also reduces the probably for common typos, like comparing a value to itself
|
|
* or comparing the same value twice.
|
|
*/
|
|
|
|
#define BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type) \
|
|
friend bool operator!=(const Type &a, const Type &b) \
|
|
{ \
|
|
return !(a == b); \
|
|
}
|
|
|
|
#define BLI_STRUCT_EQUALITY_OPERATORS_1(Type, m) \
|
|
friend bool operator==(const Type &a, const Type &b) \
|
|
{ \
|
|
return a.m == b.m; \
|
|
} \
|
|
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
|
|
|
|
#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2) \
|
|
friend bool operator==(const Type &a, const Type &b) \
|
|
{ \
|
|
return a.m1 == b.m1 && a.m2 == b.m2; \
|
|
} \
|
|
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
|
|
|
|
#define BLI_STRUCT_EQUALITY_OPERATORS_3(Type, m1, m2, m3) \
|
|
friend bool operator==(const Type &a, const Type &b) \
|
|
{ \
|
|
return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3; \
|
|
} \
|
|
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
|
|
|
|
#define BLI_STRUCT_EQUALITY_OPERATORS_4(Type, m1, m2, m3, m4) \
|
|
friend bool operator==(const Type &a, const Type &b) \
|
|
{ \
|
|
return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4; \
|
|
} \
|
|
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
|
|
|
|
#define BLI_STRUCT_EQUALITY_OPERATORS_5(Type, m1, m2, m3, m4, m5) \
|
|
friend bool operator==(const Type &a, const Type &b) \
|
|
{ \
|
|
return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4 && a.m5 == b.m5; \
|
|
} \
|
|
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
|
|
|
|
#define BLI_STRUCT_EQUALITY_OPERATORS_6(Type, m1, m2, m3, m4, m5, m6) \
|
|
friend bool operator==(const Type &a, const Type &b) \
|
|
{ \
|
|
return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4 && a.m5 == b.m5 && \
|
|
a.m6 == b.m6; \
|
|
} \
|
|
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
|