Files
test/source/blender/blenkernel/intern/subdiv_ccg_test.cc
Sergey Sharybin e0154de320 Rework Bake from Multires
The main idea is to switch Bake from Multires from legacy DerivedMesh
to Subdiv. On the development side of things this change removes a lot
of code, also making it easier easier to rework CustomData and related
topics, without being pulled down by the DerivedMesh.

On the user level switch to Subdiv means:

- Much more closer handling of the multi-resolution data: the derived
  mesh code was close, but not exactly the same when it comes to the
  final look of mesh.

  Other than less obvious cases (like old DerivedMesh approach doing
  recursive subdivision instead of pushing subdivided vertices on the
  limit surface) there are more obvious ones like difference in edge
  creases, and non-supported vertex creases by the DerivedMesh.

- UV interpolation is done correctly now when baking to non-base level
  (baking to multi-resolution level >= 1).

  Previously in this case the old derived mesh interpolation was used
  to interpolate face-varying data, which gives different results from
  the OpenSubdiv interpolation.

- Ngon faces are properly supported now.

A possible remaining issue is the fact that getting normal from CCG
always uses smooth interpolation. Based on the code it always has been
the case, so while it is something to look into it might be considered
a separate topic to dig into.
2025-08-22 17:59:27 +02:00

63 lines
1.4 KiB
C++

/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "testing/testing.h"
#include "BKE_ccg.hh"
#include "BKE_subdiv_ccg.hh"
namespace blender::bke::tests {
TEST(subdiv_ccg_coord, to_index)
{
CCGKey key;
key.level = 2;
key.elem_size = sizeof(float);
key.has_normals = false;
key.has_mask = false;
key.normal_offset = -1;
key.mask_offset = -1;
key.grid_size = CCG_grid_size(key.level); /* 3 */
key.grid_area = key.grid_size * key.grid_size; /* 9 */
key.grid_bytes = key.grid_area * key.elem_size;
SubdivCCGCoord coord;
coord.grid_index = 2;
coord.x = 1;
coord.y = 1;
/* (grid_index * grid_area) + y * grid_size + x */
/* (2 * 9) + (1 * 3) + 1 */
EXPECT_EQ(coord.to_index(key), 22);
}
TEST(subdiv_ccg_coord, constructor)
{
CCGKey key;
key.level = 2;
key.elem_size = sizeof(float);
key.has_normals = false;
key.has_mask = false;
key.normal_offset = -1;
key.mask_offset = -1;
key.grid_size = CCG_grid_size(key.level); /* 3 */
key.grid_area = key.grid_size * key.grid_size; /* 9 */
key.grid_bytes = key.grid_area * key.elem_size;
SubdivCCGCoord coord = SubdivCCGCoord::from_index(key, 22);
coord.grid_index = 2;
coord.x = 1;
coord.y = 1;
EXPECT_EQ(coord.grid_index, 2);
EXPECT_EQ(coord.x, 1);
EXPECT_EQ(coord.y, 1);
}
} // namespace blender::bke::tests