Blender V5.0
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 <gtest/gtest.h>
6
7#include "util/boundbox.h"
8#include "util/transform.h"
9
11
12TEST(BoundBox, transformed)
13{
14 {
15 const Transform tfm = transform_translate(make_float3(1, 2, 3));
16 const BoundBox orig_bounds(make_float3(-2, -3, -4), make_float3(3, 4, 5));
17 const BoundBox transformed_bounds = orig_bounds.transformed(&tfm);
18 EXPECT_LE(len(transformed_bounds.min - make_float3(-1, -1, -1)), 1e-6f);
19 EXPECT_LE(len(transformed_bounds.max - make_float3(4, 6, 8)), 1e-6f);
20 }
21
22 /* Non-valid boundbox should result in non-valid after transform. */
23 {
24 const Transform tfm = transform_scale(make_float3(1, 1, 1));
25 EXPECT_FALSE(BoundBox(BoundBox::empty).transformed(&tfm).valid());
26 }
27}
28
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:280
ccl_device_inline Transform transform_translate(const float3 t)
Definition transform.h:270
CCL_NAMESPACE_BEGIN TEST(BoundBox, transformed)
uint len