Blender V4.5
util_boundbox_test.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2025 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "util/boundbox.h"
6
7#include "testing/testing.h"
8
9#include "util/transform.h"
10
12
13TEST(BoundBox, transformed)
14{
15 {
16 const Transform tfm = transform_translate(make_float3(1, 2, 3));
17 const BoundBox orig_bounds(make_float3(-2, -3, -4), make_float3(3, 4, 5));
18 const BoundBox transformed_bounds = orig_bounds.transformed(&tfm);
19 EXPECT_LE(len(transformed_bounds.min - make_float3(-1, -1, -1)), 1e-6f);
20 EXPECT_LE(len(transformed_bounds.max - make_float3(4, 6, 8)), 1e-6f);
21 }
22
23 /* Non-valid boundbox should result in non-valid after transform. */
24 {
25 const Transform tfm = transform_scale(make_float3(1, 1, 1));
26 EXPECT_FALSE(BoundBox(BoundBox::empty).transformed(&tfm).valid());
27 }
28}
29
struct BoundBox BoundBox
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
BoundBox transformed(const Transform *tfm) const
Definition boundbox.h:134
float3 max
Definition boundbox.h:20
float3 min
Definition boundbox.h:20
ccl_device_inline Transform transform_scale(const float3 s)
Definition transform.h:247
ccl_device_inline Transform transform_translate(const float3 t)
Definition transform.h:237
CCL_NAMESPACE_BEGIN TEST(BoundBox, transformed)
uint len