Blender V5.3
sculpt_detail_test.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "sculpt_dyntopo.hh"
10
11#include "BKE_gtest_base.hh"
12#include "BKE_object_types.hh"
13
14#include "DNA_object_types.h"
15
16#include "testing/testing.h"
17
19constexpr float CONSTANT_DETAIL = 50.0f;
20constexpr float BRUSH_RADIUS = 0.5f;
21constexpr float PIXEL_RADIUS = 200;
22constexpr float PIXEL_SIZE = 100;
23
25
26TEST_F(SculptDetailConversionTest, ConstantToBrushDetail)
27{
28 bke::ObjectRuntime runtime;
30
31 Object ob;
32 ob.runtime = &runtime;
33
34 const float brush_percent = constant_to_brush_detail(CONSTANT_DETAIL, BRUSH_RADIUS, ob);
35 const float converted = brush_to_detail_size(brush_percent, BRUSH_RADIUS);
36
37 const float expected = constant_to_detail_size(CONSTANT_DETAIL, ob);
38 EXPECT_FLOAT_EQ(expected, converted);
39}
40TEST_F(SculptDetailConversionTest, ConstantToRelativeDetail)
41{
42 bke::ObjectRuntime runtime;
44
45 Object ob;
46 ob.runtime = &runtime;
47
48 const float relative_detail = constant_to_relative_detail(
50 const float converted = relative_to_detail_size(
51 relative_detail, BRUSH_RADIUS, PIXEL_RADIUS, PIXEL_SIZE);
52
53 const float expected = constant_to_detail_size(CONSTANT_DETAIL, ob);
54 EXPECT_FLOAT_EQ(expected, converted);
55}
56} // namespace blender::ed::sculpt_paint::dyntopo::detail_size::test
Object is a sort of wrapper for general info.
TEST_F(SculptDetailConversionTest, ConstantToBrushDetail)
float relative_to_detail_size(const float relative_detail, const float brush_radius, const float pixel_radius, const float pixel_size)
float constant_to_detail_size(const float constant_detail, const Object &ob)
float constant_to_relative_detail(const float constant_detail, const float brush_radius, const float pixel_radius, const float pixel_size, const Object &ob)
float constant_to_brush_detail(const float constant_detail, const float brush_radius, const Object &ob)
float brush_to_detail_size(const float brush_percent, const float brush_radius)
static MatBase identity()
bke::ObjectRuntime * runtime